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