]> icculus.org git repositories - btb/d2x.git/blob - include/cfile.h
move old per-file change logs into new file ChangeLog-old
[btb/d2x.git] / include / cfile.h
1 /* $Id: cfile.h,v 1.11 2004-08-28 23:17:45 schaffner 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  */
20
21 #ifndef _CFILE_H
22 #define _CFILE_H
23
24 #include <stdio.h>
25
26 #include "maths.h"
27 #include "vecmat.h"
28
29 typedef struct CFILE CFILE;
30
31 //Specify the name of the hogfile.  Returns 1 if hogfile found & had files
32 int cfile_init(char *hogname);
33
34 int cfile_size(char *hogname);
35
36 CFILE * cfopen(char * filename, char * mode);
37 int cfilelength( CFILE *fp );                                                   // Returns actual size of file...
38 size_t cfread( void * buf, size_t elsize, size_t nelem, CFILE * fp );
39 int cfclose(CFILE *cfile);
40 int cfgetc( CFILE * fp );
41 int cfseek( CFILE *fp, long int offset, int where );
42 int cftell( CFILE * fp );
43 char * cfgets( char * buf, size_t n, CFILE * fp );
44
45 int cfeof(CFILE *cfile);
46 int cferror(CFILE *cfile);
47
48 int cfexist( char * filename ); // Returns true if file exists on disk (1) or in hog (2).
49
50 // Deletes a file.
51 int cfile_delete(char *filename);
52
53 // Rename a file.
54 int cfile_rename(char *oldname, char *newname);
55
56 // Make a directory
57 int cfile_mkdir(char *pathname);
58
59 // cfwrite() writes to the file
60 int cfwrite(void *buf, int elsize, int nelem, CFILE *cfile);
61
62 // cfputc() writes a character to a file
63 int cfputc(int c, CFILE *cfile);
64
65 // cfputs() writes a string to a file
66 int cfputs(char *str, CFILE *cfile);
67
68 // Allows files to be gotten from an alternate hog file.
69 // Passing NULL disables this.
70 // Returns 1 if hogfile found (& contains file), else 0.  
71 // If NULL passed, returns 1
72 int cfile_use_alternate_hogfile( char * name );
73
74 // Allows files to be gotten from the Descent 1 hog file.
75 // Passing NULL disables this.
76 // Returns 1 if hogfile found (& contains file), else 0.
77 // If NULL passed, returns 1
78 int cfile_use_descent1_hogfile(char * name);
79
80 // All cfile functions will check this directory if no file exists
81 // in the current directory.
82 void cfile_use_alternate_hogdir( char * path );
83
84 //tell cfile about your critical error counter 
85 void cfile_set_critical_error_counter_ptr(int *ptr);
86
87 // prototypes for reading basic types from cfile
88 int cfile_read_int(CFILE *file);
89 short cfile_read_short(CFILE *file);
90 sbyte cfile_read_byte(CFILE *file);
91 fix cfile_read_fix(CFILE *file);
92 fixang cfile_read_fixang(CFILE *file);
93 void cfile_read_vector(vms_vector *v, CFILE *file);
94 void cfile_read_angvec(vms_angvec *v, CFILE *file);
95 void cfile_read_matrix(vms_matrix *v, CFILE *file);
96
97 // Reads variable length, null-termined string.   Will only read up
98 // to n characters.
99 void cfile_read_string(char *buf, int n, CFILE *file);
100
101 // functions for writing cfiles
102 int cfile_write_int(int i, CFILE *file);
103 int cfile_write_short(short s, CFILE *file);
104 int cfile_write_byte(sbyte u, CFILE *file);
105
106 // writes variable length, null-termined string.
107 int cfile_write_string(char *buf, CFILE *file);
108
109 #endif