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