1/* This is an OS dependent, generated file */
2
3
4#ifndef __ROKEN_H__
5#define __ROKEN_H__
6
7/* -*- C -*- */
8/*
9 * Copyright (c) 1995-2005 Kungliga Tekniska Högskolan
10 * (Royal Institute of Technology, Stockholm, Sweden).
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright
18 *    notice, this list of conditions and the following disclaimer.
19 *
20 * 2. Redistributions in binary form must reproduce the above copyright
21 *    notice, this list of conditions and the following disclaimer in the
22 *    documentation and/or other materials provided with the distribution.
23 *
24 * 3. Neither the name of the Institute nor the names of its contributors
25 *    may be used to endorse or promote products derived from this software
26 *    without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 */
40
41#include <stdio.h>
42#include <stdlib.h>
43#include <stdarg.h>
44#include <stdint.h>
45#include <string.h>
46#include <signal.h>
47
48#define ROKEN_LIB_FUNCTION
49#define ROKEN_LIB_CALL
50
51
52typedef int rk_socket_t;
53
54#define rk_closesocket(x) close(x)
55#define rk_SOCK_IOCTL(s,c,a) ioctl((s),(c),(a))
56#define rk_IS_BAD_SOCKET(s) ((s) < 0)
57#define rk_IS_SOCKET_ERROR(rv) ((rv) < 0)
58#define rk_SOCK_ERRNO errno
59#define rk_INVALID_SOCKET (-1)
60
61#define rk_SOCK_INIT() 0
62#define rk_SOCK_EXIT() do { } while(0)
63
64
65
66#define UNREACHABLE(x)
67#define UNUSED_ARGUMENT(x)
68
69
70#include <sys/param.h>
71#include <inttypes.h>
72#include <sys/types.h>
73#include <unistd.h>
74#include <sys/socket.h>
75#include <sys/uio.h>
76#include <grp.h>
77#include <sys/stat.h>
78#include <netinet/in.h>
79#include <arpa/inet.h>
80#include <netdb.h>
81#include <arpa/nameser.h>
82#include <resolv.h>
83#include <syslog.h>
84#include <fcntl.h>
85#include <errno.h>
86#include <err.h>
87#include <termios.h>
88#include <sys/ioctl.h>
89#include <sys/time.h>
90#include <time.h>
91
92
93#include <paths.h>
94
95#include <dirent.h>
96
97
98
99#include <roken-common.h>
100
101ROKEN_CPP_START
102
103#define rk_UNCONST(x) ((void *)(uintptr_t)(const void *)(x))
104
105
106
107
108
109
110
111
112
113
114
115#define asnprintf rk_asnprintf
116ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
117    rk_asnprintf (char **, size_t, const char *, ...)
118     __attribute__ ((format (printf, 3, 4)));
119
120#define vasnprintf rk_vasnprintf
121ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
122    vasnprintf (char **, size_t, const char *, va_list)
123     __attribute__((format (printf, 3, 0)));
124
125
126
127#define strlwr rk_strlwr
128ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strlwr(char *);
129
130
131
132#define strsep_copy rk_strsep_copy
133ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL strsep_copy(const char**, const char*, char*, size_t);
134
135
136
137
138#define strupr rk_strupr
139ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strupr(char *);
140
141
142
143
144
145#define rk_strerror_r strerror_r
146
147
148
149
150
151
152
153#include <pwd.h>
154ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwnam (const char *);
155ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwuid (uid_t);
156
157ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL get_default_username (void);
158
159
160
161
162
163
164
165
166#define daemon rk_daemon
167ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL daemon(int, int);
168
169
170
171
172
173
174
175
176#define pidfile rk_pidfile
177ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL pidfile (const char*);
178
179#define bswap32 rk_bswap32
180ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL bswap32(unsigned int);
181
182#define bswap16 rk_bswap16
183ROKEN_LIB_FUNCTION unsigned short ROKEN_LIB_CALL bswap16(unsigned short);
184
185
186
187ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL tm2time (struct tm, int);
188
189ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL unix_verify_user(char *, char *);
190
191ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_concat (char *, size_t, ...);
192
193ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL roken_mconcat (char **, size_t, ...);
194
195ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_vconcat (char *, size_t, va_list);
196
197ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
198    roken_vmconcat (char **, size_t, va_list);
199
200ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
201    net_write (rk_socket_t, const void *, size_t);
202
203ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
204    net_read (rk_socket_t, void *, size_t);
205
206ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
207    issuid(void);
208
209
210#define copyhostent rk_copyhostent
211ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
212copyhostent (const struct hostent *);
213
214
215
216
217
218
219
220
221
222
223ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
224getnameinfo_verified(const struct sockaddr *, socklen_t,
225		     char *, socklen_t,
226		     char *, socklen_t,
227		     int);
228
229ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
230roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **);
231ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
232roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **);
233
234
235
236
237#define emalloc rk_emalloc
238ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL emalloc (size_t);
239#define ecalloc rk_ecalloc
240ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL ecalloc(size_t, size_t);
241#define erealloc rk_erealloc
242ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL erealloc (void *, size_t);
243#define estrdup rk_estrdup
244ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL estrdup (const char *);
245
246/*
247 * kludges and such
248 */
249
250ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
251roken_gethostby_setup(const char*, const char*);
252ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
253roken_gethostbyname(const char*);
254ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
255roken_gethostbyaddr(const void*, socklen_t, int);
256
257#define roken_getservbyname(x,y) getservbyname(x,y)
258
259#define roken_openlog(a,b,c) openlog(a,b,c)
260
261#define roken_getsockname(a,b,c) getsockname(a,b,c)
262
263
264
265
266ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
267mini_inetd_addrinfo (struct addrinfo*, rk_socket_t *);
268
269ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
270mini_inetd (int, rk_socket_t *);
271
272
273#define strsvis rk_strsvis
274ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
275strsvis(char *, const char *, int, const char *);
276
277#define strsvisx rk_strsvisx
278ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
279strsvisx(char *, const char *, size_t, int, const char *);
280
281
282
283
284#define svis rk_svis
285ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
286svis(char *, int, int, int, const char *);
287
288
289
290#define closefrom rk_closefrom
291ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
292closefrom(int);
293
294
295
296#define rk_random() arc4random()
297#define rk_random_uniform(_n) arc4random_uniform(_n)
298
299
300
301
302ROKEN_CPP_END
303
304#endif /* __ROKEN_H__ */
305