s4:heimdal: import lorikeet-heimdal-200911122202 (commit 9291fd2d101f3eecec550178634f...
[samba.git] / source4 / heimdal / lib / roken / roken.h.in
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 1995-2005 Kungliga Tekniska Högskolan
4  * (Royal Institute of Technology, Stockholm, Sweden).
5  * All rights reserved.
6  * 
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 
18  * 3. Neither the name of the Institute nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  * 
22  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  */
34
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <stdarg.h>
38 #ifdef HAVE_STDINT_H
39 #include <stdint.h>
40 #endif
41 #include <string.h>
42 #include <signal.h>
43
44 #ifdef _AIX
45 struct ether_addr;
46 struct sockaddr_dl;
47 #endif
48 #ifdef HAVE_SYS_PARAM_H
49 #include <sys/param.h>
50 #endif
51 #ifdef HAVE_INTTYPES_H
52 #include <inttypes.h>
53 #endif
54 #ifdef HAVE_SYS_TYPES_H
55 #include <sys/types.h>
56 #endif
57 #ifdef HAVE_SYS_BITYPES_H
58 #include <sys/bitypes.h>
59 #endif
60 #ifdef HAVE_BIND_BITYPES_H
61 #include <bind/bitypes.h>
62 #endif
63 #ifdef HAVE_NETINET_IN6_MACHTYPES_H
64 #include <netinet/in6_machtypes.h>
65 #endif
66 #ifdef HAVE_UNISTD_H
67 #include <unistd.h>
68 #endif
69 #ifdef HAVE_SYS_SOCKET_H
70 #include <sys/socket.h>
71 #endif
72 #ifdef HAVE_SYS_UIO_H
73 #include <sys/uio.h>
74 #endif
75 #ifdef HAVE_GRP_H
76 #include <grp.h>
77 #endif
78 #ifdef HAVE_SYS_STAT_H
79 #include <sys/stat.h>
80 #endif
81 #ifdef HAVE_NETINET_IN_H
82 #include <netinet/in.h>
83 #endif
84 #ifdef HAVE_NETINET_IN6_H
85 #include <netinet/in6.h>
86 #endif
87 #ifdef HAVE_NETINET6_IN6_H
88 #include <netinet6/in6.h>
89 #endif
90 #ifdef HAVE_ARPA_INET_H
91 #include <arpa/inet.h>
92 #endif
93 #ifdef HAVE_NETDB_H
94 #include <netdb.h>
95 #endif
96 #ifdef HAVE_ARPA_NAMESER_H
97 #include <arpa/nameser.h>
98 #endif
99 #ifdef HAVE_RESOLV_H
100 #include <resolv.h>
101 #endif
102 #ifdef HAVE_SYSLOG_H
103 #include <syslog.h>
104 #endif
105 #ifdef HAVE_FCNTL_H
106 #include <fcntl.h>
107 #endif
108 #ifdef HAVE_ERRNO_H
109 #include <errno.h>
110 #endif
111 #include <err.h>
112 #ifdef HAVE_TERMIOS_H
113 #include <termios.h>
114 #endif
115 #ifdef HAVE_SYS_IOCTL_H
116 #include <sys/ioctl.h>
117 #endif
118 #ifdef TIME_WITH_SYS_TIME
119 #include <sys/time.h>
120 #include <time.h>
121 #elif defined(HAVE_SYS_TIME_H)
122 #include <sys/time.h>
123 #else
124 #include <time.h>
125 #endif
126
127 #ifdef HAVE_WS2TCPIP_H
128 #include <ws2tcpip.h>
129 #endif
130
131 #ifdef HAVE_PATHS_H
132 #include <paths.h>
133 #endif
134
135 #ifndef HAVE_SSIZE_T
136 typedef int ssize_t;
137 #endif
138
139 #include <roken-common.h>
140
141 ROKEN_CPP_START
142
143 #ifdef HAVE_UINTPTR_T
144 #define rk_UNCONST(x) ((void *)(uintptr_t)(const void *)(x))
145 #else
146 #define rk_UNCONST(x) ((void *)(unsigned long)(const void *)(x))
147 #endif
148
149 #if !defined(HAVE_SETSID) && defined(HAVE__SETSID)
150 #define setsid _setsid
151 #endif
152
153 #ifndef HAVE_PUTENV
154 #define putenv rk_putenv
155 int ROKEN_LIB_FUNCTION putenv(const char *);
156 #endif
157
158 #if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO)
159 #ifndef HAVE_SETENV
160 #define setenv rk_setenv
161 #endif
162 int ROKEN_LIB_FUNCTION setenv(const char *, const char *, int);
163 #endif
164
165 #if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO)
166 #ifndef HAVE_UNSETENV
167 #define unsetenv rk_unsetenv
168 #endif
169 void ROKEN_LIB_FUNCTION unsetenv(const char *);
170 #endif
171
172 #if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO)
173 #ifndef HAVE_GETUSERSHELL
174 #define getusershell rk_getusershell
175 #define endusershell rk_endusershell
176 #endif
177 char * ROKEN_LIB_FUNCTION getusershell(void);
178 void ROKEN_LIB_FUNCTION endusershell(void);
179 #endif
180
181 #if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO)
182 #ifndef HAVE_SNPRINTF
183 #define snprintf rk_snprintf
184 #endif
185 int ROKEN_LIB_FUNCTION
186      rk_snprintf (char *, size_t, const char *, ...)
187      __attribute__ ((format (printf, 3, 4)));
188 #endif
189
190 #if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO)
191 #ifndef HAVE_VSNPRINTF
192 #define vsnprintf rk_vsnprintf
193 #endif
194 int ROKEN_LIB_FUNCTION 
195      rk_vsnprintf (char *, size_t, const char *, va_list)
196      __attribute__((format (printf, 3, 0)));
197 #endif
198
199 #if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO)
200 #ifndef HAVE_ASPRINTF
201 #define asprintf rk_asprintf
202 #endif
203 int ROKEN_LIB_FUNCTION
204      rk_asprintf (char **, const char *, ...)
205      __attribute__ ((format (printf, 2, 3)));
206 #endif
207
208 #if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO)
209 #ifndef HAVE_VASPRINTF
210 #define vasprintf rk_vasprintf
211 #endif
212 int ROKEN_LIB_FUNCTION
213     rk_vasprintf (char **, const char *, va_list)
214      __attribute__((format (printf, 2, 0)));
215 #endif
216
217 #if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO)
218 #ifndef HAVE_ASNPRINTF
219 #define asnprintf rk_asnprintf
220 #endif
221 int ROKEN_LIB_FUNCTION
222     rk_asnprintf (char **, size_t, const char *, ...)
223      __attribute__ ((format (printf, 3, 4)));
224 #endif
225
226 #if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO)
227 #ifndef HAVE_VASNPRINTF
228 #define vasnprintf rk_vasnprintf
229 #endif
230 int ROKEN_LIB_FUNCTION
231     vasnprintf (char **, size_t, const char *, va_list)
232      __attribute__((format (printf, 3, 0)));
233 #endif
234
235 #ifndef HAVE_STRDUP
236 #define strdup rk_strdup
237 char * ROKEN_LIB_FUNCTION strdup(const char *);
238 #endif
239
240 #if !defined(HAVE_STRNDUP) || defined(NEED_STRNDUP_PROTO)
241 #ifndef HAVE_STRNDUP
242 #define strndup rk_strndup
243 #endif
244 char * ROKEN_LIB_FUNCTION strndup(const char *, size_t);
245 #endif
246
247 #ifndef HAVE_STRLWR
248 #define strlwr rk_strlwr
249 char * ROKEN_LIB_FUNCTION strlwr(char *);
250 #endif
251
252 #ifndef HAVE_STRNLEN
253 #define strnlen rk_strnlen
254 size_t ROKEN_LIB_FUNCTION strnlen(const char*, size_t);
255 #endif
256
257 #if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO)
258 #ifndef HAVE_STRSEP
259 #define strsep rk_strsep
260 #endif
261 char * ROKEN_LIB_FUNCTION strsep(char**, const char*);
262 #endif
263
264 #if !defined(HAVE_STRSEP_COPY) || defined(NEED_STRSEP_COPY_PROTO)
265 #ifndef HAVE_STRSEP_COPY
266 #define strsep_copy rk_strsep_copy
267 #endif
268 ssize_t ROKEN_LIB_FUNCTION strsep_copy(const char**, const char*, char*, size_t);
269 #endif
270
271 #ifndef HAVE_STRCASECMP
272 #define strcasecmp rk_strcasecmp
273 int ROKEN_LIB_FUNCTION strcasecmp(const char *, const char *);
274 #endif
275
276 #ifdef NEED_FCLOSE_PROTO
277 int ROKEN_LIB_FUNCTION fclose(FILE *);
278 #endif
279
280 #ifdef NEED_STRTOK_R_PROTO
281 char * ROKEN_LIB_FUNCTION strtok_r(char *, const char *, char **);
282 #endif
283
284 #ifndef HAVE_STRUPR
285 #define strupr rk_strupr
286 char * ROKEN_LIB_FUNCTION strupr(char *);
287 #endif
288
289 #ifndef HAVE_STRLCPY
290 #define strlcpy rk_strlcpy
291 size_t ROKEN_LIB_FUNCTION strlcpy (char *, const char *, size_t);
292 #endif
293
294 #ifndef HAVE_STRLCAT
295 #define strlcat rk_strlcat
296 size_t ROKEN_LIB_FUNCTION strlcat (char *, const char *, size_t);
297 #endif
298
299 #ifndef HAVE_GETDTABLESIZE
300 #define getdtablesize rk_getdtablesize
301 int ROKEN_LIB_FUNCTION getdtablesize(void);
302 #endif
303
304 #if !defined(HAVE_STRERROR) && !defined(strerror)
305 #define strerror rk_strerror
306 char * ROKEN_LIB_FUNCTION strerror(int);
307 #endif
308
309 #if !defined(HAVE_STRERROR) && !defined(strerror)
310 #define strerror_r rk_strerror_r
311 int ROKEN_LIB_FUNCTION strerror_r(int, char *, size_t);
312 #endif
313
314
315 #if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO)
316 #ifndef HAVE_HSTRERROR
317 #define hstrerror rk_hstrerror
318 #endif
319 /* This causes a fatal error under Psoriasis */
320 #ifndef SunOS
321 const char * ROKEN_LIB_FUNCTION hstrerror(int);
322 #endif
323 #endif
324
325 #if !HAVE_DECL_H_ERRNO
326 extern int h_errno;
327 #endif
328
329 #if !defined(HAVE_INET_ATON) || defined(NEED_INET_ATON_PROTO)
330 #ifndef HAVE_INET_ATON
331 #define inet_aton rk_inet_aton
332 #endif
333 int ROKEN_LIB_FUNCTION inet_aton(const char *, struct in_addr *);
334 #endif
335
336 #ifndef HAVE_INET_NTOP
337 #define inet_ntop rk_inet_ntop
338 const char * ROKEN_LIB_FUNCTION
339 inet_ntop(int af, const void *src, char *dst, size_t size);
340 #endif
341
342 #ifndef HAVE_INET_PTON
343 #define inet_pton rk_inet_pton
344 int ROKEN_LIB_FUNCTION
345 inet_pton(int, const char *, void *);
346 #endif
347
348 #ifndef HAVE_GETCWD
349 #define getcwd rk_getcwd
350 char* ROKEN_LIB_FUNCTION getcwd(char *, size_t);
351 #endif
352
353 #ifdef HAVE_PWD_H
354 #include <pwd.h>
355 struct passwd * ROKEN_LIB_FUNCTION k_getpwnam (const char *);
356 struct passwd * ROKEN_LIB_FUNCTION k_getpwuid (uid_t);
357 #endif
358
359 const char * ROKEN_LIB_FUNCTION get_default_username (void);
360
361 #ifndef HAVE_SETEUID
362 #define seteuid rk_seteuid
363 int ROKEN_LIB_FUNCTION seteuid(uid_t);
364 #endif
365
366 #ifndef HAVE_SETEGID
367 #define setegid rk_setegid
368 int ROKEN_LIB_FUNCTION setegid(gid_t);
369 #endif
370
371 #ifndef HAVE_LSTAT
372 #define lstat rk_lstat
373 int ROKEN_LIB_FUNCTION lstat(const char *, struct stat *);
374 #endif
375
376 #if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO)
377 #ifndef HAVE_MKSTEMP
378 #define mkstemp rk_mkstemp
379 #endif
380 int ROKEN_LIB_FUNCTION mkstemp(char *);
381 #endif
382
383 #ifndef HAVE_CGETENT
384 #define cgetent rk_cgetent
385 #define cgetstr rk_cgetstr
386 int ROKEN_LIB_FUNCTION cgetent(char **, char **, const char *);
387 int ROKEN_LIB_FUNCTION cgetstr(char *, const char *, char **);
388 #endif
389
390 #ifndef HAVE_INITGROUPS
391 #define initgroups rk_initgroups
392 int ROKEN_LIB_FUNCTION initgroups(const char *, gid_t);
393 #endif
394
395 #ifndef HAVE_FCHOWN
396 #define fchown rk_fchown
397 int ROKEN_LIB_FUNCTION fchown(int, uid_t, gid_t);
398 #endif
399
400 #if !defined(HAVE_DAEMON) || defined(NEED_DAEMON_PROTO)
401 #ifndef HAVE_DAEMON
402 #define daemon rk_daemon
403 #endif
404 int ROKEN_LIB_FUNCTION daemon(int, int);
405 #endif
406
407 #ifndef HAVE_CHOWN
408 #define chown rk_chown
409 int ROKEN_LIB_FUNCTION chown(const char *, uid_t, gid_t);
410 #endif
411
412 #ifndef HAVE_RCMD
413 #define rcmd rk_rcmd
414 int ROKEN_LIB_FUNCTION
415     rcmd(char **, unsigned short, const char *,
416          const char *, const char *, int *);
417 #endif
418
419 #if !defined(HAVE_INNETGR) || defined(NEED_INNETGR_PROTO)
420 #ifndef HAVE_INNETGR
421 #define innetgr rk_innetgr
422 #endif
423 int ROKEN_LIB_FUNCTION innetgr(const char*, const char*,
424     const char*, const char*);
425 #endif
426
427 #ifndef HAVE_IRUSEROK
428 #define iruserok rk_iruserok
429 int ROKEN_LIB_FUNCTION iruserok(unsigned, int, 
430     const char *, const char *);
431 #endif
432
433 #if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO)
434 #ifndef HAVE_GETHOSTNAME
435 #define gethostname rk_gethostname
436 #endif
437 int ROKEN_LIB_FUNCTION gethostname(char *, int);
438 #endif
439
440 #ifndef HAVE_WRITEV
441 #define writev rk_writev
442 ssize_t ROKEN_LIB_FUNCTION
443 writev(int, const struct iovec *, int);
444 #endif
445
446 #ifndef HAVE_READV
447 #define readv rk_readv
448 ssize_t ROKEN_LIB_FUNCTION
449 readv(int, const struct iovec *, int);
450 #endif
451
452 #ifndef HAVE_PIDFILE
453 #define pidfile rk_pidfile
454 void ROKEN_LIB_FUNCTION pidfile (const char*);
455 #endif
456
457 #ifndef HAVE_BSWAP32
458 #define bswap32 rk_bswap32
459 unsigned int ROKEN_LIB_FUNCTION bswap32(unsigned int);
460 #endif
461
462 #ifndef HAVE_BSWAP16
463 #define bswap16 rk_bswap16
464 unsigned short ROKEN_LIB_FUNCTION bswap16(unsigned short);
465 #endif
466
467 #ifndef HAVE_FLOCK
468 #ifndef LOCK_SH
469 #define LOCK_SH   1             /* Shared lock */
470 #endif
471 #ifndef LOCK_EX
472 #define LOCK_EX   2             /* Exclusive lock */
473 #endif
474 #ifndef LOCK_NB
475 #define LOCK_NB   4             /* Don't block when locking */
476 #endif
477 #ifndef LOCK_UN
478 #define LOCK_UN   8             /* Unlock */
479 #endif
480
481 #define flock(_x,_y) rk_flock(_x,_y)
482 int rk_flock(int fd, int operation);
483 #endif /* HAVE_FLOCK */
484
485 #if defined(SunOS) || defined(_AIX)
486 #define dirfd(x) ((x)->dd_fd)
487 #endif
488
489 time_t ROKEN_LIB_FUNCTION tm2time (struct tm, int);
490
491 int ROKEN_LIB_FUNCTION unix_verify_user(char *, char *);
492
493 int ROKEN_LIB_FUNCTION roken_concat (char *, size_t, ...);
494
495 size_t ROKEN_LIB_FUNCTION roken_mconcat (char **, size_t, ...);
496
497 int ROKEN_LIB_FUNCTION roken_vconcat (char *, size_t, va_list);
498
499 size_t ROKEN_LIB_FUNCTION
500     roken_vmconcat (char **, size_t, va_list);
501
502 ssize_t ROKEN_LIB_FUNCTION net_write (int, const void *, size_t);
503
504 ssize_t ROKEN_LIB_FUNCTION net_read (int, void *, size_t);
505
506 int ROKEN_LIB_FUNCTION issuid(void);
507
508 #ifndef HAVE_STRUCT_WINSIZE
509 struct winsize {
510         unsigned short ws_row, ws_col;
511         unsigned short ws_xpixel, ws_ypixel;
512 };
513 #endif
514
515 int ROKEN_LIB_FUNCTION get_window_size(int fd, struct winsize *);
516
517 #ifndef HAVE_VSYSLOG
518 #define vsyslog rk_vsyslog
519 void ROKEN_LIB_FUNCTION vsyslog(int, const char *, va_list);
520 #endif
521
522 #if !HAVE_DECL_OPTARG
523 extern char *optarg;
524 #endif
525 #if !HAVE_DECL_OPTIND
526 extern int optind;
527 #endif
528 #if !HAVE_DECL_OPTERR
529 extern int opterr;
530 #endif
531
532 #ifndef HAVE_GETIPNODEBYNAME
533 #define getipnodebyname rk_getipnodebyname
534 struct hostent * ROKEN_LIB_FUNCTION
535 getipnodebyname (const char *, int, int, int *);
536 #endif
537
538 #ifndef HAVE_GETIPNODEBYADDR
539 #define getipnodebyaddr rk_getipnodebyaddr
540 struct hostent * ROKEN_LIB_FUNCTION
541 getipnodebyaddr (const void *, size_t, int, int *);
542 #endif
543
544 #ifndef HAVE_FREEHOSTENT
545 #define freehostent rk_freehostent
546 void ROKEN_LIB_FUNCTION
547 freehostent (struct hostent *);
548 #endif
549
550 #ifndef HAVE_COPYHOSTENT
551 #define copyhostent rk_copyhostent
552 struct hostent * ROKEN_LIB_FUNCTION
553 copyhostent (const struct hostent *);
554 #endif
555
556 #ifndef HAVE_SOCKLEN_T
557 typedef int socklen_t;
558 #endif
559
560 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
561
562 #ifndef HAVE_SA_FAMILY_T
563 typedef unsigned short sa_family_t;
564 #endif
565
566 #ifdef HAVE_IPV6
567 #define _SS_MAXSIZE sizeof(struct sockaddr_in6)
568 #else
569 #define _SS_MAXSIZE sizeof(struct sockaddr_in)
570 #endif
571
572 #define _SS_ALIGNSIZE   sizeof(unsigned long)
573
574 #if HAVE_STRUCT_SOCKADDR_SA_LEN
575
576 typedef unsigned char roken_sa_family_t;
577
578 #define _SS_PAD1SIZE   ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t) - sizeof(unsigned char)) % _SS_ALIGNSIZE)
579 #define _SS_PAD2SIZE   (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + sizeof(unsigned char) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
580
581 struct sockaddr_storage {
582     unsigned char       ss_len;
583     roken_sa_family_t   ss_family;
584     char                __ss_pad1[_SS_PAD1SIZE];
585     unsigned long       __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1];
586 };
587
588 #else /* !HAVE_STRUCT_SOCKADDR_SA_LEN */
589
590 typedef unsigned short roken_sa_family_t;
591
592 #define _SS_PAD1SIZE   ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t)) % _SS_ALIGNSIZE)
593 #define _SS_PAD2SIZE   (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
594
595 struct sockaddr_storage {
596     roken_sa_family_t   ss_family;
597     char                __ss_pad1[_SS_PAD1SIZE];
598     unsigned long       __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1];
599 };
600
601 #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
602
603 #endif /* HAVE_STRUCT_SOCKADDR_STORAGE */
604
605 #ifndef HAVE_STRUCT_ADDRINFO
606 struct addrinfo {
607     int    ai_flags;
608     int    ai_family;
609     int    ai_socktype;
610     int    ai_protocol;
611     size_t ai_addrlen;
612     char  *ai_canonname;
613     struct sockaddr *ai_addr;
614     struct addrinfo *ai_next;
615 };
616 #endif
617
618 #ifndef HAVE_GETADDRINFO
619 #define getaddrinfo rk_getaddrinfo
620 int ROKEN_LIB_FUNCTION
621 getaddrinfo(const char *,
622             const char *,
623             const struct addrinfo *,
624             struct addrinfo **);
625 #endif
626
627 #ifndef HAVE_GETNAMEINFO
628 #define getnameinfo rk_getnameinfo
629 int ROKEN_LIB_FUNCTION
630 getnameinfo(const struct sockaddr *, socklen_t,
631                 char *, size_t,
632                 char *, size_t,
633                 int);
634 #endif
635
636 #ifndef HAVE_FREEADDRINFO
637 #define freeaddrinfo rk_freeaddrinfo
638 void ROKEN_LIB_FUNCTION
639 freeaddrinfo(struct addrinfo *);
640 #endif
641
642 #ifndef HAVE_GAI_STRERROR
643 #define gai_strerror rk_gai_strerror
644 const char * ROKEN_LIB_FUNCTION
645 gai_strerror(int);
646 #endif
647
648 int ROKEN_LIB_FUNCTION
649 getnameinfo_verified(const struct sockaddr *, socklen_t,
650                      char *, size_t,
651                      char *, size_t,
652                      int);
653
654 int ROKEN_LIB_FUNCTION
655 roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **); 
656 int ROKEN_LIB_FUNCTION
657 roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **);
658
659 #ifndef HAVE_STRFTIME
660 #define strftime rk_strftime
661 size_t ROKEN_LIB_FUNCTION
662 strftime (char *, size_t, const char *, const struct tm *);
663 #endif
664
665 #ifndef HAVE_STRPTIME
666 #define strptime rk_strptime
667 char * ROKEN_LIB_FUNCTION
668 strptime (const char *, const char *, struct tm *);
669 #endif
670
671 #ifndef HAVE_EMALLOC
672 #define emalloc rk_emalloc
673 void * ROKEN_LIB_FUNCTION emalloc (size_t);
674 #endif
675 #ifndef HAVE_ECALLOC
676 #define ecalloc rk_ecalloc
677 void * ROKEN_LIB_FUNCTION ecalloc(size_t, size_t);
678 #endif
679 #ifndef HAVE_EREALLOC
680 #define erealloc rk_erealloc
681 void * ROKEN_LIB_FUNCTION erealloc (void *, size_t);
682 #endif
683 #ifndef HAVE_ESTRDUP
684 #define estrdup rk_estrdup
685 char * ROKEN_LIB_FUNCTION estrdup (const char *);
686 #endif
687
688 /*
689  * kludges and such
690  */
691
692 int ROKEN_LIB_FUNCTION
693 roken_gethostby_setup(const char*, const char*);
694 struct hostent* ROKEN_LIB_FUNCTION
695 roken_gethostbyname(const char*);
696 struct hostent* ROKEN_LIB_FUNCTION 
697 roken_gethostbyaddr(const void*, size_t, int);
698
699 #ifdef GETSERVBYNAME_PROTO_COMPATIBLE
700 #define roken_getservbyname(x,y) getservbyname(x,y)
701 #else
702 #define roken_getservbyname(x,y) getservbyname((char *)x, (char *)y)
703 #endif
704
705 #ifdef OPENLOG_PROTO_COMPATIBLE
706 #define roken_openlog(a,b,c) openlog(a,b,c)
707 #else
708 #define roken_openlog(a,b,c) openlog((char *)a,b,c)
709 #endif
710
711 #ifdef GETSOCKNAME_PROTO_COMPATIBLE
712 #define roken_getsockname(a,b,c) getsockname(a,b,c)
713 #else
714 #define roken_getsockname(a,b,c) getsockname(a, b, (void*)c)
715 #endif
716
717 #ifndef HAVE_SETPROGNAME
718 #define setprogname rk_setprogname
719 void ROKEN_LIB_FUNCTION setprogname(const char *);
720 #endif
721
722 #ifndef HAVE_GETPROGNAME
723 #define getprogname rk_getprogname
724 const char * ROKEN_LIB_FUNCTION getprogname(void);
725 #endif
726
727 #if !defined(HAVE_SETPROGNAME) && !defined(HAVE_GETPROGNAME) && !HAVE_DECL___PROGNAME
728 extern const char *__progname;
729 #endif
730
731 void ROKEN_LIB_FUNCTION mini_inetd_addrinfo (struct addrinfo*);
732 void ROKEN_LIB_FUNCTION mini_inetd (int);
733
734 #ifndef HAVE_LOCALTIME_R
735 #define localtime_r rk_localtime_r
736 struct tm * ROKEN_LIB_FUNCTION
737 localtime_r(const time_t *, struct tm *);
738 #endif
739
740 #if !defined(HAVE_STRSVIS) || defined(NEED_STRSVIS_PROTO)
741 #ifndef HAVE_STRSVIS
742 #define strsvis rk_strsvis
743 #endif
744 int ROKEN_LIB_FUNCTION
745 strsvis(char *, const char *, int, const char *);
746 #endif
747
748 #if !defined(HAVE_STRUNVIS) || defined(NEED_STRUNVIS_PROTO)
749 #ifndef HAVE_STRUNVIS
750 #define strunvis rk_strunvis
751 #endif
752 int ROKEN_LIB_FUNCTION
753 strunvis(char *, const char *);
754 #endif
755
756 #if !defined(HAVE_STRVIS) || defined(NEED_STRVIS_PROTO)
757 #ifndef HAVE_STRVIS
758 #define strvis rk_strvis
759 #endif
760 int ROKEN_LIB_FUNCTION
761 strvis(char *, const char *, int);
762 #endif
763
764 #if !defined(HAVE_STRVISX) || defined(NEED_STRVISX_PROTO)
765 #ifndef HAVE_STRVISX
766 #define strvisx rk_strvisx
767 #endif
768 int ROKEN_LIB_FUNCTION
769 strvisx(char *, const char *, size_t, int);
770 #endif
771
772 #if !defined(HAVE_SVIS) || defined(NEED_SVIS_PROTO)
773 #ifndef HAVE_SVIS
774 #define svis rk_svis
775 #endif
776 char * ROKEN_LIB_FUNCTION
777 svis(char *, int, int, int, const char *);
778 #endif
779
780 #if !defined(HAVE_UNVIS) || defined(NEED_UNVIS_PROTO)
781 #ifndef HAVE_UNVIS
782 #define unvis rk_unvis
783 #endif
784 int ROKEN_LIB_FUNCTION
785 unvis(char *, int, int *, int);
786 #endif
787
788 #if !defined(HAVE_VIS) || defined(NEED_VIS_PROTO)
789 #ifndef HAVE_VIS
790 #define vis rk_vis
791 #endif
792 char * ROKEN_LIB_FUNCTION
793 vis(char *, int, int, int);
794 #endif
795
796 #if !defined(HAVE_CLOSEFROM)
797 #define closefrom rk_closefrom
798 int ROKEN_LIB_FUNCTION
799 closefrom(int);
800 #endif
801
802 #if !defined(HAVE_TIMEGM)
803 #define timegm rk_timegm
804 time_t ROKEN_LIB_FUNCTION
805 rk_timegm(struct tm *tm);
806 #endif
807
808 #ifdef NEED_QSORT
809 #define qsort rk_qsort
810 void
811 rk_qsort(void *, size_t, size_t, int (*)(const void *, const void *));
812 #endif
813
814 #ifdef SOCKET_WRAPPER_REPLACE
815 #include <socket_wrapper.h>
816 #endif
817
818 ROKEN_CPP_END