home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / EXTRAS / WINWAIS / IR / CUTIL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-07  |  3.8 KB  |  148 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE
  2.    No guarantees or restrictions.  See the readme file for the full standard
  3.    disclaimer.  
  4.   
  5.    3.26.90      Harry Morris, morris@think.com
  6.    4.11.90  HWM - generalized conditional includes (see c-dialect.h)
  7. */
  8.  
  9. #ifndef _H_C_util_
  10. #define _H_C_util_
  11.  
  12. #include "cdialect.h"
  13.  
  14. #include <stdio.h>   /* this used to be wrapped in an ifndef NULL, 
  15.             but messed up on some gcc's */
  16. #include <sys/time.h>
  17.  
  18. #define MAX_FILENAME_LEN 255L
  19.  
  20. /*----------------------------------------------------------------------*/
  21. /* types and constants */
  22.  
  23. #ifndef boolean
  24. #define boolean unsigned long
  25. #endif /* ndef boolean */ 
  26.  
  27. #ifndef Boolean
  28. #define Boolean boolean
  29. #endif /* ndef Boolean */ 
  30.  
  31. #ifndef true
  32. #define true    (boolean)1L
  33. #endif /* ndef true */
  34.  
  35. #ifndef false
  36. #define false   (boolean)0L   /* used to be (!true), but broke 
  37.                  some compilers */
  38. #endif /* ndef false */
  39.  
  40. #ifndef TRUE
  41. #define TRUE    true
  42. #endif /* ndef TRUE */
  43.  
  44. #ifndef FALSE
  45. #define FALSE   false
  46. #endif /* ndef FALSE */
  47.  
  48. #ifndef NULL
  49. #define NULL    0L
  50. #endif /* ndef NULL */
  51.  
  52. /*----------------------------------------------------------------------*/
  53. /* Fast string macros - warning don't pass NULL to these! */
  54.  
  55. #define STREQ(s1,s2) ((*(s1)==*(s2)) && !strcmp(s1,s2))
  56. #define STRNCMP(s1,s2,n) \
  57.     ((*(s1)==*(s2)) ? strncmp(s1,s2,n) : (*(s1) - *(s2)))
  58.  
  59. /*----------------------------------------------------------------------*/
  60. /* convenience */
  61.  
  62. #define nl() printf("\n")
  63.  
  64. /*----------------------------------------------------------------------*/
  65. /* functions */
  66.  
  67. #ifdef __cplusplus
  68. /* declare these as C style functions */
  69. extern "C"
  70.     {
  71. #endif /* def __cplusplus */
  72.  
  73. /* enhanced memory handling functions - don't call them directly, use the
  74.    macros below */
  75. void    fs_checkPtr _AP((void*));
  76.  
  77. int     fs_meminit _AP((long));
  78. void    fs_memterm _AP((void));
  79. void*   fs_malloc _AP((long));
  80. void*   fs_realloc _AP((void*,long));
  81.  
  82. void    fs_free _AP((void*));
  83. char*   fs_strncat _AP((char*,char*,long,long));
  84.  
  85. /* macros for memory functions.  call these in your program.  */
  86. #define s_meminit(m)            fs_meminit(m)
  87. #define s_memterm()             fs_memterm()
  88. #define s_checkPtr(ptr)         fs_checkPtr(ptr)
  89. #define s_malloc(size)          fs_malloc(size)
  90. #define s_realloc(ptr,size)     fs_realloc((ptr),(size))
  91. #define s_free(ptr)             { fs_free(ptr); ptr = NULL; }
  92. #define s_strncat(dst,src,maxToAdd,maxTotal)    fs_strncat((dst),(src),(maxToAdd),(maxTotal))
  93.  
  94. char*   s_strdup _AP((char* s));
  95.  
  96. char*   strtokf _AP((char* s1,long (*isDelimiter)(long c))); 
  97.  
  98. #define IS_DELIMITER    1
  99. #define NOT_DELIMITER   !IS_DELIMITER
  100.  
  101. #ifdef ANSI_LIKE        /* use ansi */
  102. long            cprintf _AP((boolean print,char* format,...));
  103. #else /* use K & R */
  104. long            cprintf _AP(());
  105. #endif
  106.  
  107. #ifdef ANSI_LIKE        /* use ansi */
  108. void            waislog _AP((char* format,...));
  109. #else /* use K & R */
  110. #ifdef BSD
  111.  
  112. #define waislog printf("\n%d: %s ", getpid(), printable_time()); printf
  113.  
  114. #else
  115. void            waislog _AP(());
  116. #endif /* BSD */
  117. #endif /* ANSI_LIKE */
  118.  
  119. void    warn _AP((char* message));
  120.  
  121. boolean substrcmp _AP((char *string1, char *string2));
  122. #ifndef MAX
  123. #define MAX(x,y) (((x) > (y)) ? (x) : (y))
  124. #endif
  125. #ifndef MIN
  126. #define MIN(x,y) (((x) < (y)) ? (x) : (y))
  127. #endif
  128. #define ABS(x) (((x) < 0) ? (-(x)) : (x))
  129.  
  130. char *printable_time _AP((void));
  131.  
  132. char char_downcase _AP((unsigned long ch));
  133. char *string_downcase _AP((char* w));
  134.  
  135.  
  136. char *next_arg _AP((int *argc, char ***argv));
  137. char *peek_arg _AP((int *argc, char ***argv));
  138.  
  139. void            beFriendly _AP((void));
  140.  
  141. #ifdef __cplusplus
  142.     }
  143. #endif /* def __cplusplus */
  144.  
  145. /*----------------------------------------------------------------------*/
  146.  
  147. #endif /* ndef _H_C_util_ */
  148.