]>
Commit | Line | Data |
---|---|---|
d1b2a10e | 1 | /* |
2 | * $XConsortium: def.h,v 1.6 88/09/22 13:52:33 jim Exp $ | |
3 | */ | |
4 | #include <stdio.h> | |
5 | #include <ctype.h> | |
6 | #include <sys/types.h> | |
7 | #include <fcntl.h> | |
8 | #include <sys/stat.h> | |
9 | ||
10 | #ifdef USG | |
11 | #define u_char unchar | |
12 | #endif | |
13 | ||
14 | #define MAXDEFINES 512 | |
15 | #define MAXFILES 512 | |
16 | #define MAXDIRS 10 | |
17 | #define SYMTABINC 10 /* must be > 1 for define() to work right */ | |
18 | #define TRUE 1 | |
19 | #define FALSE 0 | |
20 | ||
21 | /* the following must match the directives table in main.c */ | |
22 | #define IF 0 | |
23 | #define IFDEF 1 | |
24 | #define IFNDEF 2 | |
25 | #define ELSE 3 | |
26 | #define ENDIF 4 | |
27 | #define DEFINE 5 | |
28 | #define UNDEF 6 | |
29 | #define INCLUDE 7 | |
30 | #define LINE 8 | |
31 | #define PRAGMA 9 | |
32 | #define ELIF 10 | |
33 | #define EJECT 11 | |
34 | #define IFFALSE 12 /* pseudo value --- never matched */ | |
35 | #define ELIFFALSE 13 /* pseudo value --- never matched */ | |
36 | #define INCLUDEDOT 14 /* pseudo value --- never matched */ | |
37 | ||
38 | #ifdef DEBUG | |
39 | extern int debug; | |
40 | #define debug0 ((debug&0x0001)==0) ? debug : log /* show ifn*(def)*,endif */ | |
41 | #define debug1 ((debug&0x0002)==0) ? debug : log /* trace defined/!defined */ | |
42 | #define debug2 ((debug&0x0004)==0) ? debug : log /* show #include */ | |
43 | #define debug3 ((debug&0x0008)==0) ? debug : log /* show #include SYMBOL */ | |
44 | #define debug4 ((debug&0x0010)==0) ? debug : log /* unused */ | |
45 | #define debug5 ((debug&0x0020)==0) ? debug : log /* unused */ | |
46 | #define debug6 ((debug&0x0040)==0) ? debug : log /* unused */ | |
47 | #else DEBUG | |
48 | #define debug0 | |
49 | #define debug1 | |
50 | #define debug2 | |
51 | #define debug3 | |
52 | #define debug4 | |
53 | #define debug5 | |
54 | #define debug6 | |
55 | #endif DEBUG | |
56 | ||
57 | typedef u_char boolean; | |
58 | ||
59 | struct symtab { | |
60 | char *s_name; | |
61 | char *s_value; | |
62 | }; | |
63 | ||
64 | struct inclist { | |
65 | char *i_incstring; /* string from #include line */ | |
66 | char *i_file; /* path name of the include file */ | |
67 | struct inclist **i_list; /* list of files it itself includes */ | |
68 | int i_listlen; /* length of i_list */ | |
69 | struct symtab *i_defs; /* symbol table for this file */ | |
70 | struct symtab *i_lastdef; /* last symbol defined */ | |
71 | int i_deflen; /* number of defines */ | |
72 | boolean i_defchecked; /* whether defines have been checked */ | |
73 | boolean i_notified; /* whether we have revealed includes */ | |
74 | boolean i_marked; /* whether it's in the makefile */ | |
75 | boolean i_searched; /* whether we have read this */ | |
76 | boolean i_included_sym; /* whether #include SYMBOL was found */ | |
77 | /* Can't use i_list if TRUE */ | |
78 | }; | |
79 | ||
80 | struct filepointer { | |
81 | char *f_p; | |
82 | char *f_base; | |
83 | char *f_end; | |
84 | long f_len; | |
85 | long f_line; | |
86 | }; | |
87 | ||
88 | char *copy(); | |
89 | char *malloc(); | |
90 | char *realloc(); | |
91 | char *basename(); | |
92 | char *getline(); | |
93 | struct symtab *slookup(); | |
94 | struct symtab *defined(); | |
95 | struct symtab *fdefined(); | |
96 | struct filepointer *getfile(); | |
97 | struct inclist *newinclude(); | |
98 | struct inclist *inc_path(); |