/* Utitlity macros for the W3 code library MACROS FOR GENERAL USE Generates: HTUtils.h See also: the system dependent file "tcp.h" */ #ifndef DEBUG #define DEBUG /* Noone ever turns this off as trace is too important */ #endif /* Keep option for really small memory applications tho */ #ifndef HTUTILS_H #define HTUTILS_H #ifdef HAVE_CONFIG_H #include /* generated by autoconf 'configure' script */ #else /* Explicit system-configure */ #ifdef VMS #define NO_SIZECHANGE #endif /* FIXME: these will be removed after completing auto-configure script */ #ifdef _IBMR2 #define USE_DIRENT /* sys V style directory open */ #endif /* _IBMR2 */ #ifdef _SYSV3 #include #define USE_DIRENT /* sys V style directory open */ #endif /* _SYSV3 */ /* Solaris. */ #if defined(sun) && defined(__svr4__) && !defined(USE_DIRENT) #define USE_DIRENT /* sys V style directory open */ #endif /* sun && __svr4__ && !USE_DIRENT */ #ifdef __alpha #define USE_DIRENT #endif /* __alpha */ #ifndef USE_DIRENT #ifdef SVR4 #define USE_DIRENT #endif /* SVR4 */ #endif /* !USE_DIRENT */ #ifndef SOLARIS2 #include /* For bzero etc */ #endif /* !SOLARIS2 */ #ifdef SCO #define sco #endif /* SCO */ #ifdef sco #include #define USE_DIRENT #endif /* sco */ /* Intergraph CLIX */ #ifdef CLIX #include #define USE_DIRENT #endif /* CLIX */ #ifdef ISC #ifndef NO_UNISTD_H #include #endif /* !NO_UNISTD_H */ #else #if !defined(NO_UNISTD_H) && !defined(VMS) #include #endif /* !NO_UNISTD_H && !VMS */ #endif /* ISC */ #if defined(SVR4) || defined(UNIXWARE) #include #ifndef NO_FILIO_H /* BSD Interactive doesn't have filio.h. */ #include #endif /* !NO_FILIO_H */ #endif /* SVR4 || UNIXWARE */ /* SOLARIS 2 */ #ifdef SOLARIS2 #include #endif /* SOLARIS2 */ #ifndef NO_FILIO_H #define NO_FILIO_H /* prevent conflict between autoconf & BSDI make */ #endif /* Accommodate pre-autoconf Makefile */ #ifndef NO_CBREAK #define HAVE_CBREAK 1 #endif #ifndef NO_CUSERID #define HAVE_CUSERID 1 #endif #ifndef NO_FILIO_H #define HAVE_SYS_FILIO_H 1 #endif #ifndef NO_GETCWD #define HAVE_GETCWD 1 #endif #ifndef USE_SLANG #ifndef NO_KEYPAD #define HAVE_KEYPAD 1 #endif #ifndef NO_TTYTYPE #define HAVE_TTYTYPE 1 #endif #endif /* USE_SLANG */ #ifndef NO_PUTENV #define HAVE_PUTENV 1 #endif #ifndef NO_SIZECHANGE #define HAVE_SIZECHANGE 1 #endif #ifndef NO_UNISTD_H #define HAVE_UNISTD_H 1 #endif #ifndef NO_UTMP #define HAVE_UTMP 1 #endif #endif #ifdef _WINDOWS /* SCW */ #include "windef.h" #define BOOLEAN_DEFINED #define va_arg #include #define popen _popen #define pclose _pclose #endif /* _WINDOWS */ #ifdef SHORT_NAMES #define WWW_TraceFlag HTTrFlag #endif /* Debug message control. */ #ifndef STDIO_H #include #define STDIO_H #endif #ifdef DEBUG #define TRACE (WWW_TraceFlag) #define PROGRESS(str) printf(str) extern int WWW_TraceFlag; #else #define TRACE 0 #define PROGRESS(str) /* nothing for now */ #endif #define CTRACE if(TRACE)fprintf #define tfp stderr /* ERROR TYPE This is passed back when streams are aborted. It might be nice to have some structure of error messages, numbers, and recursive pointers to reasons. Curently this is a placeholder for something more sophisticated. */ typedef void * HTError; /* Unused at present -- best definition? */ /* Standard C library for malloc() etc */ #ifdef DGUX #include #endif /* DGUX */ #ifdef vax #ifdef unix #define ultrix /* Assume vax+unix=ultrix */ #endif /* unix */ #endif /* vax */ #ifndef VMS #ifndef ultrix #ifdef NeXT #include /* NeXT */ #endif /* NeXT */ #ifndef MACH /* Vincent.Cate@furmint.nectar.cs.cmu.edu */ #ifndef __STRICT_BSD__ #include #endif /* !__STRICT_BSD__ */ #endif /* !MACH */ #else /* ultrix: */ #include #include #include #include /* ANSI */ /* BSN */ #endif /* !ultrix */ #else /* VMS: */ #include #include #include #if defined(VAXC) && !defined(__DECC) #define malloc VAXC$MALLOC_OPT #define calloc VAXC$CALLOC_OPT #define free VAXC$FREE_OPT #define cfree VAXC$CFREE_OPT #define realloc VAXC$REALLOC_OPT #endif /* VAXC && !__DECC */ #endif /* !VMS */ /* Macros for declarations */ #define PUBLIC /* Accessible outside this module */ #define PRIVATE static /* Accessible only within this module */ #ifdef __STDC__ #define CONST const /* "const" only exists in STDC */ #define NOPARAMS (void) #define PARAMS(parameter_list) parameter_list #define NOARGS (void) #define ARGS1(t,a) \ (t a) #define ARGS2(t,a,u,b) \ (t a, u b) #define ARGS3(t,a,u,b,v,c) \ (t a, u b, v c) #define ARGS4(t,a,u,b,v,c,w,d) \ (t a, u b, v c, w d) #define ARGS5(t,a,u,b,v,c,w,d,x,e) \ (t a, u b, v c, w d, x e) #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) \ (t a, u b, v c, w d, x e, y f) #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) \ (t a, u b, v c, w d, x e, y f, z g) #define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) \ (t a, u b, v c, w d, x e, y f, z g, s h) #define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) \ (t a, u b, v c, w d, x e, y f, z g, s h, r i) #define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) \ (t a, u b, v c, w d, x e, y f, z g, s h, r i, q j) #else /* not ANSI */ #ifndef _WINDOWS #define CONST #endif #define NOPARAMS () #define PARAMS(parameter_list) () #define NOARGS () #define ARGS1(t,a) (a) \ t a; #define ARGS2(t,a,u,b) (a,b) \ t a; u b; #define ARGS3(t,a,u,b,v,c) (a,b,c) \ t a; u b; v c; #define ARGS4(t,a,u,b,v,c,w,d) (a,b,c,d) \ t a; u b; v c; w d; #define ARGS5(t,a,u,b,v,c,w,d,x,e) (a,b,c,d,e) \ t a; u b; v c; w d; x e; #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) (a,b,c,d,e,f) \ t a; u b; v c; w d; x e; y f; #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) (a,b,c,d,e,f,g) \ t a; u b; v c; w d; x e; y f; z g; #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) \ t a; u b; v c; w d; x e; y f; z g; s h; #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) \ t a; u b; v c; w d; x e; y f; z g; s h; r i; #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) \ t a; u b; v c; w d; x e; y f; z g; s h; r i; q j; #endif /* __STDC__ (ANSI) */ #ifndef NULL #define NULL ((void *)0) #endif /* Booleans */ /* Note: GOOD and BAD are already defined (differently) on RS6000 aix */ /* #define GOOD(status) ((status)38;1) VMS style status: test bit 0 */ /* #define BAD(status) (!GOOD(status)) Bit 0 set if OK, otherwise clear */ #ifndef _WINDOWS #ifndef BOOLEAN_DEFINED typedef char BOOLEAN; /* Logical value */ #ifndef CURSES #ifndef TRUE #define TRUE (BOOLEAN)1 #define FALSE (BOOLEAN)0 #endif #endif /* CURSES */ #endif /* _WINDOWS */ #define BOOLEAN_DEFINED #endif #ifndef BOOL #define BOOL BOOLEAN #endif #ifndef YES #define YES (BOOLEAN)1 #define NO (BOOLEAN)0 #endif extern BOOL LYOutOfMemory; /* Declared in LYexit.c - FM */ #define TCP_PORT 80 /* Allocated to http by Jon Postel/ISI 24-Jan-92 */ #define OLD_TCP_PORT 2784 /* Try the old one if no answer on 80 */ #define DNP_OBJ 80 /* This one doesn't look busy, but we must check */ /* That one was for decnet */ /* Inline Function WHITE: Is character c white space? */ /* For speed, include all control characters */ #define WHITE(c) (((unsigned char)(TOASCII(c))) <= 32) /* Sucess (>=0) and failure (<0) codes */ #define HT_REDIRECTING 29996 #define HT_LOADED 29997 /* Instead of a socket */ #define HT_PARTIAL_CONTENT 206 /* Partial Content */ #define HT_INTERRUPTED -29998 #define HT_NOT_LOADED -29999 #define HT_OK 0 /* Generic success*/ #define HT_ERROR -1 /* Generic failure */ #define HT_NO_ACCESS -10 /* Access not available */ #define HT_FORBIDDEN -11 /* Access forbidden */ #define HT_INTERNAL -12 /* Weird -- should never happen. */ #define HT_BAD_EOF -12 /* Premature EOF */ #include "HTString.h" /* String utilities */ #ifndef va_arg #ifdef __STDC__ #include #else #include #endif #endif /* Out Of Memory checking for malloc() return: */ #ifndef __FILE__ #define __FILE__ "" #define __LINE__ "" #endif #include "LYexit.h" #define outofmem(file, func)\ { fprintf(stderr,\ "\r\n\r\n\r\n%s %s: out of memory. Aborting...\r\n", file, func);\ LYOutOfMemory = TRUE; exit(-1);} /* extern void outofmem PARAMS((const char *fname, const char *func)); */ /* Upper- and Lowercase macros The problem here is that toupper(x) is not defined officially unless isupper(x) is. These macros are CERTAINLY needed on #if defined(pyr) || define(mips) or BDSI platforms. For safefy, we make them mandatory. */ #include #include #ifndef TOLOWER /* Pyramid and Mips can't uppercase non-alpha */ #define TOLOWER(c) (isupper((unsigned char)c) ? tolower((unsigned char)c) : (c)) #define TOUPPER(c) (islower((unsigned char)c) ? toupper((unsigned char)c) : (c)) #endif /* ndef TOLOWER */ /* The local equivalents of CR and LF We can check for these after net ascii text has been converted to the local representation. Similarly, we include them in strings to be sent as net ascii after translation. */ #define LF FROMASCII('\012') /* ASCII line feed LOCAL EQUIVALENT */ #define CR FROMASCII('\015') /* Will be converted to ^M for transmission */ #endif /* HTUTILS_H */ /* end of utilities */