[439] | 1 | /* System dependent definitions for GNU tar.
|
---|
| 2 | Copyright (C) 1994 Free Software Foundation, Inc.
|
---|
| 3 |
|
---|
| 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)
|
---|
| 7 | any later version.
|
---|
| 8 |
|
---|
| 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.
|
---|
| 13 |
|
---|
| 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 17 | */
|
---|
| 18 |
|
---|
| 19 | /*
|
---|
| 20 | * [TS:Aug/95]
|
---|
| 21 | * Based on code from system.h file in GNU's tar package
|
---|
| 22 | *
|
---|
| 23 | */
|
---|
| 24 |
|
---|
| 25 | #ifndef SYSFUNCS_H
|
---|
| 26 | #define SYSFUNCS_H
|
---|
| 27 |
|
---|
| 28 | /* [RPAP - Feb 97: WIN32 Port] */
|
---|
| 29 | #ifdef HAVE_CONFIG_H
|
---|
| 30 | # ifdef __WIN32__
|
---|
| 31 | # include <WIN32cfg.h>
|
---|
| 32 | # else
|
---|
| 33 | # include <config.h>
|
---|
| 34 | # endif
|
---|
| 35 | #endif
|
---|
| 36 |
|
---|
| 37 | /* Declare alloca. AIX requires this to be the first thing in the file. */
|
---|
| 38 |
|
---|
| 39 | #ifdef __GNUC__
|
---|
| 40 | #define alloca __builtin_alloca
|
---|
| 41 | #else
|
---|
| 42 | #if HAVE_ALLOCA_H
|
---|
| 43 | #include <alloca.h>
|
---|
| 44 | #else
|
---|
| 45 | #ifdef _AIX
|
---|
| 46 | #pragma alloca
|
---|
| 47 | #else
|
---|
| 48 | #ifndef alloca
|
---|
| 49 | char *alloca ();
|
---|
| 50 | #endif
|
---|
| 51 | #endif
|
---|
| 52 | #endif
|
---|
| 53 | #endif
|
---|
| 54 |
|
---|
| 55 | #include <sys/types.h>
|
---|
| 56 |
|
---|
| 57 | /* ------------------------------------------------- */
|
---|
| 58 | /* [TS:Aug/95]
|
---|
| 59 | * Some extra include files that mg needs
|
---|
| 60 | */
|
---|
| 61 | #include <stdlib.h>
|
---|
| 62 | #include <math.h>
|
---|
| 63 |
|
---|
| 64 | #ifndef log2
|
---|
| 65 | # ifndef M_LN2
|
---|
| 66 | # define M_LN2 0.69314718055994530942
|
---|
| 67 | # endif
|
---|
| 68 | # define log2(x) (log(x)/M_LN2)
|
---|
| 69 | #endif
|
---|
| 70 |
|
---|
| 71 |
|
---|
| 72 | #ifndef HAVE_SETBUFFER
|
---|
| 73 | # define setbuffer(f, b, s) setvbuf(f, b, _IOFBF, s)
|
---|
| 74 | #endif
|
---|
| 75 |
|
---|
| 76 | /* [RPAP - Feb 97: WIN32 Port] */
|
---|
| 77 | #if defined(__MSDOS__) && !defined(__WIN32__)
|
---|
| 78 | # define SHORT_SUFFIX 1
|
---|
| 79 | #endif
|
---|
| 80 |
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | #include <assert.h>
|
---|
| 84 |
|
---|
| 85 | /* ------------------------------------------------- */
|
---|
| 86 |
|
---|
| 87 | /* Declare a generic pointer type. */
|
---|
| 88 | #if __STDC__ || defined(__TURBOC__)
|
---|
| 89 | #define voidstar void *
|
---|
| 90 | #else
|
---|
| 91 | #define voidstar char *
|
---|
| 92 | #endif
|
---|
| 93 |
|
---|
| 94 | /* Declare ISASCII. */
|
---|
| 95 |
|
---|
| 96 | #include <ctype.h>
|
---|
| 97 |
|
---|
| 98 | #if STDC_HEADERS
|
---|
| 99 | #define ISASCII(Char) 1
|
---|
| 100 | #else
|
---|
| 101 | #ifdef isascii
|
---|
| 102 | #define ISASCII(Char) isascii (Char)
|
---|
| 103 | #else
|
---|
| 104 | #if HAVE_ISASCII
|
---|
| 105 | #define ISASCII(Char) isascii (Char)
|
---|
| 106 | #else
|
---|
| 107 | #define ISASCII(Char) 1
|
---|
| 108 | #endif
|
---|
| 109 | #endif
|
---|
| 110 | #endif
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 | /* ------------------------------------------------- */
|
---|
| 114 | /* [TS:Aug/95]
|
---|
| 115 | * The following is copied from GNU Autoconf.Info (1.1)
|
---|
| 116 | * It sets up the approriate string and memory functions.
|
---|
| 117 | */
|
---|
| 118 |
|
---|
| 119 | #if STDC_HEADERS || HAVE_STRING_H
|
---|
| 120 | #include <string.h>
|
---|
| 121 | /* An ANSI string.h and pre-ANSI memory.h might conflict */
|
---|
| 122 | #if !STDC_HEADERS && HAVE_MEMORY_H
|
---|
| 123 | #include <memory.h>
|
---|
| 124 | #endif /* not STDC_HEADERS and HAVE_MEMORY_H */
|
---|
| 125 | #ifndef index
|
---|
| 126 | #define index strchr
|
---|
| 127 | #endif
|
---|
| 128 | #ifndef rindex
|
---|
| 129 | #define rindex strrchr
|
---|
| 130 | #endif
|
---|
| 131 | #ifndef bcopy
|
---|
| 132 | #define bcopy(s, d, n) memcpy((d), (s), (n))
|
---|
| 133 | #endif
|
---|
| 134 | #ifndef bcmp
|
---|
| 135 | #define bcmp(s1, s2, n) memcmp((s1), (s2), (n))
|
---|
| 136 | #endif
|
---|
| 137 | #ifndef bzero
|
---|
| 138 | #define bzero(s, n) memset((s), 0, (n))
|
---|
| 139 | #endif
|
---|
| 140 | #else /* not STDC_HEADERS and not HAVE_STRING_H */
|
---|
| 141 | #include <strings.h>
|
---|
| 142 | /* memory.h and strings.h conflict on some systems */
|
---|
| 143 | #endif
|
---|
| 144 | /* ------------------------------------------------- */
|
---|
| 145 |
|
---|
| 146 |
|
---|
| 147 | /* Declare errno. */
|
---|
| 148 |
|
---|
| 149 | #include <errno.h>
|
---|
| 150 | #ifndef errno
|
---|
| 151 | extern int errno;
|
---|
| 152 | #endif
|
---|
| 153 |
|
---|
| 154 | /* Declare open parameters. */
|
---|
| 155 |
|
---|
| 156 | #ifdef HAVE_FCNTL_H
|
---|
| 157 | #include <fcntl.h>
|
---|
| 158 | #else
|
---|
| 159 | #include <sys/file.h>
|
---|
| 160 | #endif
|
---|
| 161 |
|
---|
| 162 | #ifndef O_BINARY
|
---|
| 163 | #define O_BINARY 0
|
---|
| 164 | #endif
|
---|
| 165 | #ifndef O_CREAT
|
---|
| 166 | #define O_CREAT 0
|
---|
| 167 | #endif
|
---|
| 168 | #ifndef O_NDELAY
|
---|
| 169 | #define O_NDELAY 0
|
---|
| 170 | #endif
|
---|
| 171 | #ifndef O_RDONLY
|
---|
| 172 | #define O_RDONLY 0
|
---|
| 173 | #endif
|
---|
| 174 | #ifndef O_RDWR
|
---|
| 175 | #define O_RDWR 2
|
---|
| 176 | #endif
|
---|
| 177 |
|
---|
| 178 | /* Declare file status routines and bits. */
|
---|
| 179 |
|
---|
| 180 | #include <sys/stat.h>
|
---|
| 181 |
|
---|
| 182 | #ifdef STAT_MACROS_BROKEN
|
---|
| 183 | #undef S_ISBLK
|
---|
| 184 | #undef S_ISCHR
|
---|
| 185 | #undef S_ISDIR
|
---|
| 186 | #undef S_ISFIFO
|
---|
| 187 | #undef S_ISLNK
|
---|
| 188 | #undef S_ISMPB
|
---|
| 189 | #undef S_ISMPC
|
---|
| 190 | #undef S_ISNWK
|
---|
| 191 | #undef S_ISREG
|
---|
| 192 | #undef S_ISSOCK
|
---|
| 193 | #endif
|
---|
| 194 |
|
---|
| 195 | /* On MSDOS, there are missing things from <sys/stat.h>. */
|
---|
[1279] | 196 | #if defined(__MSDOS__)
|
---|
[439] | 197 | #define S_ISUID 0
|
---|
| 198 | #define S_ISGID 0
|
---|
| 199 | #define S_ISVTX 0
|
---|
| 200 | #endif
|
---|
| 201 |
|
---|
[1279] | 202 | #if defined(__GNUC__) && defined(__WIN32__)
|
---|
| 203 | #include <limits.h>
|
---|
| 204 | #endif
|
---|
| 205 |
|
---|
[439] | 206 | #ifndef S_ISREG /* POSIX.1 stat stuff missing */
|
---|
| 207 | #define mode_t unsigned short
|
---|
| 208 | #endif
|
---|
| 209 | #if !defined(S_ISBLK) && defined(S_IFBLK)
|
---|
| 210 | #define S_ISBLK(Mode) (((Mode) & S_IFMT) == S_IFBLK)
|
---|
| 211 | #endif
|
---|
| 212 | #if !defined(S_ISCHR) && defined(S_IFCHR)
|
---|
| 213 | #define S_ISCHR(Mode) (((Mode) & S_IFMT) == S_IFCHR)
|
---|
| 214 | #endif
|
---|
| 215 | #if !defined(S_ISDIR) && defined(S_IFDIR)
|
---|
| 216 | #define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR)
|
---|
| 217 | #endif
|
---|
| 218 | #if !defined(S_ISREG) && defined(S_IFREG)
|
---|
| 219 | #define S_ISREG(Mode) (((Mode) & S_IFMT) == S_IFREG)
|
---|
| 220 | #endif
|
---|
| 221 | #if !defined(S_ISFIFO) && defined(S_IFIFO)
|
---|
| 222 | #define S_ISFIFO(Mode) (((Mode) & S_IFMT) == S_IFIFO)
|
---|
| 223 | #endif
|
---|
| 224 | #if !defined(S_ISLNK) && defined(S_IFLNK)
|
---|
| 225 | #define S_ISLNK(Mode) (((Mode) & S_IFMT) == S_IFLNK)
|
---|
| 226 | #endif
|
---|
| 227 | #if !defined(S_ISSOCK) && defined(S_IFSOCK)
|
---|
| 228 | #define S_ISSOCK(Mode) (((Mode) & S_IFMT) == S_IFSOCK)
|
---|
| 229 | #endif
|
---|
| 230 | #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
|
---|
| 231 | #define S_ISMPB(Mode) (((Mode) & S_IFMT) == S_IFMPB)
|
---|
| 232 | #define S_ISMPC(Mode) (((Mode) & S_IFMT) == S_IFMPC)
|
---|
| 233 | #endif
|
---|
| 234 | #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
|
---|
| 235 | #define S_ISNWK(Mode) (((Mode) & S_IFMT) == S_IFNWK)
|
---|
| 236 | #endif
|
---|
| 237 |
|
---|
| 238 | #if !defined(S_ISCTG) && defined(S_IFCTG) /* contiguous file */
|
---|
| 239 | #define S_ISCTG(Mode) (((Mode) & S_IFMT) == S_IFCTG)
|
---|
| 240 | #endif
|
---|
| 241 | #if !defined(S_ISVTX)
|
---|
| 242 | #define S_ISVTX 0001000
|
---|
| 243 | #endif
|
---|
| 244 |
|
---|
| 245 | /* [RPAP - Feb 97: WIN32 Port] */
|
---|
| 246 | #if !defined(_POSIX_SOURCE) && !defined(__WIN32__)
|
---|
| 247 | #include <sys/param.h>
|
---|
| 248 | #endif
|
---|
| 249 |
|
---|
| 250 | /* Include <unistd.h> before any preprocessor test of _POSIX_VERSION. */
|
---|
| 251 | #ifdef HAVE_UNISTD_H
|
---|
| 252 | #include <unistd.h>
|
---|
| 253 | #endif
|
---|
| 254 |
|
---|
| 255 |
|
---|
| 256 | /* Declare standard functions. */
|
---|
| 257 |
|
---|
| 258 | #ifdef STDC_HEADERS
|
---|
| 259 | #include <stdlib.h>
|
---|
| 260 | #else
|
---|
| 261 | voidstar malloc ();
|
---|
| 262 | voidstar realloc ();
|
---|
| 263 | char *getenv ();
|
---|
| 264 | #endif
|
---|
| 265 |
|
---|
| 266 | #include <stdio.h>
|
---|
| 267 |
|
---|
| 268 | #ifndef _POSIX_VERSION
|
---|
| 269 | #ifdef __MSDOS__
|
---|
| 270 | #include <io.h>
|
---|
| 271 | #else
|
---|
| 272 | off_t lseek ();
|
---|
| 273 | #endif
|
---|
| 274 | #endif
|
---|
| 275 |
|
---|
| 276 | #include <pathmax.h>
|
---|
| 277 |
|
---|
| 278 | /* Until getoptold function is declared in getopt.h, we need this here for
|
---|
| 279 | struct option. */
|
---|
| 280 | #include <getopt.h>
|
---|
| 281 |
|
---|
| 282 | #ifdef WITH_DMALLOC
|
---|
| 283 | #undef HAVE_VALLOC
|
---|
| 284 | #define DMALLOC_FUNC_CHECK
|
---|
| 285 | #include <dmalloc.h>
|
---|
| 286 | #endif
|
---|
| 287 |
|
---|
| 288 | /* Prototypes for external functions. */
|
---|
| 289 |
|
---|
| 290 | #ifndef __P
|
---|
| 291 | #if PROTOTYPES
|
---|
| 292 | #define __P(Args) Args
|
---|
| 293 | #else
|
---|
| 294 | #define __P(Args) ()
|
---|
| 295 | #endif
|
---|
| 296 | #endif
|
---|
| 297 |
|
---|
| 298 | #if HAVE_LOCALE_H
|
---|
| 299 | #include <locale.h>
|
---|
| 300 | #endif
|
---|
| 301 | #if !HAVE_SETLOCALE
|
---|
| 302 | #define setlocale(Category, Locale)
|
---|
| 303 | #endif
|
---|
| 304 |
|
---|
| 305 | #if ENABLE_NLS
|
---|
| 306 | #include <libintl.h>
|
---|
| 307 | #define _(Text) gettext (Text)
|
---|
| 308 | #else
|
---|
| 309 | #define textdomain(Domain)
|
---|
| 310 | #define _(Text) Text
|
---|
| 311 | #endif
|
---|
| 312 |
|
---|
| 313 | /* Library modules. */
|
---|
| 314 |
|
---|
[795] | 315 | #if (HAVE_VPRINTF || HAVE_DOPRNT) && __STDC__
|
---|
[821] | 316 | /*void error __P ((int, int, const char *,...));*/
|
---|
| 317 | void error (int, int, const char *,...);
|
---|
[439] | 318 | #else
|
---|
[795] | 319 | void error (int, int, char *, char *, char *, char *, char *, char *, char *, char *, char *);
|
---|
[439] | 320 | #endif
|
---|
| 321 |
|
---|
| 322 | #ifndef HAVE_STRSTR
|
---|
| 323 | char *strstr __P ((const char *, const char *));
|
---|
| 324 | #endif
|
---|
| 325 |
|
---|
| 326 | /* [RB/TS:Oct/95] commented out. Used by lib/gmalloc.c - but it defines it anyway ???
|
---|
| 327 | *#ifndef HAVE_VALLOC
|
---|
| 328 | *#define valloc(Size) malloc (Size)
|
---|
| 329 | *#endif
|
---|
| 330 | */
|
---|
| 331 |
|
---|
| 332 | voidstar xmalloc __P ((size_t));
|
---|
| 333 | voidstar xrealloc __P ((voidstar, size_t));
|
---|
| 334 | char *xstrdup __P ((const char *));
|
---|
| 335 |
|
---|
| 336 | /* [TS:Aug/95]
|
---|
| 337 | * These were required by files which referred
|
---|
| 338 | * to these as function pointers.
|
---|
| 339 | * e.g. huffman.c - fread, mgfelics.c - fgetc
|
---|
| 340 | */
|
---|
| 341 | #ifndef HAVE_FREAD_DECL
|
---|
| 342 | extern size_t fread __P ((void *, size_t, size_t, FILE *));
|
---|
| 343 | #endif
|
---|
| 344 | #ifndef HAVE_FGETC_DECL
|
---|
| 345 | extern int fgetc __P ((FILE *));
|
---|
| 346 | #endif
|
---|
| 347 |
|
---|
| 348 | /* [RPAP - Feb 97: WIN32 Port] */
|
---|
| 349 | #ifndef u_long
|
---|
| 350 | # define u_long unsigned long
|
---|
| 351 | #endif
|
---|
| 352 | #ifndef u_char
|
---|
| 353 | # define u_char unsigned char
|
---|
| 354 | #endif
|
---|
| 355 |
|
---|
| 356 |
|
---|
| 357 | #endif /* SYSFUNCS_H */
|
---|