rmt.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* Definitions for communicating with a remote tape drive.
  2. Copyright (C) 1988, 1992, 1996, 1997 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software Foundation,
  13. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  14. extern char *rmt_path__;
  15. int rmt_open__ PARAMS ((const char *, int, int, const char *));
  16. int rmt_close__ PARAMS ((int));
  17. ssize_t rmt_read__ PARAMS ((int, char *, size_t));
  18. ssize_t rmt_write__ PARAMS ((int, char *, size_t));
  19. off_t rmt_lseek__ PARAMS ((int, off_t, int));
  20. int rmt_ioctl__ PARAMS ((int, int, char *));
  21. /* A filename is remote if it contains a colon not preceded by a slash,
  22. to take care of `/:/' which is a shorthand for `/.../<CELL-NAME>/fs'
  23. on machines running OSF's Distributing Computing Environment (DCE) and
  24. Distributed File System (DFS). However, when --force-local, a
  25. filename is never remote. */
  26. #define _remdev(Path) \
  27. (!force_local_option && (rmt_path__ = strchr (Path, ':')) \
  28. && rmt_path__ > (Path) && rmt_path__[-1] != '/')
  29. #define _isrmt(Fd) \
  30. ((Fd) >= __REM_BIAS)
  31. #define __REM_BIAS 128
  32. #ifndef O_CREAT
  33. # define O_CREAT 01000
  34. #endif
  35. #define rmtopen(Path, Oflag, Mode, Command) \
  36. (_remdev (Path) ? rmt_open__ (Path, Oflag, __REM_BIAS, Command) \
  37. : open (Path, Oflag, Mode))
  38. #define rmtaccess(Path, Amode) \
  39. (_remdev (Path) ? 0 : access (Path, Amode))
  40. #define rmtstat(Path, Buffer) \
  41. (_remdev (Path) ? (errno = EOPNOTSUPP), -1 : stat (Path, Buffer))
  42. #define rmtcreat(Path, Mode, Command) \
  43. (_remdev (Path) \
  44. ? rmt_open__ (Path, 1 | O_CREAT, __REM_BIAS, Command) \
  45. : creat (Path, Mode))
  46. #define rmtlstat(Path, Buffer) \
  47. (_remdev (Path) ? (errno = EOPNOTSUPP), -1 : lstat (Path, Buffer))
  48. #define rmtread(Fd, Buffer, Length) \
  49. (_isrmt (Fd) ? rmt_read__ (Fd - __REM_BIAS, Buffer, Length) \
  50. : safe_read (Fd, Buffer, Length))
  51. #define rmtwrite(Fd, Buffer, Length) \
  52. (_isrmt (Fd) ? rmt_write__ (Fd - __REM_BIAS, Buffer, Length) \
  53. : full_write (Fd, Buffer, Length))
  54. #define rmtlseek(Fd, Offset, Where) \
  55. (_isrmt (Fd) ? rmt_lseek__ (Fd - __REM_BIAS, Offset, Where) \
  56. : lseek (Fd, Offset, Where))
  57. #define rmtclose(Fd) \
  58. (_isrmt (Fd) ? rmt_close__ (Fd - __REM_BIAS) : close (Fd))
  59. #define rmtioctl(Fd, Request, Argument) \
  60. (_isrmt (Fd) ? rmt_ioctl__ (Fd - __REM_BIAS, Request, Argument) \
  61. : ioctl (Fd, Request, Argument))
  62. #define rmtdup(Fd) \
  63. (_isrmt (Fd) ? (errno = EOPNOTSUPP), -1 : dup (Fd))
  64. #define rmtfstat(Fd, Buffer) \
  65. (_isrmt (Fd) ? (errno = EOPNOTSUPP), -1 : fstat (Fd, Buffer))
  66. #define rmtfcntl(Fd, Command, Argument) \
  67. (_isrmt (Fd) ? (errno = EOPNOTSUPP), -1 : fcntl (Fd, Command, Argument))
  68. #define rmtisatty(Fd) \
  69. (_isrmt (Fd) ? 0 : isatty (Fd))