1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* $XConsortium: def.h,v 1.25 94/04/17 20:10:33 gildea Exp $ */
3 /*
4 
5 Copyright (c) 1993, 1994  X Consortium
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
20 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 
24 Except as contained in this notice, the name of the X Consortium shall not be
25 used in advertising or otherwise to promote the sale, use or other dealings
26 in this Software without prior written authorization from the X Consortium.
27 
28 */
29 
30 #ifndef NO_X11
31 #include <X11/Xosdefs.h>
32 #ifdef _WIN32
33 #include <X11/Xw32defs.h>
34 #endif
35 #ifndef SUNOS4
36 #include <X11/Xfuncproto.h>
37 #endif /* SUNOS4 */
38 #endif /* NO_X11 */
39 
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43 #ifndef _MSC_VER
44 #include <unistd.h>
45 #endif
46 
47 #ifndef X_NOT_POSIX
48 #ifndef _POSIX_SOURCE
49 #define _POSIX_SOURCE
50 #endif
51 #endif
52 #include <sys/types.h>
53 #include <fcntl.h>
54 #include <sys/stat.h>
55 
56 #ifndef S_IFDIR
57 #define        S_IFDIR  0040000
58 #endif
59 
60 #ifndef S_IFREG
61 #define        S_IFREG  0100000
62 #endif
63 
64 #define MAXFILES    65536
65 
66 #define MAXDIRS     64
67 #define SYMHASHSEED     131  /* 131 1313 13131 ... */
68 #define SYMHASHMEMBERS  64  /* must be 2^x to work right */
69 #define TRUE        1
70 #define FALSE       0
71 
72 /* the following must match the directives table in main.c */
73 #define IF      0
74 #define ERROR           10
75 #define ELIF            13
76 #define IFFALSE         15     /* pseudo value --- never matched */
77 #define ELIFFALSE       16     /* pseudo value --- never matched */
78 #define ELIFGUESSFALSE  19     /* pseudo value --- never matched */
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 // VG: a C++ class for information about directories
97 #include "collectdircontent.hxx"
98 
99 typedef unsigned char boolean;
100 
101 struct pair {
102     char        *p_name;
103     char        *p_value;
104     struct pair *p_next;
105 };
106 
107 struct symhash {
108     struct pair *s_pairs[SYMHASHMEMBERS];
109 };
110 
111 struct  inclist {
112     char        *i_incstring;  /* string from #include line */
113     char        *i_file;       /* path name of the include file */
114     struct inclist  **i_list;  /* list of files it itself includes */
115     int         i_listlen;     /* length of i_list */
116     boolean     i_notified;    /* whether we have revealed includes */
117     boolean     i_marked;      /* whether it's in the makefile */
118     boolean     i_searched;    /* whether we have read this */
119 };
120 
121 struct filepointer {
122     char    *f_p;
123     char    *f_base;
124     char    *f_end;
125     int      f_line;
126 };
127 
128 #ifndef X_NOT_STDC_ENV
129 #if defined(macII) && !defined(__STDC__)  /* stdlib.h fails to define these */
130 char *malloc(), *realloc();
131 #endif /* macII */
132 #else
133 char            *malloc();
134 char            *realloc();
135 #endif
136 
137 char            *copy(char const *);
138 char            *base_name(char *);
139 char            *get_line(struct filepointer *);
140 char            *isdefined(char *);
141 struct filepointer  *getfile(char *);
142 struct inclist *newinclude(char const *newfile,
143                            char const *incstring);
144 struct inclist      *inc_path(char *, char *, boolean,
145                                   struct IncludesCollection *);
146 
147 void define( char *def, struct symhash **symbols );
148 void hash_define(char *name, char const * val, struct symhash **symbols);
149 struct symhash *hash_copy( struct symhash *symbols );
150 void hash_free( struct symhash *symbols );
151 void freefile( struct filepointer * fp );
152 int find_includes(struct filepointer *filep, struct inclist *file,
153     struct inclist *file_red, int recursion, boolean failOK,
154     struct IncludesCollection* incCollection, struct symhash *symbols);
155 void included_by(struct inclist *ip,
156     struct inclist * newfile);
157 int cppsetup(char const *line);
158 void add_include(struct filepointer *filep, struct inclist *file,
159     struct inclist *file_red, char *include, boolean dot, boolean failOK,
160     struct IncludesCollection* incCollection, struct symhash *symbols);
161 int match(char const *str, char **list);
162 void recursive_pr_include(struct inclist *head, char *file,
163     char *base);
164 void recursive_pr_dummy(struct inclist *head, char *file);
165 void inc_clean(void);
166 
167 void fatalerr(char *, ...);
168 void warning(char const *, ...);
169 void warning1(char const *, ...);
170 
171 void convert_slashes(char *);
172 char *append_slash(char *);
173 
174 extern char * directives[];
175 
176 extern struct inclist inclist[ MAXFILES ];
177 extern struct inclist * inclistp;
178 
179 extern char *includedirs[ ];
180 
181 extern char * objprefix;
182 
183 extern char * objsuffix;
184 
185 extern boolean printed;
186 
187 extern boolean verbose;
188 
189 extern boolean show_where_not;
190 
191 extern boolean warn_multiple;
192 
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
194