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