home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / internet / tcpipsrc / h / global < prev    next >
Text File  |  1995-02-22  |  2KB  |  81 lines

  1. /* Global definitions used by every source file.
  2.  * Some may be compiler dependent.
  3.  */
  4.  
  5. #ifndef GLOBAL_H
  6. #define GLOBAL_H
  7.  
  8. /* Indexes into binmode in files.c; hook for compilers that have special
  9.  * open modes for binary files
  10.  */
  11. #define READ_BINARY     0
  12. #define WRITE_BINARY    1
  13. extern char *binmode[];
  14.  
  15. /* These two lines assume that your compiler's longs are 32 bits and
  16.  * shorts are 16 bits. It is already assumed that chars are 8 bits,
  17.  * but it doesn't matter if they're signed or unsigned.
  18.  */
  19. typedef unsigned long int32;    /* 32-bit signed integer */
  20. typedef unsigned short int16;   /* 16-bit unsigned integer */
  21.  
  22. #ifndef u_int
  23. #define u_int unsigned int
  24. #endif
  25. #ifndef u_char
  26. #define u_char char
  27. #endif
  28. #ifndef u_short
  29. #define u_short unsigned short
  30. #endif
  31. #ifndef u_long
  32. #define u_long unsigned long
  33. #endif
  34.  
  35. #define uchar(x) (x)
  36. #define MAXINT16 65535          /* Largest 16-bit integer */
  37.  
  38. /* Define null object pointer in case stdio.h isn't included */
  39. #ifndef NULL
  40. /* General purpose NULL pointer */
  41. #define NULL (void *)0
  42. #endif
  43. #define NULLCHAR (char *)0      /* Null character pointer */
  44. #define NULLFP   (int (*)())0   /* Null pointer to function returning int */
  45. #define NULLVFP  (void (*)())0  /* Null pointer to function returning void */
  46. #define NULLFILE (FILE *)0      /* Null file pointer */
  47.  
  48. /* General purpose function macros */
  49. #define min(x,y)        ((x)<(y)?(x):(y))       /* Lesser of two args */
  50. #define max(x,y)        ((x)>(y)?(x):(y))       /* Greater of two args */
  51.  
  52. /* Extract a short from a long */
  53. /* Hacked these to see if it speeds things up */
  54. #define hiword(x)       ((int16) ((x) >> 16) & 0xFFFF)
  55. #define loword(x)       ((int16) ((x) & 0xFFFF))
  56.  
  57. /* Extract a byte from a short */
  58. #define hibyte(x)       (((x) >> 8) & 0xff)
  59. #define lobyte(x)       ((x) & 0xff)
  60.  
  61. /* Extract nibbles from a byte */
  62. #define hinibble(x)     (((x) >> 4) & 0xf)
  63. #define lonibble(x)     ((x) & 0xf)
  64.  
  65. char *strdup(char *);           /* In MISC.H */
  66.  
  67. void *mem_malloc(unsigned int, char *, int);
  68. void *mem_calloc(unsigned int, unsigned int, char *, int);
  69. char *mem_strdup(char *, char *, int);
  70. void  mem_free(void *, char *, int);
  71.  
  72. #define      MEM_NORMAL
  73. #if !defined(MEM_NORMAL)
  74. #define malloc(u)       mem_malloc((u),__FILE__,__LINE__)
  75. #define calloc(u,v)     mem_calloc((u),(v),__FILE__,__LINE__)
  76. #define strdup(s)       mem_strdup((s),__FILE__,__LINE__)
  77. #define free(p)         mem_free((p),__FILE__,__LINE__)
  78. #endif
  79.  
  80. #endif
  81.