Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* $XConsortium: def.h,v 1.25 94/04/17 20:10:33 gildea Exp $ */
  2. /*
  3. Copyright (c) 1993, 1994 X Consortium
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  16. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  17. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  18. Except as contained in this notice, the name of the X Consortium shall not be
  19. used in advertising or otherwise to promote the sale, use or other dealings
  20. in this Software without prior written authorization from the X Consortium.
  21. */
  22. #include <stdio.h>
  23. #include <ctype.h>
  24. #ifndef X_NOT_POSIX
  25. #ifndef _POSIX_SOURCE
  26. #define _POSIX_SOURCE
  27. #endif
  28. #endif
  29. #include <sys/types.h>
  30. #include <fcntl.h>
  31. #include <sys/stat.h>
  32. #define MAXDEFINES 512
  33. #define MAXFILES 512
  34. #define MAXDIRS 64
  35. #define SYMTABINC 10 /* must be > 1 for define() to work right */
  36. #define TRUE 1
  37. #define FALSE 0
  38. /* the following must match the directives table in main.c */
  39. #define IF 0
  40. #define IFDEF 1
  41. #define IFNDEF 2
  42. #define ELSE 3
  43. #define ENDIF 4
  44. #define DEFINE 5
  45. #define UNDEF 6
  46. #define INCLUDE 7
  47. #define LINE 8
  48. #define PRAGMA 9
  49. #define ERROR 10
  50. #define IDENT 11
  51. #define SCCS 12
  52. #define ELIF 13
  53. #define EJECT 14
  54. #define IFFALSE 15 /* pseudo value --- never matched */
  55. #define ELIFFALSE 16 /* pseudo value --- never matched */
  56. #define INCLUDEDOT 17 /* pseudo value --- never matched */
  57. #define IFGUESSFALSE 18 /* pseudo value --- never matched */
  58. #define ELIFGUESSFALSE 19 /* pseudo value --- never matched */
  59. #ifdef DEBUG
  60. extern int _debugmask;
  61. /*
  62. * debug levels are:
  63. *
  64. * 0 show ifn*(def)*,endif
  65. * 1 trace defined/!defined
  66. * 2 show #include
  67. * 3 show #include SYMBOL
  68. * 4-6 unused
  69. */
  70. #define debug(level,arg) { if (_debugmask & (1 << level)) warning arg; }
  71. #else
  72. #define debug(level,arg) /**/
  73. #endif /* DEBUG */
  74. typedef unsigned char boolean;
  75. struct symtab {
  76. char *s_name;
  77. char *s_value;
  78. };
  79. struct inclist {
  80. char *i_incstring; /* string from #include line */
  81. char *i_file; /* path name of the include file */
  82. struct inclist **i_list; /* list of files it itself includes */
  83. int i_listlen; /* length of i_list */
  84. struct symtab *i_defs; /* symbol table for this file */
  85. int i_ndefs; /* current # defines */
  86. int i_deflen; /* amount of space in table */
  87. boolean i_defchecked; /* whether defines have been checked */
  88. boolean i_notified; /* whether we have revealed includes */
  89. boolean i_marked; /* whether it's in the makefile */
  90. boolean i_searched; /* whether we have read this */
  91. boolean i_included_sym; /* whether #include SYMBOL was found */
  92. /* Can't use i_list if TRUE */
  93. };
  94. struct filepointer {
  95. char *f_p;
  96. char *f_base;
  97. char *f_end;
  98. long f_len;
  99. long f_line;
  100. };
  101. #ifndef X_NOT_STDC_ENV
  102. #include <stdlib.h>
  103. #if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */
  104. char *malloc(), *realloc();
  105. #endif /* macII */
  106. #else
  107. char *malloc();
  108. char *realloc();
  109. #endif
  110. char *copy();
  111. char *base_name();
  112. char *getline();
  113. struct symtab *slookup();
  114. struct symtab *isdefined();
  115. struct symtab *fdefined();
  116. struct filepointer *getfile();
  117. struct inclist *newinclude();
  118. struct inclist *inc_path();
  119. #if NeedVarargsPrototypes
  120. extern fatalerr(char *, ...);
  121. extern warning(char *, ...);
  122. extern warning1(char *, ...);
  123. #endif