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 #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 /* Since major is a function on SVR4, we can't use `ifndef major'.  */
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                    /* Might be defined in sys/types.h.  */
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(/*@out@*/ char * dest, const char * src);
00084 #endif
00085 
00086 #if !defined(HAVE_STPNCPY)
00087 char * stpncpy(/*@out@*/ char * dest, const char * src, size_t n);
00088 #endif
00089 
00090 #include <errno.h>
00091 #ifndef errno
00092 /*@-declundef @*/
00093 extern int errno;
00094 /*@=declundef @*/
00095 #endif
00096 
00097 #ifdef STDC_HEADERS
00098 /*@-macrounrecog -incondefs -globuse -mustmod @*/ /* FIX: shrug */
00099 #define getopt system_getopt
00100 /*@=macrounrecog =incondefs =globuse =mustmod @*/
00101 /*@-skipansiheaders@*/
00102 #include <stdlib.h>
00103 /*@=skipansiheaders@*/
00104 #undef getopt
00105 #if defined(__LCLINT__)
00106 /*@-declundef -incondefs @*/    /* LCL: modifies clause missing */
00107 extern char * realpath (const char * file_name, /*@out@*/ char * resolved_name)
00108         /*@globals errno, fileSystem @*/
00109         /*@requires maxSet(resolved_name) >=  (PATH_MAX - 1); @*/
00110         /*@modifies *resolved_name, errno, fileSystem @*/;
00111 /*@=declundef =incondefs @*/
00112 #endif
00113 #else /* not STDC_HEADERS */
00114 char *getenv (const char *name);
00115 #if ! HAVE_REALPATH
00116 char *realpath(const char *path, char resolved_path []);
00117 #endif
00118 #endif /* STDC_HEADERS */
00119 
00120 /* XXX solaris2.5.1 has not */
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 /* not HAVE_DIRENT_H */
00147 # define dirent direct
00148 # define NLENGTH(direct) ((direct)->d_namlen)
00149 # ifdef HAVE_SYS_NDIR_H
00150 #  include <sys/ndir.h>
00151 # endif /* HAVE_SYS_NDIR_H */
00152 # ifdef HAVE_SYS_DIR_H
00153 #  include <sys/dir.h>
00154 # endif /* HAVE_SYS_DIR_H */
00155 # ifdef HAVE_NDIR_H
00156 #  include <ndir.h>
00157 # endif /* HAVE_NDIR_H */
00158 #endif /* HAVE_DIRENT_H */
00159 
00160 #if defined(__LCLINT__)
00161 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
00162 /*@only@*/ void * alloca (size_t __size)
00163         /*@ensures MaxSet(result) == (__size - 1) @*/
00164         /*@*/;
00165 /*@=declundef =incondefs @*/
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 /* AIX alloca decl has to be the first thing in the file, bletch! */
00177 char *alloca ();
00178 #  endif
00179 # endif
00180 #endif
00181 
00182 #if defined (__GLIBC__) && defined(__LCLINT__)
00183 /*@-declundef@*/
00184 /*@unchecked@*/
00185 extern __const __int32_t *__ctype_tolower;
00186 /*@unchecked@*/
00187 extern __const __int32_t *__ctype_toupper;
00188 /*@=declundef@*/
00189 #include <ctype.h>
00190 
00191 /*@-exportlocal@*/
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 /*@=exportlocal@*/
00203 
00204 #endif
00205 
00206 #if HAVE_SYS_MMAN_H && !defined(__LCLINT__)
00207 #include <sys/mman.h>
00208 #endif
00209 
00210 /* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
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 /*@-noparams@*/
00225 #include <getopt.h>
00226 /*@=noparams@*/
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 /*@-declundef -incondefs @*/ /* FIX: these are macros */
00252 /*@mayexit@*/ /*@only@*/ /*@out@*/ void * xmalloc (size_t size)
00253         /*@globals errno @*/
00254         /*@ensures MaxSet(result) == (size - 1) @*/
00255         /*@modifies errno @*/;
00256 
00259 /*@mayexit@*/ /*@only@*/ void * xcalloc (size_t nmemb, size_t size)
00260         /*@ensures MaxSet(result) == (nmemb - 1) @*/
00261         /*@*/;
00262 
00266 /*@mayexit@*/ /*@only@*/ void * xrealloc (/*@null@*/ /*@only@*/ void * ptr,
00267                                         size_t size)
00268         /*@ensures MaxSet(result) == (size - 1) @*/
00269         /*@modifies *ptr @*/;
00270 
00273 /*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
00274         /*@*/;
00275 /*@=declundef =incondefs @*/
00276 
00279 /*@unused@*/ /*@exits@*/ /*@only@*/ void * vmefail(size_t size)
00280         /*@*/;
00281 
00282 #if HAVE_MCHECK_H
00283 #include <mcheck.h>
00284 #if defined(__LCLINT__)
00285 /*@-declundef -incondefs @*/ /* LCL: missing annotations */
00286 #if 0
00287 enum mcheck_status
00288   {
00289     MCHECK_DISABLED = -1,       /* Consistency checking is not turned on.  */
00290     MCHECK_OK,                  /* Block is fine.  */
00291     MCHECK_FREE,                /* Block freed twice.  */
00292     MCHECK_HEAD,                /* Memory before the block was clobbered.  */
00293     MCHECK_TAIL                 /* Memory after the block was clobbered.  */
00294   };
00295 #endif
00296 
00297 extern int mcheck (void (*__abortfunc) (enum mcheck_status))
00298         /*@globals internalState@*/
00299         /*@modifies internalState @*/;
00300 extern int mcheck_pedantic (void (*__abortfunc) (enum mcheck_status))
00301         /*@globals internalState@*/
00302         /*@modifies internalState @*/;
00303 extern void mcheck_check_all (void)
00304         /*@globals internalState@*/
00305         /*@modifies internalState @*/;
00306 extern enum mcheck_status mprobe (void *__ptr)
00307         /*@globals internalState@*/
00308         /*@modifies internalState @*/;
00309 extern void mtrace (void)
00310         /*@globals internalState@*/
00311         /*@modifies internalState @*/;
00312 extern void muntrace (void)
00313         /*@globals internalState@*/
00314         /*@modifies internalState @*/;
00315 /*@=declundef =incondefs @*/
00316 #endif /* defined(__LCLINT__) */
00317 
00318 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
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  /* defined(__GNUC__) */
00325 #endif  /* HAVE_MCHECK_H */
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 /* Take care of NLS matters.  */
00339 
00340 #if HAVE_LOCALE_H
00341 # include <locale.h>
00342 #endif
00343 #if !HAVE_SETLOCALE
00344 # define setlocale(Category, Locale) /* empty */
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) /* empty */
00353 # undef textdomain
00354 # define textdomain(Domain) /* empty */
00355 # define _(Text) Text
00356 # undef dgettext
00357 # define dgettext(DomainName, Text) Text
00358 #endif
00359 
00360 #define N_(Text) Text
00361 
00362 /* ============== from misc/miscfn.h */
00363 
00364 #if !defined(USE_GNU_GLOB)
00365 #if HAVE_FNMATCH_H
00366 /*@-noparams@*/
00367 #include <fnmatch.h>
00368 /*@=noparams@*/
00369 #endif
00370 
00371 #if HAVE_GLOB_H
00372 /*@-noparams@*/
00373 #include <glob.h>
00374 /*@=noparams@*/
00375 #endif
00376 #else
00377 /*@-noparams@*/
00378 #include "misc/glob.h"
00379 #include "misc/fnmatch.h"
00380 /*@=noparams@*/
00381 #endif
00382 
00383 #if defined(__LCLINT__)
00384 /*@-declundef -incondefs @*/ /* LCL: missing annotation */
00385 #if 0
00386 typedef /*@concrete@*/ 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 /*@-constuse@*/
00412 /*@constant int GLOB_ERR@*/
00413 /*@constant int GLOB_MARK@*/
00414 /*@constant int GLOB_NOSORT@*/
00415 /*@constant int GLOB_DOOFFS@*/
00416 /*@constant int GLOB_NOCHECK@*/
00417 /*@constant int GLOB_APPEND@*/
00418 /*@constant int GLOB_NOESCAPE@*/
00419 /*@constant int GLOB_PERIOD@*/
00420 
00421 #ifdef _GNU_SOURCE
00422 /*@constant int GLOB_MAGCHAR@*/
00423 /*@constant int GLOB_ALTDIRFUNC@*/
00424 /*@constant int GLOB_BRACE@*/
00425 /*@constant int GLOB_NOMAGIC@*/
00426 /*@constant int GLOB_TILDE@*/
00427 /*@constant int GLOB_ONLYDIR@*/
00428 /*@constant int GLOB_TILDE_CHECK@*/
00429 #endif
00430 
00431 /*@constant int GLOB_FLAGS@*/
00432 
00433 /*@constant int GLOB_NOSPACE@*/
00434 /*@constant int GLOB_ABORTED@*/
00435 /*@constant int GLOB_NOMATCH@*/
00436 /*@constant int GLOB_NOSYS@*/
00437 #ifdef _GNU_SOURCE
00438 /*@constant int GLOB_ABEND@*/
00439 #endif
00440 /*@=constuse@*/
00441 #endif
00442 
00443 extern int glob (const char *pattern, int flags,
00444                       int (*errfunc) (const char *, int),
00445                       /*@out@*/ glob_t *pglob)
00446         /*@globals errno, fileSystem @*/
00447         /*@modifies *pglob, errno, fileSystem @*/;
00448         /* XXX only annotation is a white lie */
00449 extern void globfree (/*@only@*/ glob_t *pglob)
00450         /*@modifies *pglob @*/;
00451 #ifdef _GNU_SOURCE
00452 extern int glob_pattern_p (const char *pattern, int quote)
00453         /*@*/;
00454 #endif
00455 
00456 #if 0
00457 /*@-constuse@*/
00458 /*@constant int FNM_PATHNAME@*/
00459 /*@constant int FNM_NOESCAPE@*/
00460 /*@constant int FNM_PERIOD@*/
00461 
00462 #ifdef _GNU_SOURCE
00463 /*@constant int FNM_FILE_NAME@*/        /* GNU extension */
00464 /*@constant int FNM_LEADING_DIR@*/      /* GNU extension */
00465 /*@constant int FNM_CASEFOLD@*/         /* GNU extension */
00466 /*@constant int FNM_EXTMATCH@*/         /* GNU extension */
00467 #endif
00468 
00469 /*@constant int FNM_NOMATCH@*/
00470 
00471 #ifdef _XOPEN_SOURCE
00472 /*@constant int FNM_NOSYS@*/            /* X/Open */
00473 #endif
00474 /*@=constuse@*/
00475 #endif
00476 
00477 extern int fnmatch (const char *pattern, const char *string, int flags)
00478         /*@*/;
00479 /*@=declundef =incondefs @*/
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 /* Solaris <= 2.6 limits getpass return to only 8 chars */
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 /* if !HAVE_MNTCTL */
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  /* H_SYSTEM */

Generated on Sun Feb 2 23:32:06 2003 for rpm by doxygen1.2.18