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
39 /* $Id: roken.h,v 1.63 1997/05/28 05:38:09 assar Exp $ */
48 #ifdef HAVE_SYS_TYPES_H
49 #include <sys/types.h>
57 #ifdef HAVE_SYS_STAT_H
60 #ifdef HAVE_NETINET_IN_H
61 #include <netinet/in.h>
68 #if defined(HAVE_SYS_IOCTL_H) && SunOS != 4
69 #include <sys/ioctl.h>
74 #if !defined(HAVE_SETSID) && defined(HAVE__SETSID)
75 #define setsid _setsid
79 int putenv(const char *string);
83 int setenv(const char *var, const char *val, int rewrite);
87 void unsetenv(const char *name);
90 #ifndef HAVE_GETUSERSHELL
91 char *getusershell(void);
94 #if !defined(__GNUC__) && !defined(__attribute__)
95 #define __attribute__(x)
99 int snprintf (char *str, size_t sz, const char *format, ...)
100 __attribute__ ((format (printf, 3, 4)));
103 #ifndef HAVE_VSNPRINTF
104 int vsnprintf (char *str, size_t sz, const char *format, va_list ap)
105 __attribute__((format (printf, 3, 0)));
108 #ifndef HAVE_ASPRINTF
109 int asprintf (char **ret, const char *format, ...)
110 __attribute__ ((format (printf, 2, 3)));
113 #ifndef HAVE_VASPRINTF
114 int vasprintf (char **ret, const char *format, va_list ap)
115 __attribute__((format (printf, 2, 0)));
118 #ifndef HAVE_ASNPRINTF
119 int asnprintf (char **ret, size_t max_sz, const char *format, ...)
120 __attribute__ ((format (printf, 3, 4)));
123 #ifndef HAVE_VASNPRINTF
124 int vasnprintf (char **ret, size_t max_sz, const char *format, va_list ap)
125 __attribute__((format (printf, 3, 0)));
129 char * strdup(const char *old);
133 char * strlwr(char *);
137 int strnlen(char*, int);
140 #ifndef HAVE_STRTOK_R
141 char *strtok_r(char *s1, const char *s2, char **lasts);
145 char * strupr(char *);
148 #ifndef HAVE_GETDTABLESIZE
149 int getdtablesize(void);
152 #if IRIX != 4 /* fix for compiler bug */
154 typedef RETSIGTYPE (*SigAction)(/* int??? */);
155 SigAction signal(int iSig, SigAction pAction); /* BSD compatible */
160 #define SIG_ERR ((RETSIGTYPE (*)())-1)
163 #if !defined(HAVE_STRERROR) && !defined(strerror)
164 char *strerror(int eno);
167 #ifndef HAVE_HSTRERROR
168 char *hstrerror(int herr);
171 #ifndef HAVE_H_ERRNO_DECLARATION
175 #ifndef HAVE_INET_ATON
176 /* Minimal implementation of inet_aton. Doesn't handle hex numbers. */
177 int inet_aton(const char *cp, struct in_addr *adr);
180 #if !defined(HAVE_GETCWD)
181 char* getcwd(char *path, size_t size);
185 int getent(char *cp, char *name);
190 struct passwd *k_getpwnam (char *user);
191 struct passwd *k_getpwuid (uid_t uid);
195 int seteuid(int euid);
199 int setegid(int egid);
203 int lstat(const char *path, struct stat *buf);
210 #ifndef HAVE_INITGROUPS
211 int initgroups(const char *name, gid_t basegid);
215 int fchown(int fd, uid_t owner, gid_t group);
219 int chown(const char *path, uid_t owner, gid_t group);
223 int rcmd(char **ahost, unsigned short inport, const char *locuser,
224 const char *remuser, const char *cmd, int *fd2p);
227 #ifdef TIME_WITH_SYS_TIME
228 #include <sys/time.h>
230 #elif defined(HAVE_SYS_TIME_H)
231 #include <sys/time.h>
236 time_t tm2time (struct tm tm, int local);
238 int unix_verify_user(char *user, char *password);
240 void inaddr2str(struct in_addr addr, char *s, size_t len);
242 void mini_inetd (int port);
244 #ifndef HAVE_STRUCT_WINSIZE
246 unsigned short ws_row, ws_col;
247 unsigned short ws_xpixel, ws_ypixel;
251 int get_window_size(int fd, struct winsize *);
254 #define INADDR_NONE 0xffffffff
262 #define STDIN_FILENO 0
265 #ifndef STDOUT_FILENO
266 #define STDOUT_FILENO 1
269 #ifndef STDERR_FILENO
270 #define STDERR_FILENO 2
274 #define max(a,b) (((a)>(b))?(a):(b))
278 #define min(a,b) (((a)<(b))?(a):(b))
291 /* Misc definitions for old syslogs */
294 #define openlog(id,option,facility) openlog((id),(option))
301 #define LOG_NDELAY 0x08
310 #define LOG_AUTHPRIV LOG_AUTH
314 #ifndef HAVE_OPTARG_DECLARATION
317 #ifndef HAVE_OPTIND_DECLARATION
320 #ifndef HAVE_OPTERR_DECLARATION
324 #ifndef HAVE___PROGNAME_DECLARATION
325 extern const char *__progname;
328 void set_progname(char *argv0);
334 #ifndef _PATH_DEVNULL
335 #define _PATH_DEVNULL "/dev/null"
338 #endif /* __ROKEN_H__ */