rexxsaa.pp 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  1. {
  2. Copyright (c) 1989, 1991 IBM Corporation
  3. Copyright (c) 2003 by Yuri Prokushev ([email protected]).
  4. REXX SAA Interface
  5. This program is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU Library General Public License (LGPL) as
  7. published by the Free Software Foundation; either version 2 of the
  8. License, or (at your option) any later version. This program is
  9. distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. FITNESS FOR A PARTICULAR PURPOSE.
  12. See the GNU Library General Public License for more details. You should
  13. have received a copy of the GNU Library General Public License along
  14. with this program; if not, write to the Free Software Foundation, Inc.,
  15. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. **********************************************************************}
  17. {
  18. @abstract(REXX SAA interface)
  19. @author(Yuri Prokushev ([email protected]))
  20. @created(01 Feb 2003)
  21. @lastmod(13 Feb 2003)
  22. REXX SAA Interface
  23. Warning: This code is alfa. Future versions of this unit will propably
  24. not be compatible.
  25. }
  26. (*********************************************************************
  27. *
  28. * REXX SAA Interface
  29. *
  30. *********************************************************************)
  31. Unit RexxSAA;
  32. Interface
  33. {$Mode ObjFpc}
  34. Const
  35. {$IFDEF OS2}
  36. REXX='REXX';
  37. REXXAPI='REXXAPI';
  38. {$ELSE}
  39. {$IFDEF UNIX}
  40. REXX='libregina';
  41. REXXAPI='libregina';
  42. {$ELSE}
  43. REXX='REGINA';
  44. REXXAPI='REGINA';
  45. {$ENDIF}
  46. {$ENDIF}
  47. //********************************************************************
  48. // *
  49. // Common *
  50. // *
  51. //********************************************************************
  52. //* This section defines return codes and constants that are the */
  53. //* same for both 16-bit and 32-bit REXX calls. */
  54. //Structure for external interface string (RXSTRING)
  55. Type
  56. RxString=record
  57. StrLength: Cardinal; // Length of string
  58. StrPtr: PChar; // Pointer to a string
  59. end;
  60. PRxString=^RxString; // pointer to a RXSTRING
  61. Const
  62. RxAutoBufLen=256;
  63. Type
  64. PFN=Pointer;
  65. //Structure for system exit block (RXSYSEXIT) 32-bit
  66. Type
  67. RxSysExit=record
  68. sysexit_name: PChar; // subcom enviro for sysexit
  69. sysexit_code: Longint; // sysexit function code
  70. end;
  71. PRxSysExit=^RxSysExit; // pointer to a RXSYSEXIT
  72. // Macros for RXSTRING manipulation
  73. Function RXNULLSTRING(CONST r:RXSTRING):BOOLEAN;
  74. Function RXZEROLENSTRING(CONST r:RXSTRING):BOOLEAN;
  75. Function RXVALIDSTRING(CONST r:RXSTRING):BOOLEAN;
  76. Function RXSTRLEN(CONST r:RXSTRING):LONGINT;
  77. Function RXSTRPTR(CONST r:RXSTRING):PChar;
  78. Procedure MAKERXSTRING(VAR r:RXSTRING;p:PChar;l:LONGINT);
  79. //Call type codes for use on interpreter startup
  80. Const
  81. RxCommand=0; // Program called as Command
  82. RxSubroutine=1; // Program called as Subroutin
  83. RxFunction=2; // Program called as Function
  84. // Subcommand Interface defines
  85. // Drop Authority for RXSUBCOM interface
  86. Const
  87. RxSubCom_Droppable=$00; // handler to be dropped by all
  88. RxSubCom_Nondrop=$01; // process with same PID as the
  89. // registrant may drop environ
  90. // Return Codes from RXSUBCOM interface
  91. Const
  92. RXSUBCOM_ISREG = $01; // Subcommand is registered
  93. RXSUBCOM_ERROR = $01; // Subcommand Ended in Error
  94. RXSUBCOM_FAILURE = $02; // Subcommand Ended in Failure
  95. RXSUBCOM_BADENTRY = 1001; // Invalid Entry Conditions
  96. RXSUBCOM_NOEMEM = 1002; // Insuff stor to complete req
  97. RXSUBCOM_BADTYPE = 1003; // Bad registration type.
  98. RXSUBCOM_NOTINIT = 1004; // API system not initialized.
  99. RXSUBCOM_OK = 0; // Function Complete
  100. RXSUBCOM_DUP = 10; // Duplicate Environment Name-
  101. // but Registration Completed
  102. RXSUBCOM_MAXREG = 20; // Cannot register more
  103. // handlers
  104. RXSUBCOM_NOTREG = 30; // Name Not Registered
  105. RXSUBCOM_NOCANDROP = 40; // Name not droppable
  106. RXSUBCOM_LOADERR = 50; // Could not load function
  107. RXSUBCOM_NOPROC =127; // RXSUBCOM routine - not found
  108. // Shared Variable Pool Interface defines
  109. // Function Codes for Variable Pool Interface (shvcode)
  110. Const
  111. RXSHV_SET = $00; // Set var from given value
  112. RXSHV_FETCH = $01; // Copy value of var to buffer
  113. RXSHV_DROPV = $02; // Drop variable
  114. RXSHV_SYSET = $03; // Symbolic name Set variable
  115. RXSHV_SYFET = $04; // Symbolic name Fetch variable
  116. RXSHV_SYDRO = $05; // Symbolic name Drop variable
  117. RXSHV_NEXTV = $06; // Fetch "next" variable
  118. RXSHV_PRIV = $07; // Fetch private information
  119. RXSHV_EXIT = $08; // Set function exit value
  120. // Return Codes for Variable Pool Interface
  121. Const
  122. RXSHV_NOAVL = 144; // Interface not available
  123. // Return Code Flags for Variable Pool Interface (shvret)
  124. Const
  125. RXSHV_OK = $00; // Execution was OK
  126. RXSHV_NEWV = $01; // Variable did not exist
  127. RXSHV_LVAR = $02; // Last var trans via SHVNEXTV
  128. RXSHV_TRUNC = $04; // Truncation occurred-Fetch
  129. RXSHV_BADN = $08; // Invalid variable name
  130. RXSHV_MEMFL = $10; // Out of memory failure
  131. RXSHV_BADF = $80; // Invalid funct code (shvcode)
  132. // Structure of Shared Variable Request Block (SHVBLOCK)
  133. Type
  134. PSHVBLOCK=^SHVBLOCK;
  135. SHVBLOCK=record
  136. shvnext: PSHVBLOCK; // pointer to the next block
  137. shvname: RxString; // Pointer to the name buffer
  138. shvvalue: RxString; // Pointer to the value buffer
  139. shvnamelen: Cardinal; // Length of the name value
  140. shvvaluelen: Cardinal; // Length of the fetch value
  141. shvcode: Byte; // Function code for this block
  142. shvret: Byte; // Individual Return Code Flags
  143. end;
  144. // External Function Interface
  145. // Registration Type Identifiers for Available Function Table
  146. Const
  147. RXFUNC_DYNALINK=1; // Function Available in DLL
  148. RXFUNC_CALLENTRY=2; // Registered as mem entry pt.
  149. // Return Codes from RxFunction interface
  150. Const
  151. RXFUNC_OK = 0; // REXX-API Call Successful
  152. RXFUNC_DEFINED = 10; // Function Defined in AFT
  153. RXFUNC_NOMEM = 20; // Not Enough Mem to Add
  154. RXFUNC_NOTREG = 30; // Funct Not Registered in AFT
  155. RXFUNC_MODNOTFND = 40; // Funct Dll Module Not Found
  156. RXFUNC_ENTNOTFND = 50; // Funct Entry Point Not Found
  157. RXFUNC_NOTINIT = 60; // API not initialized
  158. RXFUNC_BADTYPE = 70; // Bad function type
  159. // System Exits defines
  160. // Drop Authority for Rexx Exit interface
  161. Const
  162. RXEXIT_DROPPABLE = $00; // handler to be dropped by all
  163. RXEXIT_NONDROP = $01; // process with same PID as the
  164. // registrant may drop environ
  165. // Exit return actions
  166. Const
  167. RXEXIT_HANDLED = 0; // Exit handled exit event
  168. RXEXIT_NOT_HANDLED = 1; // Exit passes on exit event
  169. RXEXIT_RAISE_ERROR =-1; // Exit handler error occurred
  170. // Return Codes from RXEXIT interface
  171. Const
  172. RXEXIT_ISREG = $01; // Exit is registered
  173. RXEXIT_ERROR = $01; // Exit Ended in Error
  174. RXEXIT_FAILURE = $02; // Exit Ended in Failure
  175. RXEXIT_BADENTRY = 1001; // Invalid Entry Conditions
  176. RXEXIT_NOEMEM = 1002; // Insuff stor to complete req
  177. RXEXIT_BADTYPE = 1003; // Bad registration type.
  178. RXEXIT_NOTINIT = 1004; // API system not initialized.
  179. RXEXIT_OK = 0; // Function Complete
  180. RXEXIT_DUP = 10; // Duplicate Exit Name-
  181. // but Registration Completed
  182. RXEXIT_MAXREG = 20; // Cannot register more
  183. // handlers
  184. RXEXIT_NOTREG = 30; // Name Not Registered
  185. RXEXIT_NOCANDROP = 40; // Name not droppable
  186. RXEXIT_LOADERR = 50; // Could not load function
  187. RXEXIT_NOPROC = 127; // RXEXIT routine - not found
  188. // System Exit function and sub-function definitions
  189. Const
  190. RXENDLST = 0; // End of exit list.
  191. RXFNC = 2; // Process external functions.
  192. RXFNCCAL = 1; // subcode value.
  193. RXCMD = 3; // Process host commands.
  194. RXCMDHST = 1; // subcode value.
  195. RXMSQ = 4; // Manipulate queue.
  196. RXMSQPLL = 1; // Pull a line from queue
  197. RXMSQPSH = 2; // Place a line on queue
  198. RXMSQSIZ = 3; // Return num of lines on queue
  199. RXMSQNAM = 20; // Set active queue name
  200. RXSIO = 5; // Session I/O.
  201. RXSIOSAY = 1; // SAY a line to STDOUT
  202. RXSIOTRC = 2; // Trace output
  203. RXSIOTRD = 3; // Read from char stream
  204. RXSIODTR = 4; // DEBUG read from char stream
  205. RXSIOTLL = 5; // Return linelength(N/A OS/2)
  206. RXHLT = 7; // Halt processing.
  207. RXHLTCLR = 1; // Clear HALT indicator
  208. RXHLTTST = 2; // Test HALT indicator
  209. RXTRC = 8; // Test ext trace indicator.
  210. RXTRCTST = 1; // subcode value.
  211. RXINI = 9; // Initialization processing.
  212. RXINIEXT = 1; // subcode value.
  213. RXTER = 10; // Termination processing.
  214. RXTEREXT = 1; // subcode value.
  215. RXNOOFEXITS = 11; // 1 + largest exit number.
  216. Type
  217. PEXIT=^Byte; // ptr to exit parameter block
  218. // Asynchronous Request Interface defines
  219. // Return Codes from Asynchronous Request interface
  220. Const
  221. RXARI_OK = 0; // Interface completed
  222. RXARI_NOT_FOUND = 1; // Target program not found
  223. RXARI_PROCESSING_ERROR = 2; // Error processing request
  224. // Macro Space Interface defines
  225. // Registration Search Order Flags
  226. Const
  227. RXMACRO_SEARCH_BEFORE = 1; // Beginning of search order
  228. RXMACRO_SEARCH_AFTER = 2; // End of search order
  229. // Return Codes from RxMacroSpace interface
  230. Const
  231. RXMACRO_OK = 0; // Macro interface completed
  232. RXMACRO_NO_STORAGE = 1; // Not Enough Storage Available
  233. RXMACRO_NOT_FOUND = 2; // Requested function not found
  234. RXMACRO_EXTENSION_REQUIRED= 3; // File ext required for save
  235. RXMACRO_ALREADY_EXISTS = 4; // Macro functions exist
  236. RXMACRO_FILE_ERROR = 5; // File I/O error in save/load
  237. RXMACRO_SIGNATURE_ERROR = 6; // Incorrect format for load
  238. RXMACRO_SOURCE_NOT_FOUND = 7; // Requested cannot be found
  239. RXMACRO_INVALID_POSITION = 8; // Invalid search order pos
  240. RXMACRO_NOT_INIT = 9; // API not initialized
  241. //*********************************************************************/
  242. //* */
  243. //* 32-bit */
  244. //* */
  245. //*********************************************************************/
  246. // Main Entry Point to the REXXSAA Interpreter
  247. Function RexxStart(ArgC: Longint; // Num of args passed to rexx
  248. ArgV: PRXSTRING; // Array of args passed to rex
  249. Filename: PChar; // [d:][path] filename[.ext]
  250. Proc: PRXSTRING; // Loc of rexx proc in memory
  251. Env: PChar; // ASCIIZ initial environment.
  252. rType: Longint; // type (command,subrtn,funct)
  253. Exit_: PRXSYSEXIT; // SysExit env. names & codes
  254. Ret: PInteger; // Ret code from if numeric
  255. RetVal: PRXSTRING): Longint; cdecl; // Retvalue from the rexx proc
  256. Function RexxStart(ArgC: Longint; // Num of args passed to rexx
  257. ArgV: PRXSTRING; // Array of args passed to rex
  258. Filename: PChar; // [d:][path] filename[.ext]
  259. Proc: PRXSTRING; // Loc of rexx proc in memory
  260. Env: PChar; // ASCIIZ initial environment.
  261. rType: Longint; // type (command,subrtn,funct)
  262. Exit_: PRXSYSEXIT; // SysExit env. names & codes
  263. var Ret: Integer; // Ret code from if numeric
  264. var RetVal: RXSTRING): Longint; cdecl; // Retvalue from the rexx proc
  265. // Subcommand Interface
  266. // This type simplifies coding of a Subcommand handler.
  267. Type
  268. RexxSubcomHandler=function(a: PRXSTRING; b: PWord; c: PRXSTRING): Cardinal; cdecl;
  269. // RexxRegisterSubcomDll -- Register a DLL entry point
  270. // as a Subcommand handler
  271. Function RexxRegisterSubcomDll(
  272. HName: PChar; // Name of subcom handler
  273. DllName: PChar; // Name of DLL
  274. ProcName: PChar; // Name of procedure in DLL
  275. UserArea: PWord; // User area
  276. Drop: Cardinal): Cardinal; cdecl; // Drop authority.
  277. // RexxRegisterSubcomExe -- Register an EXE entry point
  278. // as a Subcommand handler
  279. Function RexxRegisterSubcomExe(
  280. HName: PChar; // Name of subcom handler
  281. HandlerAddr: PFn; // address of handler in EXE
  282. UserArea: PWord): Cardinal; cdecl; // User area
  283. // RexxQuerySubcom - Query an environment for Existance
  284. Function RexxQuerySubcom(
  285. EnvName: PChar; // Name of the Environment
  286. DllName: PChar; // DLL Module Name
  287. ExCode: PWord; // Stor for existance code
  288. User: PWord): Cardinal; cdecl; // Stor for user word
  289. Function RexxQuerySubcom(
  290. EnvName: PChar; // Name of the Environment
  291. DllName: PChar; // DLL Module Name
  292. var ExCode: Word; // Stor for existance code
  293. var User: Word): Cardinal; cdecl; // Stor for user word
  294. // RexxDeregisterSubcom - Drop registration of a Subcommand
  295. // environment
  296. Function RexxDeregisterSubcom(
  297. EnvName: PChar; // Name of the Environment
  298. DllName: PChar): Cardinal; cdecl; // DLL Module Name
  299. // Shared Variable Pool Interface
  300. // RexxVariablePool - Request Variable Pool Service
  301. Function RexxVariablePool(Pool: PShvBlock): Cardinal; cdecl;
  302. Function RexxVariablePool(var Pool: ShvBlock): Cardinal; cdecl; // Pointer to list of SHVBLOCKs
  303. // External Function Interface
  304. // This typedef simplifies coding of an External Function.
  305. Type
  306. RexxFunctionHandler=Function(a: PByte;
  307. b: Cardinal;
  308. var c: RXSTRING;
  309. d: PChar;
  310. var e: RXSTRING): Cardinal; cdecl;
  311. // RexxRegisterFunctionDll - Register a function in the AFT
  312. Function RexxRegisterFunctionDll(
  313. FnName: PChar; // Name of function to add
  314. DllName: PChar; // Dll file name (if in dll)
  315. Entry: PChar): Cardinal; cdecl; // Entry in dll
  316. // RexxRegisterFunctionExe - Register a function in the AFT
  317. Function RexxRegisterFunctionExe(
  318. FnName: PChar; // Name of function to add
  319. Entry: PFn): Cardinal; cdecl; // Entry point in EXE
  320. // RexxDeregisterFunction - Delete a function from the AFT
  321. Function RexxDeregisterFunction(FnName: PChar): Cardinal; cdecl; // Name of function to remove
  322. // RexxQueryFunction - Scan the AFT for a function
  323. Function RexxQueryFunction(FnName: PChar): Cardinal; cdecl; // Name of function to find
  324. // System Exits
  325. // Subfunction RXFNCCAL - External Function Calls
  326. //rxfnc_flags flags
  327. const
  328. rxfferr = $01; // Invalid call to routine.
  329. rxffnfnd = $02; // Function not found.
  330. rxffsub = $04; // Called as a subroutine
  331. type
  332. RxFnCCal_Parm = record
  333. rxfnc_flags: Byte; // function flags
  334. rxfnc_name: PChar; // Pointer to function name.
  335. rxfnc_namel: Word; // Length of function name.
  336. rxfnc_que: PChar; // Current queue name.
  337. rxfnc_quel: Word; // Length of queue name.
  338. rxfnc_argc: Word; // Number of args in list.
  339. rxfnc_argv: PRxString; // Pointer to argument list.
  340. rxfnc_retc: RxString; // Return value.
  341. end;
  342. // Subfunction RXCMDHST -- Process Host Commands
  343. // rxcmd_flags flags
  344. const
  345. rxfcfail = $01; // Command failed.
  346. rxfcerr = $02; // Command ERROR occurred.
  347. type
  348. RxCmdHst_Parm = record
  349. rxcmd_flags: Byte; // error/failure flags
  350. rxcmd_address: PChar; // Pointer to address name.
  351. rxcmd_addressl: Word; // Length of address name.
  352. rxcmd_dll: PChar; // dll name for command.
  353. rxcmd_dll_len: Word; // Length of dll name.
  354. rxcmd_command: RxString; // The command string.
  355. rxcmd_retc: RxString; // Pointer to return buffer
  356. end;
  357. // Subfunction RXMSQPLL -- Pull Entry from Queue
  358. RxMsqPll_Parm = record
  359. rxmsq_retc: RxString; // Pointer to dequeued entry
  360. end; // buffer. User allocated.
  361. // Subfunction RXMSQPSH -- Push Entry on Queue
  362. // rxmsq_flags flags
  363. const
  364. rxfmlifo = $01; // Stack entry LIFO if set
  365. type
  366. RxMsqPsh_Parm = record
  367. rxmsq_flags: Byte; // LIFO/FIFO flag
  368. rxmsq_value: RxString // The entry to be pushed.
  369. end;
  370. // Subfunction RXMSQSIZ -- Return the Current Queue Size
  371. Type
  372. RxMsqSiz_Parm = record
  373. rxmsq_size: Cardinal; // Number of Lines in Queue
  374. end;
  375. // Subfunction RXMSQNAM -- Set Current Queue Name
  376. Type
  377. RxMsqNam_Parm = record
  378. rxmsq_name: RxString; // RxString containing
  379. end; // queue name.
  380. // Subfunction RXSIOSAY -- Perform SAY Clause
  381. Type
  382. RxSioSay_Parm = record
  383. rxsio_string: RxString; // String to display.
  384. end;
  385. // Subfunction RXSIOTRC -- Write Trace Output
  386. Type
  387. RxSioTrc_Parm = record
  388. rxsio_string: RxString; // Trace line to display.
  389. end;
  390. // Subfunction RXSIOTRD -- Read Input from the Terminal
  391. Type
  392. RxSioTrd_Parm = record
  393. rxsiotrd_retc: RxString; // RxString for output.
  394. end;
  395. // Subfunction RXSIODTR -- Read Debug Input from the Terminal
  396. Type
  397. RxSioDtr_Parm = record
  398. rxsiodtr_retc: RxString; // RxString for output.
  399. end;
  400. // Subfunction RXHSTTST -- Test for HALT Condition
  401. // rxhlt_flags flags
  402. const
  403. rxfhhalt = $01; // Set if HALT occurred.
  404. type
  405. RxHltTst_Parm = record
  406. rxhlt_flags: Byte; // Set if HALT occurred
  407. end;
  408. // Subfunction RXTRCTST -- Test for TRACE Condition
  409. // rxtrc_flags flags
  410. const
  411. rxftrace = $01; // Set to run external trace.
  412. type
  413. RxTrcTst_Parm = record
  414. rxtrc_flags: Byte; // Set to run external trace
  415. end;
  416. // This typedef simplifies coding of an Exit handler.
  417. Type
  418. RexxExitHandler=function(A: Longint;
  419. B: Longint;
  420. C: PEXIT): Cardinal; cdecl;
  421. // RexxRegisterExitDll - Register a system exit.
  422. Function RexxRegisterExitDll(
  423. HExit: PChar; // Name of the exit handler
  424. DllName: PChar; // Name of the DLL
  425. ProcName: PChar; // Name of the procedure
  426. UserArea: PByte; // User area
  427. Drop: Cardinal): Cardinal; cdecl; // Drop authority
  428. // RexxRegisterExitExe - Register a system exit.
  429. Function RexxRegisterExitExe(
  430. HExit: PChar; // Name of the exit handler
  431. HandlerAddr: PFn; // Address of exit handler
  432. UserArea: PByte): Cardinal; cdecl; // User area
  433. // RexxDeregisterExit - Drop registration of a system exit.
  434. Function RexxDeregisterExit(
  435. ExitName: PChar; // Exit name
  436. DllName: PChar): Cardinal; cdecl; // DLL module name
  437. // RexxQueryExit - Query an exit for existance.
  438. Function RexxQueryExit(
  439. ExitName: PChar; // Exit name
  440. DllName: PChar; // DLL Module name.
  441. var ExFlag: Word; // Existance flag.
  442. UserArea: Pointer): Cardinal; cdecl; // User data.
  443. Function RexxQueryExit(
  444. ExitName: PChar; // Exit name
  445. DllName: PChar; // DLL Module name.
  446. var ExFlag: Word; // Existance flag.
  447. UserArea: PByte): Cardinal; cdecl; // User data.
  448. Function RexxQueryExit(
  449. ExitName: PChar; // Exit name
  450. DllName: PChar; // DLL Module name.
  451. ExFlag: PWord; // Existance flag.
  452. UserArea: PByte): Cardinal; cdecl; // User data.
  453. Function RexxQueryExit(
  454. ExitName: PChar; // Exit name
  455. DllName: PChar; // DLL Module name.
  456. ExFlag: PWord; // Existance flag.
  457. UserArea: Pointer): Cardinal; cdecl; // User data.
  458. // Asynchronous Request Interface
  459. // RexxSetHalt - Request Program Halt
  460. Function RexxSetHalt(
  461. Pid: Longint; // Process Id
  462. Tid: Longint): Cardinal; cdecl; // Thread Id
  463. // RexxSetTrace - Request Program Trace
  464. Function RexxSetTrace(
  465. Pid: Longint; // Process Id
  466. Tid: Longint): Cardinal; cdecl; // Thread Id
  467. // RexxResetTrace - Turn Off Program Trace
  468. Function RexxResetTrace(
  469. Pid: Longint; // Process Id
  470. Tid: Longint): Cardinal; cdecl; // Thread Id
  471. // Macro Space Interface
  472. // RexxAddMacro - Register a function in the Macro Space
  473. Function RexxAddMacro(
  474. FnName: PChar; // Function to add or change
  475. FileName: PChar; // Name of file to get function
  476. SrchPos: Cardinal): Cardinal; cdecl; // Flag indicating search pos
  477. // RexxDropMacro - Remove a function from the Macro Space
  478. Function RexxDropMacro(FnName: PChar): Cardinal; cdecl; // Name of function to remove
  479. // RexxSaveMacroSpace - Save Macro Space functions to a file
  480. Function RexxSaveMacroSpace(
  481. ArgC: Cardinal; // Argument count (0==save all)
  482. var NameLst: PChar; // List of funct names to save
  483. FileName: PChar): Cardinal; cdecl; // File to save functions in
  484. // RexxLoadMacroSpace - Load Macro Space functions from a file
  485. Function RexxLoadMacroSpace(
  486. ArgC: Cardinal; // Argument count (0==load all)
  487. var NameLst: PChar; // List of funct names to load
  488. FileName: PChar): Cardinal; cdecl; // File to load functions from
  489. // RexxQueryMacro - Find a function's search-order position
  490. Function RexxQueryMacro(
  491. FnName: PChar; // Function to search for
  492. var PtrPos: Word): Cardinal; cdecl; // Ptr for position flag return
  493. // RexxReorderMacro - Change a function's search-order
  494. // position
  495. Function RexxReorderMacro(
  496. FnName: PChar; // Name of funct change order
  497. NewPos: Cardinal): Cardinal; cdecl; // New position for function
  498. // RexxClearMacroSpace - Remove all functions from a MacroSpace
  499. Function RexxClearMacroSpace: Cardinal; cdecl; // No Arguments.
  500. (* Not supported yet!!
  501. /* REGINA EXTENSIONS *********************************************************/
  502. /* The following function is an extension to the standard. Never try to
  503. * address the function directly. Use the dynamic linking machanism of
  504. * your operating system instead. This function was introduced in version
  505. * 2.0.
  506. * Returns: ULONG, in lower byte the two-digit fraction part of the version.
  507. * The higher bytes will hold the integer part of the version.
  508. * Examples: 0x10A codes the Version "1.10".
  509. * VersionString will be filled if VersionString is non-NULL.
  510. * If VersionString is non-NULL then there are two possibilities:
  511. * a) VersionString->strlength == 0: VersionString is filled with the
  512. * appropriate values. VersionString->strptr
  513. * is always created.
  514. * b) VersionString->strlength != 0: VersionString->strptr is filled up to
  515. * this value. VersionString->strlength will
  516. * hold the copied bytes.
  517. * Note: A terminating ASCII-zero is appended if there is enough space
  518. * although it is never counted in VersionString.strlength.
  519. * RexxAllocateMemory is used if needed.
  520. */
  521. *)
  522. {
  523. Type
  524. ReginaVersion=Function(var VersionString: RxString);
  525. }
  526. Implementation
  527. Function RexxStart(ArgC: Longint; // Num of args passed to rexx
  528. ArgV: PRXSTRING; // Array of args passed to rex
  529. Filename: PChar; // [d:][path] filename[.ext]
  530. Proc: PRXSTRING; // Loc of rexx proc in memory
  531. Env: PChar; // ASCIIZ initial environment.
  532. rType: Longint; // type (command,subrtn,funct)
  533. Exit_: PRXSYSEXIT; // SysExit env. names & codes
  534. Ret: PInteger; // Ret code from if numeric
  535. RetVal: PRXSTRING): Longint; cdecl; // Retvalue from the rexx proc
  536. external REXX name 'RexxStart';
  537. Function RexxStart(ArgC: Longint; // Num of args passed to rexx
  538. ArgV: PRXSTRING; // Array of args passed to rex
  539. Filename: PChar; // [d:][path] filename[.ext]
  540. Proc: PRXSTRING; // Loc of rexx proc in memory
  541. Env: PChar; // ASCIIZ initial environment.
  542. rType: Longint; // type (command,subrtn,funct)
  543. Exit_: PRXSYSEXIT; // SysExit env. names & codes
  544. var Ret: integer; // Ret code from if numeric
  545. var RetVal: RXSTRING): Longint; cdecl; // Retvalue from the rexx proc
  546. external REXX name 'RexxStart';
  547. Function RexxRegisterSubcomDll(
  548. HName: PChar; // Name of subcom handler
  549. DllName: PChar; // Name of DLL
  550. ProcName: PChar; // Name of procedure in DLL
  551. UserArea: PWord; // User area
  552. Drop: Cardinal): Cardinal; cdecl; // Drop authority.
  553. external REXXAPI name 'RexxRegisterSubcomDll';
  554. Function RexxRegisterSubcomExe(
  555. HName: PChar; // Name of subcom handler
  556. HandlerAddr: PFn; // address of handler in EXE
  557. UserArea: PWord): Cardinal; cdecl; // User area
  558. external REXXAPI name 'RexxRegisterSubcomExe';
  559. Function RexxQuerySubcom(
  560. EnvName: PChar; // Name of the Environment
  561. DllName: PChar; // DLL Module Name
  562. ExCode: PWord; // Stor for existance code
  563. User: PWord): Cardinal; cdecl; // Stor for user word
  564. external REXXAPI name 'RexxQuerySubcom';
  565. Function RexxQuerySubcom(
  566. EnvName: PChar; // Name of the Environment
  567. DllName: PChar; // DLL Module Name
  568. var ExCode: Word; // Stor for existance code
  569. var User: Word): Cardinal; cdecl; // Stor for user word
  570. external REXXAPI name 'RexxQuerySubcom';
  571. Function RexxDeregisterSubcom(
  572. EnvName: PChar; // Name of the Environment
  573. DllName: PChar): Cardinal; cdecl; // DLL Module Name
  574. external REXXAPI name 'RexxDeregisterSubcom';
  575. Function RexxVariablePool(Pool: PShvBlock): Cardinal; cdecl;
  576. external REXX name 'RexxVariablePool';
  577. Function RexxVariablePool(var Pool: ShvBlock): Cardinal; cdecl; // Pointer to list of SHVBLOCKs
  578. external REXX name 'RexxVariablePool';
  579. Function RexxRegisterFunctionDll(
  580. FnName: PChar; // Name of function to add
  581. DllName: PChar; // Dll file name (if in dll)
  582. Entry: PChar): Cardinal; cdecl; // Entry in dll
  583. external REXXAPI name 'RexxRegisterFunctionDll';
  584. Function RexxRegisterFunctionExe(
  585. FnName: PChar; // Name of function to add
  586. Entry: PFn): Cardinal; cdecl; // Entry point in EXE
  587. external REXXAPI name 'RexxRegisterFunctionExe';
  588. Function RexxDeregisterFunction(FnName: PChar): Cardinal; cdecl; // Name of function to remove
  589. external REXXAPI name 'RexxDeregisterFunction';
  590. Function RexxQueryFunction(FnName: PChar): Cardinal; cdecl; // Name of function to find
  591. external REXXAPI name 'RexxQueryFunction';
  592. Function RexxRegisterExitDll(
  593. HExit: PChar; // Name of the exit handler
  594. DllName: PChar; // Name of the DLL
  595. ProcName: PChar; // Name of the procedure
  596. UserArea: PByte; // User area
  597. Drop: Cardinal): Cardinal; cdecl; // Drop authority
  598. external REXXAPI name 'RexxRegisterExitDll';
  599. Function RexxRegisterExitExe(
  600. HExit: PChar; // Name of the exit handler
  601. HandlerAddr: PFn; // Address of exit handler
  602. UserArea: PByte): Cardinal; cdecl; // User area
  603. external REXXAPI name 'RexxRegisterExitExe';
  604. Function RexxDeregisterExit(
  605. ExitName: PChar; // Exit name
  606. DllName: PChar): Cardinal; cdecl; // DLL module name
  607. external REXXAPI name 'RexxDeregisterExit';
  608. Function RexxQueryExit(
  609. ExitName: PChar; // Exit name
  610. DllName: PChar; // DLL Module name.
  611. var ExFlag: Word; // Existance flag.
  612. UserArea: Pointer): Cardinal; cdecl; // User data.
  613. external REXXAPI name 'RexxQueryExit';
  614. Function RexxQueryExit(
  615. ExitName: PChar; // Exit name
  616. DllName: PChar; // DLL Module name.
  617. var ExFlag: Word; // Existance flag.
  618. UserArea: PByte): Cardinal; cdecl; // User data.
  619. external REXXAPI name 'RexxQueryExit';
  620. Function RexxQueryExit(
  621. ExitName: PChar; // Exit name
  622. DllName: PChar; // DLL Module name.
  623. ExFlag: PWord; // Existance flag.
  624. UserArea: PByte): Cardinal; cdecl; // User data.
  625. external REXXAPI name 'RexxQueryExit';
  626. Function RexxQueryExit(
  627. ExitName: PChar; // Exit name
  628. DllName: PChar; // DLL Module name.
  629. ExFlag: PWord; // Existance flag.
  630. UserArea: Pointer): Cardinal; cdecl; // User data.
  631. external REXXAPI name 'RexxQueryExit';
  632. Function RexxSetHalt(
  633. Pid: Longint; // Process Id
  634. Tid: Longint): Cardinal; cdecl; // Thread Id
  635. external REXX name 'RexxSetHalt';
  636. Function RexxSetTrace(
  637. Pid: Longint; // Process Id
  638. Tid: Longint): Cardinal; cdecl; // Thread Id
  639. external REXX name 'RexxSetTrace';
  640. Function RexxResetTrace(
  641. Pid: Longint; // Process Id
  642. Tid: Longint): Cardinal; cdecl; // Thread Id
  643. external REXX name 'RexxResetTrace';
  644. Function RexxAddMacro(
  645. FnName: PChar; // Function to add or change
  646. FileName: PChar; // Name of file to get function
  647. SrchPos: Cardinal): Cardinal; cdecl; // Flag indicating search pos
  648. external REXXAPI name 'RexxAddMacro';
  649. Function RexxDropMacro(FnName: PChar): Cardinal; cdecl; // Name of function to remove
  650. external REXXAPI name 'RexxDropMacro';
  651. Function RexxSaveMacroSpace(
  652. ArgC: Cardinal; // Argument count (0==save all)
  653. var NameLst: PChar; // List of funct names to save
  654. FileName: PChar): Cardinal; cdecl; // File to save functions in
  655. external REXXAPI name 'RexxSaveMacroSpace';
  656. Function RexxLoadMacroSpace(
  657. ArgC: Cardinal; // Argument count (0==load all)
  658. var NameLst: PChar; // List of funct names to load
  659. FileName: PChar): Cardinal; cdecl; // File to load functions from
  660. external REXXAPI name 'RexxLoadMacroSpace';
  661. Function RexxQueryMacro(
  662. FnName: PChar; // Function to search for
  663. var PtrPos: Word): Cardinal; cdecl; // Ptr for position flag return
  664. external REXXAPI name 'RexxQueryLoadMacro';
  665. Function RexxReorderMacro(
  666. FnName: PChar; // Name of funct change order
  667. NewPos: Cardinal): Cardinal; cdecl; // New position for function
  668. external REXXAPI name 'RexxReorderMacro';
  669. Function RexxClearMacroSpace: Cardinal; cdecl; // No Arguments.
  670. external REXXAPI name 'RexxClearMacroSpace';
  671. Function RxNullString(const r: RxString): Boolean;
  672. Begin
  673. RxNullString:=r.strptr=nil;
  674. End;
  675. Function RxZeroLenString(const r: RxString): Boolean;
  676. Begin
  677. RxZeroLenString:=((r.strptr<>nil) and (r.strlength=0));
  678. End;
  679. Function RxValidString(const r: RxString): Boolean;
  680. Begin
  681. RxValidString:=((r.strptr<>nil) and (r.strlength>0));
  682. End;
  683. Function RxStrLen(const r: RxString): Longint;
  684. Begin
  685. If RxNullString(r) then
  686. RxStrLen:=0
  687. else
  688. RxStrLen:=r.strlength;
  689. End;
  690. Function RxStrPtr(Const r: RxString): PChar;
  691. Begin
  692. RxStrPtr:=r.strptr;
  693. End;
  694. Procedure MakeRxString(Var r: RxString; p: PChar; l: Longint);
  695. Begin
  696. r.strptr:=p;
  697. r.strlength:=l;
  698. End;
  699. End.