1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
/*
$Header: d:/cvsroot/tads/TADS2/LINF.H,v 1.3 1999/07/11 00:46:30 MJRoberts Exp $
*/
/*
* Copyright (c) 1991, 2002 Michael J. Roberts. All Rights Reserved.
*
* Please see the accompanying license file, LICENSE.TXT, for information
* on using and copying this software.
*/
/*
Name
linf.h - line source File
Function
Defines the file line source
Notes
The file line source reads lines from an OS file.
Modified
08/14/91 MJRoberts - creation
*/
#ifndef LINF_INCLUDED
#define LINF_INCLUDED
#include <stdio.h>
#ifndef STD_INCLUDED
#include "std.h"
#endif
#ifndef OS_INCLUDED
#include "os.h"
#endif
#ifndef LIN_INCLUDED
#include "lin.h"
#endif
#ifndef OBJ_INCLUDED
#include "obj.h"
#endif
#ifndef MCM_INCLUDED
#include "mcm.h"
#endif
#ifndef TOK_INCLUDED
#include "tok.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* maximum number of pages of debugging records we can keep */
#define LINFPGMAX 128
/*
* executable line information structure: this record relates one
* executable line to the object containing the p-code, and the offset
* in the object of the p-code for the start of the line
*/
struct linfinfo
{
/*
* OPCLINE data (file seek position or line number, depending on how
* the game was compiled: -ds -> file seek offset, -ds2 -> line
* number)
*/
ulong fpos;
/* object number */
objnum objn;
/* offset from start of code */
uint ofs;
};
/*
* file line source
*/
struct linfdef
{
lindef linflin; /* superclass data */
osfildef *linffp; /* file pointer for this line source */
char linfbuf[100]; /* buffer for the line contents */
int linfbufnxt; /* offset in buffer of start of next line */
int linfnxtlen; /* length of data after linfbufnxt */
ulong linfnum; /* current line number */
ulong linfseek; /* seek position of current line */
mcmcxdef *linfmem; /* memory manager context */
mcmon linfpg[LINFPGMAX]; /* pages for debugging records */
ulong linfcrec; /* number of debugger records written so far */
char linfnam[1]; /* name of file being read */
};
typedef struct linfdef linfdef;
/* initialize a file line source, opening the file for the line source */
linfdef *linfini(mcmcxdef *mctx, errcxdef *errctx, char *filename,
int flen, struct tokpdef *path, int must_find_file,
int new_line_records);
/* initialize a pre-allocated linfdef, skipping debugger page setup */
void linfini2(mcmcxdef *mctx, linfdef *linf,
char *filename, int flen, osfildef *fp, int new_line_records);
/* get next line from line source */
int linfget(lindef *lin);
/* generate printable rep of current position in source (for errors) */
void linfppos(lindef *lin, char *buf, uint bufl);
/* close line source */
void linfcls(lindef *lin);
/* generate source-line debug instruction operand */
void linfglop(lindef *lin, uchar *buf);
/* generate new-style source-line debug instructino operand */
void linfglop2(lindef *lin, uchar *buf);
/* save line source to binary (.gam) file */
int linfwrt(lindef *lin, osfildef *fp);
/* load a file-line-source from binary (.gam) file */
int linfload(osfildef *fp, struct dbgcxdef *dbgctx, errcxdef *ec,
struct tokpdef *path);
/* add a debugger line record for the current line */
void linfcmp(lindef *lin, uchar *buf);
/* find nearest line record to a file seek location */
void linffind(lindef *lin, char *buf, objnum *objp, uint *ofsp);
/* activate line source for debugging */
void linfact(lindef *lin);
/* disactivate line source */
void linfdis(lindef *lin);
/* get current seek position */
void linftell(lindef *lin, uchar *pos);
/* seek */
void linfseek(lindef *lin, uchar *pos);
/* read */
int linfread(lindef *lin, uchar *buf, uint siz);
/* add a signed delta to a seek positon */
void linfpadd(lindef *lin, uchar *pos, long delta);
/* query whether at top of file */
int linfqtop(lindef *lin, uchar *pos);
/* read one line at current seek position */
int linfgets(lindef *lin, uchar *buf, uint bufsiz);
/* get name of line source */
void linfnam(lindef *lin, char *buf);
/* get the current line number */
ulong linflnum(lindef *lin);
/* go to top or bottom */
void linfgoto(lindef *lin, int where);
/* return the current offset in the line source */
long linfofs(lindef *lin);
/* renumber an object */
void linfren(lindef *lin, objnum oldnum, objnum newnum);
/* delete an object */
void linfdelnum(lindef *lin, objnum objn);
/* copy line records to an array of linfinfo structures */
void linf_copy_linerecs(linfdef *linf, struct linfinfo *info);
/* debugging echo */
#ifdef DEBUG
# define LINFDEBUG(x) x
#else /* DEBUG */
# define LINFDEBUG(x)
#endif /* DEBUG */
#ifdef __cplusplus
}
#endif
#endif /* LINF_INCLUDED */
|