00001
00005 #ifndef H_SYSTEM
00006 #define H_SYSTEM
00007
00008 #ifdef HAVE_CONFIG_H
00009 #include "config.h"
00010 #endif
00011
00012 #include <sys/types.h>
00013 #include <sys/stat.h>
00014 #include <stdio.h>
00015
00016 #ifdef HAVE_SYS_PARAM_H
00017 #include <sys/param.h>
00018 #endif
00019
00020
00021
00022 #ifdef HAVE_UNISTD_H
00023 #include <unistd.h>
00024 #endif
00025
00026 #if TIME_WITH_SYS_TIME
00027 # include <sys/time.h>
00028 # include <time.h>
00029 #else
00030 # if HAVE_SYS_TIME_H
00031 # include <sys/time.h>
00032 # else
00033 # include <time.h>
00034 # endif
00035 #endif
00036
00037 #if NEED_TIMEZONE
00038 extern time_t timezone;
00039 #endif
00040
00041 #ifdef __LCLINT__
00042 typedef unsigned int u_int32_t;
00043 typedef unsigned short u_int16_t;
00044 typedef unsigned char u_int8_t;
00045
00046 typedef int int32_t;
00047
00048
00049 void * alloca (size_t size) ;
00050
00051 #endif
00052
00053
00054 #if MAJOR_IN_MKDEV
00055 #include <sys/mkdev.h>
00056 #define HAVE_MAJOR
00057 #endif
00058 #if MAJOR_IN_SYSMACROS
00059 #include <sys/sysmacros.h>
00060 #define HAVE_MAJOR
00061 #endif
00062 #ifdef major
00063 #define HAVE_MAJOR
00064 #endif
00065
00066 #ifndef HAVE_MAJOR
00067 #define major(dev) (((dev) >> 8) & 0xff)
00068 #define minor(dev) ((dev) & 0xff)
00069 #define makedev(maj, min) (((maj) << 8) | (min))
00070 #endif
00071 #undef HAVE_MAJOR
00072
00073 #ifdef HAVE_UTIME_H
00074 #include <utime.h>
00075 #endif
00076
00077
00078
00079
00080 #ifdef HAVE_STRING_H
00081 # if !STDC_HEADERS && HAVE_MEMORY_H
00082 # include <memory.h>
00083 # endif
00084 # include <string.h>
00085 #else
00086 # include <strings.h>
00087 char *memchr ();
00088 #endif
00089
00090 #if !defined(HAVE_STPCPY) || defined(__LCLINT__)
00091
00092 char * stpcpy(char * dest, const char * src) ;
00093
00094 #endif
00095
00096 #if !defined(HAVE_STPNCPY) || defined(__LCLINT__)
00097
00098 char * stpncpy(char * dest, const char * src, size_t n) ;
00099
00100 #endif
00101
00102 #include <errno.h>
00103 #ifndef errno
00104
00105 extern int errno;
00106
00107 #endif
00108
00109 #ifdef STDC_HEADERS
00110
00111 #define getopt system_getopt
00112
00113
00114 #include <stdlib.h>
00115
00116 #undef getopt
00117 #else
00118 char *getenv (const char *name);
00119 #endif
00120
00121
00122 #if !defined(EXIT_FAILURE)
00123 #define EXIT_FAILURE 1
00124 #endif
00125
00126 #ifdef HAVE_FCNTL_H
00127 #include <fcntl.h>
00128 #else
00129 #include <sys/file.h>
00130 #endif
00131
00132 #if !defined(SEEK_SET) && !defined(__LCLINT__)
00133 #define SEEK_SET 0
00134 #define SEEK_CUR 1
00135 #define SEEK_END 2
00136 #endif
00137 #if !defined(F_OK) && !defined(__LCLINT__)
00138 #define F_OK 0
00139 #define X_OK 1
00140 #define W_OK 2
00141 #define R_OK 4
00142 #endif
00143
00144 #ifdef HAVE_DIRENT_H
00145 # include <dirent.h>
00146 # define NLENGTH(direct) (strlen((direct)->d_name))
00147 #else
00148 # define dirent direct
00149 # define NLENGTH(direct) ((direct)->d_namlen)
00150 # ifdef HAVE_SYS_NDIR_H
00151 # include <sys/ndir.h>
00152 # endif
00153 # ifdef HAVE_SYS_DIR_H
00154 # include <sys/dir.h>
00155 # endif
00156 # ifdef HAVE_NDIR_H
00157 # include <ndir.h>
00158 # endif
00159 #endif
00160
00161 #ifdef __GNUC__
00162 # undef alloca
00163 # define alloca __builtin_alloca
00164 #else
00165 # ifdef HAVE_ALLOCA_H
00166 # include <alloca.h>
00167 # else
00168 # ifndef _AIX
00169
00170 char *alloca ();
00171 # endif
00172 # endif
00173 #endif
00174
00175 #include <ctype.h>
00176
00177 #if HAVE_SYS_MMAN_H
00178 #include <sys/mman.h>
00179 #endif
00180
00181
00182 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
00183 #include <sys/resource.h>
00184 #endif
00185
00186 #if HAVE_SYS_UTSNAME_H
00187 #include <sys/utsname.h>
00188 #endif
00189
00190 #if HAVE_SYS_WAIT_H
00191 #include <sys/wait.h>
00192 #endif
00193
00194 #if HAVE_GETOPT_H
00195 #include <getopt.h>
00196 #endif
00197
00198 #if HAVE_GRP_H
00199 #include <grp.h>
00200 #endif
00201
00202 #if HAVE_LIMITS_H
00203 #include <limits.h>
00204 #endif
00205
00206 #if HAVE_ERR_H
00207 #include <err.h>
00208 #endif
00209
00210 #if HAVE_MALLOC_H
00211 #include <malloc.h>
00212 #endif
00213
00214 #if HAVE_SYSLOG_H
00215 #include <syslog.h>
00216 #endif
00217
00218
00219 void * xmalloc (size_t size) ;
00220 void * xcalloc (size_t nmemb, size_t size) ;
00221 void * xrealloc ( void * ptr,
00222 size_t size) ;
00223 char * xstrdup (const char *str) ;
00224
00225 void * vmefail(size_t size);
00226
00227 #if HAVE_MCHECK_H
00228 #include <mcheck.h>
00229 #endif
00230
00231
00232
00233 #if HAVE_MCHECK_H && defined(__GNUC__)
00234 #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
00235 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
00236 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
00237 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
00238 #endif
00239
00240
00241 #if defined __GLIBC__ && __GLIBC__ >= 2
00242 #if __GLIBC_MINOR__ >= 1
00243 #define __progname __assert_program_name
00244 #endif
00245 #define setprogname(pn)
00246 #else
00247 #define __progname program_name
00248 #define setprogname(pn) \
00249 { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
00250 else __progname = pn; \
00251 }
00252 #endif
00253 const char *__progname;
00254
00255 #if HAVE_NETDB_H
00256 #ifndef __LCLINT__
00257 #include <netdb.h>
00258 #endif
00259 #endif
00260
00261 #if HAVE_PWD_H
00262 #include <pwd.h>
00263 #endif
00264
00265
00266
00267 #if HAVE_LOCALE_H
00268 # include <locale.h>
00269 #endif
00270 #if !HAVE_SETLOCALE
00271 # define setlocale(Category, Locale)
00272 #endif
00273
00274 #if ENABLE_NLS && !defined(__LCLINT__)
00275 # include <libintl.h>
00276 # define _(Text) gettext (Text)
00277 #else
00278 # undef bindtextdomain
00279 # define bindtextdomain(Domain, Directory)
00280 # undef textdomain
00281 # define textdomain(Domain)
00282 # define _(Text) Text
00283 # undef dgettext
00284 # define dgettext(DomainName, Text) Text
00285 #endif
00286
00287 #define N_(Text) Text
00288
00289
00290
00291 #if !defined(USE_GNU_GLOB)
00292 #if HAVE_FNMATCH_H
00293 #include <fnmatch.h>
00294 #endif
00295
00296 #if HAVE_GLOB_H
00297 #include <glob.h>
00298 #endif
00299 #else
00300 #include "misc/glob.h"
00301 #include "misc/fnmatch.h"
00302 #endif
00303
00304 #if ! HAVE_S_IFSOCK
00305 #define S_IFSOCK (0xC000)
00306 #endif
00307
00308 #if ! HAVE_S_ISLNK
00309 #define S_ISLNK(mode) ((mode & 0xF000) == S_IFLNK)
00310 #endif
00311
00312 #if ! HAVE_S_ISSOCK
00313 #define S_ISSOCK(mode) ((mode & 0xF000) == S_IFSOCK)
00314 #endif
00315
00316 #if NEED_STRINGS_H
00317 #include <strings.h>
00318 #endif
00319
00320 #if ! HAVE_REALPATH
00321 char *realpath(const char *path, char resolved_path []);
00322 #endif
00323
00324 #if NEED_MYREALLOC
00325 #define realloc(ptr,size) myrealloc(ptr,size)
00326 extern void *myrealloc(void *, size_t);
00327 #endif
00328
00329 #if ! HAVE_SETENV
00330 extern int setenv(const char *name, const char *value, int replace);
00331 extern void unsetenv(const char *name);
00332 #endif
00333
00334 #if HAVE_SYS_SOCKET_H
00335 #include <sys/types.h>
00336 #ifndef __LCLINT__
00337 #include <sys/socket.h>
00338 #endif
00339 #endif
00340
00341 #if HAVE_SYS_SELECT_H
00342 #include <sys/select.h>
00343 #endif
00344
00345
00346 #if HAVE_GETPASSPHRASE
00347 #define getpass getpassphrase
00348 #endif
00349
00350 #if ! HAVE_LCHOWN
00351 #define lchown chown
00352 #endif
00353
00354 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
00355 # define GETMNTENT_ONE 0
00356 # define GETMNTENT_TWO 0
00357 # if HAVE_SYS_MNTCTL_H
00358 # include <sys/mntctl.h>
00359 # endif
00360 # if HAVE_SYS_VMOUNT_H
00361 # include <sys/vmount.h>
00362 # endif
00363 # if HAVE_SYS_MOUNT_H
00364 # include <sys/mount.h>
00365 # endif
00366 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
00367 # if HAVE_MNTENT_H
00368 # include <stdio.h>
00369 # include <mntent.h>
00370 # define our_mntent struct mntent
00371 # define our_mntdir mnt_dir
00372 # elif HAVE_STRUCT_MNTTAB
00373 # include <stdio.h>
00374 # include <mnttab.h>
00375 struct our_mntent {
00376 char * our_mntdir;
00377 };
00378 struct our_mntent *getmntent(FILE *filep);
00379 # define our_mntent struct our_mntent
00380 # else
00381 # include <stdio.h>
00382 struct our_mntent {
00383 char * our_mntdir;
00384 };
00385 struct our_mntent *getmntent(FILE *filep);
00386 # define our_mntent struct our_mntent
00387 # endif
00388 # define GETMNTENT_ONE 1
00389 # define GETMNTENT_TWO 0
00390 #elif HAVE_SYS_MNTTAB_H
00391 # include <stdio.h>
00392 # include <sys/mnttab.h>
00393 # define GETMNTENT_ONE 0
00394 # define GETMNTENT_TWO 1
00395 # define our_mntent struct mnttab
00396 # define our_mntdir mnt_mountp
00397 #else
00398 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
00399 #endif
00400
00401 #ifndef MOUNTED
00402 #define MOUNTED "/etc/mnttab"
00403 #endif
00404 #endif