2 * Copyright (c) 1995 - 2002 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. 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.
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
34 /* $Id: roken-common.h,v 1.51.6.1 2004/01/15 18:15:05 lha Exp $ */
36 #ifndef __ROKEN_COMMON_H__
37 #define __ROKEN_COMMON_H__
40 #define ROKEN_CPP_START extern "C" {
41 #define ROKEN_CPP_END }
43 #define ROKEN_CPP_START
48 #define INADDR_NONE 0xffffffff
51 #ifndef INADDR_LOOPBACK
52 #define INADDR_LOOPBACK 0x7f000001
60 #define STDIN_FILENO 0
64 #define STDOUT_FILENO 1
68 #define STDERR_FILENO 2
72 #define max(a,b) (((a)>(b))?(a):(b))
76 #define min(a,b) (((a)<(b))?(a):(b))
88 #define openlog(id,option,facility) openlog((id),(option))
95 #define LOG_NDELAY 0x08
104 #define LOG_AUTHPRIV LOG_AUTH
112 #define O_ACCMODE 003
116 #define _PATH_DEV "/dev/"
119 #ifndef _PATH_DEVNULL
120 #define _PATH_DEVNULL "/dev/null"
124 #define _PATH_HEQUIV "/etc/hosts.equiv"
128 #define _PATH_VARRUN "/var/run/"
132 #define _PATH_BSHELL "/bin/sh"
136 #define MAXPATHLEN (1024+4)
140 #define SIG_ERR ((RETSIGTYPE (*)(int))-1)
144 * error code for getipnodeby{name,addr}
147 #ifndef HOST_NOT_FOUND
148 #define HOST_NOT_FOUND 1
156 #define NO_RECOVERY 3
164 #define NO_ADDRESS NO_DATA
168 * error code for getaddrinfo
172 #define EAI_NOERROR 0 /* no error */
177 #define EAI_ADDRFAMILY 1 /* address family for nodename not supported */
178 #define EAI_AGAIN 2 /* temporary failure in name resolution */
179 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */
180 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */
181 #define EAI_FAMILY 5 /* ai_family not supported */
182 #define EAI_MEMORY 6 /* memory allocation failure */
183 #define EAI_NODATA 7 /* no address associated with nodename */
184 #define EAI_NONAME 8 /* nodename nor servname provided, or not known */
185 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */
186 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */
187 #define EAI_SYSTEM 11 /* system error returned in errno */
189 #endif /* EAI_NONAME */
191 /* flags for getaddrinfo() */
194 #define AI_PASSIVE 0x01
195 #define AI_CANONNAME 0x02
196 #endif /* AI_PASSIVE */
198 #ifndef AI_NUMERICHOST
199 #define AI_NUMERICHOST 0x04
202 /* flags for getnameinfo() */
205 #define NI_DGRAM 0x01
206 #define NI_NAMEREQD 0x02
207 #define NI_NOFQDN 0x04
208 #define NI_NUMERICHOST 0x08
209 #define NI_NUMERICSERV 0x10
213 * constants for getnameinfo
217 #define NI_MAXHOST 1025
218 #define NI_MAXSERV 32
222 * constants for inet_ntop
225 #ifndef INET_ADDRSTRLEN
226 #define INET_ADDRSTRLEN 16
229 #ifndef INET6_ADDRSTRLEN
230 #define INET6_ADDRSTRLEN 46
249 #ifndef HAVE___ATTRIBUTE__
250 #define __attribute__(x)
255 #ifndef IRIX4 /* fix for compiler bug */
257 typedef RETSIGTYPE (*SigAction)(int);
258 SigAction signal(int iSig, SigAction pAction); /* BSD compatible */
262 int ROKEN_LIB_FUNCTION simple_execve(const char*, char*const[], char*const[]);
263 int ROKEN_LIB_FUNCTION simple_execvp(const char*, char *const[]);
264 int ROKEN_LIB_FUNCTION simple_execlp(const char*, ...);
265 int ROKEN_LIB_FUNCTION simple_execle(const char*, ...);
266 int ROKEN_LIB_FUNCTION simple_execl(const char *file, ...);
268 int ROKEN_LIB_FUNCTION wait_for_process(pid_t);
269 int ROKEN_LIB_FUNCTION pipe_execv(FILE**, FILE**, FILE**, const char*, ...);
271 void ROKEN_LIB_FUNCTION print_version(const char *);
273 ssize_t ROKEN_LIB_FUNCTION eread (int fd, void *buf, size_t nbytes);
274 ssize_t ROKEN_LIB_FUNCTION ewrite (int fd, const void *buf, size_t nbytes);
279 hostent_find_fqdn (const struct hostent *he);
282 esetenv(const char *var, const char *val, int rewrite);
285 socket_set_address_and_port (struct sockaddr *sa, const void *ptr, int port);
288 socket_addr_size (const struct sockaddr *sa);
291 socket_set_any (struct sockaddr *sa, int af);
294 socket_sockaddr_size (const struct sockaddr *sa);
297 socket_get_address (struct sockaddr *sa);
300 socket_get_port (const struct sockaddr *sa);
303 socket_set_port (struct sockaddr *sa, int port);
306 socket_set_portrange (int sock, int restr, int af);
309 socket_set_debug (int sock);
312 socket_set_tos (int sock, int tos);
315 socket_set_reuseaddr (int sock, int val);
318 vstrcollect(va_list *ap);
321 strcollect(char *first, ...);
323 void timevalfix(struct timeval *t1);
324 void timevaladd(struct timeval *t1, const struct timeval *t2);
325 void timevalsub(struct timeval *t1, const struct timeval *t2);
327 char *pid_file_write (const char *progname);
328 void pid_file_delete (char **);
331 read_environment(const char *file, char ***env);
333 void warnerr(int doerrno, const char *fmt, va_list ap)
334 __attribute__ ((format (printf, 2, 0)));
338 #endif /* __ROKEN_COMMON_H__ */