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 #endif
00025
00026 #if TIME_WITH_SYS_TIME
00027 # include <sys/time.h>
00028 # include <time.h>
00029 #else
00030 # if HAVE_SYS_TIME_H
00031 # include <sys/time.h>
00032 # else
00033 # include <time.h>
00034 # endif
00035 #endif
00036
00037 #if NEED_TIMEZONE
00038 extern time_t timezone;
00039 #endif
00040
00041 #ifdef __LCLINT__
00042 typedef unsigned int u_int32_t;
00043 typedef unsigned short u_int16_t;
00044 typedef unsigned char u_int8_t;
00045 typedef int int32_t;
00046
00047 void * alloca (size_t size) ;
00048
00049 #endif
00050
00051
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
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
00076
00077
00078 #ifdef HAVE_STRING_H
00079 # if !STDC_HEADERS && HAVE_MEMORY_H
00080 # include <memory.h>
00081 # endif
00082 # include <string.h>
00083 #else
00084 # include <strings.h>
00085 char *memchr ();
00086 #endif
00087
00088 #if !defined(HAVE_STPCPY) || defined(__LCLINT__)
00089
00090 char * stpcpy(char * dest, const char * src) ;
00091
00092 #endif
00093
00094 #if !defined(HAVE_STPNCPY) || defined(__LCLINT__)
00095
00096 char * stpncpy(char * dest, const char * src, size_t n) ;
00097
00098 #endif
00099
00100 #include <errno.h>
00101 #ifndef errno
00102
00103 extern int errno;
00104
00105 #endif
00106
00107 #ifdef STDC_HEADERS
00108
00109 #define getopt system_getopt
00110
00111
00112 #include <stdlib.h>
00113
00114 #undef getopt
00115 #else
00116 char *getenv (const char *name);
00117 #endif
00118
00119
00120 #if !defined(EXIT_FAILURE)
00121 #define EXIT_FAILURE 1
00122 #endif
00123
00124 #ifdef HAVE_FCNTL_H
00125 #include <fcntl.h>
00126 #else
00127 #include <sys/file.h>
00128 #endif
00129
00130 #if !defined(SEEK_SET) && !defined(__LCLINT__)
00131 #define SEEK_SET 0
00132 #define SEEK_CUR 1
00133 #define SEEK_END 2
00134 #endif
00135 #if !defined(F_OK) && !defined(__LCLINT__)
00136 #define F_OK 0
00137 #define X_OK 1
00138 #define W_OK 2
00139 #define R_OK 4
00140 #endif
00141
00142 #ifdef HAVE_DIRENT_H
00143 # include <dirent.h>
00144 # define NLENGTH(direct) (strlen((direct)->d_name))
00145 #else
00146 # define dirent direct
00147 # define NLENGTH(direct) ((direct)->d_namlen)
00148 # ifdef HAVE_SYS_NDIR_H
00149 # include <sys/ndir.h>
00150 # endif
00151 # ifdef HAVE_SYS_DIR_H
00152 # include <sys/dir.h>
00153 # endif
00154 # ifdef HAVE_NDIR_H
00155 # include <ndir.h>
00156 # endif
00157 #endif
00158
00159 #ifdef __GNUC__
00160 # undef alloca
00161 # define alloca __builtin_alloca
00162 #else
00163 # ifdef HAVE_ALLOCA_H
00164 # include <alloca.h>
00165 # else
00166 # ifndef _AIX
00167
00168 char *alloca ();
00169 # endif
00170 # endif
00171 #endif
00172
00173 #include <ctype.h>
00174
00175 #if HAVE_SYS_MMAN_H
00176 #include <sys/mman.h>
00177 #endif
00178
00179
00180 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
00181 #include <sys/resource.h>
00182 #endif
00183
00184 #if HAVE_SYS_UTSNAME_H
00185 #include <sys/utsname.h>
00186 #endif
00187
00188 #if HAVE_SYS_WAIT_H
00189 #include <sys/wait.h>
00190 #endif
00191
00192 #if HAVE_GETOPT_H
00193 #include <getopt.h>
00194 #endif
00195
00196 #if HAVE_GRP_H
00197 #include <grp.h>
00198 #endif
00199
00200 #if HAVE_LIMITS_H
00201 #include <limits.h>
00202 #endif
00203
00204 #if HAVE_ERR_H
00205 #include <err.h>
00206 #endif
00207
00208 #if HAVE_MALLOC_H
00209 #include <malloc.h>
00210 #endif
00211
00212
00213 void * xmalloc (size_t size) ;
00214 void * xcalloc (size_t nmemb, size_t size) ;
00215 void * xrealloc ( void * ptr,
00216 size_t size) ;
00217 char * xstrdup (const char *str) ;
00218
00219 void * vmefail(size_t size);
00220
00221 #if HAVE_MCHECK_H
00222 #include <mcheck.h>
00223 #endif
00224
00225
00226
00227 #if HAVE_MCHECK_H && defined(__GNUC__)
00228 #define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
00229 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
00230 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
00231 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
00232 #endif
00233
00234
00235 #if defined __GLIBC__ && __GLIBC__ >= 2
00236 #if __GLIBC_MINOR__ >= 1
00237 #define __progname __assert_program_name
00238 #endif
00239 #define setprogname(pn)
00240 #else
00241 #define __progname program_name
00242 #define setprogname(pn) \
00243 { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
00244 else __progname = pn; \
00245 }
00246 #endif
00247 const char *__progname;
00248
00249 #if HAVE_NETDB_H
00250 #ifndef __LCLINT__
00251 #include <netdb.h>
00252 #endif
00253 #endif
00254
00255 #if HAVE_PWD_H
00256 #include <pwd.h>
00257 #endif
00258
00259
00260
00261 #if HAVE_LOCALE_H
00262 # include <locale.h>
00263 #endif
00264 #if !HAVE_SETLOCALE
00265 # define setlocale(Category, Locale)
00266 #endif
00267
00268 #if ENABLE_NLS && !defined(__LCLINT__)
00269 # include <libintl.h>
00270 # define _(Text) gettext (Text)
00271 #else
00272 # undef bindtextdomain
00273 # define bindtextdomain(Domain, Directory)
00274 # undef textdomain
00275 # define textdomain(Domain)
00276 # define _(Text) Text
00277 # undef dgettext
00278 # define dgettext(DomainName, Text) Text
00279 #endif
00280
00281 #define N_(Text) Text
00282
00283
00284
00285 #if !defined(USE_GNU_GLOB)
00286 #if HAVE_FNMATCH_H
00287 #include <fnmatch.h>
00288 #endif
00289
00290 #if HAVE_GLOB_H
00291 #include <glob.h>
00292 #endif
00293 #else
00294 #include "misc/glob.h"
00295 #include "misc/fnmatch.h"
00296 #endif
00297
00298 #if ! HAVE_S_IFSOCK
00299 #define S_IFSOCK (0xC000)
00300 #endif
00301
00302 #if ! HAVE_S_ISLNK
00303 #define S_ISLNK(mode) ((mode & 0xF000) == S_IFLNK)
00304 #endif
00305
00306 #if ! HAVE_S_ISSOCK
00307 #define S_ISSOCK(mode) ((mode & 0xF000) == S_IFSOCK)
00308 #endif
00309
00310 #if NEED_STRINGS_H
00311 #include <strings.h>
00312 #endif
00313
00314 #if ! HAVE_REALPATH
00315 char *realpath(const char *path, char resolved_path []);
00316 #endif
00317
00318 #if NEED_MYREALLOC
00319 #define realloc(ptr,size) myrealloc(ptr,size)
00320 extern void *myrealloc(void *, size_t);
00321 #endif
00322
00323 #if ! HAVE_SETENV
00324 extern int setenv(const char *name, const char *value, int replace);
00325 extern void unsetenv(const char *name);
00326 #endif
00327
00328 #if HAVE_SYS_SOCKET_H
00329 #include <sys/types.h>
00330 #ifndef __LCLINT__
00331 #include <sys/socket.h>
00332 #endif
00333 #endif
00334
00335 #if HAVE_SYS_SELECT_H
00336 #include <sys/select.h>
00337 #endif
00338
00339
00340 #if HAVE_GETPASSPHRASE
00341 #define getpass getpassphrase
00342 #endif
00343
00344 #if ! HAVE_LCHOWN
00345 #define lchown chown
00346 #endif
00347
00348 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
00349 # define GETMNTENT_ONE 0
00350 # define GETMNTENT_TWO 0
00351 # if HAVE_SYS_MNTCTL_H
00352 # include <sys/mntctl.h>
00353 # endif
00354 # if HAVE_SYS_VMOUNT_H
00355 # include <sys/vmount.h>
00356 # endif
00357 # if HAVE_SYS_MOUNT_H
00358 # include <sys/mount.h>
00359 # endif
00360 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
00361 # if HAVE_MNTENT_H
00362 # include <stdio.h>
00363 # include <mntent.h>
00364 # define our_mntent struct mntent
00365 # define our_mntdir mnt_dir
00366 # elif HAVE_STRUCT_MNTTAB
00367 # include <stdio.h>
00368 # include <mnttab.h>
00369 struct our_mntent {
00370 char * our_mntdir;
00371 };
00372 struct our_mntent *getmntent(FILE *filep);
00373 # define our_mntent struct our_mntent
00374 # else
00375 # include <stdio.h>
00376 struct our_mntent {
00377 char * our_mntdir;
00378 };
00379 struct our_mntent *getmntent(FILE *filep);
00380 # define our_mntent struct our_mntent
00381 # endif
00382 # define GETMNTENT_ONE 1
00383 # define GETMNTENT_TWO 0
00384 #elif HAVE_SYS_MNTTAB_H
00385 # include <stdio.h>
00386 # include <sys/mnttab.h>
00387 # define GETMNTENT_ONE 0
00388 # define GETMNTENT_TWO 1
00389 # define our_mntent struct mnttab
00390 # define our_mntdir mnt_mountp
00391 #else
00392 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
00393 #endif
00394
00395 #ifndef MOUNTED
00396 #define MOUNTED "/etc/mnttab"
00397 #endif
00398 #endif