home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / pslib / cflib.h < prev    next >
Text File  |  1998-06-08  |  6KB  |  179 lines

  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * $Source: f:/miner/source/pslib/rcs/cflib.h $
  15.  * $Revision: 1.13 $
  16.  * $Author: john $
  17.  * $Date: 1994/02/15 12:53:06 $
  18.  *
  19.  * Sample setup for RCS header
  20.  *
  21.  * $Log: cflib.h $
  22.  * Revision 1.13  1994/02/15  12:53:06  john
  23.  * Made numfiles stored in library be a short instead of char.
  24.  * 
  25.  * Revision 1.12  1993/12/08  17:06:34  yuan
  26.  * Added CheckFile.
  27.  * 
  28.  * Revision 1.11  1993/10/28  15:16:54  yuan
  29.  * Added WriteFile and AppendFile prototypes.
  30.  * 
  31.  * Revision 1.10  1993/10/28  14:41:13  yuan
  32.  * New cfread functions added to cflib.
  33.  * 
  34.  * Revision 1.9  1993/10/27  12:41:58  yuan
  35.  * Added prototype for ReadFileBuf.
  36.  * 
  37.  * Revision 1.8  1993/10/19  12:39:13  matt
  38.  * Added '#ifndef' around body of file
  39.  * Added new error codes
  40.  * Included readfile.h
  41.  * 
  42.  * Revision 1.7  1993/09/29  17:53:38  yuan
  43.  * lzw_compression and lzw_expand documented more clearly (hopefully)
  44.  * some error flags added.
  45.  * 
  46.  * Revision 1.6  1993/09/27  17:12:21  yuan
  47.  * Documentation for using lib_init(), lib_close(), and LibReadFile() added.
  48.  * 
  49.  * Revision 1.5  1993/09/21  17:22:22  yuan
  50.  * *** empty log message ***
  51.  * 
  52.  * Revision 1.4  1993/09/21  17:16:56  yuan
  53.  * cleaning up
  54.  * 
  55.  * Revision 1.3  1993/09/21  17:07:01  yuan
  56.  * broken and unbroken
  57.  * 
  58.  * Revision 1.2  1993/09/20  12:26:25  yuan
  59.  * ReadFile, WriteFile, AppendFile removed to readfile.h
  60.  * 
  61.  * Revision 1.1  1993/09/14  13:15:30  yuan
  62.  * Initial revision
  63.  * 
  64.  * Revision 1.3  1993/09/09  15:41:22  yuan
  65.  * pslib.exe docs removed.
  66.  * 
  67.  * Revision 1.2  1993/09/09  12:40:03  yuan
  68.  * compression routine prototypes from library.h added.
  69.  * 
  70.  * Revision 1.1  1993/09/08  16:16:57  yuan
  71.  * Initial revision
  72.  * 
  73.  *
  74.  
  75.         PSLIB is a system for librarying files.  We can combine data
  76.         files into one library, saving disk space and simplifying
  77.         distribution of demos, etc.
  78.  
  79.         The system consists of two parts, a program to create libraries
  80.         and a routine to read from the libraries.
  81.  
  82.  
  83.         The old way:
  84.         -----------
  85.  
  86.         In order to extract the file from the library, the extract function is
  87.         called.  The format is as follows:
  88.  
  89.         extract ( <name of library to extract files from>,
  90.                   <filename to extract>,
  91.                   <buffer to extract to> );
  92.  
  93.         The improved and current method:
  94.         -------------------------------
  95.  
  96.         In order to extract a file from the library, we first initialize
  97.         our library file with lib_init(filename);
  98.  
  99.         This opens our library file, verifies that it is a PSLB file,
  100.         and reads the headers into a global array.
  101.  
  102.         LibReadFile() reads the desired filename from the library and returns
  103.         the data in a buffer.  This is identical in format to the
  104.         function ReadFile() in readfile.h.
  105.  
  106.         Once the library is opened, we can call LibReadFile() multiple
  107.         times.
  108.  
  109.         After all the data files desired are read lib_close() is called
  110.         to close our library file.
  111.  
  112. */
  113.  
  114. #ifndef _CFLIB_H
  115. #define _CFLIB_H
  116.  
  117. #include "types.h"
  118.  
  119. //#include "readfile.h"   //get prototypes
  120.  
  121. // error codes for lib_init()
  122.  
  123. #define LI_NO_ERROR        0        //opened just fine
  124. #define LI_NOT_PSLIB        1        //the file isn't one of our libraries
  125. #define LI_NO_FILE        2        //can't find requested file
  126. #define LI_NO_MEM            3        //couldn't allocate memory for file index
  127.  
  128. int lib_init( char *lib_name );
  129.  
  130. void lib_close();
  131.  
  132. ubyte *ReadFile( char *filename, int *length );
  133.  
  134. int ReadFileBuf( char *filename, byte *buf, int bufsize );
  135. // ReadFileBuf reads bufize bytes of 'filename' into the address of 'buf'
  136. //  returns an error code < 0 if there is an error.
  137.  
  138. ubyte *extract( char *library, char *filename );
  139.  
  140. // lzw function prototypes
  141.  
  142. ubyte *lzw_expand( ubyte *inputbuf, ubyte *outputbuf, int length );
  143. // lzw_expand can be called in one of two ways :
  144. // 1) If the address of a buffer is passed to outputbuf, then the expanded
  145. //      data of the input is passed thru outputbuf.
  146. // 2) Otherwise, if NULL is passed to outputbuf, then a buffer is malloc'd and
  147. //      returned.
  148.  
  149. ubyte *lzw_compress( ubyte *inputbuf, ubyte *outputbuf, int input_size, int *output_size );
  150. // lzw_compress can be called in one of two ways :
  151. // 1) If the address of a buffer is passed to outputbuf, then the compressed
  152. //      data of the input is passed thru outputbuf.
  153. // 2) Otherwise, if NULL is passed to outputbuf, then a buffer is malloc'd and
  154. //      returned.
  155.  
  156. ubyte *cfreadfile( char *filename, int *size );
  157. // cfreadfile reads a "cfwrite" file and returns the lzw expanded buffer.
  158.  
  159. int cfwritefile( char *filename, ubyte *buffer, int length );
  160. // cfwrite takes a buffer 'buffer', lzw compresses it, and writes it to a "cfwrite" file.
  161.  
  162. int WriteFile( char *filename, void *data, int length );
  163. // WriteFile writes 'length' bytes of 'data' to 'filename'
  164. //  returns an error code != 0 if there is an error.
  165.  
  166. int AppendFile( char *filename, void *data, int length );
  167. // AppendFile appends 'length' bytes of 'data' to 'filename'
  168. //  returns an error code != 0 if there is an error.
  169.  
  170. int CheckFile( char *filename );
  171. // Returns status of a file
  172. //        0 - not found.
  173. //        1 - In local directory.
  174. //        2 - In opened library file
  175.  
  176. #endif
  177.  
  178. 
  179.