Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

system.h

Go to the documentation of this file.
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 /*@-redef@*/
00016 typedef unsigned int u_int32_t;
00017 typedef unsigned short u_int16_t;
00018 typedef unsigned char u_int8_t;
00019 /*@-incondefs@*/        /* LCLint 3.0.0.15 */
00020 typedef int int32_t;
00021 /*@=incondefs@*/
00022 /* XXX from /usr/include/bits/sigset.h */
00023 /*@-sizeoftype@*/
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 /*@=sizeoftype@*/
00030 /*@=redef@*/
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 /* <unistd.h> should be included before any preprocessor test
00041    of _POSIX_VERSION.  */
00042 #ifdef HAVE_UNISTD_H
00043 #include <unistd.h>
00044 #if defined(__LCLINT__)
00045 /*@-superuser -declundef -incondefs @*/ /* LCL: modifies clause missing */
00046 extern int chroot (const char *__path)
00047         /*@globals errno, systemState @*/
00048         /*@modifies errno, systemState @*/;
00049 /*@=superuser =declundef =incondefs @*/
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 /* Since major is a function on SVR4, we can't use `ifndef major'.  */
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                    /* Might be defined in sys/types.h.  */
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(/*@out@*/ char * dest, const char * src);
00107 #endif
00108 
00109 #if !defined(HAVE_STPNCPY)
00110 char * stpncpy(/*@out@*/ char * dest, const char * src, size_t n);
00111 #endif
00112 
00113 #include <errno.h>
00114 #ifndef errno
00115 /*@-declundef @*/
00116 extern int errno;
00117 /*@=declundef @*/
00118 #endif
00119 
00120 #if defined(__LCLINT__)
00121 /*@-declundef @*/
00122 /*@exits@*/
00123 extern void error(int status, int errnum, const char *format, ...)
00124         __attribute__ ((__format__ (__printf__, 3, 4)))
00125         /*@globals fileSystem @*/
00126         /*@modifies fileSystem @*/;
00127 /*@=declundef @*/
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 /*@-macrounrecog -incondefs -globuse -mustmod @*/ /* FIX: shrug */
00140 #define getopt system_getopt
00141 /*@=macrounrecog =incondefs =globuse =mustmod @*/
00142 /*@-skipansiheaders@*/
00143 #include <stdlib.h>
00144 /*@=skipansiheaders@*/
00145 #undef getopt
00146 #if defined(__LCLINT__)
00147 /*@-declundef -incondefs @*/    /* LCL: modifies clause missing */
00148 extern char * realpath (const char * file_name, /*@out@*/ char * resolved_name)
00149         /*@globals errno, fileSystem @*/
00150         /*@requires maxSet(resolved_name) >=  (PATH_MAX - 1); @*/
00151         /*@modifies *resolved_name, errno, fileSystem @*/;
00152 /*@=declundef =incondefs @*/
00153 #endif
00154 #else /* not STDC_HEADERS */
00155 char *getenv (const char *name);
00156 #if ! HAVE_REALPATH
00157 char *realpath(const char *path, char resolved_path []);
00158 #endif
00159 #endif /* STDC_HEADERS */
00160 
00161 /* XXX solaris2.5.1 has not */
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 /* not HAVE_DIRENT_H */
00188 # define dirent direct
00189 # define NLENGTH(direct) ((direct)->d_namlen)
00190 # ifdef HAVE_SYS_NDIR_H
00191 #  include <sys/ndir.h>
00192 # endif /* HAVE_SYS_NDIR_H */
00193 # ifdef HAVE_SYS_DIR_H
00194 #  include <sys/dir.h>
00195 # endif /* HAVE_SYS_DIR_H */
00196 # ifdef HAVE_NDIR_H
00197 #  include <ndir.h>
00198 # endif /* HAVE_NDIR_H */
00199 #endif /* HAVE_DIRENT_H */
00200 
00201 #if defined(__LCLINT__)
00202 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
00203 /*@only@*/ /*@out@*/ void * alloca (size_t __size)
00204         /*@ensures maxSet(result) == (__size - 1) @*/
00205         /*@*/;
00206 /*@=declundef =incondefs @*/
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 /* AIX alloca decl has to be the first thing in the file, bletch! */
00218 char *alloca ();
00219 #  endif
00220 # endif
00221 #endif
00222 
00223 #if defined (__GLIBC__) && defined(__LCLINT__)
00224 /*@-declundef@*/
00225 /*@unchecked@*/
00226 extern __const __int32_t *__ctype_tolower;
00227 /*@unchecked@*/
00228 extern __const __int32_t *__ctype_toupper;
00229 /*@=declundef@*/
00230 #endif
00231 
00232 #include <ctype.h>
00233 
00234 #if defined (__GLIBC__) && defined(__LCLINT__)
00235 /*@-exportlocal@*/
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 /*@=exportlocal@*/
00247 
00248 #endif
00249 
00250 #if HAVE_SYS_MMAN_H && !defined(__LCLINT__)
00251 #include <sys/mman.h>
00252 #endif
00253 
00254 /* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
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 /*@-noparams@*/
00269 #include <getopt.h>
00270 /*@=noparams@*/
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 /*@-declundef -incondefs @*/ /* FIX: these are macros */
00292 /*@mayexit@*/ /*@only@*/ /*@out@*/ void * xmalloc (size_t size)
00293         /*@globals errno @*/
00294         /*@ensures maxSet(result) == (size - 1) @*/
00295         /*@modifies errno @*/;
00296 
00299 /*@mayexit@*/ /*@only@*/ void * xcalloc (size_t nmemb, size_t size)
00300         /*@ensures maxSet(result) == (nmemb - 1) @*/
00301         /*@*/;
00302 
00306 /*@mayexit@*/ /*@only@*/ void * xrealloc (/*@null@*/ /*@only@*/ void * ptr,
00307                                         size_t size)
00308         /*@ensures maxSet(result) == (size - 1) @*/
00309         /*@modifies *ptr @*/;
00310 
00313 /*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
00314         /*@*/;
00315 /*@=declundef =incondefs @*/
00316 
00319 /*@unused@*/ /*@exits@*/ /*@only@*/ void * vmefail(size_t size)
00320         /*@*/;
00321 
00322 #if HAVE_MCHECK_H
00323 #include <mcheck.h>
00324 #if defined(__LCLINT__)
00325 /*@-declundef -incondefs @*/ /* LCL: missing annotations */
00326 #if 0
00327 enum mcheck_status
00328   {
00329     MCHECK_DISABLED = -1,       /* Consistency checking is not turned on.  */
00330     MCHECK_OK,                  /* Block is fine.  */
00331     MCHECK_FREE,                /* Block freed twice.  */
00332     MCHECK_HEAD,                /* Memory before the block was clobbered.  */
00333     MCHECK_TAIL                 /* Memory after the block was clobbered.  */
00334   };
00335 #endif
00336 
00337 extern int mcheck (void (*__abortfunc) (enum mcheck_status))
00338         /*@globals internalState@*/
00339         /*@modifies internalState @*/;
00340 extern int mcheck_pedantic (void (*__abortfunc) (enum mcheck_status))
00341         /*@globals internalState@*/
00342         /*@modifies internalState @*/;
00343 extern void mcheck_check_all (void)
00344         /*@globals internalState@*/
00345         /*@modifies internalState @*/;
00346 extern enum mcheck_status mprobe (void *__ptr)
00347         /*@globals internalState@*/
00348         /*@modifies internalState @*/;
00349 extern void mtrace (void)
00350         /*@globals internalState@*/
00351         /*@modifies internalState @*/;
00352 extern void muntrace (void)
00353         /*@globals internalState@*/
00354         /*@modifies internalState @*/;
00355 /*@=declundef =incondefs @*/
00356 #endif /* defined(__LCLINT__) */
00357 
00358 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
00359 #if defined(__GNUC__)
00360 #define xmalloc(_size)          (malloc(_size) ? : vmefail(_size))
00361 #define xcalloc(_nmemb, _size)  (calloc((_nmemb), (_size)) ? : vmefail(_size))
00362 #define xrealloc(_ptr, _size)   (realloc((_ptr), (_size)) ? : vmefail(_size))
00363 #define xstrdup(_str)   (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
00364 #endif  /* defined(__GNUC__) */
00365 #endif  /* HAVE_MCHECK_H */
00366 
00367 /* Retrofit glibc __progname */
00368 #if defined __GLIBC__ && __GLIBC__ >= 2
00369 #if __GLIBC_MINOR__ >= 1
00370 #define __progname      __assert_program_name
00371 #endif
00372 #define setprogname(pn)
00373 #else
00374 #define __progname      program_name
00375 #define setprogname(pn) \
00376   { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
00377     else __progname = pn;               \
00378   }
00379 #endif
00380 /*@unchecked@*/
00381 const char *__progname;
00382 
00383 #if HAVE_NETDB_H
00384 #include <netdb.h>
00385 #endif
00386 
00387 #if HAVE_PWD_H
00388 #include <pwd.h>
00389 #endif
00390 
00391 /* Take care of NLS matters.  */
00392 
00393 #if HAVE_LOCALE_H
00394 # include <locale.h>
00395 #endif
00396 #if !HAVE_SETLOCALE
00397 # define setlocale(Category, Locale) /* empty */
00398 #endif
00399 
00400 #if ENABLE_NLS && !defined(__LCLINT__)
00401 # include <libintl.h>
00402 # define _(Text) gettext (Text)
00403 #else
00404 # undef bindtextdomain
00405 # define bindtextdomain(Domain, Directory) /* empty */
00406 # undef textdomain
00407 # define textdomain(Domain) /* empty */
00408 # define _(Text) Text
00409 # undef dgettext
00410 # define dgettext(DomainName, Text) Text
00411 #endif
00412 
00413 #define N_(Text) Text
00414 
00415 /* ============== from misc/miscfn.h */
00416 
00417 #if !defined(USE_GNU_GLOB)
00418 #if HAVE_FNMATCH_H
00419 /*@-noparams@*/
00420 #include <fnmatch.h>
00421 /*@=noparams@*/
00422 #endif
00423 
00424 #if HAVE_GLOB_H
00425 /*@-noparams@*/
00426 #include <glob.h>
00427 /*@=noparams@*/
00428 #endif
00429 #else
00430 /*@-noparams@*/
00431 #include "misc/glob.h"
00432 #include "misc/fnmatch.h"
00433 /*@=noparams@*/
00434 #endif
00435 
00436 #if defined(__LCLINT__)
00437 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
00438 #if 0
00439 typedef /*@concrete@*/ struct
00440   {
00441     size_t gl_pathc;
00442     char **gl_pathv;
00443     size_t gl_offs;
00444     int gl_flags;
00445 
00446     void (*gl_closedir) (void *);
00447 #ifdef _GNU_SOURCE
00448     struct dirent *(*gl_readdir) (void *);
00449 #else
00450     void *(*gl_readdir) (void *);
00451 #endif
00452     ptr_t (*gl_opendir) (const char *);
00453 #ifdef _GNU_SOURCE
00454     int (*gl_lstat) (const char *restrict, struct stat *restrict);
00455     int (*gl_stat) (const char *restrict, struct stat *restrict);
00456 #else
00457     int (*gl_lstat) (const char *restrict, void *restrict);
00458     int (*gl_stat) (const char *restrict, void *restrict);
00459 #endif
00460   } glob_t;
00461 #endif
00462 
00463 #if 0
00464 /*@-constuse@*/
00465 /*@constant int GLOB_ERR@*/
00466 /*@constant int GLOB_MARK@*/
00467 /*@constant int GLOB_NOSORT@*/
00468 /*@constant int GLOB_DOOFFS@*/
00469 /*@constant int GLOB_NOCHECK@*/
00470 /*@constant int GLOB_APPEND@*/
00471 /*@constant int GLOB_NOESCAPE@*/
00472 /*@constant int GLOB_PERIOD@*/
00473 
00474 #ifdef _GNU_SOURCE
00475 /*@constant int GLOB_MAGCHAR@*/
00476 /*@constant int GLOB_ALTDIRFUNC@*/
00477 /*@constant int GLOB_BRACE@*/
00478 /*@constant int GLOB_NOMAGIC@*/
00479 /*@constant int GLOB_TILDE@*/
00480 /*@constant int GLOB_ONLYDIR@*/
00481 /*@constant int GLOB_TILDE_CHECK@*/
00482 #endif
00483 
00484 /*@constant int GLOB_FLAGS@*/
00485 
00486 /*@constant int GLOB_NOSPACE@*/
00487 /*@constant int GLOB_ABORTED@*/
00488 /*@constant int GLOB_NOMATCH@*/
00489 /*@constant int GLOB_NOSYS@*/
00490 #ifdef _GNU_SOURCE
00491 /*@constant int GLOB_ABEND@*/
00492 #endif
00493 /*@=constuse@*/
00494 #endif
00495 
00496 extern int glob (const char *pattern, int flags,
00497                       int (*errfunc) (const char *, int),
00498                       /*@out@*/ glob_t *pglob)
00499         /*@globals errno, fileSystem @*/
00500         /*@modifies *pglob, errno, fileSystem @*/;
00501         /* XXX only annotation is a white lie */
00502 extern void globfree (/*@only@*/ glob_t *pglob)
00503         /*@modifies *pglob @*/;
00504 #ifdef _GNU_SOURCE
00505 extern int glob_pattern_p (const char *pattern, int quote)
00506         /*@*/;
00507 #endif
00508 
00509 #if 0
00510 /*@-constuse@*/
00511 /*@constant int FNM_PATHNAME@*/
00512 /*@constant int FNM_NOESCAPE@*/
00513 /*@constant int FNM_PERIOD@*/
00514 
00515 #ifdef _GNU_SOURCE
00516 /*@constant int FNM_FILE_NAME@*/        /* GNU extension */
00517 /*@constant int FNM_LEADING_DIR@*/      /* GNU extension */
00518 /*@constant int FNM_CASEFOLD@*/         /* GNU extension */
00519 /*@constant int FNM_EXTMATCH@*/         /* GNU extension */
00520 #endif
00521 
00522 /*@constant int FNM_NOMATCH@*/
00523 
00524 #ifdef _XOPEN_SOURCE
00525 /*@constant int FNM_NOSYS@*/            /* X/Open */
00526 #endif
00527 /*@=constuse@*/
00528 #endif
00529 
00530 extern int fnmatch (const char *pattern, const char *string, int flags)
00531         /*@*/;
00532 /*@=declundef =incondefs @*/
00533 #endif
00534 
00535 #if ! HAVE_S_IFSOCK
00536 #define S_IFSOCK (0xc000)
00537 #endif
00538 
00539 #if ! HAVE_S_ISLNK
00540 #define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
00541 #endif
00542 
00543 #if ! HAVE_S_ISSOCK
00544 #define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
00545 #endif
00546 
00547 #if NEED_STRINGS_H
00548 #include <strings.h>
00549 #endif
00550 
00551 #if NEED_MYREALLOC
00552 #define realloc(ptr,size) myrealloc(ptr,size)
00553 extern void *myrealloc(void *, size_t);
00554 #endif
00555 
00556 #if ! HAVE_SETENV
00557 extern int setenv(const char *name, const char *value, int replace);
00558 extern void unsetenv(const char *name);
00559 #endif
00560 
00561 #if HAVE_SYS_SOCKET_H
00562 #include <sys/types.h>
00563 #include <sys/socket.h>
00564 #endif
00565 
00566 #if HAVE_SYS_SELECT_H && !defined(__LCLINT__)
00567 #include <sys/select.h>
00568 #endif
00569 
00570 /* Solaris <= 2.6 limits getpass return to only 8 chars */
00571 #if HAVE_GETPASSPHRASE
00572 #define getpass getpassphrase
00573 #endif
00574 
00575 #if ! HAVE_LCHOWN
00576 #define lchown chown
00577 #endif
00578 
00579 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
00580 # define GETMNTENT_ONE 0
00581 # define GETMNTENT_TWO 0
00582 # if HAVE_SYS_MNTCTL_H
00583 #  include <sys/mntctl.h>
00584 # endif
00585 # if HAVE_SYS_VMOUNT_H
00586 #  include <sys/vmount.h>
00587 # endif
00588 # if HAVE_SYS_MOUNT_H
00589 #  include <sys/mount.h>
00590 # endif
00591 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
00592 # if HAVE_MNTENT_H
00593 #  include <stdio.h>
00594 #  include <mntent.h>
00595 #  define our_mntent struct mntent
00596 #  define our_mntdir mnt_dir
00597 # elif HAVE_STRUCT_MNTTAB
00598 #  include <stdio.h>
00599 #  include <mnttab.h>
00600    struct our_mntent {
00601        char * our_mntdir;
00602    };
00603    struct our_mntent *getmntent(FILE *filep);
00604 #  define our_mntent struct our_mntent
00605 # else
00606 #  include <stdio.h>
00607    struct our_mntent {
00608        char * our_mntdir;
00609    };
00610    struct our_mntent *getmntent(FILE *filep);
00611 #  define our_mntent struct our_mntent
00612 # endif
00613 # define GETMNTENT_ONE 1
00614 # define GETMNTENT_TWO 0
00615 #elif HAVE_SYS_MNTTAB_H
00616 # include <stdio.h>
00617 # include <sys/mnttab.h>
00618 # define GETMNTENT_ONE 0
00619 # define GETMNTENT_TWO 1
00620 # define our_mntent struct mnttab
00621 # define our_mntdir mnt_mountp
00622 #else /* if !HAVE_MNTCTL */
00623 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
00624 #endif
00625 
00626 #ifndef MOUNTED
00627 #define MOUNTED "/etc/mnttab"
00628 #endif
00629 
00630 #if defined(__LCLINT__)
00631 #define FILE_RCSID(id)
00632 #else
00633 #define FILE_RCSID(id) \
00634 static inline const char *rcsid(const char *p) { \
00635         return rcsid(p = id); \
00636 }
00637 #endif
00638 
00639 #endif  /* H_SYSTEM */

Generated on Mon Sep 13 15:06:00 2004 for rpm by doxygen 1.3.5