1/*
2 * Copyright (c) 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1.  Redistributions of source code must retain the above copyright
11 *     notice, this list of conditions and the following disclaimer.
12 * 2.  Redistributions in binary form must reproduce the above copyright
13 *     notice, this list of conditions and the following disclaimer in the
14 *     documentation and/or other materials provided with the distribution.
15 * 3.  Neither the name of Apple Inc. ("Apple") nor the names of its
16 *     contributors may be used to endorse or promote products derived from
17 *     this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * Portions of this software have been released under the following terms:
31 *
32 * (c) Copyright 1989-1993 OPEN SOFTWARE FOUNDATION, INC.
33 * (c) Copyright 1989-1993 HEWLETT-PACKARD COMPANY
34 * (c) Copyright 1989-1993 DIGITAL EQUIPMENT CORPORATION
35 *
36 * To anyone who acknowledges that this file is provided "AS IS"
37 * without any express or implied warranty:
38 * permission to use, copy, modify, and distribute this file for any
39 * purpose is hereby granted without fee, provided that the above
40 * copyright notices and this notice appears in all source code copies,
41 * and that none of the names of Open Software Foundation, Inc., Hewlett-
42 * Packard Company or Digital Equipment Corporation be used
43 * in advertising or publicity pertaining to distribution of the software
44 * without specific, written prior permission.  Neither Open Software
45 * Foundation, Inc., Hewlett-Packard Company nor Digital
46 * Equipment Corporation makes any representations about the suitability
47 * of this software for any purpose.
48 *
49 * Copyright (c) 2007, Novell, Inc. All rights reserved.
50 * Redistribution and use in source and binary forms, with or without
51 * modification, are permitted provided that the following conditions
52 * are met:
53 *
54 * 1.  Redistributions of source code must retain the above copyright
55 *     notice, this list of conditions and the following disclaimer.
56 * 2.  Redistributions in binary form must reproduce the above copyright
57 *     notice, this list of conditions and the following disclaimer in the
58 *     documentation and/or other materials provided with the distribution.
59 * 3.  Neither the name of Novell Inc. nor the names of its contributors
60 *     may be used to endorse or promote products derived from this
61 *     this software without specific prior written permission.
62 *
63 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
64 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
65 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
66 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY
67 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
68 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
69 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
70 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
71 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
72 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
73 *
74 * @APPLE_LICENSE_HEADER_END@
75 */
76
77/*
78**
79**  NAME
80**
81**      ERRORS.H
82**
83**  FACILITY:
84**
85**      Interface Definition Language (IDL) Compiler
86**
87**  ABSTRACT:
88**
89**
90**
91**  VERSION: DCE 1.0
92**
93*/
94
95#ifndef ERRORS_H
96#define ERRORS_H
97
98#include <errno.h>
99#include <nidl.h>
100#include <nametbl.h>
101
102#define IDL_ERROR_LIST_SIZE 5
103
104/* An opaque pointer. */
105#ifndef YY_TYPEDEF_YY_SCANNER_T
106#define YY_TYPEDEF_YY_SCANNER_T
107typedef void* yyscan_t;
108#endif
109
110void error
111(
112	long msg_id,
113	...
114);
115
116void warning
117(
118	long msg_id,
119	...
120);
121
122void vlog_source_error
123(
124 STRTAB_str_t filename,
125 int lineno,
126 long msg_id,
127 va_list ap
128);
129
130void log_source_error
131(
132	/* it is not a nonsense */
133	STRTAB_str_t filename,
134	int lineno,
135	long msg_id,
136	... /* 0..5 args terminated by NULL if less than five */
137);
138
139void vlog_source_warning
140(
141 STRTAB_str_t filename,
142 int lineno,
143 long msg_id,
144 va_list ap
145 );
146
147void log_source_warning
148(
149	/* it is not a nonsense */
150	STRTAB_str_t filename,
151	int lineno,
152	long msg_id,
153	... /* 0..5 args terminated by NULL if less than five */
154);
155
156void vlog_error
157(
158 /* it is not a nonsense */
159 int lineno, /* Source line number */
160 long msg_id, /* Message ID */
161 va_list ap
162);
163
164void log_error
165(
166	/* it is not a nonsense */
167	int lineno, /* Source line number */
168	long msg_id, /* Message ID */
169	... /* 0..5 args terminated by NULL if less than five */
170);
171
172void vlog_warning
173(
174 /* it is not a nonsense */
175 int lineno, /* Source line number */
176 long msg_id, /* Message ID */
177 va_list ap
178);
179
180void log_warning
181(
182	/* it is not a nonsense */
183	int lineno, /* Source line number */
184	long msg_id, /* Message ID */
185	... /* 0..5 args terminated by NULL if less than five */
186);
187
188typedef struct {
189    long msg_id;
190    const void* arg[IDL_ERROR_LIST_SIZE];
191} idl_error_list_t;
192
193typedef idl_error_list_t *idl_error_list_p;
194
195void error_list
196(
197    int vecsize,
198    idl_error_list_p errvec,
199    boolean exitflag
200);
201
202void inq_name_for_errors
203(
204    char *name,
205	size_t name_len
206);
207
208void set_name_for_errors
209(
210    char const *name
211);
212
213boolean print_errors
214(
215    void
216);
217
218#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
219typedef struct YYLTYPE
220{
221    int first_line;
222    int first_column;
223    int last_line;
224    int last_column;
225} YYLTYPE;
226# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
227# define YYLTYPE_IS_DECLARED 1
228# define YYLTYPE_IS_TRIVIAL 1
229#endif
230
231struct parser_location_t;
232
233void idl_yyerror
234(
235    const struct parser_location_t * location,
236    char const * message
237);
238
239void yywhere
240(
241    const struct parser_location_t * location
242);
243
244/*
245 * Error info to be fillin the fe_info nodes
246 */
247extern int          error_count;
248
249/* XXX These globals are set and unset in the NIDL and ACF parsers in
250 * xxx_input() and xxx_parser_destroy(). They should be more-or-less
251 * accurate, but it would be better to continue plumbing the
252 * parser_location_t down into error() and warning() so that we can
253 * get rid of this ugliness.
254 */
255
256extern FILE    *yyin_p;           /* Points to yyin or acf_yyin */
257extern unsigned*yylineno_p;       /* Points to yylineno or acf_yylineno */
258
259#ifdef DUMPERS
260#define INTERNAL_ERROR(string) {printf("Internal Error Diagnostic: %s\n",string);warning(NIDL_INTERNAL_ERROR,__FILE__,__LINE__);}
261#else
262#define INTERNAL_ERROR(string) {error(NIDL_INTERNAL_ERROR,__FILE__,__LINE__); printf(string);}
263#endif
264#endif
265/* preserve coding style vim: set tw=78 sw=4 : */
266