1 /* Portability cruft. Include after config.h and sys/types.h.
2 Copyright (C) 1996, 1998, 1999 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
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 #if defined (__STDC__) && __STDC__
41 int open(), read(), close();
51 extern char *sys_errlist
[];
52 # define strerror(E) (0 <= (E) && (E) < sys_nerr ? _(sys_errlist[E]) : _("Unknown system error"))
55 /* Some operating systems treat text and binary files differently. */
59 # define SET_BINARY(fd) setmode (fd, O_BINARY)
61 # define SET_BINARY(fd) _setmode (fd, O_BINARY)
66 # define SET_BINARY(fd) (void)0
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 /* This assumes _WIN32, like DJGPP, has D_OK. Does it? In what header? */
86 # define is_EISDIR(e, f) \
88 || ((e) == EACCES && access (f, D_OK) == 0 && ((e) = EISDIR, 1)))
90 # define is_EISDIR(e, f) ((e) == EACCES && access (f, D_OK) == 0)
96 # define is_EISDIR(e, f) ((e) == EISDIR)
98 # define is_EISDIR(e, f) 0
102 #if STAT_MACROS_BROKEN
106 #if !defined(S_ISDIR) && defined(S_IFDIR)
107 # define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR)
109 #if !defined(S_ISREG) && defined(S_IFREG)
110 # define S_ISREG(Mode) (((Mode) & S_IFMT) == S_IFREG)
117 ptr_t
malloc(), realloc(), calloc();
130 /* The extra casts work around common compiler bugs. */
131 #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
132 #define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
133 ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
135 #define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
137 # define CHAR_MAX TYPE_MAXIMUM (char)
140 # define INT_MAX TYPE_MAXIMUM (int)
143 # define UCHAR_MAX TYPE_MAXIMUM (unsigned char)
146 #if !defined(STDC_HEADERS) && defined(HAVE_STRING_H) && defined(HAVE_MEMORY_H)
149 #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
152 # include <strings.h>
154 # define strchr index
156 # define strrchr rindex
158 # define memcpy(d, s, n) bcopy (s, d, n)
163 #if ! defined HAVE_MEMMOVE && ! defined memmove
164 # define memmove(d, s, n) bcopy (s, d, n)
170 # define isgraph(C) (isprint(C) && !isspace(C))
173 #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
174 # define IN_CTYPE_DOMAIN(c) 1
176 # define IN_CTYPE_DOMAIN(c) isascii(c)
179 #define ISALPHA(C) (IN_CTYPE_DOMAIN (C) && isalpha (C))
180 #define ISUPPER(C) (IN_CTYPE_DOMAIN (C) && isupper (C))
181 #define ISLOWER(C) (IN_CTYPE_DOMAIN (C) && islower (C))
182 #define ISDIGIT(C) (IN_CTYPE_DOMAIN (C) && isdigit (C))
183 #define ISXDIGIT(C) (IN_CTYPE_DOMAIN (C) && isxdigit (C))
184 #define ISSPACE(C) (IN_CTYPE_DOMAIN (C) && isspace (C))
185 #define ISPUNCT(C) (IN_CTYPE_DOMAIN (C) && ispunct (C))
186 #define ISALNUM(C) (IN_CTYPE_DOMAIN (C) && isalnum (C))
187 #define ISPRINT(C) (IN_CTYPE_DOMAIN (C) && isprint (C))
188 #define ISGRAPH(C) (IN_CTYPE_DOMAIN (C) && isgraph (C))
189 #define ISCNTRL(C) (IN_CTYPE_DOMAIN (C) && iscntrl (C))
191 #define TOLOWER(C) (ISUPPER(C) ? tolower(C) : (C))
194 # include <libintl.h>
195 # define _(String) gettext (String)
197 # define _(String) String
199 #define N_(String) String
205 #ifndef initialize_main
206 #define initialize_main(argcp, argvp)