home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / gnulib / libsrc98.zoo / null.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-23  |  631 b   |  38 lines

  1. /* /dev/null data sink */
  2.  
  3. #include <stddef.h>
  4. #include <device.h>
  5.  
  6. #ifndef mkdev
  7. #define mkdev(a,b)    ((((a) << 8) & 0xff00)|((b) & 0x00ff))
  8. #endif
  9.  
  10. static long null_open(const char *name, int flags, unsigned mode)
  11. {
  12.     return(mkdev('N',0));
  13. }
  14.  
  15. static long null_close(int fd) 
  16. {
  17.     return 0;
  18. }
  19.  
  20. static long null_read(int fd, void *buf, long nbytes)
  21. {
  22.     return 0;
  23. }
  24.  
  25. static long null_write(int fd, void *buf, long nbytes)
  26. {
  27.     return nbytes;
  28. }
  29.  
  30. static struct _device    null_dev =
  31.     {"NUL:", "null", mkdev('N', 0),
  32.          null_open, null_close, null_read, null_write, NULL, NULL };
  33.  
  34. void install_null()
  35. {
  36.     _install_device(&null_dev);
  37. }
  38.