home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.7z / ftp.whtech.com / emulators / v9t9 / linux / sources / V9t9 / source / OSLib / Posix.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-10-19  |  2.9 KB  |  150 lines

  1.  
  2. /*
  3.  *    POSIX types
  4.  */
  5. #ifndef _POSIX_C_SOURCE
  6. #define _POSIX_C_SOURCE 199309
  7. #endif
  8.  
  9. #include <limits.h>
  10. #include <errno.h>
  11. #include <time.h>
  12.  
  13. #if defined(BEWORKS_FS) || defined(QNX_FS)
  14. #define OS_MAXVOLLEN    63
  15. #else
  16. #define OS_MAXVOLLEN    7
  17. #endif
  18.  
  19. // until we can fudge the FSSpecs...
  20. #define OS_MAXNAMELEN    63
  21.  
  22. #if OSLIB_USE_MAXIMUM_PATH
  23.     #define OS_MAXPATHLEN (PATH_MAX-1)
  24. #else
  25.     #if PATH_MAX > 255
  26.     #define OS_MAXPATHLEN 255
  27.     #else
  28.     #define OS_MAXPATHLEN (PATH_MAX-1)
  29.     #endif
  30. #endif
  31.  
  32. #define OS_VOLSIZE        (OS_MAXVOLLEN+1)
  33. #define OS_NAMESIZE        (OS_MAXNAMELEN+1)
  34. #define OS_PATHSIZE        (OS_MAXPATHLEN+1)
  35.  
  36. #define OS_PATHSEP        '/'
  37. #define OS_CWDSTR        "."
  38. #define OS_PDSTR        "../"
  39.  
  40. #define    OS_ENVSEP        ':'
  41. #define    OS_ENVSEPLIST    ":;"
  42.  
  43. #undef    OS_IS_CASE_INSENSITIVE
  44. #undef    OS_REL_PATH_HAS_SEP
  45.  
  46. /*    As used by open() */
  47. typedef    
  48. int                    OSRef;        /*    file ref */
  49.  
  50. /*    C string representing a full path;
  51.     directories must end in '/'
  52.  */
  53. typedef
  54. struct                OSPathSpec
  55. {
  56.     char            s[OS_PATHSIZE];
  57. }                    OSPathSpec;        /*    OS specifier for a path */
  58.  
  59. /*    C string representing a name  */
  60. typedef
  61. struct                OSNameSpec
  62. {
  63.     char            s[OS_NAMESIZE];    
  64. }                    OSNameSpec;        /*     OS specifier for a name */
  65.  
  66. /*    As used by opendir() */
  67. typedef
  68. struct
  69. {
  70.     void        *dir;                    /* really DIR* */
  71.     OSPathSpec    path;                    /* original path */
  72. }                    OSDirRef;        /*    directory scan ref */
  73.  
  74. /*    As used by malloc(), etc.  */
  75. typedef
  76. struct                OSHandle
  77. {
  78.     void            *addr;                    /* of block */
  79.     size_t            used,size;                /* used, total bytes */
  80. }                    OSHandle;        /*  memory handle */
  81.  
  82. /*    As used by errno */
  83. typedef 
  84. int                    OSError;        /*    error type */
  85.  
  86. /*    No-error code */
  87. #define    OS_NOERR        0
  88.  
  89. /*    Does OSError report error? */
  90. #define OS_ISERR(x)        ((x)<0)
  91.  
  92. #if defined(__BEOS__)
  93. #include <be/support/Errors.h>
  94. #endif
  95.  
  96. /*    OSError representing 'file not found' */
  97. #define OS_FNFERR        ENOENT
  98.  
  99. /*    OSError representing 'directory not found' */
  100. #define OS_DNFERR        ENOENT
  101.  
  102. /*    OSError representing 'file is a directory' */
  103. #define OS_FIDERR        EISDIR
  104.  
  105. /*    OSError representing 'file is not a directory' */
  106. #define OS_FNIDERR        ENOTDIR
  107.  
  108. /*    OSError representing 'filename too long' */
  109. #define OS_FNTLERR        ENAMETOOLONG
  110.  
  111. /*    OSError representing 'out of memory' */
  112. #define OS_MEMERR        ENOMEM
  113.  
  114. /*    OSError representing 'permission denied' */
  115. #define OS_PERMERR        EACCES
  116.  
  117. /*    OSError representing 'busy' (as for handles) */
  118. #define OS_BUSYERR        EBUSY
  119.  
  120. /*    A permissions mask [and mime type] */
  121. typedef    
  122. struct
  123. {
  124.     int        perm;
  125. #if defined(BEWORKS_FS)
  126.     char    mime[256];
  127. #endif    
  128. }                    OSFileType;        /*    way to identify a file's type */
  129.  
  130. extern                OSFileType OS_TEXTTYPE;            /* text file */
  131.  
  132. /*    Time */
  133. typedef
  134. time_t                OSTime;
  135.  
  136. /*
  137.     Libraries:  although QNX does not have 
  138.     run-time library support, we define the type to
  139.     allow stuff to compile.
  140.  */
  141. #if !defined(UNDER_BEWORKS)
  142.     /*    As used by dlopen() */
  143.     typedef
  144.     void *            OSLibrary;        /*    library handle */
  145. #else
  146.     /*    As used by load_add_on() */
  147.     typedef
  148.     long            OSLibrary;        /*    library handle */
  149. #endif
  150.