feisty meow concerns codebase  2.140
def.h
Go to the documentation of this file.
1 /* $XConsortium: def.h,v 1.25 94/04/17 20:10:33 gildea Exp $ */
2 /*
3 
4 Copyright (c) 1993, 1994 X Consortium
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 
23 Except as contained in this notice, the name of the X Consortium shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the X Consortium.
26 
27 */
28 
29 #include <stdio.h>
30 #include "Xosdefs.h"
31 #ifdef WIN32
32 #endif
33 #ifdef __OS2__
34 #define __STDC__ 1
35 #include "Xos2defs.h"
36 #endif
37 #include "Xfuncproto.h"
38 #include <ctype.h>
39 #ifndef X_NOT_POSIX
40 #ifndef _POSIX_SOURCE
41 #define _POSIX_SOURCE
42 #endif
43 #endif
44 #include <sys/types.h>
45 #include <fcntl.h>
46 #include <sys/stat.h>
47 
48 #define MAXDEFINES 512
49 #define MAXFILES 4000
50 #define MAXDIRS 640
51 #define SYMTABINC 10 /* must be > 1 for define() to work right */
52 
53 /* the following must match the directives table in main.c */
54 #define IF 0
55 #define IFDEF 1
56 #define IFNDEF 2
57 #define ELSE 3
58 #define ENDIF 4
59 #define DEFINE 5
60 #define UNDEF 6
61 #define INCLUDE 7
62 #define LINE 8
63 #define PRAGMA 9
64 #define ERROR 10
65 #define IDENT 11
66 #define SCCS 12
67 #define ELIF 13
68 #define EJECT 14
69 #define IMPORT 15
70 
71 #define IFFALSE 16 /* pseudo value --- never matched */
72 #define ELIFFALSE 17 /* pseudo value --- never matched */
73 #define INCLUDEDOT 18 /* pseudo value --- never matched */
74 #define IFGUESSFALSE 19 /* pseudo value --- never matched */
75 #define ELIFGUESSFALSE 20 /* pseudo value --- never matched */
76 
78  // uncomment this for debugging version.
79 
80 #ifdef DEBUG
81 extern int _debugmask;
82 /*
83  * debug levels are:
84  *
85  * 0 show ifn*(def)*,endif
86  * 1 trace defined/!defined
87  * 2 show #include
88  * 3 show #include SYMBOL
89  * 4-6 unused
90  */
91 #define debug(level,arg) { if (_debugmask & (1 << level)) warning arg; }
92 #else
93 #define debug(level,arg) {}
94 #endif /* DEBUG */
95 
96 struct symtab {
97  char *s_name;
98  char *s_value;
99 };
100 
101 struct inclist {
102  char *i_incstring; /* string from #include line */
103  char *i_file; /* path name of the include file */
104  inclist **i_list; /* list of files it itself includes */
105  int i_listlen; /* length of i_list */
106  symtab *i_defs; /* symbol table for this file */
107  int i_ndefs; /* current # defines */
108  int i_deflen; /* amount of space in table */
109  bool i_defchecked; /* whether defines have been checked */
110  bool i_notified; /* whether we have revealed includes */
111  bool i_marked; /* whether it's in the makefile */
112  bool i_searched; /* whether we have read this */
113  bool i_included_sym; /* whether #include SYMBOL was found */
114  /* Can't use i_list if true */
115 };
116 
117 struct filepointer {
118  char *f_p;
119  char *f_base;
120  char *f_end;
121  long f_len;
122  long f_line;
123  char *f_name;
124 };
125 
126 #ifndef X_NOT_STDC_ENV
127 #include <stdlib.h>
128 #if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */
129 char *malloc(), *realloc();
130 #endif /* macII */
131 #else
132 char *malloc();
133 char *realloc();
134 #endif
135 
136 /*
137 char *getline();
138 symtab *slookup();
139 symtab *isdefined();
140 symtab *fdefined();
141 filepointer *getfile();
142 inclist *newinclude(register char *, register char *);
143 inclist *inc_path();
144 */
145 
146 // cppsetup.cpp:
147 int cppsetup(register char *line, register filepointer *filep,
148  register inclist *inc);
149 
150 // include.cpp
151 inclist *newinclude(register char *newfile, register char *incstring);
152 void inc_clean();
153 inclist *inc_path(register char *file, register char *include, bool dot,
154  bool &failure_okay);
155 void included_by(register inclist *ip, register inclist *newfile);
156 
157 // main.cpp:
158 char *base_name(register char *file);
159 char *copy(register char *str);
160 filepointer *getfile(char *file);
161 void freefile(filepointer *fp);
162 char *getline(register filepointer *filep);
163 int match(register const char *str, register const char **list);
164 void redirect(char *line, char *makefile);
165 #if NeedVarargsPrototypes
166  void fatalerr(const char *, ...);
167  void warning(const char *, ...);
168  void warning1(const char *, ...);
169 #endif
170 
171 // parse.cpp:
172 void define(char *def, inclist *file);
173 void define2(char *name, char *val, inclist *file);
174 int deftype(register char *line, register filepointer *filep,
175  register inclist *file_red, register inclist *file,
176  int parse_it);
177 symtab *fdefined(register char *symbol, inclist *file, inclist **srcfile);
178 int find_includes(filepointer *filep, inclist *file,
179  inclist *file_red, int recursion, bool failOK);
180 int gobble(register filepointer *filep, inclist *file,
181  inclist *file_red);
182 symtab *isdefined(register char *symbol, inclist *file,
183  inclist **srcfile);
184 symtab *slookup(register char *symbol, register inclist *file);
185 void undefine(char *symbol, register inclist *file);
186 int zero_value(register char *exp, register filepointer *filep,
187  register inclist *file_red);
188 
189 // pr.cpp:
190 void add_include(filepointer *filep, inclist *file,
191  inclist *file_red, char *include, bool dot, bool failOK);
192 void pr(register inclist *ip, char *file, char *base, bool rc_file);
193 void recursive_pr_include(register inclist *head, register char *file,
194  register char *base);
195 
symtab * isdefined(register char *symbol, inclist *file, inclist **srcfile)
Definition: parse.cpp:362
void recursive_pr_include(register inclist *head, register char *file, register char *base)
int find_includes(filepointer *filep, inclist *file, inclist *file_red, int recursion, bool failOK)
Definition: parse.cpp:40
char * getline(register filepointer *filep)
void pr(register inclist *ip, char *file, char *base, bool rc_file)
void add_include(filepointer *filep, inclist *file, inclist *file_red, char *include, bool dot, bool failOK)
Definition: pr.cpp:44
int deftype(register char *line, register filepointer *filep, register inclist *file_red, register inclist *file, int parse_it)
void freefile(filepointer *fp)
Definition: makedep.cpp:547
void define2(char *name, char *val, inclist *file)
Definition: parse.cpp:434
int zero_value(register char *exp, register filepointer *filep, register inclist *file_red)
inclist * inc_path(register char *file, register char *include, bool dot, bool &failure_okay)
Definition: include.cpp:58
inclist * newinclude(register char *newfile, register char *incstring)
Definition: include.cpp:276
symtab * fdefined(register char *symbol, inclist *file, inclist **srcfile)
Definition: parse.cpp:378
symtab * slookup(register char *symbol, register inclist *file)
Definition: parse.cpp:510
char * base_name(register char *file)
Definition: makedep.cpp:653
int match(register const char *str, register const char **list)
Definition: makedep.cpp:562
void redirect(char *line, char *makefile)
Definition: makedep.cpp:678
void undefine(char *symbol, register inclist *file)
Definition: parse.cpp:548
filepointer * getfile(char *file)
Definition: makedep.cpp:518
void inc_clean()
Definition: include.cpp:340
void define(char *def, inclist *file)
Definition: parse.cpp:416
char * copy(register char *str)
Definition: makedep.cpp:554
void included_by(register inclist *ip, register inclist *newfile)
Definition: include.cpp:296
int gobble(register filepointer *filep, inclist *file, inclist *file_red)
int cppsetup(register char *line, register filepointer *filep, register inclist *inc)
void warning1(const char *msg, x1, x2, x3, x4, x5, x6, x7, x8, x9)
Definition: makedep.cpp:790
void fatalerr(char *msg, x1, x2, x3, x4, x5, x6, x7, x8, x9)
Definition: makedep.cpp:749
void warning(const char *msg, x1, x2, x3, x4, x5, x6, x7, x8, x9)
Definition: makedep.cpp:770
long f_line
Definition: def.h:122
char * f_base
Definition: def.h:119
char * f_p
Definition: def.h:118
char * f_name
Definition: def.h:123
char * f_end
Definition: def.h:120
long f_len
Definition: def.h:121
Definition: def.h:101
bool i_searched
Definition: def.h:112
bool i_defchecked
Definition: def.h:109
int i_deflen
Definition: def.h:108
bool i_included_sym
Definition: def.h:113
int i_listlen
Definition: def.h:105
symtab * i_defs
Definition: def.h:106
bool i_notified
Definition: def.h:110
int i_ndefs
Definition: def.h:107
bool i_marked
Definition: def.h:111
char * i_incstring
Definition: def.h:102
char * i_file
Definition: def.h:103
inclist ** i_list
Definition: def.h:104
Definition: def.h:96
char * s_value
Definition: def.h:98
char * s_name
Definition: def.h:97