forked from MidnightCommander/mc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_slang.h
327 lines (272 loc) · 7.89 KB
/
_slang.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
/* header file for S-Lang internal structures that users do not (should not)
need. Use slang.h for that purpose. */
/* Copyright (c) 1992, 1995 John E. Davis
* All rights reserved.
*
* You may distribute under the terms of either the GNU General Public
* License or the Perl Artistic License.
*/
#include "config.h"
#include <string.h>
#include <glib.h>
#include "slang-mc.h"
#include "jdmacros.h"
#ifdef VMS
# define SLANG_SYSTEM_NAME "_VMS"
#else
# if defined (__GO32__) || defined (__EMX__) || \
defined (msdos) || defined (__os2__)
# define SLANG_SYSTEM_NAME "_IBMPC"
# else
# define SLANG_SYSTEM_NAME "_UNIX"
# endif
#endif /* VMS */
#ifdef msdos
#define SLANG_MAX_SYMBOLS 500
#else
#define SLANG_MAX_SYMBOLS 2500
#endif
/* maximum number of global symbols--- slang builtin, functions, global vars */
/* These quantities are main_types for byte-compiled code. They are used
* by the inner_interp routine. The ones commented out with a // are
* actually defined in slang.h because they are also used as the main_type in
* the name table.
*/
/* // #define SLANG_LVARIABLE 0x01 */
#define SLANG_LOGICAL 0x02
#define SLANG_BINARY 0x03
/* // #define SLANG_INTRINSIC 0x06 */
/* // #define SLANG_FUNCTION 0x07 */
#define SLANG_LITERAL 0x08 /* constant objects */
#define SLANG_BLOCK 0x09
#define SLANG_EQS 0x0A
#define SLANG_UNARY 0x0B
#define SLANG_LUNARY 0x0C
/* // #define SLANG_GVARIABLE 0x0D */
/* // #define SLANG_IVARIABLE 0x0E */ /* intrinsic variables */
/* // #define SLANG_RVARIABLE 0x0F */ /* read only variable */
/* These 3 MUST be in this order too ! */
#define SLANG_RETURN 0x10
#define SLANG_BREAK 0x11
#define SLANG_CONTINUE 0x12
#define SLANG_EXCH 0x13
#define SLANG_LABEL 0x14
#define SLANG_LOBJPTR 0x15
#define SLANG_GOBJPTR 0x16
#define SLANG_X_ERROR 0x17
/* These must be in this order */
#define SLANG_X_USER0 0x18
#define SLANG_X_USER1 0x19
#define SLANG_X_USER2 0x1A
#define SLANG_X_USER3 0x1B
#define SLANG_X_USER4 0x1C
#ifdef SLANG_NOOP
# define SLANG_NOOP_DIRECTIVE 0x2F
#endif
/* If SLANG_DATA occurs as the main_type for an object in the interpreter's
* byte-code, it currently refers to a STRING.
*/
/* // #define SLANG_DATA 0x30 */ /* real objects which may be destroyed */
/* Subtypes */
#define ERROR_BLOCK 0x01
/* gets executed if block encounters error other than stack related */
#define EXIT_BLOCK 0x02
#define USER_BLOCK0 0x03
#define USER_BLOCK1 0x04
#define USER_BLOCK2 0x05
#define USER_BLOCK3 0x06
#define USER_BLOCK4 0x07
/* The user blocks MUST be in the above order */
/* directive subtypes */
#define SLANG_LOOP_MASK 0x80
#define SLANG_LOOP 0x81
#define SLANG_WHILE 0x82
#define SLANG_FOR 0x83
#define SLANG_FOREVER 0x84
#define SLANG_CFOR 0x85
#define SLANG_DOWHILE 0x86
#define SLANG_IF_MASK 0x40
#define SLANG_IF 0x41
#define SLANG_IFNOT 0x42
#define SLANG_ELSE 0x43
/* local, global variable assignments
* The order here is important. See interp_variable_eqs to see how this
* is exploited. */
#define SLANG_EQS_MASK 0x20
/* local variables */
/* Keep these in this order!! */
#define SLANG_LEQS 0x21
#define SLANG_LPEQS 0x22
#define SLANG_LMEQS 0x23
#define SLANG_LPP 0x24
#define SLANG_LMM 0x25
/* globals */
/* Keep this on this order!! */
#define SLANG_GEQS 0x26
#define SLANG_GPEQS 0x27
#define SLANG_GMEQS 0x28
#define SLANG_GPP 0x29
#define SLANG_GMM 0x2A
/* intrinsic variables */
#define SLANG_IEQS 0x2B
#define SLANG_IPEQS 0x2C
#define SLANG_IMEQS 0x2D
#define SLANG_IPP 0x2E
#define SLANG_IMM 0x2F
#define SLANG_ELSE_MASK 0x10
#define SLANG_ANDELSE 0x11
#define SLANG_ORELSE 0x12
#define SLANG_SWITCH 0x13
/* LOGICAL SUBTYPES (operate on integers) */
#define SLANG_MOD 16
#define SLANG_OR 17
#define SLANG_AND 18
#define SLANG_BAND 19
#define SLANG_BOR 20
#define SLANG_BXOR 21
#define SLANG_SHL 22
#define SLANG_SHR 23
/* LUnary Subtypes */
#define SLANG_NOT 24
#define SLANG_BNOT 25
typedef struct SLBlock_Type
{
unsigned char main_type;
unsigned char sub_type;
union
{
struct SLBlock_Type *blk;
int i_blk;
SLang_Name_Type *n_blk;
char *s_blk;
#ifdef FLOAT_TYPE
float64 *f_blk; /*literal float is a pointer */
#endif
long l_blk;
}
b;
}
SLBlock_Type;
typedef struct
{
unsigned char main_type; /* block, intrinsic... */
unsigned char sub_type; /* SLANG_WHILE, SLANG_DATA, ... */
union
{
long l_val;
char *s_val;
int i_val;
SLuser_Object_Type *uobj;
SLang_Name_Type *n_val;
#ifdef FLOAT_TYPE
float64 f_val;
#endif
} v;
} SLang_Object_Type;
extern void SLang_free_object (SLang_Object_Type *);
extern int SLang_pop_non_object (SLang_Object_Type *);
extern void _SLdo_error (char *, ...);
extern void SLcompile(char *);
extern void (*SLcompile_ptr)(char *);
typedef struct
{
char *name; int type;
} SLang_Name2_Type;
extern void SLstupid_hash(void);
typedef struct SLName_Table
{
struct SLName_Table *next; /* next table */
SLang_Name_Type *table; /* pointer to table */
int n; /* entries in this table */
char name[32]; /* name of table */
int ofs[256]; /* offsets into table */
} SLName_Table;
extern SLName_Table *SLName_Table_Root;
#ifdef MSWINDOWS
extern SLang_Name_Type *SLang_Name_Table;
#else
extern SLang_Name_Type SLang_Name_Table[SLANG_MAX_SYMBOLS];
#endif
extern SLang_Name2_Type SL_Binary_Ops [];
extern SLang_Object_Type *SLStack_Pointer;
extern char *SLbyte_compile_name(char *);
extern int SLang_pop(SLang_Object_Type *);
extern char *SLexpand_escaped_char(char *, char *);
extern void SLexpand_escaped_string (char *, char *, char *);
extern SLang_Object_Type *_SLreverse_stack (int);
extern SLang_Name_Type *SLang_locate_name(char *);
/* returns a pointer to a MALLOCED string */
extern char *SLstringize_object (SLang_Object_Type *);
/* array types */
typedef struct SLArray_Type
{
unsigned char type; /* int, float, etc... */
int dim; /* # of dims (max 3) */
int x, y, z; /* actual dims */
union
{
unsigned char *c_ptr;
unsigned char **s_ptr;
int *i_ptr;
#ifdef FLOAT_TYPE
float64 *f_ptr;
#endif
SLuser_Object_Type **u_ptr;
}
buf;
unsigned char flags; /* readonly, etc... If this is non-zero,
* the buf pointer will NOT be freed.
* See SLarray_free_array.
*/
} SLArray_Type;
/* Callback to delete array */
extern void SLarray_free_array (long *);
/* maximum size of run time stack */
#ifdef msdos
#define SLANG_MAX_STACK_LEN 500
#else
#define SLANG_MAX_STACK_LEN 2500
#endif
#ifdef MSWINDOWS
extern SLang_Object_Type *SLRun_Stack;
#else
extern SLang_Object_Type SLRun_Stack[SLANG_MAX_STACK_LEN];
#endif
extern SLang_Object_Type *SLStack_Pointer;
extern int SLang_Trace;
extern int SLstack_depth(void);
extern void SLang_trace_fun(char *);
extern void SLexecute_function(SLang_Name_Type *);
extern char *SLmake_string (char *);
extern int _SLeqs_name(char *, SLang_Name2_Type *);
extern void SLang_push(SLang_Object_Type *);
extern void SLang_push_float(float64);
extern void SLadd_variable(char *);
extern void SLang_clear_error(void);
extern void SLarray_info (void);
extern int SLPreprocess_Only; /* preprocess instead of
* bytecompiling
*/
extern void SLdo_pop (void);
extern unsigned int SLsys_getkey (void);
extern int SLsys_input_pending (int);
#ifdef REAL_UNIX_SYSTEM
extern int SLtt_tigetflag (char *, char **);
extern int SLtt_tigetnum (char *, char **);
extern char *SLtt_tigetstr (char *, char **);
extern char *SLtt_tigetent (char *);
#endif
#ifdef msdos
#define MAX_INPUT_BUFFER_LEN 40
#else
#define MAX_INPUT_BUFFER_LEN 1024
#endif
extern unsigned char SLang_Input_Buffer [MAX_INPUT_BUFFER_LEN];
extern unsigned int SLang_Input_Buffer_Len;
extern int SLregister_types (void);
#ifndef pc_system
extern char *SLtt_Graphics_Char_Pairs;
#endif /* NOT pc_system */
extern void _SLerrno_set_return_status (void);
extern char *_SLerrno_strerror (void);
extern int _SLerrno_Return_Status;