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.
37 unsigned r
; /* read */
38 unsigned w
; /* write */
39 unsigned c
; /* collisions */
40 unsigned e
; /* elements */
44 typedef struct varbox
{
46 variableptr next
, prev
, realbox
;
47 struct strengtype
*name
, *value
;
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). */
58 /* typedef int bool ; */
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 */
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 */
97 PROTECTED_DelayedScriptExit
,
98 PROTECTED_DelayedInterpreterExit
,
99 PROTECTED_DelayedRexxSignal
100 } delayed_error_type_t
;
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
120 typedef struct pparambox
*paramboxptr
;
121 typedef const struct pparambox
*cparamboxptr
;
122 typedef struct pparambox
{
125 struct strengtype
*value
;
128 typedef struct tnode
{
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 */
135 struct strengtype
*name
;
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
) ;
152 int trace_only
; /* For labels */
155 unsigned long nodeindex
; /* for an effectiv relocation, never change! */
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
;
168 typedef struct labelboxx
*labelboxptr
;
169 typedef const struct labelboxx
*clabelboxptr
;
170 typedef struct labelboxx
{
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 */
187 typedef struct sig_type
192 int invoke
; /* is true if invoked with SIGNAL */
193 int rc
, subrc
, lineno
;
196 typedef void (*signal_handler
)(int);
198 typedef struct __regina_option
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
210 * A FIFO operation will happen at the bottom end.
212 struct _StackLine
*higher
;
213 struct _StackLine
*lower
;
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.
233 /* A queue is one of different implementations of queue types.
234 * See the picture and the description at the beginning of stack.c.
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.
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 :-(
251 * Content: We have a double linked list of buffers. See Buffer
257 /* This is the count of buffers including the zeroth buffer */
260 /* This is the overall count of elements in all buffers */
263 struct { /* external: e */
265 * The port number for the current connection to an external rxstack
266 * Valid values: 1..0xFFFF, unused: 0
270 * The socket fd for the current connection to an external rxstack
271 * Valid values: not -1, unused/error: -1
275 * The server address of the current connection. Used to determine if
276 * we need to disconnect from one rxstack server and connect to
278 * The true data type is a 32 bit system depending type.
279 * Valid values: not 0, unused: 0
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
290 Buffer t
; /* temp: t */
294 typedef struct { /* one for each redirection in environment */
295 streng
*name
; /* name if any, but not expanded */
297 streng
*base
; /* "number" if name is a stem */
298 streng
*currname
; /* expanded name + ".number" if name */
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 */
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???() */
326 typedef struct proclevelbox
*proclevel
;
327 typedef const struct proclevelbox
*cproclevel
;
328 typedef struct proclevelbox
{
329 int numfuzz
, currnumsize
, numform
;
332 proclevel prev
, next
;
333 var_hashtable
*vars
;
335 struct strengtype
*environment
, *prev_env
;
336 char tracestat
, traceint
, varflag
; /* MDW 30012002 */
339 jmp_buf *signal_continue
; /* see jump_rexx_signal() */
340 unsigned long options
;
344 typedef struct _ttree
{ /* bucket list of treenodes which allows ultra fast
345 * loading of instore macros.
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 */
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.
362 typedef struct _otree
{ /* bucket list of offscrlines which allows ultra fast
363 * loading of instore macros.
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 */
370 } otree
; /* offsrcline type */
372 typedef struct { /* internal_parser_type is a structure containing data from a
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
;
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 */
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
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
417 char ignore
[4 * 256/8]; /* Allow 256 bit machines */
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 */
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) */
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
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
;
469 jmp_buf *script_exit
; /* see jump_script_exit() */
471 proclevbox
*currlevel0
;
472 struct systeminfobox
*previous
;
474 int cstackcnt
, cstackmax
;
478 internal_parser_type tree
;
482 #ifndef DONT_TYPEDEF_PFN
483 typedef unsigned long (*PFN
)() ;
492 struct library
*next
, *prev
;
500 void *gci_info
; /* for function handlers */
501 unsigned char user_area
[8]; /* for suncommand and exit handlers */
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
516 * init() may map some "stupid" function on advanced function, as for
517 * instance Win9x doesn't support redirection correctly.
520 struct regina_utsname
;
521 typedef struct _OS_Dep_funcs
{
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
);
541 #include "regina64.h"
544 #endif /* REGINA_TYPES_H_INCLUDED */