home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / h / hpack78s.zip / io / hpackio.h < prev   
C/C++ Source or Header  |  1992-11-24  |  5KB  |  164 lines

  1. /****************************************************************************
  2. *                                                                            *
  3. *                            HPACK Multi-System Archiver                        *
  4. *                            ===========================                        *
  5. *                                                                            *
  6. *                          HPACK I/O Routines Header File                    *
  7. *                            HPACKIO.H  Updated 30/06/92                        *
  8. *                                                                            *
  9. * This program is protected by copyright and as such any use or copying of    *
  10. *  this code for your own purposes directly or indirectly is highly uncool    *
  11. *                      and if you do so there will be....trubble.                *
  12. *                 And remember: We know where your kids go to school.            *
  13. *                                                                            *
  14. *        Copyright 1990 - 1992  Peter C.Gutmann.  All rights reserved        *
  15. *                                                                            *
  16. ****************************************************************************/
  17.  
  18. #ifndef _HPACKIO_DEFINED
  19.  
  20. #define _HPACKIO_DEFINED
  21.  
  22. /* The type of a FD */
  23.  
  24. #ifdef __MAC__
  25.   typedef short            FD;
  26. #else
  27.   typedef int            FD;
  28. #endif /* __MAC__ */
  29.  
  30. /* File I/O error return codes */
  31.  
  32. #define IO_ERROR        -1
  33.  
  34. /* File access mode */
  35.  
  36. #if !defined( __ATARI__ ) && !defined( __UNIX__ )
  37.   #ifdef __MAC__
  38.     #define O_RDONLY    1
  39.     #define O_WRONLY    2
  40.     #define O_RDWR        3
  41.   #else
  42.     #define O_RDONLY    0
  43.     #define O_WRONLY    1
  44.     #define O_RDWR        2
  45.   #endif /* __MAC__ */
  46. #endif /* !__UNIX__ */
  47.  
  48. /* Sharing mode - necessary when multiple users can access a file */
  49.  
  50. #if defined( __AMIGA__ ) || defined( __MSDOS__ ) || defined( __OS2__ )
  51.   #define S_DENYRDWR    ( 1 << 4 )
  52.   #define S_DENYWR        ( 2 << 4 )
  53.   #define S_DENYRD        ( 3 << 4 )
  54.   #define S_DENYNONE    ( 4 << 4 )
  55. #else
  56.   #define S_DENYRDWR    0
  57.   #define S_DENYWR        0
  58.   #define S_DENYRD        0
  59.   #define S_DENYNONE    0
  60. #endif /* __MSDOS__ || __OS2__ */
  61.  
  62. /* Access information for the file - extra information which may improve
  63.    handling under some OS's */
  64.  
  65. #ifdef __OS2__
  66.   #define A_SEQ            0x100
  67.   #define A_RAND        0x200
  68.   #define A_RANDSEQ        0x300
  69. #else
  70.   #define A_SEQ            0
  71.   #define A_RAND        0
  72.   #define A_RANDSEQ        0
  73. #endif /* __OS2__ */
  74.  
  75. /* Origin codes for hlseek() */
  76.  
  77. #define SEEK_SET    0
  78. #define SEEK_CUR    1
  79. #define SEEK_END    2
  80.  
  81. /* Standard streams */
  82.  
  83. #define STDIN        0
  84. #define STDOUT        1
  85. #define STDERR        2
  86. #define STDAUX        3
  87. #define STDPRN        4
  88.  
  89. #if !defined( __AMIGA__ ) && !defined( __ARC__ ) && !defined( __IIGS__ ) && \
  90.     !defined( __MAC__ ) && !defined( __MSDOS__ ) && !defined( __OS2__ )
  91.  
  92. #include <fcntl.h>
  93.  
  94. #ifdef __ATARI__
  95.   #include <io.h>            /* Prototypes for low-level I/O routines */
  96.   #include <direct.h>        /* Prototypes for directory-handling routines */
  97. #endif /* __ATARI__ */
  98.  
  99. /* Macros to turn the generic HPACKIO functions into their equivalent on
  100.    the current system */
  101.  
  102. #define hopen    open            /* Open existing file */
  103. #define hclose    close            /* Close file */
  104. #define hlseek    lseek            /* Seek to position in file */
  105. #define hread    read            /* Read data from a file */
  106. #define hwrite    write            /* Write data to a file */
  107. #define hrename    rename            /* Rename file */
  108.  
  109. /* HPACKIO functions which need special versions on some systems */
  110.  
  111. #ifdef __ATARI__
  112.   #define htruncate(theFD)    hwrite( theFD, NULL, 0 )
  113. #else
  114.   int htruncate( const FD theFD );/* Truncate a file at current position */
  115. #endif /* __ATARI__ */
  116.  
  117. #if defined( __UNIX__ ) || defined( __AMIGA__ )
  118.   int hcreat( const char *filePath, const int attr );
  119.   int hchmod( const char *filePath, const int attr );
  120. #else
  121.   #define hcreat    creat        /* Create a file */
  122.   #define hchmod    chmod        /* Change file attributes */
  123. #endif /* __UNIX__ || __AMIGA__ */
  124.  
  125. #if defined( __VMS__ )
  126.   #define htell(theFD)    hlseek( theFD, 0L, SEEK_CUR )
  127.   #define hunlink        delete
  128. #elif defined( __ATARI__ )
  129.   #define htell            tell    /* Return current position in file */
  130.   #define hunlink        remove    /* Delete file */
  131. #else
  132.   #define htell            tell    /* Return current position in file */
  133.   #define hunlink        unlink    /* Delete file */
  134. #endif /* __VMS__ */
  135.  
  136. #if defined( __UNIX__ ) || defined( __VMS__ )
  137.   int hmkdir( const char *dirName, const int attr );
  138. #elif defined( __ATARI__ )
  139.   #define hmkdir(dirName,attr)    mkdir( dirName )
  140. #else
  141.   #define hmkdir        mkdir    /* Create directory */
  142. #endif /* __UNIX__ || __VMS__ */
  143.  
  144. #else
  145.  
  146. /* Prototypes for functions in HPACKIO library */
  147.  
  148. FD hcreat( const char *fileName, const int attr );
  149. FD hopen( const char *fileName, const int mode );
  150. int hclose( const FD theFD );
  151. long hlseek( const FD theFD, const long position, const int whence );
  152. long htell( const FD theFD );
  153. int hread( const FD theFD, void *buffer, const unsigned int bufSize );
  154. int hwrite( const FD theFD, void *buffer, const unsigned int bufSize );
  155. int htruncate( const FD theFD );
  156. int hchmod( const char *fileName, const WORD attr );
  157. int hunlink( const char *fileName );
  158. int hmkdir( const char *dirName, const int attr );
  159. int hrename( const char *srcName, const char *destName );
  160.  
  161. #endif /* !( __AMIGA__ || __ARC__ || __IIGS__ || __MAC__ || __MSDOS__ || __OS2__ ) */
  162.  
  163. #endif /* !_HPACKIO_DEFINED */
  164.