home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue2 / SDL.ARC / !unixlib / source / clib / unixlib / h / dev next >
Encoding:
Text File  |  2004-09-10  |  6.6 KB  |  180 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/unixlib/dev.h,v $
  4.  * $Date: 2004/09/09 15:34:52 $
  5.  * $Revision: 1.7 $
  6.  * $State: Exp $
  7.  * $Author: peter $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. #ifndef __UNIXLIB_DEV_H
  12. #define __UNIXLIB_DEV_H
  13.  
  14. #ifndef __UNIXLIB_FEATURES_H
  15. #include <unixlib/features.h>
  16. #endif
  17.  
  18. #ifndef __UNIXLIB_TYPES_H
  19. #include <unixlib/types.h>
  20. #endif
  21.  
  22. #ifndef __UNIXLIB_FD_H
  23. #include <unixlib/fd.h>
  24. #endif
  25.  
  26. #include <sys/select.h>
  27. #include <sys/stat.h>
  28.  
  29. __BEGIN_DECLS
  30.  
  31.  
  32. /* major device numbers */
  33.  
  34. #define DEV_RISCOS    0    /* RISC OS file system */
  35. #define DEV_TTY        1    /* tty                 */
  36. #define DEV_PIPE    2    /* UnixLib pipe()      */
  37. #define DEV_NULL    3    /* /dev/null           */
  38. #define DEV_SOCKET    4    /* Network socket      */
  39. #define DEV_ZERO    5    /* /dev/zero           */
  40. #define DEV_RANDOM    6    /* /dev/random         */
  41. #define DEV_DSP        7    /* /dev/dsp            */
  42.  
  43. #define NDEV        8
  44.  
  45.  
  46. struct dev
  47. {
  48.   void *(*open) (struct __unixlib_fd *__fd, const char *__fname, int __mode);
  49.   int (*close) (struct __unixlib_fd *__fd);
  50.   int (*read) (struct __unixlib_fd *__fd, void *__data, int __nbyte);
  51.   int (*write) (struct __unixlib_fd *__fd, const void *__data, int __nbyte);
  52.   __off_t (*lseek) (struct __unixlib_fd *__fd, __off_t __lpos, int __whence);
  53.   int (*ioctl) (struct __unixlib_fd *__fd, unsigned long __request,
  54.                 void *__arg);
  55.   int (*select)(struct __unixlib_fd *__fd, int __fd1, fd_set *__read,
  56.         fd_set *__write, fd_set *__except);
  57.   int (*stat) (const char *filename, struct stat *buf);
  58.   int (*fstat) (int fd, struct stat *buf);
  59. };
  60.  
  61. extern struct dev __dev[NDEV];
  62.  
  63. extern const dev_t __getdevtype (const char *__filename);
  64.  
  65. extern void *__fsopen (struct __unixlib_fd *__fd, const char *__fname,
  66.                int __mode);
  67. extern int __fsclose (struct __unixlib_fd *__fd);
  68. extern int __fsread (struct __unixlib_fd *__fd, void *__data, int __nbyte);
  69. extern int __fswrite (struct __unixlib_fd *__fd, const void *__data,
  70.               int __nbyte);
  71. extern __off_t __fslseek (struct __unixlib_fd *__fd, __off_t __lpos,
  72.               int __whence);
  73. #ifdef __UNIXLIB_NO_COMMON_DEV
  74. extern int __fsioctl (struct __unixlib_fd *__fd, unsigned long __request,
  75.                       void *__arg);
  76. extern int __fsselect (struct __unixlib_fd *__fd, int __fd1,
  77.                fd_set *__read, fd_set *__write,
  78.                fd_set *__except);
  79. #endif
  80. extern int __fsstat (const char *__filename, struct stat *__buf);
  81. extern int __fsfstat (int __fd, struct stat *__buf);
  82.  
  83. extern void *__ttyopen         (struct __unixlib_fd *__fd,
  84.                   const char *file, int __mode);
  85. extern int __ttyclose         (struct __unixlib_fd *__fd);
  86. extern int __ttyread         (struct __unixlib_fd *__fd,
  87.                   void *buf, int __nbyte);
  88. extern int __ttywrite         (struct __unixlib_fd *__fd,
  89.                   const void *buf, int __nbyte);
  90. #ifdef __UNIXLIB_NO_COMMON_DEV
  91. extern __off_t __ttylseek    (struct __unixlib_fd *__fd,
  92.                   __off_t __lpos, int __whence);
  93. #endif
  94. extern int __ttyioctl         (struct __unixlib_fd *__fd,
  95.                   unsigned long __request, void *__arg);
  96. extern int __ttyselect         (struct __unixlib_fd *__fdriptor,
  97.                   int __fd1, fd_set *__read,
  98.                   fd_set *__write, fd_set *__except);
  99.  
  100. extern void *__pipeopen         (struct __unixlib_fd *__fd,
  101.                   const char *file, int __mode);
  102. extern int __pipeclose         (struct __unixlib_fd *__fd);
  103. extern int __piperead         (struct __unixlib_fd *__fd,
  104.                   void *__data, int __nbyte);
  105. extern int __pipewrite         (struct __unixlib_fd *__fd,
  106.                   const void *__data, int __nbyte);
  107. #ifdef __UNIXLIB_NO_COMMON_DEV
  108. extern __off_t __pipelseek   (struct __unixlib_fd *__fd,
  109.                   __off_t __lpos, int __whence);
  110. extern int __pipeioctl         (struct __unixlib_fd *__fd,
  111.                   unsigned long __request, void *__arg);
  112. #endif
  113. extern int __pipeselect         (struct __unixlib_fd *__fdriptor,
  114.                   int __fd1, fd_set *__read,
  115.                   fd_set *__write, fd_set *__except);
  116.  
  117. extern void *__nullopen         (struct __unixlib_fd *__fd,
  118.                   const char *file, int __mode);
  119. extern int __nullclose         (struct __unixlib_fd *__fd);
  120. extern int __nullread         (struct __unixlib_fd *__fd,
  121.                   void *__data, int __nbyte);
  122. extern int __nullwrite         (struct __unixlib_fd *__fd,
  123.                   const void *__data, int __nbyte);
  124. #ifdef __UNIXLIB_NO_COMMON_DEV
  125. extern __off_t __nulllseek   (struct __unixlib_fd *__fd,
  126.                   __off_t __lpos, int __whence);
  127. extern int __nullioctl         (struct __unixlib_fd *__fd,
  128.                   unsigned long __request, void *__arg);
  129. extern int __nullselect         (struct __unixlib_fd *__fdriptor,
  130.                   int __fd1, fd_set *__read,
  131.                   fd_set *__write, fd_set *__except);
  132. #endif
  133. extern int __nullstat (const char *__filename, struct stat *__buf);
  134. extern int __nullfstat (int __fd, struct stat *__buf);
  135.  
  136. extern void *__sockopen         (struct __unixlib_fd *__fd,
  137.                   const char *file, int __mode);
  138. extern int __sockclose         (struct __unixlib_fd *__fd);
  139. extern int __sockread         (struct __unixlib_fd *__fd,
  140.                   void *__data, int __nbyte);
  141. extern int __sockwrite         (struct __unixlib_fd *__fd,
  142.                   const void *__data, int __nbyte);
  143. #ifdef __UNIXLIB_NO_COMMON_DEV
  144. extern __off_t __socklseek   (struct __unixlib_fd *__fd,
  145.                   __off_t __lpos, int __whence);
  146. #endif
  147. extern int __sockioctl         (struct __unixlib_fd *__fd,
  148.                   unsigned long __request, void *__arg);
  149. extern int __sockselect         (struct __unixlib_fd *__fdriptor,
  150.                   int __fd1, fd_set *__read,
  151.                   fd_set *__write, fd_set *__except);
  152.  
  153. #ifndef __UNIXLIB_NO_COMMON_DEV
  154. /* Return ESPIPE */
  155. extern __off_t __commonlseek (struct __unixlib_fd *__fd,
  156.                   __off_t __lpos, int __whence);
  157. /* Return EINVAL */
  158. extern int __commonioctl     (struct __unixlib_fd *__fd,
  159.                   unsigned long __request, void *__arg);
  160. /* Return ready to read, ready to write, no execptional conditions */
  161. extern int __commonselect    (struct __unixlib_fd *__fdriptor,
  162.                   int __fd, fd_set *__read,
  163.                   fd_set *__write, fd_set *__except);
  164. #endif
  165.  
  166. extern int __zeroread (struct __unixlib_fd *__file_desc, void *__data, int __nbyte);
  167.  
  168. extern void *__randomopen (struct __unixlib_fd *__file_desc, const char *__file, int __mode);
  169. extern int __randomread (struct __unixlib_fd *__file_desc, void *__data, int __nbyte);
  170.  
  171.  
  172. extern void *__dspopen (struct __unixlib_fd *__file_desc, const char *__file, int __mode);
  173. extern int __dspclose (struct __unixlib_fd *__fd);
  174. extern __off_t __dsplseek (struct __unixlib_fd *__fd, __off_t __lpos, int __whence);
  175. extern int __dspioctl (struct __unixlib_fd *__fd, unsigned long __request, void *__arg);
  176.  
  177. __END_DECLS
  178.  
  179. #endif
  180.