openbsd-compat.h revision 149749
1149749Sdes/* $Id: openbsd-compat.h,v 1.30 2005/08/26 20:15:20 tim Exp $ */ 298937Sdes 3124208Sdes/* 4124208Sdes * Copyright (c) 1999-2003 Damien Miller. All rights reserved. 5124208Sdes * Copyright (c) 2003 Ben Lindstrom. All rights reserved. 6124208Sdes * Copyright (c) 2002 Tim Rice. All rights reserved. 7124208Sdes * 8124208Sdes * Redistribution and use in source and binary forms, with or without 9124208Sdes * modification, are permitted provided that the following conditions 10124208Sdes * are met: 11124208Sdes * 1. Redistributions of source code must retain the above copyright 12124208Sdes * notice, this list of conditions and the following disclaimer. 13124208Sdes * 2. Redistributions in binary form must reproduce the above copyright 14124208Sdes * notice, this list of conditions and the following disclaimer in the 15124208Sdes * documentation and/or other materials provided with the distribution. 16124208Sdes * 17124208Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18124208Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19124208Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20124208Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21124208Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22124208Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23124208Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24124208Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25124208Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26124208Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27124208Sdes */ 2898937Sdes 29124208Sdes#ifndef _OPENBSD_COMPAT_H 30124208Sdes#define _OPENBSD_COMPAT_H 3198937Sdes 32124208Sdes#include "includes.h" 33124208Sdes 3498937Sdes/* OpenBSD function replacements */ 3598937Sdes#include "base64.h" 3698937Sdes#include "sigact.h" 3798937Sdes#include "glob.h" 3898937Sdes#include "readpassphrase.h" 39113908Sdes#include "vis.h" 40124208Sdes#include "getrrsetbyname.h" 4198937Sdes 42124208Sdes 43124208Sdes#ifndef HAVE_BASENAME 44124208Sdeschar *basename(const char *path); 45124208Sdes#endif 46124208Sdes 47124208Sdes#ifndef HAVE_BINDRESVPORT_SA 48124208Sdesint bindresvport_sa(int sd, struct sockaddr *sa); 49124208Sdes#endif 50124208Sdes 51137015Sdes#ifndef HAVE_CLOSEFROM 52137015Sdesvoid closefrom(int); 53137015Sdes#endif 54137015Sdes 55124208Sdes#ifndef HAVE_GETCWD 56124208Sdeschar *getcwd(char *pt, size_t size); 57124208Sdes#endif 58124208Sdes 59124208Sdes#if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) 60124208Sdeschar *realpath(const char *path, char *resolved); 61124208Sdes#endif 62124208Sdes 63124208Sdes#ifndef HAVE_RRESVPORT_AF 64124208Sdesint rresvport_af(int *alport, sa_family_t af); 65124208Sdes#endif 66124208Sdes 67124208Sdes#ifndef HAVE_STRLCPY 68124208Sdes/* #include <sys/types.h> XXX Still needed? */ 69124208Sdessize_t strlcpy(char *dst, const char *src, size_t siz); 70124208Sdes#endif 71124208Sdes 72124208Sdes#ifndef HAVE_STRLCAT 73124208Sdes/* #include <sys/types.h> XXX Still needed? */ 74124208Sdessize_t strlcat(char *dst, const char *src, size_t siz); 75124208Sdes#endif 76124208Sdes 77124208Sdes#ifndef HAVE_SETENV 78124208Sdesint setenv(register const char *name, register const char *value, int rewrite); 79124208Sdes#endif 80124208Sdes 81124208Sdes#ifndef HAVE_STRMODE 82124208Sdesvoid strmode(int mode, char *p); 83124208Sdes#endif 84124208Sdes 85124208Sdes#if !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP) 86124208Sdesint mkstemps(char *path, int slen); 87124208Sdesint mkstemp(char *path); 88124208Sdeschar *mkdtemp(char *path); 89124208Sdes#endif 90124208Sdes 91124208Sdes#ifndef HAVE_DAEMON 92124208Sdesint daemon(int nochdir, int noclose); 93124208Sdes#endif 94124208Sdes 95124208Sdes#ifndef HAVE_DIRNAME 96124208Sdeschar *dirname(const char *path); 97124208Sdes#endif 98124208Sdes 99124208Sdes#if defined(BROKEN_INET_NTOA) || !defined(HAVE_INET_NTOA) 100124208Sdeschar *inet_ntoa(struct in_addr in); 101124208Sdes#endif 102124208Sdes 103124208Sdes#ifndef HAVE_INET_NTOP 104124208Sdesconst char *inet_ntop(int af, const void *src, char *dst, size_t size); 105124208Sdes#endif 106124208Sdes 107124208Sdes#ifndef HAVE_INET_ATON 108124208Sdesint inet_aton(const char *cp, struct in_addr *addr); 109124208Sdes#endif 110124208Sdes 111124208Sdes#ifndef HAVE_STRSEP 112124208Sdeschar *strsep(char **stringp, const char *delim); 113124208Sdes#endif 114124208Sdes 115124208Sdes#ifndef HAVE_SETPROCTITLE 116124208Sdesvoid setproctitle(const char *fmt, ...); 117124208Sdesvoid compat_init_setproctitle(int argc, char *argv[]); 118124208Sdes#endif 119124208Sdes 120124208Sdes#ifndef HAVE_GETGROUPLIST 121124208Sdes/* #include <grp.h> XXXX Still needed ? */ 122124208Sdesint getgrouplist(const char *, gid_t, gid_t *, int *); 123124208Sdes#endif 124124208Sdes 125124208Sdes#if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_OPTRESET) 126124208Sdesint BSDgetopt(int argc, char * const *argv, const char *opts); 127124208Sdes#endif 128124208Sdes 129124208Sdes 13098937Sdes/* Home grown routines */ 13198937Sdes#include "bsd-misc.h" 13298937Sdes#include "bsd-waitpid.h" 13398937Sdes 134124208Sdes/*#include <sys/types.h> XXX Still needed? * For uid_t, gid_t * */ 135124208Sdes 136124208Sdes#ifndef HAVE_GETPEEREID 137124208Sdesint getpeereid(int , uid_t *, gid_t *); 138124208Sdes#endif 139124208Sdes 140124208Sdes#ifndef HAVE_ARC4RANDOM 141124208Sdesunsigned int arc4random(void); 142124208Sdesvoid arc4random_stir(void); 143124208Sdes#endif /* !HAVE_ARC4RANDOM */ 144124208Sdes 145126274Sdes#ifndef HAVE_OPENPTY 146126274Sdesint openpty(int *, int *, char *, struct termios *, struct winsize *); 147126274Sdes#endif /* HAVE_OPENPTY */ 148124208Sdes 149124208Sdes/* #include <sys/types.h> XXX needed? For size_t */ 150124208Sdes 151124208Sdes#ifndef HAVE_SNPRINTF 152124208Sdesint snprintf(char *, size_t, const char *, ...); 153124208Sdes#endif 154124208Sdes 155149749Sdes#ifndef HAVE_STRTONUM 156149749Sdeslong long strtonum(const char *, long long, long long, const char **); 157149749Sdes#endif 158149749Sdes 159124208Sdes#ifndef HAVE_VSNPRINTF 160124208Sdesint vsnprintf(char *, size_t, const char *, va_list); 161124208Sdes#endif 162124208Sdes 163124208Sdesvoid *xmmap(size_t size); 164124208Sdeschar *xcrypt(const char *password, const char *salt); 165124208Sdeschar *shadow_pw(struct passwd *pw); 166124208Sdes 167124208Sdes 16898937Sdes/* rfc2553 socket API replacements */ 169124208Sdes#include "fake-rfc2553.h" 17098937Sdes 17198937Sdes/* Routines for a single OS platform */ 17298937Sdes#include "bsd-cray.h" 173124208Sdes#include "bsd-cygwin_util.h" 17498937Sdes#include "port-irix.h" 17598937Sdes#include "port-aix.h" 176149749Sdes#include "port-uw.h" 17798937Sdes 178124208Sdes#endif /* _OPENBSD_COMPAT_H */ 179