]>
Dogcows Code - chaz/tar/blob - src/system.h
1 /* System dependent definitions for GNU tar.
2 Copyright (C) 1994, 1995, 1996, 1997 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.
23 /* Declare alloca. AIX requires this to be the first thing in the file. */
26 # define alloca __builtin_alloca
41 #include <sys/types.h>
43 /* Declare a generic pointer type. */
44 #if __STDC__ || defined(__TURBOC__)
45 # define voidstar void *
47 # define voidstar char *
50 /* Declare ISASCII. */
55 # define ISASCII(Char) 1
58 # define ISASCII(Char) isascii (Char)
61 # define ISASCII(Char) isascii (Char)
63 # define ISASCII(Char) 1
68 /* Declare string and memory handling routines. Take care that an ANSI
69 string.h and pre-ANSI memory.h might conflict, and that memory.h and
70 strings.h conflict on some systems. */
72 #if STDC_HEADERS || HAVE_STRING_H
74 # if !STDC_HEADERS && HAVE_MEMORY_H
83 # define strrchr rindex
86 # define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
89 # define memcmp(Src1, Src2, Num) bcmp (Src1, Src2, Num)
100 /* Declare open parameters. */
105 # include <sys/file.h>
107 /* Pick only one of the next three: */
109 # define O_RDONLY 0 /* only allow read */
112 # define O_WRONLY 1 /* only allow write */
115 # define O_RDWR 2 /* both are allowed */
117 /* The rest can be OR-ed in to the above: */
119 # define O_NDELAY 4 /* don't block on opening devices */
122 # define O_CREAT 8 /* create file if needed */
125 # define O_EXCL 16 /* file cannot already exist */
128 # define O_TRUNC 32 /* truncate file on open */
131 # define O_APPEND 64 /* always write at end of file */
133 /* MS-DOG forever, with my love! */
137 /* Emulate System V 3-argument open call */
142 /* Declare file status routines and bits. */
144 #include <sys/stat.h>
150 #if STAT_MACROS_BROKEN
163 /* On MSDOS, there are missing things from <sys/stat.h>. */
170 #ifndef S_ISREG /* POSIX.1 stat stuff missing */
171 # define mode_t unsigned short
173 #if !defined(S_ISBLK) && defined(S_IFBLK)
174 # define S_ISBLK(Mode) (((Mode) & S_IFMT) == S_IFBLK)
176 #if !defined(S_ISCHR) && defined(S_IFCHR)
177 # define S_ISCHR(Mode) (((Mode) & S_IFMT) == S_IFCHR)
179 #if !defined(S_ISDIR) && defined(S_IFDIR)
180 # define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR)
182 #if !defined(S_ISREG) && defined(S_IFREG)
183 # define S_ISREG(Mode) (((Mode) & S_IFMT) == S_IFREG)
185 #if !defined(S_ISFIFO) && defined(S_IFIFO)
186 # define S_ISFIFO(Mode) (((Mode) & S_IFMT) == S_IFIFO)
188 #if !defined(S_ISLNK) && defined(S_IFLNK)
189 # define S_ISLNK(Mode) (((Mode) & S_IFMT) == S_IFLNK)
191 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
192 # define S_ISSOCK(Mode) (((Mode) & S_IFMT) == S_IFSOCK)
194 #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
195 # define S_ISMPB(Mode) (((Mode) & S_IFMT) == S_IFMPB)
196 # define S_ISMPC(Mode) (((Mode) & S_IFMT) == S_IFMPC)
198 #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
199 # define S_ISNWK(Mode) (((Mode) & S_IFMT) == S_IFNWK)
203 # define mkfifo(Path, Mode) (mknod (Path, (Mode) | S_IFIFO, 0))
206 #if !defined(S_ISCTG) && defined(S_IFCTG) /* contiguous file */
207 # define S_ISCTG(Mode) (((Mode) & S_IFMT) == S_IFCTG)
209 #if !defined(S_ISVTX)
210 # define S_ISVTX 0001000
213 #ifndef _POSIX_SOURCE
214 # include <sys/param.h>
217 /* Include <unistd.h> before any preprocessor test of _POSIX_VERSION. */
222 /* Declare make device, major and minor. Since major is a function on
223 SVR4, we have to resort to GOT_MAJOR instead of just testing if
224 major is #define'd. */
227 # include <sys/mkdev.h>
231 #if MAJOR_IN_SYSMACROS
232 # include <sys/sysmacros.h>
236 /* Some <sys/types.h> defines the macros. */
243 # define major(Device) (Device)
244 # define minor(Device) (Device)
245 # define makedev(Major, Minor) (((Major) << 8) | (Minor))
250 /* For HP-UX before HP-UX 8, major/minor are not in <sys/sysmacros.h>. */
252 # if defined(hpux) || defined(__hpux__) || defined(__hpux)
253 # include <sys/mknod.h>
259 # define major(Device) (((Device) >> 8) & 0xff)
260 # define minor(Device) ((Device) & 0xff)
261 # define makedev(Major, Minor) (((Major) << 8) | (Minor))
266 /* Declare directory reading routines and structures. */
269 # include "msd_dir.h"
270 # define NAMLEN(dirent) ((dirent)->d_namlen)
274 # define NAMLEN(dirent) (strlen((dirent)->d_name))
276 # define dirent direct
277 # define NAMLEN(dirent) ((dirent)->d_namlen)
279 # include <sys/ndir.h>
282 # include <sys/dir.h>
290 /* Declare wait status. */
293 # include <sys/wait.h>
297 # define WAIT_T union wait
299 # define WTERMSIG(Status) ((Status).w_termsig)
302 # define WCOREDUMP(Status) ((Status).w_coredump)
305 # define WEXITSTATUS(Status) ((Status).w_retcode)
310 # define WTERMSIG(Status) ((Status) & 0x7f)
313 # define WCOREDUMP(Status) ((Status) & 0x80)
316 # define WEXITSTATUS(Status) (((Status) >> 8) & 0xff)
321 # define WIFSTOPPED(Status) (WTERMSIG(Status) == 0x7f)
324 # define WIFSIGNALED(Status) (WTERMSIG(Status) != 0)
327 # define WIFEXITED(Status) (WTERMSIG(Status) == 0)
330 /* FIXME: It is wrong to use BLOCKSIZE for buffers when the logical block
331 size is greater than 512 bytes; so ST_BLKSIZE code below, in preparation
332 for some cleanup in this area, later. */
334 /* Get or fake the disk device blocksize. Usually defined by sys/param.h
337 #if !defined(DEV_BSIZE) && defined(BSIZE)
338 # define DEV_BSIZE BSIZE
340 #if !defined(DEV_BSIZE) && defined(BBSIZE) /* SGI */
341 # define DEV_BSIZE BBSIZE
344 # define DEV_BSIZE 4096
347 /* Extract or fake data from a `struct stat'. ST_BLKSIZE gives the
348 optimal I/O blocksize for the file, in bytes. Some systems, like
349 Sequents, return st_blksize of 0 on pipes. */
352 # define ST_BLKSIZE(Statbuf) DEV_BSIZE
354 # define ST_BLKSIZE(Statbuf) \
355 ((Statbuf).st_blksize > 0 ? (Statbuf).st_blksize : DEV_BSIZE)
358 /* Extract or fake data from a `struct stat'. ST_NBLOCKS gives the
359 number of 512-byte blocks in the file (including indirect blocks).
360 fileblocks.c uses BSIZE. HP-UX counts st_blocks in 1024-byte units,
361 this loses when mixing HP-UX and BSD filesystems with NFS. AIX PS/2
362 counts st_blocks in 4K units. */
365 # if defined(_POSIX_SOURCE) || !defined(BSIZE)
366 # define ST_NBLOCKS(Statbuf) (((Statbuf).st_size + 512 - 1) / 512)
368 # define ST_NBLOCKS(Statbuf) (st_blocks ((Statbuf).st_size))
371 # if defined(hpux) || defined(__hpux__) || defined(__hpux)
372 # define ST_NBLOCKS(Statbuf) ((Statbuf).st_blocks * 2)
374 # if defined(_AIX) && defined(_I386)
375 # define ST_NBLOCKS(Statbuf) ((Statbuf).st_blocks * 8)
377 # define ST_NBLOCKS(Statbuf) ((Statbuf).st_blocks)
382 /* This is a real challenge to properly get MTIO* symbols :-(. ISC uses
383 <sys/gentape.h>. SCO and BSDi uses <sys/tape.h>; BSDi also requires
384 <sys/tprintf.h> and <sys/device.h> for defining tp_dev and tpr_t. It
385 seems that the rest use <sys/mtio.h>, which itself requires other files,
386 depending on systems. Pyramid defines _IOW in <sgtty.h>, for example. */
388 #if HAVE_SYS_GENTAPE_H
389 # include <sys/gentape.h>
392 # if HAVE_SYS_DEVICE_H
393 # include <sys/device.h>
396 # include <sys/buf.h>
398 # if HAVE_SYS_TPRINTF_H
399 # include <sys/tprintf.h>
401 # include <sys/tape.h>
404 # include <sys/ioctl.h>
408 # if HAVE_SYS_IO_TRIOCTL_H
409 # include <sys/io/trioctl.h>
411 # include <sys/mtio.h>
416 /* Declare standard functions. */
431 #ifndef _POSIX_VERSION
443 # define DMALLOC_FUNC_CHECK
444 # include <dmalloc.h>
447 /* Prototypes for external functions. */
451 # define PARAMS(Args) Args
453 # define PARAMS(Args) ()
461 # define setlocale(Category, Locale)
465 # include <libintl.h>
466 # define _(Text) gettext (Text)
468 # define bindtextdomain(Domain, Directory)
469 # define textdomain(Domain)
470 # define _(Text) Text
472 #define N_(Text) Text
474 /* Library modules. */
479 char *strstr
PARAMS ((const char *, const char *));
484 voidstar valloc
PARAMS ((size_t));
487 # define valloc(Size) malloc (Size)
490 voidstar xmalloc
PARAMS ((size_t));
491 voidstar xrealloc
PARAMS ((voidstar
, size_t));
492 char *xstrdup
PARAMS ((const char *));
This page took 0.058963 seconds and 4 git commands to generate.