roken.h.in revision 102644
1139804Simp/* -*- C -*- */ 2177633Sdfr/* 3177633Sdfr * Copyright (c) 1995 - 2002 Kungliga Tekniska H�gskolan 4177633Sdfr * (Royal Institute of Technology, Stockholm, Sweden). 5177633Sdfr * All rights reserved. 6177633Sdfr * 7177633Sdfr * Redistribution and use in source and binary forms, with or without 8177633Sdfr * modification, are permitted provided that the following conditions 9177633Sdfr * are met: 10177633Sdfr * 11177633Sdfr * 1. Redistributions of source code must retain the above copyright 12177633Sdfr * notice, this list of conditions and the following disclaimer. 13177633Sdfr * 14177633Sdfr * 2. Redistributions in binary form must reproduce the above copyright 15177633Sdfr * notice, this list of conditions and the following disclaimer in the 16177633Sdfr * documentation and/or other materials provided with the distribution. 17177633Sdfr * 18177633Sdfr * 3. Neither the name of the Institute nor the names of its contributors 19177633Sdfr * may be used to endorse or promote products derived from this software 20177633Sdfr * without specific prior written permission. 21177633Sdfr * 22177633Sdfr * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 23177633Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24177633Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25177633Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 26177633Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27177633Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281960Sdg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291960Sdg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 301960Sdg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 311960Sdg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 321960Sdg * SUCH DAMAGE. 331960Sdg */ 341960Sdg 351960Sdg/* $Id: roken.h.in,v 1.169 2002/08/26 21:43:38 assar Exp $ */ 361960Sdg 371960Sdg#include <stdio.h> 381960Sdg#include <stdlib.h> 391960Sdg#include <stdarg.h> 401960Sdg#include <string.h> 411960Sdg#include <signal.h> 421960Sdg 431960Sdg#ifdef _AIX 441960Sdgstruct ether_addr; 451960Sdgstruct sockaddr_dl; 461960Sdg#endif 471960Sdg#ifdef HAVE_SYS_PARAM_H 481960Sdg#include <sys/param.h> 491960Sdg#endif 501960Sdg#ifdef HAVE_INTTYPES_H 511960Sdg#include <inttypes.h> 521960Sdg#endif 531960Sdg#ifdef HAVE_SYS_TYPES_H 541960Sdg#include <sys/types.h> 551960Sdg#endif 561960Sdg#ifdef HAVE_SYS_BITYPES_H 571960Sdg#include <sys/bitypes.h> 581960Sdg#endif 591960Sdg#ifdef HAVE_BIND_BITYPES_H 601960Sdg#include <bind/bitypes.h> 61116182Sobrien#endif 62116182Sobrien#ifdef HAVE_NETINET_IN6_MACHTYPES_H 63116182Sobrien#include <netinet/in6_machtypes.h> 6432929Seivind#endif 6532929Seivind#ifdef HAVE_UNISTD_H 661960Sdg#include <unistd.h> 671960Sdg#endif 68177633Sdfr#ifdef HAVE_SYS_SOCKET_H 6941059Speter#include <sys/socket.h> 70114216Skan#endif 7131561Sbde#ifdef HAVE_SYS_UIO_H 72101778Sphk#include <sys/uio.h> 7376166Smarkm#endif 741960Sdg#ifdef HAVE_GRP_H 75177633Sdfr#include <grp.h> 7618020Sbde#endif 771960Sdg#ifdef HAVE_SYS_STAT_H 781960Sdg#include <sys/stat.h> 791960Sdg#endif 801960Sdg#ifdef HAVE_NETINET_IN_H 81177633Sdfr#include <netinet/in.h> 821960Sdg#endif 831960Sdg#ifdef HAVE_NETINET_IN6_H 8422880Sbde#include <netinet/in6.h> 8522880Sbde#endif 8622880Sbde#ifdef HAVE_NETINET6_IN6_H 8722880Sbde#include <netinet6/in6.h> 8822880Sbde#endif 89177633Sdfr#ifdef HAVE_ARPA_INET_H 9024481Sbde#include <arpa/inet.h> 911960Sdg#endif 921960Sdg#ifdef HAVE_NETDB_H 93227293Sed#include <netdb.h> 9430309Sphk#endif 95177633Sdfr#ifdef HAVE_ARPA_NAMESER_H 96177633Sdfr#include <arpa/nameser.h> 97177633Sdfr#endif 98177633Sdfr#ifdef HAVE_RESOLV_H 99177633Sdfr#include <resolv.h> 100177633Sdfr#endif 1011960Sdg#ifdef HAVE_SYSLOG_H 1021960Sdg#include <syslog.h> 103177633Sdfr#endif 104177633Sdfr#ifdef HAVE_FCNTL_H 105177633Sdfr#include <fcntl.h> 106177633Sdfr#endif 107177633Sdfr#ifdef HAVE_ERRNO_H 108177633Sdfr#include <errno.h> 109192685Skib#endif 110177633Sdfr#ifdef HAVE_ERR_H 111177633Sdfr#include <err.h> 112177633Sdfr#endif 113177633Sdfr#ifdef HAVE_TERMIOS_H 114177633Sdfr#include <termios.h> 115177633Sdfr#endif 116177633Sdfr#if defined(HAVE_SYS_IOCTL_H) && SunOS != 40 117177633Sdfr#include <sys/ioctl.h> 118177633Sdfr#endif 119177633Sdfr#ifdef TIME_WITH_SYS_TIME 120177633Sdfr#include <sys/time.h> 121177633Sdfr#include <time.h> 122177633Sdfr#elif defined(HAVE_SYS_TIME_H) 123177633Sdfr#include <sys/time.h> 124177633Sdfr#else 125177633Sdfr#include <time.h> 126177633Sdfr#endif 127177633Sdfr 128177633Sdfr#ifdef HAVE_PATHS_H 129177633Sdfr#include <paths.h> 130177633Sdfr#endif 131177633Sdfr 132177633Sdfr 133177633Sdfr#ifndef ROKEN_LIB_FUNCTION 134177633Sdfr#if defined(__BORLANDC__) 135177633Sdfr#define ROKEN_LIB_FUNCTION /* not-ready-definition-yet */ 136177633Sdfr#elif defined(_MSC_VER) 137177633Sdfr#define ROKEN_LIB_FUNCTION /* not-ready-definition-yet2 */ 138177633Sdfr#else 139177633Sdfr#define ROKEN_LIB_FUNCTION 140177633Sdfr#endif 141140808Sjeff#endif 142177633Sdfr 143177633Sdfr#ifndef HAVE_SSIZE_T 144177633Sdfrtypedef int ssize_t; 145177633Sdfr#endif 146140808Sjeff 147177633Sdfr#include <roken-common.h> 148177633Sdfr 149177633SdfrROKEN_CPP_START 150177633Sdfr 151177633Sdfr#if !defined(HAVE_SETSID) && defined(HAVE__SETSID) 152177633Sdfr#define setsid _setsid 153177633Sdfr#endif 154177633Sdfr 155177633Sdfr#ifndef HAVE_PUTENV 156177633Sdfrint putenv(const char *string); 157177633Sdfr#endif 158177633Sdfr 159177633Sdfr#if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO) 160177633Sdfrint setenv(const char *var, const char *val, int rewrite); 161177633Sdfr#endif 162177633Sdfr 163177633Sdfr#if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO) 164177633Sdfrvoid unsetenv(const char *name); 165177633Sdfr#endif 166177633Sdfr 167177633Sdfr#if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO) 168177633Sdfrchar *getusershell(void); 169177633Sdfrvoid endusershell(void); 170177633Sdfr#endif 1711960Sdg 1721960Sdg#if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO) 173177633Sdfrint snprintf (char *str, size_t sz, const char *format, ...) 174177633Sdfr __attribute__ ((format (printf, 3, 4))); 175177633Sdfr#endif 176177633Sdfr 177177633Sdfr#if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO) 178177633Sdfrint vsnprintf (char *str, size_t sz, const char *format, va_list ap) 179177633Sdfr __attribute__((format (printf, 3, 0))); 180177633Sdfr#endif 181177633Sdfr 182177633Sdfr#if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO) 183177633Sdfrint asprintf (char **ret, const char *format, ...) 184177633Sdfr __attribute__ ((format (printf, 2, 3))); 185177633Sdfr#endif 186177633Sdfr 187177633Sdfr#if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO) 188177633Sdfrint vasprintf (char **ret, const char *format, va_list ap) 189177633Sdfr __attribute__((format (printf, 2, 0))); 190177633Sdfr#endif 191177633Sdfr 192177633Sdfr#if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO) 193177633Sdfrint asnprintf (char **ret, size_t max_sz, const char *format, ...) 194177633Sdfr __attribute__ ((format (printf, 3, 4))); 195177633Sdfr#endif 196177633Sdfr 197177633Sdfr#if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO) 198177633Sdfrint vasnprintf (char **ret, size_t max_sz, const char *format, va_list ap) 199177633Sdfr __attribute__((format (printf, 3, 0))); 200177633Sdfr#endif 201177633Sdfr 202177633Sdfr#ifndef HAVE_STRDUP 203177633Sdfrchar * strdup(const char *old); 204177633Sdfr#endif 205177633Sdfr 206177633Sdfr#if !defined(HAVE_STRNDUP) || defined(NEED_STRNDUP_PROTO) 207177633Sdfrchar * strndup(const char *old, size_t sz); 208177633Sdfr#endif 209177633Sdfr 210177633Sdfr#ifndef HAVE_STRLWR 211177633Sdfrchar * strlwr(char *); 212177633Sdfr#endif 213177633Sdfr 214177633Sdfr#ifndef HAVE_STRNLEN 215177633Sdfrsize_t strnlen(const char*, size_t); 216177633Sdfr#endif 217177633Sdfr 218177633Sdfr#if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO) 219177633Sdfrchar *strsep(char**, const char*); 220177633Sdfr#endif 221177633Sdfr 222177633Sdfr#if !defined(HAVE_STRSEP_COPY) || defined(NEED_STRSEP_COPY_PROTO) 223177633Sdfrssize_t strsep_copy(const char**, const char*, char*, size_t); 224177633Sdfr#endif 225177633Sdfr 226177633Sdfr#ifndef HAVE_STRCASECMP 227177633Sdfrint strcasecmp(const char *s1, const char *s2); 228177633Sdfr#endif 229177633Sdfr 230177633Sdfr#ifdef NEED_FCLOSE_PROTO 231177633Sdfrint fclose(FILE *); 232177633Sdfr#endif 233177633Sdfr 234177633Sdfr#ifdef NEED_STRTOK_R_PROTO 235177633Sdfrchar *strtok_r(char *s1, const char *s2, char **lasts); 236177633Sdfr#endif 237177633Sdfr 238177633Sdfr#ifndef HAVE_STRUPR 239177633Sdfrchar * strupr(char *); 240177633Sdfr#endif 241177633Sdfr 242177633Sdfr#ifndef HAVE_STRLCPY 243177633Sdfrsize_t strlcpy (char *dst, const char *src, size_t dst_sz); 244177633Sdfr#endif 245177633Sdfr 246177633Sdfr#ifndef HAVE_STRLCAT 247177633Sdfrsize_t strlcat (char *dst, const char *src, size_t dst_sz); 248177633Sdfr#endif 249177633Sdfr 250177633Sdfr#ifndef HAVE_GETDTABLESIZE 251177633Sdfrint getdtablesize(void); 252177633Sdfr#endif 253177633Sdfr 254177633Sdfr#if !defined(HAVE_STRERROR) && !defined(strerror) 255177633Sdfrchar *strerror(int eno); 256177633Sdfr#endif 257177633Sdfr 258177633Sdfr#if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO) 259177633Sdfr/* This causes a fatal error under Psoriasis */ 260177633Sdfr#if !(defined(SunOS) && (SunOS >= 50)) 261177633Sdfrconst char *hstrerror(int herr); 262177633Sdfr#endif 263177633Sdfr#endif 264177633Sdfr 265177633Sdfr#ifndef HAVE_H_ERRNO_DECLARATION 266177633Sdfrextern int h_errno; 267177633Sdfr#endif 268177633Sdfr 269177633Sdfr#if !defined(HAVE_INET_ATON) || defined(NEED_INET_ATON_PROTO) 270177633Sdfrint inet_aton(const char *cp, struct in_addr *adr); 271177633Sdfr#endif 272177633Sdfr 273177633Sdfr#ifndef HAVE_INET_NTOP 274177633Sdfrconst char * 275177633Sdfrinet_ntop(int af, const void *src, char *dst, size_t size); 276177633Sdfr#endif 277177633Sdfr 278177633Sdfr#ifndef HAVE_INET_PTON 279177633Sdfrint 280177633Sdfrinet_pton(int af, const char *src, void *dst); 281177633Sdfr#endif 282177633Sdfr 283177633Sdfr#if !defined(HAVE_GETCWD) 284177633Sdfrchar* getcwd(char *path, size_t size); 285177633Sdfr#endif 286177633Sdfr 287177633Sdfr#ifdef HAVE_PWD_H 288177633Sdfr#include <pwd.h> 289177633Sdfrstruct passwd *k_getpwnam (const char *user); 290177633Sdfrstruct passwd *k_getpwuid (uid_t uid); 291177633Sdfr#endif 292177633Sdfr 293177633Sdfrconst char *get_default_username (void); 294177633Sdfr 295177633Sdfr#ifndef HAVE_SETEUID 296177633Sdfrint seteuid(uid_t euid); 297177633Sdfr#endif 298177633Sdfr 299177633Sdfr#ifndef HAVE_SETEGID 300177633Sdfrint setegid(gid_t egid); 301177633Sdfr#endif 302177633Sdfr 303177633Sdfr#ifndef HAVE_LSTAT 304177633Sdfrint lstat(const char *path, struct stat *buf); 305177633Sdfr#endif 306177633Sdfr 307177633Sdfr#if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO) 308177633Sdfrint mkstemp(char *); 309177633Sdfr#endif 310177633Sdfr 311177633Sdfr#ifndef HAVE_CGETENT 312177633Sdfrint cgetent(char **buf, char **db_array, const char *name); 313177633Sdfrint cgetstr(char *buf, const char *cap, char **str); 314177633Sdfr#endif 315177633Sdfr 316177633Sdfr#ifndef HAVE_INITGROUPS 317177633Sdfrint initgroups(const char *name, gid_t basegid); 318177633Sdfr#endif 319177633Sdfr 320177633Sdfr#ifndef HAVE_FCHOWN 321177633Sdfrint fchown(int fd, uid_t owner, gid_t group); 322177633Sdfr#endif 323177633Sdfr 324177633Sdfr#ifndef HAVE_DAEMON 325177633Sdfrint daemon(int nochdir, int noclose); 326177633Sdfr#endif 327177633Sdfr 328177633Sdfr#ifndef HAVE_INNETGR 329177633Sdfrint innetgr(const char *netgroup, const char *machine, 330177633Sdfr const char *user, const char *domain); 331177633Sdfr#endif 332177633Sdfr 333177633Sdfr#ifndef HAVE_CHOWN 334177633Sdfrint chown(const char *path, uid_t owner, gid_t group); 335177633Sdfr#endif 336177633Sdfr 337177633Sdfr#ifndef HAVE_RCMD 338177633Sdfrint rcmd(char **ahost, unsigned short inport, const char *locuser, 339177633Sdfr const char *remuser, const char *cmd, int *fd2p); 340177633Sdfr#endif 341177633Sdfr 342177633Sdfr#if !defined(HAVE_INNETGR) || defined(NEED_INNETGR_PROTO) 343177633Sdfrint innetgr(const char*, const char*, const char*, const char*); 344177633Sdfr#endif 345177633Sdfr 346177633Sdfr#ifndef HAVE_IRUSEROK 347177633Sdfrint iruserok(unsigned raddr, int superuser, const char *ruser, 348177633Sdfr const char *luser); 349177633Sdfr#endif 350192685Skib 351177633Sdfr#if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO) 352177633Sdfrint gethostname(char *name, int namelen); 353192685Skib#endif 354192685Skib 355192685Skib#ifndef HAVE_WRITEV 356192685Skibssize_t 357177633Sdfrwritev(int d, const struct iovec *iov, int iovcnt); 358177633Sdfr#endif 359177633Sdfr 360177633Sdfr#ifndef HAVE_READV 361177633Sdfrssize_t 362177633Sdfrreadv(int d, const struct iovec *iov, int iovcnt); 363177633Sdfr#endif 364177633Sdfr 365302234Sbdrewery#ifndef HAVE_MKSTEMP 366177633Sdfrint 367177633Sdfrmkstemp(char *template); 368177633Sdfr#endif 369177633Sdfr 370177633Sdfr#ifndef HAVE_PIDFILE 371177633Sdfrvoid pidfile (const char*); 372177633Sdfr#endif 373177633Sdfr 374177633Sdfr#ifndef HAVE_BSWAP32 375177633Sdfrunsigned int bswap32(unsigned int); 376177633Sdfr#endif 377177633Sdfr 378177633Sdfr#ifndef HAVE_BSWAP16 379177633Sdfrunsigned short bswap16(unsigned short); 380177633Sdfr#endif 381177633Sdfr 382177633Sdfr#ifndef HAVE_FLOCK 383177633Sdfr#ifndef LOCK_SH 384177633Sdfr#define LOCK_SH 1 /* Shared lock */ 385177633Sdfr#endif 386177633Sdfr#ifndef LOCK_EX 387177633Sdfr#define LOCK_EX 2 /* Exclusive lock */ 388177633Sdfr#endif 389177633Sdfr#ifndef LOCK_NB 390177633Sdfr#define LOCK_NB 4 /* Don't block when locking */ 391177633Sdfr#endif 392177633Sdfr#ifndef LOCK_UN 393177633Sdfr#define LOCK_UN 8 /* Unlock */ 394177633Sdfr#endif 395177633Sdfr 396177633Sdfrint flock(int fd, int operation); 397177633Sdfr#endif /* HAVE_FLOCK */ 398177633Sdfr 399177633Sdfrtime_t tm2time (struct tm tm, int local); 400177633Sdfr 401192685Skibint unix_verify_user(char *user, char *password); 402177633Sdfr 403177633Sdfrint roken_concat (char *s, size_t len, ...); 404177633Sdfr 4051960Sdgsize_t roken_mconcat (char **s, size_t max_len, ...); 4061960Sdg 4071960Sdgint roken_vconcat (char *s, size_t len, va_list args); 408177633Sdfr 409177633Sdfrsize_t roken_vmconcat (char **s, size_t max_len, va_list args); 4101960Sdg 411177633Sdfrssize_t net_write (int fd, const void *buf, size_t nbytes); 412171193Sjeff 413177633Sdfrssize_t net_read (int fd, void *buf, size_t nbytes); 414171193Sjeff 415177633Sdfrint issuid(void); 416177633Sdfr 417177633Sdfr#ifndef HAVE_STRUCT_WINSIZE 418177633Sdfrstruct winsize { 41982346Sache unsigned short ws_row, ws_col; 4201960Sdg unsigned short ws_xpixel, ws_ypixel; 4211960Sdg}; 4221960Sdg#endif 423177633Sdfr 424177633Sdfrint get_window_size(int fd, struct winsize *); 425177633Sdfr 426177633Sdfr#ifndef HAVE_VSYSLOG 427177633Sdfrvoid vsyslog(int pri, const char *fmt, va_list ap); 428177633Sdfr#endif 429177633Sdfr 430177633Sdfr#ifndef HAVE_OPTARG_DECLARATION 431177633Sdfrextern char *optarg; 4321960Sdg#endif 4331960Sdg#ifndef HAVE_OPTIND_DECLARATION 4341960Sdgextern int optind; 4351960Sdg#endif 4361960Sdg#ifndef HAVE_OPTERR_DECLARATION 4371960Sdgextern int opterr; 4381960Sdg#endif 4391960Sdg 4401960Sdg#ifndef HAVE___PROGNAME_DECLARATION 4411960Sdgextern const char *__progname; 4421960Sdg#endif 4431960Sdg 4441960Sdg#ifndef HAVE_ENVIRON_DECLARATION 4451960Sdgextern char **environ; 44682516Sache#endif 447171193Sjeff 448171193Sjeff#ifndef HAVE_GETIPNODEBYNAME 4491960Sdgstruct hostent * 4501960Sdggetipnodebyname (const char *name, int af, int flags, int *error_num); 4511960Sdg#endif 4521960Sdg 453171193Sjeff#ifndef HAVE_GETIPNODEBYADDR 4541960Sdgstruct hostent * 455171193Sjeffgetipnodebyaddr (const void *src, size_t len, int af, int *error_num); 456171193Sjeff#endif 45782200Sache 458171193Sjeff#ifndef HAVE_FREEHOSTENT 459171193Sjeffvoid 46082202Sachefreehostent (struct hostent *h); 46182200Sache#endif 462171193Sjeff 463171193Sjeff#ifndef HAVE_COPYHOSTENT 464177633Sdfrstruct hostent * 465177633Sdfrcopyhostent (const struct hostent *h); 466177633Sdfr#endif 46782346Sache 468171193Sjeff#ifndef HAVE_SOCKLEN_T 469171193Sjefftypedef int socklen_t; 47082172Sache#endif 47120676Sbde 472269055Skib#ifndef HAVE_STRUCT_SOCKADDR_STORAGE 473269055Skib 474269055Skib#ifndef HAVE_SA_FAMILY_T 4751960Sdgtypedef unsigned short sa_family_t; 47620676Sbde#endif 47720676Sbde 478184227Sdfr#ifdef HAVE_IPV6 479184227Sdfr#define _SS_MAXSIZE sizeof(struct sockaddr_in6) 48020676Sbde#else 48120676Sbde#define _SS_MAXSIZE sizeof(struct sockaddr_in) 482184227Sdfr#endif 483171193Sjeff 48420676Sbde#define _SS_ALIGNSIZE sizeof(unsigned long) 48520676Sbde 486184227Sdfr#if HAVE_STRUCT_SOCKADDR_SA_LEN 487177633Sdfr 48820676Sbdetypedef unsigned char roken_sa_family_t; 489177633Sdfr 490177633Sdfr#define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t) - sizeof(unsigned char)) % _SS_ALIGNSIZE) 491171193Sjeff#define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + sizeof(unsigned char) + _SS_PAD1SIZE + _SS_ALIGNSIZE)) 492177633Sdfr 493177633Sdfrstruct sockaddr_storage { 494177633Sdfr unsigned char ss_len; 495177633Sdfr roken_sa_family_t ss_family; 496177633Sdfr char __ss_pad1[_SS_PAD1SIZE]; 497177633Sdfr unsigned long __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1]; 498177633Sdfr}; 499177633Sdfr 500177633Sdfr#else /* !HAVE_STRUCT_SOCKADDR_SA_LEN */ 501177633Sdfr 502177633Sdfrtypedef unsigned short roken_sa_family_t; 503177633Sdfr 504177633Sdfr#define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t)) % _SS_ALIGNSIZE) 505177633Sdfr#define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + _SS_PAD1SIZE + _SS_ALIGNSIZE)) 506177633Sdfr 507177633Sdfrstruct sockaddr_storage { 508177633Sdfr roken_sa_family_t ss_family; 509177633Sdfr char __ss_pad1[_SS_PAD1SIZE]; 510177633Sdfr unsigned long __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1]; 511177633Sdfr}; 512177633Sdfr 513177633Sdfr#endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ 514177633Sdfr 515177633Sdfr#endif /* HAVE_STRUCT_SOCKADDR_STORAGE */ 516177633Sdfr 517177633Sdfr#ifndef HAVE_STRUCT_ADDRINFO 518177633Sdfrstruct addrinfo { 519177633Sdfr int ai_flags; 520177633Sdfr int ai_family; 521177633Sdfr int ai_socktype; 522177633Sdfr int ai_protocol; 523177633Sdfr size_t ai_addrlen; 524177633Sdfr char *ai_canonname; 525177633Sdfr struct sockaddr *ai_addr; 526177633Sdfr struct addrinfo *ai_next; 527177633Sdfr}; 528177633Sdfr#endif 529177633Sdfr 530177633Sdfr#ifndef HAVE_GETADDRINFO 531177633Sdfrint 532177633Sdfrgetaddrinfo(const char *nodename, 533177633Sdfr const char *servname, 534177633Sdfr const struct addrinfo *hints, 535177633Sdfr struct addrinfo **res); 536177633Sdfr#endif 537177633Sdfr 538177633Sdfr#ifndef HAVE_GETNAMEINFO 539177633Sdfrint getnameinfo(const struct sockaddr *sa, socklen_t salen, 540177633Sdfr char *host, size_t hostlen, 541177633Sdfr char *serv, size_t servlen, 542171772Skib int flags); 543177633Sdfr#endif 544177633Sdfr 545171193Sjeff#ifndef HAVE_FREEADDRINFO 546177633Sdfrvoid 547177633Sdfrfreeaddrinfo(struct addrinfo *ai); 548177633Sdfr#endif 5491960Sdg 550177633Sdfr#ifndef HAVE_GAI_STRERROR 551192685Skibchar * 5521960Sdggai_strerror(int ecode); 5531960Sdg#endif 554177633Sdfr 555177633Sdfrint 556177633Sdfrgetnameinfo_verified(const struct sockaddr *sa, socklen_t salen, 557177633Sdfr char *host, size_t hostlen, 558177633Sdfr char *serv, size_t servlen, 559177633Sdfr int flags); 560177633Sdfr 561177633Sdfrint roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **); 562177633Sdfrint roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **); 563177633Sdfr 564177633Sdfr#ifndef HAVE_STRFTIME 56587211Salfredsize_t 56687211Salfredstrftime (char *buf, size_t maxsize, const char *format, 56787211Salfred const struct tm *tm); 56887211Salfred#endif 56987211Salfred 57087211Salfred#ifndef HAVE_STRPTIME 57187211Salfredchar * 57222521Sdysonstrptime (const char *buf, const char *format, struct tm *timeptr); 573177633Sdfr#endif 574177633Sdfr 575177633Sdfr#ifndef HAVE_EMALLOC 5761960Sdgvoid *emalloc (size_t); 577177633Sdfr#endif 5781960Sdg#ifndef HAVE_ECALLOC 579177633Sdfrvoid *ecalloc(size_t num, size_t sz); 580177633Sdfr#endif 581177633Sdfr#ifndef HAVE_EREALLOC 582177633Sdfrvoid *erealloc (void *, size_t); 5831960Sdg#endif 584171193Sjeff#ifndef HAVE_ESTRDUP 585178243Skibchar *estrdup (const char *); 586178243Skib#endif 587178243Skib 588178243Skib/* 589178243Skib * kludges and such 590177633Sdfr */ 591177633Sdfr 592177633Sdfr#if 1 593177633Sdfrint roken_gethostby_setup(const char*, const char*); 594177633Sdfrstruct hostent* roken_gethostbyname(const char*); 595177633Sdfrstruct hostent* roken_gethostbyaddr(const void*, size_t, int); 596177633Sdfr#else 597177633Sdfr#ifdef GETHOSTBYNAME_PROTO_COMPATIBLE 598177633Sdfr#define roken_gethostbyname(x) gethostbyname(x) 599177633Sdfr#else 600177633Sdfr#define roken_gethostbyname(x) gethostbyname((char *)x) 601177633Sdfr#endif 602177633Sdfr 603177633Sdfr#ifdef GETHOSTBYADDR_PROTO_COMPATIBLE 604177841Sdfr#define roken_gethostbyaddr(a, l, t) gethostbyaddr(a, l, t) 605177633Sdfr#else 606177633Sdfr#define roken_gethostbyaddr(a, l, t) gethostbyaddr((char *)a, l, t) 607177633Sdfr#endif 608177633Sdfr#endif 609177633Sdfr 610177633Sdfr#ifdef GETSERVBYNAME_PROTO_COMPATIBLE 611177633Sdfr#define roken_getservbyname(x,y) getservbyname(x,y) 612177633Sdfr#else 613177633Sdfr#define roken_getservbyname(x,y) getservbyname((char *)x, (char *)y) 614177633Sdfr#endif 615178243Skib 616178243Skib#ifdef OPENLOG_PROTO_COMPATIBLE 617178243Skib#define roken_openlog(a,b,c) openlog(a,b,c) 618178243Skib#else 619178243Skib#define roken_openlog(a,b,c) openlog((char *)a,b,c) 620178243Skib#endif 621178243Skib 622178243Skib#ifdef GETSOCKNAME_PROTO_COMPATIBLE 623178243Skib#define roken_getsockname(a,b,c) getsockname(a,b,c) 624178243Skib#else 625177633Sdfr#define roken_getsockname(a,b,c) getsockname(a, b, (void*)c) 626177841Sdfr#endif 627177841Sdfr 628177633Sdfr#ifndef HAVE_SETPROGNAME 629177841Sdfrvoid setprogname(const char *argv0); 630177841Sdfr#endif 631177841Sdfr 632177841Sdfr#ifndef HAVE_GETPROGNAME 633177633Sdfrconst char *getprogname(void); 634177633Sdfr#endif 635177633Sdfr 636177633Sdfrvoid mini_inetd_addrinfo (struct addrinfo*); 637177633Sdfrvoid mini_inetd (int port); 638177633Sdfr 639177841Sdfrvoid set_progname(char *argv0); 640177841Sdfrconst char *get_progname(void); 641177841Sdfr 642177633Sdfr#ifndef HAVE_LOCALTIME_R 643177633Sdfrstruct tm * 644177633Sdfrlocaltime_r(const time_t *timer, struct tm *result); 645192683Skib#endif 646192683Skib 647192683Skib#if !defined(HAVE_STRSVIS) || defined(NEED_STRSVIS_PROTO) 648192683Skibint 649192683Skibstrsvis(char *dst, const char *src, int flag, const char *extra); 650192683Skib#endif 651192683Skib 652194356Skib#if !defined(HAVE_STRUNVIS) || defined(NEED_STRUNVIS_PROTO) 653194356Skibint 654192683Skibstrunvis(char *dst, const char *src); 655193931Skib#endif 656192683Skib 657192683Skib#if !defined(HAVE_STRVIS) || defined(NEED_STRVIS_PROTO) 658192683Skibint 659192683Skibstrvis(char *dst, const char *src, int flag); 660192683Skib#endif 661192683Skib 6621960Sdg#if !defined(HAVE_STRVISX) || defined(NEED_STRVISX_PROTO) 663177633Sdfrint 664171193Sjeffstrvisx(char *dst, const char *src, size_t len, int flag); 6651960Sdg#endif 6661960Sdg 667177633Sdfr#if !defined(HAVE_SVIS) || defined(NEED_SVIS_PROTO) 668177633Sdfrchar * 669171193Sjeffsvis(char *dst, int c, int flag, int nextc, const char *extra); 6701960Sdg#endif 6711960Sdg 672177633Sdfr#if !defined(HAVE_UNVIS) || defined(NEED_UNVIS_PROTO) 673177633Sdfrint 674171193Sjeffunvis(char *cp, int c, int *astate, int flag); 6758876Srgrimes#endif 676177633Sdfr 677177633Sdfr#if !defined(HAVE_VIS) || defined(NEED_VIS_PROTO) 678177633Sdfrchar * 679177633Sdfrvis(char *dst, int c, int flag, int nextc); 680177633Sdfr#endif 681177633Sdfr 682177633SdfrROKEN_CPP_END 683177633Sdfr