heimdal: unset SLIST_ENTRY only if we are with windows
[Samba.git] / source4 / heimdal / lib / roken / roken-common.h
blob6a09da40e45b4b66079d1a2144bbdd2b3e5e2f0f
1 /*
2 * Copyright (c) 1995 - 2005 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
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.
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.
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.
34 /* $Id$ */
36 #ifndef __ROKEN_COMMON_H__
37 #define __ROKEN_COMMON_H__
39 #ifndef ROKEN_LIB_FUNCTION
40 #ifdef _WIN32
41 #define ROKEN_LIB_FUNCTION
42 #define ROKEN_LIB_CALL __cdecl
43 #else
44 #define ROKEN_LIB_FUNCTION
45 #define ROKEN_LIB_CALL
46 #endif
47 #endif
49 #ifdef __cplusplus
50 #define ROKEN_CPP_START extern "C" {
51 #define ROKEN_CPP_END }
52 #else
53 #define ROKEN_CPP_START
54 #define ROKEN_CPP_END
55 #endif
57 #ifndef INADDR_NONE
58 #define INADDR_NONE 0xffffffff
59 #endif
61 #ifndef INADDR_LOOPBACK
62 #define INADDR_LOOPBACK 0x7f000001
63 #endif
65 #ifndef SOMAXCONN
66 #define SOMAXCONN 5
67 #endif
69 #ifndef STDIN_FILENO
70 #define STDIN_FILENO 0
71 #endif
73 #ifndef STDOUT_FILENO
74 #define STDOUT_FILENO 1
75 #endif
77 #ifndef STDERR_FILENO
78 #define STDERR_FILENO 2
79 #endif
81 #ifndef max
82 #define max(a,b) (((a)>(b))?(a):(b))
83 #endif
85 #ifndef min
86 #define min(a,b) (((a)<(b))?(a):(b))
87 #endif
89 #ifndef TRUE
90 #define TRUE 1
91 #endif
93 #ifndef FALSE
94 #define FALSE 0
95 #endif
97 #ifndef LOG_DAEMON
98 #define openlog(id,option,facility) openlog((id),(option))
99 #define LOG_DAEMON 0
100 #endif
101 #ifndef LOG_ODELAY
102 #define LOG_ODELAY 0
103 #endif
104 #ifndef LOG_NDELAY
105 #define LOG_NDELAY 0x08
106 #endif
107 #ifndef LOG_CONS
108 #define LOG_CONS 0
109 #endif
110 #ifndef LOG_AUTH
111 #define LOG_AUTH 0
112 #endif
113 #ifndef LOG_AUTHPRIV
114 #define LOG_AUTHPRIV LOG_AUTH
115 #endif
117 #ifndef F_OK
118 #define F_OK 0
119 #endif
121 #ifndef O_ACCMODE
122 #define O_ACCMODE 003
123 #endif
125 #ifndef _WIN32
127 #ifndef _PATH_DEV
128 #define _PATH_DEV "/dev/"
129 #endif
131 #ifndef _PATH_DEVNULL
132 #define _PATH_DEVNULL "/dev/null"
133 #endif
135 #ifndef _PATH_HEQUIV
136 #define _PATH_HEQUIV "/etc/hosts.equiv"
137 #endif
139 #ifndef _PATH_VARRUN
140 #define _PATH_VARRUN "/var/run/"
141 #endif
143 #ifndef _PATH_BSHELL
144 #define _PATH_BSHELL "/bin/sh"
145 #endif
147 #ifndef MAXPATHLEN
148 #define MAXPATHLEN (1024+4)
149 #endif
151 #else/* !_WIN32 */
153 /* Minimize conflict with WinNT.h */
154 #ifdef SLIST_ENTRY
155 #undef SLIST_ENTRY
156 #endif
158 #endif /* _WIN32 */
160 #ifndef PATH_MAX
161 #define PATH_MAX MAX_PATH
162 #endif
164 #ifndef RETSIGTYPE
165 #define RETSIGTYPE void
166 #endif
168 #ifndef SIG_ERR
169 #define SIG_ERR ((RETSIGTYPE (*)(int))-1)
170 #endif
173 * error code for getipnodeby{name,addr}
176 #ifndef HOST_NOT_FOUND
177 #define HOST_NOT_FOUND 1
178 #endif
180 #ifndef TRY_AGAIN
181 #define TRY_AGAIN 2
182 #endif
184 #ifndef NO_RECOVERY
185 #define NO_RECOVERY 3
186 #endif
188 #ifndef NO_DATA
189 #define NO_DATA 4
190 #endif
192 #ifndef NO_ADDRESS
193 #define NO_ADDRESS NO_DATA
194 #endif
197 * error code for getaddrinfo
200 #ifndef EAI_NOERROR
201 #define EAI_NOERROR 0 /* no error */
202 #endif
204 #ifndef EAI_NONAME
206 #define EAI_ADDRFAMILY 1 /* address family for nodename not supported */
207 #define EAI_AGAIN 2 /* temporary failure in name resolution */
208 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */
209 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */
210 #define EAI_FAMILY 5 /* ai_family not supported */
211 #define EAI_MEMORY 6 /* memory allocation failure */
212 #define EAI_NODATA 7 /* no address associated with nodename */
213 #define EAI_NONAME 8 /* nodename nor servname provided, or not known */
214 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */
215 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */
216 #define EAI_SYSTEM 11 /* system error returned in errno */
218 #endif /* EAI_NONAME */
220 /* flags for getaddrinfo() */
222 #ifndef AI_PASSIVE
223 #define AI_PASSIVE 0x01
224 #define AI_CANONNAME 0x02
225 #endif /* AI_PASSIVE */
227 #ifndef AI_NUMERICHOST
228 #define AI_NUMERICHOST 0x04
229 #endif
231 #ifndef AI_NUMERICSERV
232 #define AI_NUMERICSERV 0x08
233 #endif
235 /* flags for getnameinfo() */
237 #ifndef NI_DGRAM
238 #define NI_DGRAM 0x01
239 #define NI_NAMEREQD 0x02
240 #define NI_NOFQDN 0x04
241 #define NI_NUMERICHOST 0x08
242 #define NI_NUMERICSERV 0x10
243 #endif
246 * constants for getnameinfo
249 #ifndef NI_MAXHOST
250 #define NI_MAXHOST 1025
251 #define NI_MAXSERV 32
252 #endif
255 * constants for inet_ntop
258 #ifndef INET_ADDRSTRLEN
259 #define INET_ADDRSTRLEN 16
260 #endif
262 #ifndef INET6_ADDRSTRLEN
263 #define INET6_ADDRSTRLEN 46
264 #endif
267 * for shutdown(2)
270 #ifndef SHUT_RD
271 #define SHUT_RD 0
272 #endif
274 #ifndef SHUT_WR
275 #define SHUT_WR 1
276 #endif
278 #ifndef SHUT_RDWR
279 #define SHUT_RDWR 2
280 #endif
282 #ifndef HAVE___ATTRIBUTE__
283 #define __attribute__(x)
284 #endif
286 ROKEN_CPP_START
288 #ifndef IRIX4 /* fix for compiler bug */
289 #ifndef _WIN32
290 #ifdef RETSIGTYPE
291 typedef RETSIGTYPE (*SigAction)(int);
292 SigAction signal(int iSig, SigAction pAction); /* BSD compatible */
293 #endif
294 #endif
295 #endif
297 #define SE_E_UNSPECIFIED (-1)
298 #define SE_E_FORKFAILED (-2)
299 #define SE_E_WAITPIDFAILED (-3)
300 #define SE_E_EXECTIMEOUT (-4)
301 #define SE_E_NOEXEC 126
302 #define SE_E_NOTFOUND 127
304 #define SE_PROCSTATUS(st) (((st) >= 0 && (st) < 126)? st: -1)
305 #define SE_PROCSIGNAL(st) (((st) >= 128)? (st) - 128: -1)
306 #define SE_IS_ERROR(st) ((st) < 0 || (st) >= 126)
309 #define simple_execve rk_simple_execve
310 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
311 simple_execve(const char*, char*const[], char*const[]);
313 #define simple_execve_timed rk_simple_execve_timed
314 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
315 simple_execve_timed(const char *, char *const[],
316 char *const [], time_t (*)(void *),
317 void *, time_t);
319 #define simple_execvp rk_simple_execvp
320 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
321 simple_execvp(const char*, char *const[]);
323 #define simple_execvp_timed rk_simple_execvp_timed
324 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
325 simple_execvp_timed(const char *, char *const[],
326 time_t (*)(void *), void *, time_t);
328 #define simple_execlp rk_simple_execlp
329 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
330 simple_execlp(const char*, ...);
332 #define simple_execle rk_simple_execle
333 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
334 simple_execle(const char*, ...);
336 #define wait_for_process rk_wait_for_process
337 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
338 wait_for_process(pid_t);
340 #define wait_for_process_timed rk_wait_for_process_timed
341 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
342 wait_for_process_timed(pid_t, time_t (*)(void *),
343 void *, time_t);
345 #define pipe_execv rk_pipe_execv
346 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
347 pipe_execv(FILE**, FILE**, FILE**, const char*, ...);
349 #define print_version rk_print_version
350 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
351 print_version(const char *);
353 #define eread rk_eread
354 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
355 eread (int fd, void *buf, size_t nbytes);
357 #define ewrite rk_ewrite
358 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
359 ewrite (int fd, const void *buf, size_t nbytes);
361 struct hostent;
363 #define hostent_find_fqdn rk_hostent_find_fqdn
364 ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
365 hostent_find_fqdn (const struct hostent *);
367 #define esetenv rk_esetenv
368 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
369 esetenv(const char *, const char *, int);
371 #define socket_set_address_and_port rk_socket_set_address_and_port
372 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
373 socket_set_address_and_port (struct sockaddr *, const void *, int);
375 #define socket_addr_size rk_socket_addr_size
376 ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
377 socket_addr_size (const struct sockaddr *);
379 #define socket_set_any rk_socket_set_any
380 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
381 socket_set_any (struct sockaddr *, int);
383 #define socket_sockaddr_size rk_socket_sockaddr_size
384 ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
385 socket_sockaddr_size (const struct sockaddr *);
387 #define socket_get_address rk_socket_get_address
388 ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
389 socket_get_address (const struct sockaddr *);
391 #define socket_get_port rk_socket_get_port
392 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
393 socket_get_port (const struct sockaddr *);
395 #define socket_set_port rk_socket_set_port
396 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
397 socket_set_port (struct sockaddr *, int);
399 #define socket_set_portrange rk_socket_set_portrange
400 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
401 socket_set_portrange (rk_socket_t, int, int);
403 #define socket_set_debug rk_socket_set_debug
404 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
405 socket_set_debug (rk_socket_t);
407 #define socket_set_tos rk_socket_set_tos
408 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
409 socket_set_tos (rk_socket_t, int);
411 #define socket_set_reuseaddr rk_socket_set_reuseaddr
412 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
413 socket_set_reuseaddr (rk_socket_t, int);
415 #define socket_set_ipv6only rk_socket_set_ipv6only
416 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
417 socket_set_ipv6only (rk_socket_t, int);
419 #define socket_to_fd rk_socket_to_fd
420 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
421 socket_to_fd(rk_socket_t, int);
423 #define vstrcollect rk_vstrcollect
424 ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
425 vstrcollect(va_list *ap);
427 #define strcollect rk_strcollect
428 ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL
429 strcollect(char *first, ...);
431 #define timevalfix rk_timevalfix
432 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
433 timevalfix(struct timeval *t1);
435 #define timevaladd rk_timevaladd
436 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
437 timevaladd(struct timeval *t1, const struct timeval *t2);
439 #define timevalsub rk_timevalsub
440 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
441 timevalsub(struct timeval *t1, const struct timeval *t2);
443 #define pid_file_write rk_pid_file_write
444 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
445 pid_file_write (const char *progname);
447 #define pid_file_delete rk_pid_file_delete
448 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
449 pid_file_delete (char **);
451 #define read_environment rk_read_environment
452 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
453 read_environment(const char *file, char ***env);
455 #define free_environment rk_free_environment
456 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
457 free_environment(char **);
459 #define warnerr rk_warnerr
460 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
461 rk_warnerr(int doerrno, const char *fmt, va_list ap)
462 __attribute__ ((format (printf, 2, 0)));
464 ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
465 rk_realloc(void *, size_t);
467 struct rk_strpool;
469 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
470 rk_strpoolcollect(struct rk_strpool *);
472 ROKEN_LIB_FUNCTION struct rk_strpool * ROKEN_LIB_CALL
473 rk_strpoolprintf(struct rk_strpool *, const char *, ...)
474 __attribute__ ((format (printf, 2, 3)));
476 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
477 rk_strpoolfree(struct rk_strpool *);
479 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
480 rk_dumpdata (const char *, const void *, size_t);
482 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
483 rk_undumpdata (const char *, void **, size_t *);
485 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
486 rk_xfree (void *);
488 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
489 rk_cloexec(int);
491 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
492 rk_cloexec_file(FILE *);
494 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
495 rk_cloexec_dir(DIR *);
497 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
498 ct_memcmp(const void *, const void *, size_t);
500 void ROKEN_LIB_FUNCTION
501 rk_random_init(void);
503 ROKEN_CPP_END
505 #endif /* __ROKEN_COMMON_H__ */