def.h revision 0eb10989
1/* $XdotOrg: $ */ 2/* $Xorg: def.h,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */ 3/* 4 5Copyright (c) 1993, 1994, 1998 The Open Group. 6 7Permission to use, copy, modify, distribute, and sell this software and its 8documentation for any purpose is hereby granted without fee, provided that 9the above copyright notice appear in all copies and that both that 10copyright notice and this permission notice appear in supporting 11documentation. 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 19OPEN GROUP 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 Open Group 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 Open Group. 26 27*/ 28/* $XFree86: xc/config/makedepend/def.h,v 3.13tsi Exp $ */ 29 30#ifdef HAVE_CONFIG_H /* Autotooled for Xorg 7.0? */ 31# include "makedepend-config.h" 32# define USING_AUTOCONF 33#endif 34 35#include <X11/Xos.h> 36#include <X11/Xfuncproto.h> 37#include <stdlib.h> 38#include <stdio.h> 39#include <string.h> 40#include <ctype.h> 41#if 0 42#ifndef X_NOT_POSIX 43#ifndef _POSIX_SOURCE 44#define _POSIX_SOURCE 45#endif 46#endif 47#endif 48#include <sys/types.h> 49#include <fcntl.h> 50#include <sys/stat.h> 51 52#define MAXDEFINES 512 53#define MAXFILES 1024 54#define MAXINCFILES 128 /* "-include" files */ 55#define MAXDIRS 64 56#define SYMTABINC 10 /* must be > 1 for define() to work right */ 57#define TRUE 1 58#define FALSE 0 59 60/* the following must match the directives table in main.c */ 61#define IF 0 62#define IFDEF 1 63#define IFNDEF 2 64#define ELSE 3 65#define ENDIF 4 66#define DEFINE 5 67#define UNDEF 6 68#define INCLUDE 7 69#define LINE 8 70#define PRAGMA 9 71#define ERROR 10 72#define IDENT 11 73#define SCCS 12 74#define ELIF 13 75#define EJECT 14 76#define WARNING 15 77#define INCLUDENEXT 16 78#define IFFALSE 17 /* pseudo value --- never matched */ 79#define ELIFFALSE 18 /* pseudo value --- never matched */ 80#define INCLUDEDOT 19 /* pseudo value --- never matched */ 81#define IFGUESSFALSE 20 /* pseudo value --- never matched */ 82#define ELIFGUESSFALSE 21 /* pseudo value --- never matched */ 83#define INCLUDENEXTDOT 22 /* pseudo value --- never matched */ 84 85#ifdef DEBUG 86extern int _debugmask; 87/* 88 * debug levels are: 89 * 90 * 0 show ifn*(def)*,endif 91 * 1 trace defined/!defined 92 * 2 show #include 93 * 3 show #include SYMBOL 94 * 4-6 unused 95 */ 96#define debug(level,arg) { if (_debugmask & (1 << level)) warning arg; } 97#else 98#define debug(level,arg) /**/ 99#endif /* DEBUG */ 100 101typedef unsigned char boolean; 102 103struct symtab { 104 char *s_name; 105 char *s_value; 106}; 107 108/* possible i_flag */ 109#define DEFCHECKED (1<<0) /* whether defines have been checked */ 110#define NOTIFIED (1<<1) /* whether we have revealed includes */ 111#define MARKED (1<<2) /* whether it's in the makefile */ 112#define SEARCHED (1<<3) /* whether we have read this */ 113#define FINISHED (1<<4) /* whether we are done reading this */ 114#define INCLUDED_SYM (1<<5) /* whether #include SYMBOL was found 115 Can't use i_list if TRUE */ 116struct inclist { 117 char *i_incstring; /* string from #include line */ 118 char *i_file; /* path name of the include file */ 119 struct inclist **i_list; /* list of files it itself includes */ 120 int i_listlen; /* length of i_list */ 121 struct symtab **i_defs; /* symbol table for this file and its 122 children when merged */ 123 int i_ndefs; /* current # defines */ 124 boolean *i_merged; /* whether we have merged child 125 defines */ 126 unsigned char i_flags; 127}; 128 129struct filepointer { 130 char *f_name; 131 char *f_p; 132 char *f_base; 133 char *f_end; 134 long f_len; 135 long f_line; 136 long cmdinc_count; 137 char **cmdinc_list; 138 long cmdinc_line; 139}; 140 141#include <stdlib.h> 142#if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */ 143char *malloc(), *realloc(); 144#endif /* macII */ 145 146char *copy(char *str); 147int match(char *str, char **list); 148char *base_name(char *file); 149char *getnextline(struct filepointer *fp); 150struct symtab **slookup(char *symbol, struct inclist *file); 151struct symtab **isdefined(char *symbol, struct inclist *file, 152 struct inclist **srcfile); 153struct symtab **fdefined(char *symbol, struct inclist *file, 154 struct inclist **srcfile); 155struct filepointer *getfile(char *file); 156void included_by(struct inclist *ip, 157 struct inclist *newfile); 158struct inclist *newinclude(char *newfile, char *incstring); 159void inc_clean (void); 160struct inclist *inc_path(char *file, char *include, int type); 161 162void freefile(struct filepointer *fp); 163 164void define2(char *name, char *val, struct inclist *file); 165void define(char *def, struct inclist *file); 166void undefine(char *symbol, struct inclist *file); 167int find_includes(struct filepointer *filep, 168 struct inclist *file, 169 struct inclist *file_red, 170 int recursion, boolean failOK); 171 172void recursive_pr_include(struct inclist *head, 173 char *file, char *base); 174void add_include(struct filepointer *filep, 175 struct inclist *file, 176 struct inclist *file_red, 177 char *include, int type, 178 boolean failOK); 179 180int cppsetup(char *filename, 181 char *line, 182 struct filepointer *filep, 183 struct inclist *inc); 184 185 186extern void fatalerr(char *, ...); 187extern void warning(char *, ...); 188extern void warning1(char *, ...); 189