4 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 #define __attribute__(a)
27 #define __dead __attribute__ ((__noreturn__))
30 #define __packed __attribute__ ((__packed__))
37 #ifndef HAVE_BSD_TYPES
38 typedef uint8_t u_int8_t
;
39 typedef uint16_t u_int16_t
;
40 typedef uint32_t u_int32_t
;
41 typedef uint64_t u_int64_t
;
45 #define _PATH_BSHELL "/bin/sh"
46 #define _PATH_TMP "/tmp/"
47 #define _PATH_DEVNULL "/dev/null"
48 #define _PATH_TTY "/dev/tty"
49 #define _PATH_DEV "/dev/"
53 #include <sys/queue.h>
55 #include "compat/queue.h"
61 #include "compat/tree.h"
64 #ifdef HAVE_BITSTRING_H
65 #include <bitstring.h>
67 #include "compat/bitstring.h"
89 #include "compat/vis.h"
95 #include "compat/imsg.h"
101 #include <inttypes.h>
104 #ifdef BROKEN_CMSG_FIRSTHDR
106 #define CMSG_FIRSTHDR(mhdr) \
107 ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
108 (struct cmsghdr *)(mhdr)->msg_control : \
109 (struct cmsghdr *)NULL)
113 #ifdef _CMSG_DATA_ALIGN
114 #define CMSG_ALIGN _CMSG_DATA_ALIGN
116 #define CMSG_ALIGN(len) (((len) + sizeof(long) - 1) & ~(sizeof(long) - 1))
121 #define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len))
125 #define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
129 #define O_DIRECTORY 0
141 #define SUN_LEN(sun) (sizeof (sun)->sun_path)
145 #define timercmp(tvp, uvp, cmp) \
146 (((tvp)->tv_sec == (uvp)->tv_sec) ? \
147 ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
148 ((tvp)->tv_sec cmp (uvp)->tv_sec))
152 #define timeradd(tvp, uvp, vvp) \
154 (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
155 (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
156 if ((vvp)->tv_usec >= 1000000) { \
158 (vvp)->tv_usec -= 1000000; \
164 #define timersub(tvp, uvp, vvp) \
166 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
167 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
168 if ((vvp)->tv_usec < 0) { \
170 (vvp)->tv_usec += 1000000; \
176 #define TTY_NAME_MAX 32
181 #define bzero(buf, len) memset(buf, 0, len);
184 #ifndef HAVE_CLOSEFROM
189 #ifndef HAVE_STRCASESTR
191 char *strcasestr(const char *, const char *);
196 char *strsep(char **, const char *);
199 #ifndef HAVE_STRTONUM
201 long long strtonum(const char *, long long, long long, const char **);
206 size_t strlcpy(char *, const char *, size_t);
211 size_t strlcat(char *, const char *, size_t);
216 int daemon(int, int);
219 #ifndef HAVE_B64_NTOP
221 #undef b64_ntop /* for Cygwin */
222 int b64_ntop(const char *, size_t, char *, size_t);
227 #include <sys/ioctl.h>
228 pid_t
forkpty(int *, char *, struct termios
*, struct winsize
*);
231 #ifndef HAVE_ASPRINTF
233 int asprintf(char **, const char *, ...);
234 int vasprintf(char **, const char *, va_list);
239 char *fgetln(FILE *, size_t *);
244 int setenv(const char *, const char *, int);
245 int unsetenv(const char *);
248 #ifndef HAVE_CFMAKERAW
250 void cfmakeraw(struct termios
*);
255 #define AT_FDCWD -100
256 int openat(int, const char *, int, ...);
263 extern int BSDopterr
;
264 extern int BSDoptind
;
265 extern int BSDoptopt
;
266 extern int BSDoptreset
;
267 extern char *BSDoptarg
;
268 int BSDgetopt(int, char *const *, const char *);
269 #define getopt(ac, av, o) BSDgetopt(ac, av, o)
270 #define opterr BSDopterr
271 #define optind BSDoptind
272 #define optopt BSDoptopt
273 #define optreset BSDoptreset
274 #define optarg BSDoptarg
277 #endif /* COMPAT_H */