source: 2.19_branch/Sibyl/RTL/REXXSAA.PAS@ 376

Last change on this file since 376 was 8, checked in by RBRi, 19 years ago

+ rest of sibyl stuff

  • Property svn:eol-style set to native
File size: 15.5 KB
Line 
1UNIT REXXSAA;
2
3{**************************************************************************
4* *
5* Module Name: REXXSAA.PAS *
6* *
7* OS/2 REXX Interface *
8* *
9* *
10***************************************************************************}
11
12INTERFACE
13
14USES OS2Def;
15
16TYPE
17 PRXSTRING=^RXSTRING;
18 RXSTRING=RECORD
19 strlength:LONGWORD;
20 strptr:PChar;
21 END;
22
23CONST
24 RXAUTOBUFLEN = 256;
25
26TYPE
27 PRXSYSEXIT=^RXSYSEXIT;
28 RXSYSEXIT=RECORD
29 sysexit_name:PChar;
30 sysexit_code:LONGINT;
31 END;
32
33CONST
34 RXCOMMAND =0;
35 RXSUBROUTINE =1;
36 RXFUNCTION =2;
37
38CONST
39 RXSUBCOM_DROPPABLE =$00;
40 RXSUBCOM_NONDROP =$01;
41
42CONST
43 RXSUBCOM_ISREG =$01;
44 RXSUBCOM_ERROR =$01;
45 RXSUBCOM_FAILURE =$02;
46 RXSUBCOM_BADENTRY =1001;
47 RXSUBCOM_NOEMEM =1002;
48 RXSUBCOM_BADTYPE =1003;
49 RXSUBCOM_NOTINIT =1004;
50 RXSUBCOM_OK = 0;
51 RXSUBCOM_DUP =10;
52 RXSUBCOM_MAXREG =20;
53 RXSUBCOM_NOTREG =30;
54 RXSUBCOM_NOCANDROP =40;
55 RXSUBCOM_LOADERR =50;
56 RXSUBCOM_NOPROC =127;
57
58CONST
59 RXSHV_SET =$00; /* Set var from given value */
60 RXSHV_FETCH =$01; /* Copy value of var to buffer */
61 RXSHV_DROPV =$02; /* Drop variable */
62 RXSHV_SYSET =$03; /* Symbolic name Set variable */
63 RXSHV_SYFET =$04; /* Symbolic name Fetch variable*/
64 RXSHV_SYDRO =$05; /* Symbolic name Drop variable */
65 RXSHV_NEXTV =$06; /* Fetch "next" variable */
66 RXSHV_PRIV =$07; /* Fetch private information */
67 RXSHV_EXIT =$08; /* Set function exit value */
68
69 RXSHV_NOAVL =144; /* Interface not available */
70
71 RXSHV_OK =$00; /* Execution was OK */
72 RXSHV_NEWV =$01; /* Variable did not exist */
73 RXSHV_LVAR =$02; /* Last var trans via SHVNEXTV */
74 RXSHV_TRUNC =$04; /* Truncation occurred-Fetch */
75 RXSHV_BADN =$08; /* Invalid variable name */
76 RXSHV_MEMFL =$10; /* Out of memory failure */
77 RXSHV_BADF =$80; /* Invalid funct code (shvcode)*/
78
79TYPE
80 PSHVBLOCK=^SHVBLOCK;
81 SHVBLOCK=RECORD
82 shvnext:PSHVBLOCK;
83 shvname:RXSTRING;
84 shvvalue:RXSTRING;
85 shvnamelen:ULONG;
86 shvvaluelen:ULONG;
87 shvcode:BYTE;
88 shvret:BYTE;
89 END;
90
91CONST
92 RXFUNC_DYNALINK =1; /* Function Available in DLL */
93 RXFUNC_CALLENTRY =2; /* Registered as mem entry pt.*/
94
95 RXFUNC_OK =0; /* REXX-API Call Successful */
96 RXFUNC_DEFINED =10; /* Function Defined in AFT */
97 RXFUNC_NOMEM =20; /* Not Enough Mem to Add */
98 RXFUNC_NOTREG =30; /* Funct Not Registered in AFT*/
99 RXFUNC_MODNOTFND =40; /* Funct Dll Module Not Found */
100 RXFUNC_ENTNOTFND =50; /* Funct Entry Point Not Found*/
101 RXFUNC_NOTINIT =60; /* API not initialized */
102 RXFUNC_BADTYPE =70; /* Bad function type */
103
104 RXEXIT_DROPPABLE =$00; /* handler to be dropped by all*/
105 RXEXIT_NONDROP =$01; /* process with same PID as the*/
106 /* registrant may drop environ */
107
108 RXEXIT_HANDLED =0; /* Exit handled exit event */
109 RXEXIT_NOT_HANDLED =1; /* Exit passes on exit event */
110 RXEXIT_RAISE_ERROR =-1; /* Exit handler error occurred */
111
112 RXEXIT_ISREG =$01; /* Exit is registered */
113 RXEXIT_ERROR =$01; /* Exit Ended in Error */
114 RXEXIT_FAILURE =$02; /* Exit Ended in Failure */
115 RXEXIT_BADENTRY =1001; /* Invalid Entry Conditions */
116 RXEXIT_NOEMEM =1002; /* Insuff stor to complete req */
117 RXEXIT_BADTYPE =1003; /* Bad registration type. */
118 RXEXIT_NOTINIT =1004; /* API system not initialized. */
119 RXEXIT_OK = 0; /* Function Complete */
120 RXEXIT_DUP =10; /* Duplicate Exit Name- */
121 /* but Registration Completed */
122
123 RXEXIT_MAXREG =20; /* Cannot register more */
124 /* handlers */
125 RXEXIT_NOTREG =30; /* Name Not Registered */
126 RXEXIT_NOCANDROP =40; /* Name not droppable */
127 RXEXIT_LOADERR =50; /* Could not load function */
128 RXEXIT_NOPROC =127; /* RXEXIT routine - not found */
129
130 RXENDLST =0; /* End of exit list. */
131 RXFNC =2; /* Process external functions. */
132 RXFNCCAL =1; /* subcode value. */
133 RXCMD =3; /* Process host commands. */
134 RXCMDHST =1; /* subcode value. */
135 RXMSQ =4; /* Manipulate queue. */
136 RXMSQPLL =1; /* Pull a line from queue */
137 RXMSQPSH =2; /* Place a line on queue */
138 RXMSQSIZ =3; /* Return num of lines on queue*/
139 RXMSQNAM =20; /* Set active queue name */
140 RXSIO =5; /* Session I/O. */
141 RXSIOSAY =1; /* SAY a line to STDOUT */
142 RXSIOTRC =2; /* Trace output */
143 RXSIOTRD =3; /* Read from char stream */
144 RXSIODTR =4; /* DEBUG read from char stream */
145 RXSIOTLL =5; /* Return linelength(N/A OS/2) */
146 RXHLT =7; /* Halt processing. */
147 RXHLTCLR =1; /* Clear HALT indicator */
148 RXHLTTST =2; /* Test HALT indicator */
149 RXTRC =8; /* Test ext trace indicator. */
150 RXTRCTST =1; /* subcode value. */
151 RXINI =9; /* Initialization processing. */
152 RXINIEXT =1; /* subcode value. */
153 RXTER =10; /* Termination processing. */
154 RXTEREXT =1; /* subcode value. */
155 RXNOOFEXITS =11; /* 1 + largest exit number. */
156
157TYPE
158 PEXIT=PUCHAR;
159 PFN=POINTER;
160
161CONST
162 RXARI_OK =0; /* Interface completed */
163 RXARI_NOT_FOUND =1; /* Target program not found */
164 RXARI_PROCESSING_ERROR =2; /* Error processing request */
165
166 RXMACRO_SEARCH_BEFORE =1; /* Beginning of search order */
167 RXMACRO_SEARCH_AFTER =2; /* End of search order */
168
169 RXMACRO_OK =0; /* Macro interface completed */
170 RXMACRO_NO_STORAGE =1; /* Not Enough Storage Available*/
171 RXMACRO_NOT_FOUND =2; /* Requested function not found*/
172 RXMACRO_EXTENSION_REQUIRED =3; /* File ext required for save */
173 RXMACRO_ALREADY_EXISTS =4; /* Macro functions exist */
174 RXMACRO_FILE_ERROR =5; /* File I/O error in save/load */
175 RXMACRO_SIGNATURE_ERROR =6; /* Incorrect format for load */
176 RXMACRO_SOURCE_NOT_FOUND =7; /* Requested cannot be found */
177 RXMACRO_INVALID_POSITION =8; /* Invalid search order pos */
178 RXMACRO_NOT_INIT =9; /* API not initialized */
179
180TYPE
181 RXARGUMENTS = array[0..0] of RXString;
182
183 RexxFunctionHandler=FUNCTION(Name:PChar;ul:ULONG;
184 VAR rxArgs:RXARGUMENTS;
185 VAR qName:CSTRING;
186 VAR result:RXSTRING):ULONG;
187
188 RxFnCCal_Parm = RECORD
189 rxfnc_flags: Byte;
190 rxfnc_name: PChar;
191 rxfnc_namel: Word;
192 rxfnc_que: PChar;
193 rxfnc_quel: Word;
194 rxfnc_argc: Word;
195 rxfnc_argv: PRxString;
196 rxfnc_retc: RxString;
197 END;
198
199CONST
200
201 rxfcfail = $01; { Command failed. }
202 rxfcerr = $02; { Command ERROR occurred. }
203
204TYPE
205
206 RxCmdHst_Parm = RECORD
207 rxcmd_flags: Byte;
208 rxcmd_address: PChar;
209 rxcmd_addressl: Word;
210 rxcmd_dll: PChar;
211 rxcmd_dll_len: Word;
212 rxcmd_command: RxString;
213 rxcmd_retc: RxString;
214 END;
215
216 RxMsqPll_Parm = RECORD
217 rxmsq_retc: RxString;
218 END;
219
220CONST
221 rxfmlifo = $01; { Stack entry LIFO if set }
222
223TYPE
224 RxMsqPsh_Parm = RECORD
225 rxmsq_flags: Byte;
226 rxmsq_value: RxString
227 END;
228
229 RxMsqSiz_Parm = RECORD
230 rxmsq_size: ULong;
231 END;
232
233 RxMsqNam_Parm = RECORD
234 rxmsq_name: RxString;
235 END;
236
237 RxSioSay_Parm = RECORD
238 rxsio_string: RxString;
239 END;
240
241 RxSioTrc_Parm = RECORD
242 rxsio_string: RxString;
243 END;
244
245 RxSioTrd_Parm = RECORD
246 rxsiotrd_retc: RxString;
247 END;
248
249 RxSioDtr_Parm = RECORD
250 rxsiodtr_retc: RxString;
251 END;
252
253CONST
254 rxfhhalt = $01; { Set if HALT occurred. }
255
256TYPE
257 RxHltTst_Parm = RECORD
258 rxhlt_flags: Byte;
259 END;
260
261CONST
262 rxftrace = $01; { Set to run external trace. }
263
264TYPE
265 RxTrcTst_Parm = RECORD
266 rxtrc_flags: Byte;
267 END;
268
269IMPORTS
270 FUNCTION RexxStart (ArgC:Long;VAR ArgV:RxString;
271 VAR FileName:CSTRING;
272 VAR Proc:RxString;
273 VAR Env:CSTRING;
274 rType:Long;
275 VAR Exit:RxSysExit;
276 var Ret:Word;
277 var RetVal:RxString):LONG;
278 APIENTRY; 'REXX' INDEX 1;
279 FUNCTION RexxRegisterSubcomDll(CONST Name:CSTRING;
280 CONST DllName:CSTRING;
281 CONST ProcName:CSTRING;
282 VAR UserArea;
283 Authority:LONGWORD):APIRET;
284 APIENTRY; 'REXXAPI' INDEX 6;
285 FUNCTION RexxRegisterSubcomExe(Const HandlerName:CSTRING;
286 HandlerAddr:PFN;
287 VAR UserArea):APIRET;
288 APIENTRY; 'REXXAPI' INDEX 7;
289 FUNCTION RexxQuerySubcom(CONST EnvName:CSTRING;
290 CONST DllName:CSTRING;
291 VAR ExCode:WORD;
292 VAR User:WORD):APIRET;
293 APIENTRY; 'REXXAPI' INDEX 8;
294 FUNCTION RexxDeregisterSubcom(CONST EnvName:CSTRING;
295 CONST DllName:CSTRING):APIRET;
296 APIENTRY; 'REXXAPI' INDEX 9;
297 FUNCTION RexxVariablePool(VAR block:SHVBLOCK):APIRET;
298 APIENTRY; 'REXX' INDEX 2;
299 FUNCTION RexxRegisterFunctionDll(CONST FuncName:CSTRING;
300 CONST DllName:CSTRING;
301 CONST Entry:CSTRING):APIRET;
302 APIENTRY; 'REXXAPI' INDEX 17;
303 FUNCTION RexxRegisterFunctionExe(CONST FuncName:CSTRING;
304 Entry:PFN):APIRET;
305 APIENTRY; 'REXXAPI' INDEX 18;
306 FUNCTION RexxDeregisterFunction(CONST Name:CSTRING):APIRET;
307 APIENTRY; 'REXXAPI' INDEX 19;
308 FUNCTION RexxQueryFunction(CONST Name:CSTRING):APIRET;
309 APIENTRY; 'REXXAPI' INDEX 20;
310 FUNCTION RexxRegisterExitDll(CONST Handler:CSTRING;
311 CONST DllName:CSTRING;
312 CONST ProcName:CSTRING;
313 VAR UserArea;
314 authority:ULONG):APIRET;
315 APIENTRY; 'REXXAPI' INDEX 11;
316 FUNCTION RexxRegisterExitExe(CONST Handler:CSTRING;
317 Address:PFN;
318 VAR UserArea):APIRET;
319 APIENTRY; 'REXXAPI' INDEX 12;
320 FUNCTION RexxDeregisterExit(CONST Name:CSTRING;
321 CONST DllName:CSTRING):APIRET;
322 APIENTRY; 'REXXAPI' INDEX 13;
323 FUNCTION RexxQueryExit(CONST ExitName:CSTRING;
324 CONST DllName:CSTRING;
325 VAR ExistanceFlag:USHORT;
326 VAR UserArea):APIRET;
327 APIENTRY; 'REXXAPI' INDEX 14;
328 FUNCTION RexxSetHalt(apid:PID;atid:TID):APIRET;
329 APIENTRY; 'REXX' INDEX 3;
330 FUNCTION RexxSetTrace(apid:PID;atid:TID):APIRET;
331 APIENTRY; 'REXX' INDEX 4;
332 FUNCTION RexxResetTrace(apid:PID;atid:TID):APIRET;
333 APIENTRY; 'REXXAPI' INDEX 5;
334 FUNCTION RexxAddMacro(CONST FuncName:CSTRING;
335 CONST FileName:CSTRING;
336 searchpos:ULONG):APIRET;
337 APIENTRY; 'REXXAPI' INDEX 22;
338 FUNCTION RexxDropMacro(CONST Name:CSTRING):APIRET;
339 APIENTRY; 'REXXAPI' INDEX 23;
340 FUNCTION RexxSaveMacroSpace(argcount:ULONG;
341 VAR NameList:PChar;
342 CONST FileName:CSTRING):APIRET;
343 APIENTRY; 'REXXAPI' INDEX 28;
344 FUNCTION RexxLoadMacroSpace(argcount:ULONG;
345 VAR NameList:PChar;
346 CONST FileName:CSTRING):APIRET;
347 APIENTRY; 'REXXAPI' INDEX 25;
348 FUNCTION RexxQueryMacro(CONST FuncName:CSTRING;
349 VAR posflag:WORD):APIRET;
350 APIENTRY; 'REXXAPI' INDEX 26;
351 FUNCTION RexxReorderMacro(CONST FuncName:CSTRING;
352 NewPos:ULONG):APIRET;
353 APIENTRY; 'REXXAPI' INDEX 27;
354 FUNCTION RexxClearMacroSpace:APIRET;
355 APIENTRY; 'REXXAPI' INDEX 24;
356END;
357
358FUNCTION RXNULLSTRING(CONST r:RXSTRING):BOOLEAN;
359FUNCTION RXZEROLENSTRING(CONST r:RXSTRING):BOOLEAN;
360FUNCTION RXVALIDSTRING(CONST r:RXSTRING):BOOLEAN;
361FUNCTION RXSTRLEN(CONST r:RXSTRING):LONGINT;
362FUNCTION RXSTRPTR(CONST r:RXSTRING):PChar;
363PROCEDURE MAKERXSTRING(VAR r:RXSTRING;p:PChar;l:LONGINT);
364
365IMPLEMENTATION
366
367FUNCTION RXNULLSTRING(CONST r:RXSTRING):BOOLEAN;
368BEGIN
369 result:=r.strptr=NIL;
370END;
371
372FUNCTION RXZEROLENSTRING(CONST r:RXSTRING):BOOLEAN;
373BEGIN
374 result:=((r.strptr<>NIL)AND(r.strlength=0));
375END;
376
377FUNCTION RXVALIDSTRING(CONST r:RXSTRING):BOOLEAN;
378BEGIN
379 result:=((r.strptr<>NIL)AND(r.strlength>0));
380END;
381
382FUNCTION RXSTRLEN(CONST r:RXSTRING):LONGINT;
383BEGIN
384 IF RXNULLSTRING(r) THEN result:=0
385 ELSE result:=r.strlength;
386END;
387
388FUNCTION RXSTRPTR(CONST r:RXSTRING):PChar;
389BEGIN
390 result:=r.strptr;
391END;
392
393PROCEDURE MAKERXSTRING(VAR r:RXSTRING;p:PChar;l:LONGINT);
394BEGIN
395 r.strptr:=p;
396 r.strlength:=l;
397END;
398
399BEGIN
400END.
Note: See TracBrowser for help on using the repository browser.