]> Dogcows Code - chaz/tar/blob - src/rmt.h
6260c0855ecf1bf904f3369e58904b25360fcda8
[chaz/tar] / src / rmt.h
1 /* Definitions for communicating with a remote tape drive.
2 Copyright (C) 1988, 1992 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 #ifdef HAVE_UNISTD_H
19 #include <unistd.h>
20 #endif
21
22 #if !defined(_POSIX_VERSION)
23 #ifdef __MSDOS__
24 #include <io.h>
25 #else /* !__MSDOS__ */
26 extern off_t lseek();
27 #endif /* __MSDOS__ */
28 #endif /* _POSIX_VERSION */
29
30 #ifdef NO_REMOTE
31 #define _isrmt(f) 0
32 #define rmtopen open
33 #define rmtaccess access
34 #define rmtstat stat
35 #define rmtcreat creat
36 #define rmtlstat lstat
37 #define rmtread read
38 #define rmtwrite write
39 #define rmtlseek lseek
40 #define rmtclose close
41 #define rmtioctl ioctl
42 #define rmtdup dup
43 #define rmtfstat fstat
44 #define rmtfcntl fcntl
45 #define rmtisatty isatty
46
47 #else /* !NO_REMOTE */
48
49 #define __REM_BIAS 128
50 #define RMTIOCTL
51
52 #ifndef O_CREAT
53 #define O_CREAT 01000
54 #endif
55
56 extern char *__rmt_path;
57
58 #if defined(USG) || defined(STDC_HEADERS)
59 #include <string.h>
60 #define index strchr
61 #else
62 extern char *index();
63 #endif
64
65 #define _remdev(path) (!f_force_local && (__rmt_path=index(path, ':')))
66 #define _isrmt(fd) ((fd) >= __REM_BIAS)
67
68 #define rmtopen(path,oflag,mode) (_remdev(path) ? __rmt_open(path, oflag, mode, __REM_BIAS) : open(path, oflag, mode))
69 #define rmtaccess(path, amode) (_remdev(path) ? 0 : access(path, amode))
70 #define rmtstat(path, buf) (_remdev(path) ? (errno = EOPNOTSUPP), -1 : stat(path, buf))
71 #define rmtcreat(path, mode) (_remdev(path) ? __rmt_open (path, 1 | O_CREAT, mode, __REM_BIAS) : creat(path, mode))
72 #define rmtlstat(path,buf) (_remdev(path) ? (errno = EOPNOTSUPP), -1 : lstat(path,buf))
73
74 #define rmtread(fd, buf, n) (_isrmt(fd) ? __rmt_read(fd - __REM_BIAS, buf, n) : read(fd, buf, n))
75 #define rmtwrite(fd, buf, n) (_isrmt(fd) ? __rmt_write(fd - __REM_BIAS, buf, n) : write(fd, buf, n))
76 #define rmtlseek(fd, off, wh) (_isrmt(fd) ? __rmt_lseek(fd - __REM_BIAS, off, wh) : lseek(fd, off, wh))
77 #define rmtclose(fd) (_isrmt(fd) ? __rmt_close(fd - __REM_BIAS) : close(fd))
78 #ifdef RMTIOCTL
79 #define rmtioctl(fd,req,arg) (_isrmt(fd) ? __rmt_ioctl(fd - __REM_BIAS, req, arg) : ioctl(fd, req, arg))
80 #else
81 #define rmtioctl(fd,req,arg) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : ioctl(fd, req, arg))
82 #endif
83 #define rmtdup(fd) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : dup(fd))
84 #define rmtfstat(fd, buf) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : fstat(fd, buf))
85 #define rmtfcntl(fd,cmd,arg) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : fcntl (fd, cmd, arg))
86 #define rmtisatty(fd) (_isrmt(fd) ? 0 : isatty(fd))
87
88 #undef RMTIOCTL
89
90 int __rmt_open ();
91 int __rmt_close ();
92 int __rmt_read ();
93 int __rmt_write ();
94 long __rmt_lseek();
95 int __rmt_ioctl ();
96 #endif /* !NO_REMOTE */
This page took 0.036171 seconds and 3 git commands to generate.