]> Dogcows Code - chaz/tar/blob - src/rmt.h
7b3c2982b6b8870ae242207cccbd9fcd98a49e78
[chaz/tar] / src / rmt.h
1 /* Definitions for communicating with a remote tape drive.
2 Copyright (C) 1988, 1992, 1996, 1997 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 Foundation,
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17
18 extern char *rmt_path__;
19
20 int rmt_open__ PARAMS ((const char *, int, int, const char *));
21 int rmt_close__ PARAMS ((int));
22 ssize_t rmt_read__ PARAMS ((int, char *, size_t));
23 ssize_t rmt_write__ PARAMS ((int, char *, size_t));
24 off_t rmt_lseek__ PARAMS ((int, off_t, int));
25 int rmt_ioctl__ PARAMS ((int, int, char *));
26
27 /* A filename is remote if it contains a colon not preceeded by a slash,
28 to take care of `/:/' which is a shorthand for `/.../<CELL-NAME>/fs'
29 on machines running OSF's Distributing Computing Environment (DCE) and
30 Distributed File System (DFS). However, when --force-local, a
31 filename is never remote. */
32
33 #define _remdev(Path) \
34 (!force_local_option && (rmt_path__ = strchr (Path, ':')) \
35 && rmt_path__ > (Path) && rmt_path__[-1] != '/')
36
37 #define _isrmt(Fd) \
38 ((Fd) >= __REM_BIAS)
39
40 #define __REM_BIAS 128
41
42 #ifndef O_CREAT
43 # define O_CREAT 01000
44 #endif
45
46 #define rmtopen(Path, Oflag, Mode, Command) \
47 (_remdev (Path) ? rmt_open__ (Path, Oflag, __REM_BIAS, Command) \
48 : open (Path, Oflag, Mode))
49
50 #define rmtaccess(Path, Amode) \
51 (_remdev (Path) ? 0 : access (Path, Amode))
52
53 #define rmtstat(Path, Buffer) \
54 (_remdev (Path) ? (errno = EOPNOTSUPP), -1 : stat (Path, Buffer))
55 /* FIXME: errno should be read-only */
56
57 #define rmtcreat(Path, Mode, Command) \
58 (_remdev (Path) \
59 ? rmt_open__ (Path, 1 | O_CREAT, __REM_BIAS, Command) \
60 : creat (Path, Mode))
61
62 #define rmtlstat(Path, Buffer) \
63 (_remdev (Path) ? (errno = EOPNOTSUPP), -1 : lstat (Path, Buffer))
64 /* FIXME: errno should be read-only */
65
66 #define rmtread(Fd, Buffer, Length) \
67 (_isrmt (Fd) ? rmt_read__ (Fd - __REM_BIAS, Buffer, Length) \
68 : full_read (Fd, Buffer, Length))
69
70 #define rmtwrite(Fd, Buffer, Length) \
71 (_isrmt (Fd) ? rmt_write__ (Fd - __REM_BIAS, Buffer, Length) \
72 : full_write (Fd, Buffer, Length))
73
74 #define rmtlseek(Fd, Offset, Where) \
75 (_isrmt (Fd) ? rmt_lseek__ (Fd - __REM_BIAS, Offset, Where) \
76 : lseek (Fd, Offset, Where))
77
78 #define rmtclose(Fd) \
79 (_isrmt (Fd) ? rmt_close__ (Fd - __REM_BIAS) : close (Fd))
80
81 #define rmtioctl(Fd, Request, Argument) \
82 (_isrmt (Fd) ? rmt_ioctl__ (Fd - __REM_BIAS, Request, Argument) \
83 : ioctl (Fd, Request, Argument))
84
85 #define rmtdup(Fd) \
86 (_isrmt (Fd) ? (errno = EOPNOTSUPP), -1 : dup (Fd))
87 /* FIXME: errno should be read-only */
88
89 #define rmtfstat(Fd, Buffer) \
90 (_isrmt (Fd) ? (errno = EOPNOTSUPP), -1 : fstat (Fd, Buffer))
91 /* FIXME: errno should be read-only */
92
93 #define rmtfcntl(Fd, Command, Argument) \
94 (_isrmt (Fd) ? (errno = EOPNOTSUPP), -1 : fcntl (Fd, Command, Argument))
95 /* FIXME: errno should be read-only */
96
97 #define rmtisatty(Fd) \
98 (_isrmt (Fd) ? 0 : isatty (Fd))
This page took 0.035689 seconds and 3 git commands to generate.