Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / top / dist / os.h
blob6a9a2cdf3cb235a19b8f08eea16438e9546554cc
1 /*
2 * Copyright (c) 1984 through 2008, William LeFebvre
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
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
14 * distribution.
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.
33 #include "config.h"
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <stdio.h>
39 #ifdef HAVE_LIMITS_H
40 #include <limits.h>
41 #endif
43 #if TIME_WITH_SYS_TIME
44 # include <sys/time.h>
45 # include <time.h>
46 #else
47 # if HAVE_SYS_TIME_H
48 # include <sys/time.h>
49 # else
50 # include <time.h>
51 # endif
52 #endif
54 #ifdef __NetBSD__
55 #include <util.h>
56 #else
57 #define emalloc malloc
58 #define estrdup strdup
59 #define ecalloc calloc
60 #define erealloc realloc
61 #endif
63 #if STDC_HEADERS
64 #include <string.h>
65 #include <stdlib.h>
66 #define setbuffer(f, b, s) setvbuf((f), (b), (b) ? _IOFBF : _IONBF, (s))
67 #define memzero(a, b) memset((a), 0, (b))
68 #else /* !STDC_HEADERS */
69 #ifndef HAVE_STRCHR
70 #define strchr(a, b) index((a), (b))
71 #define strrchr(a, b) rindex((a), (b))
72 #endif /* HAVE_STRCHR */
73 #ifdef HAVE_MEMCPY
74 #define memzero(a, b) memset((a), 0, (b))
75 #else
76 #define memcpy(a, b, c) bcopy((b), (a), (c))
77 #define memzero(a, b) bzero((a), (b))
78 #define memcmp(a, b, c) bcmp((a), (b), (c))
79 #endif /* HAVE_MEMCPY */
80 #ifdef HAVE_STRINGS_H
81 #include <strings.h>
82 #else
83 #ifdef HAVE_STRING_H
84 #include <string.h>
85 #endif
86 #endif
87 char *getenv();
88 caddr_t malloc();
89 #endif /* STDC_HEADERS */
91 /* If snprintf or vsnprintf aren't available, we substitute our own.
92 But we have to include stdarg in order to be able to define them.
94 #ifdef HAVE_STDARG_H
95 #include <stdarg.h>
96 #ifndef HAVE_SNPRINTF
97 int ap_snprintf(char *buf, size_t len, const char *format,...);
98 #define snprintf ap_snprintf
99 #endif
100 #ifndef HAVE_VSNPRINTF
101 int ap_vsnprintf(char *buf, size_t len, const char *format,va_list ap);
102 #define vsnprintf ap_vsnprintf
103 #endif
104 #endif
106 #if !HAVE_PID_T
107 typedef long pid_t;
108 #endif
109 #if !HAVE_TIME_T
110 typedef long time_t;
111 #endif
112 #if !HAVE_UID_T
113 typedef long uid_t;
114 #endif
116 #ifndef INT_MAX
117 #define INT_MAX (0x7fffffff)
118 #endif
120 #ifndef UINT_MAX
121 #define UINT_MAX (0xffffffffU)
122 #endif
124 /* we must have both sighold and sigrelse to use them */
125 #if defined(HAVE_SIGHOLD) && !defined(HAVE_SIGRELSE)
126 #undef HAVE_SIGHOLD
127 #endif
129 #ifdef HAVE_UNISTD_H
130 #include <unistd.h>
131 #endif
133 #ifdef HAVE_SYSEXITS_H
134 #include <sysexits.h>
135 #else
136 #define EX_OK 0 /* successful termination */
137 #define EX_USAGE 64 /* command line usage error */
138 #define EX_DATAERR 65 /* data format error */
139 #define EX_NOINPUT 66 /* cannot open input */
140 #define EX_NOUSER 67 /* addressee unknown */
141 #define EX_NOHOST 68 /* host name unknown */
142 #define EX_UNAVAILABLE 69 /* service unavailable */
143 #define EX_SOFTWARE 70 /* internal software error */
144 #define EX_OSERR 71 /* system error (e.g., can't fork) */
145 #define EX_OSFILE 72 /* critical OS file missing */
146 #define EX_CANTCREAT 73 /* can't create (user) output file */
147 #define EX_IOERR 74 /* input/output error */
148 #define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
149 #define EX_PROTOCOL 76 /* remote error in protocol */
150 #define EX_NOPERM 77 /* permission denied */
151 #define EX_CONFIG 78 /* configuration error */
152 #endif