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_SYSLOG_H
00242 #include <syslog.h>
00243 #endif
00244
00245 #if HAVE_MALLOC_H && !defined(__LCLINT__)
00246 #include <malloc.h>
00247 #endif
00248
00249
00252 void * xmalloc (size_t size)
00253
00254
00255 ;
00256
00259 void * xcalloc (size_t nmemb, size_t size)
00260
00261 ;
00262
00266 void * xrealloc ( void * ptr,
00267 size_t size)
00268
00269 ;
00270
00273 char * xstrdup (const char *str)
00274 ;
00275
00276
00279 void * vmefail(size_t size)
00280 ;
00281
00282 #if HAVE_MCHECK_H
00283 #include <mcheck.h>
00284 #if defined(__LCLINT__)
00285
00286 #if 0
00287 enum mcheck_status
00288 {
00289 MCHECK_DISABLED = -1,
00290 MCHECK_OK,
00291 MCHECK_FREE,
00292 MCHECK_HEAD,
00293 MCHECK_TAIL
00294 };
00295 #endif
00296
00297 extern int mcheck (void (*__abortfunc) (enum mcheck_status))
00298
00299 ;
00300 extern int mcheck_pedantic (void (*__abortfunc) (enum mcheck_status))
00301
00302 ;
00303 extern void mcheck_check_all (void)
00304
00305 ;
00306 extern enum mcheck_status mprobe (void *__ptr)
00307
00308 ;
00309 extern void mtrace (void)
00310
00311 ;
00312 extern void muntrace (void)
00313
00314 ;
00315
00316 #endif
00317
00318
00319 #if defined(__GNUC__)
00320 #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
00321 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
00322 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
00323 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
00324 #endif
00325 #endif
00326
00327 #define setprogname(pn)
00328 extern const char *__progname;
00329
00330 #if HAVE_NETDB_H
00331 #include <netdb.h>
00332 #endif
00333
00334 #if HAVE_PWD_H
00335 #include <pwd.h>
00336 #endif
00337
00338
00339
00340 #if HAVE_LOCALE_H
00341 # include <locale.h>
00342 #endif
00343 #if !HAVE_SETLOCALE
00344 # define setlocale(Category, Locale)
00345 #endif
00346
00347 #if ENABLE_NLS && !defined(__LCLINT__)
00348 # include <libintl.h>
00349 # define _(Text) gettext (Text)
00350 #else
00351 # undef bindtextdomain
00352 # define bindtextdomain(Domain, Directory)
00353 # undef textdomain
00354 # define textdomain(Domain)
00355 # define _(Text) Text
00356 # undef dgettext
00357 # define dgettext(DomainName, Text) Text
00358 #endif
00359
00360 #define N_(Text) Text
00361
00362
00363
00364 #if !defined(USE_GNU_GLOB)
00365 #if HAVE_FNMATCH_H
00366
00367 #include <fnmatch.h>
00368
00369 #endif
00370
00371 #if HAVE_GLOB_H
00372
00373 #include <glob.h>
00374
00375 #endif
00376 #else
00377
00378 #include "misc/glob.h"
00379 #include "misc/fnmatch.h"
00380
00381 #endif
00382
00383 #if defined(__LCLINT__)
00384
00385 #if 0
00386 typedef struct
00387 {
00388 size_t gl_pathc;
00389 char **gl_pathv;
00390 size_t gl_offs;
00391 int gl_flags;
00392
00393 void (*gl_closedir) (void *);
00394 #ifdef _GNU_SOURCE
00395 struct dirent *(*gl_readdir) (void *);
00396 #else
00397 void *(*gl_readdir) (void *);
00398 #endif
00399 ptr_t (*gl_opendir) (const char *);
00400 #ifdef _GNU_SOURCE
00401 int (*gl_lstat) (const char *restrict, struct stat *restrict);
00402 int (*gl_stat) (const char *restrict, struct stat *restrict);
00403 #else
00404 int (*gl_lstat) (const char *restrict, void *restrict);
00405 int (*gl_stat) (const char *restrict, void *restrict);
00406 #endif
00407 } glob_t;
00408 #endif
00409
00410 #if 0
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421 #ifdef _GNU_SOURCE
00422
00423
00424
00425
00426
00427
00428
00429 #endif
00430
00431
00432
00433
00434
00435
00436
00437 #ifdef _GNU_SOURCE
00438
00439 #endif
00440
00441 #endif
00442
00443 extern int glob (const char *pattern, int flags,
00444 int (*errfunc) (const char *, int),
00445 glob_t *pglob)
00446
00447 ;
00448
00449 extern void globfree ( glob_t *pglob)
00450 ;
00451 #ifdef _GNU_SOURCE
00452 extern int glob_pattern_p (const char *pattern, int quote)
00453 ;
00454 #endif
00455
00456 #if 0
00457
00458
00459
00460
00461
00462 #ifdef _GNU_SOURCE
00463
00464
00465
00466
00467 #endif
00468
00469
00470
00471 #ifdef _XOPEN_SOURCE
00472
00473 #endif
00474
00475 #endif
00476
00477 extern int fnmatch (const char *pattern, const char *string, int flags)
00478 ;
00479
00480 #endif
00481
00482 #if ! HAVE_S_IFSOCK
00483 #define S_IFSOCK (0xc000)
00484 #endif
00485
00486 #if ! HAVE_S_ISLNK
00487 #define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
00488 #endif
00489
00490 #if ! HAVE_S_ISSOCK
00491 #define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
00492 #endif
00493
00494 #if NEED_STRINGS_H
00495 #include <strings.h>
00496 #endif
00497
00498 #if NEED_MYREALLOC
00499 #define realloc(ptr,size) myrealloc(ptr,size)
00500 extern void *myrealloc(void *, size_t);
00501 #endif
00502
00503 #if ! HAVE_SETENV
00504 extern int setenv(const char *name, const char *value, int replace);
00505 extern void unsetenv(const char *name);
00506 #endif
00507
00508 #if HAVE_SYS_SOCKET_H
00509 #include <sys/types.h>
00510 #include <sys/socket.h>
00511 #endif
00512
00513 #if HAVE_SYS_SELECT_H && !defined(__LCLINT__)
00514 #include <sys/select.h>
00515 #endif
00516
00517
00518 #if HAVE_GETPASSPHRASE
00519 #define getpass getpassphrase
00520 #endif
00521
00522 #if ! HAVE_LCHOWN
00523 #define lchown chown
00524 #endif
00525
00526 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
00527 # define GETMNTENT_ONE 0
00528 # define GETMNTENT_TWO 0
00529 # if HAVE_SYS_MNTCTL_H
00530 # include <sys/mntctl.h>
00531 # endif
00532 # if HAVE_SYS_VMOUNT_H
00533 # include <sys/vmount.h>
00534 # endif
00535 # if HAVE_SYS_MOUNT_H
00536 # include <sys/mount.h>
00537 # endif
00538 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
00539 # if HAVE_MNTENT_H
00540 # include <stdio.h>
00541 # include <mntent.h>
00542 # define our_mntent struct mntent
00543 # define our_mntdir mnt_dir
00544 # define our_mnttype mnt_type
00545 # elif HAVE_STRUCT_MNTTAB
00546 # include <stdio.h>
00547 # include <mnttab.h>
00548 struct our_mntent {
00549 char * our_mntdir;
00550 };
00551 struct our_mntent *getmntent(FILE *filep);
00552 # define our_mntent struct our_mntent
00553 # else
00554 # include <stdio.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 # endif
00561 # define GETMNTENT_ONE 1
00562 # define GETMNTENT_TWO 0
00563 #elif HAVE_SYS_MNTTAB_H
00564 # include <stdio.h>
00565 # include <sys/mnttab.h>
00566 # define GETMNTENT_ONE 0
00567 # define GETMNTENT_TWO 1
00568 # define our_mntent struct mnttab
00569 # define our_mntdir mnt_mountp
00570 #else
00571 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
00572 #endif
00573
00574 #ifndef MOUNTED
00575 #define MOUNTED "/etc/mnttab"
00576 #endif
00577 #endif