home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / fweb153.zip / fweb-1.53 / web / includes.hweb < prev    next >
Text File  |  1995-09-23  |  5KB  |  241 lines

  1. @z --- includes.hweb ---
  2.  
  3. FWEB version 1.53 (September 23, 1995)
  4.  
  5. Based on version 0.5 of S. Levy's CWEB [copyright (C) 1987 Princeton University]
  6.  
  7. @x-----------------------------------------------------------------------------
  8.  
  9. @ This file is included immediately after \.{custom.h}.  It contains logic
  10. based on the flags set in \.{custom.h}, includes some extra files that are
  11. pretty well standard, and includes the timing macros.
  12.  
  13. First, we try to ensure the preprocessor doesn't get annoyed.
  14.  
  15. @<Operating sys...@>=
  16.  
  17. /* SYSTEM LOGIC based on \.{custom.h}, and additional include files. */
  18.  
  19. #ifndef ANSI_CTYPE_H
  20.     #define ANSI_CTYPE_H 0
  21. #endif
  22.  
  23. #ifndef ANSI_SPRINTF
  24.     #define ANSI_SPRINTF 0
  25. #endif
  26.  
  27. #ifndef ANSI_SSCANF
  28.     #define ANSI_SSCANF 0
  29. #endif
  30.  
  31. #ifndef ANSI_SYSTEM
  32.     #define ANSI_SYSTEM 0
  33. #endif
  34.  
  35. #ifndef DEBUG_XCHR
  36.     #define DEBUG_XCHR 0
  37. #endif
  38.  
  39. #ifndef FCN_CALLS
  40.     #define FCN_CALLS 0
  41. #endif
  42.  
  43. #ifndef FANCY_SPLIT
  44.     #define FANCY_SPLIT 0
  45. #endif
  46.  
  47. #ifndef HAVE_ERROR
  48.     #define HAVE_ERROR 0
  49. #endif
  50.  
  51. #ifndef HAVE_GETENV
  52.     #define HAVE_GETENV 0
  53. #endif
  54.  
  55. #ifndef HAVE_GETTIMEOFDAY
  56.     #define HAVE_GETTIMEOFDAY 0
  57. #endif
  58.  
  59. #ifndef HAVE_LIMITS_H
  60.     #define HAVE_LIMITS_H 0
  61. #endif
  62.  
  63. #ifndef HAVE_SYS_TIMEB_H
  64.     #define HAVE_SYS_TIMEB_H 0
  65. #endif
  66.  
  67. #ifndef HAVE_STDARG_H
  68.     #define HAVE_STDARG_H 0
  69. #endif
  70.  
  71. #ifndef HAVE_STDDEF_H
  72.     #define HAVE_STDDEF_H 0
  73. #endif
  74.  
  75. #ifndef HAVE_STDLIB_H
  76.     #define HAVE_STDLIB_H 0
  77. #endif
  78.  
  79. #ifndef HAVE_STD_PROTOTYPES
  80.     #define HAVE_STD_PROTOTYPES 0
  81. #endif
  82.  
  83. #ifndef HAVE_STRERROR
  84.     #define HAVE_STRERROR 0
  85. #endif
  86.  
  87. #ifndef HAVE_VALUES_H
  88.     #define HAVE_VALUES_H 0
  89. #endif
  90.  
  91. #ifndef HUGE_POINTERS
  92.     #define HUGE_POINTERS 0
  93. #endif
  94.  
  95. #ifndef KEEP_CONST
  96.     #define KEEP_CONST 0
  97. #endif
  98.  
  99. #ifndef NEW_DIFFTIME
  100.     #define NEW_DIFFTIME 0
  101. #endif
  102.  
  103. #ifndef NO_VOID
  104.     #define NO_VOID 0
  105. #endif
  106.  
  107. #ifndef NON_ANSI_CALLOC
  108.     #define NON_ANSI_CALLOC 0
  109. #endif
  110.  
  111. #ifndef OLD_PROTOTYPES
  112.     #define OLD_PROTOTYPES 0
  113. #endif
  114.  
  115. #ifndef PRINT_AVAILABLE_MEMORY
  116.     #define PRINT_AVAILABLE_MEMORY 0
  117. #endif
  118.  
  119. #ifndef SIZE_T_DEFINED
  120.     #define SIZE_T_DEFINED 0
  121. #endif
  122.  
  123. #ifndef TIMING 
  124.     #define TIMING 0
  125. #endif
  126.  
  127. #ifndef TRANSLATE_ASCII 
  128.     #define TRANSLATE_ASCII 0
  129. #endif
  130.  
  131. #ifndef UNIX_PATH
  132.     #define UNIX_PATH 0
  133. #endif
  134.  
  135. @ Next, we start conditional processing.
  136. @<Operating sys...@>=
  137.  
  138. #if HAVE_STDARG_H
  139.     #include <stdarg.h>
  140. #else
  141.     #include <varargs.h>
  142. #endif
  143.  
  144. #if HAVE_STDLIB_H
  145.     #include <stdlib.h>
  146. #endif
  147.  
  148. #if !HAVE_STD_PROTOTYPES
  149.     #include "stdlib0.h"
  150. #endif
  151.  
  152. #if HAVE_STDDEF_H
  153.     #include <stddef.h>
  154. #endif
  155.  
  156. #if HAVE_LIMITS_H
  157.     #include <limits.h> // ANSI: Numerical limits.
  158. #else
  159.     #if HAVE_VALUES_H
  160.         #define INT_MAX MAXINT
  161.         #define LONG_MAX MAXLONG
  162.     #else
  163.         #define INT_MAX 0x7FFF
  164.         #define LONG_MAX INT_MAX
  165.     #endif
  166.  
  167.     #define INT_MIN (~(INT_MAX))
  168.     #define LONG_MIN (~(LONG_MAX))
  169.     #define ULONG_MAX (MAXLONG | (~(MAXLONG)))
  170.         /* E.g., |0x7FFF @t\OR@> 0x8000|. */
  171. #endif
  172.  
  173. #if HAVE_FLOAT_H
  174.     #include <float.h>
  175. #else
  176.     #ifndef DBL_DIG
  177.         #define DBL_DIG 10
  178.     #endif
  179. #endif
  180.  
  181. #if !NON_ANSI_CALLOC
  182.     #define CALLOC calloc
  183.     #define REALLOC(old_ptr, new_size, old_size) realloc(old_ptr, new_size)
  184.     #define FREE free
  185. #endif // |ANSI_CALLOC|
  186.  
  187.  
  188. /* Some compilers can't handle |unsigned long| constants of the form
  189. |123UL|.  Thus, these constants are declared via the following macro. */
  190.  
  191. #define UL(num) ((unsigned long)(num))
  192.  
  193. #include <stdio.h> // ANSI: STDIO routines.
  194. #include <errno.h>
  195.  
  196. /* We use only ANSI write routines. */
  197. #define FWRITE(buf,len,fp) fwrite((CONST void *)(buf),(size_t)(len),\
  198.                 (size_t)(1),fp)
  199.  
  200. #define WRITE1(buf,len) \
  201.     {\
  202.     int _k;\
  203.     outer_char *_p;\
  204.     for(_p=buf,_k=(int)(len); _k>0; _k--)\
  205.       {\
  206.       PUTC(*_p);\
  207.       _p++;\
  208.       }\
  209.     }
  210.  
  211. /* The following is courtesy of the autoconf Info file. */
  212. #if STDC_HEADERS || HAVE_STRING_H
  213.     #include <string.h> // ANSI: String manipulation routines.
  214.  
  215.     #if !STDC_HEADERS && HAVE_MEMORY_H
  216.         #include <memory.h>
  217.     #endif
  218. #else
  219.     #include <strings.h>
  220. #endif
  221.  
  222. #include <ctype.h> // ANSI: Character classification macros.
  223.  
  224. /* The following works only for |ASCII| machines.  Furthermore, it's slower
  225. than the usual procedure involving ANDing a |_ctype| array with various bit
  226. flags.  However, that procedure isn't portable across machines.  Caution:
  227. This solution evaluates |c| more than once, so watch out for side effects! */
  228. #if !ANSI_CTYPE_H
  229.     #undef isalpha
  230.     #undef isupper
  231.     #undef islower
  232.  
  233.     #define isupper(c) ('A' <= (unsigned)(c) && (unsigned)(c) <= 'Z')
  234.     #define islower(c) ('a' <= (unsigned)(c) && (unsigned)(c) <= 'z')
  235.     #define isalpha(c) (isupper(c) || islower(c))
  236. #endif
  237.  
  238. #include <setjmp.h> // ANSI: |longjmp| and |setjmp|.
  239.  
  240. @I time.hweb // Timing's quite an annoyance.
  241.