home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR3 / KA9Q212.ZIP / GLOBAL.H < prev    next >
C/C++ Source or Header  |  1993-07-16  |  7KB  |  241 lines

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