michael@0: /* $Xorg: def.h,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */ michael@0: /* michael@0: michael@0: Copyright (c) 1993, 1994, 1998 The Open Group. michael@0: michael@0: Permission to use, copy, modify, distribute, and sell this software and its michael@0: documentation for any purpose is hereby granted without fee, provided that michael@0: the above copyright notice appear in all copies and that both that michael@0: copyright notice and this permission notice appear in supporting michael@0: documentation. michael@0: michael@0: The above copyright notice and this permission notice shall be included in michael@0: all copies or substantial portions of the Software. michael@0: michael@0: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR michael@0: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, michael@0: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE michael@0: OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN michael@0: AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN michael@0: CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. michael@0: michael@0: Except as contained in this notice, the name of The Open Group shall not be michael@0: used in advertising or otherwise to promote the sale, use or other dealings michael@0: in this Software without prior written authorization from The Open Group. michael@0: michael@0: */ michael@0: /* $XFree86: xc/config/makedepend/def.h,v 3.14 2003/01/17 17:09:49 tsi Exp $ */ michael@0: michael@0: #ifndef NO_X11 michael@0: #include michael@0: #include michael@0: #endif michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #if 0 michael@0: #ifndef X_NOT_POSIX michael@0: #ifndef _POSIX_SOURCE michael@0: #define _POSIX_SOURCE michael@0: #endif michael@0: #endif michael@0: #endif michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #define MAXDEFINES 512 michael@0: #define MAXFILES 1024 michael@0: #define MAXINCFILES 256 /* "-include" files */ michael@0: #define MAXDIRS 1024 michael@0: #define SYMTABINC 10 /* must be > 1 for define() to work right */ michael@0: #define TRUE 1 michael@0: #define FALSE 0 michael@0: michael@0: /* the following must match the directives table in main.c */ michael@0: #define IF 0 michael@0: #define IFDEF 1 michael@0: #define IFNDEF 2 michael@0: #define ELSE 3 michael@0: #define ENDIF 4 michael@0: #define DEFINE 5 michael@0: #define UNDEF 6 michael@0: #define INCLUDE 7 michael@0: #define LINE 8 michael@0: #define PRAGMA 9 michael@0: #define ERROR 10 michael@0: #define IDENT 11 michael@0: #define SCCS 12 michael@0: #define ELIF 13 michael@0: #define EJECT 14 michael@0: #define WARNING 15 michael@0: #define INCLUDENEXT 16 michael@0: #define IFFALSE 17 /* pseudo value --- never matched */ michael@0: #define ELIFFALSE 18 /* pseudo value --- never matched */ michael@0: #define INCLUDEDOT 19 /* pseudo value --- never matched */ michael@0: #define IFGUESSFALSE 20 /* pseudo value --- never matched */ michael@0: #define ELIFGUESSFALSE 21 /* pseudo value --- never matched */ michael@0: #define INCLUDENEXTDOT 22 /* pseudo value --- never matched */ michael@0: michael@0: #ifdef DEBUG michael@0: extern int _debugmask; michael@0: /* michael@0: * debug levels are: michael@0: * michael@0: * 0 show ifn*(def)*,endif michael@0: * 1 trace defined/!defined michael@0: * 2 show #include michael@0: * 3 show #include SYMBOL michael@0: * 4-6 unused michael@0: */ michael@0: #define debug(level,arg) { if (_debugmask & (1 << level)) warning arg; } michael@0: #else michael@0: #define debug(level,arg) /**/ michael@0: #endif /* DEBUG */ michael@0: michael@0: typedef unsigned char boolean; michael@0: michael@0: struct symtab { michael@0: char *s_name; michael@0: char *s_value; michael@0: }; michael@0: michael@0: /* possible i_flag */ michael@0: #define DEFCHECKED (1<<0) /* whether defines have been checked */ michael@0: #define NOTIFIED (1<<1) /* whether we have revealed includes */ michael@0: #define MARKED (1<<2) /* whether it's in the makefile */ michael@0: #define SEARCHED (1<<3) /* whether we have read this */ michael@0: #define FINISHED (1<<4) /* whether we are done reading this */ michael@0: #define INCLUDED_SYM (1<<5) /* whether #include SYMBOL was found michael@0: Can't use i_list if TRUE */ michael@0: struct inclist { michael@0: char *i_incstring; /* string from #include line */ michael@0: char *i_file; /* path name of the include file */ michael@0: struct inclist **i_list; /* list of files it itself includes */ michael@0: int i_listlen; /* length of i_list */ michael@0: struct symtab **i_defs; /* symbol table for this file and its michael@0: children when merged */ michael@0: int i_ndefs; /* current # defines */ michael@0: boolean *i_merged; /* whether we have merged child michael@0: defines */ michael@0: unsigned char i_flags; michael@0: }; michael@0: michael@0: struct filepointer { michael@0: char *f_name; michael@0: char *f_p; michael@0: char *f_base; michael@0: char *f_end; michael@0: long f_len; michael@0: long f_line; michael@0: long cmdinc_count; michael@0: char **cmdinc_list; michael@0: long cmdinc_line; michael@0: }; michael@0: michael@0: #include michael@0: #if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */ michael@0: char *malloc(), *realloc(); michael@0: #endif /* macII */ michael@0: michael@0: char *copy(char *str); michael@0: int match(char *str, char **list); michael@0: char *base_name(char *file); michael@0: char *getnextline(struct filepointer *fp); michael@0: struct symtab **slookup(char *symbol, struct inclist *file); michael@0: struct symtab **isdefined(char *symbol, struct inclist *file, michael@0: struct inclist **srcfile); michael@0: struct symtab **fdefined(char *symbol, struct inclist *file, michael@0: struct inclist **srcfile); michael@0: struct filepointer *getfile(char *file); michael@0: void included_by(struct inclist *ip, michael@0: struct inclist *newfile); michael@0: struct inclist *newinclude(char *newfile, char *incstring); michael@0: void inc_clean (void); michael@0: struct inclist *inc_path(char *file, char *include, int type); michael@0: michael@0: void freefile(struct filepointer *fp); michael@0: michael@0: void define2(char *name, char *val, struct inclist *file); michael@0: void define(char *def, struct inclist *file); michael@0: void undefine(char *symbol, struct inclist *file); michael@0: int find_includes(struct filepointer *filep, michael@0: struct inclist *file, michael@0: struct inclist *file_red, michael@0: int recursion, boolean failOK); michael@0: michael@0: void recursive_pr_include(struct inclist *head, michael@0: char *file, char *base); michael@0: void add_include(struct filepointer *filep, michael@0: struct inclist *file, michael@0: struct inclist *file_red, michael@0: char *include, int type, michael@0: boolean failOK); michael@0: michael@0: int cppsetup(char *filename, michael@0: char *line, michael@0: struct filepointer *filep, michael@0: struct inclist *inc); michael@0: michael@0: michael@0: extern void fatalerr(char *, ...); michael@0: extern void warning(char *, ...); michael@0: extern void warning1(char *, ...);