1 /* $Id: cfile.h,v 1.11 2004-08-28 23:17:45 schaffner 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...
29 typedef struct CFILE CFILE;
31 //Specify the name of the hogfile. Returns 1 if hogfile found & had files
32 int cfile_init(char *hogname);
34 int cfile_size(char *hogname);
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 );
45 int cfeof(CFILE *cfile);
46 int cferror(CFILE *cfile);
48 int cfexist( char * filename ); // Returns true if file exists on disk (1) or in hog (2).
51 int cfile_delete(char *filename);
54 int cfile_rename(char *oldname, char *newname);
57 int cfile_mkdir(char *pathname);
59 // cfwrite() writes to the file
60 int cfwrite(void *buf, int elsize, int nelem, CFILE *cfile);
62 // cfputc() writes a character to a file
63 int cfputc(int c, CFILE *cfile);
65 // cfputs() writes a string to a file
66 int cfputs(char *str, CFILE *cfile);
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 );
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);
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 );
84 //tell cfile about your critical error counter
85 void cfile_set_critical_error_counter_ptr(int *ptr);
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);
97 // Reads variable length, null-termined string. Will only read up
99 void cfile_read_string(char *buf, int n, CFILE *file);
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);
106 // writes variable length, null-termined string.
107 int cfile_write_string(char *buf, CFILE *file);