don't build pcre as part of the linklibs target
[AROS-Contrib.git] / regina / regina_t.h
blobacb728394d72dc8e944955d3e4cd938b92720eb5
1 /*
2 * The Regina Rexx Interpreter
3 * Copyright (C) 1992-1994 Anders Christensen <anders@pvv.unit.no>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef REGINA_TYPES_H_INCLUDED
20 #define REGINA_TYPES_H_INCLUDED
22 typedef struct varbox *variableptr ;
23 typedef const struct varbox *cvariableptr ;
26 * var_hashtable is a table with size entries. The entries are added according
27 * to their hash value.
28 * r is the number of read accesses.
29 * w is the number of write accesses.
30 * c is the number of collisions on access or while creating/copying the table.
31 * e is the number of true elements in the tbl, hashed to size buckets.
32 * Note that tbl contains one more hidden element used for variable
33 * maintenance if size > 0.
35 typedef struct {
36 variableptr *tbl;
37 unsigned r; /* read */
38 unsigned w; /* write */
39 unsigned c; /* collisions */
40 unsigned e; /* elements */
41 unsigned size;
42 } var_hashtable;
44 typedef struct varbox {
45 var_hashtable *index;
46 variableptr next, prev, realbox ;
47 struct strengtype *name, *value ;
48 int guard ;
49 num_descr *num ;
50 int flag ;
51 unsigned hash ;
52 long hwired, valid ; /* FGC: at least valid may be too small for many
53 recursions with short instead of long.
54 27.09.98 (09/27/98). */
55 variableptr stem ;
56 } variable ;
58 /* typedef int bool ; */
60 typedef struct {
61 unsigned int lnum:1 ; /* left side of comparison is a number or string constant */
62 unsigned int rnum:1 ; /* right side of comparison is a number or string constant */
63 unsigned int lsvar:1 ; /* left side of comparison is a simple variable */
64 unsigned int rsvar:1 ; /* right side of comparison is a simple variable */
65 unsigned int lcvar:1 ; /* left side of comparison is a compound variable */
66 unsigned int rcvar:1 ; /* right side of comparison is a compound variable */
67 } compflags ;
69 typedef enum {
70 awtUNKNOWN = 0,
71 awtSTREAM = 1,
72 awtSTEM = 2,
73 awtLIFO = 3,
74 awtFIFO = 4
75 } AddressWithType;
77 typedef enum {
78 antUNKNOWN = 0,
79 antSTRING = 1,
80 antSIMSYMBOL = 2
81 } AddressNameType;
83 typedef enum {
84 fpdRETAIN = 0,
85 fpdCLEAR = 1
86 } FilePtrDisposition;
88 typedef struct {
89 unsigned int append:1;
90 unsigned int isinput:1;
91 unsigned int iserror:1;
92 unsigned int awt:3; /* overlay with AddressWithType */
93 unsigned int ant:2; /* overlay with AddressNameType */
94 } outputflags; /* used by ADDRESS WITH resourceo */
96 typedef enum {
97 PROTECTED_DelayedScriptExit,
98 PROTECTED_DelayedInterpreterExit,
99 PROTECTED_DelayedRexxSignal
100 } delayed_error_type_t;
102 typedef enum {
103 QisUnused,
104 QisSESSION,
105 QisInternal,
106 QisExternal,
107 QisTemp
108 } queue_type_t ;
110 typedef struct {
111 time_t sec ;
112 time_t usec ;
113 } rexx_time;
115 struct _tsd_t; /* If this won't work change "struct _tsd_t *" to "void *"
116 * below. This will require more changes. Let your compiler
117 * choose the places.
120 typedef struct pparambox *paramboxptr ;
121 typedef const struct pparambox *cparamboxptr ;
122 typedef struct pparambox {
123 paramboxptr next ;
124 int dealloc ;
125 struct strengtype *value ;
126 } parambox ;
128 typedef struct tnode {
129 unsigned int type ;
130 int charnr, lineno ;
131 union { /* saves memory which is really needed */
132 int called; /* used during execution *and* don't need init */
133 struct tnode *last; /* used during parsing */
134 } o ;
135 struct strengtype *name ;
136 rexx_time *now ;
137 struct tnode *p[4] ;
138 union {
140 * WARNING: When changing check whether to modify dumptree and the
141 * whole instore stuff. Seek for X_CEXPRLIST.
143 streng *(*func)(struct _tsd_t *,cparamboxptr) ;
144 streng *strng ;
145 struct tnode *node ;
146 num_descr *number ;
147 compflags flags ;
148 variable *varbx ;
149 outputflags of ;
150 int parseflags ;
151 int nonansi ;
152 int trace_only ; /* For labels */
153 } u ;
154 struct tnode *next ;
155 unsigned long nodeindex ; /* for an effectiv relocation, never change! */
156 } treenode ;
157 typedef struct tnode *nodeptr ;
158 typedef const struct tnode *cnodeptr ;
160 typedef struct lineboxx *lineboxptr ;
161 typedef const struct lineboxx *clineboxptr ;
162 typedef struct lineboxx {
163 lineboxptr next, prev ;
164 struct strengtype *line ;
165 int lineno ;
166 } linebox ;
168 typedef struct labelboxx *labelboxptr ;
169 typedef const struct labelboxx *clabelboxptr ;
170 typedef struct labelboxx {
171 labelboxptr next ;
172 unsigned long hash ;
173 nodeptr entry ;
174 } labelbox ;
176 typedef struct trap_type /* index is type of signal */
178 unsigned int on_off:1 ; /* true if trap is active/on */
179 /* unsigned int trapped:1 ; */ /* true if condition has been raised */
180 unsigned int def_act:1 ; /* true if default action is to ignore */
181 unsigned int delayed:1 ; /* true if trap is in delay mode */
182 unsigned int ignored:1 ; /* true if ignored when in delayed mode */
183 unsigned int invoked:1 ; /* true if invoked by SIGNAL */
184 streng *name ; /* label to transfer control to */
185 } trap ;
187 typedef struct sig_type
189 int type ;
190 streng *info ;
191 streng *descr ;
192 int invoke ; /* is true if invoked with SIGNAL */
193 int rc, subrc, lineno ;
194 } sigtype ;
196 typedef void (*signal_handler)(int);
198 typedef struct __regina_option
200 char *name ;
201 int offset ;
202 char *contains ;
203 } option_type ;
205 typedef struct _StackLine {
206 /* A stack line is a double linked list element of a streng. The streng
207 * never contains a line end and is never NULL.
208 * A read operations will happen at the top end, as well as a LIFO
209 * operation.
210 * A FIFO operation will happen at the bottom end.
212 struct _StackLine *higher ;
213 struct _StackLine *lower ;
214 streng *contents ;
215 } StackLine ;
217 typedef struct _Buffer {
218 /* A buffer is a double linked list of stack line bundles.
219 * MAKEBUF() adds a new buffer at the newest end.
221 struct _Buffer *higher ;
222 struct _Buffer *lower ;
224 /* The "content" of the buffer. See StackLine for a description.
225 * For a faster response of QUEUED(), we count the elements of lines.
227 StackLine *top ;
228 StackLine *bottom ;
229 unsigned elements ;
230 } Buffer ;
232 typedef struct {
233 /* A queue is one of different implementations of queue types.
234 * See the picture and the description at the beginning of stack.c.
236 queue_type_t type;
237 union {
238 struct { /* internal or SESSION: i */
239 /* name is the uppercased name of the queue. In rare cases this
240 * may be NULL for QisSESSION after initialisation.
242 streng *name ;
244 * Indicates if the queue is a "real" queue
245 * or a false queue as a result of a rxqueue('set', 'qname')
246 * on a queue that doesn't exist. This is crap behaviour!
247 * but that's how Object Rexx works :-(
249 int isReal ;
251 * Content: We have a double linked list of buffers. See Buffer
252 * for a description.
254 Buffer *top ;
255 Buffer *bottom ;
257 /* This is the count of buffers including the zeroth buffer */
258 unsigned buffers ;
260 /* This is the overall count of elements in all buffers */
261 unsigned elements ;
262 } i ;
263 struct { /* external: e */
265 * The port number for the current connection to an external rxstack
266 * Valid values: 1..0xFFFF, unused: 0
268 int portno;
270 * The socket fd for the current connection to an external rxstack
271 * Valid values: not -1, unused/error: -1
273 int socket;
275 * The server address of the current connection. Used to determine if
276 * we need to disconnect from one rxstack server and connect to
277 * another.
278 * The true data type is a 32 bit system depending type.
279 * Valid values: not 0, unused: 0
281 int address;
283 * A boolean value which indicates if the external queue has had a timeout
284 * set on it via RXQUEUE( 'Timeout' )
285 * Valid values: 0 or 1
287 int timeoutSet;
288 streng *name;
289 } e ;
290 Buffer t ; /* temp: t */
291 } u ;
292 } Queue ;
294 typedef struct { /* one for each redirection in environment */
295 streng *name; /* name if any, but not expanded */
296 outputflags flags;
297 streng *base; /* "number" if name is a stem */
298 streng *currname; /* expanded name + ".number" if name */
299 /* is a stem */
300 int currnamelen; /* len(currname) without ".number"*/
301 int currnum; /* current number for a stem position */
302 /* or -1 if unknown */
303 int maxnum; /* maximum number for a stem position */
304 /* or -1 if unknown */
305 void *file; /* fileboxptr of the file with the */
306 /* above name or NULL. */
307 Queue *queue; /* queue with the above name or NULL. */
308 Queue *tmp_queue;/* temporary queue for the redirection*/
309 /* or NULL without this helper. */
310 unsigned int SameAsOutput:2; /* locally used in shell.c */
311 unsigned int FileRedirected:1; /* locally used in shell.c */
312 char *tempname; /* locally used filename in shell.c */
313 int type; /* locally used source in shell.c */
314 int hdls[3]; /* locally used connection in shell.c */
315 } environpart;
317 typedef struct {
318 struct strengtype *name; /* stemname or streamname if any */
319 int subtype; /* SUBENVIR_... */
320 int subcomed; /* has this environment been redirected to an API program via RexxRegistreSubcom???() */
321 environpart input;
322 environpart output;
323 environpart error;
324 } environment;
326 typedef struct proclevelbox *proclevel ;
327 typedef const struct proclevelbox *cproclevel ;
328 typedef struct proclevelbox {
329 int numfuzz, currnumsize, numform ;
330 int mathtype ;
331 rexx_time rx_time ;
332 proclevel prev, next ;
333 var_hashtable *vars ;
334 paramboxptr args ;
335 struct strengtype *environment, *prev_env ;
336 char tracestat, traceint, varflag ; /* MDW 30012002 */
337 sigtype *sig ;
338 trap *traps ;
339 jmp_buf *signal_continue; /* see jump_rexx_signal() */
340 unsigned long options;
341 int pool;
342 } proclevbox ;
344 typedef struct _ttree { /* bucket list of treenodes which allows ultra fast
345 * loading of instore macros.
347 struct _ttree *next;
348 unsigned long max; /* maximum number of elements in the bucket */
349 unsigned long num; /* current number of elements in the bucket */
350 unsigned long sum; /* sum of indices until element 0 */
351 treenode * elems;
352 } ttree; /* treenode type */
354 typedef struct { /* offsrcline: offset based source lines */
355 unsigned long length;
356 unsigned long offset;
357 /* That's all. You need the source string of the incore macro to create
358 * a real sourceline using this information.
360 } offsrcline;
362 typedef struct _otree { /* bucket list of offscrlines which allows ultra fast
363 * loading of instore macros.
365 struct _otree *next;
366 unsigned long max; /* maximum number of elements in the bucket */
367 unsigned long num; /* current number of elements in the bucket */
368 unsigned long sum; /* sum of indices until element 0 */
369 offsrcline * elems;
370 } otree; /* offsrcline type */
372 typedef struct { /* internal_parser_type is a structure containing data from a
373 * parsing operation.
375 lineboxptr first_source_line; /* Either this two values */
376 lineboxptr last_source_line ; /* exist or srclines below */
377 int tline; /* line number where error occured */
378 int tstart; /* column number where error occured */
379 int if_linenr; /* line number of last IF keyword */
380 int when_linenr; /* line number of last WHEN keyword */
381 labelboxptr first_label;
382 labelboxptr last_label;
383 unsigned long numlabels;
384 labelboxptr sort_labels ;
385 int result;
386 nodeptr root;
387 ttree * nodes;
388 otree * srclines; /* Either this two values exist */
389 const char * incore_source; /* or the two values above */
390 streng * kill; /* Probably the true source of incore_source in case
391 * of an "INTERPRET" instruction or other not user
392 * generated but interpreted strings; else NULL.
394 struct _tsd_t *TSD; /* needed during the parsing step */
395 } internal_parser_type;
397 typedef struct { /* extstring: external (instore) string */
398 unsigned long length;
399 /* and directly following the string's content */
400 } extstring;
402 typedef struct { /* external_parser_type: the instore macro in user space */
403 /* Never change from here until source including since it allows the
404 * reconstruction of the source if the machine type or Regina version
405 * doesn't match.
407 char Magic[32]; /* "Regina's Internal Format\r\n" filled with 0 */
408 #define MAGIC "Regina's Internal Format\r\n"
409 char ReginaVersion[64]; /* PARSE_VERSION_STRING */
411 /* The following structure allows the detection of different
412 * architectures. We don't want to try to decode something from
413 * a 64 bit big endian encoded parsing tree on an i586 for
414 * example.
416 union {
417 char ignore[4 * 256/8]; /* Allow 256 bit machines */
418 struct {
419 unsigned long one; /* value one */
420 unsigned long two; /* value two */
421 void * ptr3; /* value (void*)3, size may be different to unsigned */
422 void * ptr4; /* value (void*)4 */
423 } s;
424 } arch_detector;
426 unsigned long OverallSize; /* in byte of this structure and all dependencies */
428 unsigned long version; /* INSTORE_VERSION */
430 /* We describe the sourcelines first */
431 unsigned long NumberOfSourceLines;
432 unsigned long source;
433 /* Offset to table of source lines. Imagine a value of 1000 and
434 * 5 source lines (previous value). This structure has an address
435 * of 500 in the memory (what you get from malloc or something else).
436 * Then: The table has 5 entries at position 1500 in memory.
437 * Each table entry is an offsrcline structure. The source string is the
438 * instore[0] string of RexxStart or another source string.
441 unsigned long NumberOfTreeElements;
442 unsigned long TreeStart; /* Within 0 .. (NumberOfTreeElements-1) */
443 unsigned long tree;
444 /* Offset to table of nodes. Imagine a value of 2000 and
445 * 6 elements (NumberIfTreeElements). This structure has an address
446 * of 500 in the memory (what you get from malloc or something else).
447 * Then: The table has 6 treenodes at position 2500 in memory.
448 * Each table entry (treenode) must be relocated. Every nodeptr within a
449 * element is just an index within this table. If node->p[2] of one picked
450 * table entry is ((nodeptr) 4) then the address is calculated as follows:
451 * 500 + tree + (4*sizeof(treenode))
452 * This value should be assigned to node->p[2] to use the value in its
453 * normal manner.
454 * A NULL value is represented by (nodeptr) (unsigned) -1.
455 * Every string within a treenode is relocated by adding 500. Imagine a
456 * value of 3000 for node->name. Then an extstring structure is located
457 * at 3500 in memory which represents the string's content.
459 } external_parser_type;
461 typedef struct systeminfobox *sysinfo ;
462 typedef const struct systeminfobox *csysinfo ;
463 typedef struct systeminfobox {
464 struct strengtype *input_file ; /* must be 0-terminated without counting of the '\0' */
465 streng *environment ;
466 FILE *input_fp;
467 int tracing ;
468 int interactive ;
469 jmp_buf *script_exit; /* see jump_script_exit() */
470 streng *result ;
471 proclevbox *currlevel0 ;
472 struct systeminfobox *previous ;
473 nodeptr *callstack ;
474 int cstackcnt, cstackmax ;
475 int hooks ;
476 int invoked ;
477 int trace_override;
478 internal_parser_type tree;
479 int ctrlcounter;
480 } sysinfobox ;
482 #ifndef DONT_TYPEDEF_PFN
483 typedef unsigned long (*PFN)() ;
484 #endif
487 struct library {
488 streng *name;
489 void *handle;
490 unsigned long used;
492 struct library *next, *prev;
496 struct entry_point {
497 streng *name;
498 PFN addr;
499 union {
500 void *gci_info; /* for function handlers */
501 unsigned char user_area[8]; /* for suncommand and exit handlers */
502 } special;
504 unsigned long hash;
505 struct library *lib;
506 struct entry_point *next, *prev;
510 * Every major OS has some functionality that isn't shared with others.
511 * Most functions relate to the command execution/redirection stuff.
512 * The global function collection *OS_Dep will point to this structure.
513 * Some systems, Win9x and OS/2-EMX, even use the DOS entry table because
514 * they can't take advantage of the performance functions the system
515 * usually provides.
516 * init() may map some "stupid" function on advanced function, as for
517 * instance Win9x doesn't support redirection correctly.
519 struct _tsd_t;
520 struct regina_utsname;
521 typedef struct _OS_Dep_funcs {
522 void (*init) (void);
523 int (*setenv) (const char *name, const char *value);
524 int (*fork_exec) (struct _tsd_t *TSD, environment *env, const char *cmdline, int *rc);
525 int (*wait) (int process);
526 int (*open_subprocess_connection) (const struct _tsd_t *TSD, environpart *ep);
527 void (*unblock_handle) (int *handle, void *async_info);
528 void (*restart_file) (int hdl);
529 int (*close) (int handle, void *async_info);
530 void (*close_special) (int handle);
531 int (*read) (int hdl, void *buf, unsigned size, void *async_info) ;
532 int (*write) (int hdl, const void *buf, unsigned size, void *async_info);
533 void* (*create_async_info) (const struct _tsd_t *TSD);
534 void (*delete_async_info) (void *async_info);
535 void (*reset_async_info) (void *async_info);
536 void (*add_async_waiter) (void *async_info, int handle, int add_as_read_handle);
537 void (*wait_async_info) (void *async_info);
538 int (*uname) (struct regina_utsname *name);
539 } OS_Dep_funcs;
541 #include "regina64.h"
544 #endif /* REGINA_TYPES_H_INCLUDED */