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