1/*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23#define __darwin_i386_exception_state i386_exception_state
24#define __darwin_i386_float_state i386_float_state
25#define __darwin_i386_thread_state i386_thread_state
26
27#include <stdarg.h>
28#include "stuff/ofile.h"
29#include "stuff/print.h"
30#include "stuff/errors.h"
31
32__private_extern__
33void
34archive_error(
35struct ofile *ofile,
36const char *format, ...)
37{
38    va_list ap;
39
40	va_start(ap, format);
41	if(ofile->file_type == OFILE_FAT){
42	    print("%s: for architecture %s archive: %s ",
43		  progname, ofile->arch_flag.name, ofile->file_name);
44	}
45	else{
46	    print("%s: archive: %s ", progname, ofile->file_name);
47	}
48	vprint(format, ap);
49        print("\n");
50	va_end(ap);
51	errors++;
52}
53
54__private_extern__
55void
56archive_member_error(
57struct ofile *ofile,
58const char *format, ...)
59{
60    va_list ap;
61
62	va_start(ap, format);
63	if(ofile->file_type == OFILE_FAT){
64	    print("%s: for architecture %s archive member: %s(%.*s) ",
65		  progname, ofile->arch_flag.name, ofile->file_name,
66		  (int)ofile->member_name_size, ofile->member_name);
67	}
68	else{
69	    print("%s: archive member: %s(%.*s) ", progname, ofile->file_name,
70		  (int)ofile->member_name_size, ofile->member_name);
71	}
72	vprint(format, ap);
73        print("\n");
74	va_end(ap);
75	errors++;
76}
77
78#ifndef OTOOL
79__private_extern__
80void
81Mach_O_error(
82struct ofile *ofile,
83const char *format, ...)
84{
85    va_list ap;
86
87	va_start(ap, format);
88	if(ofile->file_type == OFILE_FAT){
89	    if(ofile->arch_type == OFILE_ARCHIVE){
90		print("%s: for architecture %s object: %s(%.*s) ", progname,
91		      ofile->arch_flag.name, ofile->file_name,
92		      (int)ofile->member_name_size, ofile->member_name);
93	    }
94	    else{
95		print("%s: for architecture %s object: %s ", progname,
96		      ofile->arch_flag.name, ofile->file_name);
97	    }
98	}
99	else if(ofile->file_type == OFILE_ARCHIVE){
100	    if(ofile->member_type == OFILE_FAT){
101		print("%s: for object: %s(%.*s) architecture %s ", progname,
102		      ofile->file_name, (int)ofile->member_name_size,
103		      ofile->arch_flag.name, ofile->member_name);
104	    }
105	    else{
106		print("%s: object: %s(%.*s) ", progname, ofile->file_name,
107		      (int)ofile->member_name_size, ofile->member_name);
108	    }
109	}
110	else{
111	    print("%s: object: %s ", progname, ofile->file_name);
112	}
113	vprint(format, ap);
114        print("\n");
115	va_end(ap);
116	errors++;
117}
118#endif /* !defined(OTOOL) */
119