iruserok prototype
[heimdal.git] / lib / roken / roken.h.in
blob5addbdf4f8639be0c52cc73944ab11a87196223f
1 /*
2 * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
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
36 * SUCH DAMAGE.
39 /* $Id$ */
41 #ifndef __ROKEN_H__
42 #define __ROKEN_H__
44 #include <stdio.h>
45 #include <stdlib.h>
46 #include <stdarg.h>
47 #include <string.h>
48 #include <signal.h>
49 #ifdef HAVE_SYS_TYPES_H
50 #include <sys/types.h>
51 #endif
52 #ifdef HAVE_UNISTD_H
53 #include <unistd.h>
54 #endif
55 #ifdef HAVE_SYS_SOCKET_H
56 #include <sys/socket.h>
57 #endif
58 #ifdef HAVE_SYS_UIO_H
59 #include <sys/uio.h>
60 #endif
61 #ifdef HAVE_GRP_H
62 #include <grp.h>
63 #endif
64 #ifdef HAVE_SYS_STAT_H
65 #include <sys/stat.h>
66 #endif
67 #ifdef HAVE_NETINET_IN_H
68 #include <netinet/in.h>
69 #endif
70 #ifdef HAVE_NETINET_IN6_H
71 #include <netinet/in6.h>
72 #endif
73 #ifdef HAVE_NETINET6_IN6_H
74 #include <netinet6/in6.h>
75 #endif
76 #ifdef HAVE_WINSOCK_H
77 #include <winsock.h>
78 #endif
81 #ifdef HAVE_FCNTL_H
82 #include <fcntl.h>
83 #endif
85 #ifdef HAVE_ERRNO_H
86 #include <errno.h>
87 #endif
89 #ifdef HAVE_TERMIOS_H
90 #include <termios.h>
91 #endif
93 #if defined(HAVE_SYS_IOCTL_H) && SunOS != 4
94 #include <sys/ioctl.h>
95 #endif
97 #if !defined(HAVE_SETSID) && defined(HAVE__SETSID)
98 #define setsid _setsid
99 #endif
101 #ifndef HAVE_PUTENV
102 int putenv(const char *string);
103 #endif
105 #ifndef HAVE_SETENV
106 int setenv(const char *var, const char *val, int rewrite);
107 #endif
109 #ifndef HAVE_UNSETENV
110 void unsetenv(const char *name);
111 #endif
113 #if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO)
114 char *getusershell(void);
115 #endif
117 #if !defined(__GNUC__) && !defined(__attribute__)
118 #define __attribute__(x)
119 #endif
121 #ifndef HAVE_SNPRINTF
122 int snprintf (char *str, size_t sz, const char *format, ...)
123 __attribute__ ((format (printf, 3, 4)));
124 #endif
126 #ifndef HAVE_VSNPRINTF
127 int vsnprintf (char *str, size_t sz, const char *format, va_list ap)
128 __attribute__((format (printf, 3, 0)));
129 #endif
131 #ifndef HAVE_ASPRINTF
132 int asprintf (char **ret, const char *format, ...)
133 __attribute__ ((format (printf, 2, 3)));
134 #endif
136 #ifndef HAVE_VASPRINTF
137 int vasprintf (char **ret, const char *format, va_list ap)
138 __attribute__((format (printf, 2, 0)));
139 #endif
141 #ifndef HAVE_ASNPRINTF
142 int asnprintf (char **ret, size_t max_sz, const char *format, ...)
143 __attribute__ ((format (printf, 3, 4)));
144 #endif
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)));
149 #endif
151 #ifndef HAVE_STRDUP
152 char * strdup(const char *old);
153 #endif
155 #ifndef HAVE_STRLWR
156 char * strlwr(char *);
157 #endif
159 #ifndef HAVE_STRNLEN
160 int strnlen(char*, int);
161 #endif
163 #ifndef HAVE_STRSEP
164 char *strsep(char**, const char*);
165 #endif
167 #ifdef NEED_FCLOSE_PROTO
168 int fclose(FILE *);
169 #endif
171 #ifdef NEED_STRTOK_R_PROTO
172 char *strtok_r(char *s1, const char *s2, char **lasts);
173 #endif
175 #ifndef HAVE_STRUPR
176 char * strupr(char *);
177 #endif
179 #ifndef HAVE_GETDTABLESIZE
180 int getdtablesize(void);
181 #endif
183 #if IRIX != 4 /* fix for compiler bug */
184 #ifdef RETSIGTYPE
185 typedef RETSIGTYPE (*SigAction)(/* int??? */);
186 SigAction signal(int iSig, SigAction pAction); /* BSD compatible */
187 #endif
188 #endif
190 #ifndef SIG_ERR
191 #define SIG_ERR ((RETSIGTYPE (*)())-1)
192 #endif
194 #if !defined(HAVE_STRERROR) && !defined(strerror)
195 char *strerror(int eno);
196 #endif
198 #if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO)
199 char *hstrerror(int herr);
200 #endif
202 #ifndef HAVE_H_ERRNO_DECLARATION
203 extern int h_errno;
204 #endif
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);
209 #endif
211 #if !defined(HAVE_GETCWD)
212 char* getcwd(char *path, size_t size);
213 #endif
215 #ifdef HAVE_PWD_H
216 #include <pwd.h>
217 struct passwd *k_getpwnam (char *user);
218 struct passwd *k_getpwuid (uid_t uid);
219 #endif
221 #ifndef HAVE_SETEUID
222 int seteuid(uid_t euid);
223 #endif
225 #ifndef HAVE_SETEGID
226 int setegid(gid_t egid);
227 #endif
229 #ifndef HAVE_LSTAT
230 int lstat(const char *path, struct stat *buf);
231 #endif
233 #ifndef HAVE_MKSTEMP
234 int mkstemp(char *);
235 #endif
237 #ifndef HAVE_INITGROUPS
238 int initgroups(const char *name, gid_t basegid);
239 #endif
241 #ifndef HAVE_FCHOWN
242 int fchown(int fd, uid_t owner, gid_t group);
243 #endif
245 #ifndef HAVE_CHOWN
246 int chown(const char *path, uid_t owner, gid_t group);
247 #endif
249 #ifndef HAVE_RCMD
250 int rcmd(char **ahost, unsigned short inport, const char *locuser,
251 const char *remuser, const char *cmd, int *fd2p);
252 #endif
254 #ifndef HAVE_IRUSEROK
255 int iruserok(u_int32_t raddr, int superuser, const char *ruser,
256 const char *luser);
257 #endif
259 #ifndef HAVE_WRITEV
260 ssize_t
261 writev(int d, const struct iovec *iov, int iovcnt);
262 #endif
264 #ifndef HAVE_READV
265 ssize_t
266 readv(int d, const struct iovec *iov, int iovcnt);
267 #endif
269 #ifndef HAVE_FLOCK
270 #ifndef LOCK_SH
271 #define LOCK_SH 1 /* Shared lock */
272 #endif
273 #ifndef LOCK_EX
274 #define LOCK_EX 2 /* Exclusive lock */
275 #endif
276 #ifndef LOCK_NB
277 #define LOCK_NB 4 /* Don't block when locking */
278 #endif
279 #ifndef LOCK_UN
280 #define LOCK_UN 8 /* Unlock */
281 #endif
283 int flock(int fd, int operation);
284 #endif /* HAVE_FLOCK */
286 #ifdef TIME_WITH_SYS_TIME
287 #include <sys/time.h>
288 #include <time.h>
289 #elif defined(HAVE_SYS_TIME_H)
290 #include <sys/time.h>
291 #else
292 #include <time.h>
293 #endif
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
304 struct winsize {
305 unsigned short ws_row, ws_col;
306 unsigned short ws_xpixel, ws_ypixel;
308 #endif
310 int get_window_size(int fd, struct winsize *);
312 #ifndef INADDR_NONE
313 #define INADDR_NONE 0xffffffff
314 #endif
316 #ifndef SOMAXCONN
317 #define SOMAXCONN 5
318 #endif
320 #ifndef STDIN_FILENO
321 #define STDIN_FILENO 0
322 #endif
324 #ifndef STDOUT_FILENO
325 #define STDOUT_FILENO 1
326 #endif
328 #ifndef STDERR_FILENO
329 #define STDERR_FILENO 2
330 #endif
332 #ifndef max
333 #define max(a,b) (((a)>(b))?(a):(b))
334 #endif
336 #ifndef min
337 #define min(a,b) (((a)<(b))?(a):(b))
338 #endif
340 #ifndef TRUE
341 #define TRUE 1
342 #endif
344 #ifndef FALSE
345 #define FALSE 0
346 #endif
348 #ifdef HAVE_SYSLOG_H
349 #include <syslog.h>
350 /* Misc definitions for old syslogs */
352 #ifndef LOG_DAEMON
353 #define openlog(id,option,facility) openlog((id),(option))
354 #define LOG_DAEMON 0
355 #endif
356 #ifndef LOG_ODELAY
357 #define LOG_ODELAY 0
358 #endif
359 #ifndef LOG_NDELAY
360 #define LOG_NDELAY 0x08
361 #endif
362 #ifndef LOG_CONS
363 #define LOG_CONS 0
364 #endif
365 #ifndef LOG_AUTH
366 #define LOG_AUTH 0
367 #endif
368 #ifndef LOG_AUTHPRIV
369 #define LOG_AUTHPRIV LOG_AUTH
370 #endif
371 #endif
373 #ifndef HAVE_VSYSLOG
374 void vsyslog(int pri, const char *fmt, va_list ap);
375 #endif
377 #ifndef HAVE_OPTARG_DECLARATION
378 extern char *optarg;
379 #endif
380 #ifndef HAVE_OPTIND_DECLARATION
381 extern int optind;
382 #endif
383 #ifndef HAVE_OPTERR_DECLARATION
384 extern int opterr;
385 #endif
387 #ifndef HAVE___PROGNAME_DECLARATION
388 extern const char *__progname;
389 #endif
392 * kludges and such
395 #ifdef GETHOSTBYNAME_PROTO_COMPATIBLE
396 #define roken_gethostbyname(x) gethostbyname(x)
397 #else
398 #define roken_gethostbyname(x) gethostbyname((char *)x)
399 #endif
401 #ifdef GETHOSTBYADDR_PROTO_COMPATIBLE
402 #define roken_gethostbyaddr(a, l, t) gethostbyaddr(a, l, t)
403 #else
404 #define roken_gethostbyaddr(a, l, t) gethostbyaddr((char *)a, l, t)
405 #endif
407 #ifdef GETSERVBYNAME_PROTO_COMPATIBLE
408 #define roken_getservbyname(x,y) getservbyname(x,y)
409 #else
410 #define roken_getservbyname(x,y) getservbyname((char *)x, (char *)y)
411 #endif
413 #ifdef OPENLOG_PROTO_COMPATIBLE
414 #define roken_openlog(a,b,c) openlog(a,b,c)
415 #else
416 #define roken_openlog(a,b,c) openlog((char *)a,b,c)
417 #endif
419 void set_progname(char *argv0);
421 #ifndef F_OK
422 #define F_OK 0
423 #endif
425 #ifndef O_ACCMODE
426 #define O_ACCMODE 003
427 #endif
429 #ifdef HAVE_PATHS_H
430 #include <paths.h>
431 #endif
433 #ifndef _PATH_DEVNULL
434 #define _PATH_DEVNULL "/dev/null"
435 #endif
437 #ifndef MAXPATHLEN
438 #define MAXPATHLEN (1024+4)
439 #endif
441 #endif /* __ROKEN_H__ */