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