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