PageRenderTime 48ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/libwww2/HTUtils.h

http://github.com/alandipert/ncsa-mosaic
C Header | 268 lines | 147 code | 39 blank | 82 comment | 0 complexity | 0631df66b92c3ecc9eea466cf13b10fb MD5 | raw file
  1. /* Utitlity macros for the W3 code library
  2. MACROS FOR GENERAL USE
  3. Generates: HTUtils.h
  4. See also: the system dependent file "tcp.h"
  5. */
  6. #ifndef DEBUG
  7. #define DEBUG /* Noone ever turns this off as trace is too important */
  8. #endif /* Keeep option for really small memory applications tho */
  9. #ifndef HTUTILS_H
  10. #define HTUTILS_H
  11. #ifdef SHORT_NAMES
  12. #define WWW_TraceFlag HTTrFlag
  13. #endif
  14. /*
  15. Debug message control.
  16. */
  17. #ifndef STDIO_H
  18. #include <stdio.h>
  19. #define STDIO_H
  20. #endif
  21. /*
  22. * Tracing now works as a boolean from a resource. No, there are no
  23. * more if's than before...
  24. *
  25. * SWP -- 02/08/96
  26. */
  27. /*
  28. #ifdef DEBUG
  29. #define TRACE (WWW_TraceFlag)
  30. #define PROGRESS(str) printf(str)
  31. extern int WWW_TraceFlag;
  32. #else
  33. #define TRACE 0
  34. #define PROGRESS(str)
  35. #endif
  36. #undef TRACE
  37. #define TRACE 1
  38. #ifdef TRACE
  39. #define HTTP_TRACE 1
  40. #endif
  41. #define CTRACE if(TRACE)fprintf
  42. #define tfp stderr
  43. */
  44. /*
  45. Standard C library for malloc() etc
  46. */
  47. #ifdef vax
  48. #ifdef unix
  49. #define ultrix /* Assume vax+unix=ultrix */
  50. #endif
  51. #endif
  52. #ifndef VMS
  53. #ifndef ultrix
  54. #ifdef NeXT
  55. #include <libc.h> /* NeXT */
  56. #endif
  57. #ifndef MACH /* Vincent.Cate@furmint.nectar.cs.cmu.edu */
  58. #include <stdlib.h> /* ANSI */
  59. #endif
  60. #else /* ultrix */
  61. #include <malloc.h>
  62. #include <memory.h>
  63. #include <stdio.h>
  64. #endif
  65. #else /* VMS */
  66. #include <stdio.h>
  67. #include <ctype.h>
  68. #endif
  69. #ifdef __sgi
  70. #include <malloc.h>
  71. #endif
  72. /*
  73. Macros for declarations
  74. */
  75. #define PUBLIC /* Accessible outside this module */
  76. #define PRIVATE static /* Accessible only within this module */
  77. #ifdef __STDC__
  78. #if 0
  79. #define WWW_CONST const /* "const" only exists in STDC */
  80. #endif
  81. #define WWW_CONST
  82. #define NOPARAMS (void)
  83. #define PARAMS(parameter_list) parameter_list
  84. #define NOARGS (void)
  85. #define ARGS1(t,a) \
  86. (t a)
  87. #define ARGS2(t,a,u,b) \
  88. (t a, u b)
  89. #define ARGS3(t,a,u,b,v,c) \
  90. (t a, u b, v c)
  91. #define ARGS4(t,a,u,b,v,c,w,d) \
  92. (t a, u b, v c, w d)
  93. #define ARGS5(t,a,u,b,v,c,w,d,x,e) \
  94. (t a, u b, v c, w d, x e)
  95. #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) \
  96. (t a, u b, v c, w d, x e, y f)
  97. #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) \
  98. (t a, u b, v c, w d, x e, y f, z g)
  99. #define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) \
  100. (t a, u b, v c, w d, x e, y f, z g, s h)
  101. #define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) \
  102. (t a, u b, v c, w d, x e, y f, z g, s h, r i)
  103. #define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) \
  104. (t a, u b, v c, w d, x e, y f, z g, s h, r i, q j)
  105. #else /* not ANSI */
  106. #define WWW_CONST
  107. #define NOPARAMS ()
  108. #define PARAMS(parameter_list) ()
  109. #define NOARGS ()
  110. #define ARGS1(t,a) (a) \
  111. t a;
  112. #define ARGS2(t,a,u,b) (a,b) \
  113. t a; u b;
  114. #define ARGS3(t,a,u,b,v,c) (a,b,c) \
  115. t a; u b; v c;
  116. #define ARGS4(t,a,u,b,v,c,w,d) (a,b,c,d) \
  117. t a; u b; v c; w d;
  118. #define ARGS5(t,a,u,b,v,c,w,d,x,e) (a,b,c,d,e) \
  119. t a; u b; v c; w d; x e;
  120. #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) (a,b,c,d,e,f) \
  121. t a; u b; v c; w d; x e; y f;
  122. #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) (a,b,c,d,e,f,g) \
  123. t a; u b; v c; w d; x e; y f; z g;
  124. #define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) (a,b,c,d,e,f,g,h) \
  125. t a; u b; v c; w d; x e; y f; z g; s h;
  126. #define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) (a,b,c,d,e,f,g,h,i) \
  127. t a; u b; v c; w d; x e; y f; z g; s h; r i;
  128. #define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) (a,b,c,d,e,f,g,h,i,j) \
  129. t a; u b; v c; w d; x e; y f; z g; s h; r i; q j;
  130. #endif /* __STDC__ (ANSI) */
  131. #ifndef NULL
  132. #define NULL ((void *)0)
  133. #endif
  134. /*
  135. Booleans
  136. */
  137. /* Note: GOOD and BAD are already defined (differently) on RS6000 aix */
  138. /* #define GOOD(status) ((status)38;1) VMS style status: test bit 0 */
  139. /* #define BAD(status) (!GOOD(status)) Bit 0 set if OK, otherwise clear */
  140. #ifndef BOOLEAN_DEFINED
  141. typedef char BOOLEAN; /* Logical value */
  142. #ifndef TRUE
  143. #define TRUE (BOOLEAN)1
  144. #define FALSE (BOOLEAN)0
  145. #endif
  146. #define BOOLEAN_DEFINED
  147. #endif
  148. #ifndef BOOL
  149. #define BOOL BOOLEAN
  150. #endif
  151. #ifndef YES
  152. #define YES (BOOLEAN)1
  153. #define NO (BOOLEAN)0
  154. #endif
  155. #ifndef min
  156. #define min(a,b) ((a) <= (b) ? (a) : (b))
  157. #define max(a,b) ((a) >= (b) ? (a) : (b))
  158. #endif
  159. #define TCP_PORT 80 /* Allocated to http by Jon Postel/ISI 24-Jan-92 */
  160. /* Inline Function WHITE: Is character c white space? */
  161. /* For speed, include all control characters */
  162. #define WHITE(c) (((unsigned char)(c)) <= 32)
  163. /*
  164. Sucess (>=0) and failure (<0) codes
  165. */
  166. #define HT_REDIRECTING 29998
  167. #define HT_LOADED 29999 /* Instead of a socket */
  168. #define HT_INTERRUPTED -29998
  169. #define HT_NOT_LOADED -29999
  170. #define HT_OK 0 /* Generic success*/
  171. #define HT_NO_ACCESS -10 /* Access not available */
  172. #define HT_FORBIDDEN -11 /* Access forbidden */
  173. #define HT_INTERNAL -12 /* Weird -- should never happen. */
  174. #define HT_BAD_EOF -12 /* Premature EOF */
  175. #include "HTString.h" /* String utilities */
  176. #ifdef __STDC__
  177. #include <stdarg.h>
  178. #else
  179. #include <varargs.h>
  180. #endif
  181. /*
  182. Out Of Memory checking for malloc() return:
  183. */
  184. #ifndef __FILE__
  185. #define __FILE__ ""
  186. #define __LINE__ ""
  187. #endif
  188. #define outofmem(file, func) \
  189. { fprintf(stderr, "%s %s: out of memory.\nProgram aborted.\n", file, func); \
  190. exit(1);}
  191. /*
  192. Upper- and Lowercase macros
  193. The problem here is that toupper(x) is not defined officially unless isupper(x) is.
  194. These macros are CERTAINLY needed on #if defined(pyr) || define(mips) or BDSI
  195. platforms. For safefy, we make them mandatory.
  196. */
  197. #include <ctype.h>
  198. #ifndef TOLOWER
  199. /* Pyramid and Mips can't uppercase non-alpha */
  200. #define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
  201. #define TOUPPER(c) (islower(c) ? toupper(c) : (c))
  202. #endif /* ndef TOLOWER */
  203. #define CR '\015' /* Must be converted to ^M for transmission */
  204. #define LF '\012' /* Must be converted to ^J for transmission */
  205. #endif /* HTUTILS_H */
  206. /*
  207. end of utilities */