2 This file is part of the Free Pascal run time library.
4 A file in Amiga system run time library.
5 Copyright (c) 1998 by Nils Sjoholm
6 member of the Amiga RTL development team.
8 See the file COPYING.FPC, included in this distribution,
9 for details about the copyright.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 **********************************************************************}
24 { === rexx/storage.h ==================================================
26 * Copyright (c) 1986, 1987 by William S. Hawes (All Rights Reserved)
28 * =====================================================================
29 * Header file to define ARexx data structures.
33 { The NexxStr structure is used to maintain the internal strings in REXX.
34 * It includes the buffer area for the string and associated attributes.
35 * This is actually a variable-length structure; it is allocated for a
36 * specific length string, and the length is never modified thereafter
37 * (since it's used for recycling).
44 ns_Ivalue
: Longint; { integer value }
45 ns_Length
: Word; { length in bytes (excl null) }
46 ns_Flags
: Byte; { attribute flags }
47 ns_Hash
: Byte; { hash code }
48 ns_Buff
: Array [0..7] of Byte;
49 { buffer area for strings }
50 end; { size: 16 bytes (minimum) }
54 NXADDLEN
= 9; { offset plus null byte }
56 { String attribute flag bit definitions }
58 NSB_KEEP
= 0; { permanent string? }
59 NSB_STRING
= 1; { string form valid? }
60 NSB_NOTNUM
= 2; { non-numeric? }
61 NSB_NUMBER
= 3; { a valid number? }
62 NSB_BINARY
= 4; { integer value saved? }
63 NSB_FLOAT
= 5; { floating point format? }
64 NSB_EXT
= 6; { an external string? }
65 NSB_SOURCE
= 7; { part of the program source? }
67 { The flag form of the string attributes }
78 { Combinations of flags }
80 NSF_INTNUM
= NSF_NUMBER
+ NSF_BINARY
+ NSF_STRING
;
81 NSF_DPNUM
= NSF_NUMBER
+ NSF_FLOAT
;
82 NSF_ALPHA
= NSF_NOTNUM
+ NSF_STRING
;
83 NSF_OWNED
= NSF_SOURCE
+ NSF_EXT
+ NSF_KEEP
;
84 KEEPSTR
= NSF_STRING
+ NSF_SOURCE
+ NSF_NOTNUM
;
85 KEEPNUM
= NSF_STRING
+ NSF_SOURCE
+ NSF_NUMBER
+ NSF_BINARY
;
87 { The RexxArg structure is identical to the NexxStr structure, but
88 * is allocated from system memory rather than from internal storage.
89 * This structure is used for passing arguments to external programs.
90 * It is usually passed as an "argstring", a pointer to the string buffer.
97 ra_Size
: Longint; { total allocated length }
98 ra_Length
: Word; { length of string }
99 ra_Flags
: Byte; { attribute flags }
100 ra_Hash
: Byte; { hash code }
101 ra_Buff
: Array [0..7] of Byte;
103 end; { size: 16 bytes (minimum) }
105 { The RexxMsg structure is used for all communications with REXX
106 * programs. It is an EXEC message with a parameter block appended.
109 pRexxMsg
= ^tRexxMsg
;
111 rm_Node
: tMessage
; { EXEC message structure }
112 rm_TaskBlock
: Pointer; { global structure (private) }
113 rm_LibBase
: Pointer; { library base (private) }
114 rm_Action
: Longint; { command (action) code }
115 rm_Result1
: Longint; { primary result (return code) }
116 rm_Result2
: Longint; { secondary result }
117 rm_Args
: Array [0..15] of STRPTR
;
118 { argument block (ARG0-ARG15) }
120 rm_PassPort
: pMsgPort
; { forwarding port }
121 rm_CommAddr
: STRPTR
; { host address (port name) }
122 rm_FileExt
: STRPTR
; { file extension }
123 rm_Stdin
: Longint; { input stream (filehandle) }
124 rm_Stdout
: Longint; { output stream (filehandle) }
125 rm_avail
: Longint; { future expansion }
126 end; { size: 128 bytes }
130 MAXRMARG
= 15; { maximum arguments }
132 { Command (action) codes for message packets }
134 RXCOMM
= $01000000; { a command-level invocation }
135 RXFUNC
= $02000000; { a function call }
136 RXCLOSE
= $03000000; { close the REXX server }
137 RXQUERY
= $04000000; { query for information }
138 RXADDFH
= $07000000; { add a function host }
139 RXADDLIB
= $08000000; { add a function library }
140 RXREMLIB
= $09000000; { remove a function library }
141 RXADDCON
= $0A000000; { add/update a ClipList string }
142 RXREMCON
= $0B000000; { remove a ClipList string }
143 RXTCOPN
= $0C000000; { open the trace console }
144 RXTCCLS
= $0D000000; { close the trace console }
146 { Command modifier flag bits }
148 RXFB_NOIO
= 16; { suppress I/O inheritance? }
149 RXFB_RESULT
= 17; { result string expected? }
150 RXFB_STRING
= 18; { program is a "string file"? }
151 RXFB_TOKEN
= 19; { tokenize the command line? }
152 RXFB_NONRET
= 20; { a "no-return" message? }
154 { The flag form of the command modifiers }
156 RXFF_NOIO
= $00010000;
157 RXFF_RESULT
= $00020000;
158 RXFF_STRING
= $00040000;
159 RXFF_TOKEN
= $00080000;
160 RXFF_NONRET
= $00100000;
162 RXCODEMASK
= $FF000000;
163 RXARGMASK
= $0000000F;
165 { The RexxRsrc structure is used to manage global resources. Each node
166 * has a name string created as a RexxArg structure, and the total size
167 * of the node is saved in the "rr_Size" field. The REXX systems library
168 * provides functions to allocate and release resource nodes. If special
169 * deletion operations are required, an offset and base can be provided in
170 * "rr_Func" and "rr_Base", respectively. This "autodelete" function will
171 * be called with the base in register A6 and the node in A0.
176 pRexxRsrc
= ^tRexxRsrc
;
179 rr_Func
: Integer; { "auto-delete" offset }
180 rr_Base
: Pointer; { "auto-delete" base }
181 rr_Size
: Longint; { total size of node }
182 rr_Arg1
: Longint; { available ... }
183 rr_Arg2
: Longint; { available ... }
184 end; { size: 32 bytes }
188 { Resource node types }
190 RRT_ANY
= 0; { any node type ... }
191 RRT_LIB
= 1; { a function library }
192 RRT_PORT
= 2; { a public port }
193 RRT_FILE
= 3; { a file IoBuff }
194 RRT_HOST
= 4; { a function host }
195 RRT_CLIP
= 5; { a Clip List node }
197 { The RexxTask structure holds the fields used by REXX to communicate with
198 * external processes, including the client task. It includes the global
199 * data structure (and the base environment). The structure is passed to
200 * the newly-created task in its "wake-up" message.
203 GLOBALSZ
= 200; { total size of GlobalData }
207 pRexxTask
= ^tRexxTask
;
209 rt_Global
: Array [0..GLOBALSZ
-1] of Byte;
210 { global data structure }
211 rt_MsgPort
: tMsgPort
; { global message port }
212 rt_Flags
: Byte; { task flag bits }
213 rt_SigBit
: Shortint
; { signal bit }
215 rt_ClientID
: Pointer; { the client's task ID }
216 rt_MsgPkt
: Pointer; { the packet being processed }
217 rt_TaskID
: Pointer; { our task ID }
218 rt_RexxPort
: Pointer; { the REXX public port }
220 rt_ErrTrap
: Pointer; { Error trap address }
221 rt_StackPtr
: Pointer; { stack pointer for traps }
223 rt_Header1
: tList
; { Environment list }
224 rt_Header2
: tList
; { Memory freelist }
225 rt_Header3
: tList
; { Memory allocation list }
226 rt_Header4
: tList
; { Files list }
227 rt_Header5
: tList
; { Message Ports List }
232 { Definitions for RexxTask flag bits }
234 RTFB_TRACE
= 0; { external trace flag }
235 RTFB_HALT
= 1; { external halt flag }
236 RTFB_SUSP
= 2; { suspend task? }
237 RTFB_TCUSE
= 3; { trace console in use? }
238 RTFB_WAIT
= 6; { waiting for reply? }
239 RTFB_CLOSE
= 7; { task completed? }
241 { Definitions for memory allocation constants }
243 MEMQUANT
= 16; { quantum of memory space }
244 MEMMASK
= $FFFFFFF0; { mask for rounding the size }
246 MEMQUICK
= 1; { EXEC flags: MEMF_PUBLIC }
247 MEMCLEAR
= $00010000; { EXEC flags: MEMF_CLEAR }
249 { The SrcNode is a temporary structure used to hold values destined for
250 * a segment array. It is also used to maintain the memory freelist.
255 pSrcNode
= ^tSrcNode
;
257 sn_Succ
: pSrcNode
; { next node }
258 sn_Pred
: pSrcNode
; { previous node }
259 sn_Ptr
: Pointer; { pointer value }
260 sn_Size
: Longint; { size of object }
261 end; { size: 16 bytes }
263 { === rexx/rexxio.h ====================================================
265 * Copyright (c) 1986, 1987 by William S. Hawes. All Rights Reserved.
267 * ======================================================================
268 * Header file for ARexx Input/Output related structures
273 RXBUFFSZ
= 204; { buffer length }
276 * The IoBuff is a resource node used to maintain the File List. Nodes
277 * are allocated and linked into the list whenever a file is opened.
284 iobNode
: tRexxRsrc
; { structure for files/strings }
285 iobRpt
: Pointer; { read/write pointer }
286 iobRct
: Longint; { character count }
287 iobDFH
: Longint; { DOS filehandle }
288 iobLock
: Longint; { DOS lock }
289 iobBct
: Longint; { buffer length }
290 iobArea
: Array [0..RXBUFFSZ
-1] of Byte;
292 end; { size: 256 bytes }
296 { Access mode definitions }
298 RXIO_EXIST
= -1; { an external filehandle }
299 RXIO_STRF
= 0; { a "string file" }
300 RXIO_READ
= 1; { read-only access }
301 RXIO_WRITE
= 2; { write mode }
302 RXIO_APPEND
= 3; { append mode (existing file) }
305 * Offset anchors for SeekF()
308 RXIO_BEGIN
= -1; { relative to start }
309 RXIO_CURR
= 0; { relative to current position }
310 RXIO_END
= 1; { relative to end }
313 * A message port structure, maintained as a resource node. The ReplyList
314 * holds packets that have been received but haven't been replied.
319 pRexxMsgPort
= ^tRexxMsgPort
;
320 tRexxMsgPort
= record
321 rmp_Node
: tRexxRsrc
; { linkage node }
322 rmp_Port
: tMsgPort
; { the message port }
323 rmp_ReplyList
: tList
; { messages awaiting reply }
332 DT_DEV
= 0; { a device }
333 DT_DIR
= 1; { an ASSIGNed directory }
334 DT_VOL
= 2; { a volume }
337 * Private DOS packet types
340 ACTION_STACK
= 2002; { stack a line }
341 ACTION_QUEUE
= 2003; { queue a line }
343 { === rexx/rxslib.h ===================================================
345 * Copyright (c) 1986, 1987, 1989 by William S. Hawes (All Rights Reserved)
347 * =====================================================================
348 * The header file for the REXX Systems Library
351 { Some macro definitions }
355 RXSNAME
: PChar
= 'rexxsyslib.library';
356 RXSID
: PChar
= 'rexxsyslib 1.06 (07 MAR 88)';
357 RXSDIR
: PChar
= 'REXX';
358 RXSTNAME
: PChar
= 'ARexx';
360 { The REXX systems library structure. This should be considered as }
361 { semi-private and read-only, except for documented exceptions. }
367 rl_Node
: tLibrary
; { EXEC library node }
368 rl_Flags
: Byte; { global flags }
370 rl_SysBase
: Pointer; { EXEC library base }
371 rl_DOSBase
: Pointer; { DOS library base }
372 rl_IeeeDPBase
: Pointer; { IEEE DP math library base }
373 rl_SegList
: Longint; { library seglist }
374 rl_NIL
: Longint; { global NIL: filehandle }
375 rl_Chunk
: Longint; { allocation quantum }
376 rl_MaxNest
: Longint; { maximum expression nesting }
377 rl_NULL
: pNexxStr
; { static string: NULL }
378 rl_FALSE
: pNexxStr
; { static string: FALSE }
379 rl_TRUE
: pNexxStr
; { static string: TRUE }
380 rl_REXX
: pNexxStr
; { static string: REXX }
381 rl_COMMAND
: pNexxStr
; { static string: COMMAND }
382 rl_STDIN
: pNexxStr
; { static string: STDIN }
383 rl_STDOUT
: pNexxStr
; { static string: STDOUT }
384 rl_STDERR
: pNexxStr
; { static string: STDERR }
385 rl_Version
: STRPTR
; { version/configuration string }
387 rl_TaskName
: STRPTR
; { name string for tasks }
388 rl_TaskPri
: Longint; { starting priority }
389 rl_TaskSeg
: Longint; { startup seglist }
390 rl_StackSize
: Longint; { stack size }
391 rl_RexxDir
: STRPTR
; { REXX directory }
392 rl_CTABLE
: STRPTR
; { character attribute table }
393 rl_Notice
: STRPTR
; { copyright notice }
395 rl_RexxPort
: tMsgPort
; { REXX public port }
396 rl_ReadLock
: Word; { lock count }
397 rl_TraceFH
: Longint; { global trace console }
398 rl_TaskList
: tList
; { REXX task list }
399 rl_NumTask
: Integer; { task count }
400 rl_LibList
: tList
; { Library List header }
401 rl_NumLib
: Integer; { library count }
402 rl_ClipList
: tList
; { ClipList header }
403 rl_NumClip
: Integer; { clip node count }
404 rl_MsgList
: tList
; { pending messages }
405 rl_NumMsg
: Integer; { pending count }
406 rl_PgmList
: tList
; { cached programs }
407 rl_NumPgm
: Integer; { program count }
409 rl_TraceCnt
: Word; { usage count for trace console }
415 { Global flag bit definitions for RexxMaster }
416 RLFB_TRACE
= RTFB_TRACE
; { interactive tracing? }
417 RLFB_HALT
= RTFB_HALT
; { halt execution? }
418 RLFB_SUSP
= RTFB_SUSP
; { suspend execution? }
419 RLFB_STOP
= 6; { deny further invocations }
420 RLFB_CLOSE
= 7; { close the master }
424 { Initialization constants }
426 RXSVERS
= 34; { main version }
427 RXSREV
= 7; { revision }
428 RXSALLOC
= $800000; { maximum allocation }
429 RXSCHUNK
= 1024; { allocation quantum }
430 RXSNEST
= 32; { expression nesting limit }
431 RXSTPRI
= 0; { task priority }
432 RXSSTACK
= 4096; { stack size }
433 RXSLISTH
= 5; { number of list headers }
435 { Character attribute flag bits used in REXX. }
437 CTB_SPACE
= 0; { white space characters }
438 CTB_DIGIT
= 1; { decimal digits 0-9 }
439 CTB_ALPHA
= 2; { alphabetic characters }
440 CTB_REXXSYM
= 3; { REXX symbol characters }
441 CTB_REXXOPR
= 4; { REXX operator characters }
442 CTB_REXXSPC
= 5; { REXX special symbols }
443 CTB_UPPER
= 6; { UPPERCASE alphabetic }
444 CTB_LOWER
= 7; { lowercase alphabetic }
458 VAR RexxSysBase
: pLibrary
;
460 PROCEDURE ClearRexxMsg(msgptr
: pRexxMsg
; count
: ULONG
);
461 FUNCTION CreateArgstring(argstring
: pCHAR
; length
: ULONG
) : pCHAR
;
462 FUNCTION CreateRexxMsg(port
: pMsgPort
; extension
: pCHAR
; host
: pCHAR
) : pRexxMsg
;
463 PROCEDURE DeleteArgstring(argstring
: pCHAR
);
464 PROCEDURE DeleteRexxMsg(packet
: pRexxMsg
);
465 FUNCTION FillRexxMsg(msgptr
: pRexxMsg
; count
: ULONG
; mask
: ULONG
) : BOOLEAN;
466 FUNCTION IsRexxMsg(msgptr
: pRexxMsg
) : BOOLEAN;
467 FUNCTION LengthArgstring(argstring
: pCHAR
) : ULONG
;
468 PROCEDURE LockRexxBase(resource
: ULONG
);
469 PROCEDURE UnlockRexxBase(resource
: ULONG
);
473 PROCEDURE ClearRexxMsg(msgptr
: pRexxMsg
; count
: ULONG
);
479 MOVEA
.L RexxSysBase
,A6
485 FUNCTION CreateArgstring(argstring
: pCHAR
; length
: ULONG
) : pCHAR
;
491 MOVEA
.L RexxSysBase
,A6
498 FUNCTION CreateRexxMsg(port
: pMsgPort
; extension
: pCHAR
; host
: pCHAR
) : pRexxMsg
;
505 MOVEA
.L RexxSysBase
,A6
512 PROCEDURE DeleteArgstring(argstring
: pCHAR
);
517 MOVEA
.L RexxSysBase
,A6
523 PROCEDURE DeleteRexxMsg(packet
: pRexxMsg
);
528 MOVEA
.L RexxSysBase
,A6
534 FUNCTION FillRexxMsg(msgptr
: pRexxMsg
; count
: ULONG
; mask
: ULONG
) : BOOLEAN;
541 MOVEA
.L RexxSysBase
,A6
547 @end: MOVE
.B D0
,@RESULT
551 FUNCTION IsRexxMsg(msgptr
: pRexxMsg
) : BOOLEAN;
556 MOVEA
.L RexxSysBase
,A6
562 @end: MOVE
.B D0
,@RESULT
566 FUNCTION LengthArgstring(argstring
: pCHAR
) : ULONG
;
571 MOVEA
.L RexxSysBase
,A6
578 PROCEDURE LockRexxBase(resource
: ULONG
);
583 MOVEA
.L RexxSysBase
,A6
589 PROCEDURE UnlockRexxBase(resource
: ULONG
);
594 MOVEA
.L RexxSysBase
,A6
600 END. (* UNIT REXXSYSLIB *)