home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / unix / unixlib_1 / !UnixLib37_netlib_clib_sys_h_dev < prev    next >
Encoding:
Text File  |  1996-11-05  |  3.3 KB  |  112 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/clib/sys/h/RCS/dev,v $
  4.  * $Date: 1996/10/30 21:58:59 $
  5.  * $Revision: 1.2 $
  6.  * $State: Exp $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: dev,v $
  10.  * Revision 1.2  1996/10/30 21:58:59  unixlib
  11.  * Massive changes made by Nick Burret and Peter Burwood.
  12.  *
  13.  * Revision 1.1  1996/04/19 21:23:56  simon
  14.  * Initial revision
  15.  *
  16.  ***************************************************************************/
  17.  
  18. #ifndef __SYS_DEV_H
  19. #define __SYS_DEV_H
  20.  
  21. #ifndef __UNIXLIB_TYPES_H
  22. #include <unixlib/types.h>
  23. #endif
  24.  
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28.  
  29. /* This section is placed here to prevent the inclusion of <sys/unix.h>
  30.    and all those other #include files that are otherwise unnecessary.  */
  31. #define MAXFD 64
  32.  
  33. struct file
  34.   {
  35.   __dev_t         dev;        /* device */
  36.   int            oflag;        /* oflag */
  37.   struct file        *dup;        /* dup list */
  38.   __pid_t        pid;        /* pid of owner */
  39.   int            r[6];        /* OS_File r0 -> r5 */
  40.   };
  41.  
  42. #define BADF(f) (!(((f) >= 0 && (f) < MAXFD) ? (__u->file[f].dup) : 0))
  43.  
  44. /* Proper start of <sys/dev.h>.  */
  45.  
  46. #define NDEV        5
  47.  
  48. /* major device numbers */
  49.  
  50. #define DEV_RISCOS    0    /* RiscOS file system */
  51. #define DEV_TTY     1    /* tty */
  52. #define DEV_PIPE    2    /* UnixLib pipe() */
  53. #define DEV_NULL    3    /* /dev/null */
  54. #define DEV_SOCKET    4    /* Freenet socket */
  55.  
  56. struct dev
  57.   {
  58.   int (*open)(char *,int,struct file *);
  59.   int (*close)(int,struct file *);
  60.   int (*read)(int,void *,int,struct file *);
  61.   int (*write)(int,void *,int,struct file *);
  62.   __off_t (*lseek)(int,__off_t,int,struct file *);
  63.   int (*ioctl)(int,int,void *,struct file *);
  64.   };
  65.  
  66. extern struct dev __dev[NDEV];
  67.  
  68. #define major(x) ((x) >> 8)
  69. #define minor(x) ((x) & 0xff)
  70. #define makedev(x,y) (__dev_t)(((x) << 8) | ((y) & 0xff))
  71.  
  72. extern int __fsopen(char *,int,struct file *);
  73. extern int __fsclose(int,struct file *);
  74. extern int __fsread(int,void *,int,struct file *);
  75. extern int __fswrite(int,void *,int,struct file *);
  76. extern __off_t __fslseek(int,__off_t,int,struct file *);
  77. extern int __fsioctl(int,int,void *,struct file *);
  78.  
  79. extern int __ttyopen(char *,int,struct file *);
  80. extern int __ttyclose(int,struct file *);
  81. extern int __ttyread(int,void *,int,struct file *);
  82. extern int __ttywrite(int,void *,int,struct file *);
  83. extern __off_t __ttylseek(int,__off_t,int,struct file *);
  84. extern int __ttyioctl(int,int,void *,struct file *);
  85.  
  86. extern int __pipeopen(char *,int,struct file *);
  87. extern int __pipeclose(int,struct file *);
  88. extern int __piperead(int,void *,int,struct file *);
  89. extern int __pipewrite(int,void *,int,struct file *);
  90. extern __off_t __pipelseek(int,__off_t,int,struct file *);
  91. extern int __pipeioctl(int,int,void *,struct file *);
  92.  
  93. extern int __nullopen(char *,int,struct file *);
  94. extern int __nullclose(int,struct file *);
  95. extern int __nullread(int,void *,int,struct file *);
  96. extern int __nullwrite(int,void *,int,struct file *);
  97. extern __off_t __nulllseek(int,__off_t,int,struct file *);
  98. extern int __nullioctl(int,int,void *,struct file *);
  99.  
  100. extern int __sockopen(char *,int,struct file *);
  101. extern int __sockclose(int,struct file *);
  102. extern int __sockread(int,void *,int,struct file *);
  103. extern int __sockwrite(int,void *,int,struct file *);
  104. extern __off_t __socklseek(int,__off_t,int,struct file *);
  105. extern int __sockioctl(int,int,void *,struct file *);
  106.  
  107. #ifdef __cplusplus
  108.     }
  109. #endif
  110.  
  111. #endif
  112.