roken-common.h revision 55682
155682Smarkm/*
255682Smarkm * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska H�gskolan
355682Smarkm * (Royal Institute of Technology, Stockholm, Sweden).
455682Smarkm * All rights reserved.
555682Smarkm *
655682Smarkm * Redistribution and use in source and binary forms, with or without
755682Smarkm * modification, are permitted provided that the following conditions
855682Smarkm * are met:
955682Smarkm *
1055682Smarkm * 1. Redistributions of source code must retain the above copyright
1155682Smarkm *    notice, this list of conditions and the following disclaimer.
1255682Smarkm *
1355682Smarkm * 2. Redistributions in binary form must reproduce the above copyright
1455682Smarkm *    notice, this list of conditions and the following disclaimer in the
1555682Smarkm *    documentation and/or other materials provided with the distribution.
1655682Smarkm *
1755682Smarkm * 3. Neither the name of the Institute nor the names of its contributors
1855682Smarkm *    may be used to endorse or promote products derived from this software
1955682Smarkm *    without specific prior written permission.
2055682Smarkm *
2155682Smarkm * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
2255682Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2355682Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2455682Smarkm * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
2555682Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2655682Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2755682Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2855682Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2955682Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3055682Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3155682Smarkm * SUCH DAMAGE.
3255682Smarkm */
3355682Smarkm
3455682Smarkm/* $Id: roken-common.h,v 1.24 1999/12/05 13:25:40 assar Exp $ */
3555682Smarkm
3655682Smarkm#ifndef __ROKEN_COMMON_H__
3755682Smarkm#define __ROKEN_COMMON_H__
3855682Smarkm
3955682Smarkm#ifndef INADDR_NONE
4055682Smarkm#define INADDR_NONE 0xffffffff
4155682Smarkm#endif
4255682Smarkm
4355682Smarkm#ifndef INADDR_LOOPBACK
4455682Smarkm#define INADDR_LOOPBACK 0x7f000001
4555682Smarkm#endif
4655682Smarkm
4755682Smarkm#ifndef SOMAXCONN
4855682Smarkm#define SOMAXCONN 5
4955682Smarkm#endif
5055682Smarkm
5155682Smarkm#ifndef STDIN_FILENO
5255682Smarkm#define STDIN_FILENO 0
5355682Smarkm#endif
5455682Smarkm
5555682Smarkm#ifndef STDOUT_FILENO
5655682Smarkm#define STDOUT_FILENO 1
5755682Smarkm#endif
5855682Smarkm
5955682Smarkm#ifndef STDERR_FILENO
6055682Smarkm#define STDERR_FILENO 2
6155682Smarkm#endif
6255682Smarkm
6355682Smarkm#ifndef max
6455682Smarkm#define max(a,b) (((a)>(b))?(a):(b))
6555682Smarkm#endif
6655682Smarkm
6755682Smarkm#ifndef min
6855682Smarkm#define min(a,b) (((a)<(b))?(a):(b))
6955682Smarkm#endif
7055682Smarkm
7155682Smarkm#ifndef TRUE
7255682Smarkm#define TRUE 1
7355682Smarkm#endif
7455682Smarkm
7555682Smarkm#ifndef FALSE
7655682Smarkm#define FALSE 0
7755682Smarkm#endif
7855682Smarkm
7955682Smarkm#ifndef LOG_DAEMON
8055682Smarkm#define openlog(id,option,facility) openlog((id),(option))
8155682Smarkm#define	LOG_DAEMON	0
8255682Smarkm#endif
8355682Smarkm#ifndef LOG_ODELAY
8455682Smarkm#define LOG_ODELAY 0
8555682Smarkm#endif
8655682Smarkm#ifndef LOG_NDELAY
8755682Smarkm#define LOG_NDELAY 0x08
8855682Smarkm#endif
8955682Smarkm#ifndef LOG_CONS
9055682Smarkm#define LOG_CONS 0
9155682Smarkm#endif
9255682Smarkm#ifndef LOG_AUTH
9355682Smarkm#define LOG_AUTH 0
9455682Smarkm#endif
9555682Smarkm#ifndef LOG_AUTHPRIV
9655682Smarkm#define LOG_AUTHPRIV LOG_AUTH
9755682Smarkm#endif
9855682Smarkm
9955682Smarkm#ifndef F_OK
10055682Smarkm#define F_OK 0
10155682Smarkm#endif
10255682Smarkm
10355682Smarkm#ifndef O_ACCMODE
10455682Smarkm#define O_ACCMODE	003
10555682Smarkm#endif
10655682Smarkm
10755682Smarkm#ifndef _PATH_DEVNULL
10855682Smarkm#define _PATH_DEVNULL "/dev/null"
10955682Smarkm#endif
11055682Smarkm
11155682Smarkm#ifndef _PATH_HEQUIV
11255682Smarkm#define _PATH_HEQUIV "/etc/hosts.equiv"
11355682Smarkm#endif
11455682Smarkm
11555682Smarkm#ifndef MAXPATHLEN
11655682Smarkm#define MAXPATHLEN (1024+4)
11755682Smarkm#endif
11855682Smarkm
11955682Smarkm#ifndef SIG_ERR
12055682Smarkm#define SIG_ERR ((RETSIGTYPE (*)())-1)
12155682Smarkm#endif
12255682Smarkm
12355682Smarkm/*
12455682Smarkm * error code for getipnodeby{name,addr}
12555682Smarkm */
12655682Smarkm
12755682Smarkm#ifndef HOST_NOT_FOUND
12855682Smarkm#define HOST_NOT_FOUND 1
12955682Smarkm#endif
13055682Smarkm
13155682Smarkm#ifndef TRY_AGAIN
13255682Smarkm#define TRY_AGAIN 2
13355682Smarkm#endif
13455682Smarkm
13555682Smarkm#ifndef NO_RECOVERY
13655682Smarkm#define NO_RECOVERY 3
13755682Smarkm#endif
13855682Smarkm
13955682Smarkm#ifndef NO_DATA
14055682Smarkm#define NO_DATA 4
14155682Smarkm#endif
14255682Smarkm
14355682Smarkm#ifndef NO_ADDRESS
14455682Smarkm#define NO_ADDRESS NO_DATA
14555682Smarkm#endif
14655682Smarkm
14755682Smarkm/*
14855682Smarkm * error code for getaddrinfo
14955682Smarkm */
15055682Smarkm
15155682Smarkm#ifndef EAI_NOERROR
15255682Smarkm#define EAI_NOERROR	0	/* no error */
15355682Smarkm#endif
15455682Smarkm
15555682Smarkm#ifndef EAI_ADDRFAMILY
15655682Smarkm
15755682Smarkm#define EAI_ADDRFAMILY	1	/* address family for nodename not supported */
15855682Smarkm#define EAI_AGAIN	2	/* temporary failure in name resolution */
15955682Smarkm#define EAI_BADFLAGS	3	/* invalid value for ai_flags */
16055682Smarkm#define EAI_FAIL	4	/* non-recoverable failure in name resolution */
16155682Smarkm#define EAI_FAMILY	5	/* ai_family not supported */
16255682Smarkm#define EAI_MEMORY	6	/* memory allocation failure */
16355682Smarkm#define EAI_NODATA	7	/* no address associated with nodename */
16455682Smarkm#define EAI_NONAME	8	/* nodename nor servname provided, or not known */
16555682Smarkm#define EAI_SERVICE	9	/* servname not supported for ai_socktype */
16655682Smarkm#define EAI_SOCKTYPE   10	/* ai_socktype not supported */
16755682Smarkm#define EAI_SYSTEM     11	/* system error returned in errno */
16855682Smarkm
16955682Smarkm#endif /* EAI_ADDRFAMILY */
17055682Smarkm
17155682Smarkm/* flags for getaddrinfo() */
17255682Smarkm
17355682Smarkm#ifndef AI_PASSIVE
17455682Smarkm
17555682Smarkm#define AI_PASSIVE	0x01
17655682Smarkm#define AI_CANONNAME	0x02
17755682Smarkm#define AI_NUMERICHOST	0x04
17855682Smarkm
17955682Smarkm#endif /* AI_PASSIVE */
18055682Smarkm
18155682Smarkm/* flags for getnameinfo() */
18255682Smarkm
18355682Smarkm#ifndef NI_DGRAM
18455682Smarkm#define NI_DGRAM	0x01
18555682Smarkm#define NI_NAMEREQD	0x02
18655682Smarkm#define NI_NOFQDN	0x04
18755682Smarkm#define NI_NUMERICHOST	0x08
18855682Smarkm#define NI_NUMERICSERV	0x10
18955682Smarkm#endif
19055682Smarkm
19155682Smarkm/*
19255682Smarkm * constants for getnameinfo
19355682Smarkm */
19455682Smarkm
19555682Smarkm#ifndef NI_MAXHOST
19655682Smarkm#define NI_MAXHOST  1025
19755682Smarkm#define NI_MAXSERV    32
19855682Smarkm#endif
19955682Smarkm
20055682Smarkm/*
20155682Smarkm * constants for inet_ntop
20255682Smarkm */
20355682Smarkm
20455682Smarkm#ifndef INET_ADDRSTRLEN
20555682Smarkm#define INET_ADDRSTRLEN    16
20655682Smarkm#endif
20755682Smarkm
20855682Smarkm#ifndef INET6_ADDRSTRLEN
20955682Smarkm#define INET6_ADDRSTRLEN   46
21055682Smarkm#endif
21155682Smarkm
21255682Smarkm/*
21355682Smarkm * for shutdown(2)
21455682Smarkm */
21555682Smarkm
21655682Smarkm#ifndef SHUT_RD
21755682Smarkm#define SHUT_RD 0
21855682Smarkm#endif
21955682Smarkm
22055682Smarkm#ifndef SHUT_WR
22155682Smarkm#define SHUT_WR 1
22255682Smarkm#endif
22355682Smarkm
22455682Smarkm#ifndef SHUT_RDWR
22555682Smarkm#define SHUT_RDWR 2
22655682Smarkm#endif
22755682Smarkm
22855682Smarkm#ifndef HAVE___ATTRIBUTE__
22955682Smarkm#define __attribute__(x)
23055682Smarkm#endif
23155682Smarkm
23255682Smarkm#if IRIX != 4 /* fix for compiler bug */
23355682Smarkm#ifdef RETSIGTYPE
23455682Smarkmtypedef RETSIGTYPE (*SigAction)(/* int??? */);
23555682SmarkmSigAction signal(int iSig, SigAction pAction); /* BSD compatible */
23655682Smarkm#endif
23755682Smarkm#endif
23855682Smarkm
23955682Smarkmint ROKEN_LIB_FUNCTION simple_execve(const char*, char*const[], char*const[]);
24055682Smarkmint ROKEN_LIB_FUNCTION simple_execvp(const char*, char *const[]);
24155682Smarkmint ROKEN_LIB_FUNCTION simple_execlp(const char*, ...);
24255682Smarkmint ROKEN_LIB_FUNCTION simple_execle(const char*, ...);
24355682Smarkm
24455682Smarkmvoid ROKEN_LIB_FUNCTION print_version(const char *);
24555682Smarkm
24655682Smarkmvoid *ROKEN_LIB_FUNCTION emalloc (size_t);
24755682Smarkmvoid *ROKEN_LIB_FUNCTION erealloc (void *, size_t);
24855682Smarkmchar *ROKEN_LIB_FUNCTION estrdup (const char *);
24955682Smarkm
25055682Smarkmssize_t ROKEN_LIB_FUNCTION eread (int fd, void *buf, size_t nbytes);
25155682Smarkmssize_t ROKEN_LIB_FUNCTION ewrite (int fd, const void *buf, size_t nbytes);
25255682Smarkm
25355682Smarkmvoid
25455682Smarkmsocket_set_address_and_port (struct sockaddr *sa, const void *ptr, int port);
25555682Smarkm
25655682Smarkmsize_t
25755682Smarkmsocket_addr_size (const struct sockaddr *sa);
25855682Smarkm
25955682Smarkmvoid
26055682Smarkmsocket_set_any (struct sockaddr *sa, int af);
26155682Smarkm
26255682Smarkmsize_t
26355682Smarkmsocket_sockaddr_size (const struct sockaddr *sa);
26455682Smarkm
26555682Smarkmvoid *
26655682Smarkmsocket_get_address (struct sockaddr *sa);
26755682Smarkm
26855682Smarkmint
26955682Smarkmsocket_get_port (const struct sockaddr *sa);
27055682Smarkm
27155682Smarkmvoid
27255682Smarkmsocket_set_port (struct sockaddr *sa, int port);
27355682Smarkm
27455682Smarkmvoid
27555682Smarkmsocket_set_debug (int sock);
27655682Smarkm
27755682Smarkmvoid
27855682Smarkmsocket_set_tos (int sock, int tos);
27955682Smarkm
28055682Smarkmvoid
28155682Smarkmsocket_set_reuseaddr (int sock, int val);
28255682Smarkm
28355682Smarkm#endif /* __ROKEN_COMMON_H__ */
284