Initial import from FreeBSD RELENG_4:
[dragonfly.git] / crypto / kerberosIV / lib / roken / roken-common.h
1 /*
2  * Copyright (c) 1995, 1996, 1997, 1998, 1999 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.
12  * 
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.
16  * 
17  * 3. Neither the name of the Institute nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  * 
21  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33
34 /* $Id: roken-common.h,v 1.19.2.2 2000/08/16 03:37:26 assar Exp $ */
35
36 #ifndef __ROKEN_COMMON_H__
37 #define __ROKEN_COMMON_H__
38
39 #ifndef INADDR_NONE
40 #define INADDR_NONE 0xffffffff
41 #endif
42
43 #ifndef SOMAXCONN
44 #define SOMAXCONN 5
45 #endif
46
47 #ifndef STDIN_FILENO
48 #define STDIN_FILENO 0
49 #endif
50
51 #ifndef STDOUT_FILENO
52 #define STDOUT_FILENO 1
53 #endif
54
55 #ifndef STDERR_FILENO
56 #define STDERR_FILENO 2
57 #endif
58
59 #ifndef max
60 #define max(a,b) (((a)>(b))?(a):(b))
61 #endif
62
63 #ifndef min
64 #define min(a,b) (((a)<(b))?(a):(b))
65 #endif
66
67 #ifndef TRUE
68 #define TRUE 1
69 #endif
70
71 #ifndef FALSE
72 #define FALSE 0
73 #endif
74
75 #ifndef LOG_DAEMON
76 #define openlog(id,option,facility) openlog((id),(option))
77 #define LOG_DAEMON      0
78 #endif
79 #ifndef LOG_ODELAY
80 #define LOG_ODELAY 0
81 #endif
82 #ifndef LOG_NDELAY
83 #define LOG_NDELAY 0x08
84 #endif
85 #ifndef LOG_CONS
86 #define LOG_CONS 0
87 #endif
88 #ifndef LOG_AUTH
89 #define LOG_AUTH 0
90 #endif
91 #ifndef LOG_AUTHPRIV
92 #define LOG_AUTHPRIV LOG_AUTH
93 #endif
94
95 #ifndef F_OK
96 #define F_OK 0
97 #endif
98
99 #ifndef O_ACCMODE
100 #define O_ACCMODE       003
101 #endif
102
103 #ifndef _PATH_DEV
104 #define _PATH_DEV "/dev/"
105 #endif
106
107 #ifndef _PATH_DEVNULL
108 #define _PATH_DEVNULL "/dev/null"
109 #endif
110
111 #ifndef _PATH_HEQUIV
112 #define _PATH_HEQUIV "/etc/hosts.equiv"
113 #endif
114
115 #ifndef MAXPATHLEN
116 #define MAXPATHLEN (1024+4)
117 #endif
118
119 #ifndef SIG_ERR
120 #define SIG_ERR ((RETSIGTYPE (*)())-1)
121 #endif
122
123 #ifndef HOST_NOT_FOUND
124 #define HOST_NOT_FOUND 1
125 #endif
126
127 #ifndef TRY_AGAIN
128 #define TRY_AGAIN 2
129 #endif
130
131 #ifndef NO_RECOVERY
132 #define NO_RECOVERY 3
133 #endif
134
135 #ifndef NO_DATA
136 #define NO_DATA 4
137 #endif
138
139 #ifndef NO_ADDRESS
140 #define NO_ADDRESS NO_DATA
141 #endif
142
143 #if 0
144
145 struct addrinfo {
146     int    ai_flags;
147     int    ai_family;
148     int    ai_socktype;
149     int    ai_protocol;
150     size_t ai_addrlen;
151     char  *ai_canonname;
152     struct sockaddr *ai_addr;
153     struct addrinfo *ai_next;
154 };
155
156 #define EAI_ADDRFAMILY  1       /* address family for nodename not supported */
157 #define EAI_AGAIN       2       /* temporary failure in name resolution */
158 #define EAI_BADFLAGS    3       /* invalid value for ai_flags */
159 #define EAI_FAIL        4       /* non-recoverable failure in name resolution */
160 #define EAI_FAMILY      5       /* ai_family not supported */
161 #define EAI_MEMORY      6       /* memory allocation failure */
162 #define EAI_NODATA      7       /* no address associated with nodename */
163 #define EAI_NONAME      8       /* nodename nor servname provided, or not known */
164 #define EAI_SERVICE     9       /* servname not supported for ai_socktype */
165 #define EAI_SOCKTYPE   10       /* ai_socktype not supported */
166 #define EAI_SYSTEM     11       /* system error returned in errno */
167
168 /* flags for getaddrinfo() */
169
170 #define AI_PASSIVE      0x01
171 #define AI_CANONNAME    0x02
172 #define AI_NUMERICHOST  0x04
173
174 #endif
175
176 /*
177  * constants for inet_ntop
178  */
179
180 #ifndef INET_ADDRSTRLEN
181 #define INET_ADDRSTRLEN    16
182 #endif
183
184 #ifndef INET6_ADDRSTRLEN
185 #define INET6_ADDRSTRLEN   46
186 #endif
187
188 /*
189  * for shutdown(2)
190  */
191
192 #ifndef SHUT_RD
193 #define SHUT_RD 0
194 #endif
195
196 #ifndef SHUT_WR
197 #define SHUT_WR 1
198 #endif
199
200 #ifndef SHUT_RDWR
201 #define SHUT_RDWR 2
202 #endif
203
204 #ifndef HAVE___ATTRIBUTE__
205 #define __attribute__(x)
206 #endif
207
208 #if IRIX != 4 /* fix for compiler bug */
209 #ifdef RETSIGTYPE
210 typedef RETSIGTYPE (*SigAction)(/* int??? */);
211 SigAction signal(int iSig, SigAction pAction); /* BSD compatible */
212 #endif
213 #endif
214
215 int ROKEN_LIB_FUNCTION simple_execve(const char*, char*const[], char*const[]);
216 int ROKEN_LIB_FUNCTION simple_execvp(const char*, char *const[]);
217 int ROKEN_LIB_FUNCTION simple_execlp(const char*, ...);
218 int ROKEN_LIB_FUNCTION simple_execle(const char*, ...);
219
220 void ROKEN_LIB_FUNCTION print_version(const char *);
221
222 void *ROKEN_LIB_FUNCTION emalloc (size_t);
223 void *ROKEN_LIB_FUNCTION erealloc (void *, size_t);
224 char *ROKEN_LIB_FUNCTION estrdup (const char *);
225
226 ssize_t ROKEN_LIB_FUNCTION eread (int fd, void *buf, size_t nbytes);
227 ssize_t ROKEN_LIB_FUNCTION ewrite (int fd, const void *buf, size_t nbytes);
228
229 void
230 socket_set_address_and_port (struct sockaddr *sa, const void *ptr, int port);
231
232 size_t
233 socket_addr_size (const struct sockaddr *sa);
234
235 void
236 socket_set_any (struct sockaddr *sa, int af);
237
238 size_t
239 socket_sockaddr_size (const struct sockaddr *sa);
240
241 void *
242 socket_get_address (struct sockaddr *sa);
243
244 int
245 socket_get_port (const struct sockaddr *sa);
246
247 void
248 socket_set_port (struct sockaddr *sa, int port);
249
250 void
251 socket_set_debug (int sock);
252
253 void
254 socket_set_tos (int sock, int tos);
255
256 void
257 socket_set_reuseaddr (int sock, int val);
258
259 char **
260 vstrcollect(va_list *ap);
261
262 char **
263 strcollect(char *first, ...);
264  
265 #endif /* __ROKEN_COMMON_H__ */