Change __signed to signed.
[dragonfly.git] / crypto / kerberosIV / lib / roken / roken.h.in
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
4  * (Royal Institute of Technology, Stockholm, Sweden).
5  * All rights reserved.
6  * 
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 
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.
17  * 
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.
21  * 
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
32  * SUCH DAMAGE.
33  */
34
35 /* $Id: roken.h.in,v 1.125.2.4 2000/03/12 20:32:51 assar Exp $ */
36
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <stdarg.h>
40 #include <string.h>
41 #include <signal.h>
42 #ifdef HAVE_SYS_PARAM_H
43 #include <sys/param.h>
44 #endif
45 #ifdef HAVE_SYS_TYPES_H
46 #include <sys/types.h>
47 #endif
48 #ifdef HAVE_UNISTD_H
49 #include <unistd.h>
50 #endif
51 #ifdef HAVE_SYS_SOCKET_H
52 #include <sys/socket.h>
53 #endif
54 #ifdef HAVE_SYS_UIO_H
55 #include <sys/uio.h>
56 #endif
57 #ifdef HAVE_GRP_H
58 #include <grp.h>
59 #endif
60 #ifdef HAVE_SYS_STAT_H
61 #include <sys/stat.h>
62 #endif
63 #ifdef HAVE_NETINET_IN_H
64 #include <netinet/in.h>
65 #endif
66 #ifdef HAVE_NETINET_IN6_H
67 #include <netinet/in6.h>
68 #endif
69 #ifdef HAVE_NETINET6_IN6_H
70 #include <netinet6/in6.h>
71 #endif
72 #ifdef HAVE_ARPA_INET_H
73 #include <arpa/inet.h>
74 #endif
75 #ifdef HAVE_NETDB_H
76 #include <netdb.h>
77 #endif
78 #ifdef HAVE_SYSLOG_H
79 #include <syslog.h>
80 #endif
81 #ifdef HAVE_WINSOCK_H
82 #include <winsock.h>
83 #endif
84 #ifdef HAVE_FCNTL_H
85 #include <fcntl.h>
86 #endif
87 #ifdef HAVE_ERRNO_H
88 #include <errno.h>
89 #endif
90 #ifdef HAVE_ERR_H
91 #include <err.h>
92 #endif
93 #ifdef HAVE_TERMIOS_H
94 #include <termios.h>
95 #endif
96 #if defined(HAVE_SYS_IOCTL_H) && SunOS != 40
97 #include <sys/ioctl.h>
98 #endif
99 #ifdef TIME_WITH_SYS_TIME
100 #include <sys/time.h>
101 #include <time.h>
102 #elif defined(HAVE_SYS_TIME_H)
103 #include <sys/time.h>
104 #else
105 #include <time.h>
106 #endif
107
108 #ifdef HAVE_PATHS_H
109 #include <paths.h>
110 #endif
111
112 #ifdef __cplusplus
113 extern "C" {
114 #endif
115
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 */
121 #else
122 #define ROKEN_LIB_FUNCTION
123 #endif
124 #endif
125
126 #include <roken-common.h>
127
128 #if !defined(HAVE_SETSID) && defined(HAVE__SETSID)
129 #define setsid _setsid
130 #endif
131
132 #ifndef HAVE_PUTENV
133 int putenv(const char *string);
134 #endif
135
136 #if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO)
137 int setenv(const char *var, const char *val, int rewrite);
138 #endif
139
140 #if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO)
141 void unsetenv(const char *name);
142 #endif
143
144 #if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO)
145 char *getusershell(void);
146 void endusershell(void);
147 #endif
148
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)));
152 #endif
153
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)));
157 #endif
158
159 #if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO)
160 int asprintf (char **ret, const char *format, ...)
161      __attribute__ ((format (printf, 2, 3)));
162 #endif
163
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)));
167 #endif
168
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)));
172 #endif
173
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)));
177 #endif
178
179 #ifndef HAVE_STRDUP
180 char * strdup(const char *old);
181 #endif
182
183 #ifndef HAVE_STRNDUP
184 char * strndup(const char *old, size_t sz);
185 #endif
186
187 #ifndef HAVE_STRLWR
188 char * strlwr(char *);
189 #endif
190
191 #ifndef HAVE_STRNLEN
192 size_t strnlen(const char*, size_t);
193 #endif
194
195 #if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO)
196 char *strsep(char**, const char*);
197 #endif
198
199 #ifndef HAVE_STRCASECMP
200 int strcasecmp(const char *s1, const char *s2);
201 #endif
202
203 #ifdef NEED_FCLOSE_PROTO
204 int fclose(FILE *);
205 #endif
206
207 #ifdef NEED_STRTOK_R_PROTO
208 char *strtok_r(char *s1, const char *s2, char **lasts);
209 #endif
210
211 #ifndef HAVE_STRUPR
212 char * strupr(char *);
213 #endif
214
215 #ifndef HAVE_STRLCPY
216 size_t strlcpy (char *dst, const char *src, size_t dst_sz);
217 #endif
218
219 #ifndef HAVE_STRLCAT
220 size_t strlcat (char *dst, const char *src, size_t dst_sz);
221 #endif
222
223 #ifndef HAVE_GETDTABLESIZE
224 int getdtablesize(void);
225 #endif
226
227 #if !defined(HAVE_STRERROR) && !defined(strerror)
228 char *strerror(int eno);
229 #endif
230
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);
235 #endif
236 #endif
237
238 #ifndef HAVE_H_ERRNO_DECLARATION
239 extern int h_errno;
240 #endif
241
242 #if !defined(HAVE_INET_ATON) || defined(NEED_INET_ATON_PROTO)
243 int inet_aton(const char *cp, struct in_addr *adr);
244 #endif
245
246 #ifndef HAVE_INET_NTOP
247 const char *
248 inet_ntop(int af, const void *src, char *dst, size_t size);
249 #endif
250
251 #ifndef HAVE_INET_PTON
252 int
253 inet_pton(int af, const char *src, void *dst);
254 #endif
255
256 #if !defined(HAVE_GETCWD)
257 char* getcwd(char *path, size_t size);
258 #endif
259
260 #ifdef HAVE_PWD_H
261 #include <pwd.h>
262 struct passwd *k_getpwnam (const char *user);
263 struct passwd *k_getpwuid (uid_t uid);
264 #endif
265
266 const char *get_default_username (void);
267
268 #ifndef HAVE_SETEUID
269 int seteuid(uid_t euid);
270 #endif
271
272 #ifndef HAVE_SETEGID
273 int setegid(gid_t egid);
274 #endif
275
276 #ifndef HAVE_LSTAT
277 int lstat(const char *path, struct stat *buf);
278 #endif
279
280 #if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO)
281 int mkstemp(char *);
282 #endif
283
284 #ifndef HAVE_CGETENT
285 int cgetent(char **buf, char **db_array, const char *name);
286 int cgetstr(char *buf, const char *cap, char **str);
287 #endif
288
289 #ifndef HAVE_INITGROUPS
290 int initgroups(const char *name, gid_t basegid);
291 #endif
292
293 #ifndef HAVE_FCHOWN
294 int fchown(int fd, uid_t owner, gid_t group);
295 #endif
296
297 #ifndef HAVE_DAEMON
298 int daemon(int nochdir, int noclose);
299 #endif
300
301 #ifndef HAVE_INNETGR
302 int innetgr(const char *netgroup, const char *machine, 
303             const char *user, const char *domain);
304 #endif
305
306 #ifndef HAVE_CHOWN
307 int chown(const char *path, uid_t owner, gid_t group);
308 #endif
309
310 #ifndef HAVE_RCMD
311 int rcmd(char **ahost, unsigned short inport, const char *locuser,
312          const char *remuser, const char *cmd, int *fd2p);
313 #endif
314
315 #if !defined(HAVE_INNETGR) || defined(NEED_INNETGR_PROTO)
316 int innetgr(const char*, const char*, const char*, const char*);
317 #endif
318
319 #ifndef HAVE_IRUSEROK
320 int iruserok(unsigned raddr, int superuser, const char *ruser,
321              const char *luser);
322 #endif
323
324 #if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO)
325 int gethostname(char *name, int namelen);
326 #endif
327
328 #ifndef HAVE_WRITEV
329 ssize_t
330 writev(int d, const struct iovec *iov, int iovcnt);
331 #endif
332
333 #ifndef HAVE_READV
334 ssize_t
335 readv(int d, const struct iovec *iov, int iovcnt);
336 #endif
337
338 #ifndef HAVE_MKSTEMP
339 int
340 mkstemp(char *template);
341 #endif
342
343 #ifndef HAVE_FLOCK
344 #ifndef LOCK_SH
345 #define LOCK_SH   1             /* Shared lock */
346 #endif
347 #ifndef LOCK_EX
348 #define LOCK_EX   2             /* Exclusive lock */
349 #endif
350 #ifndef LOCK_NB
351 #define LOCK_NB   4             /* Don't block when locking */
352 #endif
353 #ifndef LOCK_UN
354 #define LOCK_UN   8             /* Unlock */
355 #endif
356
357 int flock(int fd, int operation);
358 #endif /* HAVE_FLOCK */
359
360 time_t tm2time (struct tm tm, int local);
361
362 int unix_verify_user(char *user, char *password);
363
364 void inaddr2str(struct in_addr addr, char *s, size_t len);
365
366 void mini_inetd (int port);
367
368 int roken_concat (char *s, size_t len, ...);
369
370 size_t roken_mconcat (char **s, size_t max_len, ...);
371
372 int roken_vconcat (char *s, size_t len, va_list args);
373
374 size_t roken_vmconcat (char **s, size_t max_len, va_list args);
375
376 ssize_t net_write (int fd, const void *buf, size_t nbytes);
377
378 ssize_t net_read (int fd, void *buf, size_t nbytes);
379
380 int issuid(void);
381
382 #ifndef HAVE_STRUCT_WINSIZE
383 struct winsize {
384         unsigned short ws_row, ws_col;
385         unsigned short ws_xpixel, ws_ypixel;
386 };
387 #endif
388
389 int get_window_size(int fd, struct winsize *);
390
391 #ifndef HAVE_VSYSLOG
392 void vsyslog(int pri, const char *fmt, va_list ap);
393 #endif
394
395 #ifndef HAVE_OPTARG_DECLARATION
396 extern char *optarg;
397 #endif
398 #ifndef HAVE_OPTIND_DECLARATION
399 extern int optind;
400 #endif
401 #ifndef HAVE_OPTERR_DECLARATION
402 extern int opterr;
403 #endif
404
405 #ifndef HAVE___PROGNAME_DECLARATION
406 extern const char *__progname;
407 #endif
408
409 #ifndef HAVE_ENVIRON_DECLARATION
410 extern char **environ;
411 #endif
412
413 #ifndef HAVE_GETIPNODEBYNAME
414 struct hostent *
415 getipnodebyname (const char *name, int af, int flags, int *error_num);
416 #endif
417
418 #ifndef HAVE_GETIPNODEBYADDR
419 struct hostent *
420 getipnodebyaddr (const void *src, size_t len, int af, int *error_num);
421 #endif
422
423 #ifndef HAVE_FREEHOSTENT
424 void
425 freehostent (struct hostent *h);
426 #endif
427
428 #ifndef HAVE_COPYHOSTENT
429 struct hostent *
430 copyhostent (const struct hostent *h);
431 #endif
432
433 #ifndef HAVE_SOCKLEN_T
434 typedef int socklen_t;
435 #endif
436
437 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
438
439 #ifndef HAVE_SA_FAMILY_T
440 typedef unsigned short sa_family_t;
441 #endif
442
443 #ifdef HAVE_IPV6
444 #define _SS_MAXSIZE sizeof(struct sockaddr_in6)
445 #else
446 #define _SS_MAXSIZE sizeof(struct sockaddr_in)
447 #endif
448
449 #define _SS_ALIGNSIZE   sizeof(unsigned long)
450
451 #if HAVE_STRUCT_SOCKADDR_SA_LEN
452
453 typedef unsigned char roken_sa_family_t;
454
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))
457
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];
463 };
464
465 #else /* !HAVE_STRUCT_SOCKADDR_SA_LEN */
466
467 typedef unsigned short roken_sa_family_t;
468
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))
471
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];
476 };
477
478 #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
479
480 #endif /* HAVE_STRUCT_SOCKADDR_STORAGE */
481
482 /*
483  * kludges and such
484  */
485
486 #if 1
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);
490 #else
491 #ifdef GETHOSTBYNAME_PROTO_COMPATIBLE
492 #define roken_gethostbyname(x) gethostbyname(x)
493 #else
494 #define roken_gethostbyname(x) gethostbyname((char *)x)
495 #endif
496
497 #ifdef GETHOSTBYADDR_PROTO_COMPATIBLE
498 #define roken_gethostbyaddr(a, l, t) gethostbyaddr(a, l, t)
499 #else
500 #define roken_gethostbyaddr(a, l, t) gethostbyaddr((char *)a, l, t)
501 #endif
502 #endif
503
504 #ifdef GETSERVBYNAME_PROTO_COMPATIBLE
505 #define roken_getservbyname(x,y) getservbyname(x,y)
506 #else
507 #define roken_getservbyname(x,y) getservbyname((char *)x, (char *)y)
508 #endif
509
510 #ifdef OPENLOG_PROTO_COMPATIBLE
511 #define roken_openlog(a,b,c) openlog(a,b,c)
512 #else
513 #define roken_openlog(a,b,c) openlog((char *)a,b,c)
514 #endif
515
516 void set_progname(char *argv0);
517
518 #ifdef __cplusplus
519 }
520 #endif