tell openssl to look for the ca-bundle.crt in our common location
[AROS-Contrib.git] / development / build / makedepend / cppsetup.c
blob5ec48c4131933b113324d0c45133ac3485210bbf
1 /* $Xorg: cppsetup.c,v 1.3 2000/08/17 19:41:50 cpqbld Exp $ */
2 /*
4 Copyright (c) 1993, 1994, 1998 The Open Group
6 All Rights Reserved.
8 The above copyright notice and this permission notice shall be included in
9 all copies or substantial portions of the Software.
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
15 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 Except as contained in this notice, the name of The Open Group shall not be
19 used in advertising or otherwise to promote the sale, use or other dealings
20 in this Software without prior written authorization from The Open Group.
23 /* $XFree86: xc/config/makedepend/cppsetup.c,v 3.9 2001/04/29 23:25:02 tsi Exp $ */
25 #include "def.h"
27 #ifdef CPP
29 * This file is strictly for the sake of cpy.y and yylex.c (if
30 * you indeed have the source for cpp).
32 #define IB 1
33 #define SB 2
34 #define NB 4
35 #define CB 8
36 #define QB 16
37 #define WB 32
38 #define SALT '#'
39 #if defined(pdp11) || defined(vax) || defined(ns16000) || defined(mc68000) || defined(ibm032)
40 #define COFF 128
41 #else
42 #define COFF 0
43 #endif
45 * These variables used by cpy.y and yylex.c
47 extern char *outp, *inp, *newp, *pend;
48 extern char *ptrtab;
49 extern char fastab[];
50 extern char slotab[];
53 * cppsetup
55 struct filepointer *currentfile;
56 struct inclist *currentinc;
58 int
59 cppsetup(char *line, struct filepointer *filep, struct inclist *inc)
61 char *p, savec;
62 static boolean setupdone = FALSE;
63 boolean value;
65 if (!setupdone) {
66 cpp_varsetup();
67 setupdone = TRUE;
70 currentfile = filep;
71 currentinc = inc;
72 inp = newp = line;
73 for (p=newp; *p; p++)
77 * put a newline back on the end, and set up pend, etc.
79 *p++ = '\n';
80 savec = *p;
81 *p = '\0';
82 pend = p;
84 ptrtab = slotab+COFF;
85 *--inp = SALT;
86 outp=inp;
87 value = yyparse();
88 *p = savec;
89 return(value);
92 struct symtab **lookup(symbol)
93 char *symbol;
95 static struct symtab *undefined;
96 struct symtab **sp;
98 sp = isdefined(symbol, currentinc, NULL);
99 if (sp == NULL) {
100 sp = &undefined;
101 (*sp)->s_value = NULL;
103 return (sp);
106 pperror(tag, x0,x1,x2,x3,x4)
107 int tag,x0,x1,x2,x3,x4;
109 warning("\"%s\", line %d: ", currentinc->i_file, currentfile->f_line);
110 warning(x0,x1,x2,x3,x4);
114 yyerror(s)
115 register char *s;
117 fatalerr("Fatal error: %s\n", s);
119 #else /* not CPP */
121 #include "ifparser.h"
122 struct _parse_data {
123 struct filepointer *filep;
124 struct inclist *inc;
125 const char *line;
128 static const char *
129 my_if_errors (IfParser *ip, const char *cp, const char *expecting)
131 struct _parse_data *pd = (struct _parse_data *) ip->data;
132 int lineno = pd->filep->f_line;
133 char *filename = pd->inc->i_file;
134 char prefix[300];
135 int prefixlen;
136 int i;
138 sprintf (prefix, "\"%s\":%d", filename, lineno);
139 prefixlen = strlen(prefix);
140 fprintf (stderr, "%s: %s", prefix, pd->line);
141 i = cp - pd->line;
142 if (i > 0 && pd->line[i-1] != '\n') {
143 putc ('\n', stderr);
145 for (i += prefixlen + 3; i > 0; i--) {
146 putc (' ', stderr);
148 fprintf (stderr, "^--- expecting %s\n", expecting);
149 return NULL;
153 #define MAXNAMELEN 256
155 static struct symtab **
156 lookup_variable (IfParser *ip, const char *var, int len)
158 char tmpbuf[MAXNAMELEN + 1];
159 struct _parse_data *pd = (struct _parse_data *) ip->data;
161 if (len > MAXNAMELEN)
162 return 0;
164 strncpy (tmpbuf, var, len);
165 tmpbuf[len] = '\0';
166 return isdefined (tmpbuf, pd->inc, NULL);
170 static int
171 my_eval_defined (IfParser *ip, const char *var, int len)
173 if (lookup_variable (ip, var, len))
174 return 1;
175 else
176 return 0;
179 #define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')
181 static long
182 my_eval_variable (IfParser *ip, const char *var, int len)
184 long val;
185 struct symtab **s;
187 s = lookup_variable (ip, var, len);
188 if (!s)
189 return 0;
190 do {
191 var = (*s)->s_value;
192 if (!isvarfirstletter(*var) || !strcmp((*s)->s_name, var))
193 break;
194 s = lookup_variable (ip, var, strlen(var));
195 } while (s);
197 var = ParseIfExpression(ip, var, &val);
198 if (var && *var) debug(4, ("extraneous: '%s'\n", var));
199 return val;
203 cppsetup(char *line, struct filepointer *filep, struct inclist *inc)
205 IfParser ip;
206 struct _parse_data pd;
207 long val = 0;
209 pd.filep = filep;
210 pd.inc = inc;
211 pd.line = line;
212 ip.funcs.handle_error = my_if_errors;
213 ip.funcs.eval_defined = my_eval_defined;
214 ip.funcs.eval_variable = my_eval_variable;
215 ip.data = (char *) &pd;
217 (void) ParseIfExpression (&ip, line, &val);
218 if (val)
219 return IF;
220 else
221 return IFFALSE;
223 #endif /* CPP */