1 /* $Id: cfile.h,v 1.10 2003-10-04 02:58:23 btb Exp $ */
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.
17 * Prototypes for compressed file functions...
20 * Revision 1.1 1995/03/30 10:25:08 allender
24 * -- PC RCS Information ---
25 * Revision 1.10 1995/03/13 15:16:47 john
26 * Added alternate directory stuff.
28 * Revision 1.9 1995/02/01 20:56:40 john
29 * Added cfexist function
31 * Revision 1.8 1995/01/21 17:53:41 john
32 * Added alternate pig file thing.
34 * Revision 1.7 1994/12/12 13:19:47 john
35 * Made cfile work with fiellentth.
37 * Revision 1.6 1994/12/08 19:02:52 john
40 * Revision 1.5 1994/12/07 21:34:07 john
41 * Stripped out compression stuff...
43 * Revision 1.4 1994/07/13 00:16:53 matt
46 * Revision 1.3 1994/02/17 17:36:19 john
47 * Added CF_READ_MODE and CF_WRITE_MODE constants.
49 * Revision 1.2 1994/02/15 12:52:08 john
50 * Crappy inbetween version
52 * Revision 1.1 1994/02/15 10:54:23 john
55 * Revision 1.1 1994/02/10 15:50:54 john
69 typedef struct CFILE CFILE;
71 //Specify the name of the hogfile. Returns 1 if hogfile found & had files
72 int cfile_init(char *hogname);
74 int cfile_size(char *hogname);
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 );
85 int cfeof(CFILE *cfile);
86 int cferror(CFILE *cfile);
88 int cfexist( char * filename ); // Returns true if file exists on disk (1) or in hog (2).
91 int cfile_delete(char *filename);
94 int cfile_rename(char *oldname, char *newname);
97 int cfile_mkdir(char *pathname);
99 // cfwrite() writes to the file
100 int cfwrite(void *buf, int elsize, int nelem, CFILE *cfile);
102 // cfputc() writes a character to a file
103 int cfputc(int c, CFILE *cfile);
105 // cfputs() writes a string to a file
106 int cfputs(char *str, CFILE *cfile);
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 );
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);
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 );
124 //tell cfile about your critical error counter
125 void cfile_set_critical_error_counter_ptr(int *ptr);
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);
137 // Reads variable length, null-termined string. Will only read up
139 void cfile_read_string(char *buf, int n, CFILE *file);
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);
146 // writes variable length, null-termined string.
147 int cfile_write_string(char *buf, CFILE *file);