home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume27 / mthreads / part01 / common.h next >
Encoding:
C/C++ Source or Header  |  1993-11-20  |  4.7 KB  |  244 lines

  1. /* $Id: common.h,v 3.0 1992/02/23 21:25:39 davison $
  2.  */
  3. /* The authors make no claims as to the fitness or correctness of this software
  4.  * for any use whatsoever, and it is provided as is. Any use of this software
  5.  * is at the user's own risk. 
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #include <ctype.h>
  12. #include "config.h"    /* generated by installation script */
  13.  
  14. #include <errno.h>
  15. #include <signal.h>
  16. #ifdef I_VFORK
  17. #  include <vfork.h>
  18. #endif
  19.  
  20. #ifdef I_UNISTD
  21. #include <unistd.h>
  22. #endif
  23. #ifdef I_STDLIB
  24. #include <stdlib.h>
  25. #else
  26. char    *malloc();
  27. char    *realloc();
  28. char    *getenv();
  29. #endif
  30.  
  31. #ifdef I_STRING
  32. #include <string.h>
  33. #else
  34. #include <strings.h>
  35. #endif
  36.  
  37. #ifdef I_TIME
  38. #include <time.h>
  39. #endif
  40. #ifdef I_SYS_TIME
  41. #include <sys/time.h>
  42. #endif
  43.  
  44. #define BITSPERBYTE 8
  45. #define LBUFLEN 1024    /* line buffer length */
  46. #define MAXFILENAME 512
  47.  
  48. /* some handy defs */
  49.  
  50. #define bool char
  51. #define bool_int int
  52. #define char_int int
  53. #ifndef TRUE
  54. #define TRUE (1)
  55. #endif
  56. #ifndef FALSE
  57. #define FALSE (0)
  58. #endif
  59. #define Null(t) ((t)0)
  60. #define Nullch Null(char *)
  61. #define Nullfp Null(FILE *)
  62.  
  63. #define Ctl(ch) (ch & 037)
  64.  
  65. #define strNE(s1,s2) (strcmp(s1,s2))
  66. #define strEQ(s1,s2) (!strcmp(s1,s2))
  67. #define strnNE(s1,s2,l) (strncmp(s1,s2,l))
  68. #define strnEQ(s1,s2,l) (!strncmp(s1,s2,l))
  69.  
  70. /* Things we can figure out ourselves */
  71.  
  72. #ifdef EUNICE
  73. #   define LINKART        /* add 1 level of possible indirection */
  74. #   define UNLINK(victim) while (!unlink(victim))
  75. #else
  76. #   define UNLINK(victim) unlink(victim)
  77. #endif
  78.  
  79. /* *** System Dependent Stuff *** */
  80.  
  81. #define MAKEDIR        /* use our makedir() instead of shell script */
  82.  
  83. /* NOTE: many of these are defined in the config.h file */
  84.  
  85. #ifdef NORMSIG
  86. #   define sigset signal
  87. #endif
  88.  
  89. /* news library */
  90. #ifndef NEWSLIB        /* ~ and %l only ("~%l" is permissable) */
  91. #   define NEWSLIB "/usr/lib/news"
  92. #endif
  93.  
  94. /* path to private executables */
  95. #ifndef PRIVLIB        /* ~, %x and %l only */
  96. #   define PRIVLIB "%x/trn"
  97. #endif
  98.  
  99. /* where to find news files */
  100. #ifndef NEWSSPOOL        /* % and ~ */
  101. #   define NEWSSPOOL "/usr/spool/news"
  102. #endif
  103.  
  104. # ifndef NEW_THREAD
  105. #   define NEW_THREAD ".new"
  106. # endif
  107.  
  108. /* file containing list of active newsgroups and max article numbers */
  109. #ifndef ACTIVE            /* % and ~ */
  110. #   define ACTIVE "%x/active"
  111. #endif
  112. #ifdef USE_NNTP
  113. #   ifndef ACTIVE1
  114. #    define ACTIVE1 "%X/active1"
  115. #   endif
  116. #endif
  117. #ifndef ACTIVE2
  118. #   define ACTIVE2 "%X/active2"
  119. #endif
  120. #ifndef DBINIT
  121. #   define DBINIT "%W/db.init"
  122. #endif
  123. #ifndef MTPRELOCK
  124. #   define MTPRELOCK "%X/LOCK"
  125. #endif
  126. #ifndef MTLOCK
  127. #   define MTLOCK "%X/LOCKmthreads"
  128. #endif
  129. #ifndef MTDLOCK
  130. #   define MTDLOCK "%X/LOCKmtdaemon"
  131. #endif
  132. #ifndef MTLOG
  133. #   define MTLOG "%X/mt.log"
  134. #endif
  135.  
  136. /* path to fastest starting shell */
  137. #ifndef SH
  138. #   define SH "/bin/sh"
  139. #endif
  140.  
  141. #ifndef MAKEDIR
  142. /* shell script to make n-deep subdirectories */
  143. #   ifndef DIRMAKER        /* % and ~ */
  144. #    define DIRMAKER "%X/makedir"
  145. #   endif
  146. #endif
  147.  
  148. /* how to open binary format files */
  149. #ifndef FOPEN_RB
  150. #   define FOPEN_RB "r"
  151. #endif
  152. #ifndef FOPEN_WB
  153. #   define FOPEN_WB "w"
  154. #endif
  155.  
  156. /* what to do with ansi prototypes -- '()' == ignore, 'x' == use */
  157. #ifndef _
  158. #   ifdef __STDC__
  159. #    define _(x) x
  160. #   else
  161. #    define _(x) ()
  162. #   endif
  163. #endif
  164.  
  165. /* some important types */
  166.  
  167. typedef long        ART_NUM;    /* article number */
  168. typedef unsigned int    MEM_SIZE;    /* for passing to malloc */
  169.  
  170. /* some slight-of-hand for compatibility issues */
  171.  
  172. #ifdef HAS_STRCHR
  173. # ifndef index
  174. #   define index strchr
  175. # endif
  176. # ifndef rindex
  177. #   define rindex strrchr
  178. # endif
  179. #endif
  180. #ifdef HAS_MEMCMP
  181. # ifndef bcmp
  182. #   define bcmp(s,d,l) memcmp((s),(d),(l))
  183. # endif
  184. #endif
  185. #ifdef HAS_MEMCPY
  186. # ifndef bcopy
  187. #   define bcopy(s,d,l) memcpy((d),(s),(l))
  188. # endif
  189. #endif
  190. #ifdef HAS_MEMSET
  191. # ifndef bzero
  192. #   define bzero(s,l) memset((s),0,(l))
  193. # endif
  194. #endif
  195.  
  196. #ifndef HAS_VFORK
  197. #   define vfork fork
  198. #endif
  199.  
  200. /* *** end of the machine dependent stuff *** */
  201.  
  202. /* GLOBAL THINGS */
  203.  
  204. /* file statistics area */
  205.  
  206. EXT struct stat filestat;
  207.  
  208. /* various things of type char */
  209.  
  210. #ifdef SUPPLEMENT_STRING_H
  211. char    *index();
  212. char    *rindex();
  213. char    *strcat();
  214. char    *strcpy();
  215. #endif
  216.  
  217. EXT char buf[LBUFLEN+1];    /* general purpose line buffer */
  218.  
  219. /* miscellania */
  220.  
  221. #ifndef __STDC__
  222. int fseek();
  223. long atol(), ftell();
  224. extern int errno;
  225. #endif
  226.  
  227. EXT char nullstr[1] INIT("");
  228.  
  229. /* if subscripting is faster than shifting on your machine, define this */
  230. #undef USESUBSCRIPT
  231. #ifdef USESUBSCRIPT
  232. EXT char powerof2[] INIT({1,2,4,8,16,32,64,128});
  233. #define pow2(x) powerof2[x]
  234. #else
  235. #define pow2(x) (1 << (x))
  236. #endif
  237. #define OFFSET(a) ((a)-absfirst)
  238.  
  239. #define ctl_set(a) (ctlarea[(OFFSET(a)) / BITSPERBYTE] |= pow2((OFFSET(a)) % BITSPERBYTE))
  240. #define ctl_check(a) ((ctlarea[(OFFSET(a)) / BITSPERBYTE] & pow2((OFFSET(a)) % BITSPERBYTE)) != 0)
  241.  
  242. #define advise(str)
  243. #define report_error(str) log_entry(str)
  244.