]> icculus.org git repositories - btb/d2x.git/blob - include/cfile.h
use timer_delay instead of d_delay
[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 int cfile_size(char *hogname);
33
34 CFILE * cfopen(char * filename, char * mode);
35 int cfilelength( CFILE *fp );                                                   // Returns actual size of file...
36 size_t cfread( void * buf, size_t elsize, size_t nelem, CFILE * fp );
37 void cfclose( CFILE * cfile );
38 int cfgetc( CFILE * fp );
39 int cfseek( CFILE *fp, long int offset, int where );
40 int cftell( CFILE * fp );
41 char * cfgets( char * buf, size_t n, CFILE * fp );
42
43 int cfexist( char * filename ); // Returns true if file exists on disk (1) or in hog (2).
44
45 // Allows files to be gotten from an alternate hog file.
46 // Passing NULL disables this.
47 // Returns 1 if hogfile found (& contains file), else 0.  
48 // If NULL passed, returns 1
49 int cfile_use_alternate_hogfile( char * name );
50
51 // Allows files to be gotten from the Descent 1 hog file.
52 // Passing NULL disables this.
53 // Returns 1 if hogfile found (& contains file), else 0.
54 // If NULL passed, returns 1
55 int cfile_use_descent1_hogfile(char * name);
56
57 // All cfile functions will check this directory if no file exists
58 // in the current directory.
59 void cfile_use_alternate_hogdir( char * path );
60
61 //tell cfile about your critical error counter 
62 void cfile_set_critical_error_counter_ptr(int *ptr);
63
64 // prototypes for reading basic types from cfile
65 int cfile_read_int(CFILE *file);
66 short cfile_read_short(CFILE *file);
67 byte cfile_read_byte(CFILE *file);
68 fix cfile_read_fix(CFILE *file);
69 fixang cfile_read_fixang(CFILE *file);
70 void cfile_read_vector(vms_vector *v, CFILE *file);
71 void cfile_read_angvec(vms_angvec *v, CFILE *file);
72 void cfile_read_matrix(vms_matrix *v, CFILE *file);
73
74 extern char AltHogDir[];
75 extern char AltHogdir_initialized;
76
77 #endif