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 / fastio.h < prev    next >
C/C++ Source or Header  |  1992-11-17  |  6KB  |  170 lines

  1. /****************************************************************************
  2. *                                                                            *
  3. *                            HPACK Multi-System Archiver                        *
  4. *                            ===========================                        *
  5. *                                                                            *
  6. *                         Header File for Fast I/O Routines                    *
  7. *                            FASTIO.H  Updated 08/12/91                        *
  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, 1991  Peter C.Gutmann.  All rights reserved            *
  15. *                                                                            *
  16. ****************************************************************************/
  17.  
  18. #ifndef _FASTIO_DEFINED
  19.  
  20. #define _FASTIO_DEFINED
  21.  
  22. #ifdef __MAC__
  23.   #include "hpackio.h"
  24. #else
  25.   #include "io/hpackio.h"
  26. #endif /* __MAC__ */
  27.  
  28. /* The size of the I/O buffers */
  29.  
  30. #if defined( __MSDOS__ ) || defined( __IIGS__ )
  31.   #define _BUFSIZE    8192
  32. #else
  33.   #define _BUFSIZE    16384
  34. #endif /* __MSDOS__ || __IIGS__ */
  35.  
  36. /* The size of the directory info buffer */
  37.  
  38. #define DIRBUFSIZE    ( _BUFSIZE / 2 )
  39.  
  40. /* The EOF value */
  41.  
  42. #define FEOF        -1
  43.  
  44. /* Symbolic defines for the checksumming of input data */
  45.  
  46. #define RESET_CHECKSUM        TRUE
  47. #define NO_RESET_CHECKSUM    FALSE
  48.  
  49. /* The format of the message to display while waiting for the luser to
  50.    continue when handling a multipart archive */
  51.  
  52. #define WAIT_PARTNO        0x01    /* Print archive part number */
  53. #define WAIT_NEXTDISK    0x02    /* Ask for next disk */
  54. #define WAIT_PREVDISK    0x04    /* Ask for previous disk */
  55. #define WAIT_LASTPART    0x08    /* Ask for last disk */
  56.  
  57. /* The output intercept type:  Normally data to be output is just written to
  58.    a FD, however it can be intercepted in the vwrite() routine and
  59.    redirected/reformatted/etc.  Possible types of redirection are no output,
  60.    raw data output (default) and formatted text output */
  61.  
  62. typedef enum { OUT_NONE, OUT_DATA, OUT_FMT_TEXT } OUTINTERCEPT_TYPE;
  63.  
  64. /* The write type:  Standard mode, atomic write, safe write with trailer
  65.    padding for multipart archives */
  66.  
  67. typedef enum { STD_WRITE, ATOMIC_WRITE, SAFE_WRITE } WRITE_TYPE;
  68.  
  69. /* Some global vars declared in FASTIO.C */
  70.  
  71. extern FD _inFD, _outFD;                /* I/O file descriptors */
  72. extern BYTE *_inBuffer, *_outBuffer;    /* The I/O buffers */
  73. extern int _inByteCount, _outByteCount;    /* Current position in buffer */
  74. extern int _inBytesRead;                /* Actual no.bytes read */
  75.  
  76. /* Macros used to associate the input/output streams with FD's */
  77.  
  78. #define setOutputFD(theFD)    _outFD = theFD
  79. #define setInputFD(theFD)    _inFD = theFD
  80. #define getOutputFD()        _outFD
  81. #define getInputFD()        _inFD
  82.  
  83. /* Vars used to handle the general-purpose buffer */
  84.  
  85. extern BYTE *mrglBuffer, *dirBuffer;
  86. extern int mrglBufCount, dirBufCount;
  87.  
  88. /* Flag used to indicate status of the atomic write necessary at the end of
  89.    a multipart archive */
  90.  
  91. extern BOOLEAN atomicWriteOK;
  92.  
  93. /* Prototypes for the fast I/O functions themselves */
  94.  
  95. void initFastIO( void );
  96. void endFastIO( void );
  97. void resetFastIn( void );
  98. void resetFastOut( void );
  99. void saveInputState( void );
  100. void restoreInputState( void );
  101. void saveOutputState( void );
  102. void restoreOutputState( void );
  103. inline void initTranslationSystem( const BYTE lineEndChar );
  104. void checksumBegin( const BOOLEAN resetChecksum );
  105. void checksumEnd( void );
  106. void checksumDirBegin( const BOOLEAN resetChecksum );
  107. void checksumDirEnd( void );
  108. void checksumSetInput( const long dataLength, const BOOLEAN resetChecksum );
  109. int cryptBegin( const BOOLEAN isMainKey );
  110. void cryptEnd( void );
  111. BOOLEAN cryptSetInput( long dataLength, int *cryptInfoLength );
  112. void preemptCryptChecksum( const long length );
  113. long getCurrPosition( void );
  114. void setCurrPosition( const long position );
  115. void setWriteType( const WRITE_TYPE writeType );
  116. int vread( BYTE *buffer, int count );
  117. long vlseek( const long offset, const int whence );
  118. long vtell( void );
  119. void skipSeek( LONG skipDist );
  120. void skipToData( void );
  121. void writeBuffer( const int bufSize );
  122. void writeMrglBuffer( const int bufSize );
  123. void writeDirBuffer( const int bufSize );
  124. void flushBuffer( void );
  125. void flushMrglBuffer( void );
  126. void flushDirBuffer( void );
  127. void setOutputIntercept( OUTINTERCEPT_TYPE interceptType );
  128. void resetOutputIntercept( void );
  129. void multipartWait( const WORD promptType, const int partNo );
  130.  
  131. /* Function versions of the original put/get byte/word/long macros.  These
  132.    are used instead of macro's since the macros tended to produce a huge
  133.    amount of code due to macro expansion.  Following common usage they are
  134.    referred to by the macro names with a prepended 'f' */
  135.  
  136. void fputByte( const BYTE data );
  137. void fputWord( const WORD data );
  138. void fputLong( const LONG data );
  139. int fgetByte( void );
  140. WORD fgetWord( void );
  141. LONG fgetLong( void );
  142.  
  143. /* The corresponding routines for directory data.  We don't need to give a
  144.    file descriptor since we always use the same directory file */
  145.  
  146. void fputDirByte( const BYTE data );
  147. void fputDirWord( const WORD data );
  148. void fputDirLong( const LONG data );
  149.  
  150. /* The memory equivalents for the above functions - get/put a WORD or LONG
  151.    from/to a section of memory */
  152.  
  153. WORD mgetWord( BYTE *memPtr );
  154. LONG mgetLong( BYTE *memPtr );
  155. void mputWord( BYTE *memPtr, const WORD data );
  156. void mputLong( BYTE *memPtr, const LONG data );
  157.  
  158. /* The following works because we only ever do a read when we have no more
  159.    chars available.  Thus when we read the last char in the buffer we don't
  160.    read in more until we need the next char after that, so that _inByteCount
  161.    is never set to 0 which would cause problems */
  162.  
  163. #define ungetByte()        _inByteCount--
  164.  
  165. /* Macro to force a read on the next fgetByte() */
  166.  
  167. #define forceRead()        _inByteCount = _inBytesRead = _BUFSIZE
  168.  
  169. #endif /* !_FASTIO_DEFINED */
  170.