home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / tar-1.11.8-src.tgz / tar.out / fsf / tar / src / rmt.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  3KB  |  96 lines

  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. extern char *__rmt_path;
  19.  
  20. int __rmt_open __P ((const char *, int, int, const char *));
  21. int __rmt_close __P ((int));
  22. int __rmt_read __P ((int, char *, unsigned int));
  23. int __rmt_write __P ((int, char *, unsigned int));
  24. long __rmt_lseek __P ((int, off_t, int));
  25. int __rmt_ioctl __P ((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.    [Which system?  What is DCE?  What is DFS?]  */
  34.  
  35. #define _remdev(Path) \
  36.   (!flag_force_local && (__rmt_path = strchr (Path, ':')) \
  37.    && __rmt_path > (Path) && __rmt_path[-1] != '/')
  38.  
  39. #define _isrmt(Fd) \
  40.   ((Fd) >= __REM_BIAS)
  41.  
  42. #define __REM_BIAS    128
  43.  
  44. #ifndef O_CREAT
  45. #define O_CREAT    01000
  46. #endif
  47.  
  48. #define rmtopen(Path, Oflag, Mode, Command) \
  49.   (_remdev (Path) ? __rmt_open (Path, Oflag, __REM_BIAS, Command) \
  50.    : open (Path, Oflag, Mode))
  51.  
  52. #define rmtaccess(Path, Amode) \
  53.   (_remdev (Path) ? 0 : access (Path, Amode))
  54.  
  55. #define rmtstat(Path, Buffer) \
  56.   (_remdev (Path) ? (errno = EOPNOTSUPP), -1 : stat (Path, Buffer))
  57.  
  58. #define rmtcreat(Path, Mode, Command) \
  59.    (_remdev (Path) \
  60.     ? __rmt_open (Path, 1 | O_CREAT, __REM_BIAS, Command) \
  61.     : creat (Path, Mode))
  62.  
  63. #define rmtlstat(Path, Buffer) \
  64.   (_remdev (Path) ? (errno = EOPNOTSUPP), -1 : lstat (Path, Buffer))
  65.  
  66. #define rmtread(Fd, Buffer, Length) \
  67.   (_isrmt (Fd) ? __rmt_read (Fd - __REM_BIAS, Buffer, Length) \
  68.    : read (Fd, Buffer, Length))
  69.  
  70. #define rmtwrite(Fd, Buffer, Length) \
  71.   (_isrmt (Fd) ? __rmt_write (Fd - __REM_BIAS, Buffer, Length) \
  72.    : 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.  
  88. #define rmtfstat(Fd, Buffer) \
  89.   (_isrmt (Fd) ? (errno = EOPNOTSUPP), -1 : fstat (Fd, Buffer))
  90.  
  91. #define rmtfcntl(Fd, Command, Argument) \
  92.   (_isrmt (Fd) ? (errno = EOPNOTSUPP), -1 : fcntl (Fd, Command, Argument))
  93.  
  94. #define rmtisatty(Fd) \
  95.   (_isrmt (Fd) ? 0 : isatty (Fd))
  96.