Back to index

lightning-sunbird  0.9+nobinonly
def.h
Go to the documentation of this file.
00001 /* $Xorg: def.h,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */
00002 /*
00003 
00004 Copyright (c) 1993, 1994, 1998 The Open Group.
00005 
00006 Permission to use, copy, modify, distribute, and sell this software and its
00007 documentation for any purpose is hereby granted without fee, provided that
00008 the above copyright notice appear in all copies and that both that
00009 copyright notice and this permission notice appear in supporting
00010 documentation.
00011 
00012 The above copyright notice and this permission notice shall be included in
00013 all copies or substantial portions of the Software.
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00018 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00019 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00020 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00021 
00022 Except as contained in this notice, the name of The Open Group shall not be
00023 used in advertising or otherwise to promote the sale, use or other dealings
00024 in this Software without prior written authorization from The Open Group.
00025 
00026 */
00027 /* $XFree86: xc/config/makedepend/def.h,v 3.14 2003/01/17 17:09:49 tsi Exp $ */
00028 
00029 #ifndef NO_X11
00030 #include <X11/Xos.h>
00031 #include <X11/Xfuncproto.h>
00032 #endif
00033 #include <stdlib.h>
00034 #include <stdio.h>
00035 #include <string.h>
00036 #include <ctype.h>
00037 #if 0
00038 #ifndef X_NOT_POSIX
00039 #ifndef _POSIX_SOURCE
00040 #define _POSIX_SOURCE
00041 #endif
00042 #endif
00043 #endif
00044 #include <sys/types.h>
00045 #include <fcntl.h>
00046 #include <sys/stat.h>
00047 
00048 #define MAXDEFINES   512
00049 #define MAXFILES     1024
00050 #define MAXINCFILES  128    /* "-include" files */
00051 #define MAXDIRS             64
00052 #define SYMTABINC    10     /* must be > 1 for define() to work right */
00053 #define       TRUE          1
00054 #define       FALSE         0
00055 
00056 /* the following must match the directives table in main.c */
00057 #define       IF            0
00058 #define       IFDEF         1
00059 #define       IFNDEF        2
00060 #define       ELSE          3
00061 #define       ENDIF         4
00062 #define       DEFINE        5
00063 #define       UNDEF         6
00064 #define       INCLUDE              7
00065 #define       LINE          8
00066 #define       PRAGMA        9
00067 #define ERROR           10
00068 #define IDENT           11
00069 #define SCCS            12
00070 #define ELIF            13
00071 #define EJECT           14
00072 #define WARNING         15
00073 #define INCLUDENEXT     16
00074 #define IFFALSE         17     /* pseudo value --- never matched */
00075 #define ELIFFALSE       18     /* pseudo value --- never matched */
00076 #define INCLUDEDOT      19     /* pseudo value --- never matched */
00077 #define IFGUESSFALSE    20     /* pseudo value --- never matched */
00078 #define ELIFGUESSFALSE  21     /* pseudo value --- never matched */
00079 #define INCLUDENEXTDOT  22     /* pseudo value --- never matched */
00080 
00081 #ifdef DEBUG
00082 extern int    _debugmask;
00083 /*
00084  * debug levels are:
00085  * 
00086  *     0      show ifn*(def)*,endif
00087  *     1      trace defined/!defined
00088  *     2      show #include
00089  *     3      show #include SYMBOL
00090  *     4-6    unused
00091  */
00092 #define debug(level,arg) { if (_debugmask & (1 << level)) warning arg; }
00093 #else
00094 #define       debug(level,arg) 
00095 #endif /* DEBUG */
00096 
00097 typedef       unsigned char boolean;
00098 
00099 struct symtab {
00100        char   *s_name;
00101        char   *s_value;
00102 };
00103 
00104 /* possible i_flag */
00105 #define DEFCHECKED   (1<<0) /* whether defines have been checked */
00106 #define NOTIFIED     (1<<1) /* whether we have revealed includes */
00107 #define MARKED              (1<<2) /* whether it's in the makefile */
00108 #define SEARCHED     (1<<3) /* whether we have read this */
00109 #define FINISHED     (1<<4) /* whether we are done reading this */
00110 #define INCLUDED_SYM (1<<5) /* whether #include SYMBOL was found
00111                                Can't use i_list if TRUE */
00112 struct inclist {
00113        char          *i_incstring; /* string from #include line */
00114        char          *i_file;      /* path name of the include file */
00115        struct inclist       **i_list;     /* list of files it itself includes */
00116        int           i_listlen;    /* length of i_list */
00117        struct symtab **i_defs;     /* symbol table for this file and its
00118                                       children when merged */
00119        int           i_ndefs;      /* current # defines */
00120        boolean              *i_merged;      /* whether we have merged child
00121                                       defines */
00122        unsigned char   i_flags;
00123 };
00124 
00125 struct filepointer {
00126        char   *f_name;
00127        char   *f_p;
00128        char   *f_base;
00129        char   *f_end;
00130        long   f_len;
00131        long   f_line;
00132        long   cmdinc_count;
00133        char   **cmdinc_list;
00134        long   cmdinc_line;
00135 };
00136 
00137 #include <stdlib.h>
00138 #if defined(macII) && !defined(__STDC__)  /* stdlib.h fails to define these */
00139 char *malloc(), *realloc();
00140 #endif /* macII */
00141 
00142 char                 *copy(char *str);
00143 int                     match(char *str, char **list);
00144 char                 *base_name(char *file);
00145 char                 *getnextline(struct filepointer *fp);
00146 struct symtab        **slookup(char *symbol, struct inclist *file);
00147 struct symtab        **isdefined(char *symbol, struct inclist *file,
00148                                 struct inclist **srcfile);
00149 struct symtab        **fdefined(char *symbol, struct inclist *file,
00150                                struct inclist **srcfile);
00151 struct filepointer   *getfile(char *file);
00152 void                    included_by(struct inclist *ip, 
00153                                 struct inclist *newfile);
00154 struct inclist              *newinclude(char *newfile, char *incstring);
00155 void                    inc_clean (void);
00156 struct inclist              *inc_path(char *file, char *include, int type);
00157 
00158 void                    freefile(struct filepointer *fp);
00159 
00160 void                    define2(char *name, char *val, struct inclist *file);
00161 void                    define(char *def, struct inclist *file);
00162 void                    undefine(char *symbol, struct inclist *file);
00163 int                     find_includes(struct filepointer *filep, 
00164                                   struct inclist *file, 
00165                                   struct inclist *file_red, 
00166                                   int recursion, boolean failOK);
00167 
00168 void                    recursive_pr_include(struct inclist *head, 
00169                                         char *file, char *base);
00170 void                    add_include(struct filepointer *filep, 
00171                                 struct inclist *file, 
00172                                 struct inclist *file_red, 
00173                                 char *include, int type,
00174                                 boolean failOK);
00175 
00176 int                     cppsetup(char *filename,
00177                              char *line,
00178                              struct filepointer *filep,
00179                              struct inclist *inc);
00180 
00181 
00182 extern void fatalerr(char *, ...);
00183 extern void warning(char *, ...);
00184 extern void warning1(char *, ...);