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. */
25 #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
92 #if !defined(HAVE_STPCPY) || defined(__LCLINT__)
93 char * stpcpy(char * dest, const char * src);
102 #define getopt system_getopt
103 /*@-skipansiheaders@*/
105 /*@=skipansiheaders@*/
107 #else /* not STDC_HEADERS */
108 char *getenv (const char *name);
109 #endif /* STDC_HEADERS */
114 #include <sys/file.h>
131 # define NLENGTH(direct) (strlen((direct)->d_name))
132 #else /* not HAVE_DIRENT_H */
133 # define dirent direct
134 # define NLENGTH(direct) ((direct)->d_namlen)
135 # ifdef HAVE_SYS_NDIR_H
136 # include <sys/ndir.h>
137 # endif /* HAVE_SYS_NDIR_H */
138 # ifdef HAVE_SYS_DIR_H
139 # include <sys/dir.h>
140 # endif /* HAVE_SYS_DIR_H */
143 # endif /* HAVE_NDIR_H */
144 #endif /* HAVE_DIRENT_H */
148 # define alloca __builtin_alloca
150 # ifdef HAVE_ALLOCA_H
154 /* AIX alloca decl has to be the first thing in the file, bletch! */
163 #include <sys/mman.h>
166 /* XXX FIXME: popt on sunos4.1.3: <sys/resource.h> requires <sys/time.h> */
167 #if HAVE_SYS_RESOURCE_H && HAVE_SYS_TIME_H
168 #include <sys/resource.h>
171 #if HAVE_SYS_UTSNAME_H
172 #include <sys/utsname.h>
176 #include <sys/wait.h>
199 /*@only@*/ void * xmalloc (size_t size);
200 /*@only@*/ void * xcalloc (size_t nmemb, size_t size);
201 /*@only@*/ void * xrealloc (void *ptr, size_t size);
202 /*@only@*/ char * xstrdup (const char *str);
210 /* Memory allocation via macro defs to get meaningful locations from mtrace() */
211 #if HAVE_MCHECK_H && defined(__GNUC__)
212 #define xmalloc(_size) (malloc(_size) ? : vmefail())
213 #define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail())
214 #define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail())
215 #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str)))
216 #endif /* HAVE_MCHECK_H && defined(__GNUC__) */
218 /* Retrofit glibc __progname */
219 #if defined __GLIBC__ && __GLIBC__ >= 2
220 #define setprogname(pn)
222 #define __progname program_name
223 #define setprogname(pn) \
224 { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
225 else __progname = pn; \
233 #endif /* __LCLINT__ */
240 /* Take care of NLS matters. */
246 # define setlocale(Category, Locale) /* empty */
249 #if ENABLE_NLS && !defined(__LCLINT__)
250 # include <libintl.h>
251 # define _(Text) gettext (Text)
253 # undef bindtextdomain
254 # define bindtextdomain(Domain, Directory) /* empty */
256 # define textdomain(Domain) /* empty */
257 # define _(Text) Text
259 # define dgettext(DomainName, Text) Text
262 #define N_(Text) Text
264 /* ============== from misc/miscfn.h */
269 #include "misc/fnmatch.h"
275 #include "misc/glob.h"
279 #define S_IFSOCK (0xC000)
283 #define S_ISLNK(mode) ((mode & 0xF000) == S_IFLNK)
287 #define S_ISSOCK(mode) ((mode & 0xF000) == S_IFSOCK)
295 char *realpath(const char *path, char resolved_path []);
299 #define realloc(ptr,size) myrealloc(ptr,size)
300 extern void *myrealloc(void *, size_t);
303 #if HAVE_SYS_SOCKET_H
304 #include <sys/types.h>
306 #include <sys/socket.h>
307 #endif /* __LCLINT__ */
310 #if HAVE_SYS_SELECT_H
311 #include <sys/select.h>
314 /* Solaris <= 2.6 limits getpass return to only 8 chars */
315 #if HAVE_GETPASSPHRASE
316 #define getpass getpassphrase
323 #if HAVE_GETMNTINFO_R || HAVE_MNTCTL
324 # define GETMNTENT_ONE 0
325 # define GETMNTENT_TWO 0
326 # if HAVE_SYS_MNTCTL_H
327 # include <sys/mntctl.h>
329 # if HAVE_SYS_VMOUNT_H
330 # include <sys/vmount.h>
332 # if HAVE_SYS_MOUNT_H
333 # include <sys/mount.h>
335 #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
339 # define our_mntent struct mntent
340 # define our_mntdir mnt_dir
341 # elif HAVE_STRUCT_MNTTAB
347 struct our_mntent *getmntent(FILE *filep);
348 # define our_mntent struct our_mntent
354 struct our_mntent *getmntent(FILE *filep);
355 # define our_mntent struct our_mntent
357 # define GETMNTENT_ONE 1
358 # define GETMNTENT_TWO 0
359 #elif HAVE_SYS_MNTTAB_H
361 # include <sys/mnttab.h>
362 # define GETMNTENT_ONE 0
363 # define GETMNTENT_TWO 1
364 # define our_mntent struct mnttab
365 # define our_mntdir mnt_mountp
366 #else /* if !HAVE_MNTCTL */
367 # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system.
371 #define MOUNTED "/etc/mnttab"
373 #endif /* H_SYSTEM */