home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue2 / SDL.ARC / !unixlib / source / clib / unixlib / h / fd < prev    next >
Encoding:
Text File  |  2004-09-05  |  1.6 KB  |  61 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/unixlib/fd.h,v $
  4.  * $Date: 2002/09/24 21:02:37 $
  5.  * $Revision: 1.3 $
  6.  * $State: Exp $
  7.  * $Author: admin $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. /* File descriptor interface definition.  */
  12.  
  13. #ifndef __UNIXLIB_FD_H
  14. #define __UNIXLIB_FD_H 1
  15.  
  16. #ifndef __UNIXLIB_FEATURES_H
  17. #include <unixlib/features.h>
  18. #endif
  19.  
  20. #ifndef __UNIXLIB_TYPES_H
  21. #include <unixlib/types.h>
  22. #endif
  23.  
  24. __BEGIN_DECLS
  25.  
  26. /* Maximum number of file descriptors that a process can have. */
  27. #define MAXFD 64
  28.  
  29. /* Magic number for file descriptors.  */
  30. #define _FDMAGIC 0xfeabaeca
  31.  
  32. /* File descriptor structure definition. */
  33. struct __unixlib_fd
  34. {
  35.   unsigned int __magic; /* magic number for descriptor validity */
  36.   unsigned int fs : 8; /* Filing system that file resides on */
  37.   unsigned int device : 8; /* Device type (tty, socket etc. ) */
  38.   unsigned int dflag : 16; /* File descriptor flags.  */
  39.   void *handle; /* device specific field (i.e. socket, file handle) */
  40.   int fflag; /* File status flags (attribs for opening a file) */
  41.   __pid_t pid; /* process ID of the owner */
  42. };
  43.  
  44. /* Macro for checking file descriptor validity.  */
  45. #define BADF(fdes) (((unsigned int)(fdes) < MAXFD) ? (__u->fd[(fdes)].__magic != _FDMAGIC):1)
  46.  
  47. #ifdef __UNIXLIB_INTERNALS
  48. /* File descriptor flags.  */
  49.  
  50. /* Set if file is a directory.  */
  51. #define FILE_ISDIR 0x0001
  52.  
  53.  
  54. /* Allocate and initialise a new file descriptor.  */
  55. extern int __alloc_file_descriptor (void);
  56. #endif
  57.  
  58. __END_DECLS
  59.  
  60. #endif
  61.