home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / network / src_1218.zip / GLOBAL.H < prev    next >
C/C++ Source or Header  |  1991-06-02  |  6KB  |  217 lines

  1. #ifndef _GLOBAL_H
  2. #define    _GLOBAL_H
  3.  
  4. /* Global definitions used by every source file.
  5.  * Some may be compiler dependent.
  6.  */
  7.  
  8. #if    defined(__TURBOC__) || defined(__STDC__) || defined(LATTICE)
  9. #define    ANSIPROTO    1
  10. #endif
  11.  
  12. #ifndef    __ARGS
  13. #ifdef    ANSIPROTO
  14. #define    __ARGS(x)    x
  15. #else
  16. #define    __ARGS(x)    ()
  17. #endif
  18. #endif
  19.  
  20.  
  21. #if    !defined(AMIGA) && (defined(LATTICE) || defined(MAC) || defined(__TURBOC__))
  22. /* These compilers require special open modes when reading binary files.
  23.  *
  24.  * "The single most brilliant design decision in all of UNIX was the
  25.  * choice of a SINGLE character as the end-of-line indicator" -- M. O'Dell
  26.  *
  27.  * "Whoever picked the end-of-line conventions for MS-DOS and the Macintosh
  28.  * should be shot!" -- P. Karn's corollary to O'Dells' declaration
  29.  */
  30. #define    READ_BINARY    "rb"
  31. #define    WRITE_BINARY    "wb"
  32. #define    APPEND_BINARY    "ab+"
  33. #define    READ_TEXT    "rt"
  34. #define    WRITE_TEXT    "wt"
  35. #define    APPEND_TEXT    "at+"
  36.  
  37. #else
  38.  
  39. #define    READ_BINARY    "r"
  40. #define    WRITE_BINARY    "w"
  41. #define    APPEND_BINARY    "a+"
  42. #define    READ_TEXT    "r"
  43. #define    WRITE_TEXT    "w"
  44. #define    APPEND_TEXT    "a+"
  45.  
  46. #endif
  47.  
  48. /* These two lines assume that your compiler's longs are 32 bits and
  49.  * shorts are 16 bits. It is already assumed that chars are 8 bits,
  50.  * but it doesn't matter if they're signed or unsigned.
  51.  */
  52. typedef long int32;        /* 32-bit signed integer */
  53. typedef unsigned short int16;    /* 16-bit unsigned integer */
  54. typedef unsigned char byte_t;    /*  8-bit unsigned integer */
  55. #define    uchar(x) ((unsigned char)(x))
  56. #define    MAXINT16 65535        /* Largest 16-bit integer */
  57. #define    MAXINT32 4294967295L    /* Largest 32-bit integer */
  58.  
  59. #define    HASHMOD    7        /* Modulus used by hash_ip() function */
  60.  
  61. /* The "interrupt" keyword is non-standard, so make it configurable */
  62. #if    defined(__TURBOC__) && defined(MSDOS)
  63. #define    INTERRUPT    void interrupt
  64. #else
  65. #define    INTERRUPT    void
  66. #endif
  67.  
  68. /* Note that these definitions are on by default if none of the Turbo-C style
  69.  * memory model definitions are on; this avoids having to change them when
  70.  * porting to 68K environments.
  71.  */
  72. #if    !defined(__TINY__) && !defined(__SMALL__) && !defined(__MEDIUM__)
  73. #define    LARGEDATA    1
  74. #endif
  75.  
  76. #if    !defined(__TINY__) && !defined(__SMALL__) && !defined(__COMPACT__)
  77. #define    LARGECODE    1
  78. #endif
  79.  
  80. /* Since not all compilers support structure assignment, the ASSIGN()
  81.  * macro is used. This controls how it's actually implemented.
  82.  */
  83. #ifdef    NOSTRUCTASSIGN    /* Version for old compilers that don't support it */
  84. #define    ASSIGN(a,b)    memcpy((char *)&(a),(char *)&(b),sizeof(b));
  85. #else            /* Version for compilers that do */
  86. #define    ASSIGN(a,b)    ((a) = (b))
  87. #endif
  88.  
  89. /* Define null object pointer in case stdio.h isn't included */
  90. #ifndef    NULL
  91. /* General purpose NULL pointer */
  92. #define    NULL (void *)0
  93. #endif
  94. #define    NULLCHAR (char *)0    /* Null character pointer */
  95. #define    NULLCHARP (char **)0    /* Null character pointer pointer */
  96. #define    NULLINT    (int *)0    /* Null integer pointer */
  97. #define    NULLFP     (int (*)())0    /* Null pointer to function returning int */
  98. #define    NULLVFP     (void (*)())0    /* Null pointer to function returning void */
  99. #define    NULLVIFP (INTERRUPT (*)())0
  100. #define    NULLFILE (FILE *)0    /* Null file pointer */
  101.  
  102. /* standard boolean constants */
  103. #define FALSE 0
  104. #define TRUE 1
  105. #define NO 0
  106. #define YES 1
  107.  
  108. /* string equality shorthand */
  109. #define STREQ(x,y) (strcmp(x,y) == 0)
  110.  
  111. /* Extract a short from a long */
  112. #define    hiword(x)    ((int16)((x) >> 16))
  113. #define    loword(x)    ((int16)(x))
  114.  
  115. /* Extract a byte from a short */
  116. #define    hibyte(x)    ((unsigned char)((x) >> 8))
  117. #define    lobyte(x)    ((unsigned char)(x))
  118.  
  119. /* Extract nibbles from a byte */
  120. #define    hinibble(x)    (((x) >> 4) & 0xf)
  121. #define    lonibble(x)    ((x) & 0xf)
  122.  
  123. /* Various low-level and miscellaneous functions */
  124. unsigned long availmem __ARGS((void));
  125. void *callocw __ARGS((unsigned nelem,unsigned size));
  126. int32 clock();
  127. int dirps __ARGS((void));
  128. int getopt __ARGS((int argc,char *argv[],char *opts));
  129. int htoi __ARGS((char *));
  130. long htol __ARGS((char *));
  131. char *inbuf __ARGS((int16 port,char *buf,int16 cnt));
  132. int16 hash_ip __ARGS((int32 addr));
  133. int istate __ARGS((void));
  134. void log __ARGS((int s,char *fmt, ...));
  135. int log2 __ARGS((int16 x));
  136. void *ltop __ARGS((long));
  137. void *mallocw __ARGS((unsigned nb));
  138. char *outbuf __ARGS((int16 port,char *buf,int16 cnt));
  139. long ptol __ARGS((void *));
  140. void restore __ARGS((int));
  141. void rflush __ARGS((void));
  142. void rip __ARGS((char *));
  143. char *smsg __ARGS((char *msgs[],unsigned nmsgs,unsigned n));
  144. int tprintf __ARGS((char *fmt,...));
  145. #if    !defined __TURBOC__
  146. char *strdup __ARGS((const char *));
  147. #endif
  148. int wildmat __ARGS((char *s,char *p,char **argv));
  149.  
  150. #include <stdlib.h>
  151. #include <string.h>
  152.  
  153. #ifdef    AZTEC
  154. #define    rewind(fp)    fseek(fp,0L,0);
  155. #endif
  156.  
  157. #if    defined(__TURBOC__) && defined(MSDOS)
  158. #define movblock(so,ss,do,ds,c)    movedata(ss,so,ds,do,c)
  159. #ifndef outportw
  160. #define outportw outport
  161. #endif
  162. #ifndef inportw
  163. #define inportw inport
  164. #endif
  165.  
  166. #else
  167.  
  168. /* General purpose function macros already defined in turbo C */
  169. #ifndef    min
  170. #define    min(x,y)    ((x)<(y)?(x):(y))    /* Lesser of two args */
  171. #endif
  172. #ifndef max
  173. #define    max(x,y)    ((x)>(y)?(x):(y))    /* Greater of two args */
  174. #endif
  175. #ifdef    MSDOS
  176. #define MK_FP(seg,ofs)    ((void far *) \
  177.             (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
  178. #endif
  179. #endif    /* __TURBOC __ */
  180.  
  181. #ifdef    AMIGA
  182. /* super kludge de WA3YMH */
  183. #ifndef    fileno
  184. #include <stdio.h>
  185. #endif
  186. #define fclose(fp)    amiga_fclose(fp)
  187. extern int amiga_fclose __ARGS((FILE *));
  188. extern FILE *tmpfile __ARGS((void));
  189.  
  190. extern char *sys_errlist[];
  191. extern int errno;
  192. #endif
  193.  
  194. /* Externals used by getopt */
  195. extern int optind;
  196. extern char *optarg;
  197.  
  198. /* Threshold setting on available memory */
  199. extern int32 Memthresh;
  200.  
  201. /* System clock - count of ticks since startup */
  202. extern int32 Clock;
  203.  
  204. /* Various useful standard error messages */
  205. extern char Badhost[];
  206. extern char Nospace[];
  207. extern char Notval[];
  208. extern char *Hostname;
  209. extern char Version[];
  210.  
  211. /* Your system's end-of-line convention */
  212. extern char Eol[];
  213.  
  214. extern void (*Gcollect[])();
  215.  
  216. #endif    /* _GLOBAL_H */
  217.