home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / OPENSTEP / Networking / msend-3.3-I / common.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-26  |  4.8 KB  |  263 lines

  1. /*
  2.  * common.h
  3.  *
  4.  * Copyright (c) 1992 Sun Microsystems, Inc.
  5.  * Copyright (c) 1993 Zik Saleeba <zik@zikzak.apana.org.au>
  6.  *
  7.  * This header shared between the daemon and the client and
  8.  * contains the portability code.
  9.  * This implementation may be freely copied, modified, and 
  10.  * redistributed, provided that this comment is retained.
  11.  */
  12.  
  13. /* $Id: common.h,v 1.1 1997/10/26 07:31:23 lukeh Exp $ */
  14.  
  15. #define MESSAGE_SEP "\n---< MESSAGE FOLLOWS >---\n"
  16. #define MSG_SEP (MESSAGE_SEP+1)
  17.  
  18.  
  19. /*
  20.  * Portability considerations
  21.  */
  22.  
  23. #ifdef AIX
  24. #define USE_STRFTIME
  25. #define USE_SYSV_UTMP
  26. #define SIGHANDLER_TYPE int
  27. #define BSD_SIGHANDLERS
  28. #define NO_GETDTABLESIZE
  29. #define NEW_HEADERS
  30. #define NO_UNION_WAIT
  31. #define USE_LOCKF
  32. #endif
  33.  
  34. #ifdef BSD
  35. #define USE_STRFTIME
  36. #define SIGHANDLER_TYPE int
  37. #define BSD_SIGHANDLERS
  38. #endif
  39.  
  40. #ifdef BSD44
  41. #define USE_STRFTIME
  42. #define NEW_STRFTIME
  43. #define SIGHANDLER_TYPE void
  44. #define NEW_HEADERS
  45. #define NO_UNION_WAIT
  46. #define USE_SETSID
  47. #endif
  48.  
  49. #ifdef IRIX
  50. #define USE_SETSID
  51. #define USE_SYSV_UTMP
  52. #define USE_STRFTIME
  53. #define NEW_STRFTIME
  54. #define IGNORE_CHILDREN
  55. #define SIGHANDLER_TYPE void
  56. #define GETHOSTNAME_NO_FQDN
  57. #define USE_LOCKF
  58. #define USE_MEMORY_H
  59. #define USE_MALLOC_H
  60. #define NEW_HEADERS
  61. #endif
  62.  
  63. #ifdef LINUX
  64. #define USE_SETSID
  65. #define USE_STRFTIME
  66. #define NEW_STRFTIME
  67. #define USE_SYSV_UTMP
  68. #define IGNORE_CHILDREN
  69. #define SIGHANDLER_TYPE void
  70. #define USE_LOCKF
  71. #define USE_MEMORY_H
  72. #define USE_MALLOC_H
  73. #define NEW_HEADERS
  74. #endif
  75.  
  76. #ifdef OLDBSD
  77. #define SIGHANDLER_TYPE int
  78. #define BSD_SIGHANDLERS
  79. #define NO_S_IWGRP
  80. #define NO_POSIX_STRFUNCS
  81. #define NO_POSIX_MEMFUNCS
  82. #endif
  83.  
  84. #ifdef SUNOS3
  85. #define BSD_SIGHANDLERS
  86. #define SIGHANDLER_TYPE int
  87. #define NO_LIMITS_H
  88. #define NO_S_IWGRP
  89. #define USE_MALLOC_H
  90. #define NO_BROADCAST
  91. #define FD_SET(n,p) ((p)->fds_bits[(n)/32] |= (1<<((n)%32)))
  92. #define FD_CLR(n,p) ((p)->fds_bits[(n)/32] &= (1<<((n)%32)))
  93. #define FD_ISSET(n,p) ((p)->fds_bits[(n)/32] & (1<<((n)%32)))
  94. #define FD_ZERO(p) bzero(p,sizeof(p))
  95. #define NO_POSIX_STRFUNCS
  96. #endif
  97.  
  98. #ifdef SUNOS4
  99. #define BSD_SIGHANDLERS
  100. #define SIGHANDLER_TYPE int
  101. #define NO_LIMITS_H
  102. #define USE_MALLOC_H
  103. #define NO_STRCASECMP
  104. #define NO_POSIX_STRFUNCS
  105. #endif
  106.  
  107. #ifdef SVR4
  108. #define USE_SETSID
  109. #define USE_SYSV_UTMP
  110. #define USE_UTMPX
  111. #define USE_STRFTIME
  112. #define NEW_STRFTIME
  113. #define IGNORE_CHILDREN
  114. #define SIGHANDLER_TYPE void
  115. #define NO_GETDTABLESIZE
  116. #define GETHOSTNAME_NO_FQDN
  117. #define USE_LOCKF
  118. #define USE_SYSTEMINFO
  119. #define USE_SOCKIO_H
  120. #define NO_SYS_FILE_H
  121. #define USE_MEMORY_H
  122. #define USE_MALLOC_H
  123. #define NEW_HEADERS
  124. #define NO_STRCASECMP
  125. #endif
  126.  
  127. #ifdef ULTRIX
  128. #define USE_STRFTIME
  129. #define SIGHANDLER_TYPE int
  130. #define BSD_SIGHANDLERS
  131. #define USE_MEMORY_H
  132. #define USE_MALLOC_H
  133. #endif
  134.  
  135. #ifndef SIGHANDLER_TYPE
  136. error You MUST choose a system type before you compile
  137. #endif
  138.  
  139.  
  140. /*
  141.  * Include files
  142.  */
  143.  
  144. #include <sys/types.h>
  145. #include <sys/time.h>
  146. #include <sys/stat.h>
  147. #include <sys/socket.h>
  148. #include <netinet/in.h>
  149. #include <net/if.h>
  150. #include <arpa/inet.h>
  151. #include <netdb.h>
  152. #include <stdio.h>
  153. #include <fcntl.h>
  154. #include <string.h>
  155. #include <signal.h>
  156. #include <ctype.h>
  157. #include <unistd.h>
  158. #include <pwd.h>
  159. #include <sys/param.h>
  160. #include <errno.h>
  161.  
  162. #ifdef NEW_HEADERS
  163. #include <stdlib.h>
  164. #endif
  165.  
  166. #ifdef USE_UTMPX
  167. #include <utmpx.h>
  168. #else
  169. #include <utmp.h>
  170. #endif
  171.  
  172. #ifdef USE_SOCKIO_H
  173. #include <sys/sockio.h>
  174. #else
  175. #include <sys/ioctl.h>
  176. #endif
  177.  
  178. #ifndef NO_SYS_FILE_H
  179. #include <sys/file.h>
  180. #endif
  181.  
  182. #ifdef USE_SYSTEMINFO
  183. #include <sys/utsname.h>
  184. #include <sys/systeminfo.h>
  185. #endif
  186.  
  187. #ifdef NO_GETDTABLESIZE
  188. #include <sys/select.h>
  189. #endif
  190.  
  191. #ifdef BSD_SIGHANDLERS
  192. #include <sys/wait.h>
  193. #endif
  194.  
  195. #ifndef NO_LIMITS_H
  196. #include <limits.h>
  197. #endif
  198.  
  199. #ifdef USE_MALLOC_H
  200. #include <malloc.h>
  201. #endif
  202.  
  203. #ifdef USE_MEMORY_H
  204. #include <memory.h>
  205. #endif
  206.  
  207. #ifndef _PATH_UTMP
  208. #ifndef UTMP_FILE
  209. #define _PATH_UTMP      "/etc/utmp"
  210. #else
  211. #define _PATH_UTMP      UTMP_FILE
  212. #endif
  213. #endif
  214.  
  215. #ifndef PATH_MAX
  216. #ifdef MAXPATHLEN
  217. #define PATH_MAX MAXPATHLEN
  218. #else
  219. #define PATH_MAX 256
  220. #endif
  221. #endif
  222.  
  223. #ifndef MAXHOSTNAMELEN
  224. #define MAXHOSTNAMELEN 64
  225. #endif
  226.  
  227. #define DEFAULT_DEST "console"
  228. #define MAX_LOCK_FAILS 180
  229.  
  230. #ifndef NO_POSIX_MEMFUNCS
  231. #define MEMCMP(d,s,l) memcmp(d,s,l)
  232. #define MEMZERO(d,l) memset(d,'\0',l)
  233. #define MEMSET(d,c,l) memset(d,c,l)
  234. #define MEMCPY(d,s,l) memcpy(d,s,l)
  235. #else
  236. #define MEMCMP(d,s,l) bcmp(d,s,l)
  237. #define MEMZERO(d,l) bzero(d,l)
  238. #define MEMSET(d,c,l) compat_memset(d,c,l)
  239. #define MEMCPY(d,s,l) bcopy(s,d,l)
  240. #endif
  241.  
  242. #ifndef NO_POSIX_STRFUNCS
  243. #define STRCHR(s,c) strchr(s,c)
  244. #define STRSTR(d,s) strstr(d,s)
  245. #else
  246. #define STRCHR(s,c) index(s,c)
  247. #define STRSTR(d,s) compat_strstr(d,s)
  248. #endif
  249.  
  250. #ifndef NO_STRCASECMP
  251. #define STRCASECMP(a,b) strcasecmp(a,b)
  252. #define STRNCASECMP(a,b,n) strncasecmp(a,b,n)
  253. #else
  254. #define STRCASECMP(a,b) compat_strcasecmp(a,b)
  255. #define STRNCASECMP(a,b,n) compat_strncasecmp(a,b,n)
  256. #endif
  257.  
  258. #ifdef SECURE
  259. #define BIND(a,b,c) bindresvport(a,b,c)
  260. #else
  261. #define BIND(a,b,c) bind(a,b,c)
  262. #endif
  263.