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
00014 #if defined(__LCLINT__)
00015
00016 typedef unsigned int u_int32_t;
00017 typedef unsigned short u_int16_t;
00018 typedef unsigned char u_int8_t;
00019
00020 typedef int int32_t;
00021
00022
00023 #endif
00024
00025 #include <sys/stat.h>
00026 #include <stdio.h>
00027
00028 #ifdef HAVE_SYS_PARAM_H
00029 #include <sys/param.h>
00030 #endif
00031
00032
00033
00034 #ifdef HAVE_UNISTD_H
00035 #include <unistd.h>
00036 #if defined(__LCLINT__)
00037
00038 extern int chroot (const char *__path)
00039
00040 ;
00041
00042 #endif
00043 #if !defined(__GLIBC__) && !defined(__LCLINT__)
00044 extern char ** environ;
00045 #endif
00046 #endif
00047
00048 #if TIME_WITH_SYS_TIME
00049 # include <sys/time.h>
00050 # include <time.h>
00051 #else
00052 # if HAVE_SYS_TIME_H
00053 # include <sys/time.h>
00054 # else
00055 # include <time.h>
00056 # endif
00057 #endif
00058
00059 #if NEED_TIMEZONE
00060 extern time_t timezone;
00061 #endif
00062
00063
00064 #if MAJOR_IN_MKDEV
00065 #include <sys/mkdev.h>
00066 #define HAVE_MAJOR
00067 #endif
00068 #if MAJOR_IN_SYSMACROS
00069 #include <sys/sysmacros.h>
00070 #define HAVE_MAJOR
00071 #endif
00072 #ifdef major
00073 #define HAVE_MAJOR
00074 #endif
00075
00076 #ifndef HAVE_MAJOR
00077 #define major(dev) (((dev) >> 8) & 0xff)
00078 #define minor(dev) ((dev) & 0xff)
00079 #define makedev(maj, min) (((maj) << 8) | (min))
00080 #endif
00081 #undef HAVE_MAJOR
00082
00083 #ifdef HAVE_UTIME_H
00084 #include <utime.h>
00085 #endif
00086
00087 #ifdef HAVE_STRING_H
00088 # if !STDC_HEADERS && HAVE_MEMORY_H
00089 # include <memory.h>
00090 # endif
00091 # include <string.h>
00092 #else
00093 # include <strings.h>
00094 char *memchr ();
00095 #endif
00096
00097 #if !defined(HAVE_STPCPY)
00098 char * stpcpy( char * dest, const char * src);
00099 #endif
00100
00101 #if !defined(HAVE_STPNCPY)
00102 char * stpncpy( char * dest, const char * src, size_t n);
00103 #endif
00104
00105 #include <errno.h>
00106 #ifndef errno
00107
00108 extern int errno;
00109
00110 #endif
00111
00112 #ifdef STDC_HEADERS
00113
00114 #define getopt system_getopt
00115
00116
00117 #include <stdlib.h>
00118
00119 #undef getopt
00120 #if defined(__LCLINT__)
00121
00122 extern char * realpath (const char * file_name, char * resolved_name)
00123
00124
00125 ;
00126
00127 #endif
00128 #else
00129 char *getenv (const char *name);
00130 #if ! HAVE_REALPATH
00131 char *realpath(const char *path, char resolved_path []);
00132 #endif
00133 #endif
00134
00135
00136 #if !defined(EXIT_FAILURE)
00137 #define EXIT_FAILURE 1
00138 #endif
00139
00140 #ifdef HAVE_FCNTL_H
00141 #include <fcntl.h>
00142 #else
00143 #include <sys/file.h>
00144 #endif
00145
00146 #if !defined(SEEK_SET) && !defined(__LCLINT__)
00147 #define SEEK_SET 0
00148 #define SEEK_CUR 1
00149 #define SEEK_END 2
00150 #endif
00151 #if !defined(F_OK) && !defined(__LCLINT__)
00152 #define F_OK 0
00153 #define X_OK 1
00154 #define W_OK 2
00155 #define R_OK 4
00156 #endif
00157
00158 #ifdef HAVE_DIRENT_H
00159 # include <dirent.h>
00160 # define NLENGTH(direct) (strlen((direct)->d_name))
00161 #else
00162 # define dirent direct
00163 # define NLENGTH(direct) ((direct)->d_namlen)
00164 # ifdef HAVE_SYS_NDIR_H
00165 # include <sys/ndir.h>
00166 # endif
00167 # ifdef HAVE_SYS_DIR_H
00168 # include <sys/dir.h>
00169 # endif
00170 # ifdef HAVE_NDIR_H
00171 # include <ndir.h>
00172 # endif
00173 #endif
00174
00175 #if defined(__LCLINT__)
00176
00177 void * alloca (size_t __size)
00178
00179 ;
00180
00181 #endif
00182
00183 #ifdef __GNUC__
00184 # undef alloca
00185 # define alloca __builtin_alloca
00186 #else
00187 # ifdef HAVE_ALLOCA_H
00188 # include <alloca.h>
00189 # else
00190 # ifndef _AIX
00191
00192 char *alloca ();
00193 # endif
00194 # endif
00195 #endif
00196
00197 #if defined (__GLIBC__) && defined(__LCLINT__)
00198
00199
00200 extern __const __int32_t *__ctype_tolower;
00201
00202 extern __const __int32_t *__ctype_toupper;
00203
00204 #endif
00205
00206 #include <ctype.h>
00207
00208 #if defined (__GLIBC__) && defined(__LCLINT__)
00209
00210 extern int isalnum(int) __THROW ;
00211 extern int iscntrl(int) __THROW ;
00212 extern int isgraph(int) __THROW ;
00213 extern int islower(int) __THROW ;
00214 extern int ispunct(int) __THROW ;
00215 extern int isxdigit(int) __THROW ;
00216 extern int isascii(int) __THROW ;
00217 extern int toascii(int) __THROW ;
00218 extern int _toupper(int) __THROW ;
00219 extern int _tolower(int) __THROW ;
00220
00221
00222 #endif
00223
00224 #if HAVE_SYS_MMAN_H && !defined(__LCLINT__)
00225 #include <sys/mman.h>
00226 #endif
00227
00228
00229 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
00230 #include <sys/resource.h>
00231 #endif
00232
00233 #if HAVE_SYS_UTSNAME_H
00234 #include <sys/utsname.h>
00235 #endif
00236
00237 #if HAVE_SYS_WAIT_H
00238 #include <sys/wait.h>
00239 #endif
00240
00241 #if HAVE_GETOPT_H
00242
00243 #include <getopt.h>
00244
00245 #endif
00246
00247 #if HAVE_GRP_H
00248 #include <grp.h>
00249 #endif
00250
00251 #if HAVE_LIMITS_H
00252 #include <limits.h>
00253 #endif
00254
00255 #if HAVE_ERR_H
00256 #include <err.h>
00257 #endif
00258
00259 #if HAVE_MALLOC_H && !defined(__LCLINT__)
00260 #include <malloc.h>
00261 #endif
00262
00263
00266 void * xmalloc (size_t size)
00267
00268
00269 ;
00270
00273 void * xcalloc (size_t nmemb, size_t size)
00274
00275 ;
00276
00280 void * xrealloc ( void * ptr,
00281 size_t size)
00282
00283 ;
00284
00287 char * xstrdup (const char *str)
00288 ;
00289
00290
00293 void * vmefail(size_t size)
00294 ;
00295
00296 #if HAVE_MCHECK_H
00297 #include <mcheck.h>
00298 #if defined(__LCLINT__)
00299
00300 #if 0
00301 enum mcheck_status
00302 {
00303 MCHECK_DISABLED = -1,
00304 MCHECK_OK,
00305 MCHECK_FREE,
00306 MCHECK_HEAD,
00307 MCHECK_TAIL
00308 };
00309 #endif
00310
00311 extern int mcheck (void (*__abortfunc) (enum mcheck_status))
00312
00313 ;
00314 extern int mcheck_pedantic (void (*__abortfunc) (enum mcheck_status))
00315
00316 ;
00317 extern void mcheck_check_all (void)
00318
00319 ;
00320 extern enum mcheck_status mprobe (void *__ptr)
00321
00322 ;
00323 extern void mtrace (void)
00324
00325 ;
00326 extern void muntrace (void)
00327
00328 ;
00329
00330 #endif
00331
00332
00333 #if defined(__GNUC__)
00334 #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
00335 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
00336 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
00337 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
00338 #endif
00339 #endif
00340
00341
00342 #if defined __GLIBC__ && __GLIBC__ >= 2
00343 #if __GLIBC_MINOR__ >= 1
00344 #define __progname __assert_program_name
00345 #endif
00346 #define setprogname(pn)
00347 #else
00348 #define __progname program_name
00349 #define setprogname(pn) \
00350 { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
00351 else __progname = pn; \
00352 }
00353 #endif
00354
00355 const char *__progname;
00356
00357 #if HAVE_NETDB_H
00358 #include <netdb.h>
00359 #endif
00360
00361 #if HAVE_PWD_H
00362 #include <pwd.h>
00363 #endif
00364
00365
00366
00367 #if HAVE_LOCALE_H
00368 # include <locale.h>
00369 #endif
00370 #if !HAVE_SETLOCALE
00371 # define setlocale(Category, Locale)
00372 #endif
00373
00374 #if ENABLE_NLS && !defined(__LCLINT__)
00375 # include <libintl.h>
00376 # define _(Text) gettext (Text)
00377 #else
00378 # undef bindtextdomain
00379 # define bindtextdomain(Domain, Directory)
00380 # undef textdomain
00381 # define textdomain(Domain)
00382 # define _(Text) Text
00383 # undef dgettext
00384 # define dgettext(DomainName, Text) Text
00385 #endif
00386
00387 #define N_(Text) Text
00388
00389
00390
00391 #if !defined(USE_GNU_GLOB)
00392 #if HAVE_FNMATCH_H
00393
00394 #include <fnmatch.h>
00395
00396 #endif
00397
00398 #if HAVE_GLOB_H
00399
00400 #include <glob.h>
00401
00402 #endif
00403 #else
00404
00405 #include "misc/glob.h"
00406 #include "misc/fnmatch.h"
00407
00408 #endif
00409
00410 #if defined(__LCLINT__)
00411
00412 #if 0
00413 typedef struct
00414 {
00415 size_t gl_pathc;
00416 char **gl_pathv;
00417 size_t gl_offs;
00418 int gl_flags;
00419
00420 void (*gl_closedir) (void *);
00421 #ifdef _GNU_SOURCE
00422 struct dirent *(*gl_readdir) (void *);
00423 #else
00424 void *(*gl_readdir) (void *);
00425 #endif
00426 ptr_t (*gl_opendir) (const char *);
00427 #ifdef _GNU_SOURCE
00428 int (*gl_lstat) (const char *restrict, struct stat *restrict);
00429 int (*gl_stat) (const char *restrict, struct stat *restrict);
00430 #else
00431 int (*gl_lstat) (const char *restrict, void *restrict);
00432 int (*gl_stat) (const char *restrict, void *restrict);
00433 #endif
00434 } glob_t;
00435 #endif
00436
00437 #if 0
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448 #ifdef _GNU_SOURCE
00449
00450
00451
00452
00453
00454
00455
00456 #endif
00457
00458
00459
00460
00461
00462
00463
00464 #ifdef _GNU_SOURCE
00465
00466 #endif
00467
00468 #endif
00469
00470 extern int glob (const char *pattern, int flags,
00471 int (*errfunc) (const char *, int),
00472 glob_t *pglob)
00473
00474 ;
00475
00476 extern void globfree ( glob_t *pglob)
00477 ;
00478 #ifdef _GNU_SOURCE
00479 extern int glob_pattern_p (const char *pattern, int quote)
00480 ;
00481 #endif
00482
00483 #if 0
00484
00485
00486
00487
00488
00489 #ifdef _GNU_SOURCE
00490
00491
00492
00493
00494 #endif
00495
00496
00497
00498 #ifdef _XOPEN_SOURCE
00499
00500 #endif
00501
00502 #endif
00503
00504 extern int fnmatch (const char *pattern, const char *string, int flags)
00505 ;
00506
00507 #endif
00508
00509 #if ! HAVE_S_IFSOCK
00510 #define S_IFSOCK (0xc000)
00511 #endif
00512
00513 #if ! HAVE_S_ISLNK
00514 #define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
00515 #endif
00516
00517 #if ! HAVE_S_ISSOCK
00518 #define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
00519 #endif
00520
00521 #if NEED_STRINGS_H
00522 #include <strings.h>
00523 #endif
00524
00525 #if NEED_MYREALLOC
00526 #define realloc(ptr,size) myrealloc(ptr,size)
00527 extern void *myrealloc(void *, size_t);
00528 #endif
00529
00530 #if ! HAVE_SETENV
00531 extern int setenv(const char *name, const char *value, int replace);
00532 extern void unsetenv(const char *name);
00533 #endif
00534
00535 #if HAVE_SYS_SOCKET_H
00536 #include <sys/types.h>
00537 #include <sys/socket.h>
00538 #endif
00539
00540 #if HAVE_SYS_SELECT_H && !defined(__LCLINT__)
00541 #include <sys/select.h>
00542 #endif
00543
00544
00545 #if HAVE_GETPASSPHRASE
00546 #define getpass getpassphrase
00547 #endif
00548
00549 #if ! HAVE_LCHOWN
00550 #define lchown chown
00551 #endif
00552
00553 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
00554 # define GETMNTENT_ONE 0
00555 # define GETMNTENT_TWO 0
00556 # if HAVE_SYS_MNTCTL_H
00557 # include <sys/mntctl.h>
00558 # endif
00559 # if HAVE_SYS_VMOUNT_H
00560 # include <sys/vmount.h>
00561 # endif
00562 # if HAVE_SYS_MOUNT_H
00563 # include <sys/mount.h>
00564 # endif
00565 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
00566 # if HAVE_MNTENT_H
00567 # include <stdio.h>
00568 # include <mntent.h>
00569 # define our_mntent struct mntent
00570 # define our_mntdir mnt_dir
00571 # elif HAVE_STRUCT_MNTTAB
00572 # include <stdio.h>
00573 # include <mnttab.h>
00574 struct our_mntent {
00575 char * our_mntdir;
00576 };
00577 struct our_mntent *getmntent(FILE *filep);
00578 # define our_mntent struct our_mntent
00579 # else
00580 # include <stdio.h>
00581 struct our_mntent {
00582 char * our_mntdir;
00583 };
00584 struct our_mntent *getmntent(FILE *filep);
00585 # define our_mntent struct our_mntent
00586 # endif
00587 # define GETMNTENT_ONE 1
00588 # define GETMNTENT_TWO 0
00589 #elif HAVE_SYS_MNTTAB_H
00590 # include <stdio.h>
00591 # include <sys/mnttab.h>
00592 # define GETMNTENT_ONE 0
00593 # define GETMNTENT_TWO 1
00594 # define our_mntent struct mnttab
00595 # define our_mntdir mnt_mountp
00596 #else
00597 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
00598 #endif
00599
00600 #ifndef MOUNTED
00601 #define MOUNTED "/etc/mnttab"
00602 #endif
00603
00604 #if defined(__LCLINT__)
00605 #define FILE_RCSID(id)
00606 #else
00607 #define FILE_RCSID(id) \
00608 static inline const char *rcsid(const char *p) { \
00609 return rcsid(p = id); \
00610 }
00611 #endif
00612
00613 #endif