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