def.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* $Xorg: def.h,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */
  2. /*
  3. Copyright (c) 1993, 1994, 1998 The Open Group.
  4. Permission to use, copy, modify, distribute, and sell this software and its
  5. documentation for any purpose is hereby granted without fee, provided that
  6. the above copyright notice appear in all copies and that both that
  7. copyright notice and this permission notice appear in supporting
  8. documentation.
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  15. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  16. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. Except as contained in this notice, the name of The Open Group shall not be
  18. used in advertising or otherwise to promote the sale, use or other dealings
  19. in this Software without prior written authorization from The Open Group.
  20. */
  21. /* $XFree86: xc/config/makedepend/def.h,v 3.14 2003/01/17 17:09:49 tsi Exp $ */
  22. #ifndef NO_X11
  23. #include <X11/Xos.h>
  24. #include <X11/Xfuncproto.h>
  25. #endif
  26. #include <stdlib.h>
  27. #include <stdio.h>
  28. #include <string.h>
  29. #include <ctype.h>
  30. #if 0
  31. #ifndef X_NOT_POSIX
  32. #ifndef _POSIX_SOURCE
  33. #define _POSIX_SOURCE
  34. #endif
  35. #endif
  36. #endif
  37. #include <sys/types.h>
  38. #include <fcntl.h>
  39. #include <sys/stat.h>
  40. #define MAXDEFINES 512
  41. #define MAXFILES 1024
  42. #define MAXINCFILES 256 /* "-include" files */
  43. #define MAXDIRS 1024
  44. #define SYMTABINC 10 /* must be > 1 for define() to work right */
  45. #define TRUE 1
  46. #define FALSE 0
  47. /* the following must match the directives table in main.c */
  48. #define IF 0
  49. #define IFDEF 1
  50. #define IFNDEF 2
  51. #define ELSE 3
  52. #define ENDIF 4
  53. #define DEFINE 5
  54. #define UNDEF 6
  55. #define INCLUDE 7
  56. #define LINE 8
  57. #define PRAGMA 9
  58. #define ERROR 10
  59. #define IDENT 11
  60. #define SCCS 12
  61. #define ELIF 13
  62. #define EJECT 14
  63. #define WARNING 15
  64. #define INCLUDENEXT 16
  65. #define IFFALSE 17 /* pseudo value --- never matched */
  66. #define ELIFFALSE 18 /* pseudo value --- never matched */
  67. #define INCLUDEDOT 19 /* pseudo value --- never matched */
  68. #define IFGUESSFALSE 20 /* pseudo value --- never matched */
  69. #define ELIFGUESSFALSE 21 /* pseudo value --- never matched */
  70. #define INCLUDENEXTDOT 22 /* pseudo value --- never matched */
  71. #ifdef DEBUG
  72. extern int _debugmask;
  73. /*
  74. * debug levels are:
  75. *
  76. * 0 show ifn*(def)*,endif
  77. * 1 trace defined/!defined
  78. * 2 show #include
  79. * 3 show #include SYMBOL
  80. * 4-6 unused
  81. */
  82. #define debug(level,arg) { if (_debugmask & (1 << level)) warning arg; }
  83. #else
  84. #define debug(level,arg) /**/
  85. #endif /* DEBUG */
  86. typedef unsigned char boolean;
  87. struct symtab {
  88. char *s_name;
  89. char *s_value;
  90. };
  91. /* possible i_flag */
  92. #define DEFCHECKED (1<<0) /* whether defines have been checked */
  93. #define NOTIFIED (1<<1) /* whether we have revealed includes */
  94. #define MARKED (1<<2) /* whether it's in the makefile */
  95. #define SEARCHED (1<<3) /* whether we have read this */
  96. #define FINISHED (1<<4) /* whether we are done reading this */
  97. #define INCLUDED_SYM (1<<5) /* whether #include SYMBOL was found
  98. Can't use i_list if TRUE */
  99. struct inclist {
  100. char *i_incstring; /* string from #include line */
  101. char *i_file; /* path name of the include file */
  102. struct inclist **i_list; /* list of files it itself includes */
  103. int i_listlen; /* length of i_list */
  104. struct symtab **i_defs; /* symbol table for this file and its
  105. children when merged */
  106. int i_ndefs; /* current # defines */
  107. boolean *i_merged; /* whether we have merged child
  108. defines */
  109. unsigned char i_flags;
  110. };
  111. struct filepointer {
  112. char *f_name;
  113. char *f_p;
  114. char *f_base;
  115. char *f_end;
  116. long f_len;
  117. long f_line;
  118. long cmdinc_count;
  119. char **cmdinc_list;
  120. long cmdinc_line;
  121. };
  122. #include <stdlib.h>
  123. #if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */
  124. char *malloc(), *realloc();
  125. #endif /* macII */
  126. char *copy(char *str);
  127. int match(char *str, char **list);
  128. char *base_name(char *file);
  129. char *getnextline(struct filepointer *fp);
  130. struct symtab **slookup(char *symbol, struct inclist *file);
  131. struct symtab **isdefined(char *symbol, struct inclist *file,
  132. struct inclist **srcfile);
  133. struct symtab **fdefined(char *symbol, struct inclist *file,
  134. struct inclist **srcfile);
  135. struct filepointer *getfile(char *file);
  136. void included_by(struct inclist *ip,
  137. struct inclist *newfile);
  138. struct inclist *newinclude(char *newfile, char *incstring);
  139. void inc_clean (void);
  140. struct inclist *inc_path(char *file, char *include, int type);
  141. void freefile(struct filepointer *fp);
  142. void define2(char *name, char *val, struct inclist *file);
  143. void define(char *def, struct inclist *file);
  144. void undefine(char *symbol, struct inclist *file);
  145. int find_includes(struct filepointer *filep,
  146. struct inclist *file,
  147. struct inclist *file_red,
  148. int recursion, boolean failOK);
  149. void recursive_pr_include(struct inclist *head,
  150. char *file, char *base);
  151. void add_include(struct filepointer *filep,
  152. struct inclist *file,
  153. struct inclist *file_red,
  154. char *include, int type,
  155. boolean failOK);
  156. int cppsetup(char *filename,
  157. char *line,
  158. struct filepointer *filep,
  159. struct inclist *inc);
  160. extern void fatalerr(char *, ...);
  161. extern void warning(char *, ...);
  162. extern void warning1(char *, ...);