3 /* Portability cruft. Include after config.h and sys/types.h.
4 Copyright 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 #if defined (__STDC__) && __STDC__
43 int open(), read(), close();
53 extern char *sys_errlist
[];
54 # define strerror(E) (0 <= (E) && (E) < sys_nerr ? _(sys_errlist[E]) : _("Unknown system error"))
57 /* Some operating systems treat text and binary files differently. */
59 # undef O_BINARY /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */
61 #ifdef HAVE_DOS_FILE_CONTENTS
64 # define SET_BINARY(fd) setmode (fd, O_BINARY)
66 # define SET_BINARY(fd) _setmode (fd, O_BINARY)
70 #ifdef HAVE_DOS_FILE_NAMES
71 # define IS_SLASH(c) ((c) == '/' || (c) == '\\')
72 # define FILESYSTEM_PREFIX_LEN(f) ((f)[0] && (f)[1] == ':' ? 2 : 0)
76 # define IS_SLASH(c) ((c) == '/')
79 #ifndef FILESYSTEM_PREFIX_LEN
80 # define FILESYSTEM_PREFIX_LEN(f) 0
83 int isdir
PARAMS ((char const *));
85 #ifdef HAVE_DIR_EACCES_BUG
87 # define is_EISDIR(e, f) \
89 || ((e) == EACCES && isdir (f) && ((e) = EISDIR, 1)))
91 # define is_EISDIR(e, f) ((e) == EACCES && isdir (f))
97 # define is_EISDIR(e, f) ((e) == EISDIR)
99 # define is_EISDIR(e, f) 0
103 #if STAT_MACROS_BROKEN
107 #if !defined(S_ISDIR) && defined(S_IFDIR)
108 # define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR)
110 #if !defined(S_ISREG) && defined(S_IFREG)
111 # define S_ISREG(Mode) (((Mode) & S_IFMT) == S_IFREG)
118 ptr_t
malloc(), realloc(), calloc();
131 /* The extra casts work around common compiler bugs. */
132 #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
133 #define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
134 ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
136 #define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
138 # define CHAR_MAX TYPE_MAXIMUM (char)
141 # define INT_MAX TYPE_MAXIMUM (int)
144 # define UCHAR_MAX TYPE_MAXIMUM (unsigned char)
147 #if !defined(STDC_HEADERS) && defined(HAVE_STRING_H) && defined(HAVE_MEMORY_H)
150 #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
153 # include <strings.h>
155 # define strchr index
157 # define strrchr rindex
159 # define memcpy(d, s, n) bcopy (s, d, n)
164 #if ! defined HAVE_MEMMOVE && ! defined memmove
165 # define memmove(d, s, n) bcopy (s, d, n)
171 # define isgraph(C) (isprint(C) && !isspace(C))
174 #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
175 # define IN_CTYPE_DOMAIN(c) 1
177 # define IN_CTYPE_DOMAIN(c) isascii(c)
180 #define ISALPHA(C) (IN_CTYPE_DOMAIN (C) && isalpha (C))
181 #define ISUPPER(C) (IN_CTYPE_DOMAIN (C) && isupper (C))
182 #define ISLOWER(C) (IN_CTYPE_DOMAIN (C) && islower (C))
183 #define ISDIGIT(C) (IN_CTYPE_DOMAIN (C) && isdigit (C))
184 #define ISXDIGIT(C) (IN_CTYPE_DOMAIN (C) && isxdigit (C))
185 #define ISSPACE(C) (IN_CTYPE_DOMAIN (C) && isspace (C))
186 #define ISPUNCT(C) (IN_CTYPE_DOMAIN (C) && ispunct (C))
187 #define ISALNUM(C) (IN_CTYPE_DOMAIN (C) && isalnum (C))
188 #define ISPRINT(C) (IN_CTYPE_DOMAIN (C) && isprint (C))
189 #define ISGRAPH(C) (IN_CTYPE_DOMAIN (C) && isgraph (C))
190 #define ISCNTRL(C) (IN_CTYPE_DOMAIN (C) && iscntrl (C))
192 #define TOLOWER(C) (ISUPPER(C) ? tolower(C) : (C))
195 # include <libintl.h>
196 # define _(String) gettext (String)
198 # define _(String) String
200 #define N_(String) String
206 #ifndef initialize_main
207 #define initialize_main(argcp, argvp)