]> Dogcows Code - chaz/tar/blobdiff - src/rmt.h
Updated
[chaz/tar] / src / rmt.h
index c4744060b4800e3267070243a66ac8dd4ed9360b..a685686d48dd8ed1ce84fbfbc08864613c082695 100644 (file)
--- a/src/rmt.h
+++ b/src/rmt.h
@@ -1,5 +1,7 @@
 /* Definitions for communicating with a remote tape drive.
-   Copyright (C) 1988, 1992 Free Software Foundation, Inc.
+
+   Copyright (C) 1988, 1992, 1996, 1997, 2001, 2003, 2004 Free
+   Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+extern char *rmt_dev_name__;
+
+int rmt_open__ (const char *, int, int, const char *);
+int rmt_close__ (int);
+size_t rmt_read__ (int, char *, size_t);
+size_t rmt_write__ (int, char *, size_t);
+off_t rmt_lseek__ (int, off_t, int);
+int rmt_ioctl__ (int, int, char *);
+
+/* A filename is remote if it contains a colon not preceded by a slash,
+   to take care of `/:/' which is a shorthand for `/.../<CELL-NAME>/fs'
+   on machines running OSF's Distributing Computing Environment (DCE) and
+   Distributed File System (DFS).  However, when --force-local, a
+   filename is never remote.  */
+
+#define _remdev(dev_name) \
+  (!force_local_option && (rmt_dev_name__ = strchr (dev_name, ':')) \
+   && rmt_dev_name__ > (dev_name) \
+   && ! memchr (dev_name, '/', rmt_dev_name__ - (dev_name)))
 
-#if !defined(_POSIX_VERSION)
-#ifdef __MSDOS__
-#include <io.h>
-#else /* !__MSDOS__ */
-extern off_t lseek();
-#endif /* __MSDOS__ */
-#endif /* _POSIX_VERSION */
-
-#ifdef NO_REMOTE
-#define _isrmt(f)      0
-#define rmtopen                open
-#define rmtaccess      access
-#define rmtstat                stat
-#define rmtcreat       creat
-#define rmtlstat       lstat
-#define rmtread                read
-#define rmtwrite       write
-#define rmtlseek       lseek
-#define rmtclose       close
-#define rmtioctl       ioctl
-#define rmtdup         dup
-#define rmtfstat       fstat
-#define rmtfcntl       fcntl
-#define rmtisatty      isatty
-
-#else /* !NO_REMOTE */
-
-#define __REM_BIAS     128
-#define RMTIOCTL
+#define _isrmt(fd) \
+  ((fd) >= __REM_BIAS)
+
+#define __REM_BIAS (1 << 30)
 
 #ifndef O_CREAT
-#define O_CREAT        01000
+# define O_CREAT 01000
 #endif
 
-extern char *__rmt_path;
+#define rmtopen(dev_name, oflag, mode, command) \
+  (_remdev (dev_name) ? rmt_open__ (dev_name, oflag, __REM_BIAS, command) \
+   : open (dev_name, oflag, mode))
 
-#if defined(USG) || defined(STDC_HEADERS)
-#include <string.h>
-#define index strchr
-#else
-extern char *index();
-#endif
+#define rmtaccess(dev_name, amode) \
+  (_remdev (dev_name) ? 0 : access (dev_name, amode))
 
-#define _remdev(path)  (!f_force_local && __rmt_path=index(path, ':'))
-#define _isrmt(fd)             ((fd) >= __REM_BIAS)
-
-#define rmtopen(path,oflag,mode) (_remdev(path) ? __rmt_open(path, oflag, mode, __REM_BIAS) : open(path, oflag, mode))
-#define rmtaccess(path, amode) (_remdev(path) ? 0 : access(path, amode))
-#define rmtstat(path, buf)     (_remdev(path) ? (errno = EOPNOTSUPP), -1 : stat(path, buf))
-#define rmtcreat(path, mode)   (_remdev(path) ? __rmt_open (path, 1 | O_CREAT, mode, __REM_BIAS) : creat(path, mode))
-#define rmtlstat(path,buf)     (_remdev(path) ? (errno = EOPNOTSUPP), -1 : lstat(path,buf))
-
-#define rmtread(fd, buf, n)    (_isrmt(fd) ? __rmt_read(fd - __REM_BIAS, buf, n) : read(fd, buf, n))
-#define rmtwrite(fd, buf, n)   (_isrmt(fd) ? __rmt_write(fd - __REM_BIAS, buf, n) : write(fd, buf, n))
-#define rmtlseek(fd, off, wh)  (_isrmt(fd) ? __rmt_lseek(fd - __REM_BIAS, off, wh) : lseek(fd, off, wh))
-#define rmtclose(fd)           (_isrmt(fd) ? __rmt_close(fd - __REM_BIAS) : close(fd))
-#ifdef RMTIOCTL
-#define rmtioctl(fd,req,arg)   (_isrmt(fd) ? __rmt_ioctl(fd - __REM_BIAS, req, arg) : ioctl(fd, req, arg))
-#else
-#define rmtioctl(fd,req,arg)   (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : ioctl(fd, req, arg))
-#endif
-#define rmtdup(fd)             (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : dup(fd))
-#define rmtfstat(fd, buf)      (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : fstat(fd, buf))
-#define rmtfcntl(fd,cmd,arg)   (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : fcntl (fd, cmd, arg))
-#define rmtisatty(fd)          (_isrmt(fd) ? 0 : isatty(fd))
-
-#undef RMTIOCTL
-
-int __rmt_open ();
-int __rmt_close ();
-int __rmt_read ();
-int __rmt_write ();
-long __rmt_lseek();
-int __rmt_ioctl ();
-#endif /* !NO_REMOTE */
+#define rmtstat(dev_name, buffer) \
+  (_remdev (dev_name) ? (errno = EOPNOTSUPP), -1 : stat (dev_name, buffer))
+
+#define rmtcreat(dev_name, mode, command) \
+   (_remdev (dev_name) \
+    ? rmt_open__ (dev_name, 1 | O_CREAT, __REM_BIAS, command) \
+    : creat (dev_name, mode))
+
+#define rmtlstat(dev_name, muffer) \
+  (_remdev (dev_name) ? (errno = EOPNOTSUPP), -1 : lstat (dev_name, buffer))
+
+#define rmtread(fd, buffer, length) \
+  (_isrmt (fd) ? rmt_read__ (fd - __REM_BIAS, buffer, length) \
+   : safe_read (fd, buffer, length))
+
+#define rmtwrite(fd, buffer, length) \
+  (_isrmt (fd) ? rmt_write__ (fd - __REM_BIAS, buffer, length) \
+   : full_write (fd, buffer, length))
+
+#define rmtlseek(fd, offset, where) \
+  (_isrmt (fd) ? rmt_lseek__ (fd - __REM_BIAS, offset, where) \
+   : lseek (fd, offset, where))
+
+#define rmtclose(fd) \
+  (_isrmt (fd) ? rmt_close__ (fd - __REM_BIAS) : close (fd))
+
+#define rmtioctl(fd, request, argument) \
+  (_isrmt (fd) ? rmt_ioctl__ (fd - __REM_BIAS, request, argument) \
+   : ioctl (fd, request, argument))
+
+#define rmtdup(fd) \
+  (_isrmt (fd) ? (errno = EOPNOTSUPP), -1 : dup (fd))
+
+#define rmtfstat(fd, buffer) \
+  (_isrmt (fd) ? (errno = EOPNOTSUPP), -1 : fstat (fd, buffer))
+
+#define rmtfcntl(cd, command, argument) \
+  (_isrmt (fd) ? (errno = EOPNOTSUPP), -1 : fcntl (fd, command, argument))
+
+#define rmtisatty(fd) \
+  (_isrmt (fd) ? 0 : isatty (fd))
This page took 0.027126 seconds and 4 git commands to generate.