cfad47cfa3/tads2/bif.h

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
/*
2
$Header: d:/cvsroot/tads/TADS2/BIF.H,v 1.3 1999/07/11 00:46:29 MJRoberts Exp $
3
*/
4
5
/* 
6
 *   Copyright (c) 1991, 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
  bif.h - built-in functions interface
14
Function
15
  interface to run-time intrinsic function implementation
16
Notes
17
  None
18
Modified
19
  12/16/92 MJRoberts     - add TADS/Graphic functions
20
  12/26/91 MJRoberts     - creation
21
*/
22
23
#ifndef BIF_INCLUDED
24
#define BIF_INCLUDED
25
26
#ifndef OS_INCLUDED
27
# include "os.h"
28
#endif
29
#ifndef ERR_INCLUDED
30
# include "err.h"
31
#endif
32
#ifndef RUN_INCLUDED
33
# include "run.h"
34
#endif
35
#ifndef TIO_INCLUDED
36
# include "tio.h"
37
#endif
38
#ifndef REGEX_H
39
#include "regex.h"
40
#endif
41
42
#ifdef __cplusplus
43
extern "C" {
44
#endif
45
46
/* forward definitions */
47
struct vocidef;
48
struct voccxdef;
49
50
/* maximum number of file handles available */
51
#define BIFFILMAX  10
52
53
54
/* file contexts for the built-in file handling functions */
55
struct biffildef
56
{
57
    osfildef *fp;                          /* underyling system file handle */
58
    uint      flags;                                               /* flags */
59
#define BIFFIL_F_BINARY    0x01                           /* file is binary */
60
};
61
typedef struct biffildef biffildef;
62
63
/* built-in execution context */
64
struct bifcxdef
65
{
66
    errcxdef *bifcxerr;                           /* error-handling context */
67
    runcxdef *bifcxrun;                           /* code execution context */
68
    tiocxdef *bifcxtio;                                 /* text I/O context */
69
    long      bifcxrnd;                               /* random number seed */
70
    int       bifcxseed1;                   /* first seed for new generator */
71
    int       bifcxseed2;                  /* second seed for new generator */
72
    int       bifcxseed3;                   /* third seed for new generator */
73
    int       bifcxrndset;                   /* randomize() has been called */
74
    biffildef bifcxfile[BIFFILMAX];          /* file handles for fopen, etc */
75
    uint      bifcxsafety;                         /* file I/O safety level */
76
    char     *bifcxsavext;        /* saved game extension (null by default) */
77
    struct appctxdef *bifcxappctx;              /* host application context */
78
    re_context bifcxregex;          /* regular expression searching context */
79
};
80
typedef struct bifcxdef bifcxdef;
81
82
/*
83
 *   argument list checking routines - can be disabled for faster
84
 *   run-time 
85
 */
86
87
/* check for proper number of arguments */
88
/* void bifcntargs(bifcxdef *ctx, int argcnt) */
89
90
/* check that next argument has proper type */
91
/* void bifchkarg(bifcxdef *ctx, dattyp typ); */
92
93
#ifdef RUNFAST
94
# define bifcntargs(ctx, parmcnt, argcnt)
95
# define bifchkarg(ctx, typ)
96
#else /* RUNFAST */
97
# define bifcntargs(ctx, parmcnt, argcnt) \
98
  (parmcnt == argcnt ? DISCARD 0 : \
99
   (runsig(ctx->bifcxrun, ERR_BIFARGC), DISCARD 0))
100
# define bifchkarg(ctx, typ) \
101
  (runtostyp(ctx->bifcxrun) == typ ? DISCARD 0 : \
102
   (runsig(ctx->bifcxrun, ERR_INVTBIF), DISCARD 0))
103
#endif /* RUNFAST */
104
105
/* determine if one object is a subclass of another */
106
int bifinh(struct voccxdef *voc, struct vocidef *v, objnum cls);
107
108
109
/* enumerate the built-in functions */
110
void bifyon(bifcxdef *ctx, int argc);                   /* yorn - yes or no */
111
void bifsfs(bifcxdef *ctx, int argc);                            /* setfuse */
112
void bifrfs(bifcxdef *ctx, int argc);                            /* remfuse */
113
void bifsdm(bifcxdef *ctx, int argc);                          /* setdaemon */
114
void bifrdm(bifcxdef *ctx, int argc);                          /* remdaemon */
115
void bifinc(bifcxdef *ctx, int argc);                            /* incturn */
116
void bifqui(bifcxdef *ctx, int argc);                               /* quit */
117
void bifsav(bifcxdef *ctx, int argc);                               /* save */
118
void bifrso(bifcxdef *ctx, int argc);                            /* restore */
119
void biflog(bifcxdef *ctx, int argc);                            /* logging */
120
void bifres(bifcxdef *ctx, int argc);                            /* restart */
121
void bifinp(bifcxdef *ctx, int argc);           /* input - get line from kb */
122
void bifnfy(bifcxdef *ctx, int argc);                             /* notify */
123
void bifunn(bifcxdef *ctx, int argc);                           /* unnotify */
124
void biftrc(bifcxdef *ctx, int argc);                       /* trace on/off */
125
void bifsay(bifcxdef *ctx, int argc);                                /* say */
126
void bifcar(bifcxdef *ctx, int argc);                                /* car */
127
void bifcdr(bifcxdef *ctx, int argc);                                /* cdr */
128
void bifcap(bifcxdef *ctx, int argc);                               /* caps */
129
void biflen(bifcxdef *ctx, int argc);                             /* length */
130
void biffnd(bifcxdef *ctx, int argc);                               /* find */
131
void bifsit(bifcxdef *ctx, int argc);           /* setit - set current 'it' */
132
void bifsrn(bifcxdef *ctx, int argc);               /* randomize: seed rand */
133
void bifrnd(bifcxdef *ctx, int argc);         /* rand - get a random number */
134
void bifask(bifcxdef *ctx, int argc);                            /* askfile */
135
void bifssc(bifcxdef *ctx, int argc);                           /* setscore */
136
void bifsub(bifcxdef *ctx, int argc);                             /* substr */
137
void bifcvs(bifcxdef *ctx, int argc);          /* cvtstr: convert to string */
138
void bifcvn(bifcxdef *ctx, int argc);          /* cvtnum: convert to number */
139
void bifupr(bifcxdef *ctx, int argc);                              /* upper */
140
void biflwr(bifcxdef *ctx, int argc);                              /* lower */
141
void biffob(bifcxdef *ctx, int argc);                           /* firstobj */
142
void bifnob(bifcxdef *ctx, int argc);                            /* nextobj */
143
void bifsvn(bifcxdef *ctx, int argc);                         /* setversion */
144
void bifarg(bifcxdef *ctx, int argc);                             /* getarg */
145
void biftyp(bifcxdef *ctx, int argc);                           /* datatype */
146
void bifisc(bifcxdef *ctx, int argc);                            /* isclass */
147
void bifund(bifcxdef *ctx, int argc);                               /* undo */
148
void bifdef(bifcxdef *ctx, int argc);                            /* defined */
149
void bifpty(bifcxdef *ctx, int argc);                           /* proptype */
150
void bifoph(bifcxdef *ctx, int argc);                            /* outhide */
151
void bifgfu(bifcxdef *ctx, int argc);                            /* getfuse */
152
void bifruf(bifcxdef *ctx, int argc);                           /* runfuses */
153
void bifrud(bifcxdef *ctx, int argc);                         /* rundaemons */
154
void biftim(bifcxdef *ctx, int argc);                            /* gettime */
155
void bifsct(bifcxdef *ctx, int argc);                          /* intersect */
156
void bifink(bifcxdef *ctx, int argc);                           /* inputkey */
157
void bifwrd(bifcxdef *ctx, int argc);                           /* objwords */
158
void bifadw(bifcxdef *ctx, int argc);                            /* addword */
159
void bifdlw(bifcxdef *ctx, int argc);                            /* delword */
160
void bifgtw(bifcxdef *ctx, int argc);                           /* getwords */
161
void bifnoc(bifcxdef *ctx, int argc);                             /* nocaps */
162
void bifskt(bifcxdef *ctx, int argc);                           /* skipturn */
163
void bifcls(bifcxdef *ctx, int argc);                        /* clearscreen */
164
void bif1sc(bifcxdef *ctx, int argc);                            /* firstsc */
165
void bifvin(bifcxdef *ctx, int argc);                           /* verbinfo */
166
void bifcapture(bifcxdef *ctx, int argc);                     /* outcapture */
167
168
void biffopen(bifcxdef *ctx, int argc);                            /* fopen */
169
void biffclose(bifcxdef *ctx, int argc);                          /* fclose */
170
void biffwrite(bifcxdef *ctx, int argc);                          /* fwrite */
171
void biffread(bifcxdef *ctx, int argc);                            /* fread */
172
void biffseek(bifcxdef *ctx, int argc);                            /* fseek */
173
void biffseekeof(bifcxdef *ctx, int argc);                      /* fseekeof */
174
void bifftell(bifcxdef *ctx, int argc);                            /* ftell */
175
176
void bifsysinfo(bifcxdef *ctx, int argc);                     /* systemInfo */
177
void bifmore(bifcxdef *ctx, int argc);                        /* morePrompt */
178
void bifsetme(bifcxdef *ctx, int argc);                      /* parserSetMe */
179
void bifgetme(bifcxdef *ctx, int argc);                      /* parserGetMe */
180
181
void bifresearch(bifcxdef *ctx, int argc);                      /* reSearch */
182
void bifregroup(bifcxdef *ctx, int argc);                     /* reGetGroup */
183
184
void bifinpevt(bifcxdef *ctx, int argc);                      /* inputevent */
185
void bifdelay(bifcxdef *ctx, int argc);                        /* timeDelay */
186
187
void bifsetoutfilter(bifcxdef *ctx, int argc);           /* setOutputFilter */
188
void bifexec(bifcxdef *ctx, int argc);                       /* execCommand */
189
void bifgetobj(bifcxdef *ctx, int argc);                    /* parserGetObj */
190
void bifparsenl(bifcxdef *ctx, int argc);            /* parserParseNounList */
191
void bifprstok(bifcxdef *ctx, int argc);                  /* parserTokenize */
192
void bifprstoktyp(bifcxdef *ctx, int argc);            /* parserGetTokTypes */
193
void bifprsdict(bifcxdef *ctx, int argc);               /* parserDictLookup */
194
void bifprsrslv(bifcxdef *ctx, int argc);           /* parserResolveObjects */
195
void bifprsrplcmd(bifcxdef *ctx, int argc);         /* parserReplaceCommand */
196
void bifexitobj(bifcxdef *ctx, int argc);                        /* exitobj */
197
void bifinpdlg(bifcxdef *ctx, int argc);                     /* inputdialog */
198
void bifresexists(bifcxdef *ctx, int argc);               /* resourceExists */
199
200
/*
201
 *   TADS/graphic functions - these are present in the text system, but
202
 *   don't do anything.
203
 */
204
void bifgrp(bifcxdef *ctx, int argc);            /* g_readpic: read picture */
205
void bifgsp(bifcxdef *ctx, int argc);            /* g_showpic: show picture */
206
void bifgsh(bifcxdef *ctx, int argc);             /* g_sethot: set hot list */
207
void bifgin(bifcxdef *ctx, int argc);                        /* g_inventory */
208
void bifgco(bifcxdef *ctx, int argc);                          /* g_compass */
209
void bifgov(bifcxdef *ctx, int argc);                          /* g_overlay */
210
void bifgmd(bifcxdef *ctx, int argc);                             /* g_mode */
211
void bifgmu(bifcxdef *ctx, int argc);                            /* g_music */
212
void bifgpa(bifcxdef *ctx, int argc);                            /* g_pause */
213
void bifgef(bifcxdef *ctx, int argc);                           /* g_effect */
214
void bifgsn(bifcxdef *ctx, int argc);                            /* g_sound */
215
216
#ifdef __cplusplus
217
}
218
#endif
219
220
#endif /* BIF_INCLUDED */