home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sp15demo.zip / libsrc.zip / LIBSRC / REXXSAA.PAS < prev    next >
Pascal/Delphi Source File  |  1996-02-20  |  16KB  |  398 lines

  1. UNIT REXXSAA;
  2.  
  3. {**************************************************************************
  4. *                                                                         *
  5. * Module Name: REXXSAA.PAS                                                *
  6. *                                                                         *
  7. * OS/2 REXX Interface                                                     *
  8. *                                                                         *
  9. *                                                                         *
  10. ***************************************************************************}
  11.  
  12. INTERFACE
  13.  
  14. USES OS2Def;
  15.  
  16. TYPE
  17.      PRXSTRING=^RXSTRING;
  18.      RXSTRING=RECORD
  19.                     strlength:LONGWORD;
  20.                     strptr:PChar;
  21.               END;
  22.  
  23. CONST
  24.      RXAUTOBUFLEN        = 256;
  25.  
  26. TYPE
  27.     PRXSYSEXIT=^RXSYSEXIT;
  28.     RXSYSEXIT=RECORD
  29.                     sysexit_name:PChar;
  30.                     sysexit_code:LONGINT;
  31.     END;
  32.  
  33. CONST
  34.      RXCOMMAND       =0;
  35.      RXSUBROUTINE    =1;
  36.      RXFUNCTION      =2;
  37.  
  38. CONST
  39.      RXSUBCOM_DROPPABLE   =$00;
  40.      RXSUBCOM_NONDROP     =$01;
  41.  
  42. CONST
  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.  
  58. CONST
  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.  
  79. TYPE
  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.  
  91. CONST
  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.  
  157. TYPE
  158.     PEXIT=PUCHAR;
  159.     PFN=POINTER;
  160.  
  161. CONST
  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.  
  180. TYPE
  181.     RexxFunctionHandler=FUNCTION(VAR uc:UCHAR;ul:ULONG;
  182.                                  VAR rxs:RXSTRING;
  183.                                  VAR apsz:CSTRING;
  184.                                  VAR rxs2:RXSTRING):ULONG;
  185.  
  186.      RxFnCCal_Parm = RECORD
  187.                         rxfnc_flags: Byte;
  188.                         rxfnc_name:  PChar;
  189.                         rxfnc_namel: Word;
  190.                         rxfnc_que:   PChar;
  191.                         rxfnc_quel:  Word;
  192.                         rxfnc_argc:  Word;
  193.                         rxfnc_argv:  PRxString;
  194.                         rxfnc_retc:  RxString;
  195.      END;
  196.  
  197. CONST
  198.  
  199.   rxfcfail                      = $01;  { Command failed.            }
  200.   rxfcerr                       = $02;  { Command ERROR occurred.    }
  201.  
  202. TYPE
  203.  
  204.   RxCmdHst_Parm = RECORD
  205.                       rxcmd_flags:    Byte;
  206.                       rxcmd_address:  PChar;
  207.                       rxcmd_addressl: Word;
  208.                       rxcmd_dll:      PChar;
  209.                       rxcmd_dll_len:  Word;
  210.                       rxcmd_command:  RxString;
  211.                       rxcmd_retc:     RxString;
  212.   END;
  213.  
  214.   RxMsqPll_Parm = RECORD
  215.                       rxmsq_retc: RxString;
  216.   END;
  217.  
  218. CONST
  219.    rxfmlifo                     = $01;  { Stack entry LIFO if set    }
  220.  
  221. TYPE
  222.   RxMsqPsh_Parm = RECORD
  223.                        rxmsq_flags: Byte;
  224.                        rxmsq_value: RxString
  225.   END;
  226.  
  227.   RxMsqSiz_Parm = RECORD
  228.                        rxmsq_size: ULong;
  229.   END;
  230.  
  231.   RxMsqNam_Parm = RECORD
  232.                        rxmsq_name: RxString;
  233.   END;
  234.  
  235.   RxSioSay_Parm = RECORD
  236.                        rxsio_string: RxString;
  237.   END;
  238.  
  239.   RxSioTrc_Parm = RECORD
  240.                        rxsio_string: RxString;
  241.   END;
  242.  
  243.   RxSioTrd_Parm = RECORD
  244.                        rxsiotrd_retc: RxString;
  245.   END;
  246.  
  247.   RxSioDtr_Parm = RECORD
  248.                        rxsiodtr_retc: RxString;
  249.   END;
  250.  
  251. CONST
  252.    rxfhhalt                      = $01;  { Set if HALT occurred.      }
  253.  
  254. TYPE
  255.    RxHltTst_Parm = RECORD
  256.                        rxhlt_flags: Byte;
  257.    END;
  258.  
  259. CONST
  260.   rxftrace                      = $01;  { Set to run external trace. }
  261.  
  262. TYPE
  263.   RxTrcTst_Parm = RECORD
  264.                        rxtrc_flags: Byte;
  265.   END;
  266.  
  267. IMPORTS
  268.      FUNCTION RexxStart (ArgC:Long;VAR ArgV:RxString;
  269.                          VAR FileName:CSTRING;
  270.                          VAR Proc:RxString;
  271.                          VAR Env:CSTRING;
  272.                          rType:Long;
  273.                          VAR Exit:RxSysExit;
  274.                          var Ret:Word;
  275.                          var RetVal:RxString):LONG;
  276.            APIENTRY; REXX INDEX 1;
  277.      FUNCTION RexxRegisterSubcomDll(CONST Name:CSTRING;
  278.                                     CONST DllName:CSTRING;
  279.                                     CONST ProcName:CSTRING;
  280.                                     VAR UserArea;
  281.                                     Authority:LONGWORD):APIRET;
  282.            APIENTRY; REXXAPI INDEX 6;
  283.      FUNCTION RexxRegisterSubcomExe(Const HandlerName:CSTRING;
  284.                                     HandlerAddr:PFN;
  285.                                     VAR UserArea):APIRET;
  286.            APIENTRY; REXXAPI INDEX 7;
  287.      FUNCTION RexxQuerySubcom(CONST EnvName:CSTRING;
  288.                               CONST DllName:CSTRING;
  289.                               VAR ExCode:WORD;
  290.                               VAR User:WORD):APIRET;
  291.            APIENTRY; REXXAPI INDEX 8;
  292.      FUNCTION RexxDeregisterSubcom(CONST EnvName:CSTRING;
  293.                                    CONST DllName:CSTRING):APIRET;
  294.            APIENTRY; REXXAPI INDEX 9;
  295.      FUNCTION RexxVariablePool(VAR block:SHVBLOCK):APIRET;
  296.            APIENTRY; REXX INDEX 2;
  297.      FUNCTION RexxRegisterFunctionDll(CONST FuncName:CSTRING;
  298.                                       CONST DllName:CSTRING;
  299.                                       CONST Entry:CSTRING):APIRET;
  300.            APIENTRY; REXXAPI INDEX 17;
  301.      FUNCTION RexxRegisterFunctionExe(CONST FuncName:CSTRING;
  302.                                       Entry:PFN):APIRET;
  303.            APIENTRY; REXXAPI INDEX 18;
  304.      FUNCTION RexxDeregisterFunction(CONST Name:CSTRING):APIRET;
  305.            APIENTRY; REXXAPI INDEX 19;
  306.      FUNCTION RexxQueryFunction(CONST Name:CSTRING):APIRET;
  307.            APIENTRY; REXXAPI INDEX 20;
  308.      FUNCTION RexxRegisterExitDll(CONST Handler:CSTRING;
  309.                                   CONST DllName:CSTRING;
  310.                                   CONST ProcName:CSTRING;
  311.                                   VAR UserArea;
  312.                                   authority:ULONG):APIRET;
  313.            APIENTRY; REXXAPI INDEX 11;
  314.      FUNCTION RexxRegisterExitExe(CONST Handler:CSTRING;
  315.                                   Address:PFN;
  316.                                   VAR UserArea):APIRET;
  317.            APIENTRY; REXXAPI INDEX 12;
  318.       FUNCTION RexxDeregisterExit(CONST Name:CSTRING;
  319.                                   CONST DllName:CSTRING):APIRET;
  320.            APIENTRY; REXXAPI INDEX 13;
  321.       FUNCTION RexxQueryExit(CONST ExitName:CSTRING;
  322.                              CONST DllName:CSTRING;
  323.                              VAR ExistanceFlag:USHORT;
  324.                              VAR UserArea):APIRET;
  325.            APIENTRY; REXXAPI INDEX 14;
  326.       FUNCTION RexxSetHalt(apid:PID;atid:TID):APIRET;
  327.            APIENTRY; REXX INDEX 3;
  328.       FUNCTION RexxSetTrace(apid:PID;atid:TID):APIRET;
  329.            APIENTRY; REXX INDEX 4;
  330.       FUNCTION RexxResetTrace(apid:PID;atid:TID):APIRET;
  331.            APIENTRY; REXXAPI INDEX 5;
  332.       FUNCTION RexxAddMacro(CONST FuncName:CSTRING;
  333.                             CONST FileName:CSTRING;
  334.                             searchpos:ULONG):APIRET;
  335.            APIENTRY; REXXAPI INDEX 22;
  336.       FUNCTION RexxDropMacro(CONST Name:CSTRING):APIRET;
  337.            APIENTRY; REXXAPI INDEX 23;
  338.       FUNCTION RexxSaveMacroSpace(argcount:ULONG;
  339.                                   VAR NameList:PChar;
  340.                                   CONST FileName:CSTRING):APIRET;
  341.            APIENTRY; REXXAPI INDEX 28;
  342.       FUNCTION RexxLoadMacroSpace(argcount:ULONG;
  343.                                   VAR NameList:PChar;
  344.                                   CONST FileName:CSTRING):APIRET;
  345.            APIENTRY; REXXAPI INDEX 25;
  346.       FUNCTION RexxQueryMacro(CONST FuncName:CSTRING;
  347.                               VAR posflag:WORD):APIRET;
  348.            APIENTRY; REXXAPI INDEX 26;
  349.       FUNCTION RexxReorderMacro(CONST FuncName:CSTRING;
  350.                                 NewPos:ULONG):APIRET;
  351.            APIENTRY; REXXAPI INDEX 27;
  352.       FUNCTION RexxClearMacroSpace:APIRET;
  353.            APIENTRY; REXXAPI INDEX 24;
  354. END;
  355.  
  356. FUNCTION RXNULLSTRING(CONST r:RXSTRING):BOOLEAN;
  357. FUNCTION RXZEROLENSTRING(CONST r:RXSTRING):BOOLEAN;
  358. FUNCTION RXVALIDSTRING(CONST r:RXSTRING):BOOLEAN;
  359. FUNCTION RXSTRLEN(CONST r:RXSTRING):LONGINT;
  360. FUNCTION RXSTRPTR(CONST r:RXSTRING):PChar;
  361. PROCEDURE MAKERXSTRING(VAR r:RXSTRING;p:PChar;l:LONGINT);
  362.  
  363. IMPLEMENTATION
  364.  
  365. FUNCTION RXNULLSTRING(CONST r:RXSTRING):BOOLEAN;
  366. BEGIN
  367.      result:=r.strptr=NIL;
  368. END;
  369.  
  370. FUNCTION RXZEROLENSTRING(CONST r:RXSTRING):BOOLEAN;
  371. BEGIN
  372.      result:=((r.strptr<>NIL)AND(r.strlength=0));
  373. END;
  374.  
  375. FUNCTION RXVALIDSTRING(CONST r:RXSTRING):BOOLEAN;
  376. BEGIN
  377.      result:=((r.strptr<>NIL)AND(r.strlength>0));
  378. END;
  379.  
  380. FUNCTION RXSTRLEN(CONST r:RXSTRING):LONGINT;
  381. BEGIN
  382.      IF RXNULLSTRING(r) THEN result:=0
  383.      ELSE result:=r.strlength;
  384. END;
  385.  
  386. FUNCTION RXSTRPTR(CONST r:RXSTRING):PChar;
  387. BEGIN
  388.      result:=r.strptr;
  389. END;
  390.  
  391. PROCEDURE MAKERXSTRING(VAR r:RXSTRING;p:PChar;l:LONGINT);
  392. BEGIN
  393.      r.strptr:=p;
  394.      r.strlength:=l;
  395. END;
  396.  
  397. BEGIN
  398. END.