home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntinc25.zoo / device.h < prev    next >
C/C++ Source or Header  |  1992-06-02  |  1KB  |  52 lines

  1. /* File to describe user definable devices. */
  2.  
  3. #ifndef _DEVICE_H
  4. #define _DEVICE_H
  5.  
  6. #ifndef _COMPILER_H
  7. #include <compiler.h>
  8. #endif
  9.  
  10. #ifndef _TYPES_H
  11. #include <types.h>
  12. #endif
  13.  
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17.  
  18. typedef long (*devfunc_t)();
  19.  
  20. struct _device {
  21.     char    *dosnm,        /* name under DOS (e.g. "CON:")     */
  22.         *unxnm;        /* name under UNIX (e.g. "console")     */
  23.     dev_t     dev;        /* device number   (e.g. 0xffff)    */
  24.     devfunc_t     open, close, read, write, ioctl;
  25.     struct _device    *next;
  26. };
  27.  
  28. /*
  29.  * Pseudo-device interface stuff. New devices can be hooked into the chain
  30.  * that's rooted at __devices. All unx2dos and low level i/o functions use this
  31.  * chain in determining whether files are devices or disk files, as does stat().
  32.  * The major device number of user-supplied devices must *NOT* be 0 or 0xff,
  33.  * both of which are reserved.
  34.  */
  35.  
  36. #define mkdev(major,minor)  ((dev_t)((((major) << 8) & 0xff00)|((minor) & 0x00ff)))
  37.  
  38. /* major/minor defined in <types.h> */
  39.  
  40. extern struct _device *__devices;
  41.  
  42. __EXTERN void _install_device __PROTO((struct _device *d));
  43. __EXTERN struct _device *_dev_fd __PROTO((int fd));
  44. __EXTERN struct _device *_dev_dosname __PROTO((const char *dosnm));
  45. __EXTERN struct _device *_dev_unxname __PROTO((const char *unm));
  46.  
  47. #ifdef __cplusplus
  48. }
  49. #endif
  50.  
  51. #endif /* _DEVICE_H */
  52.