roken.h.in revision 1.1 1 1.1 elric /* -*- C -*- */
2 1.1 elric /*
3 1.1 elric * Copyright (c) 1995-2005 Kungliga Tekniska Hgskolan
4 1.1 elric * (Royal Institute of Technology, Stockholm, Sweden).
5 1.1 elric * All rights reserved.
6 1.1 elric *
7 1.1 elric * Redistribution and use in source and binary forms, with or without
8 1.1 elric * modification, are permitted provided that the following conditions
9 1.1 elric * are met:
10 1.1 elric *
11 1.1 elric * 1. Redistributions of source code must retain the above copyright
12 1.1 elric * notice, this list of conditions and the following disclaimer.
13 1.1 elric *
14 1.1 elric * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 elric * notice, this list of conditions and the following disclaimer in the
16 1.1 elric * documentation and/or other materials provided with the distribution.
17 1.1 elric *
18 1.1 elric * 3. Neither the name of the Institute nor the names of its contributors
19 1.1 elric * may be used to endorse or promote products derived from this software
20 1.1 elric * without specific prior written permission.
21 1.1 elric *
22 1.1 elric * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23 1.1 elric * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.1 elric * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.1 elric * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26 1.1 elric * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.1 elric * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.1 elric * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 elric * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.1 elric * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.1 elric * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 elric * SUCH DAMAGE.
33 1.1 elric */
34 1.1 elric
35 1.1 elric #include <stdio.h>
36 1.1 elric #include <stdlib.h>
37 1.1 elric #include <stdarg.h>
38 1.1 elric #ifdef HAVE_STDINT_H
39 1.1 elric #include <stdint.h>
40 1.1 elric #endif
41 1.1 elric #include <string.h>
42 1.1 elric #include <signal.h>
43 1.1 elric
44 1.1 elric #ifndef ROKEN_LIB_FUNCTION
45 1.1 elric #ifdef _WIN32
46 1.1 elric # define ROKEN_LIB_CALL __cdecl
47 1.1 elric # ifdef ROKEN_LIB_DYNAMIC
48 1.1 elric # define ROKEN_LIB_FUNCTION __declspec(dllimport)
49 1.1 elric # define ROKEN_LIB_VARIABLE __declspec(dllimport)
50 1.1 elric # else
51 1.1 elric # define ROKEN_LIB_FUNCTION
52 1.1 elric # define ROKEN_LIB_VARIABLE
53 1.1 elric # endif
54 1.1 elric #else
55 1.1 elric #define ROKEN_LIB_FUNCTION
56 1.1 elric #define ROKEN_LIB_CALL
57 1.1 elric #define ROKEN_LIB_VARIABLE
58 1.1 elric #endif
59 1.1 elric #endif
60 1.1 elric
61 1.1 elric #ifdef HAVE_WINSOCK
62 1.1 elric /* Declarations for Microsoft Windows */
63 1.1 elric
64 1.1 elric #include <winsock2.h>
65 1.1 elric #include <ws2tcpip.h>
66 1.1 elric
67 1.1 elric /*
68 1.1 elric * error codes for inet_ntop/inet_pton
69 1.1 elric */
70 1.1 elric #define EAFNOSUPPORT WSAEAFNOSUPPORT
71 1.1 elric
72 1.1 elric typedef SOCKET rk_socket_t;
73 1.1 elric
74 1.1 elric #define rk_closesocket(x) closesocket(x)
75 1.1 elric #define rk_INVALID_SOCKET INVALID_SOCKET
76 1.1 elric #define rk_IS_BAD_SOCKET(s) ((s) == INVALID_SOCKET)
77 1.1 elric #define rk_IS_SOCKET_ERROR(rv) ((rv) == SOCKET_ERROR)
78 1.1 elric #define rk_SOCK_ERRNO WSAGetLastError()
79 1.1 elric
80 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_SOCK_IOCTL(SOCKET s, long cmd, int * argp);
81 1.1 elric
82 1.1 elric #define ETIMEDOUT WSAETIMEDOUT
83 1.1 elric #define EWOULDBLOCK WSAEWOULDBLOCK
84 1.1 elric #define ENOTSOCK WSAENOTSOCK
85 1.1 elric
86 1.1 elric #define rk_SOCK_INIT() rk_WSAStartup()
87 1.1 elric #define rk_SOCK_EXIT() rk_WSACleanup()
88 1.1 elric
89 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSAStartup(void);
90 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSACleanup(void);
91 1.1 elric
92 1.1 elric #else /* not WinSock */
93 1.1 elric
94 1.1 elric typedef int rk_socket_t;
95 1.1 elric
96 1.1 elric #define rk_closesocket(x) close(x)
97 1.1 elric #define rk_SOCK_IOCTL(s,c,a) ioctl((s),(c),(a))
98 1.1 elric #define rk_IS_BAD_SOCKET(s) ((s) < 0)
99 1.1 elric #define rk_IS_SOCKET_ERROR(rv) ((rv) < 0)
100 1.1 elric #define rk_SOCK_ERRNO errno
101 1.1 elric #define rk_INVALID_SOCKET (-1)
102 1.1 elric
103 1.1 elric #define rk_SOCK_INIT() 0
104 1.1 elric #define rk_SOCK_EXIT() do { } while(0)
105 1.1 elric
106 1.1 elric #endif
107 1.1 elric
108 1.1 elric #ifdef _MSC_VER
109 1.1 elric /* Declarations for Microsoft Visual C runtime on Windows */
110 1.1 elric
111 1.1 elric #include<process.h>
112 1.1 elric
113 1.1 elric #include<io.h>
114 1.1 elric
115 1.1 elric #ifndef __BIT_TYPES_DEFINED__
116 1.1 elric #define __BIT_TYPES_DEFINED__
117 1.1 elric
118 1.1 elric typedef __int8 int8_t;
119 1.1 elric typedef __int16 int16_t;
120 1.1 elric typedef __int32 int32_t;
121 1.1 elric typedef __int64 int64_t;
122 1.1 elric typedef unsigned __int8 uint8_t;
123 1.1 elric typedef unsigned __int16 uint16_t;
124 1.1 elric typedef unsigned __int32 uint32_t;
125 1.1 elric typedef unsigned __int64 uint64_t;
126 1.1 elric typedef uint8_t u_int8_t;
127 1.1 elric typedef uint16_t u_int16_t;
128 1.1 elric typedef uint32_t u_int32_t;
129 1.1 elric typedef uint64_t u_int64_t;
130 1.1 elric
131 1.1 elric #endif /* __BIT_TYPES_DEFINED__ */
132 1.1 elric
133 1.1 elric #define UNREACHABLE(x) x
134 1.1 elric #define UNUSED_ARGUMENT(x) ((void) x)
135 1.1 elric
136 1.1 elric #define RETSIGTYPE void
137 1.1 elric
138 1.1 elric #define VOID_RETSIGTYPE 1
139 1.1 elric
140 1.1 elric #ifdef VOID_RETSIGTYPE
141 1.1 elric #define SIGRETURN(x) return
142 1.1 elric #else
143 1.1 elric #define SIGRETURN(x) return (RETSIGTYPE)(x)
144 1.1 elric #endif
145 1.1 elric
146 1.1 elric #ifndef CPP_ONLY
147 1.1 elric
148 1.1 elric typedef int pid_t;
149 1.1 elric
150 1.1 elric typedef unsigned int gid_t;
151 1.1 elric
152 1.1 elric typedef unsigned int uid_t;
153 1.1 elric
154 1.1 elric typedef unsigned short mode_t;
155 1.1 elric
156 1.1 elric #endif
157 1.1 elric
158 1.1 elric #ifndef __cplusplus
159 1.1 elric #define inline __inline
160 1.1 elric #endif
161 1.1 elric
162 1.1 elric #else
163 1.1 elric
164 1.1 elric #define UNREACHABLE(x)
165 1.1 elric #define UNUSED_ARGUMENT(x)
166 1.1 elric
167 1.1 elric #endif
168 1.1 elric
169 1.1 elric #ifdef _AIX
170 1.1 elric struct ether_addr;
171 1.1 elric struct sockaddr_dl;
172 1.1 elric #endif
173 1.1 elric #ifdef HAVE_SYS_PARAM_H
174 1.1 elric #include <sys/param.h>
175 1.1 elric #endif
176 1.1 elric #ifdef HAVE_INTTYPES_H
177 1.1 elric #include <inttypes.h>
178 1.1 elric #endif
179 1.1 elric #ifdef HAVE_SYS_TYPES_H
180 1.1 elric #include <sys/types.h>
181 1.1 elric #endif
182 1.1 elric #ifdef HAVE_SYS_BITYPES_H
183 1.1 elric #include <sys/bitypes.h>
184 1.1 elric #endif
185 1.1 elric #ifdef HAVE_BIND_BITYPES_H
186 1.1 elric #include <bind/bitypes.h>
187 1.1 elric #endif
188 1.1 elric #ifdef HAVE_NETINET_IN6_MACHTYPES_H
189 1.1 elric #include <netinet/in6_machtypes.h>
190 1.1 elric #endif
191 1.1 elric #ifdef HAVE_UNISTD_H
192 1.1 elric #include <unistd.h>
193 1.1 elric #endif
194 1.1 elric #ifdef HAVE_SYS_SOCKET_H
195 1.1 elric #include <sys/socket.h>
196 1.1 elric #endif
197 1.1 elric #ifdef HAVE_SYS_UIO_H
198 1.1 elric #include <sys/uio.h>
199 1.1 elric #endif
200 1.1 elric #ifdef HAVE_GRP_H
201 1.1 elric #include <grp.h>
202 1.1 elric #endif
203 1.1 elric #ifdef HAVE_SYS_STAT_H
204 1.1 elric #include <sys/stat.h>
205 1.1 elric #endif
206 1.1 elric #ifdef HAVE_NETINET_IN_H
207 1.1 elric #include <netinet/in.h>
208 1.1 elric #endif
209 1.1 elric #ifdef HAVE_NETINET_IN6_H
210 1.1 elric #include <netinet/in6.h>
211 1.1 elric #endif
212 1.1 elric #ifdef HAVE_NETINET6_IN6_H
213 1.1 elric #include <netinet6/in6.h>
214 1.1 elric #endif
215 1.1 elric #ifdef HAVE_ARPA_INET_H
216 1.1 elric #include <arpa/inet.h>
217 1.1 elric #endif
218 1.1 elric #ifdef HAVE_NETDB_H
219 1.1 elric #include <netdb.h>
220 1.1 elric #endif
221 1.1 elric #ifdef HAVE_ARPA_NAMESER_H
222 1.1 elric #include <arpa/nameser.h>
223 1.1 elric #endif
224 1.1 elric #ifdef HAVE_RESOLV_H
225 1.1 elric #include <resolv.h>
226 1.1 elric #endif
227 1.1 elric #ifdef HAVE_SYSLOG_H
228 1.1 elric #include <syslog.h>
229 1.1 elric #endif
230 1.1 elric #ifdef HAVE_FCNTL_H
231 1.1 elric #include <fcntl.h>
232 1.1 elric #endif
233 1.1 elric #ifdef HAVE_ERRNO_H
234 1.1 elric #include <errno.h>
235 1.1 elric #endif
236 1.1 elric #include <err.h>
237 1.1 elric #ifdef HAVE_TERMIOS_H
238 1.1 elric #include <termios.h>
239 1.1 elric #endif
240 1.1 elric #ifdef HAVE_SYS_IOCTL_H
241 1.1 elric #include <sys/ioctl.h>
242 1.1 elric #endif
243 1.1 elric #ifdef TIME_WITH_SYS_TIME
244 1.1 elric #include <sys/time.h>
245 1.1 elric #include <time.h>
246 1.1 elric #elif defined(HAVE_SYS_TIME_H)
247 1.1 elric #include <sys/time.h>
248 1.1 elric #else
249 1.1 elric #include <time.h>
250 1.1 elric #endif
251 1.1 elric
252 1.1 elric #ifdef HAVE_PATHS_H
253 1.1 elric #include <paths.h>
254 1.1 elric #endif
255 1.1 elric
256 1.1 elric #ifdef HAVE_DIRENT_H
257 1.1 elric #include <dirent.h>
258 1.1 elric #endif
259 1.1 elric
260 1.1 elric #ifdef BACKSLASH_PATH_DELIM
261 1.1 elric #define rk_PATH_DELIM '\\'
262 1.1 elric #endif
263 1.1 elric
264 1.1 elric #ifndef HAVE_SSIZE_T
265 1.1 elric #ifndef SSIZE_T_DEFINED
266 1.1 elric #ifdef ssize_t
267 1.1 elric #undef ssize_t
268 1.1 elric #endif
269 1.1 elric #ifdef _WIN64
270 1.1 elric typedef __int64 ssize_t;
271 1.1 elric #else
272 1.1 elric typedef int ssize_t;
273 1.1 elric #endif
274 1.1 elric #define SSIZE_T_DEFINED
275 1.1 elric #endif /* SSIZE_T_DEFINED */
276 1.1 elric #endif /* HAVE_SSIZE_T */
277 1.1 elric
278 1.1 elric #include <roken-common.h>
279 1.1 elric
280 1.1 elric ROKEN_CPP_START
281 1.1 elric
282 1.1 elric #ifdef HAVE_UINTPTR_T
283 1.1 elric #define rk_UNCONST(x) ((void *)(uintptr_t)(const void *)(x))
284 1.1 elric #else
285 1.1 elric #define rk_UNCONST(x) ((void *)(unsigned long)(const void *)(x))
286 1.1 elric #endif
287 1.1 elric
288 1.1 elric #if !defined(HAVE_SETSID) && defined(HAVE__SETSID)
289 1.1 elric #define setsid _setsid
290 1.1 elric #endif
291 1.1 elric
292 1.1 elric #ifdef _MSC_VER
293 1.1 elric /* Additional macros for Visual C/C++ runtime */
294 1.1 elric
295 1.1 elric #define close _close
296 1.1 elric
297 1.1 elric #define getpid _getpid
298 1.1 elric
299 1.1 elric #define open _open
300 1.1 elric
301 1.1 elric #define chdir _chdir
302 1.1 elric
303 1.1 elric #define fsync _commit
304 1.1 elric
305 1.1 elric /* The MSVC implementation of snprintf is not C99 compliant. */
306 1.1 elric #define snprintf rk_snprintf
307 1.1 elric #define vsnprintf rk_vsnprintf
308 1.1 elric #define vasnprintf rk_vasnprintf
309 1.1 elric #define vasprintf rk_vasprintf
310 1.1 elric #define asnprintf rk_asnprintf
311 1.1 elric #define asprintf rk_asprintf
312 1.1 elric
313 1.1 elric #define _PIPE_BUFFER_SZ 8192
314 1.1 elric #define pipe(fds) _pipe((fds), _PIPE_BUFFER_SZ, O_BINARY);
315 1.1 elric
316 1.1 elric #define ftruncate(fd, sz) _chsize((fd), (sz))
317 1.1 elric
318 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
319 1.1 elric rk_snprintf (char *str, size_t sz, const char *format, ...);
320 1.1 elric
321 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
322 1.1 elric rk_asprintf (char **ret, const char *format, ...);
323 1.1 elric
324 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
325 1.1 elric rk_asnprintf (char **ret, size_t max_sz, const char *format, ...);
326 1.1 elric
327 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
328 1.1 elric rk_vasprintf (char **ret, const char *format, va_list args);
329 1.1 elric
330 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
331 1.1 elric rk_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args);
332 1.1 elric
333 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
334 1.1 elric rk_vsnprintf (char *str, size_t sz, const char *format, va_list args);
335 1.1 elric
336 1.1 elric /* missing stat.h predicates */
337 1.1 elric
338 1.1 elric #define S_ISREG(m) (((m) & _S_IFREG) == _S_IFREG)
339 1.1 elric
340 1.1 elric #define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
341 1.1 elric
342 1.1 elric #define S_ISCHR(m) (((m) & _S_IFCHR) == _S_IFCHR)
343 1.1 elric
344 1.1 elric #define S_ISFIFO(m) (((m) & _S_IFIFO) == _S_IFIFO)
345 1.1 elric
346 1.1 elric /* The following are not implemented:
347 1.1 elric
348 1.1 elric S_ISLNK(m)
349 1.1 elric S_ISSOCK(m)
350 1.1 elric S_ISBLK(m)
351 1.1 elric */
352 1.1 elric
353 1.1 elric #endif /* _MSC_VER */
354 1.1 elric
355 1.1 elric #ifdef HAVE_WINSOCK
356 1.1 elric
357 1.1 elric /* While we are at it, define WinSock specific scatter gather socket
358 1.1 elric I/O. */
359 1.1 elric
360 1.1 elric #define iovec _WSABUF
361 1.1 elric #define iov_base buf
362 1.1 elric #define iov_len len
363 1.1 elric
364 1.1 elric struct msghdr {
365 1.1 elric void *msg_name;
366 1.1 elric socklen_t msg_namelen;
367 1.1 elric struct iovec *msg_iov;
368 1.1 elric size_t msg_iovlen;
369 1.1 elric void *msg_control;
370 1.1 elric socklen_t msg_controllen;
371 1.1 elric int msg_flags;
372 1.1 elric };
373 1.1 elric
374 1.1 elric #define sendmsg sendmsg_w32
375 1.1 elric
376 1.1 elric ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
377 1.1 elric sendmsg_w32(rk_socket_t s, const struct msghdr * msg, int flags);
378 1.1 elric
379 1.1 elric #endif /* HAVE_WINSOCK */
380 1.1 elric
381 1.1 elric #ifndef HAVE_PUTENV
382 1.1 elric #define putenv rk_putenv
383 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL putenv(const char *);
384 1.1 elric #endif
385 1.1 elric
386 1.1 elric #if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO)
387 1.1 elric #ifndef HAVE_SETENV
388 1.1 elric #define setenv rk_setenv
389 1.1 elric #endif
390 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setenv(const char *, const char *, int);
391 1.1 elric #endif
392 1.1 elric
393 1.1 elric #if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO)
394 1.1 elric #ifndef HAVE_UNSETENV
395 1.1 elric #define unsetenv rk_unsetenv
396 1.1 elric #endif
397 1.1 elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL unsetenv(const char *);
398 1.1 elric #endif
399 1.1 elric
400 1.1 elric #if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO)
401 1.1 elric #ifndef HAVE_GETUSERSHELL
402 1.1 elric #define getusershell rk_getusershell
403 1.1 elric #define endusershell rk_endusershell
404 1.1 elric #endif
405 1.1 elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL getusershell(void);
406 1.1 elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL endusershell(void);
407 1.1 elric #endif
408 1.1 elric
409 1.1 elric #if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO)
410 1.1 elric #ifndef HAVE_SNPRINTF
411 1.1 elric #define snprintf rk_snprintf
412 1.1 elric #endif
413 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
414 1.1 elric rk_snprintf (char *, size_t, const char *, ...)
415 1.1 elric __attribute__ ((format (printf, 3, 4)));
416 1.1 elric #endif
417 1.1 elric
418 1.1 elric #if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO)
419 1.1 elric #ifndef HAVE_VSNPRINTF
420 1.1 elric #define vsnprintf rk_vsnprintf
421 1.1 elric #endif
422 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
423 1.1 elric rk_vsnprintf (char *, size_t, const char *, va_list)
424 1.1 elric __attribute__((format (printf, 3, 0)));
425 1.1 elric #endif
426 1.1 elric
427 1.1 elric #if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO)
428 1.1 elric #ifndef HAVE_ASPRINTF
429 1.1 elric #define asprintf rk_asprintf
430 1.1 elric #endif
431 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
432 1.1 elric rk_asprintf (char **, const char *, ...)
433 1.1 elric __attribute__ ((format (printf, 2, 3)));
434 1.1 elric #endif
435 1.1 elric
436 1.1 elric #if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO)
437 1.1 elric #ifndef HAVE_VASPRINTF
438 1.1 elric #define vasprintf rk_vasprintf
439 1.1 elric #endif
440 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
441 1.1 elric rk_vasprintf (char **, const char *, va_list)
442 1.1 elric __attribute__((format (printf, 2, 0)));
443 1.1 elric #endif
444 1.1 elric
445 1.1 elric #if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO)
446 1.1 elric #ifndef HAVE_ASNPRINTF
447 1.1 elric #define asnprintf rk_asnprintf
448 1.1 elric #endif
449 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
450 1.1 elric rk_asnprintf (char **, size_t, const char *, ...)
451 1.1 elric __attribute__ ((format (printf, 3, 4)));
452 1.1 elric #endif
453 1.1 elric
454 1.1 elric #if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO)
455 1.1 elric #ifndef HAVE_VASNPRINTF
456 1.1 elric #define vasnprintf rk_vasnprintf
457 1.1 elric #endif
458 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
459 1.1 elric vasnprintf (char **, size_t, const char *, va_list)
460 1.1 elric __attribute__((format (printf, 3, 0)));
461 1.1 elric #endif
462 1.1 elric
463 1.1 elric #ifndef HAVE_STRDUP
464 1.1 elric #define strdup rk_strdup
465 1.1 elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strdup(const char *);
466 1.1 elric #endif
467 1.1 elric
468 1.1 elric #if !defined(HAVE_STRNDUP) || defined(NEED_STRNDUP_PROTO)
469 1.1 elric #ifndef HAVE_STRNDUP
470 1.1 elric #define strndup rk_strndup
471 1.1 elric #endif
472 1.1 elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strndup(const char *, size_t);
473 1.1 elric #endif
474 1.1 elric
475 1.1 elric #ifndef HAVE_STRLWR
476 1.1 elric #define strlwr rk_strlwr
477 1.1 elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strlwr(char *);
478 1.1 elric #endif
479 1.1 elric
480 1.1 elric #ifndef HAVE_STRNLEN
481 1.1 elric #define strnlen rk_strnlen
482 1.1 elric ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strnlen(const char*, size_t);
483 1.1 elric #endif
484 1.1 elric
485 1.1 elric #if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO)
486 1.1 elric #ifndef HAVE_STRSEP
487 1.1 elric #define strsep rk_strsep
488 1.1 elric #endif
489 1.1 elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strsep(char**, const char*);
490 1.1 elric #endif
491 1.1 elric
492 1.1 elric #if !defined(HAVE_STRSEP_COPY) || defined(NEED_STRSEP_COPY_PROTO)
493 1.1 elric #ifndef HAVE_STRSEP_COPY
494 1.1 elric #define strsep_copy rk_strsep_copy
495 1.1 elric #endif
496 1.1 elric ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL strsep_copy(const char**, const char*, char*, size_t);
497 1.1 elric #endif
498 1.1 elric
499 1.1 elric #ifndef HAVE_STRCASECMP
500 1.1 elric #define strcasecmp rk_strcasecmp
501 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL strcasecmp(const char *, const char *);
502 1.1 elric #endif
503 1.1 elric
504 1.1 elric #ifdef NEED_FCLOSE_PROTO
505 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fclose(FILE *);
506 1.1 elric #endif
507 1.1 elric
508 1.1 elric #ifdef NEED_STRTOK_R_PROTO
509 1.1 elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strtok_r(char *, const char *, char **);
510 1.1 elric #endif
511 1.1 elric
512 1.1 elric #ifndef HAVE_STRUPR
513 1.1 elric #define strupr rk_strupr
514 1.1 elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strupr(char *);
515 1.1 elric #endif
516 1.1 elric
517 1.1 elric #ifndef HAVE_STRLCPY
518 1.1 elric #define strlcpy rk_strlcpy
519 1.1 elric ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcpy (char *, const char *, size_t);
520 1.1 elric #endif
521 1.1 elric
522 1.1 elric #ifndef HAVE_STRLCAT
523 1.1 elric #define strlcat rk_strlcat
524 1.1 elric ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcat (char *, const char *, size_t);
525 1.1 elric #endif
526 1.1 elric
527 1.1 elric #ifndef HAVE_GETDTABLESIZE
528 1.1 elric #define getdtablesize rk_getdtablesize
529 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL getdtablesize(void);
530 1.1 elric #endif
531 1.1 elric
532 1.1 elric #if !defined(HAVE_STRERROR) && !defined(strerror)
533 1.1 elric #define strerror rk_strerror
534 1.1 elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strerror(int);
535 1.1 elric #endif
536 1.1 elric
537 1.1 elric #if (!defined(HAVE_STRERROR_R) && !defined(strerror_r)) || (!defined(STRERROR_R_PROTO_COMPATIBLE) && defined(HAVE_STRERROR_R))
538 1.1 elric int ROKEN_LIB_FUNCTION rk_strerror_r(int, char *, size_t);
539 1.1 elric #else
540 1.1 elric #define rk_strerror_r strerror_r
541 1.1 elric #endif
542 1.1 elric
543 1.1 elric #if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO)
544 1.1 elric #ifndef HAVE_HSTRERROR
545 1.1 elric #define hstrerror rk_hstrerror
546 1.1 elric #endif
547 1.1 elric /* This causes a fatal error under Psoriasis */
548 1.1 elric #ifndef SunOS
549 1.1 elric ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL hstrerror(int);
550 1.1 elric #endif
551 1.1 elric #endif
552 1.1 elric
553 1.1 elric #if !HAVE_DECL_H_ERRNO
554 1.1 elric extern int h_errno;
555 1.1 elric #endif
556 1.1 elric
557 1.1 elric #if !defined(HAVE_INET_ATON) || defined(NEED_INET_ATON_PROTO)
558 1.1 elric #ifndef HAVE_INET_ATON
559 1.1 elric #define inet_aton rk_inet_aton
560 1.1 elric #endif
561 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL inet_aton(const char *, struct in_addr *);
562 1.1 elric #endif
563 1.1 elric
564 1.1 elric #ifndef HAVE_INET_NTOP
565 1.1 elric #define inet_ntop rk_inet_ntop
566 1.1 elric ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
567 1.1 elric inet_ntop(int af, const void *src, char *dst, size_t size);
568 1.1 elric #endif
569 1.1 elric
570 1.1 elric #ifndef HAVE_INET_PTON
571 1.1 elric #define inet_pton rk_inet_pton
572 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
573 1.1 elric inet_pton(int, const char *, void *);
574 1.1 elric #endif
575 1.1 elric
576 1.1 elric #ifndef HAVE_GETCWD
577 1.1 elric #define getcwd rk_getcwd
578 1.1 elric ROKEN_LIB_FUNCTION char* ROKEN_LIB_CALL getcwd(char *, size_t);
579 1.1 elric #endif
580 1.1 elric
581 1.1 elric #ifdef HAVE_PWD_H
582 1.1 elric #include <pwd.h>
583 1.1 elric ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwnam (const char *);
584 1.1 elric ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwuid (uid_t);
585 1.1 elric #endif
586 1.1 elric
587 1.1 elric ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL get_default_username (void);
588 1.1 elric
589 1.1 elric #ifndef HAVE_SETEUID
590 1.1 elric #define seteuid rk_seteuid
591 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL seteuid(uid_t);
592 1.1 elric #endif
593 1.1 elric
594 1.1 elric #ifndef HAVE_SETEGID
595 1.1 elric #define setegid rk_setegid
596 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setegid(gid_t);
597 1.1 elric #endif
598 1.1 elric
599 1.1 elric #ifndef HAVE_LSTAT
600 1.1 elric #define lstat rk_lstat
601 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL lstat(const char *, struct stat *);
602 1.1 elric #endif
603 1.1 elric
604 1.1 elric #if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO)
605 1.1 elric #ifndef HAVE_MKSTEMP
606 1.1 elric #define mkstemp rk_mkstemp
607 1.1 elric #endif
608 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL mkstemp(char *);
609 1.1 elric #endif
610 1.1 elric
611 1.1 elric #ifndef HAVE_CGETENT
612 1.1 elric #define cgetent rk_cgetent
613 1.1 elric #define cgetstr rk_cgetstr
614 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetent(char **, char **, const char *);
615 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetstr(char *, const char *, char **);
616 1.1 elric #endif
617 1.1 elric
618 1.1 elric #ifndef HAVE_INITGROUPS
619 1.1 elric #define initgroups rk_initgroups
620 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL initgroups(const char *, gid_t);
621 1.1 elric #endif
622 1.1 elric
623 1.1 elric #ifndef HAVE_FCHOWN
624 1.1 elric #define fchown rk_fchown
625 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fchown(int, uid_t, gid_t);
626 1.1 elric #endif
627 1.1 elric
628 1.1 elric #ifdef RENAME_DOES_NOT_UNLINK
629 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_rename(const char *, const char *);
630 1.1 elric #else
631 1.1 elric #define rk_rename(__rk_rn_from,__rk_rn_to) rename(__rk_rn_from,__rk_rn_to)
632 1.1 elric #endif
633 1.1 elric
634 1.1 elric #if !defined(HAVE_DAEMON) || defined(NEED_DAEMON_PROTO)
635 1.1 elric #ifndef HAVE_DAEMON
636 1.1 elric #define daemon rk_daemon
637 1.1 elric #endif
638 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL daemon(int, int);
639 1.1 elric #endif
640 1.1 elric
641 1.1 elric #ifndef HAVE_CHOWN
642 1.1 elric #define chown rk_chown
643 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL chown(const char *, uid_t, gid_t);
644 1.1 elric #endif
645 1.1 elric
646 1.1 elric #ifndef HAVE_RCMD
647 1.1 elric #define rcmd rk_rcmd
648 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
649 1.1 elric rcmd(char **, unsigned short, const char *,
650 1.1 elric const char *, const char *, int *);
651 1.1 elric #endif
652 1.1 elric
653 1.1 elric #if !defined(HAVE_INNETGR) || defined(NEED_INNETGR_PROTO)
654 1.1 elric #ifndef HAVE_INNETGR
655 1.1 elric #define innetgr rk_innetgr
656 1.1 elric #endif
657 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL innetgr(const char*, const char*,
658 1.1 elric const char*, const char*);
659 1.1 elric #endif
660 1.1 elric
661 1.1 elric #ifndef HAVE_IRUSEROK
662 1.1 elric #define iruserok rk_iruserok
663 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL iruserok(unsigned, int,
664 1.1 elric const char *, const char *);
665 1.1 elric #endif
666 1.1 elric
667 1.1 elric #if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO)
668 1.1 elric #ifndef HAVE_GETHOSTNAME
669 1.1 elric #define gethostname rk_gethostname
670 1.1 elric #endif
671 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL gethostname(char *, int);
672 1.1 elric #endif
673 1.1 elric
674 1.1 elric #ifndef HAVE_WRITEV
675 1.1 elric #define writev rk_writev
676 1.1 elric ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
677 1.1 elric writev(int, const struct iovec *, int);
678 1.1 elric #endif
679 1.1 elric
680 1.1 elric #ifndef HAVE_READV
681 1.1 elric #define readv rk_readv
682 1.1 elric ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
683 1.1 elric readv(int, const struct iovec *, int);
684 1.1 elric #endif
685 1.1 elric
686 1.1 elric #ifndef HAVE_PIDFILE
687 1.1 elric #ifdef NO_PIDFILES
688 1.1 elric #define pidfile(x) ((void) 0)
689 1.1 elric #else
690 1.1 elric #define pidfile rk_pidfile
691 1.1 elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL pidfile (const char*);
692 1.1 elric #endif
693 1.1 elric #endif
694 1.1 elric
695 1.1 elric #ifndef HAVE_BSWAP32
696 1.1 elric #define bswap32 rk_bswap32
697 1.1 elric ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL bswap32(unsigned int);
698 1.1 elric #endif
699 1.1 elric
700 1.1 elric #ifndef HAVE_BSWAP16
701 1.1 elric #define bswap16 rk_bswap16
702 1.1 elric ROKEN_LIB_FUNCTION unsigned short ROKEN_LIB_CALL bswap16(unsigned short);
703 1.1 elric #endif
704 1.1 elric
705 1.1 elric #ifndef HAVE_FLOCK
706 1.1 elric #ifndef LOCK_SH
707 1.1 elric #define LOCK_SH 1 /* Shared lock */
708 1.1 elric #endif
709 1.1 elric #ifndef LOCK_EX
710 1.1 elric #define LOCK_EX 2 /* Exclusive lock */
711 1.1 elric #endif
712 1.1 elric #ifndef LOCK_NB
713 1.1 elric #define LOCK_NB 4 /* Don't block when locking */
714 1.1 elric #endif
715 1.1 elric #ifndef LOCK_UN
716 1.1 elric #define LOCK_UN 8 /* Unlock */
717 1.1 elric #endif
718 1.1 elric
719 1.1 elric #define flock(_x,_y) rk_flock(_x,_y)
720 1.1 elric int rk_flock(int fd, int operation);
721 1.1 elric #endif /* HAVE_FLOCK */
722 1.1 elric
723 1.1 elric #ifndef HAVE_DIRFD
724 1.1 elric #ifdef HAVE_DIR_DD_FD
725 1.1 elric #define dirfd(x) ((x)->dd_fd)
726 1.1 elric #else
727 1.1 elric #ifndef _WIN32 /* Windows code never calls dirfd */
728 1.1 elric #error Missing dirfd() and ->dd_fd
729 1.1 elric #endif
730 1.1 elric #endif
731 1.1 elric #endif
732 1.1 elric
733 1.1 elric ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL tm2time (struct tm, int);
734 1.1 elric
735 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL unix_verify_user(char *, char *);
736 1.1 elric
737 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_concat (char *, size_t, ...);
738 1.1 elric
739 1.1 elric ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL roken_mconcat (char **, size_t, ...);
740 1.1 elric
741 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_vconcat (char *, size_t, va_list);
742 1.1 elric
743 1.1 elric ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
744 1.1 elric roken_vmconcat (char **, size_t, va_list);
745 1.1 elric
746 1.1 elric ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
747 1.1 elric net_write (rk_socket_t, const void *, size_t);
748 1.1 elric
749 1.1 elric ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
750 1.1 elric net_read (rk_socket_t, void *, size_t);
751 1.1 elric
752 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
753 1.1 elric issuid(void);
754 1.1 elric
755 1.1 elric #ifndef HAVE_STRUCT_WINSIZE
756 1.1 elric struct winsize {
757 1.1 elric unsigned short ws_row, ws_col;
758 1.1 elric unsigned short ws_xpixel, ws_ypixel;
759 1.1 elric };
760 1.1 elric #endif
761 1.1 elric
762 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL get_window_size(int fd, struct winsize *);
763 1.1 elric
764 1.1 elric #ifndef HAVE_VSYSLOG
765 1.1 elric #define vsyslog rk_vsyslog
766 1.1 elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL vsyslog(int, const char *, va_list);
767 1.1 elric #endif
768 1.1 elric
769 1.1 elric #ifndef HAVE_GETOPT
770 1.1 elric #define getopt rk_getopt
771 1.1 elric #define optarg rk_optarg
772 1.1 elric #define optind rk_optind
773 1.1 elric #define opterr rk_opterr
774 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
775 1.1 elric getopt(int nargc, char * const *nargv, const char *ostr);
776 1.1 elric #endif
777 1.1 elric
778 1.1 elric #if !HAVE_DECL_OPTARG
779 1.1 elric ROKEN_LIB_VARIABLE extern char *optarg;
780 1.1 elric #endif
781 1.1 elric #if !HAVE_DECL_OPTIND
782 1.1 elric ROKEN_LIB_VARIABLE extern int optind;
783 1.1 elric #endif
784 1.1 elric #if !HAVE_DECL_OPTERR
785 1.1 elric ROKEN_LIB_VARIABLE extern int opterr;
786 1.1 elric #endif
787 1.1 elric
788 1.1 elric #ifndef HAVE_GETIPNODEBYNAME
789 1.1 elric #define getipnodebyname rk_getipnodebyname
790 1.1 elric ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
791 1.1 elric getipnodebyname (const char *, int, int, int *);
792 1.1 elric #endif
793 1.1 elric
794 1.1 elric #ifndef HAVE_GETIPNODEBYADDR
795 1.1 elric #define getipnodebyaddr rk_getipnodebyaddr
796 1.1 elric ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
797 1.1 elric getipnodebyaddr (const void *, size_t, int, int *);
798 1.1 elric #endif
799 1.1 elric
800 1.1 elric #ifndef HAVE_FREEHOSTENT
801 1.1 elric #define freehostent rk_freehostent
802 1.1 elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
803 1.1 elric freehostent (struct hostent *);
804 1.1 elric #endif
805 1.1 elric
806 1.1 elric #ifndef HAVE_COPYHOSTENT
807 1.1 elric #define copyhostent rk_copyhostent
808 1.1 elric ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
809 1.1 elric copyhostent (const struct hostent *);
810 1.1 elric #endif
811 1.1 elric
812 1.1 elric #ifndef HAVE_SOCKLEN_T
813 1.1 elric typedef int socklen_t;
814 1.1 elric #endif
815 1.1 elric
816 1.1 elric #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
817 1.1 elric
818 1.1 elric #ifndef HAVE_SA_FAMILY_T
819 1.1 elric typedef unsigned short sa_family_t;
820 1.1 elric #endif
821 1.1 elric
822 1.1 elric #ifdef HAVE_IPV6
823 1.1 elric #define _SS_MAXSIZE sizeof(struct sockaddr_in6)
824 1.1 elric #else
825 1.1 elric #define _SS_MAXSIZE sizeof(struct sockaddr_in)
826 1.1 elric #endif
827 1.1 elric
828 1.1 elric #define _SS_ALIGNSIZE sizeof(unsigned long)
829 1.1 elric
830 1.1 elric #if HAVE_STRUCT_SOCKADDR_SA_LEN
831 1.1 elric
832 1.1 elric typedef unsigned char roken_sa_family_t;
833 1.1 elric
834 1.1 elric #define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t) - sizeof(unsigned char)) % _SS_ALIGNSIZE)
835 1.1 elric #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + sizeof(unsigned char) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
836 1.1 elric
837 1.1 elric struct sockaddr_storage {
838 1.1 elric unsigned char ss_len;
839 1.1 elric roken_sa_family_t ss_family;
840 1.1 elric char __ss_pad1[_SS_PAD1SIZE];
841 1.1 elric unsigned long __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1];
842 1.1 elric };
843 1.1 elric
844 1.1 elric #else /* !HAVE_STRUCT_SOCKADDR_SA_LEN */
845 1.1 elric
846 1.1 elric typedef unsigned short roken_sa_family_t;
847 1.1 elric
848 1.1 elric #define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t)) % _SS_ALIGNSIZE)
849 1.1 elric #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
850 1.1 elric
851 1.1 elric struct sockaddr_storage {
852 1.1 elric roken_sa_family_t ss_family;
853 1.1 elric char __ss_pad1[_SS_PAD1SIZE];
854 1.1 elric unsigned long __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1];
855 1.1 elric };
856 1.1 elric
857 1.1 elric #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
858 1.1 elric
859 1.1 elric #endif /* HAVE_STRUCT_SOCKADDR_STORAGE */
860 1.1 elric
861 1.1 elric #ifndef HAVE_STRUCT_ADDRINFO
862 1.1 elric struct addrinfo {
863 1.1 elric int ai_flags;
864 1.1 elric int ai_family;
865 1.1 elric int ai_socktype;
866 1.1 elric int ai_protocol;
867 1.1 elric size_t ai_addrlen;
868 1.1 elric char *ai_canonname;
869 1.1 elric struct sockaddr *ai_addr;
870 1.1 elric struct addrinfo *ai_next;
871 1.1 elric };
872 1.1 elric #endif
873 1.1 elric
874 1.1 elric #ifndef HAVE_GETADDRINFO
875 1.1 elric #define getaddrinfo rk_getaddrinfo
876 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
877 1.1 elric getaddrinfo(const char *,
878 1.1 elric const char *,
879 1.1 elric const struct addrinfo *,
880 1.1 elric struct addrinfo **);
881 1.1 elric #endif
882 1.1 elric
883 1.1 elric #ifndef HAVE_GETNAMEINFO
884 1.1 elric #define getnameinfo rk_getnameinfo
885 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
886 1.1 elric getnameinfo(const struct sockaddr *, socklen_t,
887 1.1 elric char *, size_t,
888 1.1 elric char *, size_t,
889 1.1 elric int);
890 1.1 elric #endif
891 1.1 elric
892 1.1 elric #ifndef HAVE_FREEADDRINFO
893 1.1 elric #define freeaddrinfo rk_freeaddrinfo
894 1.1 elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
895 1.1 elric freeaddrinfo(struct addrinfo *);
896 1.1 elric #endif
897 1.1 elric
898 1.1 elric #ifndef HAVE_GAI_STRERROR
899 1.1 elric #define gai_strerror rk_gai_strerror
900 1.1 elric ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
901 1.1 elric gai_strerror(int);
902 1.1 elric #endif
903 1.1 elric
904 1.1 elric #ifdef NO_SLEEP
905 1.1 elric
906 1.1 elric ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
907 1.1 elric sleep(unsigned int seconds);
908 1.1 elric
909 1.1 elric #endif
910 1.1 elric
911 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
912 1.1 elric getnameinfo_verified(const struct sockaddr *, socklen_t,
913 1.1 elric char *, size_t,
914 1.1 elric char *, size_t,
915 1.1 elric int);
916 1.1 elric
917 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
918 1.1 elric roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **);
919 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
920 1.1 elric roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **);
921 1.1 elric
922 1.1 elric #ifndef HAVE_STRFTIME
923 1.1 elric #define strftime rk_strftime
924 1.1 elric ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
925 1.1 elric strftime (char *, size_t, const char *, const struct tm *);
926 1.1 elric #endif
927 1.1 elric
928 1.1 elric #ifndef HAVE_STRPTIME
929 1.1 elric #define strptime rk_strptime
930 1.1 elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
931 1.1 elric strptime (const char *, const char *, struct tm *);
932 1.1 elric #endif
933 1.1 elric
934 1.1 elric #ifndef HAVE_GETTIMEOFDAY
935 1.1 elric #define gettimeofday rk_gettimeofday
936 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
937 1.1 elric gettimeofday (struct timeval *, void *);
938 1.1 elric #endif
939 1.1 elric
940 1.1 elric #ifndef HAVE_EMALLOC
941 1.1 elric #define emalloc rk_emalloc
942 1.1 elric ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL emalloc (size_t);
943 1.1 elric #endif
944 1.1 elric #ifndef HAVE_ECALLOC
945 1.1 elric #define ecalloc rk_ecalloc
946 1.1 elric ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL ecalloc(size_t, size_t);
947 1.1 elric #endif
948 1.1 elric #ifndef HAVE_EREALLOC
949 1.1 elric #define erealloc rk_erealloc
950 1.1 elric ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL erealloc (void *, size_t);
951 1.1 elric #endif
952 1.1 elric #ifndef HAVE_ESTRDUP
953 1.1 elric #define estrdup rk_estrdup
954 1.1 elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL estrdup (const char *);
955 1.1 elric #endif
956 1.1 elric
957 1.1 elric /*
958 1.1 elric * kludges and such
959 1.1 elric */
960 1.1 elric
961 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
962 1.1 elric roken_gethostby_setup(const char*, const char*);
963 1.1 elric ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
964 1.1 elric roken_gethostbyname(const char*);
965 1.1 elric ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
966 1.1 elric roken_gethostbyaddr(const void*, size_t, int);
967 1.1 elric
968 1.1 elric #ifdef GETSERVBYNAME_PROTO_COMPATIBLE
969 1.1 elric #define roken_getservbyname(x,y) getservbyname(x,y)
970 1.1 elric #else
971 1.1 elric #define roken_getservbyname(x,y) getservbyname((char *)x, (char *)y)
972 1.1 elric #endif
973 1.1 elric
974 1.1 elric #ifdef OPENLOG_PROTO_COMPATIBLE
975 1.1 elric #define roken_openlog(a,b,c) openlog(a,b,c)
976 1.1 elric #else
977 1.1 elric #define roken_openlog(a,b,c) openlog((char *)a,b,c)
978 1.1 elric #endif
979 1.1 elric
980 1.1 elric #ifdef GETSOCKNAME_PROTO_COMPATIBLE
981 1.1 elric #define roken_getsockname(a,b,c) getsockname(a,b,c)
982 1.1 elric #else
983 1.1 elric #define roken_getsockname(a,b,c) getsockname(a, b, (void*)c)
984 1.1 elric #endif
985 1.1 elric
986 1.1 elric #ifndef HAVE_SETPROGNAME
987 1.1 elric #define setprogname rk_setprogname
988 1.1 elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL setprogname(const char *);
989 1.1 elric #endif
990 1.1 elric
991 1.1 elric #ifndef HAVE_GETPROGNAME
992 1.1 elric #define getprogname rk_getprogname
993 1.1 elric ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL getprogname(void);
994 1.1 elric #endif
995 1.1 elric
996 1.1 elric #if !defined(HAVE_SETPROGNAME) && !defined(HAVE_GETPROGNAME) && !HAVE_DECL___PROGNAME
997 1.1 elric extern const char *__progname;
998 1.1 elric #endif
999 1.1 elric
1000 1.1 elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
1001 1.1 elric mini_inetd_addrinfo (struct addrinfo*, rk_socket_t *);
1002 1.1 elric
1003 1.1 elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
1004 1.1 elric mini_inetd (int, rk_socket_t *);
1005 1.1 elric
1006 1.1 elric #ifndef HAVE_LOCALTIME_R
1007 1.1 elric #define localtime_r rk_localtime_r
1008 1.1 elric ROKEN_LIB_FUNCTION struct tm * ROKEN_LIB_CALL
1009 1.1 elric localtime_r(const time_t *, struct tm *);
1010 1.1 elric #endif
1011 1.1 elric
1012 1.1 elric #if !defined(HAVE_STRSVIS) || defined(NEED_STRSVIS_PROTO)
1013 1.1 elric #ifndef HAVE_STRSVIS
1014 1.1 elric #define strsvis rk_strsvis
1015 1.1 elric #endif
1016 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1017 1.1 elric strsvis(char *, const char *, int, const char *);
1018 1.1 elric #endif
1019 1.1 elric
1020 1.1 elric #if !defined(HAVE_STRSVISX) || defined(NEED_STRSVISX_PROTO)
1021 1.1 elric #ifndef HAVE_STRSVISX
1022 1.1 elric #define strsvisx rk_strsvisx
1023 1.1 elric #endif
1024 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1025 1.1 elric strsvisx(char *, const char *, size_t, int, const char *);
1026 1.1 elric #endif
1027 1.1 elric
1028 1.1 elric #if !defined(HAVE_STRUNVIS) || defined(NEED_STRUNVIS_PROTO)
1029 1.1 elric #ifndef HAVE_STRUNVIS
1030 1.1 elric #define strunvis rk_strunvis
1031 1.1 elric #endif
1032 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1033 1.1 elric strunvis(char *, const char *);
1034 1.1 elric #endif
1035 1.1 elric
1036 1.1 elric #if !defined(HAVE_STRVIS) || defined(NEED_STRVIS_PROTO)
1037 1.1 elric #ifndef HAVE_STRVIS
1038 1.1 elric #define strvis rk_strvis
1039 1.1 elric #endif
1040 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1041 1.1 elric strvis(char *, const char *, int);
1042 1.1 elric #endif
1043 1.1 elric
1044 1.1 elric #if !defined(HAVE_STRVISX) || defined(NEED_STRVISX_PROTO)
1045 1.1 elric #ifndef HAVE_STRVISX
1046 1.1 elric #define strvisx rk_strvisx
1047 1.1 elric #endif
1048 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1049 1.1 elric strvisx(char *, const char *, size_t, int);
1050 1.1 elric #endif
1051 1.1 elric
1052 1.1 elric #if !defined(HAVE_SVIS) || defined(NEED_SVIS_PROTO)
1053 1.1 elric #ifndef HAVE_SVIS
1054 1.1 elric #define svis rk_svis
1055 1.1 elric #endif
1056 1.1 elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
1057 1.1 elric svis(char *, int, int, int, const char *);
1058 1.1 elric #endif
1059 1.1 elric
1060 1.1 elric #if !defined(HAVE_UNVIS) || defined(NEED_UNVIS_PROTO)
1061 1.1 elric #ifndef HAVE_UNVIS
1062 1.1 elric #define unvis rk_unvis
1063 1.1 elric #endif
1064 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1065 1.1 elric unvis(char *, int, int *, int);
1066 1.1 elric #endif
1067 1.1 elric
1068 1.1 elric #if !defined(HAVE_VIS) || defined(NEED_VIS_PROTO)
1069 1.1 elric #ifndef HAVE_VIS
1070 1.1 elric #define vis rk_vis
1071 1.1 elric #endif
1072 1.1 elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
1073 1.1 elric vis(char *, int, int, int);
1074 1.1 elric #endif
1075 1.1 elric
1076 1.1 elric #if !defined(HAVE_CLOSEFROM)
1077 1.1 elric #define closefrom rk_closefrom
1078 1.1 elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1079 1.1 elric closefrom(int);
1080 1.1 elric #endif
1081 1.1 elric
1082 1.1 elric #if !defined(HAVE_TIMEGM)
1083 1.1 elric #define timegm rk_timegm
1084 1.1 elric ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL
1085 1.1 elric rk_timegm(struct tm *tm);
1086 1.1 elric #endif
1087 1.1 elric
1088 1.1 elric #ifdef NEED_QSORT
1089 1.1 elric #define qsort rk_qsort
1090 1.1 elric void
1091 1.1 elric rk_qsort(void *, size_t, size_t, int (*)(const void *, const void *));
1092 1.1 elric #endif
1093 1.1 elric
1094 1.1 elric #if defined(HAVE_ARC4RANDOM)
1095 1.1 elric #define rk_random() arc4random()
1096 1.1 elric #elif defined(HAVE_RANDOM)
1097 1.1 elric #define rk_random() random()
1098 1.1 elric #else
1099 1.1 elric #define rk_random() rand()
1100 1.1 elric #endif
1101 1.1 elric
1102 1.1 elric #ifndef HAVE_TDELETE
1103 1.1 elric #define tdelete(a,b,c) rk_tdelete(a,b,c)
1104 1.1 elric #endif
1105 1.1 elric #ifndef HAVE_TFIND
1106 1.1 elric #define tfind(a,b,c) rk_tfind(a,b,c)
1107 1.1 elric #endif
1108 1.1 elric #ifndef HAVE_TSEARCH
1109 1.1 elric #define tsearch(a,b,c) rk_tsearch(a,b,c)
1110 1.1 elric #endif
1111 1.1 elric #ifndef HAVE_TWALK
1112 1.1 elric #define twalk(a,b) rk_twalk(a,b)
1113 1.1 elric #endif
1114 1.1 elric
1115 1.1 elric #if defined(__linux__) && defined(SOCK_CLOEXEC) && !defined(SOCKET_WRAPPER_REPLACE) && !defined(__SOCKET_WRAPPER_H__)
1116 1.1 elric #undef socket
1117 1.1 elric #define socket(_fam,_type,_prot) rk_socket(_fam,_type,_prot)
1118 1.1 elric int ROKEN_LIB_FUNCTION rk_socket(int, int, int);
1119 1.1 elric #endif
1120 1.1 elric
1121 1.1 elric #ifdef SOCKET_WRAPPER_REPLACE
1122 1.1 elric #include <socket_wrapper.h>
1123 1.1 elric #endif
1124 1.1 elric
1125 1.1 elric ROKEN_CPP_END
1126