2 * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the Kungliga Tekniska
20 * Högskolan and its contributors.
22 * 4. Neither the name of the Institute nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49 #ifdef HAVE_SYS_TYPES_H
50 #include <sys/types.h>
55 #ifdef HAVE_SYS_SOCKET_H
56 #include <sys/socket.h>
64 #ifdef HAVE_SYS_STAT_H
67 #ifdef HAVE_NETINET_IN_H
68 #include <netinet/in.h>
70 #ifdef HAVE_NETINET_IN6_H
71 #include <netinet/in6.h>
73 #ifdef HAVE_NETINET6_IN6_H
74 #include <netinet6/in6.h>
93 #if defined(HAVE_SYS_IOCTL_H) && SunOS != 4
94 #include <sys/ioctl.h>
97 #if !defined(HAVE_SETSID) && defined(HAVE__SETSID)
98 #define setsid _setsid
102 int putenv(const char *string
);
106 int setenv(const char *var
, const char *val
, int rewrite
);
109 #ifndef HAVE_UNSETENV
110 void unsetenv(const char *name
);
113 #if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO)
114 char *getusershell(void);
117 #if !defined(__GNUC__) && !defined(__attribute__)
118 #define __attribute__(x)
121 #ifndef HAVE_SNPRINTF
122 int snprintf (char *str
, size_t sz
, const char *format
, ...)
123 __attribute__ ((format (printf
, 3, 4)));
126 #ifndef HAVE_VSNPRINTF
127 int vsnprintf (char *str
, size_t sz
, const char *format
, va_list ap
)
128 __attribute__((format (printf
, 3, 0)));
131 #ifndef HAVE_ASPRINTF
132 int asprintf (char **ret
, const char *format
, ...)
133 __attribute__ ((format (printf
, 2, 3)));
136 #ifndef HAVE_VASPRINTF
137 int vasprintf (char **ret
, const char *format
, va_list ap
)
138 __attribute__((format (printf
, 2, 0)));
141 #ifndef HAVE_ASNPRINTF
142 int asnprintf (char **ret
, size_t max_sz
, const char *format
, ...)
143 __attribute__ ((format (printf
, 3, 4)));
146 #ifndef HAVE_VASNPRINTF
147 int vasnprintf (char **ret
, size_t max_sz
, const char *format
, va_list ap
)
148 __attribute__((format (printf
, 3, 0)));
152 char * strdup(const char *old
);
156 char * strlwr(char *);
160 int strnlen(char*, int);
164 char *strsep(char**, const char*);
167 #ifdef NEED_FCLOSE_PROTO
171 #ifdef NEED_STRTOK_R_PROTO
172 char *strtok_r(char *s1
, const char *s2
, char **lasts
);
176 char * strupr(char *);
179 #ifndef HAVE_GETDTABLESIZE
180 int getdtablesize(void);
183 #if IRIX != 4 /* fix for compiler bug */
185 typedef RETSIGTYPE (*SigAction
)(/* int??? */);
186 SigAction
signal(int iSig
, SigAction pAction
); /* BSD compatible */
191 #define SIG_ERR ((RETSIGTYPE (*)())-1)
194 #if !defined(HAVE_STRERROR) && !defined(strerror)
195 char *strerror(int eno
);
198 #if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO)
199 char *hstrerror(int herr
);
202 #ifndef HAVE_H_ERRNO_DECLARATION
206 #ifndef HAVE_INET_ATON
207 /* Minimal implementation of inet_aton. Doesn't handle hex numbers. */
208 int inet_aton(const char *cp
, struct in_addr
*adr
);
211 #if !defined(HAVE_GETCWD)
212 char* getcwd(char *path
, size_t size
);
217 struct passwd
*k_getpwnam (char *user
);
218 struct passwd
*k_getpwuid (uid_t uid
);
222 int seteuid(uid_t euid
);
226 int setegid(gid_t egid
);
230 int lstat(const char *path
, struct stat
*buf
);
237 #ifndef HAVE_INITGROUPS
238 int initgroups(const char *name
, gid_t basegid
);
242 int fchown(int fd
, uid_t owner
, gid_t group
);
246 int chown(const char *path
, uid_t owner
, gid_t group
);
250 int rcmd(char **ahost
, unsigned short inport
, const char *locuser
,
251 const char *remuser
, const char *cmd
, int *fd2p
);
254 #ifndef HAVE_IRUSEROK
255 int iruserok(u_int32_t raddr
, int superuser
, const char *ruser
,
261 writev(int d
, const struct iovec
*iov
, int iovcnt
);
266 readv(int d
, const struct iovec
*iov
, int iovcnt
);
271 #define LOCK_SH 1 /* Shared lock */
274 #define LOCK_EX 2 /* Exclusive lock */
277 #define LOCK_NB 4 /* Don't block when locking */
280 #define LOCK_UN 8 /* Unlock */
283 int flock(int fd
, int operation
);
284 #endif /* HAVE_FLOCK */
286 #ifdef TIME_WITH_SYS_TIME
287 #include <sys/time.h>
289 #elif defined(HAVE_SYS_TIME_H)
290 #include <sys/time.h>
295 time_t tm2time (struct tm tm
, int local
);
297 int unix_verify_user(char *user
, char *password
);
299 void inaddr2str(struct in_addr addr
, char *s
, size_t len
);
301 void mini_inetd (int port
);
303 #ifndef HAVE_STRUCT_WINSIZE
305 unsigned short ws_row
, ws_col
;
306 unsigned short ws_xpixel
, ws_ypixel
;
310 int get_window_size(int fd
, struct winsize
*);
313 #define INADDR_NONE 0xffffffff
321 #define STDIN_FILENO 0
324 #ifndef STDOUT_FILENO
325 #define STDOUT_FILENO 1
328 #ifndef STDERR_FILENO
329 #define STDERR_FILENO 2
333 #define max(a,b) (((a)>(b))?(a):(b))
337 #define min(a,b) (((a)<(b))?(a):(b))
350 /* Misc definitions for old syslogs */
353 #define openlog(id,option,facility) openlog((id),(option))
360 #define LOG_NDELAY 0x08
369 #define LOG_AUTHPRIV LOG_AUTH
374 void vsyslog(int pri
, const char *fmt
, va_list ap
);
377 #ifndef HAVE_OPTARG_DECLARATION
380 #ifndef HAVE_OPTIND_DECLARATION
383 #ifndef HAVE_OPTERR_DECLARATION
387 #ifndef HAVE___PROGNAME_DECLARATION
388 extern const char *__progname
;
395 #ifdef GETHOSTBYNAME_PROTO_COMPATIBLE
396 #define roken_gethostbyname(x) gethostbyname(x)
398 #define roken_gethostbyname(x) gethostbyname((char *)x)
401 #ifdef GETHOSTBYADDR_PROTO_COMPATIBLE
402 #define roken_gethostbyaddr(a, l, t) gethostbyaddr(a, l, t)
404 #define roken_gethostbyaddr(a, l, t) gethostbyaddr((char *)a, l, t)
407 #ifdef GETSERVBYNAME_PROTO_COMPATIBLE
408 #define roken_getservbyname(x,y) getservbyname(x,y)
410 #define roken_getservbyname(x,y) getservbyname((char *)x, (char *)y)
413 #ifdef OPENLOG_PROTO_COMPATIBLE
414 #define roken_openlog(a,b,c) openlog(a,b,c)
416 #define roken_openlog(a,b,c) openlog((char *)a,b,c)
419 void set_progname(char *argv0
);
426 #define O_ACCMODE 003
433 #ifndef _PATH_DEVNULL
434 #define _PATH_DEVNULL "/dev/null"
438 #define MAXPATHLEN (1024+4)
441 #endif /* __ROKEN_H__ */