Debian Codegraph @

terps/tads/tads2/fio.h

raw symbols SCIP
1 /*
2 $Header: d:/cvsroot/tads/TADS2/FIO.H,v 1.3 1999/07/11 00:46:29 MJRoberts Exp $
3 */
4
5 /*
6 * Copyright (c) 1992, 2002 Michael J. Roberts. All Rights Reserved.
7 *
8 * Please see the accompanying license file, LICENSE.TXT, for information
9 * on using and copying this software.
10 */
11 /*
12 Name
13 fio.h - file i/o interface
14 Function
15 fiel i/o functions - write game, read game, save game, restore game
16 Notes
17 none
18 Modified
19 04/02/92 MJRoberts - creation
20 */
21
22 #ifndef FIO_INCLUDED
23 #define FIO_INCLUDED
24
25 #ifndef MCM_INCLUDED
26 #include "mcm.h"
27 #endif
28 #ifndef OS_INCLUDED
29 #include "os.h"
30 #endif
31 #ifndef OBJ_INCLUDED
32 #include "obj.h"
33 #endif
34 #ifndef TOK_INCLUDED
35 #include "tok.h"
36 #endif
37
38 /* forward declarations */
39 struct voccxdef;
40
41
42 /* load-on-demand context (passed in by mcm in load callback) */
43 typedef struct fiolcxdef fiolcxdef;
44 struct fiolcxdef
45 {
46 osfildef *fiolcxfp; /* file pointer of load file */
47 errcxdef *fiolcxerr; /* error handling context */
48 ulong fiolcxst; /* starting offset in file */
49 uint fiolcxflg; /* flags from original load file */
50 uint fiolcxseed; /* fioxor seed */
51 uint fiolcxinc; /* fioxor increment */
52 };
53
54 /* write game to binary file */
55 void fiowrt(struct mcmcxdef *mctx, struct voccxdef *vctx,
56 struct tokcxdef *tokctx, struct tokthdef *tab,
57 uchar *fmts, uint fmtl, char *fname, uint flags, objnum preinit,
58 int extc, uint prpcnt, char *filever);
59
60 /* flag values for use with fiowrt */
61 #define FIOFSYM 0x01 /* include symbol table in output file */
62 #define FIOFLIN 0x02 /* include source file tracking information */
63 #define FIOFPRE 0x04 /* preinit needs to be run after reading game */
64 #define FIOFCRYPT 0x08 /* "encrypt" objects prior to writing them */
65 #define FIOFBIN 0x10 /* writing precompiled header */
66 #define FIOFFAST 0x20 /* fast-load records are in file */
67 #define FIOFCASE 0x40 /* case folding was turned on in original compile */
68 #define FIOFLIN2 0x80 /* new-style line records */
69
70 /* read game from binary file; sets up loader callback context */
71 void fiord(struct mcmcxdef *mctx, struct voccxdef *vctx,
72 struct tokcxdef *tctx,
73 char *fname, char *exename,
74 struct fiolcxdef *setupctx, objnum *preinit, uint *flagp,
75 struct tokpdef *path, uchar **fmtsp, uint *fmtlp,
76 uint *pcntptr, int flags, struct appctxdef *appctx,
77 char *argv0);
78
79 /* shut down load-on-demand subsystem, close load file */
80 void fiorcls(fiolcxdef *ctx);
81
82 /* loader callback - load an object on demand */
83 void OS_LOADDS fioldobj(void *ctx, mclhd handle, uchar *ptr,
84 ushort siz);
85
86 /*
87 * Save a game - returns TRUE on failure. We'll save the file to
88 * 'fname'. 'game_fname' is the name of the game file; if this is not
89 * null, we'll save it to the saved game file so that the player can
90 * later start the game by specifying only the saved game file to the
91 * run-time. 'game_fname' can be null, in which case we'll omit the
92 * game file information.
93 */
94 int fiosav(struct voccxdef *vctx, char *fname, char *game_fname);
95
96 /*
97 * fiorso() result codes
98 */
99 #define FIORSO_SUCCESS 0 /* success */
100 #define FIORSO_FILE_NOT_FOUND 1 /* file not found */
101 #define FIORSO_NOT_SAVE_FILE 2 /* not a saved game file */
102 #define FIORSO_BAD_FMT_VSN 3 /* incompatible file format version */
103 #define FIORSO_BAD_GAME_VSN 4 /* file saved by another game or version */
104 #define FIORSO_READ_ERROR 5 /* error reading from the file */
105 #define FIORSO_NO_PARAM_FILE 6 /* no parameter file (for restore(nil)) */
106
107
108 /* restore a game - returns TRUE on failure */
109 int fiorso(struct voccxdef *vctx, char *fname);
110
111 /*
112 * Look in a saved game file to determine if it has information on which
113 * GAM file created it. If the GAM file information is available, this
114 * routine returns true and stores the game file name in the given
115 * buffer; if the information isn't available, we'll return false.
116 */
117 int fiorso_getgame(char *saved_file, char *buf, size_t buflen);
118
119 /* encrypt/decrypt an object */
120 void fioxor(uchar *p, uint siz, uint seed, uint inc);
121
122
123 /* strings stored in binary game file for identification and validation */
124
125 /* file header string */
126 #define FIOFILHDR "TADS2 bin\012\015\032"
127
128 /* resource file header string */
129 #define FIOFILHDRRSC "TADS2 rsc\012\015\032"
130
131 /* CURRENT file format version string */
132 #define FIOVSNHDR "v2.2.0"
133
134 /* other file format versions that can be READ by this version */
135 #define FIOVSNHDR2 "v2.0.0"
136 #define FIOVSNHDR3 "v2.0.1"
137
138 #endif /* FIO_INCLUDED */
139