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
4Copyright (c) 1993, 1994 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in 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
81extern 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
96struct symtab {
97 char *s_name;
98 char *s_value;
99};
100
101struct 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
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 */
129char *malloc(), *realloc();
130#endif /* macII */
131#else
132char *malloc();
133char *realloc();
134#endif
135
136/*
137char *getline();
138symtab *slookup();
139symtab *isdefined();
140symtab *fdefined();
141filepointer *getfile();
142inclist *newinclude(char *, char *);
143inclist *inc_path();
144*/
145
146// cppsetup.cpp:
147int cppsetup(char *line, filepointer *filep,
148 inclist *inc);
149
150// include.cpp
151inclist *newinclude(char *newfile, char *incstring);
152void inc_clean();
153inclist *inc_path(char *file, char *include, bool dot,
154 bool &failure_okay);
155void included_by(inclist *ip, inclist *newfile);
156
157// main.cpp:
158char *base_name(char *file);
159char *copy(char *str);
160filepointer *getfile(char *file);
161void freefile(filepointer *fp);
162char *getline(filepointer *filep);
163int match(const char *str, const char **list);
164void 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:
172void define(char *def, inclist *file);
173void define2(char *name, char *val, inclist *file);
174int deftype(char *line, filepointer *filep,
175 inclist *file_red, inclist *file,
176 int parse_it);
177symtab *fdefined(char *symbol, inclist *file, inclist **srcfile);
178int find_includes(filepointer *filep, inclist *file,
179 inclist *file_red, int recursion, bool failOK);
180int gobble(filepointer *filep, inclist *file,
181 inclist *file_red);
182symtab *isdefined(char *symbol, inclist *file,
183 inclist **srcfile);
184symtab *slookup(char *symbol, inclist *file);
185void undefine(char *symbol, inclist *file);
186int zero_value(char *exp, filepointer *filep,
187 inclist *file_red);
188
189// pr.cpp:
190void add_include(filepointer *filep, inclist *file,
191 inclist *file_red, char *include, bool dot, bool failOK);
192void pr(inclist *ip, char *file, char *base, bool rc_file);
193void recursive_pr_include(inclist *head, char *file,
194 char *base);
195
filepointer * getfile(char *file)
Definition makedep.cpp:518
int find_includes(filepointer *filep, inclist *file, inclist *file_red, int recursion, bool failOK)
Definition parse.cpp:40
char * base_name(char *file)
Definition makedep.cpp:653
char * copy(char *str)
Definition makedep.cpp:554
int deftype(char *line, filepointer *filep, inclist *file_red, inclist *file, int parse_it)
Definition parse.cpp:218
symtab * slookup(char *symbol, inclist *file)
Definition parse.cpp:510
void add_include(filepointer *filep, inclist *file, inclist *file_red, char *include, bool dot, bool failOK)
Definition pr.cpp:44
void freefile(filepointer *fp)
Definition makedep.cpp:547
void define2(char *name, char *val, inclist *file)
Definition parse.cpp:434
void undefine(char *symbol, inclist *file)
Definition parse.cpp:548
int cppsetup(char *line, filepointer *filep, inclist *inc)
Definition cppsetup.cpp:207
char * getline(filepointer *filep)
Definition makedep.cpp:576
void redirect(char *line, char *makefile)
Definition makedep.cpp:678
symtab * fdefined(char *symbol, inclist *file, inclist **srcfile)
Definition parse.cpp:378
void inc_clean()
Definition include.cpp:340
void included_by(inclist *ip, inclist *newfile)
Definition include.cpp:296
symtab * isdefined(char *symbol, inclist *file, inclist **srcfile)
Definition parse.cpp:362
void pr(inclist *ip, char *file, char *base, bool rc_file)
Definition pr.cpp:98
int gobble(filepointer *filep, inclist *file, inclist *file_red)
Definition parse.cpp:165
void define(char *def, inclist *file)
Definition parse.cpp:416
inclist * newinclude(char *newfile, char *incstring)
Definition include.cpp:276
void recursive_pr_include(inclist *head, char *file, char *base)
Definition pr.cpp:80
int zero_value(char *exp, filepointer *filep, inclist *file_red)
Definition parse.cpp:407
inclist * inc_path(char *file, char *include, bool dot, bool &failure_okay)
Definition include.cpp:58
int match(const char *str, const char **list)
Definition makedep.cpp:562
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