1 /* system-dependent definitions for fileutils programs.
2 Copyright (C) 89, 91, 92, 93, 94, 1996 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26 #include <sys/types.h>
29 #ifdef HAVE_SYS_PARAM_H
30 #include <sys/param.h>
33 /* <unistd.h> should be included before any preprocessor test
39 #if TIME_WITH_SYS_TIME
40 # include <sys/time.h>
44 # include <sys/time.h>
51 extern time_t timezone;
55 /* Since major is a function on SVR4, we can't use `ifndef major'. */
57 #include <sys/mkdev.h>
60 #if MAJOR_IN_SYSMACROS
61 #include <sys/sysmacros.h>
64 #ifdef major /* Might be defined in sys/types.h. */
69 #define major(dev) (((dev) >> 8) & 0xff)
70 #define minor(dev) ((dev) & 0xff)
71 #define makedev(maj, min) (((maj) << 8) | (min))
79 /* Don't use bcopy! Use memmove if source and destination may overlap,
83 # if !STDC_HEADERS && HAVE_MEMORY_H
98 #define getopt system_getopt
99 /*@-skipansiheaders@*/
101 /*@=skipansiheaders@*/
103 #else /* not STDC_HEADERS */
104 char *getenv (const char *name);
105 #endif /* STDC_HEADERS */
110 #include <sys/file.h>
127 # define NLENGTH(direct) (strlen((direct)->d_name))
128 #else /* not HAVE_DIRENT_H */
129 # define dirent direct
130 # define NLENGTH(direct) ((direct)->d_namlen)
131 # ifdef HAVE_SYS_NDIR_H
132 # include <sys/ndir.h>
133 # endif /* HAVE_SYS_NDIR_H */
134 # ifdef HAVE_SYS_DIR_H
135 # include <sys/dir.h>
136 # endif /* HAVE_SYS_DIR_H */
139 # endif /* HAVE_NDIR_H */
140 #endif /* HAVE_DIRENT_H */
144 # define alloca __builtin_alloca
146 # ifdef HAVE_ALLOCA_H
150 /* AIX alloca decl has to be the first thing in the file, bletch! */
159 #include <sys/mman.h>
162 /* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
163 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
164 #include <sys/resource.h>
167 #if HAVE_SYS_UTSNAME_H
168 #include <sys/utsname.h>
172 #include <sys/wait.h>
195 /*@only@*/ void * xmalloc (size_t size);
196 /*@only@*/ void * xcalloc (size_t nmemb, size_t size);
197 /*@only@*/ void * xrealloc (void *ptr, size_t size);
198 /*@only@*/ char * xstrdup (const char *str);
206 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
207 #if HAVE_MCHECK_H && defined(__GNUC__)
208 #define xmalloc(_size) (malloc(_size) ? : vmefail())
209 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail())
210 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail())
211 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str)))
212 #endif /* HAVE_MCHECK_H && defined(__GNUC__) */
214 /* Retrofit glibc __progname */
216 #if defined __GLIBC__ && __GLIBC__ >= 2
217 #define setprogname(pn)
219 #define setprogname(pn) \
220 { if ((__progname = strrchr(pn, '/')) __progname++; \
221 else __progname = pn; \
228 #endif /* __LCLINT__ */
235 /* Take care of NLS matters. */
241 # define setlocale(Category, Locale) /* empty */
244 #if ENABLE_NLS && !defined(__LCLINT__)
245 # include <libintl.h>
246 # define _(Text) gettext (Text)
248 # undef bindtextdomain
249 # define bindtextdomain(Domain, Directory) /* empty */
251 # define textdomain(Domain) /* empty */
252 # define _(Text) Text
255 #define N_(Text) Text
257 /* ============== from misc/miscfn.h */
262 #include "misc/fnmatch.h"
268 #include "misc/glob.h"
272 #define S_IFSOCK (0xC000)
276 #define S_ISLNK(mode) ((mode & 0xF000) == S_IFLNK)
280 #define S_ISSOCK(mode) ((mode & 0xF000) == S_IFSOCK)
288 char *realpath(const char *path, char resolved_path []);
292 #define realloc(ptr,size) myrealloc(ptr,size)
293 extern void *myrealloc(void *, size_t);
296 #if HAVE_SYS_SOCKET_H
297 #include <sys/types.h>
299 #include <sys/socket.h>
300 #endif /* __LCLINT__ */
303 #if HAVE_SYS_SELECT_H
304 #include <sys/select.h>
307 /* Solaris <= 2.6 limits getpass return to only 8 chars */
308 #if HAVE_GETPASSPHRASE
309 #define getpass getpassphrase
316 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
317 # define GETMNTENT_ONE 0
318 # define GETMNTENT_TWO 0
319 # if HAVE_SYS_MNTCTL_H
320 # include <sys/mntctl.h>
322 # if HAVE_SYS_VMOUNT_H
323 # include <sys/vmount.h>
325 # if HAVE_SYS_MOUNT_H
326 # include <sys/mount.h>
328 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
332 # define our_mntent struct mntent
333 # define our_mntdir mnt_dir
334 # elif HAVE_STRUCT_MNTTAB
340 struct our_mntent *getmntent(FILE *filep);
341 # define our_mntent struct our_mntent
347 struct our_mntent *getmntent(FILE *filep);
348 # define our_mntent struct our_mntent
350 # define GETMNTENT_ONE 1
351 # define GETMNTENT_TWO 0
352 #elif HAVE_SYS_MNTTAB_H
354 # include <sys/mnttab.h>
355 # define GETMNTENT_ONE 0
356 # define GETMNTENT_TWO 1
357 # define our_mntent struct mnttab
358 # define our_mntdir mnt_mountp
359 #else /* if !HAVE_MNTCTL */
360 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
364 #define MOUNTED "/etc/mnttab"
366 #endif /* H_SYSTEM */