openbsd-compat.h revision 126274
1126274Sdes/* $Id: openbsd-compat.h,v 1.25 2004/01/21 06:07:23 djm 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
51124208Sdes#ifndef HAVE_GETCWD
52124208Sdeschar *getcwd(char *pt, size_t size);
53124208Sdes#endif
54124208Sdes
55124208Sdes#if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH)
56124208Sdeschar *realpath(const char *path, char *resolved);
57124208Sdes#endif
58124208Sdes
59124208Sdes#ifndef HAVE_RRESVPORT_AF
60124208Sdesint rresvport_af(int *alport, sa_family_t af);
61124208Sdes#endif
62124208Sdes
63124208Sdes#ifndef HAVE_STRLCPY
64124208Sdes/* #include <sys/types.h> XXX Still needed? */
65124208Sdessize_t strlcpy(char *dst, const char *src, size_t siz);
66124208Sdes#endif
67124208Sdes
68124208Sdes#ifndef HAVE_STRLCAT
69124208Sdes/* #include <sys/types.h> XXX Still needed? */
70124208Sdessize_t strlcat(char *dst, const char *src, size_t siz);
71124208Sdes#endif
72124208Sdes
73124208Sdes#ifndef HAVE_SETENV
74124208Sdesint setenv(register const char *name, register const char *value, int rewrite);
75124208Sdes#endif
76124208Sdes
77124208Sdes#ifndef HAVE_STRMODE
78124208Sdesvoid strmode(int mode, char *p);
79124208Sdes#endif
80124208Sdes
81124208Sdes#if !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP)
82124208Sdesint mkstemps(char *path, int slen);
83124208Sdesint mkstemp(char *path);
84124208Sdeschar *mkdtemp(char *path);
85124208Sdes#endif
86124208Sdes
87124208Sdes#ifndef HAVE_DAEMON
88124208Sdesint daemon(int nochdir, int noclose);
89124208Sdes#endif
90124208Sdes
91124208Sdes#ifndef HAVE_DIRNAME
92124208Sdeschar *dirname(const char *path);
93124208Sdes#endif
94124208Sdes
95124208Sdes#if defined(BROKEN_INET_NTOA) || !defined(HAVE_INET_NTOA)
96124208Sdeschar *inet_ntoa(struct in_addr in);
97124208Sdes#endif
98124208Sdes
99124208Sdes#ifndef HAVE_INET_NTOP
100124208Sdesconst char *inet_ntop(int af, const void *src, char *dst, size_t size);
101124208Sdes#endif
102124208Sdes
103124208Sdes#ifndef HAVE_INET_ATON
104124208Sdesint inet_aton(const char *cp, struct in_addr *addr);
105124208Sdes#endif
106124208Sdes
107124208Sdes#ifndef HAVE_STRSEP
108124208Sdeschar *strsep(char **stringp, const char *delim);
109124208Sdes#endif
110124208Sdes
111124208Sdes#ifndef HAVE_SETPROCTITLE
112124208Sdesvoid setproctitle(const char *fmt, ...);
113124208Sdesvoid compat_init_setproctitle(int argc, char *argv[]);
114124208Sdes#endif
115124208Sdes
116124208Sdes#ifndef HAVE_GETGROUPLIST
117124208Sdes/* #include <grp.h> XXXX Still needed ? */
118124208Sdesint getgrouplist(const char *, gid_t, gid_t *, int *);
119124208Sdes#endif
120124208Sdes
121124208Sdes#if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_OPTRESET)
122124208Sdesint BSDgetopt(int argc, char * const *argv, const char *opts);
123124208Sdes#endif
124124208Sdes
125124208Sdes
12698937Sdes/* Home grown routines */
12798937Sdes#include "bsd-misc.h"
12898937Sdes#include "bsd-waitpid.h"
12998937Sdes
130124208Sdes/*#include <sys/types.h> XXX Still needed? * For uid_t, gid_t * */
131124208Sdes
132124208Sdes#ifndef HAVE_GETPEEREID
133124208Sdesint getpeereid(int , uid_t *, gid_t *);
134124208Sdes#endif
135124208Sdes
136124208Sdes#ifndef HAVE_ARC4RANDOM
137124208Sdesunsigned int arc4random(void);
138124208Sdesvoid arc4random_stir(void);
139124208Sdes#endif /* !HAVE_ARC4RANDOM */
140124208Sdes
141126274Sdes#ifndef HAVE_OPENPTY
142126274Sdesint openpty(int *, int *, char *, struct termios *, struct winsize *);
143126274Sdes#endif /* HAVE_OPENPTY */
144124208Sdes
145124208Sdes/* #include <sys/types.h> XXX needed? For size_t */
146124208Sdes
147124208Sdes#ifndef HAVE_SNPRINTF
148124208Sdesint snprintf(char *, size_t, const char *, ...);
149124208Sdes#endif
150124208Sdes
151124208Sdes#ifndef HAVE_VSNPRINTF
152124208Sdesint vsnprintf(char *, size_t, const char *, va_list);
153124208Sdes#endif
154124208Sdes
155124208Sdesvoid *xmmap(size_t size);
156124208Sdeschar *xcrypt(const char *password, const char *salt);
157124208Sdeschar *shadow_pw(struct passwd *pw);
158124208Sdes
159124208Sdes
16098937Sdes/* rfc2553 socket API replacements */
161124208Sdes#include "fake-rfc2553.h"
16298937Sdes
16398937Sdes/* Routines for a single OS platform */
16498937Sdes#include "bsd-cray.h"
165124208Sdes#include "bsd-cygwin_util.h"
16698937Sdes#include "port-irix.h"
16798937Sdes#include "port-aix.h"
16898937Sdes
169124208Sdes#endif /* _OPENBSD_COMPAT_H */
170