2 * Copyright (c) 1984 through 2008, William LeFebvre
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
16 * * Neither the name of William LeFebvre nor the names of other
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <sys/types.h>
36 #include <sys/param.h>
43 #if TIME_WITH_SYS_TIME
44 # include <sys/time.h>
48 # include <sys/time.h>
57 #define setbuffer(f, b, s) setvbuf((f), (b), (b) ? _IOFBF : _IONBF, (s))
58 #define memzero(a, b) memset((a), 0, (b))
59 #else /* !STDC_HEADERS */
61 #define strchr(a, b) index((a), (b))
62 #define strrchr(a, b) rindex((a), (b))
63 #endif /* HAVE_STRCHR */
65 #define memzero(a, b) memset((a), 0, (b))
67 #define memcpy(a, b, c) bcopy((b), (a), (c))
68 #define memzero(a, b) bzero((a), (b))
69 #define memcmp(a, b, c) bcmp((a), (b), (c))
70 #endif /* HAVE_MEMCPY */
80 #endif /* STDC_HEADERS */
82 /* If snprintf or vsnprintf aren't available, we substitute our own.
83 But we have to include stdarg in order to be able to define them.
88 int ap_snprintf(char *buf
, size_t len
, const char *format
,...);
89 #define snprintf ap_snprintf
91 #ifndef HAVE_VSNPRINTF
92 int ap_vsnprintf(char *buf
, size_t len
, const char *format
,va_list ap
);
93 #define vsnprintf ap_vsnprintf
108 #define INT_MAX (0x7fffffff)
112 #define UINT_MAX (0xffffffffU)
115 /* we must have both sighold and sigrelse to use them */
116 #if defined(HAVE_SIGHOLD) && !defined(HAVE_SIGRELSE)
124 #ifdef HAVE_SYSEXITS_H
125 #include <sysexits.h>
127 #define EX_OK 0 /* successful termination */
128 #define EX_USAGE 64 /* command line usage error */
129 #define EX_DATAERR 65 /* data format error */
130 #define EX_NOINPUT 66 /* cannot open input */
131 #define EX_NOUSER 67 /* addressee unknown */
132 #define EX_NOHOST 68 /* host name unknown */
133 #define EX_UNAVAILABLE 69 /* service unavailable */
134 #define EX_SOFTWARE 70 /* internal software error */
135 #define EX_OSERR 71 /* system error (e.g., can't fork) */
136 #define EX_OSFILE 72 /* critical OS file missing */
137 #define EX_CANTCREAT 73 /* can't create (user) output file */
138 #define EX_IOERR 74 /* input/output error */
139 #define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
140 #define EX_PROTOCOL 76 /* remote error in protocol */
141 #define EX_NOPERM 77 /* permission denied */
142 #define EX_CONFIG 78 /* configuration error */