]> icculus.org git repositories - btb/d2x.git/blob - include/cfile.h
junk
[btb/d2x.git] / include / cfile.h
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-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 #ifndef _CFILE_H
15 #define _CFILE_H
16
17 #include <stdio.h>
18
19 #include "maths.h"
20 #include "vecmat.h"
21
22 typedef struct CFILE {
23         FILE                    *file;
24         int                             size;
25         int                             lib_offset;
26         int                             raw_position;
27 } CFILE;
28
29 //Specify the name of the hogfile.  Returns 1 if hogfile found & had files
30 int cfile_init(char *hogname);
31
32 CFILE * cfopen(char * filename, char * mode);
33 int cfilelength( CFILE *fp );                                                   // Returns actual size of file...
34 size_t cfread( void * buf, size_t elsize, size_t nelem, CFILE * fp );
35 void cfclose( CFILE * cfile );
36 int cfgetc( CFILE * fp );
37 int cfseek( CFILE *fp, long int offset, int where );
38 int cftell( CFILE * fp );
39 char * cfgets( char * buf, size_t n, CFILE * fp );
40
41 int cfexist( char * filename ); // Returns true if file exists on disk (1) or in hog (2).
42
43 // Allows files to be gotten from an alternate hog file.
44 // Passing NULL disables this.
45 // Returns 1 if hogfile found (& contains file), else 0.  
46 // If NULL passed, returns 1
47 int cfile_use_alternate_hogfile( char * name );
48
49 // All cfile functions will check this directory if no file exists
50 // in the current directory.
51 void cfile_use_alternate_hogdir( char * path );
52
53 //tell cfile about your critical error counter 
54 void cfile_set_critical_error_counter_ptr(int *ptr);
55
56 // prototypes for reading basic types from cfile
57 int cfile_read_int(CFILE *file);
58 short cfile_read_short(CFILE *file);
59 byte cfile_read_byte(CFILE *file);
60 fix cfile_read_fix(CFILE *file);
61 fixang cfile_read_fixang(CFILE *file);
62 void cfile_read_vector(vms_vector *v, CFILE *file);
63 void cfile_read_angvec(vms_angvec *v, CFILE *file);
64 void cfile_read_matrix(vms_matrix *v, CFILE *file);
65
66 extern char AltHogDir[];
67 extern char AltHogdir_initialized;
68
69 #endif