-
Notifications
You must be signed in to change notification settings - Fork 4
/
gu.h
415 lines (351 loc) · 8.49 KB
/
gu.h
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
/*
gu.h -- include file for the shell 'gulam' 7/20/86
copyright (c) 1986 [email protected]
*/
#define GU 1
typedef unsigned int uint;
typedef char uchar;
#include "sysdpend.h" /* this should come after OS #define */
#include <setjmp.h>
#define FALSE 0
#define TRUE (!FALSE)
#define ABORT 2 /* Death, ^G, abort, etc. */
#ifndef NULL
#define NULL 0L
#endif
#ifndef UNUSED
# define UNUSED(x) ((void)(x))
#endif
/* some std ascii chars */
#define CTRLC '\003'
#define CTRLD '\004'
#define CTRLG '\007'
#define CTRLQ '\021'
#define CTRLS '\023'
#define CTRLO '\017'
#define ESC '\033'
#define Iwssz 100
typedef struct
{ int nc;
int sz;
int ns;
uchar *ps;
} WS;
typedef uchar *WSPS;
typedef struct GA
{ int sz; /* size (in bytes) of an element */
int ne; /* #elements in the array */
int na; /* #elements allocated */
int ni; /* increment for re allocation */
uchar el[MINELM]; /* elements themselves */
} GA;
typedef struct TBLE
{ uchar * key;
uchar * elm;
struct TBLE * next;
} TBLE;
extern uchar CRLF[]; /* "\r\n" */
extern uchar ES[]; /* "\0", used as empty string */
extern uchar GulamHelp[]; /* = "gulam_help_file"; */
extern uchar Nrows[]; /* = "nrows" */
extern uchar OwnFonts[];
extern uchar History[];
extern uchar Home[];
extern uchar Rgb[];
extern uchar Cwd[];
extern uchar Status[]; /* in tv.c */
extern uchar Shell[];
extern uchar OS[];
extern uchar Gulam[];
extern uchar Verbosity[];
extern uchar GulamLogo[];
extern uchar uE[];
extern uchar Copyright[];
extern uchar defaultprompt[];
extern uchar Mini[];
extern uchar Font[];
extern uchar Completions[];
extern uchar Tempexit[];
extern uchar Scrninit[]; /* clr scrn, cursr off, wordwrap on */
extern uchar Parentexp[];
extern uchar Ncmd[];
extern long starttick;
extern long _stksize;
extern unsigned long masterdate;
extern uchar ext[];
extern uchar *rednm[2];
extern int outappend;
/* Delimiters when treating the subwords: must not contain meta-chars
?*()[]. By def, a subword has no white chars. */
extern uchar DS0[];
extern uchar DS1[];
extern uchar DS2[];
extern uchar DS3[];
extern uchar DS4[];
extern uchar DS5[];
extern uchar DFLNSEP[];
extern uchar WHITEC[]; /* ==1 for white chars, 0 ow */
extern uchar WHITEDELIMS[],DELIMS[],SUBDELIMS[],COMMA[],BTRNQD[]; /* 0/1*/
extern uchar TKN2[], EMPTY2[]; /* 0/1 vectors */
extern uchar * emsg;
extern uchar * strg;
extern long valu;
extern int fda[4];
extern int cmdprobe; /* AKP */
extern int state;
extern uchar cnmcomplete; /* name completion key char */
extern uchar cnmshow;
extern uchar negopts[], posopts[];
extern jmp_buf abort_env;
extern jmp_buf time_env;
#define lowercase(xx) chcase(xx, 0)
#define uppercase(xx) chcase(xx, 1)
/*
* cs.c
*/
int inbatchfile(void);
void csexit(int n);
int batch(uchar *p, uchar *cmdln, uchar *envp);
uchar *fnmpred(uchar c, uchar *p);
uchar *csexp(uchar *p, uchar **nextword);
void csif(uchar *arg);
void cselse(uchar *arg);
void csendif(uchar *arg);
void cswhile(uchar *arg);
void csendwhile(uchar *arg);
void csforeach(uchar *arg);
void csendfor(uchar *arg);
/*
* do.c
*/
void addoptions(uchar *p);
void source(uchar *arg);
void echo(uchar *arg);
int asktodoop(uchar *op, uchar *p);
void doforeach(uchar *op, void (*f)(uchar *arg));
void setuekey(uchar *arg);
void showbuiltins(void);
void docmd(void);
/*
* ex.c
*/
int matchednms(uchar *lst, uchar *p, int flag);
uchar *ptometach(uchar *p);
int nameexpand(uchar *lst, uchar *q, int tenex);
uchar *stdpathname(uchar *nm);
uchar *fnmsinparent(uchar *p);
int fnmexpand(uchar **p, uchar **q, int pexp, int tenex);
int fullname(uchar *name);
WS *metaexpand(uchar *p);
void pushws(WS *w);
void popargws(void);
WS *expand(uchar *p, int addremargs);
WS *aliasexp(WS *ws);
/*
* fop.c
*/
void pwd(uchar *arg);
void cdcmd(uchar *arg);
void dirs(uchar *arg);
void pushd(uchar *arg);
void popd(uchar *arg);
void grename(uchar *arg);
void rm(uchar *p);
void cp(uchar *arg);
void mv(uchar *arg);
void cat(uchar *p);
/*
* gcoatari.c
*/
void resetrs232buf(void);
void setrs232buf(void);
void setrs232speed(void);
void sbreak(void);
void alarm(uint n);
int readmodem(void);
void writemodem(char *buf, int len);
void flushinput(void);
void teexit(uchar *arg);
/*
* gfsatari.c
*/
int filetp(uchar *p, int a);
void attrstr(int a, uchar *p);
void gmkdir(uchar *p);
void grmdir(uchar *p);
uchar *gfgetcwd(void);
void cd(uchar *p);
void gchmod(uchar *p);
void tch(uchar *p, DOSTIME *td, int dontcreate);
void touch(uchar *p);
int outisredir(void);
int doout(void *dummy, uchar *p);
void doredirections(void);
void undoredirections(void);
/*
* gmcatari.c
*/
unsigned long getticks(void);
void computetime(void);
void stamptime(unsigned long *ip);
void datestr(int d, uchar *p);
int tooold(unsigned int date);
void yearstr(unsigned int date, char *s);
void timestr(int t, uchar *p);
void gsdatetime(uchar *s);
void Gem(uchar *arg);
void setgulam(void);
void mem(uchar *arg);
uchar *maxalloc(long *nb);
void maxfree(uchar *p);
void lpeekw(uchar *arg);
void lpokew(uchar *arg);
void format(uchar *p);
uchar *drvmap(char *buf);
void df(uchar *p);
void dm(uchar *p);
/*
* hist.c
*/
void histinit(void);
uchar *prevhist(void);
uchar *substhist(uchar *s);
void remember(char *p, int n);
void history(uchar *arg);
void readhistory(void);
void savehistory(void);
/*
* kb.c
*/
/*
* lex.c
*/
WS *lex(uchar *p, uchar *dlm, uchar *t2);
WS *useuplexws(void);
uchar *lexgetword(void);
uchar *lexlastword(void);
uchar *lextail(void);
void appendlextail(WS *w);
uchar *lexhead(void);
uchar *lexsemicol(void);
void lexaccept(WS *w);
void lexpush(void);
void lexpop(void);
/*
* ls.c
*/
void freewtbl(void);
void wls(int flag);
void fnmtbl(uchar *arg);
int isdir(char *p);
void ls(uchar *arg);
/*
* main.c
*/
void outstrg(void);
uchar *getprompt(void);
void gulamhelp(uchar *arg);
uchar *getoneline(void);
void getcmdanddoit(void);
void gtime(uchar *arg);
uchar *execcmd(WS *ws);
void processcmd(char *qq, int savehist);
/*
* rehash.c
*/
uchar *hashlookup(int i, uchar *p);
void which(int f);
void cmdwhich(uchar *arg);
void rehash(uchar *arg);
/*
* alias.c/tv.c
*/
TBLE *tblfind(TBLE *t, uchar *k);
void tbldelete(TBLE *t, uchar *k);
void tblinsert(TBLE *t, uchar *k, uchar *e);
TBLE *tblcreate(void);
void tblfree(TBLE *t);
WS *tblws(TBLE *t, int style);
uchar *tblstr(TBLE *t, int style);
void alias(uchar *arg);
void unalias(uchar *arg);
uchar *getalias(uchar *p);
/*
* env.c/tv.c
*/
uchar *ggetenv(uchar *p);
void gputenv(const char *p, const char *q);
WS *dupenvws(int flag);
void printenv(uchar *arg);
void gsetenv(uchar *arg);
void gunsetenv(uchar *arg);
void readinenv(uchar *p);
/*
* var.c/tv.c
*/
uchar *varstr(uchar *p);
int varnum(uchar *p);
void showvars(void);
void insertvar(uchar *p, uchar *q);
void setvarnum(uchar *p, int n);
void setvar(uchar *arg);
void unsetvar(uchar *arg);
/*
* help.c/tv.c
*/
void rdhelpfile(void);
uchar *findname(int x, int k);
/*
* util.c
*/
void charset(uchar *a, uchar *s, uint v);
GA *initga(int z, int i);
GA *addelga(GA *ga, void *e);
WS *initws(void);
void freews(WS *ws);
WS *dupws(WS *ws);
int findstr(WSPS q, uchar *p);
uchar *nthstr(WSPS p, int n);
uchar *catall(WS *ws, int m);
void strwcat(WS *ws, const uchar *p, int i);
uchar *pscolumnize(uchar *r, int ns, int cw);
WS *prefixws(uchar *p, WSPS q);
void appendws(WS *u, WS *v, int m);
void shiftws(WS *ws, int m);
void showwsps(WSPS *p);
uchar *unquote(uchar *q, uchar *p);
uchar *str3cat(uchar *p, uchar *q, uchar *r);
uchar *strsub(uchar *p, uchar *q);
char *gstrdup(const char *p);
uchar *chcase(uchar *p, int i);
int atoi(const char *p);
long atoir(const char *p, int r);
uchar *itoar(long i, int r);
uchar *itoal(long i);
int stackoverflown(int n);
void eachline(int fd, void (*fn)(uchar *q, int n));
void streachline(uchar *text, int (*fn)(void *ap, uchar *p), void *ap);
/*
* xmdm.c
*/
void rxmdm(uchar *p);
void sxmdm(uchar *p);
/*
* pregrep.c
*/
void print(uchar *arg);
void lpr(uchar *arg);
void egrep(uchar *arg);
void fgrep(uchar *arg);
/*
* ue.c
*/
void fg(uchar *arg);
void ue(uchar *arg);
void moreue(uchar *arg);
void outofroom(void);
void ueinit(void);
void ueexit(void);
void uebody(void);
KEY getkey(void);
KEY getctlkey(void);