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 #include <sys/stat.h>
00014 #include <stdio.h>
00015 
00016 #ifdef HAVE_SYS_PARAM_H
00017 #include <sys/param.h>
00018 #endif
00019 
00020 /* <unistd.h> should be included before any preprocessor test
00021    of _POSIX_VERSION.  */
00022 #ifdef HAVE_UNISTD_H
00023 #include <unistd.h>
00024 #if defined(__LCLINT__)
00025 /*@-superuser -declundef -incondefs @*/ /* LCL: modifies clause missing */
00026 extern int chroot (const char *__path)
00027         /*@globals errno, systemState @*/
00028         /*@modifies errno, systemState @*/;
00029 /*@=superuser =declundef =incondefs @*/
00030 #endif
00031 #if !defined(__GLIBC__)
00032 extern char ** environ;
00033 #endif
00034 #endif
00035 
00036 #if TIME_WITH_SYS_TIME
00037 # include <sys/time.h>
00038 # include <time.h>
00039 #else
00040 # if HAVE_SYS_TIME_H
00041 #  include <sys/time.h>
00042 # else
00043 #  include <time.h>
00044 # endif
00045 #endif
00046 
00047 #if NEED_TIMEZONE
00048 extern time_t timezone;
00049 #endif
00050 
00051 /* Since major is a function on SVR4, we can't use `ifndef major'.  */
00052 #if MAJOR_IN_MKDEV
00053 #include <sys/mkdev.h>
00054 #define HAVE_MAJOR
00055 #endif
00056 #if MAJOR_IN_SYSMACROS
00057 #include <sys/sysmacros.h>
00058 #define HAVE_MAJOR
00059 #endif
00060 #ifdef major                    /* Might be defined in sys/types.h.  */
00061 #define HAVE_MAJOR
00062 #endif
00063 
00064 #ifndef HAVE_MAJOR
00065 #define major(dev)  (((dev) >> 8) & 0xff)
00066 #define minor(dev)  ((dev) & 0xff)
00067 #define makedev(maj, min)  (((maj) << 8) | (min))
00068 #endif
00069 #undef HAVE_MAJOR
00070 
00071 #ifdef HAVE_UTIME_H
00072 #include <utime.h>
00073 #endif
00074 
00075 #ifdef HAVE_STRING_H
00076 # if !STDC_HEADERS && HAVE_MEMORY_H
00077 #  include <memory.h>
00078 # endif
00079 # include <string.h>
00080 #else
00081 # include <strings.h>
00082 char *memchr ();
00083 #endif
00084 
00085 #if !defined(HAVE_STPCPY)
00086 char * stpcpy(/*@out@*/ char * dest, const char * src);
00087 #endif
00088 
00089 #if !defined(HAVE_STPNCPY)
00090 char * stpncpy(/*@out@*/ char * dest, const char * src, size_t n);
00091 #endif
00092 
00093 #include <errno.h>
00094 #ifndef errno
00095 /*@-declundef @*/
00096 extern int errno;
00097 /*@=declundef @*/
00098 #endif
00099 
00100 #ifdef STDC_HEADERS
00101 /*@-macrounrecog -incondefs -globuse -mustmod @*/ /* FIX: shrug */
00102 #define getopt system_getopt
00103 /*@=macrounrecog =incondefs =globuse =mustmod @*/
00104 /*@-skipansiheaders@*/
00105 #include <stdlib.h>
00106 /*@=skipansiheaders@*/
00107 #undef getopt
00108 #if defined(__LCLINT__)
00109 /*@-declundef -incondefs @*/    /* LCL: modifies clause missing */
00110 extern char * realpath (const char * file_name, /*@out@*/ char * resolved_name)
00111         /*@globals errno, fileSystem @*/
00112         /*@requires maxSet(resolved_name) >=  (PATH_MAX - 1); @*/
00113         /*@modifies *resolved_name, errno, fileSystem @*/;
00114 /*@=declundef =incondefs @*/
00115 #endif
00116 #else /* not STDC_HEADERS */
00117 char *getenv (const char *name);
00118 #if ! HAVE_REALPATH
00119 char *realpath(const char *path, char resolved_path []);
00120 #endif
00121 #endif /* STDC_HEADERS */
00122 
00123 /* XXX solaris2.5.1 has not */
00124 #if !defined(EXIT_FAILURE)
00125 #define EXIT_FAILURE    1
00126 #endif
00127 
00128 #ifdef HAVE_FCNTL_H
00129 #include <fcntl.h>
00130 #else
00131 #include <sys/file.h>
00132 #endif
00133 
00134 #if !defined(SEEK_SET) && !defined(__LCLINT__)
00135 #define SEEK_SET 0
00136 #define SEEK_CUR 1
00137 #define SEEK_END 2
00138 #endif
00139 #if !defined(F_OK) && !defined(__LCLINT__)
00140 #define F_OK 0
00141 #define X_OK 1
00142 #define W_OK 2
00143 #define R_OK 4
00144 #endif
00145 
00146 #ifdef HAVE_DIRENT_H
00147 # include <dirent.h>
00148 # define NLENGTH(direct) (strlen((direct)->d_name))
00149 #else /* not HAVE_DIRENT_H */
00150 # define dirent direct
00151 # define NLENGTH(direct) ((direct)->d_namlen)
00152 # ifdef HAVE_SYS_NDIR_H
00153 #  include <sys/ndir.h>
00154 # endif /* HAVE_SYS_NDIR_H */
00155 # ifdef HAVE_SYS_DIR_H
00156 #  include <sys/dir.h>
00157 # endif /* HAVE_SYS_DIR_H */
00158 # ifdef HAVE_NDIR_H
00159 #  include <ndir.h>
00160 # endif /* HAVE_NDIR_H */
00161 #endif /* HAVE_DIRENT_H */
00162 
00163 #if defined(__LCLINT__)
00164 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
00165 /*@only@*/ void * alloca (size_t __size)
00166         /*@ensures MaxSet(result) == (__size - 1) @*/
00167         /*@*/;
00168 /*@=declundef =incondefs @*/
00169 #endif
00170 
00171 #ifdef __GNUC__
00172 # undef alloca
00173 # define alloca __builtin_alloca
00174 #else
00175 # ifdef HAVE_ALLOCA_H
00176 #  include <alloca.h>
00177 # else
00178 #  ifndef _AIX
00179 /* AIX alloca decl has to be the first thing in the file, bletch! */
00180 char *alloca ();
00181 #  endif
00182 # endif
00183 #endif
00184 
00185 #if defined (__GLIBC__) && defined(__LCLINT__)
00186 /*@-declundef@*/
00187 /*@unchecked@*/
00188 extern __const __int32_t *__ctype_tolower;
00189 /*@unchecked@*/
00190 extern __const __int32_t *__ctype_toupper;
00191 /*@=declundef@*/
00192 #include <ctype.h>
00193 
00194 /*@-exportlocal@*/
00195 extern int isalnum(int) __THROW /*@*/;
00196 extern int iscntrl(int) __THROW /*@*/;
00197 extern int isgraph(int) __THROW /*@*/;
00198 extern int islower(int) __THROW /*@*/;
00199 extern int ispunct(int) __THROW /*@*/;
00200 extern int isxdigit(int) __THROW        /*@*/;
00201 extern int isascii(int) __THROW /*@*/;
00202 extern int toascii(int) __THROW /*@*/;
00203 extern int _toupper(int) __THROW        /*@*/;
00204 extern int _tolower(int) __THROW        /*@*/;
00205 /*@=exportlocal@*/
00206 
00207 #endif
00208 
00209 #if HAVE_SYS_MMAN_H && !defined(__LCLINT__)
00210 #include <sys/mman.h>
00211 #endif
00212 
00213 /* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
00214 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
00215 #include <sys/resource.h>
00216 #endif
00217 
00218 #if HAVE_SYS_UTSNAME_H
00219 #include <sys/utsname.h>
00220 #endif
00221 
00222 #if HAVE_SYS_WAIT_H
00223 #include <sys/wait.h>
00224 #endif
00225 
00226 #if HAVE_GETOPT_H
00227 /*@-noparams@*/
00228 #include <getopt.h>
00229 /*@=noparams@*/
00230 #endif
00231 
00232 #if HAVE_GRP_H
00233 #include <grp.h>
00234 #endif
00235 
00236 #if HAVE_LIMITS_H
00237 #include <limits.h>
00238 #endif
00239 
00240 #if HAVE_ERR_H
00241 #include <err.h>
00242 #endif
00243 
00244 #if HAVE_MALLOC_H && !defined(__LCLINT__)
00245 #include <malloc.h>
00246 #endif
00247 
00248 /*@-declundef -incondefs @*/ /* FIX: these are macros */
00251 /*@mayexit@*/ /*@only@*/ /*@out@*/ void * xmalloc (size_t size)
00252         /*@globals errno @*/
00253         /*@ensures MaxSet(result) == (size - 1) @*/
00254         /*@modifies errno @*/;
00255 
00258 /*@mayexit@*/ /*@only@*/ void * xcalloc (size_t nmemb, size_t size)
00259         /*@ensures MaxSet(result) == (nmemb - 1) @*/
00260         /*@*/;
00261 
00265 /*@mayexit@*/ /*@only@*/ void * xrealloc (/*@null@*/ /*@only@*/ void * ptr,
00266                                         size_t size)
00267         /*@ensures MaxSet(result) == (size - 1) @*/
00268         /*@modifies *ptr @*/;
00269 
00272 /*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
00273         /*@*/;
00274 /*@=declundef =incondefs @*/
00275 
00278 /*@unused@*/ /*@exits@*/ /*@only@*/ void * vmefail(size_t size)
00279         /*@*/;
00280 
00281 #if HAVE_MCHECK_H
00282 #include <mcheck.h>
00283 #if defined(__LCLINT__)
00284 /*@-declundef -incondefs @*/ /* LCL: missing annotations */
00285 #if 0
00286 enum mcheck_status
00287   {
00288     MCHECK_DISABLED = -1,       /* Consistency checking is not turned on.  */
00289     MCHECK_OK,                  /* Block is fine.  */
00290     MCHECK_FREE,                /* Block freed twice.  */
00291     MCHECK_HEAD,                /* Memory before the block was clobbered.  */
00292     MCHECK_TAIL                 /* Memory after the block was clobbered.  */
00293   };
00294 #endif
00295 
00296 extern int mcheck (void (*__abortfunc) (enum mcheck_status))
00297         /*@globals internalState@*/
00298         /*@modifies internalState @*/;
00299 extern int mcheck_pedantic (void (*__abortfunc) (enum mcheck_status))
00300         /*@globals internalState@*/
00301         /*@modifies internalState @*/;
00302 extern void mcheck_check_all (void)
00303         /*@globals internalState@*/
00304         /*@modifies internalState @*/;
00305 extern enum mcheck_status mprobe (void *__ptr)
00306         /*@globals internalState@*/
00307         /*@modifies internalState @*/;
00308 extern void mtrace (void)
00309         /*@globals internalState@*/
00310         /*@modifies internalState @*/;
00311 extern void muntrace (void)
00312         /*@globals internalState@*/
00313         /*@modifies internalState @*/;
00314 /*@=declundef =incondefs @*/
00315 #endif /* defined(__LCLINT__) */
00316 
00317 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
00318 #if defined(__GNUC__)
00319 #define xmalloc(_size)          (malloc(_size) ? : vmefail(_size))
00320 #define xcalloc(_nmemb, _size)  (calloc((_nmemb), (_size)) ? : vmefail(_size))
00321 #define xrealloc(_ptr, _size)   (realloc((_ptr), (_size)) ? : vmefail(_size))
00322 #define xstrdup(_str)   (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
00323 #endif  /* defined(__GNUC__) */
00324 #endif  /* HAVE_MCHECK_H */
00325 
00326 /* Retrofit glibc __progname */
00327 #if defined __GLIBC__ && __GLIBC__ >= 2
00328 #if __GLIBC_MINOR__ >= 1
00329 #define __progname      __assert_program_name
00330 #endif
00331 #define setprogname(pn)
00332 #else
00333 #define __progname      program_name
00334 #define setprogname(pn) \
00335   { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
00336     else __progname = pn;               \
00337   }
00338 #endif
00339 const char *__progname;
00340 
00341 #if HAVE_NETDB_H
00342 #include <netdb.h>
00343 #endif
00344 
00345 #if HAVE_PWD_H
00346 #include <pwd.h>
00347 #endif
00348 
00349 /* Take care of NLS matters.  */
00350 
00351 #if HAVE_LOCALE_H
00352 # include <locale.h>
00353 #endif
00354 #if !HAVE_SETLOCALE
00355 # define setlocale(Category, Locale) /* empty */
00356 #endif
00357 
00358 #if ENABLE_NLS && !defined(__LCLINT__)
00359 # include <libintl.h>
00360 # define _(Text) gettext (Text)
00361 #else
00362 # undef bindtextdomain
00363 # define bindtextdomain(Domain, Directory) /* empty */
00364 # undef textdomain
00365 # define textdomain(Domain) /* empty */
00366 # define _(Text) Text
00367 # undef dgettext
00368 # define dgettext(DomainName, Text) Text
00369 #endif
00370 
00371 #define N_(Text) Text
00372 
00373 /* ============== from misc/miscfn.h */
00374 
00375 #if !defined(USE_GNU_GLOB)
00376 #if HAVE_FNMATCH_H
00377 /*@-noparams@*/
00378 #include <fnmatch.h>
00379 /*@=noparams@*/
00380 #endif
00381 
00382 #if HAVE_GLOB_H
00383 /*@-noparams@*/
00384 #include <glob.h>
00385 /*@=noparams@*/
00386 #endif
00387 #else
00388 /*@-noparams@*/
00389 #include "misc/glob.h"
00390 #include "misc/fnmatch.h"
00391 /*@=noparams@*/
00392 #endif
00393 
00394 #if defined(__LCLINT__)
00395 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
00396 #if 0
00397 typedef /*@concrete@*/ struct
00398   {
00399     size_t gl_pathc;
00400     char **gl_pathv;
00401     size_t gl_offs;
00402     int gl_flags;
00403 
00404     void (*gl_closedir) (void *);
00405 #ifdef _GNU_SOURCE
00406     struct dirent *(*gl_readdir) (void *);
00407 #else
00408     void *(*gl_readdir) (void *);
00409 #endif
00410     ptr_t (*gl_opendir) (const char *);
00411 #ifdef _GNU_SOURCE
00412     int (*gl_lstat) (const char *restrict, struct stat *restrict);
00413     int (*gl_stat) (const char *restrict, struct stat *restrict);
00414 #else
00415     int (*gl_lstat) (const char *restrict, void *restrict);
00416     int (*gl_stat) (const char *restrict, void *restrict);
00417 #endif
00418   } glob_t;
00419 #endif
00420 
00421 #if 0
00422 /*@-constuse@*/
00423 /*@constant int GLOB_ERR@*/
00424 /*@constant int GLOB_MARK@*/
00425 /*@constant int GLOB_NOSORT@*/
00426 /*@constant int GLOB_DOOFFS@*/
00427 /*@constant int GLOB_NOCHECK@*/
00428 /*@constant int GLOB_APPEND@*/
00429 /*@constant int GLOB_NOESCAPE@*/
00430 /*@constant int GLOB_PERIOD@*/
00431 
00432 #ifdef _GNU_SOURCE
00433 /*@constant int GLOB_MAGCHAR@*/
00434 /*@constant int GLOB_ALTDIRFUNC@*/
00435 /*@constant int GLOB_BRACE@*/
00436 /*@constant int GLOB_NOMAGIC@*/
00437 /*@constant int GLOB_TILDE@*/
00438 /*@constant int GLOB_ONLYDIR@*/
00439 /*@constant int GLOB_TILDE_CHECK@*/
00440 #endif
00441 
00442 /*@constant int GLOB_FLAGS@*/
00443 
00444 /*@constant int GLOB_NOSPACE@*/
00445 /*@constant int GLOB_ABORTED@*/
00446 /*@constant int GLOB_NOMATCH@*/
00447 /*@constant int GLOB_NOSYS@*/
00448 #ifdef _GNU_SOURCE
00449 /*@constant int GLOB_ABEND@*/
00450 #endif
00451 /*@=constuse@*/
00452 #endif
00453 
00454 extern int glob (const char *pattern, int flags,
00455                       int (*errfunc) (const char *, int),
00456                       /*@out@*/ glob_t *pglob)
00457         /*@globals errno, fileSystem @*/
00458         /*@modifies *pglob, errno, fileSystem @*/;
00459         /* XXX only annotation is a white lie */
00460 extern void globfree (/*@only@*/ glob_t *pglob)
00461         /*@modifies *pglob @*/;
00462 #ifdef _GNU_SOURCE
00463 extern int glob_pattern_p (const char *pattern, int quote)
00464         /*@*/;
00465 #endif
00466 
00467 #if 0
00468 /*@-constuse@*/
00469 /*@constant int FNM_PATHNAME@*/
00470 /*@constant int FNM_NOESCAPE@*/
00471 /*@constant int FNM_PERIOD@*/
00472 
00473 #ifdef _GNU_SOURCE
00474 /*@constant int FNM_FILE_NAME@*/        /* GNU extension */
00475 /*@constant int FNM_LEADING_DIR@*/      /* GNU extension */
00476 /*@constant int FNM_CASEFOLD@*/         /* GNU extension */
00477 /*@constant int FNM_EXTMATCH@*/         /* GNU extension */
00478 #endif
00479 
00480 /*@constant int FNM_NOMATCH@*/
00481 
00482 #ifdef _XOPEN_SOURCE
00483 /*@constant int FNM_NOSYS@*/            /* X/Open */
00484 #endif
00485 /*@=constuse@*/
00486 #endif
00487 
00488 extern int fnmatch (const char *pattern, const char *string, int flags)
00489         /*@*/;
00490 /*@=declundef =incondefs @*/
00491 #endif
00492 
00493 #if ! HAVE_S_IFSOCK
00494 #define S_IFSOCK (0xc000)
00495 #endif
00496 
00497 #if ! HAVE_S_ISLNK
00498 #define S_ISLNK(mode) ((mode & 0xf000) == S_IFLNK)
00499 #endif
00500 
00501 #if ! HAVE_S_ISSOCK
00502 #define S_ISSOCK(mode) ((mode & 0xf000) == S_IFSOCK)
00503 #endif
00504 
00505 #if NEED_STRINGS_H
00506 #include <strings.h>
00507 #endif
00508 
00509 #if NEED_MYREALLOC
00510 #define realloc(ptr,size) myrealloc(ptr,size)
00511 extern void *myrealloc(void *, size_t);
00512 #endif
00513 
00514 #if ! HAVE_SETENV
00515 extern int setenv(const char *name, const char *value, int replace);
00516 extern void unsetenv(const char *name);
00517 #endif
00518 
00519 #if HAVE_SYS_SOCKET_H
00520 #include <sys/types.h>
00521 #include <sys/socket.h>
00522 #endif
00523 
00524 #if HAVE_SYS_SELECT_H && !defined(__LCLINT__)
00525 #include <sys/select.h>
00526 #endif
00527 
00528 /* Solaris <= 2.6 limits getpass return to only 8 chars */
00529 #if HAVE_GETPASSPHRASE
00530 #define getpass getpassphrase
00531 #endif
00532 
00533 #if ! HAVE_LCHOWN
00534 #define lchown chown
00535 #endif
00536 
00537 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
00538 # define GETMNTENT_ONE 0
00539 # define GETMNTENT_TWO 0
00540 # if HAVE_SYS_MNTCTL_H
00541 #  include <sys/mntctl.h>
00542 # endif
00543 # if HAVE_SYS_VMOUNT_H
00544 #  include <sys/vmount.h>
00545 # endif
00546 # if HAVE_SYS_MOUNT_H
00547 #  include <sys/mount.h>
00548 # endif
00549 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
00550 # if HAVE_MNTENT_H
00551 #  include <stdio.h>
00552 #  include <mntent.h>
00553 #  define our_mntent struct mntent
00554 #  define our_mntdir mnt_dir
00555 # elif HAVE_STRUCT_MNTTAB
00556 #  include <stdio.h>
00557 #  include <mnttab.h>
00558    struct our_mntent {
00559        char * our_mntdir;
00560    };
00561    struct our_mntent *getmntent(FILE *filep);
00562 #  define our_mntent struct our_mntent
00563 # else
00564 #  include <stdio.h>
00565    struct our_mntent {
00566        char * our_mntdir;
00567    };
00568    struct our_mntent *getmntent(FILE *filep);
00569 #  define our_mntent struct our_mntent
00570 # endif
00571 # define GETMNTENT_ONE 1
00572 # define GETMNTENT_TWO 0
00573 #elif HAVE_SYS_MNTTAB_H
00574 # include <stdio.h>
00575 # include <sys/mnttab.h>
00576 # define GETMNTENT_ONE 0
00577 # define GETMNTENT_TWO 1
00578 # define our_mntent struct mnttab
00579 # define our_mntdir mnt_mountp
00580 #else /* if !HAVE_MNTCTL */
00581 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
00582 #endif
00583 
00584 #ifndef MOUNTED
00585 #define MOUNTED "/etc/mnttab"
00586 #endif
00587 #endif  /* H_SYSTEM */

Generated on Fri Apr 4 14:39:42 2003 for rpm by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002