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 |
|
|
#define MAXDEFINES 512 |
77 |
|
|
#define MAXFILES 512 |
78 |
|
|
#define MAXDIRS 64 |
79 |
|
|
#define SYMTABINC 10 /* must be > 1 for define() to work right */ |
80 |
|
|
#define TRUE 1 |
81 |
|
|
#define FALSE 0 |
82 |
|
|
|
83 |
|
|
/* the following must match the directives table in main.c */ |
84 |
|
|
#define IF 0 |
85 |
|
|
#define IFDEF 1 |
86 |
|
|
#define IFNDEF 2 |
87 |
|
|
#define ELSE 3 |
88 |
|
|
#define ENDIF 4 |
89 |
|
|
#define DEFINE 5 |
90 |
|
|
#define UNDEF 6 |
91 |
|
|
#define INCLUDE 7 |
92 |
|
|
#define LINE 8 |
93 |
|
|
#define PRAGMA 9 |
94 |
|
|
#define ERROR 10 |
95 |
|
|
#define IDENT 11 |
96 |
|
|
#define SCCS 12 |
97 |
|
|
#define ELIF 13 |
98 |
|
|
#define EJECT 14 |
99 |
|
|
#define IFFALSE 15 /* pseudo value --- never matched */ |
100 |
|
|
#define ELIFFALSE 16 /* pseudo value --- never matched */ |
101 |
|
|
#define INCLUDEDOT 17 /* pseudo value --- never matched */ |
102 |
|
|
#define IFGUESSFALSE 18 /* pseudo value --- never matched */ |
103 |
|
|
#define ELIFGUESSFALSE 19 /* pseudo value --- never matched */ |
104 |
|
|
|
105 |
|
|
#ifdef DEBUG |
106 |
|
|
extern int _debugmask; |
107 |
|
|
/* |
108 |
|
|
* debug levels are: |
109 |
|
|
* |
110 |
|
|
* 0 show ifn*(def)*,endif |
111 |
|
|
* 1 trace defined/!defined |
112 |
|
|
* 2 show #include |
113 |
|
|
* 3 show #include SYMBOL |
114 |
|
|
* 4-6 unused |
115 |
|
|
*/ |
116 |
|
|
#define debug(level,arg) { if (_debugmask & (1 << level)) warning arg; } |
117 |
|
|
#else |
118 |
|
|
#define debug(level,arg) /**/ |
119 |
|
|
#endif /* DEBUG */ |
120 |
|
|
|
121 |
|
|
typedef unsigned char boolean; |
122 |
|
|
|
123 |
|
|
struct symtab { |
124 |
|
|
char *s_name; |
125 |
|
|
char *s_value; |
126 |
|
|
}; |
127 |
|
|
|
128 |
|
|
struct inclist { |
129 |
|
|
char *i_incstring; /* string from #include line */ |
130 |
|
|
char *i_file; /* path name of the include file */ |
131 |
|
|
struct inclist **i_list; /* list of files it itself includes */ |
132 |
|
|
int i_listlen; /* length of i_list */ |
133 |
|
|
struct symtab *i_defs; /* symbol table for this file */ |
134 |
|
|
int i_ndefs; /* current # defines */ |
135 |
|
|
int i_deflen; /* amount of space in table */ |
136 |
|
|
boolean i_defchecked; /* whether defines have been checked */ |
137 |
|
|
boolean i_notified; /* whether we have revealed includes */ |
138 |
|
|
boolean i_marked; /* whether it's in the makefile */ |
139 |
|
|
boolean i_searched; /* whether we have read this */ |
140 |
|
|
boolean i_included_sym; /* whether #include SYMBOL was found */ |
141 |
|
|
/* Can't use i_list if TRUE */ |
142 |
|
|
}; |
143 |
|
|
|
144 |
|
|
struct filepointer { |
145 |
|
|
char *f_p; |
146 |
|
|
char *f_base; |
147 |
|
|
char *f_end; |
148 |
|
|
long f_len; |
149 |
|
|
long f_line; |
150 |
|
|
}; |
151 |
|
|
|
152 |
|
|
#ifndef NO_STDLIB_H /* X_NOT_STDC_ENV */ |
153 |
|
|
#include <stdlib.h> |
154 |
|
|
#if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */ |
155 |
|
|
char *malloc(), *realloc(); |
156 |
|
|
#endif /* macII */ |
157 |
|
|
#else |
158 |
|
|
char *malloc(); |
159 |
|
|
char *realloc(); |
160 |
|
|
#endif |
161 |
|
|
|
162 |
|
|
char *copy(); |
163 |
|
|
char *base_name(); |
164 |
|
|
char *getline(); |
165 |
|
|
struct symtab *slookup(); |
166 |
|
|
struct symtab *isdefined(); |
167 |
|
|
struct symtab *fdefined(); |
168 |
|
|
struct filepointer *getfile(); |
169 |
|
|
struct inclist *newinclude(); |
170 |
|
|
struct inclist *inc_path(); |
171 |
|
|
|
172 |
|
|
#ifdef HAVE_STDARG_H /* NeedVarargsPrototypes */ |
173 |
|
|
extern fatalerr(char *, ...); |
174 |
|
|
extern warning(char *, ...); |
175 |
|
|
extern warning1(char *, ...); |
176 |
|
|
#endif |