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