forked from KermitProject/ckermit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ckucmd.h
313 lines (269 loc) · 9.02 KB
/
ckucmd.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
/* C K U C M D . H -- Header file for interactive command parser */
/*
Author: Frank da Cruz <fdc@columbia.edu>
Columbia University Kermit Project, New York City.
Copyright (C) 1985, 2022,
Trustees of Columbia University in the City of New York.
All rights reserved. See the C-Kermit COPYING.TXT file or the
copyright text in the ckcmai.c module for disclaimer and permissions.
Note: the name of these files really should be ckccmd.h and ckccmd.c
because they are for all platforms, not just Unix. But "don't fix
what ain't broke".
Last update: Sat Sep 24 14:05:17 2022 -fdc
Removed redundant arrow-key #ifdefs (they only need to be in ckcdeb.h)
*/
#ifndef CKUCMD_H
#define CKUCMD_H
/* Command recall */
#ifdef pdp11 /* Not enough room for this */
#ifndef NORECALL
#define NORECALL
#endif /* NORECALL */
#endif /* pdp11 */
#ifdef DYNAMIC /* Dynamic command buffers */
/*
Use malloc() to allocate the many command-related buffers in ckucmd.c.
*/
#ifndef DCMDBUF
#ifndef NORECALL
#define NORECALL
#endif /* NORECALL */
#endif /* DCMDBUF */
#ifndef NORECALL
#define CK_RECALL
#else
#ifdef CK_RECALL
#undef CK_RECALL
#endif /* CK_RECALL */
#endif /* NORECALL */
#else
#ifndef NORECALL
#define NORECALL
#endif /* NORECALL */
#endif /* DYNAMIC */
#ifdef NORECALL
#ifdef CK_RECALL
#undef CK_RECALL
#endif /* CK_RECALL */
#endif /* NORECALL */
/* Special getchars */
#ifdef VMS
#ifdef getchar /* This is for VMS GCC */
#undef getchar
#endif /* getchar */
#define getchar() vms_getchar()
int vms_getchar(void);
#endif /* VMS */
#ifdef aegis
#undef getchar
#define getchar() coninc(0)
#endif /* aegis */
#ifdef AMIGA
#undef getchar
#define getchar() coninc(0)
#endif /* AMIGA */
#ifdef Plan9
#undef getchar
#define getchar() coninc(0)
#undef putchar
#define putchar(c) conoc(c)
#undef printf
#define printf conprint
#endif /* Plan9 */
/* Sizes of things */
#ifndef CMDDEP
#ifdef BIGBUFOK
#define CMDDEP 64 /* Maximum command recursion depth */
#else
#define CMDDEP 20
#endif /* BIGBUFOK */
#endif /* CMDDEP */
#define HLPLW 78 /* Width of ?-help line */
#define HLPCW 19 /* Width of ?-help column */
#define HLPBL 100 /* Help string buffer length */
#ifdef BIGBUFOK
#define ATMBL 10238 /* Command atom buffer length */
#else
#ifdef NOSPL
#define ATMBL 256
#else
#define ATMBL 1024
#endif /* NOSPL */
#endif /* BIGBUFOK */
#ifndef CMDBL
#ifdef NOSPL
/* No script programming language, save some space */
#define CMDBL 608 /* Command buffer length */
#else
#ifdef BIGBUFOK
#define CMDBL 32763
#else
#define CMDBL 4092
#endif /* OS2 */
#endif /* NOSPL */
#endif /* CMDBL */
/* Special characters */
#define RDIS 0022 /* Redisplay (^R) */
#define LDEL 0025 /* Delete line (^U) */
#define WDEL 0027 /* Delete word (^W) */
#ifdef CK_RECALL
#define C_UP 0020 /* Go Up in recall buffer (^P) */
#define C_UP2 0002 /* Alternate Go Up (^B) for VMS */
#define C_DN 0016 /* Go Down in recall buffer (^N) */
#endif /* CK_RECALL */
/* Keyword flags (bits, powers of 2) */
#define CM_INV 1 /* Invisible keyword */
#define CM_ABR 2 /* Abbreviation for another keyword */
#define CM_HLP 4 /* Help-only keyword */
#define CM_ARG 8 /* An argument is required */
#define CM_NOR 16 /* No recall for this command */
#define CM_PRE 32 /* Long-form cmdline arg for prescan */
#define CM_PSH 64 /* Command disabled if nopush */
#define CM_LOC 128 /* Command disabled if nolocal */
/*
A long-form command line option is a keyword using the regular struct keytab
and lookup mechanisms. Flags that make sense in this context are CM_ARG,
indicating this option requires an argument (operand), and CM_PRE, which
means this option must be processed before the initialization file. The
absence of CM_PRE means the option is to be processed after the
initialization file in the normal manner.
*/
/* Token flags (numbers) */
#define CMT_COM 0 /* Comment (; or #) */
#define CMT_SHE 1 /* Shell escape (!) */
#define CMT_LBL 2 /* Label (:) */
#define CMT_FIL 3 /* Indirect filespec (@) (not used) */
/* Path separator for path searches */
#ifdef OS2
#define PATHSEP ';'
#else
#ifdef UNIX
#define PATHSEP ':'
#else
#define PATHSEP ','
#endif /* UNIX */
#endif /* OS2 */
#ifndef CK_KEYTAB
#define CK_KEYTAB
/* Keyword Table Template perhaps already defined in ckcdeb.h */
struct keytab { /* Keyword table */
char *kwd; /* Pointer to keyword string */
int kwval; /* Associated value */
int flgs; /* Flags (as defined above) */
};
#endif /* CK_KEYTAB */
/* String preprocessing function */
#ifdef CK_ANSIC /* ANSI C */
#ifdef M_SYSV /* SCO Microsoft C wants no args */
typedef int (*xx_strp)();
#else
typedef int (*xx_strp)(char *, char **, int *);
#endif /* M_SYSV */
#else /* Not ANSI C */
typedef int (*xx_strp)();
#endif /* CK_ANSIC */
/* FLDDB struct */
typedef struct FDB {
int fcode; /* Function code */
char * hlpmsg; /* Help message */
char * dflt; /* Default */
char * sdata; /* Additional string data */
int ndata1; /* Additional numeric data 1 */
int ndata2; /* Additional numeric data 2 */
xx_strp spf; /* String processing function */
struct keytab * kwdtbl; /* Keyword table */
struct FDB * nxtfdb; /* Pointer to next alternative */
} fdb;
typedef struct OFDB {
struct FDB * fdbaddr; /* Address of succeeding FDB struct */
int fcode; /* Function code */
char * sresult; /* String result */
int nresult; /* Integer result */
int kflags; /* Keyword flags if any */
CK_OFF_T wresult; /* Long integer ("wide") result */
} ofdb;
#ifndef CKUCMD_C
extern struct OFDB cmresult;
#endif /* CKUCMD_C */
/* Codes for primary parsing function */
#define _CMNUM 0 /* Number */
#define _CMOFI 1 /* Output file */
#define _CMIFI 2 /* Input file */
#define _CMFLD 3 /* Arbitrary field */
#define _CMTXT 4 /* Text string */
#define _CMKEY 5 /* Keyword */
#define _CMCFM 6 /* Confirmation */
#define _CMDAT 7 /* Date/time */
#define _CMNUW 8 /* Wide version of cmnum */
/* Function prototypes */
_PROTOTYP( int xxesc, (char **) );
_PROTOTYP( int cmrini, (int) );
_PROTOTYP( VOID cmsetp, (char *) );
_PROTOTYP( VOID cmsavp, (char [], int) );
_PROTOTYP( char * cmgetp, (void) );
_PROTOTYP( VOID prompt, (xx_strp) );
_PROTOTYP( VOID pushcmd, (char *) );
_PROTOTYP( VOID cmres, (void) );
_PROTOTYP( VOID cmini, (int) );
_PROTOTYP( int cmgbrk, (void) );
_PROTOTYP( int cmgkwflgs, (void) );
_PROTOTYP( int cmpush, (void) );
_PROTOTYP( int cmpop, (void) );
_PROTOTYP( VOID untab, (char *) );
_PROTOTYP( int cmnum, (char *, char *, int, int *, xx_strp ) );
_PROTOTYP( int cmnumw, (char *, char *, int, CK_OFF_T *, xx_strp ) );
_PROTOTYP( int cmofi, (char *, char *, char **, xx_strp ) );
_PROTOTYP( int cmifi, (char *, char *, char **, int *, xx_strp ) );
_PROTOTYP( int cmiofi, (char *, char *, char **, int *, xx_strp ) );
_PROTOTYP( int cmifip,(char *, char *, char **, int *, int, char *, xx_strp ));
_PROTOTYP( int cmifi2,(char *,char *,char **,int *,int,char *,xx_strp,int ));
_PROTOTYP( int cmdir, (char *, char *, char **, xx_strp ) );
_PROTOTYP( int cmdirp, (char *, char *, char **, char *, xx_strp ) );
_PROTOTYP( int cmfld, (char *, char *, char **, xx_strp ) );
_PROTOTYP( int cmtxt, (char *, char *, char **, xx_strp ) );
_PROTOTYP( int cmkey, (struct keytab [], int, char *, char *, xx_strp) );
_PROTOTYP( int cmkeyx, (struct keytab [], int, char *, char *, xx_strp) );
_PROTOTYP( int cmkey2,(struct keytab [],int,char *,char *,char *,xx_strp,int));
_PROTOTYP( int cmswi, (struct keytab [], int, char *, char *, xx_strp) );
_PROTOTYP( int cmdate,(char *, char *, char **, int, xx_strp) );
_PROTOTYP( char * cmpeek, (void) );
_PROTOTYP( int cmfdb, (struct FDB *) );
_PROTOTYP( VOID cmfdbi, (struct FDB *,
int, char *, char *, char *, int, int, xx_strp,
struct keytab *, struct FDB *) );
_PROTOTYP( int chktok, (char *) );
_PROTOTYP( int cmcfm, (void) );
_PROTOTYP( int lookup, (struct keytab [], char *, int, int *) );
_PROTOTYP( VOID kwdhelp, (struct keytab[],int,char *,char *,char *,int,int) );
_PROTOTYP( int ungword, (void) );
_PROTOTYP( VOID unungw, (void) );
_PROTOTYP( int cmdsquo, (int) );
_PROTOTYP( int cmdgquo, (void) );
_PROTOTYP( char * ckcvtdate, (char *, int) );
_PROTOTYP( int cmdgetc, (int));
#ifndef NOARROWKEYS
_PROTOTYP( int cmdconchk, (void) );
#endif /* NOARROWKEYS */
#ifdef CK_RECALL
_PROTOTYP( char * cmgetcmd, (char *) );
_PROTOTYP( VOID addcmd, (char *) );
_PROTOTYP( VOID cmaddnext, (void) );
#endif /* CK_RECALL */
_PROTOTYP( char * cmcvtdate, (char *, int) );
_PROTOTYP( char * cmdiffdate, (char *, char *) );
_PROTOTYP( char * cmdelta, (int,
int,int,int,int,int,int,int,int,int,int,int,int ));
_PROTOTYP( char * shuffledate, (char *, int) );
_PROTOTYP( int filhelp, (int, char *, char *, int, int) );
_PROTOTYP( int xfilhelp, (int, char *, char *, int, int,
int,
char *, char *, char *, char *,
CK_OFF_T, CK_OFF_T,
int, int,
char **) );
_PROTOTYP( int delta2sec, (char *, long *) );
#ifdef DCMDBUF
_PROTOTYP( int cmsetup, (void) );
#endif /* DCMDBUF */
#endif /* CKUCMD_H */
/* End of ckucmd.h */