/crypto/heimdal/lib/roken/roken-common.h

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 498 lines · 335 code · 113 blank · 50 comment · 2 complexity · 4d50cb6d25a171333cf7caa599e8fe43 MD5 · raw file

  1. /*
  2. * Copyright (c) 1995 - 2005 Kungliga Tekniska Hรถgskolan
  3. * (Royal Institute of Technology, Stockholm, Sweden).
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. *
  17. * 3. Neither the name of the Institute nor the names of its contributors
  18. * may be used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
  22. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
  25. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31. * SUCH DAMAGE.
  32. */
  33. /* $Id$ */
  34. #ifndef __ROKEN_COMMON_H__
  35. #define __ROKEN_COMMON_H__
  36. #ifndef ROKEN_LIB_FUNCTION
  37. #ifdef _WIN32
  38. #define ROKEN_LIB_FUNCTION
  39. #define ROKEN_LIB_CALL __cdecl
  40. #else
  41. #define ROKEN_LIB_FUNCTION
  42. #define ROKEN_LIB_CALL
  43. #endif
  44. #endif
  45. #ifdef __cplusplus
  46. #define ROKEN_CPP_START extern "C" {
  47. #define ROKEN_CPP_END }
  48. #else
  49. #define ROKEN_CPP_START
  50. #define ROKEN_CPP_END
  51. #endif
  52. #ifndef INADDR_NONE
  53. #define INADDR_NONE 0xffffffff
  54. #endif
  55. #ifndef INADDR_LOOPBACK
  56. #define INADDR_LOOPBACK 0x7f000001
  57. #endif
  58. #ifndef SOMAXCONN
  59. #define SOMAXCONN 5
  60. #endif
  61. #ifndef STDIN_FILENO
  62. #define STDIN_FILENO 0
  63. #endif
  64. #ifndef STDOUT_FILENO
  65. #define STDOUT_FILENO 1
  66. #endif
  67. #ifndef STDERR_FILENO
  68. #define STDERR_FILENO 2
  69. #endif
  70. #ifndef max
  71. #define max(a,b) (((a)>(b))?(a):(b))
  72. #endif
  73. #ifndef min
  74. #define min(a,b) (((a)<(b))?(a):(b))
  75. #endif
  76. #ifndef TRUE
  77. #define TRUE 1
  78. #endif
  79. #ifndef FALSE
  80. #define FALSE 0
  81. #endif
  82. #ifndef LOG_DAEMON
  83. #define openlog(id,option,facility) openlog((id),(option))
  84. #define LOG_DAEMON 0
  85. #endif
  86. #ifndef LOG_ODELAY
  87. #define LOG_ODELAY 0
  88. #endif
  89. #ifndef LOG_NDELAY
  90. #define LOG_NDELAY 0x08
  91. #endif
  92. #ifndef LOG_CONS
  93. #define LOG_CONS 0
  94. #endif
  95. #ifndef LOG_AUTH
  96. #define LOG_AUTH 0
  97. #endif
  98. #ifndef LOG_AUTHPRIV
  99. #define LOG_AUTHPRIV LOG_AUTH
  100. #endif
  101. #ifndef F_OK
  102. #define F_OK 0
  103. #endif
  104. #ifndef O_ACCMODE
  105. #define O_ACCMODE 003
  106. #endif
  107. #ifndef _WIN32
  108. #ifndef _PATH_DEV
  109. #define _PATH_DEV "/dev/"
  110. #endif
  111. #ifndef _PATH_DEVNULL
  112. #define _PATH_DEVNULL "/dev/null"
  113. #endif
  114. #ifndef _PATH_HEQUIV
  115. #define _PATH_HEQUIV "/etc/hosts.equiv"
  116. #endif
  117. #ifndef _PATH_VARRUN
  118. #define _PATH_VARRUN "/var/run/"
  119. #endif
  120. #ifndef _PATH_BSHELL
  121. #define _PATH_BSHELL "/bin/sh"
  122. #endif
  123. #ifndef MAXPATHLEN
  124. #define MAXPATHLEN (1024+4)
  125. #endif
  126. #endif /* !_WIN32 */
  127. #ifndef PATH_MAX
  128. #define PATH_MAX MAX_PATH
  129. #endif
  130. #ifndef RETSIGTYPE
  131. #define RETSIGTYPE void
  132. #endif
  133. #ifndef SIG_ERR
  134. #define SIG_ERR ((RETSIGTYPE (*)(int))-1)
  135. #endif
  136. /*
  137. * error code for getipnodeby{name,addr}
  138. */
  139. #ifndef HOST_NOT_FOUND
  140. #define HOST_NOT_FOUND 1
  141. #endif
  142. #ifndef TRY_AGAIN
  143. #define TRY_AGAIN 2
  144. #endif
  145. #ifndef NO_RECOVERY
  146. #define NO_RECOVERY 3
  147. #endif
  148. #ifndef NO_DATA
  149. #define NO_DATA 4
  150. #endif
  151. #ifndef NO_ADDRESS
  152. #define NO_ADDRESS NO_DATA
  153. #endif
  154. /*
  155. * error code for getaddrinfo
  156. */
  157. #ifndef EAI_NOERROR
  158. #define EAI_NOERROR 0 /* no error */
  159. #endif
  160. #ifndef EAI_NONAME
  161. #define EAI_ADDRFAMILY 1 /* address family for nodename not supported */
  162. #define EAI_AGAIN 2 /* temporary failure in name resolution */
  163. #define EAI_BADFLAGS 3 /* invalid value for ai_flags */
  164. #define EAI_FAIL 4 /* non-recoverable failure in name resolution */
  165. #define EAI_FAMILY 5 /* ai_family not supported */
  166. #define EAI_MEMORY 6 /* memory allocation failure */
  167. #define EAI_NODATA 7 /* no address associated with nodename */
  168. #define EAI_NONAME 8 /* nodename nor servname provided, or not known */
  169. #define EAI_SERVICE 9 /* servname not supported for ai_socktype */
  170. #define EAI_SOCKTYPE 10 /* ai_socktype not supported */
  171. #define EAI_SYSTEM 11 /* system error returned in errno */
  172. #endif /* EAI_NONAME */
  173. /* flags for getaddrinfo() */
  174. #ifndef AI_PASSIVE
  175. #define AI_PASSIVE 0x01
  176. #define AI_CANONNAME 0x02
  177. #endif /* AI_PASSIVE */
  178. #ifndef AI_NUMERICHOST
  179. #define AI_NUMERICHOST 0x04
  180. #endif
  181. #ifndef AI_NUMERICSERV
  182. #define AI_NUMERICSERV 0x08
  183. #endif
  184. /* flags for getnameinfo() */
  185. #ifndef NI_DGRAM
  186. #define NI_DGRAM 0x01
  187. #define NI_NAMEREQD 0x02
  188. #define NI_NOFQDN 0x04
  189. #define NI_NUMERICHOST 0x08
  190. #define NI_NUMERICSERV 0x10
  191. #endif
  192. /*
  193. * constants for getnameinfo
  194. */
  195. #ifndef NI_MAXHOST
  196. #define NI_MAXHOST 1025
  197. #define NI_MAXSERV 32
  198. #endif
  199. /*
  200. * constants for inet_ntop
  201. */
  202. #ifndef INET_ADDRSTRLEN
  203. #define INET_ADDRSTRLEN 16
  204. #endif
  205. #ifndef INET6_ADDRSTRLEN
  206. #define INET6_ADDRSTRLEN 46
  207. #endif
  208. /*
  209. * for shutdown(2)
  210. */
  211. #ifndef SHUT_RD
  212. #define SHUT_RD 0
  213. #endif
  214. #ifndef SHUT_WR
  215. #define SHUT_WR 1
  216. #endif
  217. #ifndef SHUT_RDWR
  218. #define SHUT_RDWR 2
  219. #endif
  220. #ifndef HAVE___ATTRIBUTE__
  221. #define __attribute__(x)
  222. #endif
  223. ROKEN_CPP_START
  224. #ifndef IRIX4 /* fix for compiler bug */
  225. #ifndef _WIN32
  226. #ifdef RETSIGTYPE
  227. typedef RETSIGTYPE (*SigAction)(int);
  228. SigAction signal(int iSig, SigAction pAction); /* BSD compatible */
  229. #endif
  230. #endif
  231. #endif
  232. #define SE_E_UNSPECIFIED (-1)
  233. #define SE_E_FORKFAILED (-2)
  234. #define SE_E_WAITPIDFAILED (-3)
  235. #define SE_E_EXECTIMEOUT (-4)
  236. #define SE_E_NOEXEC 126
  237. #define SE_E_NOTFOUND 127
  238. #define SE_PROCSTATUS(st) (((st) >= 0 && (st) < 126)? st: -1)
  239. #define SE_PROCSIGNAL(st) (((st) >= 128)? (st) - 128: -1)
  240. #define SE_IS_ERROR(st) ((st) < 0 || (st) >= 126)
  241. #define simple_execve rk_simple_execve
  242. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  243. simple_execve(const char*, char*const[], char*const[]);
  244. #define simple_execve_timed rk_simple_execve_timed
  245. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  246. simple_execve_timed(const char *, char *const[],
  247. char *const [], time_t (*)(void *),
  248. void *, time_t);
  249. #define simple_execvp rk_simple_execvp
  250. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  251. simple_execvp(const char*, char *const[]);
  252. #define simple_execvp_timed rk_simple_execvp_timed
  253. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  254. simple_execvp_timed(const char *, char *const[],
  255. time_t (*)(void *), void *, time_t);
  256. #define simple_execlp rk_simple_execlp
  257. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  258. simple_execlp(const char*, ...);
  259. #define simple_execle rk_simple_execle
  260. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  261. simple_execle(const char*, ...);
  262. #define wait_for_process rk_wait_for_process
  263. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  264. wait_for_process(pid_t);
  265. #define wait_for_process_timed rk_wait_for_process_timed
  266. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  267. wait_for_process_timed(pid_t, time_t (*)(void *),
  268. void *, time_t);
  269. #define pipe_execv rk_pipe_execv
  270. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  271. pipe_execv(FILE**, FILE**, FILE**, const char*, ...);
  272. #define print_version rk_print_version
  273. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  274. print_version(const char *);
  275. #define eread rk_eread
  276. ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
  277. eread (int fd, void *buf, size_t nbytes);
  278. #define ewrite rk_ewrite
  279. ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
  280. ewrite (int fd, const void *buf, size_t nbytes);
  281. struct hostent;
  282. #define hostent_find_fqdn rk_hostent_find_fqdn
  283. ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
  284. hostent_find_fqdn (const struct hostent *);
  285. #define esetenv rk_esetenv
  286. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  287. esetenv(const char *, const char *, int);
  288. #define socket_set_address_and_port rk_socket_set_address_and_port
  289. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  290. socket_set_address_and_port (struct sockaddr *, const void *, int);
  291. #define socket_addr_size rk_socket_addr_size
  292. ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
  293. socket_addr_size (const struct sockaddr *);
  294. #define socket_set_any rk_socket_set_any
  295. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  296. socket_set_any (struct sockaddr *, int);
  297. #define socket_sockaddr_size rk_socket_sockaddr_size
  298. ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
  299. socket_sockaddr_size (const struct sockaddr *);
  300. #define socket_get_address rk_socket_get_address
  301. ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
  302. socket_get_address (const struct sockaddr *);
  303. #define socket_get_port rk_socket_get_port
  304. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  305. socket_get_port (const struct sockaddr *);
  306. #define socket_set_port rk_socket_set_port
  307. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  308. socket_set_port (struct sockaddr *, int);
  309. #define socket_set_portrange rk_socket_set_portrange
  310. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  311. socket_set_portrange (rk_socket_t, int, int);
  312. #define socket_set_debug rk_socket_set_debug
  313. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  314. socket_set_debug (rk_socket_t);
  315. #define socket_set_tos rk_socket_set_tos
  316. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  317. socket_set_tos (rk_socket_t, int);
  318. #define socket_set_reuseaddr rk_socket_set_reuseaddr
  319. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  320. socket_set_reuseaddr (rk_socket_t, int);
  321. #define socket_set_ipv6only rk_socket_set_ipv6only
  322. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  323. socket_set_ipv6only (rk_socket_t, int);
  324. #define socket_to_fd rk_socket_to_fd
  325. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  326. socket_to_fd(rk_socket_t, int);
  327. #define vstrcollect rk_vstrcollect
  328. ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
  329. vstrcollect(va_list *ap);
  330. #define strcollect rk_strcollect
  331. ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
  332. strcollect(char *first, ...);
  333. #define timevalfix rk_timevalfix
  334. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  335. timevalfix(struct timeval *t1);
  336. #define timevaladd rk_timevaladd
  337. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  338. timevaladd(struct timeval *t1, const struct timeval *t2);
  339. #define timevalsub rk_timevalsub
  340. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  341. timevalsub(struct timeval *t1, const struct timeval *t2);
  342. #define pid_file_write rk_pid_file_write
  343. ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
  344. pid_file_write (const char *progname);
  345. #define pid_file_delete rk_pid_file_delete
  346. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  347. pid_file_delete (char **);
  348. #define read_environment rk_read_environment
  349. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  350. read_environment(const char *file, char ***env);
  351. #define free_environment rk_free_environment
  352. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  353. free_environment(char **);
  354. #define warnerr rk_warnerr
  355. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  356. rk_warnerr(int doerrno, const char *fmt, va_list ap)
  357. __attribute__ ((format (printf, 2, 0)));
  358. ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
  359. rk_realloc(void *, size_t);
  360. struct rk_strpool;
  361. ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
  362. rk_strpoolcollect(struct rk_strpool *);
  363. ROKEN_LIB_FUNCTION struct rk_strpool * ROKEN_LIB_CALL
  364. rk_strpoolprintf(struct rk_strpool *, const char *, ...)
  365. __attribute__ ((format (printf, 2, 3)));
  366. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  367. rk_strpoolfree(struct rk_strpool *);
  368. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  369. rk_dumpdata (const char *, const void *, size_t);
  370. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  371. rk_undumpdata (const char *, void **, size_t *);
  372. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  373. rk_xfree (void *);
  374. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  375. rk_cloexec(int);
  376. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  377. rk_cloexec_file(FILE *);
  378. ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
  379. rk_cloexec_dir(DIR *);
  380. ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
  381. ct_memcmp(const void *, const void *, size_t);
  382. void ROKEN_LIB_FUNCTION
  383. rk_random_init(void);
  384. ROKEN_CPP_END
  385. #endif /* __ROKEN_COMMON_H__ */