4
0

rmt.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* Definitions for communicating with a remote tape drive.
  2. Copyright (C) 1988, 1992 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
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
  14. #ifdef HAVE_UNISTD_H
  15. #include <unistd.h>
  16. #endif
  17. #if !defined(_POSIX_VERSION)
  18. #ifdef __MSDOS__
  19. #include <io.h>
  20. #else /* !__MSDOS__ */
  21. extern off_t lseek ();
  22. #endif /* __MSDOS__ */
  23. #endif /* _POSIX_VERSION */
  24. #ifdef NO_REMOTE
  25. #define _isrmt(f) 0
  26. #define rmtopen open
  27. #define rmtaccess access
  28. #define rmtstat stat
  29. #define rmtcreat creat
  30. #define rmtlstat lstat
  31. #define rmtread read
  32. #define rmtwrite write
  33. #define rmtlseek lseek
  34. #define rmtclose close
  35. #define rmtioctl ioctl
  36. #define rmtdup dup
  37. #define rmtfstat fstat
  38. #define rmtfcntl fcntl
  39. #define rmtisatty isatty
  40. #else /* !NO_REMOTE */
  41. #define __REM_BIAS 128
  42. #define RMTIOCTL
  43. #ifndef O_CREAT
  44. #define O_CREAT 01000
  45. #endif
  46. extern char *__rmt_path;
  47. #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
  48. #include <string.h>
  49. #ifndef index
  50. #define index strchr
  51. #endif
  52. #else
  53. extern char *index ();
  54. #endif
  55. #define _remdev(path) (!f_force_local && (__rmt_path=index(path, ':')))
  56. #define _isrmt(fd) ((fd) >= __REM_BIAS)
  57. #define rmtopen(path,oflag,mode) (_remdev(path) ? __rmt_open(path, oflag, mode, __REM_BIAS) : open(path, oflag, mode))
  58. #define rmtaccess(path, amode) (_remdev(path) ? 0 : access(path, amode))
  59. #define rmtstat(path, buf) (_remdev(path) ? (errno = EOPNOTSUPP), -1 : stat(path, buf))
  60. #define rmtcreat(path, mode) (_remdev(path) ? __rmt_open (path, 1 | O_CREAT, mode, __REM_BIAS) : creat(path, mode))
  61. #define rmtlstat(path,buf) (_remdev(path) ? (errno = EOPNOTSUPP), -1 : lstat(path,buf))
  62. #define rmtread(fd, buf, n) (_isrmt(fd) ? __rmt_read(fd - __REM_BIAS, buf, n) : read(fd, buf, n))
  63. #define rmtwrite(fd, buf, n) (_isrmt(fd) ? __rmt_write(fd - __REM_BIAS, buf, n) : write(fd, buf, n))
  64. #define rmtlseek(fd, off, wh) (_isrmt(fd) ? __rmt_lseek(fd - __REM_BIAS, off, wh) : lseek(fd, off, wh))
  65. #define rmtclose(fd) (_isrmt(fd) ? __rmt_close(fd - __REM_BIAS) : close(fd))
  66. #ifdef RMTIOCTL
  67. #define rmtioctl(fd,req,arg) (_isrmt(fd) ? __rmt_ioctl(fd - __REM_BIAS, req, arg) : ioctl(fd, req, arg))
  68. #else
  69. #define rmtioctl(fd,req,arg) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : ioctl(fd, req, arg))
  70. #endif
  71. #define rmtdup(fd) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : dup(fd))
  72. #define rmtfstat(fd, buf) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : fstat(fd, buf))
  73. #define rmtfcntl(fd,cmd,arg) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : fcntl (fd, cmd, arg))
  74. #define rmtisatty(fd) (_isrmt(fd) ? 0 : isatty(fd))
  75. #undef RMTIOCTL
  76. int __rmt_open ();
  77. int __rmt_close ();
  78. int __rmt_read ();
  79. int __rmt_write ();
  80. long __rmt_lseek ();
  81. int __rmt_ioctl ();
  82. #endif /* !NO_REMOTE */