roken-common.h revision 57416
11897Swollman/* 21897Swollman * Copyright (c) 1995 - 2000 Kungliga Tekniska H�gskolan 31897Swollman * (Royal Institute of Technology, Stockholm, Sweden). 41897Swollman * All rights reserved. 51897Swollman * 61897Swollman * Redistribution and use in source and binary forms, with or without 71897Swollman * modification, are permitted provided that the following conditions 812798Swpaul * are met: 91897Swollman * 101897Swollman * 1. Redistributions of source code must retain the above copyright 111897Swollman * notice, this list of conditions and the following disclaimer. 1212798Swpaul * 131897Swollman * 2. Redistributions in binary form must reproduce the above copyright 141897Swollman * notice, this list of conditions and the following disclaimer in the 151897Swollman * documentation and/or other materials provided with the distribution. 1612798Swpaul * 171897Swollman * 3. Neither the name of the Institute nor the names of its contributors 181897Swollman * may be used to endorse or promote products derived from this software 191897Swollman * without specific prior written permission. 2012798Swpaul * 211897Swollman * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 221897Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231897Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2412798Swpaul * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 251897Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261897Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271897Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281897Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2912798Swpaul * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3012798Swpaul * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3112798Swpaul * SUCH DAMAGE. 321897Swollman */ 3312798Swpaul 341897Swollman/* $Id: roken-common.h,v 1.25 2000/01/09 10:58:34 assar Exp $ */ 351897Swollman 361897Swollman#ifndef __ROKEN_COMMON_H__ 371897Swollman#define __ROKEN_COMMON_H__ 381897Swollman 391897Swollman#ifndef INADDR_NONE 401897Swollman#define INADDR_NONE 0xffffffff 4112798Swpaul#endif 4212798Swpaul 431897Swollman#ifndef INADDR_LOOPBACK 441897Swollman#define INADDR_LOOPBACK 0x7f000001 451897Swollman#endif 4617142Sjkh 4712798Swpaul#ifndef SOMAXCONN 4817142Sjkh#define SOMAXCONN 5 4917142Sjkh#endif 5012798Swpaul 5112798Swpaul#ifndef STDIN_FILENO 5212798Swpaul#define STDIN_FILENO 0 5312798Swpaul#endif 541897Swollman 551897Swollman#ifndef STDOUT_FILENO 561897Swollman#define STDOUT_FILENO 1 571897Swollman#endif 581897Swollman 591897Swollman#ifndef STDERR_FILENO 601897Swollman#define STDERR_FILENO 2 611897Swollman#endif 621897Swollman 6312798Swpaul#ifndef max 6412798Swpaul#define max(a,b) (((a)>(b))?(a):(b)) 6512798Swpaul#endif 661897Swollman 671897Swollman#ifndef min 681897Swollman#define min(a,b) (((a)<(b))?(a):(b)) 691897Swollman#endif 701897Swollman 711897Swollman#ifndef TRUE 721897Swollman#define TRUE 1 731897Swollman#endif 741897Swollman 7517142Sjkh#ifndef FALSE 761897Swollman#define FALSE 0 771897Swollman#endif 781897Swollman 791897Swollman#ifndef LOG_DAEMON 801897Swollman#define openlog(id,option,facility) openlog((id),(option)) 811897Swollman#define LOG_DAEMON 0 821897Swollman#endif 831897Swollman#ifndef LOG_ODELAY 841897Swollman#define LOG_ODELAY 0 8512798Swpaul#endif 8612798Swpaul#ifndef LOG_NDELAY 8712798Swpaul#define LOG_NDELAY 0x08 8812798Swpaul#endif 8912798Swpaul#ifndef LOG_CONS 9012798Swpaul#define LOG_CONS 0 9112798Swpaul#endif 9212798Swpaul#ifndef LOG_AUTH 9312798Swpaul#define LOG_AUTH 0 9412798Swpaul#endif 9512798Swpaul#ifndef LOG_AUTHPRIV 961897Swollman#define LOG_AUTHPRIV LOG_AUTH 971897Swollman#endif 9812798Swpaul 9912798Swpaul#ifndef F_OK 1001897Swollman#define F_OK 0 1011897Swollman#endif 1021897Swollman 1031897Swollman#ifndef O_ACCMODE 10412798Swpaul#define O_ACCMODE 003 10512798Swpaul#endif 10612798Swpaul 10712798Swpaul#ifndef _PATH_DEV 10812798Swpaul#define _PATH_DEV "/dev/" 10912798Swpaul#endif 11012798Swpaul 11112798Swpaul#ifndef _PATH_DEVNULL 11212798Swpaul#define _PATH_DEVNULL "/dev/null" 11312798Swpaul#endif 11412798Swpaul 11512798Swpaul#ifndef _PATH_HEQUIV 11612798Swpaul#define _PATH_HEQUIV "/etc/hosts.equiv" 11712798Swpaul#endif 11812798Swpaul 11912798Swpaul#ifndef MAXPATHLEN 12012798Swpaul#define MAXPATHLEN (1024+4) 12112798Swpaul#endif 12212798Swpaul 12312798Swpaul#ifndef SIG_ERR 12412798Swpaul#define SIG_ERR ((RETSIGTYPE (*)())-1) 12512798Swpaul#endif 12612798Swpaul 12712798Swpaul/* 12812798Swpaul * error code for getipnodeby{name,addr} 12912798Swpaul */ 13012798Swpaul 13112798Swpaul#ifndef HOST_NOT_FOUND 13212798Swpaul#define HOST_NOT_FOUND 1 13312798Swpaul#endif 13412798Swpaul 13512798Swpaul#ifndef TRY_AGAIN 13612798Swpaul#define TRY_AGAIN 2 13712798Swpaul#endif 13812798Swpaul 13912798Swpaul#ifndef NO_RECOVERY 14012798Swpaul#define NO_RECOVERY 3 14112798Swpaul#endif 14212798Swpaul 14312798Swpaul#ifndef NO_DATA 14412798Swpaul#define NO_DATA 4 14512798Swpaul#endif 14612798Swpaul 14712798Swpaul#ifndef NO_ADDRESS 14812798Swpaul#define NO_ADDRESS NO_DATA 14912798Swpaul#endif 15012798Swpaul 15112798Swpaul/* 15212798Swpaul * error code for getaddrinfo 15312798Swpaul */ 15412798Swpaul 15512798Swpaul#ifndef EAI_NOERROR 15612798Swpaul#define EAI_NOERROR 0 /* no error */ 15712798Swpaul#endif 15812798Swpaul 15912798Swpaul#ifndef EAI_ADDRFAMILY 16012798Swpaul 16112798Swpaul#define EAI_ADDRFAMILY 1 /* address family for nodename not supported */ 16212798Swpaul#define EAI_AGAIN 2 /* temporary failure in name resolution */ 16312798Swpaul#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ 16412798Swpaul#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ 16512798Swpaul#define EAI_FAMILY 5 /* ai_family not supported */ 16612798Swpaul#define EAI_MEMORY 6 /* memory allocation failure */ 16712798Swpaul#define EAI_NODATA 7 /* no address associated with nodename */ 16812798Swpaul#define EAI_NONAME 8 /* nodename nor servname provided, or not known */ 16912798Swpaul#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ 17012798Swpaul#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ 17112798Swpaul#define EAI_SYSTEM 11 /* system error returned in errno */ 17212798Swpaul 17312798Swpaul#endif /* EAI_ADDRFAMILY */ 17412798Swpaul 17512798Swpaul/* flags for getaddrinfo() */ 17612798Swpaul 17712798Swpaul#ifndef AI_PASSIVE 17812798Swpaul 17912798Swpaul#define AI_PASSIVE 0x01 18012798Swpaul#define AI_CANONNAME 0x02 18112798Swpaul#define AI_NUMERICHOST 0x04 18212798Swpaul 18312798Swpaul#endif /* AI_PASSIVE */ 18412798Swpaul 18512798Swpaul/* flags for getnameinfo() */ 18612798Swpaul 18712798Swpaul#ifndef NI_DGRAM 18812798Swpaul#define NI_DGRAM 0x01 18912798Swpaul#define NI_NAMEREQD 0x02 19012798Swpaul#define NI_NOFQDN 0x04 19112798Swpaul#define NI_NUMERICHOST 0x08 19212798Swpaul#define NI_NUMERICSERV 0x10 19312798Swpaul#endif 19412798Swpaul 19512798Swpaul/* 19612798Swpaul * constants for getnameinfo 19712798Swpaul */ 19812798Swpaul 19912798Swpaul#ifndef NI_MAXHOST 20012798Swpaul#define NI_MAXHOST 1025 20112798Swpaul#define NI_MAXSERV 32 20212798Swpaul#endif 20312798Swpaul 20412798Swpaul/* 20512798Swpaul * constants for inet_ntop 20612798Swpaul */ 20712798Swpaul 20812798Swpaul#ifndef INET_ADDRSTRLEN 20912798Swpaul#define INET_ADDRSTRLEN 16 2101897Swollman#endif 2111897Swollman 2121897Swollman#ifndef INET6_ADDRSTRLEN 2131897Swollman#define INET6_ADDRSTRLEN 46 2141897Swollman#endif 2151897Swollman 2161897Swollman/* 2171897Swollman * for shutdown(2) 2181897Swollman */ 2191897Swollman 2201897Swollman#ifndef SHUT_RD 22117142Sjkh#define SHUT_RD 0 2221897Swollman#endif 2231897Swollman 2241897Swollman#ifndef SHUT_WR 22512798Swpaul#define SHUT_WR 1 22612798Swpaul#endif 22712798Swpaul 22812798Swpaul#ifndef SHUT_RDWR 22912798Swpaul#define SHUT_RDWR 2 23012798Swpaul#endif 23112798Swpaul 23212798Swpaul#ifndef HAVE___ATTRIBUTE__ 23312798Swpaul#define __attribute__(x) 23412798Swpaul#endif 23512798Swpaul 23612798Swpaul#if IRIX != 4 /* fix for compiler bug */ 2371897Swollman#ifdef RETSIGTYPE 23812798Swpaultypedef RETSIGTYPE (*SigAction)(/* int??? */); 23912798SwpaulSigAction signal(int iSig, SigAction pAction); /* BSD compatible */ 24012798Swpaul#endif 24112798Swpaul#endif 24212798Swpaul 24312798Swpaulint ROKEN_LIB_FUNCTION simple_execve(const char*, char*const[], char*const[]); 24412798Swpaulint ROKEN_LIB_FUNCTION simple_execvp(const char*, char *const[]); 24512798Swpaulint ROKEN_LIB_FUNCTION simple_execlp(const char*, ...); 24612798Swpaulint ROKEN_LIB_FUNCTION simple_execle(const char*, ...); 24712798Swpaul 24812798Swpaulvoid ROKEN_LIB_FUNCTION print_version(const char *); 24912798Swpaul 2501897Swollmanvoid *ROKEN_LIB_FUNCTION emalloc (size_t); 25112798Swpaulvoid *ROKEN_LIB_FUNCTION erealloc (void *, size_t); 25212798Swpaulchar *ROKEN_LIB_FUNCTION estrdup (const char *); 25312798Swpaul 25412798Swpaulssize_t ROKEN_LIB_FUNCTION eread (int fd, void *buf, size_t nbytes); 25512798Swpaulssize_t ROKEN_LIB_FUNCTION ewrite (int fd, const void *buf, size_t nbytes); 25612798Swpaul 25712798Swpaulvoid 25812798Swpaulsocket_set_address_and_port (struct sockaddr *sa, const void *ptr, int port); 25912798Swpaul 26012798Swpaulsize_t 26112798Swpaulsocket_addr_size (const struct sockaddr *sa); 26212798Swpaul 26312798Swpaulvoid 26412798Swpaulsocket_set_any (struct sockaddr *sa, int af); 26512798Swpaul 26612798Swpaulsize_t 26712798Swpaulsocket_sockaddr_size (const struct sockaddr *sa); 26812798Swpaul 26912798Swpaulvoid * 27012798Swpaulsocket_get_address (struct sockaddr *sa); 27112798Swpaul 27212798Swpaulint 27312798Swpaulsocket_get_port (const struct sockaddr *sa); 27412798Swpaul 27512798Swpaulvoid 27612798Swpaulsocket_set_port (struct sockaddr *sa, int port); 27712798Swpaul 27812798Swpaulvoid 27912798Swpaulsocket_set_debug (int sock); 28012798Swpaul 28112798Swpaulvoid 28212798Swpaulsocket_set_tos (int sock, int tos); 28312798Swpaul 28412798Swpaulvoid 28512798Swpaulsocket_set_reuseaddr (int sock, int val); 28612798Swpaul 28712798Swpaulchar ** 28812798Swpaulvstrcollect(va_list *ap); 28912798Swpaul 29012798Swpaulchar ** 29112798Swpaulstrcollect(char *first, ...); 29212798Swpaul 29312798Swpaul#endif /* __ROKEN_COMMON_H__ */ 29412798Swpaul