CFLIB.H 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. PSLIB is a system for librarying files. We can combine data
  75. files into one library, saving disk space and simplifying
  76. distribution of demos, etc.
  77. The system consists of two parts, a program to create libraries
  78. and a routine to read from the libraries.
  79. The old way:
  80. -----------
  81. In order to extract the file from the library, the extract function is
  82. called. The format is as follows:
  83. extract ( <name of library to extract files from>,
  84. <filename to extract>,
  85. <buffer to extract to> );
  86. The improved and current method:
  87. -------------------------------
  88. In order to extract a file from the library, we first initialize
  89. our library file with lib_init(filename);
  90. This opens our library file, verifies that it is a PSLB file,
  91. and reads the headers into a global array.
  92. LibReadFile() reads the desired filename from the library and returns
  93. the data in a buffer. This is identical in format to the
  94. function ReadFile() in readfile.h.
  95. Once the library is opened, we can call LibReadFile() multiple
  96. times.
  97. After all the data files desired are read lib_close() is called
  98. to close our library file.
  99. */
  100. #ifndef _CFLIB_H
  101. #define _CFLIB_H
  102. #include "types.h"
  103. //#include "readfile.h" //get prototypes
  104. // error codes for lib_init()
  105. #define LI_NO_ERROR 0 //opened just fine
  106. #define LI_NOT_PSLIB 1 //the file isn't one of our libraries
  107. #define LI_NO_FILE 2 //can't find requested file
  108. #define LI_NO_MEM 3 //couldn't allocate memory for file index
  109. int lib_init( char *lib_name );
  110. void lib_close();
  111. ubyte *ReadFile( char *filename, int *length );
  112. int ReadFileBuf( char *filename, byte *buf, int bufsize );
  113. // ReadFileBuf reads bufize bytes of 'filename' into the address of 'buf'
  114. // returns an error code < 0 if there is an error.
  115. ubyte *extract( char *library, char *filename );
  116. // lzw function prototypes
  117. ubyte *lzw_expand( ubyte *inputbuf, ubyte *outputbuf, int length );
  118. // lzw_expand can be called in one of two ways :
  119. // 1) If the address of a buffer is passed to outputbuf, then the expanded
  120. // data of the input is passed thru outputbuf.
  121. // 2) Otherwise, if NULL is passed to outputbuf, then a buffer is malloc'd and
  122. // returned.
  123. ubyte *lzw_compress( ubyte *inputbuf, ubyte *outputbuf, int input_size, int *output_size );
  124. // lzw_compress can be called in one of two ways :
  125. // 1) If the address of a buffer is passed to outputbuf, then the compressed
  126. // data of the input is passed thru outputbuf.
  127. // 2) Otherwise, if NULL is passed to outputbuf, then a buffer is malloc'd and
  128. // returned.
  129. ubyte *cfreadfile( char *filename, int *size );
  130. // cfreadfile reads a "cfwrite" file and returns the lzw expanded buffer.
  131. int cfwritefile( char *filename, ubyte *buffer, int length );
  132. // cfwrite takes a buffer 'buffer', lzw compresses it, and writes it to a "cfwrite" file.
  133. int WriteFile( char *filename, void *data, int length );
  134. // WriteFile writes 'length' bytes of 'data' to 'filename'
  135. // returns an error code != 0 if there is an error.
  136. int AppendFile( char *filename, void *data, int length );
  137. // AppendFile appends 'length' bytes of 'data' to 'filename'
  138. // returns an error code != 0 if there is an error.
  139. int CheckFile( char *filename );
  140. // Returns status of a file
  141. // 0 - not found.
  142. // 1 - In local directory.
  143. // 2 - In opened library file
  144. #endif
  145.