]> icculus.org git repositories - btb/d2x.git/blob - include/cfile.h
added debug info for illegal side type (d1x r1.2, r1.4, r1.2, r1.2)
[btb/d2x.git] / include / cfile.h
1 /* $Id: cfile.h,v 1.10 2003-10-04 02:58:23 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 CFILE;
70
71 //Specify the name of the hogfile.  Returns 1 if hogfile found & had files
72 int cfile_init(char *hogname);
73
74 int cfile_size(char *hogname);
75
76 CFILE * cfopen(char * filename, char * mode);
77 int cfilelength( CFILE *fp );                                                   // Returns actual size of file...
78 size_t cfread( void * buf, size_t elsize, size_t nelem, CFILE * fp );
79 int cfclose(CFILE *cfile);
80 int cfgetc( CFILE * fp );
81 int cfseek( CFILE *fp, long int offset, int where );
82 int cftell( CFILE * fp );
83 char * cfgets( char * buf, size_t n, CFILE * fp );
84
85 int cfeof(CFILE *cfile);
86 int cferror(CFILE *cfile);
87
88 int cfexist( char * filename ); // Returns true if file exists on disk (1) or in hog (2).
89
90 // Deletes a file.
91 int cfile_delete(char *filename);
92
93 // Rename a file.
94 int cfile_rename(char *oldname, char *newname);
95
96 // Make a directory
97 int cfile_mkdir(char *pathname);
98
99 // cfwrite() writes to the file
100 int cfwrite(void *buf, int elsize, int nelem, CFILE *cfile);
101
102 // cfputc() writes a character to a file
103 int cfputc(int c, CFILE *cfile);
104
105 // cfputs() writes a string to a file
106 int cfputs(char *str, CFILE *cfile);
107
108 // Allows files to be gotten from an alternate hog file.
109 // Passing NULL disables this.
110 // Returns 1 if hogfile found (& contains file), else 0.  
111 // If NULL passed, returns 1
112 int cfile_use_alternate_hogfile( char * name );
113
114 // Allows files to be gotten from the Descent 1 hog file.
115 // Passing NULL disables this.
116 // Returns 1 if hogfile found (& contains file), else 0.
117 // If NULL passed, returns 1
118 int cfile_use_descent1_hogfile(char * name);
119
120 // All cfile functions will check this directory if no file exists
121 // in the current directory.
122 void cfile_use_alternate_hogdir( char * path );
123
124 //tell cfile about your critical error counter 
125 void cfile_set_critical_error_counter_ptr(int *ptr);
126
127 // prototypes for reading basic types from cfile
128 int cfile_read_int(CFILE *file);
129 short cfile_read_short(CFILE *file);
130 sbyte cfile_read_byte(CFILE *file);
131 fix cfile_read_fix(CFILE *file);
132 fixang cfile_read_fixang(CFILE *file);
133 void cfile_read_vector(vms_vector *v, CFILE *file);
134 void cfile_read_angvec(vms_angvec *v, CFILE *file);
135 void cfile_read_matrix(vms_matrix *v, CFILE *file);
136
137 // Reads variable length, null-termined string.   Will only read up
138 // to n characters.
139 void cfile_read_string(char *buf, int n, CFILE *file);
140
141 // functions for writing cfiles
142 int cfile_write_int(int i, CFILE *file);
143 int cfile_write_short(short s, CFILE *file);
144 int cfile_write_byte(sbyte u, CFILE *file);
145
146 // writes variable length, null-termined string.
147 int cfile_write_string(char *buf, CFILE *file);
148
149 #endif