roken.h.in revision 90926
155682Smarkm/* -*- C -*- */ 255682Smarkm/* 372445Sassar * Copyright (c) 1995 - 2001 Kungliga Tekniska H�gskolan 455682Smarkm * (Royal Institute of Technology, Stockholm, Sweden). 555682Smarkm * All rights reserved. 655682Smarkm * 755682Smarkm * Redistribution and use in source and binary forms, with or without 855682Smarkm * modification, are permitted provided that the following conditions 955682Smarkm * are met: 1055682Smarkm * 1155682Smarkm * 1. Redistributions of source code must retain the above copyright 1255682Smarkm * notice, this list of conditions and the following disclaimer. 1355682Smarkm * 1455682Smarkm * 2. Redistributions in binary form must reproduce the above copyright 1555682Smarkm * notice, this list of conditions and the following disclaimer in the 1655682Smarkm * documentation and/or other materials provided with the distribution. 1755682Smarkm * 1855682Smarkm * 3. Neither the name of the Institute nor the names of its contributors 1955682Smarkm * may be used to endorse or promote products derived from this software 2055682Smarkm * without specific prior written permission. 2155682Smarkm * 2255682Smarkm * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 2355682Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2455682Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2555682Smarkm * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 2655682Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2755682Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2855682Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2955682Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3055682Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3155682Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3255682Smarkm * SUCH DAMAGE. 3355682Smarkm */ 3455682Smarkm 3590926Snectar/* $Id: roken.h.in,v 1.162 2001/10/21 23:24:33 assar Exp $ */ 3655682Smarkm 3755682Smarkm#include <stdio.h> 3855682Smarkm#include <stdlib.h> 3955682Smarkm#include <stdarg.h> 4055682Smarkm#include <string.h> 4155682Smarkm#include <signal.h> 4272445Sassar 4372445Sassar#ifdef _AIX 4472445Sassarstruct ether_addr; 4572445Sassarstruct sockaddr_dl; 4672445Sassar#endif 4755682Smarkm#ifdef HAVE_SYS_PARAM_H 4855682Smarkm#include <sys/param.h> 4955682Smarkm#endif 5078527Sassar#ifdef HAVE_INTTYPES_H 5178527Sassar#include <inttypes.h> 5278527Sassar#endif 5355682Smarkm#ifdef HAVE_SYS_TYPES_H 5455682Smarkm#include <sys/types.h> 5555682Smarkm#endif 5678527Sassar#ifdef HAVE_SYS_BITYPES_H 5778527Sassar#include <sys/bitypes.h> 5878527Sassar#endif 5978527Sassar#ifdef HAVE_BIND_BITYPES_H 6078527Sassar#include <bind/bitypes.h> 6178527Sassar#endif 6278527Sassar#ifdef HAVE_NETINET_IN6_MACHTYPES_H 6378527Sassar#include <netinet/in6_machtypes.h> 6478527Sassar#endif 6555682Smarkm#ifdef HAVE_UNISTD_H 6655682Smarkm#include <unistd.h> 6755682Smarkm#endif 6855682Smarkm#ifdef HAVE_SYS_SOCKET_H 6955682Smarkm#include <sys/socket.h> 7055682Smarkm#endif 7155682Smarkm#ifdef HAVE_SYS_UIO_H 7255682Smarkm#include <sys/uio.h> 7355682Smarkm#endif 7455682Smarkm#ifdef HAVE_GRP_H 7555682Smarkm#include <grp.h> 7655682Smarkm#endif 7755682Smarkm#ifdef HAVE_SYS_STAT_H 7855682Smarkm#include <sys/stat.h> 7955682Smarkm#endif 8055682Smarkm#ifdef HAVE_NETINET_IN_H 8155682Smarkm#include <netinet/in.h> 8255682Smarkm#endif 8355682Smarkm#ifdef HAVE_NETINET_IN6_H 8455682Smarkm#include <netinet/in6.h> 8555682Smarkm#endif 8655682Smarkm#ifdef HAVE_NETINET6_IN6_H 8755682Smarkm#include <netinet6/in6.h> 8855682Smarkm#endif 8955682Smarkm#ifdef HAVE_ARPA_INET_H 9055682Smarkm#include <arpa/inet.h> 9155682Smarkm#endif 9255682Smarkm#ifdef HAVE_NETDB_H 9355682Smarkm#include <netdb.h> 9455682Smarkm#endif 9590926Snectar#ifdef HAVE_ARPA_NAMESER_H 9690926Snectar#include <arpa/nameser.h> 9790926Snectar#endif 9890926Snectar#ifdef HAVE_RESOLV_H 9990926Snectar#include <resolv.h> 10090926Snectar#endif 10155682Smarkm#ifdef HAVE_SYSLOG_H 10255682Smarkm#include <syslog.h> 10355682Smarkm#endif 10455682Smarkm#ifdef HAVE_FCNTL_H 10555682Smarkm#include <fcntl.h> 10655682Smarkm#endif 10755682Smarkm#ifdef HAVE_ERRNO_H 10855682Smarkm#include <errno.h> 10955682Smarkm#endif 11055682Smarkm#ifdef HAVE_ERR_H 11155682Smarkm#include <err.h> 11255682Smarkm#endif 11355682Smarkm#ifdef HAVE_TERMIOS_H 11455682Smarkm#include <termios.h> 11555682Smarkm#endif 11655682Smarkm#if defined(HAVE_SYS_IOCTL_H) && SunOS != 40 11755682Smarkm#include <sys/ioctl.h> 11855682Smarkm#endif 11955682Smarkm#ifdef TIME_WITH_SYS_TIME 12055682Smarkm#include <sys/time.h> 12155682Smarkm#include <time.h> 12255682Smarkm#elif defined(HAVE_SYS_TIME_H) 12355682Smarkm#include <sys/time.h> 12455682Smarkm#else 12555682Smarkm#include <time.h> 12655682Smarkm#endif 12755682Smarkm 12855682Smarkm#ifdef HAVE_PATHS_H 12955682Smarkm#include <paths.h> 13055682Smarkm#endif 13155682Smarkm 13255682Smarkm 13355682Smarkm#ifndef ROKEN_LIB_FUNCTION 13455682Smarkm#if defined(__BORLANDC__) 13555682Smarkm#define ROKEN_LIB_FUNCTION /* not-ready-definition-yet */ 13655682Smarkm#elif defined(_MSC_VER) 13755682Smarkm#define ROKEN_LIB_FUNCTION /* not-ready-definition-yet2 */ 13855682Smarkm#else 13955682Smarkm#define ROKEN_LIB_FUNCTION 14055682Smarkm#endif 14155682Smarkm#endif 14255682Smarkm 14355682Smarkm#include <roken-common.h> 14455682Smarkm 14572445SassarROKEN_CPP_START 14672445Sassar 14755682Smarkm#if !defined(HAVE_SETSID) && defined(HAVE__SETSID) 14855682Smarkm#define setsid _setsid 14955682Smarkm#endif 15055682Smarkm 15155682Smarkm#ifndef HAVE_PUTENV 15255682Smarkmint putenv(const char *string); 15355682Smarkm#endif 15455682Smarkm 15555682Smarkm#if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO) 15655682Smarkmint setenv(const char *var, const char *val, int rewrite); 15755682Smarkm#endif 15855682Smarkm 15955682Smarkm#if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO) 16055682Smarkmvoid unsetenv(const char *name); 16155682Smarkm#endif 16255682Smarkm 16355682Smarkm#if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO) 16455682Smarkmchar *getusershell(void); 16555682Smarkmvoid endusershell(void); 16655682Smarkm#endif 16755682Smarkm 16855682Smarkm#if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO) 16955682Smarkmint snprintf (char *str, size_t sz, const char *format, ...) 17055682Smarkm __attribute__ ((format (printf, 3, 4))); 17155682Smarkm#endif 17255682Smarkm 17355682Smarkm#if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO) 17455682Smarkmint vsnprintf (char *str, size_t sz, const char *format, va_list ap) 17555682Smarkm __attribute__((format (printf, 3, 0))); 17655682Smarkm#endif 17755682Smarkm 17855682Smarkm#if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO) 17955682Smarkmint asprintf (char **ret, const char *format, ...) 18055682Smarkm __attribute__ ((format (printf, 2, 3))); 18155682Smarkm#endif 18255682Smarkm 18355682Smarkm#if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO) 18455682Smarkmint vasprintf (char **ret, const char *format, va_list ap) 18555682Smarkm __attribute__((format (printf, 2, 0))); 18655682Smarkm#endif 18755682Smarkm 18855682Smarkm#if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO) 18955682Smarkmint asnprintf (char **ret, size_t max_sz, const char *format, ...) 19055682Smarkm __attribute__ ((format (printf, 3, 4))); 19155682Smarkm#endif 19255682Smarkm 19355682Smarkm#if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO) 19455682Smarkmint vasnprintf (char **ret, size_t max_sz, const char *format, va_list ap) 19555682Smarkm __attribute__((format (printf, 3, 0))); 19655682Smarkm#endif 19755682Smarkm 19855682Smarkm#ifndef HAVE_STRDUP 19955682Smarkmchar * strdup(const char *old); 20055682Smarkm#endif 20155682Smarkm 20255682Smarkm#ifndef HAVE_STRNDUP 20355682Smarkmchar * strndup(const char *old, size_t sz); 20455682Smarkm#endif 20555682Smarkm 20655682Smarkm#ifndef HAVE_STRLWR 20755682Smarkmchar * strlwr(char *); 20855682Smarkm#endif 20955682Smarkm 21055682Smarkm#ifndef HAVE_STRNLEN 21155682Smarkmsize_t strnlen(const char*, size_t); 21255682Smarkm#endif 21355682Smarkm 21455682Smarkm#if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO) 21555682Smarkmchar *strsep(char**, const char*); 21655682Smarkm#endif 21755682Smarkm 21872445Sassar#if !defined(HAVE_STRSEP_COPY) || defined(NEED_STRSEP_COPY_PROTO) 21972445Sassarssize_t strsep_copy(const char**, const char*, char*, size_t); 22072445Sassar#endif 22172445Sassar 22255682Smarkm#ifndef HAVE_STRCASECMP 22355682Smarkmint strcasecmp(const char *s1, const char *s2); 22455682Smarkm#endif 22555682Smarkm 22655682Smarkm#ifdef NEED_FCLOSE_PROTO 22755682Smarkmint fclose(FILE *); 22855682Smarkm#endif 22955682Smarkm 23055682Smarkm#ifdef NEED_STRTOK_R_PROTO 23155682Smarkmchar *strtok_r(char *s1, const char *s2, char **lasts); 23255682Smarkm#endif 23355682Smarkm 23455682Smarkm#ifndef HAVE_STRUPR 23555682Smarkmchar * strupr(char *); 23655682Smarkm#endif 23755682Smarkm 23855682Smarkm#ifndef HAVE_STRLCPY 23955682Smarkmsize_t strlcpy (char *dst, const char *src, size_t dst_sz); 24055682Smarkm#endif 24155682Smarkm 24255682Smarkm#ifndef HAVE_STRLCAT 24355682Smarkmsize_t strlcat (char *dst, const char *src, size_t dst_sz); 24455682Smarkm#endif 24555682Smarkm 24655682Smarkm#ifndef HAVE_GETDTABLESIZE 24755682Smarkmint getdtablesize(void); 24855682Smarkm#endif 24955682Smarkm 25055682Smarkm#if !defined(HAVE_STRERROR) && !defined(strerror) 25155682Smarkmchar *strerror(int eno); 25255682Smarkm#endif 25355682Smarkm 25455682Smarkm#if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO) 25555682Smarkm/* This causes a fatal error under Psoriasis */ 25655682Smarkm#if !(defined(SunOS) && (SunOS >= 50)) 25755682Smarkmconst char *hstrerror(int herr); 25855682Smarkm#endif 25955682Smarkm#endif 26055682Smarkm 26155682Smarkm#ifndef HAVE_H_ERRNO_DECLARATION 26255682Smarkmextern int h_errno; 26355682Smarkm#endif 26455682Smarkm 26555682Smarkm#if !defined(HAVE_INET_ATON) || defined(NEED_INET_ATON_PROTO) 26655682Smarkmint inet_aton(const char *cp, struct in_addr *adr); 26755682Smarkm#endif 26855682Smarkm 26955682Smarkm#ifndef HAVE_INET_NTOP 27055682Smarkmconst char * 27155682Smarkminet_ntop(int af, const void *src, char *dst, size_t size); 27255682Smarkm#endif 27355682Smarkm 27455682Smarkm#ifndef HAVE_INET_PTON 27555682Smarkmint 27655682Smarkminet_pton(int af, const char *src, void *dst); 27755682Smarkm#endif 27855682Smarkm 27955682Smarkm#if !defined(HAVE_GETCWD) 28055682Smarkmchar* getcwd(char *path, size_t size); 28155682Smarkm#endif 28255682Smarkm 28355682Smarkm#ifdef HAVE_PWD_H 28455682Smarkm#include <pwd.h> 28555682Smarkmstruct passwd *k_getpwnam (const char *user); 28655682Smarkmstruct passwd *k_getpwuid (uid_t uid); 28755682Smarkm#endif 28855682Smarkm 28955682Smarkmconst char *get_default_username (void); 29055682Smarkm 29155682Smarkm#ifndef HAVE_SETEUID 29255682Smarkmint seteuid(uid_t euid); 29355682Smarkm#endif 29455682Smarkm 29555682Smarkm#ifndef HAVE_SETEGID 29655682Smarkmint setegid(gid_t egid); 29755682Smarkm#endif 29855682Smarkm 29955682Smarkm#ifndef HAVE_LSTAT 30055682Smarkmint lstat(const char *path, struct stat *buf); 30155682Smarkm#endif 30255682Smarkm 30355682Smarkm#if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO) 30455682Smarkmint mkstemp(char *); 30555682Smarkm#endif 30655682Smarkm 30755682Smarkm#ifndef HAVE_CGETENT 30855682Smarkmint cgetent(char **buf, char **db_array, const char *name); 30955682Smarkmint cgetstr(char *buf, const char *cap, char **str); 31055682Smarkm#endif 31155682Smarkm 31255682Smarkm#ifndef HAVE_INITGROUPS 31355682Smarkmint initgroups(const char *name, gid_t basegid); 31455682Smarkm#endif 31555682Smarkm 31655682Smarkm#ifndef HAVE_FCHOWN 31755682Smarkmint fchown(int fd, uid_t owner, gid_t group); 31855682Smarkm#endif 31955682Smarkm 32055682Smarkm#ifndef HAVE_DAEMON 32155682Smarkmint daemon(int nochdir, int noclose); 32255682Smarkm#endif 32355682Smarkm 32455682Smarkm#ifndef HAVE_INNETGR 32555682Smarkmint innetgr(const char *netgroup, const char *machine, 32655682Smarkm const char *user, const char *domain); 32755682Smarkm#endif 32855682Smarkm 32955682Smarkm#ifndef HAVE_CHOWN 33055682Smarkmint chown(const char *path, uid_t owner, gid_t group); 33155682Smarkm#endif 33255682Smarkm 33355682Smarkm#ifndef HAVE_RCMD 33455682Smarkmint rcmd(char **ahost, unsigned short inport, const char *locuser, 33555682Smarkm const char *remuser, const char *cmd, int *fd2p); 33655682Smarkm#endif 33755682Smarkm 33855682Smarkm#if !defined(HAVE_INNETGR) || defined(NEED_INNETGR_PROTO) 33955682Smarkmint innetgr(const char*, const char*, const char*, const char*); 34055682Smarkm#endif 34155682Smarkm 34255682Smarkm#ifndef HAVE_IRUSEROK 34355682Smarkmint iruserok(unsigned raddr, int superuser, const char *ruser, 34455682Smarkm const char *luser); 34555682Smarkm#endif 34655682Smarkm 34755682Smarkm#if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO) 34855682Smarkmint gethostname(char *name, int namelen); 34955682Smarkm#endif 35055682Smarkm 35155682Smarkm#ifndef HAVE_WRITEV 35255682Smarkmssize_t 35355682Smarkmwritev(int d, const struct iovec *iov, int iovcnt); 35455682Smarkm#endif 35555682Smarkm 35655682Smarkm#ifndef HAVE_READV 35755682Smarkmssize_t 35855682Smarkmreadv(int d, const struct iovec *iov, int iovcnt); 35955682Smarkm#endif 36055682Smarkm 36155682Smarkm#ifndef HAVE_MKSTEMP 36255682Smarkmint 36355682Smarkmmkstemp(char *template); 36455682Smarkm#endif 36555682Smarkm 36672445Sassar#ifndef HAVE_PIDFILE 36772445Sassarvoid pidfile (const char*); 36872445Sassar#endif 36972445Sassar 37078527Sassar#ifndef HAVE_BSWAP32 37178527Sassarunsigned int bswap32(unsigned int); 37278527Sassar#endif 37378527Sassar 37478527Sassar#ifndef HAVE_BSWAP16 37578527Sassarunsigned short bswap16(unsigned short); 37678527Sassar#endif 37778527Sassar 37855682Smarkm#ifndef HAVE_FLOCK 37955682Smarkm#ifndef LOCK_SH 38055682Smarkm#define LOCK_SH 1 /* Shared lock */ 38155682Smarkm#endif 38255682Smarkm#ifndef LOCK_EX 38355682Smarkm#define LOCK_EX 2 /* Exclusive lock */ 38455682Smarkm#endif 38555682Smarkm#ifndef LOCK_NB 38655682Smarkm#define LOCK_NB 4 /* Don't block when locking */ 38755682Smarkm#endif 38855682Smarkm#ifndef LOCK_UN 38955682Smarkm#define LOCK_UN 8 /* Unlock */ 39055682Smarkm#endif 39155682Smarkm 39255682Smarkmint flock(int fd, int operation); 39355682Smarkm#endif /* HAVE_FLOCK */ 39455682Smarkm 39555682Smarkmtime_t tm2time (struct tm tm, int local); 39655682Smarkm 39755682Smarkmint unix_verify_user(char *user, char *password); 39855682Smarkm 39955682Smarkmvoid mini_inetd (int port); 40055682Smarkm 40155682Smarkmint roken_concat (char *s, size_t len, ...); 40255682Smarkm 40355682Smarkmsize_t roken_mconcat (char **s, size_t max_len, ...); 40455682Smarkm 40555682Smarkmint roken_vconcat (char *s, size_t len, va_list args); 40655682Smarkm 40755682Smarkmsize_t roken_vmconcat (char **s, size_t max_len, va_list args); 40855682Smarkm 40955682Smarkmssize_t net_write (int fd, const void *buf, size_t nbytes); 41055682Smarkm 41155682Smarkmssize_t net_read (int fd, void *buf, size_t nbytes); 41255682Smarkm 41355682Smarkmint issuid(void); 41455682Smarkm 41555682Smarkm#ifndef HAVE_STRUCT_WINSIZE 41655682Smarkmstruct winsize { 41755682Smarkm unsigned short ws_row, ws_col; 41855682Smarkm unsigned short ws_xpixel, ws_ypixel; 41955682Smarkm}; 42055682Smarkm#endif 42155682Smarkm 42255682Smarkmint get_window_size(int fd, struct winsize *); 42355682Smarkm 42455682Smarkm#ifndef HAVE_VSYSLOG 42555682Smarkmvoid vsyslog(int pri, const char *fmt, va_list ap); 42655682Smarkm#endif 42755682Smarkm 42855682Smarkm#ifndef HAVE_OPTARG_DECLARATION 42955682Smarkmextern char *optarg; 43055682Smarkm#endif 43155682Smarkm#ifndef HAVE_OPTIND_DECLARATION 43255682Smarkmextern int optind; 43355682Smarkm#endif 43455682Smarkm#ifndef HAVE_OPTERR_DECLARATION 43555682Smarkmextern int opterr; 43655682Smarkm#endif 43755682Smarkm 43855682Smarkm#ifndef HAVE___PROGNAME_DECLARATION 43955682Smarkmextern const char *__progname; 44055682Smarkm#endif 44155682Smarkm 44255682Smarkm#ifndef HAVE_ENVIRON_DECLARATION 44355682Smarkmextern char **environ; 44455682Smarkm#endif 44555682Smarkm 44655682Smarkm#ifndef HAVE_GETIPNODEBYNAME 44755682Smarkmstruct hostent * 44855682Smarkmgetipnodebyname (const char *name, int af, int flags, int *error_num); 44955682Smarkm#endif 45055682Smarkm 45155682Smarkm#ifndef HAVE_GETIPNODEBYADDR 45255682Smarkmstruct hostent * 45355682Smarkmgetipnodebyaddr (const void *src, size_t len, int af, int *error_num); 45455682Smarkm#endif 45555682Smarkm 45655682Smarkm#ifndef HAVE_FREEHOSTENT 45755682Smarkmvoid 45855682Smarkmfreehostent (struct hostent *h); 45955682Smarkm#endif 46055682Smarkm 46155682Smarkm#ifndef HAVE_COPYHOSTENT 46255682Smarkmstruct hostent * 46355682Smarkmcopyhostent (const struct hostent *h); 46455682Smarkm#endif 46555682Smarkm 46655682Smarkm#ifndef HAVE_SOCKLEN_T 46755682Smarkmtypedef int socklen_t; 46855682Smarkm#endif 46955682Smarkm 47055682Smarkm#ifndef HAVE_STRUCT_SOCKADDR_STORAGE 47155682Smarkm 47255682Smarkm#ifndef HAVE_SA_FAMILY_T 47355682Smarkmtypedef unsigned short sa_family_t; 47455682Smarkm#endif 47555682Smarkm 47655682Smarkm#ifdef HAVE_IPV6 47755682Smarkm#define _SS_MAXSIZE sizeof(struct sockaddr_in6) 47855682Smarkm#else 47955682Smarkm#define _SS_MAXSIZE sizeof(struct sockaddr_in) 48055682Smarkm#endif 48155682Smarkm 48255682Smarkm#define _SS_ALIGNSIZE sizeof(unsigned long) 48355682Smarkm 48455682Smarkm#if HAVE_STRUCT_SOCKADDR_SA_LEN 48555682Smarkm 48655682Smarkmtypedef unsigned char roken_sa_family_t; 48755682Smarkm 48872445Sassar#define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t) - sizeof(unsigned char)) % _SS_ALIGNSIZE) 48955682Smarkm#define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + sizeof(unsigned char) + _SS_PAD1SIZE + _SS_ALIGNSIZE)) 49055682Smarkm 49155682Smarkmstruct sockaddr_storage { 49255682Smarkm unsigned char ss_len; 49355682Smarkm roken_sa_family_t ss_family; 49455682Smarkm char __ss_pad1[_SS_PAD1SIZE]; 49555682Smarkm unsigned long __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1]; 49655682Smarkm}; 49755682Smarkm 49855682Smarkm#else /* !HAVE_STRUCT_SOCKADDR_SA_LEN */ 49955682Smarkm 50055682Smarkmtypedef unsigned short roken_sa_family_t; 50155682Smarkm 50272445Sassar#define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t)) % _SS_ALIGNSIZE) 50355682Smarkm#define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + _SS_PAD1SIZE + _SS_ALIGNSIZE)) 50455682Smarkm 50555682Smarkmstruct sockaddr_storage { 50655682Smarkm roken_sa_family_t ss_family; 50755682Smarkm char __ss_pad1[_SS_PAD1SIZE]; 50855682Smarkm unsigned long __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1]; 50955682Smarkm}; 51055682Smarkm 51155682Smarkm#endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ 51255682Smarkm 51355682Smarkm#endif /* HAVE_STRUCT_SOCKADDR_STORAGE */ 51455682Smarkm 51555682Smarkm#ifndef HAVE_STRUCT_ADDRINFO 51655682Smarkmstruct addrinfo { 51755682Smarkm int ai_flags; 51855682Smarkm int ai_family; 51955682Smarkm int ai_socktype; 52055682Smarkm int ai_protocol; 52155682Smarkm size_t ai_addrlen; 52255682Smarkm char *ai_canonname; 52355682Smarkm struct sockaddr *ai_addr; 52455682Smarkm struct addrinfo *ai_next; 52555682Smarkm}; 52655682Smarkm#endif 52755682Smarkm 52855682Smarkm#ifndef HAVE_GETADDRINFO 52955682Smarkmint 53055682Smarkmgetaddrinfo(const char *nodename, 53155682Smarkm const char *servname, 53255682Smarkm const struct addrinfo *hints, 53355682Smarkm struct addrinfo **res); 53455682Smarkm#endif 53555682Smarkm 53655682Smarkm#ifndef HAVE_GETNAMEINFO 53755682Smarkmint getnameinfo(const struct sockaddr *sa, socklen_t salen, 53855682Smarkm char *host, size_t hostlen, 53955682Smarkm char *serv, size_t servlen, 54055682Smarkm int flags); 54155682Smarkm#endif 54255682Smarkm 54355682Smarkm#ifndef HAVE_FREEADDRINFO 54455682Smarkmvoid 54555682Smarkmfreeaddrinfo(struct addrinfo *ai); 54655682Smarkm#endif 54755682Smarkm 54855682Smarkm#ifndef HAVE_GAI_STRERROR 54955682Smarkmchar * 55055682Smarkmgai_strerror(int ecode); 55155682Smarkm#endif 55255682Smarkm 55355682Smarkmint 55455682Smarkmgetnameinfo_verified(const struct sockaddr *sa, socklen_t salen, 55555682Smarkm char *host, size_t hostlen, 55655682Smarkm char *serv, size_t servlen, 55755682Smarkm int flags); 55855682Smarkm 55972445Sassarint roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **); 56072445Sassarint roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **); 56157419Smarkm 56255682Smarkm#ifndef HAVE_STRFTIME 56355682Smarkmsize_t 56455682Smarkmstrftime (char *buf, size_t maxsize, const char *format, 56555682Smarkm const struct tm *tm); 56655682Smarkm#endif 56755682Smarkm 56855682Smarkm#ifndef HAVE_STRPTIME 56955682Smarkmchar * 57055682Smarkmstrptime (const char *buf, const char *format, struct tm *timeptr); 57155682Smarkm#endif 57255682Smarkm 57390926Snectar#ifndef HAVE_EMALLOC 57490926Snectarvoid *emalloc (size_t); 57590926Snectar#endif 57690926Snectar#ifndef HAVE_ECALLOC 57790926Snectarvoid *ecalloc(size_t num, size_t sz); 57890926Snectar#endif 57990926Snectar#ifndef HAVE_EREALLOC 58090926Snectarvoid *erealloc (void *, size_t); 58190926Snectar#endif 58290926Snectar#ifndef HAVE_ESTRDUP 58390926Snectarchar *estrdup (const char *); 58490926Snectar#endif 58590926Snectar 58655682Smarkm/* 58755682Smarkm * kludges and such 58855682Smarkm */ 58955682Smarkm 59055682Smarkm#if 1 59155682Smarkmint roken_gethostby_setup(const char*, const char*); 59255682Smarkmstruct hostent* roken_gethostbyname(const char*); 59355682Smarkmstruct hostent* roken_gethostbyaddr(const void*, size_t, int); 59455682Smarkm#else 59555682Smarkm#ifdef GETHOSTBYNAME_PROTO_COMPATIBLE 59655682Smarkm#define roken_gethostbyname(x) gethostbyname(x) 59755682Smarkm#else 59855682Smarkm#define roken_gethostbyname(x) gethostbyname((char *)x) 59955682Smarkm#endif 60055682Smarkm 60155682Smarkm#ifdef GETHOSTBYADDR_PROTO_COMPATIBLE 60255682Smarkm#define roken_gethostbyaddr(a, l, t) gethostbyaddr(a, l, t) 60355682Smarkm#else 60455682Smarkm#define roken_gethostbyaddr(a, l, t) gethostbyaddr((char *)a, l, t) 60555682Smarkm#endif 60655682Smarkm#endif 60755682Smarkm 60855682Smarkm#ifdef GETSERVBYNAME_PROTO_COMPATIBLE 60955682Smarkm#define roken_getservbyname(x,y) getservbyname(x,y) 61055682Smarkm#else 61155682Smarkm#define roken_getservbyname(x,y) getservbyname((char *)x, (char *)y) 61255682Smarkm#endif 61355682Smarkm 61455682Smarkm#ifdef OPENLOG_PROTO_COMPATIBLE 61555682Smarkm#define roken_openlog(a,b,c) openlog(a,b,c) 61655682Smarkm#else 61755682Smarkm#define roken_openlog(a,b,c) openlog((char *)a,b,c) 61855682Smarkm#endif 61955682Smarkm 62072445Sassar#ifdef GETSOCKNAME_PROTO_COMPATIBLE 62172445Sassar#define roken_getsockname(a,b,c) getsockname(a,b,c) 62272445Sassar#else 62372445Sassar#define roken_getsockname(a,b,c) getsockname(a, b, (void*)c) 62472445Sassar#endif 62572445Sassar 62678527Sassar#ifndef HAVE_SETPROGNAME 62778527Sassarvoid setprogname(const char *argv0); 62878527Sassar#endif 62978527Sassar 63078527Sassar#ifndef HAVE_GETPROGNAME 63178527Sassarconst char *getprogname(void); 63278527Sassar#endif 63378527Sassar 63455682Smarkmvoid set_progname(char *argv0); 63572445Sassarconst char *get_progname(void); 63655682Smarkm 63790926Snectar#ifndef HAVE_LOCALTIME_R 63890926Snectarstruct tm * 63990926Snectarlocaltime_r(const time_t *timer, struct tm *result); 64090926Snectar#endif 64190926Snectar 64272445SassarROKEN_CPP_END 643