Annotation of libwww/Library/src/HTUtils.html, revision 2.2

2.1       timbl       1: <PRE>
                      2: /*     Macros for general use                                  HTUtils.h
                      3: **
                      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:                
                     10: #ifndef HTUTILS_H
                     11: #define HTUTILS_H
                     12: 
                     13: #ifdef SHORT_NAMES
                     14: #define WWW_TraceFlag HTTrFlag
                     15: #endif
                     16: 
                     17: /*     Debug message control.
                     18: */
                     19: #ifndef STDIO_H
2.2     ! timbl      20: #include &#60;stdio.h>
2.1       timbl      21: #define STDIO_H
                     22: #endif
                     23: 
                     24: #ifdef DEBUG
                     25: #define TRACE (WWW_TraceFlag)
                     26: #define PROGRESS(str) printf(str)
                     27:        extern int WWW_TraceFlag;
                     28: #else
                     29: #define TRACE 0
                     30: #define PROGRESS(str) /* nothing for now */
                     31: #endif
                     32: 
                     33: #define CTRACE if(TRACE)fprintf
                     34: #define tfp stdout
                     35: 
                     36: 
                     37: /*     Standard C library for malloc() etc
                     38: */
                     39: #ifdef vax
                     40: #ifdef unix
                     41: #define ultrix /* Assume vax+unix=ultrix */
                     42: #endif
                     43: #endif
                     44: 
                     45: #ifndef VMS
                     46: #ifndef ultrix
                     47: #ifdef NeXT
2.2     ! timbl      48: #include &#60;libc.h>  /* NeXT */
2.1       timbl      49: #endif
                     50: #ifndef MACH /* Vincent.Cate@furmint.nectar.cs.cmu.edu */
2.2     ! timbl      51: #include &#60;stdlib.h>        /* ANSI */
2.1       timbl      52: #endif
                     53: #else /* ultrix */
2.2     ! timbl      54: #include &#60;malloc.h>
        !            55: #include &#60;memory.h>
        !            56: #include &#60;stdio.h>
2.1       timbl      57: #endif
                     58: 
                     59: #else  /* VMS */
2.2     ! timbl      60: #include &#60;stdio.h>
        !            61: #include &#60;ctype.h>
2.1       timbl      62: #endif
                     63: 
                     64: #define PUBLIC                 /* Accessible outside this module     */
                     65: #define PRIVATE static         /* Accessible only within this module */
                     66: 
                     67: #ifdef __STDC__
                     68: #define CONST const            /* "const" only exists in STDC */
                     69: #define NOPARAMS (void)
                     70: #define PARAMS(parameter_list) parameter_list
                     71: #define NOARGS (void)
                     72: #define ARGS1(t,a) \
                     73:                (t a)
                     74: #define ARGS2(t,a,u,b) \
                     75:                (t a, u b)
                     76: #define ARGS3(t,a,u,b,v,c) \
                     77:                (t a, u b, v c)
                     78: #define ARGS4(t,a,u,b,v,c,w,d) \
                     79:                (t a, u b, v c, w d)
                     80: #define ARGS5(t,a,u,b,v,c,w,d,x,e) \
                     81:                (t a, u b, v c, w d, x e)
                     82: #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) \
                     83:                (t a, u b, v c, w d, x e, y f)
                     84: #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) \
                     85:                (t a, u b, v c, w d, x e, y f, z g)
                     86: #define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) \
                     87:                (t a, u b, v c, w d, x e, y f, z g, s h)
                     88: #define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) \
                     89:                (t a, u b, v c, w d, x e, y f, z g, s h, r i)
                     90: #define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) \
                     91:                (t a, u b, v c, w d, x e, y f, z g, s h, r i, q j)
                     92: 
                     93: #else  /* not ANSI */
                     94: 
                     95: #define CONST
                     96: #define NOPARAMS ()
                     97: #define PARAMS(parameter_list) ()
                     98: #define NOARGS ()
                     99: #define ARGS1(t,a) (a) \
                    100:                t a;
                    101: #define ARGS2(t,a,u,b) (a,b) \
                    102:                t a; u b;
                    103: #define ARGS3(t,a,u,b,v,c) (a,b,c) \
                    104:                t a; u b; v c;
                    105: #define ARGS4(t,a,u,b,v,c,w,d) (a,b,c,d) \
                    106:                t a; u b; v c; w d;
                    107: #define ARGS5(t,a,u,b,v,c,w,d,x,e) (a,b,c,d,e) \
                    108:                t a; u b; v c; w d; x e;
                    109: #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) (a,b,c,d,e,f) \
                    110:                t a; u b; v c; w d; x e; y f;
                    111: #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) (a,b,c,d,e,f,g) \
                    112:                t a; u b; v c; w d; x e; y f; z g;
                    113: #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) \
                    114:                t a; u b; v c; w d; x e; y f; z g; s h;
                    115: #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) \
                    116:                t a; u b; v c; w d; x e; y f; z g; s h; r i;
                    117: #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) \
                    118:                t a; u b; v c; w d; x e; y f; z g; s h; r i q j;
                    119:                
                    120:        
                    121: #endif /* __STDC__ (ANSI) */
                    122: 
                    123: #ifndef NULL
                    124: #define NULL ((void *)0)
                    125: #endif
                    126: 
                    127: 
                    128: /* Note: GOOD and BAD are already defined (differently) on RS6000 aix */
2.2     ! timbl     129: /* #define GOOD(status) ((status)&#38;1)        VMS style status: test bit 0         */
2.1       timbl     130: /* #define BAD(status)  (!GOOD(status))         Bit 0 set if OK, otherwise clear   */
                    131: 
                    132: #ifndef BOOLEAN_DEFINED
                    133:        typedef char    BOOLEAN;                /* Logical value */
                    134: #ifndef CURSES
                    135: #ifndef TRUE
                    136: #define TRUE   (BOOLEAN)1
                    137: #define        FALSE   (BOOLEAN)0
                    138: #endif
                    139: #endif
                    140: #define BOOLEAN_DEFINED
                    141: #endif
                    142: 
                    143: #ifndef BOOL
                    144: #define BOOL BOOLEAN
                    145: #endif
                    146: #ifndef YES
                    147: #define YES (BOOLEAN)1
                    148: #define NO (BOOLEAN)0
                    149: #endif
                    150: 
                    151: #ifndef min
2.2     ! timbl     152: #define min(a,b) ((a) &#60;= (b) ? (a) : (b))
        !           153: #define max(a,b) ((a) >= (b) ? (a) : (b))
2.1       timbl     154: #endif
                    155: 
                    156: #define TCP_PORT 80    /* Allocated to http by Jon Postel/ISI 24-Jan-92 */
                    157: #define OLD_TCP_PORT 2784      /* Try the old one if no answer on 80 */
                    158: #define DNP_OBJ 80     /* This one doesn't look busy, but we must check */
                    159: 
                    160: /*     Inline Function WHITE: Is character c white space? */
                    161: /*     For speed, include all control characters */
                    162: 
2.2     ! timbl     163: #define WHITE(c) (((unsigned char)(TOASCII(c)))&#60;=32)
2.1       timbl     164: 
                    165: 
2.2     ! timbl     166: /*     Sucess (>=0) and failure (&#60;0) codes
2.1       timbl     167: */
                    168: #define HT_LOADED 29999                        /* Instead of a socket */
                    169: #define HT_OK          0               /* Generic success*/
                    170: 
                    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: 
                    176: #include "HTString.h"  /* String utilities */
                    177: 
                    178: #ifdef __STDC__
2.2     ! timbl     179: #include &#60;stdarg.h>
2.1       timbl     180: #else
2.2     ! timbl     181: #include &#60;varargs.h>
2.1       timbl     182: #endif
                    183: 
                    184: #ifdef CURSES
                    185:        /* htbrowse.c; */
2.2     ! timbl     186: #include &#60;curses.h>
2.1       timbl     187: 
                    188:        extern        WINDOW  *w_top, *w_text, *w_prompt;
                    189:        extern        void    user_message PARAMS((const char *fmt, ...));
                    190:        extern        void    prompt_set PARAMS((CONST char * msg));
                    191:        extern        void    prompt_count PARAMS((long kb));
                    192: #else
                    193: #define user_message printf
                    194: #endif
                    195: 
                    196: /*     Out Of Memory checking for malloc() return:
                    197: */
                    198: #ifndef __FILE__
                    199: #define __FILE__ ""
                    200: #define __LINE__ ""
                    201: #endif
                    202: 
                    203: #define outofmem(file, func) \
                    204:  { fprintf(stderr, "%s %s: out of memory.\nProgram aborted.\n", file, func); \
                    205:   exit(1);}
                    206: /* extern void outofmem PARAMS((const char *fname, const char *func)); */
                    207: 
                    208: 
                    209: extern void msg_init PARAMS((int height));
                    210: extern void msg_printf PARAMS((int y, const char *fmt, ...));
                    211: extern void msg_exit PARAMS((int wait_for_key));
                    212: 
                    213: /*     Upper- and Lowercase macros
                    214: **
                    215: **  The problem here is that toupper(x) is not defined officially unless
                    216: **  isupper(x) is.  These macros are CERTAINLY needed on
                    217: **  #if defined(pyr) || define(mips) or BDSI platforms.
                    218: ** For safefy, we make them mandatory.
                    219: */
                    220: 
2.2     ! timbl     221: #include &#60;ctype.h>
2.1       timbl     222: 
                    223: #ifndef TOLOWER
                    224:   /* Pyramid and Mips can't uppercase non-alpha */
                    225: #define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
                    226: #define TOUPPER(c) (islower(c) ? toupper(c) : (c))
                    227: #endif /* ndef TOLOWER */
                    228: 
                    229: #endif /* HTUTILS_H */
                    230: 
                    231: </PRE>

Webmaster