roken-common.h revision 267654
117651Speter/* 2237410Sdelphij * Copyright (c) 1995 - 2005 Kungliga Tekniska H�gskolan 3205471Sdelphij * (Royal Institute of Technology, Stockholm, Sweden). 4131380Stjr * All rights reserved. 517651Speter * 617651Speter * Redistribution and use in source and binary forms, with or without 717651Speter * modification, are permitted provided that the following conditions 817651Speter * are met: 917651Speter * 1017651Speter * 1. Redistributions of source code must retain the above copyright 1117651Speter * notice, this list of conditions and the following disclaimer. 1217651Speter * 1317651Speter * 2. Redistributions in binary form must reproduce the above copyright 1417651Speter * notice, this list of conditions and the following disclaimer in the 1517651Speter * documentation and/or other materials provided with the distribution. 1617651Speter * 1717651Speter * 3. Neither the name of the Institute nor the names of its contributors 1817651Speter * may be used to endorse or promote products derived from this software 1917651Speter * without specific prior written permission. 2017651Speter * 2117651Speter * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 2217651Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2317651Speter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2417651Speter * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 2517651Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2617651Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2717651Speter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2817651Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2917651Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3017651Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3117651Speter * SUCH DAMAGE. 3217651Speter */ 33146081Skientzle 3417651Speter/* $Id: roken-common.h 20867 2007-06-03 21:00:45Z lha $ */ 3533908Ssteve 3633908Ssteve#ifndef __ROKEN_COMMON_H__ 3717651Speter#define __ROKEN_COMMON_H__ 3817651Speter 3917651Speter#ifndef ROKEN_LIB_FUNCTION 4017651Speter#ifdef _WIN32 4117651Speter#define ROKEN_LIB_FUNCTION _stdcall 4217651Speter#else 4317651Speter#define ROKEN_LIB_FUNCTION 4417651Speter#endif 4517651Speter#endif 4617651Speter 4717651Speter#ifdef __cplusplus 4817651Speter#define ROKEN_CPP_START extern "C" { 4917651Speter#define ROKEN_CPP_END } 5017651Speter#else 5117651Speter#define ROKEN_CPP_START 5217651Speter#define ROKEN_CPP_END 5317651Speter#endif 5417651Speter 5517651Speter#ifndef INADDR_NONE 5617651Speter#define INADDR_NONE 0xffffffff 5717651Speter#endif 5817651Speter 5917651Speter#ifndef INADDR_LOOPBACK 6017651Speter#define INADDR_LOOPBACK 0x7f000001 6117651Speter#endif 6233908Ssteve 6317651Speter#ifndef SOMAXCONN 6417651Speter#define SOMAXCONN 5 6533908Ssteve#endif 6617651Speter 6717651Speter#ifndef STDIN_FILENO 6833908Ssteve#define STDIN_FILENO 0 6917651Speter#endif 7017651Speter 7133908Ssteve#ifndef STDOUT_FILENO 7217651Speter#define STDOUT_FILENO 1 7317651Speter#endif 7417651Speter 7517651Speter#ifndef STDERR_FILENO 7617651Speter#define STDERR_FILENO 2 7717651Speter#endif 7817651Speter 7917651Speter#ifndef max 8017651Speter#define max(a,b) (((a)>(b))?(a):(b)) 8133908Ssteve#endif 8233908Ssteve 8333908Ssteve#ifndef min 8433908Ssteve#define min(a,b) (((a)<(b))?(a):(b)) 8533908Ssteve#endif 8617651Speter 8717651Speter#ifndef TRUE 8817651Speter#define TRUE 1 8917651Speter#endif 9017651Speter 9117651Speter#ifndef FALSE 9217651Speter#define FALSE 0 9317651Speter#endif 9417651Speter 9517651Speter#ifndef LOG_DAEMON 9617651Speter#define openlog(id,option,facility) openlog((id),(option)) 9717651Speter#define LOG_DAEMON 0 9833908Ssteve#endif 9933908Ssteve#ifndef LOG_ODELAY 10017651Speter#define LOG_ODELAY 0 10117651Speter#endif 10217651Speter#ifndef LOG_NDELAY 10317651Speter#define LOG_NDELAY 0x08 10433908Ssteve#endif 10517651Speter#ifndef LOG_CONS 10617651Speter#define LOG_CONS 0 10717651Speter#endif 10817651Speter#ifndef LOG_AUTH 10917651Speter#define LOG_AUTH 0 11017651Speter#endif 11117651Speter#ifndef LOG_AUTHPRIV 11217651Speter#define LOG_AUTHPRIV LOG_AUTH 11333908Ssteve#endif 11433908Ssteve 11533908Ssteve#ifndef F_OK 11633908Ssteve#define F_OK 0 11717651Speter#endif 11833908Ssteve 11933908Ssteve#ifndef O_ACCMODE 12017651Speter#define O_ACCMODE 003 12117651Speter#endif 12217651Speter 12317651Speter#ifndef _PATH_DEV 12417651Speter#define _PATH_DEV "/dev/" 12517651Speter#endif 12617651Speter 12717651Speter#ifndef _PATH_DEVNULL 12817651Speter#define _PATH_DEVNULL "/dev/null" 12917651Speter#endif 13017651Speter 13117651Speter#ifndef _PATH_HEQUIV 13233908Ssteve#define _PATH_HEQUIV "/etc/hosts.equiv" 13317651Speter#endif 13417651Speter 13517651Speter#ifndef _PATH_VARRUN 13617651Speter#define _PATH_VARRUN "/var/run/" 13717651Speter#endif 13817651Speter 13917651Speter#ifndef _PATH_BSHELL 14017651Speter#define _PATH_BSHELL "/bin/sh" 14117651Speter#endif 14217651Speter 14317651Speter#ifndef MAXPATHLEN 14417651Speter#define MAXPATHLEN (1024+4) 14517651Speter#endif 14617651Speter 14717651Speter#ifndef SIG_ERR 14817651Speter#define SIG_ERR ((RETSIGTYPE (*)(int))-1) 149250261Sdelphij#endif 150250261Sdelphij 151205471Sdelphij/* 15217651Speter * error code for getipnodeby{name,addr} 15317651Speter */ 15417651Speter 15517651Speter#ifndef HOST_NOT_FOUND 15617651Speter#define HOST_NOT_FOUND 1 15717651Speter#endif 15833908Ssteve 15933908Ssteve#ifndef TRY_AGAIN 16033908Ssteve#define TRY_AGAIN 2 16133908Ssteve#endif 16217651Speter 16317651Speter#ifndef NO_RECOVERY 16417651Speter#define NO_RECOVERY 3 16517651Speter#endif 16617651Speter 16717651Speter#ifndef NO_DATA 16833908Ssteve#define NO_DATA 4 16917651Speter#endif 17017651Speter 17117651Speter#ifndef NO_ADDRESS 17217651Speter#define NO_ADDRESS NO_DATA 17317651Speter#endif 17417651Speter 17517651Speter/* 17617651Speter * error code for getaddrinfo 17717651Speter */ 17817651Speter 17917651Speter#ifndef EAI_NOERROR 18017651Speter#define EAI_NOERROR 0 /* no error */ 18117651Speter#endif 18217651Speter 18317651Speter#ifndef EAI_NONAME 18417651Speter 18517651Speter#define EAI_ADDRFAMILY 1 /* address family for nodename not supported */ 18617651Speter#define EAI_AGAIN 2 /* temporary failure in name resolution */ 18717651Speter#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ 18817651Speter#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ 18917651Speter#define EAI_FAMILY 5 /* ai_family not supported */ 19017651Speter#define EAI_MEMORY 6 /* memory allocation failure */ 19117651Speter#define EAI_NODATA 7 /* no address associated with nodename */ 19217651Speter#define EAI_NONAME 8 /* nodename nor servname provided, or not known */ 19317651Speter#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ 19417651Speter#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ 19517651Speter#define EAI_SYSTEM 11 /* system error returned in errno */ 19617651Speter 19717651Speter#endif /* EAI_NONAME */ 19817651Speter 19917651Speter/* flags for getaddrinfo() */ 20017651Speter 20117651Speter#ifndef AI_PASSIVE 202205471Sdelphij#define AI_PASSIVE 0x01 20317651Speter#define AI_CANONNAME 0x02 20417651Speter#endif /* AI_PASSIVE */ 20517651Speter 20617651Speter#ifndef AI_NUMERICHOST 207205471Sdelphij#define AI_NUMERICHOST 0x04 20817651Speter#endif 20917651Speter 21017651Speter/* flags for getnameinfo() */ 21117651Speter 21217651Speter#ifndef NI_DGRAM 21317651Speter#define NI_DGRAM 0x01 21417651Speter#define NI_NAMEREQD 0x02 21517651Speter#define NI_NOFQDN 0x04 21617651Speter#define NI_NUMERICHOST 0x08 217205471Sdelphij#define NI_NUMERICSERV 0x10 21817651Speter#endif 21917651Speter 22017651Speter/* 22117651Speter * constants for getnameinfo 222205471Sdelphij */ 22317651Speter 22417651Speter#ifndef NI_MAXHOST 22517651Speter#define NI_MAXHOST 1025 22617651Speter#define NI_MAXSERV 32 22717651Speter#endif 22817651Speter 22917651Speter/* 23017651Speter * constants for inet_ntop 23117651Speter */ 23233908Ssteve 23317651Speter#ifndef INET_ADDRSTRLEN 23417651Speter#define INET_ADDRSTRLEN 16 23517651Speter#endif 23633908Ssteve 23717651Speter#ifndef INET6_ADDRSTRLEN 23817651Speter#define INET6_ADDRSTRLEN 46 23917651Speter#endif 24017651Speter 24117651Speter/* 24217651Speter * for shutdown(2) 24317651Speter */ 24417651Speter 24517651Speter#ifndef SHUT_RD 24617651Speter#define SHUT_RD 0 24717651Speter#endif 24842471Speter 249205471Sdelphij#ifndef SHUT_WR 25042471Speter#define SHUT_WR 1 25142471Speter#endif 25242471Speter 25342471Speter#ifndef SHUT_RDWR 25442471Speter#define SHUT_RDWR 2 255205471Sdelphij#endif 25642471Speter 25717651Speter#ifndef HAVE___ATTRIBUTE__ 25817651Speter#define __attribute__(x) 25917651Speter#endif 26017651Speter 26117651SpeterROKEN_CPP_START 26233908Ssteve 26317651Speter#ifndef IRIX4 /* fix for compiler bug */ 26417651Speter#ifdef RETSIGTYPE 26517651Spetertypedef RETSIGTYPE (*SigAction)(int); 26617651SpeterSigAction signal(int iSig, SigAction pAction); /* BSD compatible */ 26717651Speter#endif 26817651Speter#endif 26917651Speter 27033908Ssteveint ROKEN_LIB_FUNCTION 27117651Spetersimple_execve(const char*, char*const[], char*const[]); 27217651Speter 27317651Speterint ROKEN_LIB_FUNCTION 27417651Spetersimple_execve_timed(const char *, char *const[], 27517651Speter char *const [], time_t (*)(void *), 27617651Speter void *, time_t); 27733908Ssteveint ROKEN_LIB_FUNCTION 27817651Spetersimple_execvp(const char*, char *const[]); 27917651Speter 28017651Speterint ROKEN_LIB_FUNCTION 28117651Spetersimple_execvp_timed(const char *, char *const[], 28217651Speter time_t (*)(void *), void *, time_t); 28317651Speterint ROKEN_LIB_FUNCTION 28417651Spetersimple_execlp(const char*, ...); 28533908Ssteve 28617651Speterint ROKEN_LIB_FUNCTION 28717651Spetersimple_execle(const char*, ...); 28817651Speter 28917651Speterint ROKEN_LIB_FUNCTION 29017651Spetersimple_execl(const char *file, ...); 29117651Speter 29217651Speterint ROKEN_LIB_FUNCTION 29317651Speterwait_for_process(pid_t); 29417651Speter 29517651Speterint ROKEN_LIB_FUNCTION 29617651Speterwait_for_process_timed(pid_t, time_t (*)(void *), 29717651Speter void *, time_t); 29817651Speterint ROKEN_LIB_FUNCTION 29917651Speterpipe_execv(FILE**, FILE**, FILE**, const char*, ...); 30017651Speter 30117651Spetervoid ROKEN_LIB_FUNCTION 30217651Speterprint_version(const char *); 30317651Speter 30417651Speterssize_t ROKEN_LIB_FUNCTION 30517651Spetereread (int fd, void *buf, size_t nbytes); 30617651Speter 30717651Speterssize_t ROKEN_LIB_FUNCTION 30817651Speterewrite (int fd, const void *buf, size_t nbytes); 30933908Ssteve 31033908Sstevestruct hostent; 31133908Ssteve 31233908Ssteveconst char * ROKEN_LIB_FUNCTION 31333908Sstevehostent_find_fqdn (const struct hostent *); 31417651Speter 31517651Spetervoid ROKEN_LIB_FUNCTION 31617651Speteresetenv(const char *, const char *, int); 31733908Ssteve 31833908Sstevevoid ROKEN_LIB_FUNCTION 31933908Sstevesocket_set_address_and_port (struct sockaddr *, const void *, int); 32033908Ssteve 32133908Sstevesize_t ROKEN_LIB_FUNCTION 32233908Sstevesocket_addr_size (const struct sockaddr *); 32333908Ssteve 32433908Sstevevoid ROKEN_LIB_FUNCTION 32533908Sstevesocket_set_any (struct sockaddr *, int); 32633908Ssteve 32733908Sstevesize_t ROKEN_LIB_FUNCTION 32833908Sstevesocket_sockaddr_size (const struct sockaddr *); 32933908Ssteve 33033908Sstevevoid * ROKEN_LIB_FUNCTION 33133908Sstevesocket_get_address (struct sockaddr *); 33233908Ssteve 33333908Ssteveint ROKEN_LIB_FUNCTION 33433908Sstevesocket_get_port (const struct sockaddr *); 335131380Stjr 33633908Sstevevoid ROKEN_LIB_FUNCTION 33733908Sstevesocket_set_port (struct sockaddr *, int); 33833908Ssteve 339131380Stjrvoid ROKEN_LIB_FUNCTION 340131380Stjrsocket_set_portrange (int, int, int); 34133908Ssteve 34233908Sstevevoid ROKEN_LIB_FUNCTION 34333908Sstevesocket_set_debug (int); 34433908Ssteve 345131380Stjrvoid ROKEN_LIB_FUNCTION 346131380Stjrsocket_set_tos (int, int); 34733908Ssteve 34833908Sstevevoid ROKEN_LIB_FUNCTION 349206924Sdelphijsocket_set_reuseaddr (int, int); 35033908Ssteve 351131380Stjrvoid ROKEN_LIB_FUNCTION 352131380Stjrsocket_set_ipv6only (int, int); 35333908Ssteve 35433908Sstevechar ** ROKEN_LIB_FUNCTION 355206924Sdelphijvstrcollect(va_list *ap); 356206924Sdelphij 35733908Sstevechar ** ROKEN_LIB_FUNCTION 358131380Stjrstrcollect(char *first, ...); 359131380Stjr 36033908Sstevevoid ROKEN_LIB_FUNCTION 36133908Sstevetimevalfix(struct timeval *t1); 36233908Ssteve 36333908Sstevevoid ROKEN_LIB_FUNCTION 364131380Stjrtimevaladd(struct timeval *t1, const struct timeval *t2); 365131380Stjr 36633908Sstevevoid ROKEN_LIB_FUNCTION 36733908Sstevetimevalsub(struct timeval *t1, const struct timeval *t2); 36833908Ssteve 36933908Sstevechar *ROKEN_LIB_FUNCTION 370131380Stjrpid_file_write (const char *progname); 371131380Stjr 37233908Sstevevoid ROKEN_LIB_FUNCTION 37333908Sstevepid_file_delete (char **); 37433908Ssteve 37533908Ssteveint ROKEN_LIB_FUNCTION 37633908Ssteveread_environment(const char *file, char ***env); 37733908Ssteve 37833908Sstevevoid ROKEN_LIB_FUNCTION 37917651Speterfree_environment(char **); 38017651Speter 381206924Sdelphijvoid ROKEN_LIB_FUNCTION 38217651Speterwarnerr(int doerrno, const char *fmt, va_list ap) 38317651Speter __attribute__ ((format (printf, 2, 0))); 38417651Speter 38517651Spetervoid * ROKEN_LIB_FUNCTION 38617651Speterrk_realloc(void *, size_t); 38717651Speter 38817651Speterstruct rk_strpool; 38917651Speter 39017651Speterchar * ROKEN_LIB_FUNCTION 39117651Speterrk_strpoolcollect(struct rk_strpool *); 39217651Speter 39317651Speterstruct rk_strpool * ROKEN_LIB_FUNCTION 39417651Speterrk_strpoolprintf(struct rk_strpool *, const char *, ...) 39517651Speter __attribute__ ((format (printf, 2, 3))); 39617651Speter 39717651Spetervoid ROKEN_LIB_FUNCTION 39842471Speterrk_strpoolfree(struct rk_strpool *); 39917651Speter 40017651Spetervoid ROKEN_LIB_FUNCTION 40117651Speterrk_dumpdata (const char *, const void *, size_t); 40217651Speter 40317651SpeterROKEN_CPP_END 40417651Speter 40517651Speter#endif /* __ROKEN_COMMON_H__ */ 40617651Speter