3 * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
4 * (Royal Institute of Technology, Stockholm, Sweden).
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
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.
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.
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
35 /* $Id: roken.h.in,v 1.125.2.4 2000/03/12 20:32:51 assar Exp $ */
42 #ifdef HAVE_SYS_PARAM_H
43 #include <sys/param.h>
45 #ifdef HAVE_SYS_TYPES_H
46 #include <sys/types.h>
51 #ifdef HAVE_SYS_SOCKET_H
52 #include <sys/socket.h>
60 #ifdef HAVE_SYS_STAT_H
63 #ifdef HAVE_NETINET_IN_H
64 #include <netinet/in.h>
66 #ifdef HAVE_NETINET_IN6_H
67 #include <netinet/in6.h>
69 #ifdef HAVE_NETINET6_IN6_H
70 #include <netinet6/in6.h>
72 #ifdef HAVE_ARPA_INET_H
73 #include <arpa/inet.h>
96 #if defined(HAVE_SYS_IOCTL_H) && SunOS != 40
97 #include <sys/ioctl.h>
99 #ifdef TIME_WITH_SYS_TIME
100 #include <sys/time.h>
102 #elif defined(HAVE_SYS_TIME_H)
103 #include <sys/time.h>
116 #ifndef ROKEN_LIB_FUNCTION
117 #if defined(__BORLANDC__)
118 #define ROKEN_LIB_FUNCTION /* not-ready-definition-yet */
119 #elif defined(_MSC_VER)
120 #define ROKEN_LIB_FUNCTION /* not-ready-definition-yet2 */
122 #define ROKEN_LIB_FUNCTION
126 #include <roken-common.h>
128 #if !defined(HAVE_SETSID) && defined(HAVE__SETSID)
129 #define setsid _setsid
133 int putenv(const char *string);
136 #if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO)
137 int setenv(const char *var, const char *val, int rewrite);
140 #if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO)
141 void unsetenv(const char *name);
144 #if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO)
145 char *getusershell(void);
146 void endusershell(void);
149 #if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO)
150 int snprintf (char *str, size_t sz, const char *format, ...)
151 __attribute__ ((format (printf, 3, 4)));
154 #if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO)
155 int vsnprintf (char *str, size_t sz, const char *format, va_list ap)
156 __attribute__((format (printf, 3, 0)));
159 #if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO)
160 int asprintf (char **ret, const char *format, ...)
161 __attribute__ ((format (printf, 2, 3)));
164 #if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO)
165 int vasprintf (char **ret, const char *format, va_list ap)
166 __attribute__((format (printf, 2, 0)));
169 #if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO)
170 int asnprintf (char **ret, size_t max_sz, const char *format, ...)
171 __attribute__ ((format (printf, 3, 4)));
174 #if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO)
175 int vasnprintf (char **ret, size_t max_sz, const char *format, va_list ap)
176 __attribute__((format (printf, 3, 0)));
180 char * strdup(const char *old);
184 char * strndup(const char *old, size_t sz);
188 char * strlwr(char *);
192 size_t strnlen(const char*, size_t);
195 #if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO)
196 char *strsep(char**, const char*);
199 #ifndef HAVE_STRCASECMP
200 int strcasecmp(const char *s1, const char *s2);
203 #ifdef NEED_FCLOSE_PROTO
207 #ifdef NEED_STRTOK_R_PROTO
208 char *strtok_r(char *s1, const char *s2, char **lasts);
212 char * strupr(char *);
216 size_t strlcpy (char *dst, const char *src, size_t dst_sz);
220 size_t strlcat (char *dst, const char *src, size_t dst_sz);
223 #ifndef HAVE_GETDTABLESIZE
224 int getdtablesize(void);
227 #if !defined(HAVE_STRERROR) && !defined(strerror)
228 char *strerror(int eno);
231 #if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO)
232 /* This causes a fatal error under Psoriasis */
233 #if !(defined(SunOS) && (SunOS >= 50))
234 const char *hstrerror(int herr);
238 #ifndef HAVE_H_ERRNO_DECLARATION
242 #if !defined(HAVE_INET_ATON) || defined(NEED_INET_ATON_PROTO)
243 int inet_aton(const char *cp, struct in_addr *adr);
246 #ifndef HAVE_INET_NTOP
248 inet_ntop(int af, const void *src, char *dst, size_t size);
251 #ifndef HAVE_INET_PTON
253 inet_pton(int af, const char *src, void *dst);
256 #if !defined(HAVE_GETCWD)
257 char* getcwd(char *path, size_t size);
262 struct passwd *k_getpwnam (const char *user);
263 struct passwd *k_getpwuid (uid_t uid);
266 const char *get_default_username (void);
269 int seteuid(uid_t euid);
273 int setegid(gid_t egid);
277 int lstat(const char *path, struct stat *buf);
280 #if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO)
285 int cgetent(char **buf, char **db_array, const char *name);
286 int cgetstr(char *buf, const char *cap, char **str);
289 #ifndef HAVE_INITGROUPS
290 int initgroups(const char *name, gid_t basegid);
294 int fchown(int fd, uid_t owner, gid_t group);
298 int daemon(int nochdir, int noclose);
302 int innetgr(const char *netgroup, const char *machine,
303 const char *user, const char *domain);
307 int chown(const char *path, uid_t owner, gid_t group);
311 int rcmd(char **ahost, unsigned short inport, const char *locuser,
312 const char *remuser, const char *cmd, int *fd2p);
315 #if !defined(HAVE_INNETGR) || defined(NEED_INNETGR_PROTO)
316 int innetgr(const char*, const char*, const char*, const char*);
319 #ifndef HAVE_IRUSEROK
320 int iruserok(unsigned raddr, int superuser, const char *ruser,
324 #if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO)
325 int gethostname(char *name, int namelen);
330 writev(int d, const struct iovec *iov, int iovcnt);
335 readv(int d, const struct iovec *iov, int iovcnt);
340 mkstemp(char *template);
345 #define LOCK_SH 1 /* Shared lock */
348 #define LOCK_EX 2 /* Exclusive lock */
351 #define LOCK_NB 4 /* Don't block when locking */
354 #define LOCK_UN 8 /* Unlock */
357 int flock(int fd, int operation);
358 #endif /* HAVE_FLOCK */
360 time_t tm2time (struct tm tm, int local);
362 int unix_verify_user(char *user, char *password);
364 void inaddr2str(struct in_addr addr, char *s, size_t len);
366 void mini_inetd (int port);
368 int roken_concat (char *s, size_t len, ...);
370 size_t roken_mconcat (char **s, size_t max_len, ...);
372 int roken_vconcat (char *s, size_t len, va_list args);
374 size_t roken_vmconcat (char **s, size_t max_len, va_list args);
376 ssize_t net_write (int fd, const void *buf, size_t nbytes);
378 ssize_t net_read (int fd, void *buf, size_t nbytes);
382 #ifndef HAVE_STRUCT_WINSIZE
384 unsigned short ws_row, ws_col;
385 unsigned short ws_xpixel, ws_ypixel;
389 int get_window_size(int fd, struct winsize *);
392 void vsyslog(int pri, const char *fmt, va_list ap);
395 #ifndef HAVE_OPTARG_DECLARATION
398 #ifndef HAVE_OPTIND_DECLARATION
401 #ifndef HAVE_OPTERR_DECLARATION
405 #ifndef HAVE___PROGNAME_DECLARATION
406 extern const char *__progname;
409 #ifndef HAVE_ENVIRON_DECLARATION
410 extern char **environ;
413 #ifndef HAVE_GETIPNODEBYNAME
415 getipnodebyname (const char *name, int af, int flags, int *error_num);
418 #ifndef HAVE_GETIPNODEBYADDR
420 getipnodebyaddr (const void *src, size_t len, int af, int *error_num);
423 #ifndef HAVE_FREEHOSTENT
425 freehostent (struct hostent *h);
428 #ifndef HAVE_COPYHOSTENT
430 copyhostent (const struct hostent *h);
433 #ifndef HAVE_SOCKLEN_T
434 typedef int socklen_t;
437 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
439 #ifndef HAVE_SA_FAMILY_T
440 typedef unsigned short sa_family_t;
444 #define _SS_MAXSIZE sizeof(struct sockaddr_in6)
446 #define _SS_MAXSIZE sizeof(struct sockaddr_in)
449 #define _SS_ALIGNSIZE sizeof(unsigned long)
451 #if HAVE_STRUCT_SOCKADDR_SA_LEN
453 typedef unsigned char roken_sa_family_t;
455 #define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t) - sizeof(unsigned char)) % _SS_ALIGNSIZE)
456 #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + sizeof(unsigned char) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
458 struct sockaddr_storage {
459 unsigned char __ss_len;
460 roken_sa_family_t __ss_family;
461 char __ss_pad1[_SS_PAD1SIZE];
462 unsigned long __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1];
465 #else /* !HAVE_STRUCT_SOCKADDR_SA_LEN */
467 typedef unsigned short roken_sa_family_t;
469 #define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t)) % _SS_ALIGNSIZE)
470 #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
472 struct sockaddr_storage {
473 roken_sa_family_t __ss_family;
474 char __ss_pad1[_SS_PAD1SIZE];
475 unsigned long __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1];
478 #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
480 #endif /* HAVE_STRUCT_SOCKADDR_STORAGE */
487 int roken_gethostby_setup(const char*, const char*);
488 struct hostent* roken_gethostbyname(const char*);
489 struct hostent* roken_gethostbyaddr(const void*, size_t, int);
491 #ifdef GETHOSTBYNAME_PROTO_COMPATIBLE
492 #define roken_gethostbyname(x) gethostbyname(x)
494 #define roken_gethostbyname(x) gethostbyname((char *)x)
497 #ifdef GETHOSTBYADDR_PROTO_COMPATIBLE
498 #define roken_gethostbyaddr(a, l, t) gethostbyaddr(a, l, t)
500 #define roken_gethostbyaddr(a, l, t) gethostbyaddr((char *)a, l, t)
504 #ifdef GETSERVBYNAME_PROTO_COMPATIBLE
505 #define roken_getservbyname(x,y) getservbyname(x,y)
507 #define roken_getservbyname(x,y) getservbyname((char *)x, (char *)y)
510 #ifdef OPENLOG_PROTO_COMPATIBLE
511 #define roken_openlog(a,b,c) openlog(a,b,c)
513 #define roken_openlog(a,b,c) openlog((char *)a,b,c)
516 void set_progname(char *argv0);