]> icculus.org git repositories - btb/d2x.git/blob - include/cfile.h
added console code (from SDL_console)
[btb/d2x.git] / include / cfile.h
1 /* $Id: cfile.h,v 1.8 2003-04-12 00:11:46 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Prototypes for compressed file functions...
18  *
19  * Old Log:
20  * Revision 1.1  1995/03/30  10:25:08  allender
21  * Initial revision
22  *
23  *
24  * -- PC RCS Information ---
25  * Revision 1.10  1995/03/13  15:16:47  john
26  * Added alternate directory stuff.
27  *
28  * Revision 1.9  1995/02/01  20:56:40  john
29  * Added cfexist function
30  *
31  * Revision 1.8  1995/01/21  17:53:41  john
32  * Added alternate pig file thing.
33  *
34  * Revision 1.7  1994/12/12  13:19:47  john
35  * Made cfile work with fiellentth.
36  *
37  * Revision 1.6  1994/12/08  19:02:52  john
38  * Added cfgets.
39  *
40  * Revision 1.5  1994/12/07  21:34:07  john
41  * Stripped out compression stuff...
42  *
43  * Revision 1.4  1994/07/13  00:16:53  matt
44  * Added include
45  *
46  * Revision 1.3  1994/02/17  17:36:19  john
47  * Added CF_READ_MODE and CF_WRITE_MODE constants.
48  *
49  * Revision 1.2  1994/02/15  12:52:08  john
50  * Crappy inbetween version
51  *
52  * Revision 1.1  1994/02/15  10:54:23  john
53  * Initial revision
54  *
55  * Revision 1.1  1994/02/10  15:50:54  john
56  * Initial revision
57  *
58  *
59  */
60
61 #ifndef _CFILE_H
62 #define _CFILE_H
63
64 #include <stdio.h>
65
66 #include "maths.h"
67 #include "vecmat.h"
68
69 typedef struct CFILE {
70         FILE                    *file;
71         int                             size;
72         int                             lib_offset;
73         int                             raw_position;
74 } CFILE;
75
76 //Specify the name of the hogfile.  Returns 1 if hogfile found & had files
77 int cfile_init(char *hogname);
78
79 int cfile_size(char *hogname);
80
81 CFILE * cfopen(char * filename, char * mode);
82 int cfilelength( CFILE *fp );                                                   // Returns actual size of file...
83 size_t cfread( void * buf, size_t elsize, size_t nelem, CFILE * fp );
84 void cfclose( CFILE * cfile );
85 int cfgetc( CFILE * fp );
86 int cfseek( CFILE *fp, long int offset, int where );
87 int cftell( CFILE * fp );
88 char * cfgets( char * buf, size_t n, CFILE * fp );
89
90 int cfexist( char * filename ); // Returns true if file exists on disk (1) or in hog (2).
91
92 // Allows files to be gotten from an alternate hog file.
93 // Passing NULL disables this.
94 // Returns 1 if hogfile found (& contains file), else 0.  
95 // If NULL passed, returns 1
96 int cfile_use_alternate_hogfile( char * name );
97
98 // Allows files to be gotten from the Descent 1 hog file.
99 // Passing NULL disables this.
100 // Returns 1 if hogfile found (& contains file), else 0.
101 // If NULL passed, returns 1
102 int cfile_use_descent1_hogfile(char * name);
103
104 // All cfile functions will check this directory if no file exists
105 // in the current directory.
106 void cfile_use_alternate_hogdir( char * path );
107
108 //tell cfile about your critical error counter 
109 void cfile_set_critical_error_counter_ptr(int *ptr);
110
111 // prototypes for reading basic types from cfile
112 int cfile_read_int(CFILE *file);
113 short cfile_read_short(CFILE *file);
114 byte cfile_read_byte(CFILE *file);
115 fix cfile_read_fix(CFILE *file);
116 fixang cfile_read_fixang(CFILE *file);
117 void cfile_read_vector(vms_vector *v, CFILE *file);
118 void cfile_read_angvec(vms_angvec *v, CFILE *file);
119 void cfile_read_matrix(vms_matrix *v, CFILE *file);
120
121 extern char AltHogDir[];
122 extern char AltHogdir_initialized;
123
124 #endif