1 |
edhill |
1.1 |
/* $XConsortium: def.h,v 1.25 94/04/17 20:10:33 gildea Exp $ */ |
2 |
|
|
|
3 |
|
|
/* |
4 |
|
|
* Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved. |
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 |
|
|
* |
13 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
14 |
|
|
* notice, this list of conditions and the following disclaimer in |
15 |
|
|
* the documentation and/or other materials provided with the |
16 |
|
|
* distribution. |
17 |
|
|
* |
18 |
|
|
* 3. The name "Carnegie Mellon University" must not be used to |
19 |
|
|
* endorse or promote products derived from this software without |
20 |
|
|
* prior written permission. For permission or any other legal |
21 |
|
|
* details, please contact |
22 |
|
|
* Office of Technology Transfer |
23 |
|
|
* Carnegie Mellon University |
24 |
|
|
* 5000 Forbes Avenue |
25 |
|
|
* Pittsburgh, PA 15213-3890 |
26 |
|
|
* (412) 268-4387, fax: (412) 268-7395 |
27 |
|
|
* tech-transfer@andrew.cmu.edu |
28 |
|
|
* |
29 |
|
|
* 4. Redistributions of any form whatsoever must retain the following |
30 |
|
|
* acknowledgment: |
31 |
|
|
* "This product includes software developed by Computing Services |
32 |
|
|
* at Carnegie Mellon University (http://www.cmu.edu/computing/)." |
33 |
|
|
* |
34 |
|
|
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO |
35 |
|
|
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
36 |
|
|
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE |
37 |
|
|
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
38 |
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN |
39 |
|
|
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING |
40 |
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
41 |
|
|
* |
42 |
|
|
*/ |
43 |
|
|
/* |
44 |
|
|
|
45 |
|
|
Copyright (c) 1993, 1994 X Consortium |
46 |
|
|
|
47 |
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
48 |
|
|
of this software and associated documentation files (the "Software"), to deal |
49 |
|
|
in the Software without restriction, including without limitation the rights |
50 |
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
51 |
|
|
copies of the Software, and to permit persons to whom the Software is |
52 |
|
|
furnished to do so, subject to the following conditions: |
53 |
|
|
|
54 |
|
|
The above copyright notice and this permission notice shall be included in |
55 |
|
|
all copies or substantial portions of the Software. |
56 |
|
|
|
57 |
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
58 |
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
59 |
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
60 |
|
|
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
61 |
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
62 |
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
63 |
|
|
|
64 |
|
|
Except as contained in this notice, the name of the X Consortium shall not be |
65 |
|
|
used in advertising or otherwise to promote the sale, use or other dealings |
66 |
|
|
in this Software without prior written authorization from the X Consortium. |
67 |
|
|
|
68 |
|
|
*/ |
69 |
|
|
|
70 |
|
|
#include <stdio.h> |
71 |
|
|
#include <ctype.h> |
72 |
|
|
#include <sys/types.h> |
73 |
|
|
#include <fcntl.h> |
74 |
|
|
#include <sys/stat.h> |
75 |
|
|
|
76 |
edhill |
1.2 |
/* === EH3 === |
77 |
edhill |
1.1 |
#define MAXDEFINES 512 |
78 |
|
|
#define MAXFILES 512 |
79 |
edhill |
1.2 |
=== EH3 === */ |
80 |
edhill |
1.3 |
#define MAXDEFINES 4096 |
81 |
|
|
#define MAXFILES 4096 |
82 |
edhill |
1.2 |
/* === EH3 === */ |
83 |
edhill |
1.3 |
#define MAXDIRS 256 |
84 |
edhill |
1.1 |
#define SYMTABINC 10 /* must be > 1 for define() to work right */ |
85 |
|
|
#define TRUE 1 |
86 |
|
|
#define FALSE 0 |
87 |
|
|
|
88 |
|
|
/* the following must match the directives table in main.c */ |
89 |
|
|
#define IF 0 |
90 |
|
|
#define IFDEF 1 |
91 |
|
|
#define IFNDEF 2 |
92 |
|
|
#define ELSE 3 |
93 |
|
|
#define ENDIF 4 |
94 |
|
|
#define DEFINE 5 |
95 |
|
|
#define UNDEF 6 |
96 |
|
|
#define INCLUDE 7 |
97 |
|
|
#define LINE 8 |
98 |
|
|
#define PRAGMA 9 |
99 |
|
|
#define ERROR 10 |
100 |
|
|
#define IDENT 11 |
101 |
|
|
#define SCCS 12 |
102 |
|
|
#define ELIF 13 |
103 |
|
|
#define EJECT 14 |
104 |
|
|
#define IFFALSE 15 /* pseudo value --- never matched */ |
105 |
|
|
#define ELIFFALSE 16 /* pseudo value --- never matched */ |
106 |
|
|
#define INCLUDEDOT 17 /* pseudo value --- never matched */ |
107 |
|
|
#define IFGUESSFALSE 18 /* pseudo value --- never matched */ |
108 |
|
|
#define ELIFGUESSFALSE 19 /* pseudo value --- never matched */ |
109 |
|
|
|
110 |
|
|
#ifdef DEBUG |
111 |
|
|
extern int _debugmask; |
112 |
|
|
/* |
113 |
|
|
* debug levels are: |
114 |
|
|
* |
115 |
|
|
* 0 show ifn*(def)*,endif |
116 |
|
|
* 1 trace defined/!defined |
117 |
|
|
* 2 show #include |
118 |
|
|
* 3 show #include SYMBOL |
119 |
|
|
* 4-6 unused |
120 |
|
|
*/ |
121 |
|
|
#define debug(level,arg) { if (_debugmask & (1 << level)) warning arg; } |
122 |
|
|
#else |
123 |
|
|
#define debug(level,arg) /**/ |
124 |
|
|
#endif /* DEBUG */ |
125 |
|
|
|
126 |
|
|
typedef unsigned char boolean; |
127 |
|
|
|
128 |
|
|
struct symtab { |
129 |
|
|
char *s_name; |
130 |
|
|
char *s_value; |
131 |
|
|
}; |
132 |
|
|
|
133 |
|
|
struct inclist { |
134 |
|
|
char *i_incstring; /* string from #include line */ |
135 |
|
|
char *i_file; /* path name of the include file */ |
136 |
|
|
struct inclist **i_list; /* list of files it itself includes */ |
137 |
|
|
int i_listlen; /* length of i_list */ |
138 |
|
|
struct symtab *i_defs; /* symbol table for this file */ |
139 |
|
|
int i_ndefs; /* current # defines */ |
140 |
|
|
int i_deflen; /* amount of space in table */ |
141 |
|
|
boolean i_defchecked; /* whether defines have been checked */ |
142 |
|
|
boolean i_notified; /* whether we have revealed includes */ |
143 |
|
|
boolean i_marked; /* whether it's in the makefile */ |
144 |
|
|
boolean i_searched; /* whether we have read this */ |
145 |
|
|
boolean i_included_sym; /* whether #include SYMBOL was found */ |
146 |
|
|
/* Can't use i_list if TRUE */ |
147 |
|
|
}; |
148 |
|
|
|
149 |
|
|
struct filepointer { |
150 |
|
|
char *f_p; |
151 |
|
|
char *f_base; |
152 |
|
|
char *f_end; |
153 |
|
|
long f_len; |
154 |
|
|
long f_line; |
155 |
|
|
}; |
156 |
|
|
|
157 |
|
|
#ifndef NO_STDLIB_H /* X_NOT_STDC_ENV */ |
158 |
|
|
#include <stdlib.h> |
159 |
|
|
#if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */ |
160 |
|
|
char *malloc(), *realloc(); |
161 |
|
|
#endif /* macII */ |
162 |
|
|
#else |
163 |
|
|
char *malloc(); |
164 |
|
|
char *realloc(); |
165 |
|
|
#endif |
166 |
|
|
|
167 |
|
|
char *copy(); |
168 |
|
|
char *base_name(); |
169 |
|
|
char *getline(); |
170 |
|
|
struct symtab *slookup(); |
171 |
|
|
struct symtab *isdefined(); |
172 |
|
|
struct symtab *fdefined(); |
173 |
|
|
struct filepointer *getfile(); |
174 |
|
|
struct inclist *newinclude(); |
175 |
|
|
struct inclist *inc_path(); |
176 |
|
|
|
177 |
|
|
#ifdef HAVE_STDARG_H /* NeedVarargsPrototypes */ |
178 |
|
|
extern fatalerr(char *, ...); |
179 |
|
|
extern warning(char *, ...); |
180 |
|
|
extern warning1(char *, ...); |
181 |
|
|
#endif |