home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rx08eemx.zip / rexxsaa.h < prev    next >
C/C++ Source or Header  |  1998-06-28  |  12KB  |  497 lines

  1. /*
  2.  *  The Regina Rexx Interpreter
  3.  *  Copyright (C) 1993-1994  Anders Christensen <anders@pvv.unit.no>
  4.  *
  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.
  9.  *
  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.
  14.  *
  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.
  18.  */
  19.  
  20. /*
  21.  * $Id: rexxsaa.h,v 1.1 1993/05/07 21:38:13 anders Exp anders $
  22.  */
  23.  
  24. /* Remember to add prototypes for Rexx*() functions */
  25.  
  26. #if defined(__WATCOMC__) && defined(__NT__)
  27. # include <windows.h>
  28. #endif
  29.  
  30. #if defined(_MSC_VER) || defined(__RSXNT__)
  31. # include <windows.h>
  32. #endif
  33.  
  34. int StartRexx() ;
  35. int ExecuteScript( int, char*, int, char* ) ;
  36. void SetVariable( int, char*, int, char* ) ;
  37. char *GetVariable( int*, int, char* ) ;
  38.  
  39. #if !defined(_OS2EMX_H) && !defined(__RSXNT__)
  40. typedef char CHAR ;
  41. typedef short SHORT ;
  42. typedef long LONG ;
  43. typedef char *PSZ ;
  44.  
  45. typedef CHAR *PCHAR ;
  46. typedef SHORT *PSHORT ;
  47. typedef LONG *PLONG ;
  48.  
  49. # ifndef UCHAR_TYPEDEFED
  50. typedef unsigned char UCHAR ;
  51. # endif
  52. # ifndef USHORT_TYPEDEFED
  53. typedef unsigned short USHORT ;
  54. # endif
  55. # ifndef ULONG_TYPEDEFED
  56. typedef unsigned long ULONG ;
  57. # endif
  58.  
  59. typedef USHORT *PUSHORT ;
  60. typedef char *PCH ;
  61. typedef unsigned char *PUCHAR ;
  62.  
  63. #endif
  64.  
  65. #ifdef INCL_REXXSAA
  66. # define INCL_RXSUBCOM
  67. # define INCL_RXSHV
  68. # define INCL_RXFUNC
  69. # define INCL_RXSYSEXIT
  70. # define INCL_RXMACRO
  71. # define INCL_RXARI
  72. #endif
  73.  
  74. #if !defined(APIENTRY)
  75. # define APIENTRY
  76. #endif
  77.  
  78. #if !defined(APIRET)
  79. # define APIRET ULONG
  80. #endif
  81.  
  82. #if !defined(_OS2EMX_H)
  83. typedef APIRET (APIENTRY *PFN)();
  84. #endif
  85.  
  86. #ifndef _OS2EMX_H
  87. typedef struct RXSTRING_type 
  88. {
  89.    ULONG   strlength ;
  90.    char *strptr ;
  91. } RXSTRING ;
  92. typedef RXSTRING *PRXSTRING ;
  93. #endif
  94.  
  95. #define RXAUTOBUFLEN  256L
  96.  
  97. typedef APIRET APIENTRY RexxSubcomHandler(PRXSTRING, PUSHORT, PRXSTRING);
  98.  
  99. #ifdef INCL_RXSYSEXIT
  100.  
  101. /* 
  102.  * The following are definition for the function codes and subcodes for
  103.  * System Exit Handlers. All RXxxx macros are function codes, while the 
  104.  * RXxxxyyy macros are function subcodes for function code RXxxx.
  105.  */
  106. #define RXFNC        2
  107. # define RXFNCCAL    1
  108.  
  109. #define RXCMD        3
  110. # define RXCMDHST    1
  111.  
  112. #define RXMSQ        4
  113. # define RXMSQPLL    1
  114. # define RXMSQPSH    2
  115. # define RXMSQSIZ    3
  116. # define RXMSQNAM   20
  117.  
  118. #define RXSIO        5
  119. # define RXSIOSAY    1
  120. # define RXSIOTRC    2
  121. # define RXSIOTRD    3
  122. # define RXSIODTR    4
  123. # define RXSIOTLL    5
  124.  
  125. #define RXHLT        7
  126. # define RXHLTCLR    1
  127. # define RXHLTTST    2
  128.  
  129. #define RXTRC        8
  130. # define RXTRCTST    1
  131.  
  132. #define RXINI        9
  133. # define RXINIEXT    1
  134.  
  135. #define RXTER       10
  136. # define RXTEREXT    1
  137.  
  138. #define RXDBG       11
  139. # define RXDBGTST    1
  140.  
  141. #define RXENDLST     0
  142. #define RXNOOFEXITS 12
  143.    
  144. #define RXEXIT_BADTYPE 1
  145. #define RXEXIT_NOTREG 2
  146. #define RXEXIT_NOEMEM 3
  147. #define RXEXIT_OK 0
  148.  
  149. /* Symbolic return codes for System Exit Handlers */
  150. #define RXEXIT_HANDLED       0
  151. #define RXEXIT_NOT_HANDLED   1
  152. #define RXEXIT_RAISE_ERROR (-1)
  153.   
  154. typedef struct {
  155.    struct {
  156.       unsigned int rxfferr:1 ;
  157.       unsigned int rxffnfnd:1 ;
  158.       unsigned int rxffsub:1 ;
  159.    } rxfnc_flags ;
  160.    unsigned char *rxfnc_name ;
  161.    unsigned short rxfnc_namel ;
  162.    unsigned char *rxfnc_que ;
  163.    unsigned short rxfnc_quel ;
  164.    unsigned short rxfnc_argc ;
  165.    RXSTRING *rxfnc_argv ;
  166.    RXSTRING rxfnc_retc ;
  167. } RXFNCCAL_PARM ;
  168.   
  169. typedef struct {
  170.    struct {
  171.       unsigned int rxfcfail:1 ;
  172.       unsigned int rxfcerr:1 ;
  173.    } rxcmd_flags ;
  174.    unsigned char *rxcmd_address ;
  175.    unsigned short rxcmd_addressl ;
  176.    unsigned char *rxcmd_dll ;
  177.    unsigned short rxcmd_dll_len ;
  178.    RXSTRING rxcmd_command ;
  179.    RXSTRING rxcmd_retc ;
  180. } RXCMDHST_PARM ;
  181.  
  182. typedef struct {
  183.    RXSTRING rxmsq_retc ;
  184. } RXMSQPLL_PARM ;
  185.  
  186. typedef struct {
  187.    struct {
  188.       unsigned rcfmlifo:1 ;
  189.    } rcmsq_flags ;
  190.    RXSTRING rxmsq_value ;
  191. } RXMSQPSH_PARM ;
  192.  
  193. typedef struct {
  194.    unsigned long rxmsq_size ;
  195. } RXMSQSIZ_PARM ;
  196.  
  197. typedef struct {
  198.    RXSTRING rxmsq_name ;
  199. } RXMSQNAM_PARM ;
  200.  
  201. typedef struct {
  202.    RXSTRING rxsio_string ;
  203. } RXSIOSAY_PARM ;
  204.  
  205. typedef RXSIOSAY_PARM RXSIOTRC_PARM ;
  206.  
  207. typedef struct {
  208.    RXSTRING rxsiotrd_retc ;
  209. } RXSIOTRD_PARM ;      
  210.  
  211. typedef struct {
  212.    RXSTRING rxsiodtr_retc ;
  213. } RXSIODTR_PARM ;
  214.  
  215. typedef struct {
  216.    struct {
  217.       unsigned int rxfhhalt:1 ;
  218.    } rxhlt_flags ;
  219. } RXHLTTST_PARM ;
  220.  
  221. typedef struct {
  222.    struct {
  223.       unsigned int rxftrace:1 ;
  224.    } rxtrx_flags ;
  225. } RXTRCTST_PARM ;
  226.  
  227. /*
  228.  #define rxfnc_flags    rxfnccal.u_rxfnc_flags
  229.  #define rxfnc_name    rxfnccal.u_rxfnc_name
  230.  #define rxfnc_namel    rxfnccal.u_rxfnc_namel
  231.  #define rxfnc_que    rxfnccal.u_rxfnc_que
  232.  #define rxfnc_quel    rxfnccal.u_rxfnc_quel
  233.  #define rxfnc_argc    rxfnccal.u_rxfnc_argc
  234.  #define rxfnc_argv    rxfnccal.u_rxfnc_argv
  235.  #define rxfnc_retc    rxfnccal.u_rxfnc_retc
  236.  #define rxcmd_flags    rxcmdhst.u_rxcmd_flags
  237.  #define rxcmd_address    rxcmdhst.u_rxcmd_address
  238.  #define rxcmd_addressl    rxcmdhst.u_rxcmd_addressl
  239.  #define rxcmd_dll    rxcmdhst.u_rxcmd_dll
  240.  #define rxcmd_dll_len    rxcmdhst.u_rxcmd_dll_len
  241.  #define rxcmd_command    rxcmdhst.u_rxcmd_command
  242.  #define rxcmd_retc    rxcmdhst.u_rxcmd_retc
  243.  #define rxmsq_retc    rxmsqpll.u_rxmsq_retc
  244.  #define rxsio_string    rxsiosay.u_rxsio_string
  245.  #define rxsiotrd_retc    rxsiotrd.u_rxsiotrd_retc 
  246.  #define rxsiodtr_retc    rxsiodtr.u_rxsiodtr_retc
  247.  #define rxhlt_flags    rxhlttst.u_rxhlt_flags
  248.  #define rxtrc_flags    rxtrctst.u_rxtrc_flags
  249.  */
  250.  
  251. typedef union {
  252.    RXFNCCAL_PARM fnccal ;
  253.    RXCMDHST_PARM cmdhst ;
  254.    RXMSQPLL_PARM msqpll ;
  255.    RXMSQPSH_PARM msqpsh ;
  256.    RXMSQSIZ_PARM msqsiz ;
  257.    RXMSQNAM_PARM msqnam ;
  258.    RXSIOSAY_PARM siosay ;
  259.    RXSIOTRC_PARM siotrc ;
  260.    RXSIOTRD_PARM siotrd ;
  261.    RXSIODTR_PARM siodtr ;
  262.    RXHLTTST_PARM hlttst ;
  263.    RXTRCTST_PARM trctst ;
  264. } EXIT ;
  265.  
  266. typedef EXIT *PEXIT ;
  267.  
  268. #ifndef _OS2EMX_H
  269. typedef struct {
  270.    char *sysexit_name ;
  271.    short sysexit_code ;
  272. } RXSYSEXIT ;
  273. typedef RXSYSEXIT *PRXSYSEXIT ;
  274. #endif
  275.  
  276. typedef LONG APIENTRY RexxExitHandler( LONG, LONG, PEXIT ) ;
  277.  
  278. APIRET APIENTRY RexxRegisterExitExe(
  279.    PSZ EnvName,
  280. #ifdef RX_STRONGTYPING
  281.    RexxExitHandler *EntryPoint,
  282. #else
  283.    PFN EntryPoint, 
  284. #endif
  285.    PUCHAR UserArea ) ;
  286.  
  287. APIRET APIENTRY RexxRegisterExitDll(
  288.    PSZ EnvName,
  289.    PSZ ModuleName,
  290.    PSZ ProcedureName,
  291.    PUCHAR UserArea,
  292.    ULONG DropAuth ) ;
  293.  
  294. APIRET APIENTRY RexxDeregisterExit(
  295.    PSZ EnvName,
  296.    PSZ ModuleName ) ;
  297.  
  298. #endif /* INCL_RXSYSEXIT */
  299.  
  300.  
  301.  
  302. #define MAXENVNAMELEN 31
  303.   
  304. #define MAKERXSTRING(x,c,l)   ((x).strptr=(c),(x).strlength=(l))
  305. #define RXNULLSTRING(x)       (!(x).strptr)
  306. #define RXSTRLEN(x)           ((x).strptr ? (x).strlength : 0UL)
  307. #define RXSTRPTR(x)           ((x).strptr)
  308. #define RXVALIDSTRING(x)      ((x).strptr && (x).strlength)
  309. #define RXZEROLENSTRING(x)    ((x).strptr && !(x).strlength)
  310.  
  311. #define RXCOMMAND         0
  312. #define RXSUBROUTINE      1
  313. #define RXFUNCTION        2
  314.  
  315.  
  316. #ifdef INCL_RXSHV
  317.  
  318. /* 
  319.  * Definitions and declarations for the Rexx variable pool interface.
  320.  */
  321.  
  322. # define RXSHV_OK    0x00    /* Everything OK */
  323. # define RXSHV_NEWV    0x01    /* Var not previously set */
  324. # define RXSHV_LVAR    0x02    /* Last var in a NEXTV sequence */
  325. # define RXSHV_TRUNC    0x04    /* Name or value has been truncated */
  326. # define RXSHV_BADN    0x08    /* Bad/invalid name */
  327. # define RXSHV_MEMFL    0x10    /* Memory problem, e.g. out of memory */
  328. # define RXSHV_BADF    0x80    /* Invalid function code */
  329.  
  330. # define RXSHV_NOAVL    0x90    /* Interface is not available */
  331.  
  332. /* 
  333.  * Note: Some documentation claims that RXSHV_BADF should have the 
  334.  *       value 0x80, but that can't be correct, can it?
  335.  */
  336.  
  337. # define RXSHV_SET    0x00    /* Set variable */
  338. # define RXSHV_FETCH    0x01    /* Get value of variable */
  339. # define RXSHV_DROPV    0x02    /* Drop variable */
  340. # define RXSHV_SYSET    0x03    /* Set symbolic variable */
  341. # define RXSHV_SYFET    0x04    /* Get value of symbolic variable */
  342. # define RXSHV_SYDRO    0x05    /* Drop symbolic variable */
  343. # define RXSHV_NEXTV    0x06    /* Get next var in a NEXTV sequence */
  344. # define RXSHV_PRIV    0x07    /* Get private information */
  345. # define RXSHV_EXIT    0x08    /* Set function exit value */
  346.  
  347. /*
  348.  * Note: A symbolic variable is a symbol that will be 'expanded' before 
  349.  *       use, while a (normal) variable is used directly, without 
  350.  *       expanding it first. 
  351.  */
  352.  
  353. typedef struct shvnode *PSHVBLOCK ;
  354. typedef struct shvnode 
  355. {
  356.    struct shvnode *shvnext ;
  357.    RXSTRING shvname, shvvalue ;
  358.    ULONG shvnamelen, shvvaluelen ;
  359.    UCHAR shvcode, shvret ;
  360. } SHVBLOCK ;
  361.  
  362. APIRET APIENTRY RexxVariablePool(
  363.    PSHVBLOCK RequestBlockList ) ;
  364.  
  365. #endif /* INCL_RXSHV */
  366.  
  367.  
  368. #ifndef _OS2EMX_H
  369. APIRET APIENTRY RexxStart(
  370.    LONG        ArgCount,
  371.    PRXSTRING     ArgList,
  372.    PSZ        ProgramName,
  373.    PRXSTRING    Instore,
  374.    PSZ        EnvName,
  375.    LONG        CallType,
  376. #ifdef INCL_RXSYSEXIT
  377.    PRXSYSEXIT    Exits,
  378. #else
  379.    void        *Exits,
  380. #endif
  381.    PSHORT    ReturnCode,
  382.    PRXSTRING    Result ) ;
  383. #endif
  384. /* 
  385.  * Return codes .... haha there doesn't seem to be a standard, except
  386.  * zero is OK, negative is an Rexx error, the positive error codes below
  387.  * are my own 'invention'
  388.  */
  389. #define RX_START_OK         0
  390. #define RX_START_BADP       1  /* Bad parameters */
  391. #define RX_START_UNIMPL     2  /* Not yet implemented :-) */
  392. #define RX_START_TOOMANYP   3  /* To many parameters */
  393. #define RX_DIDNT_START      4  /* Unable to start interpreter */
  394.  
  395.  
  396. #ifdef INCL_RXSUBCOM
  397.  
  398. APIRET APIENTRY RexxRegisterSubcomExe(
  399.    PSZ EnvName,
  400. #ifdef RX_STRONGTYPING
  401.    RexxSubcomHandler *EntryPoint,
  402. #else
  403.    PFN EntryPoint,
  404. #endif
  405.    PUCHAR UserArea ) ;
  406.  
  407. APIRET APIENTRY RexxDeregisterSubcom(
  408.    PSZ EnvName,
  409.    PSZ ModuleName ) ;
  410.  
  411. APIRET APIENTRY RexxRegisterSubcomDll(
  412.    PSZ EnvName,
  413.    PSZ ModuleName,
  414.    PSZ ProcedureName,
  415.    PUCHAR UserArea,
  416.    ULONG DropAuth ) ;
  417.  
  418. APIRET APIENTRY RexxQuerySubcom(
  419.    PSZ Envname,
  420.    PSZ ModuleName,
  421.    PUSHORT Flag,       /* Documentation diverges ... */
  422.    PUCHAR UserArea ) ;
  423.  
  424. #define RXSUBCOM_OK          0
  425. #define RXSUBCOM_DUP        10
  426. #define RXSUBCOM_MAXREG     20
  427. #define RXSUBCOM_NOTREG     30
  428. #define RXSUBCOM_NOCANDROP  40
  429. #define RXSUBCOM_LOADERR    50
  430. #define RXSUBCOM_NOPROC    127
  431.  
  432. #define RXSUBCOM_BADENTRY 1001
  433. #define RXSUBCOM_NOEMEM   1002
  434. #define RXSUBCOM_BADTYPE  1003
  435. #define RXSUBCOM_NOTINIT  1004
  436.  
  437. /* I don't know the 'real' values of these */
  438. #define RXSUBCOM_ERROR      0x01
  439. #define RXSUBCOM_ISREG      0x01
  440. #define RXSUBCOM_FAILURE    0x02
  441. #define RXSUBCOM_DROPPABLE  0x00
  442. #define RXSUBCOM_NONDROP    0x01
  443.  
  444.  
  445. #endif /* INCL_RXSUBCOM */
  446.  
  447.  
  448. #ifdef INCL_RXFUNC
  449.  
  450. typedef APIRET APIENTRY RexxFunctionHandler(PUCHAR, ULONG, PRXSTRING, PSZ, PRXSTRING) ;
  451.  
  452. APIRET APIENTRY RexxRegisterFunctionExe(
  453.    PSZ name,
  454. #ifdef RX_STRONGTYPING
  455.    RexxFunctionHandler *EntryPoint ) ;
  456. #else
  457.    PFN EntryPoint ) ;
  458. #endif
  459.  
  460. APIRET APIENTRY RexxRegisterFunctionDll(
  461.    PSZ ExternalName,
  462.    PSZ LibraryName,
  463.    PSZ InternalName ) ;
  464.  
  465. APIRET APIENTRY RexxDeregisterFunction(
  466.    PSZ name ) ;
  467.  
  468. APIRET APIENTRY RexxQueryFunction(
  469.    PSZ name ) ;
  470.  
  471. #define RXFUNC_OK             0
  472. #define RXFUNC_DEFINED       10
  473. #define RXFUNC_NOMEM         20
  474. #define RXFUNC_NOTREG        30
  475. #define RXFUNC_MODNOTFND     40
  476. #define RXFUNC_ENTNOTFND     50
  477. #define RXFUNC_NOTINIT       60
  478. #define RXFUNC_BADTYPE       70
  479. #define RXFUNC_NOEMEM      1002
  480.  
  481. #endif /* INCL_RXFUNC */
  482.  
  483. /* Asynchronous Request Interface defines */
  484. #ifdef INCL_RXARI
  485.  
  486. /***    Return Codes from Asynchronous Request interface */
  487.  
  488. #define RXARI_OK                   0
  489. #define RXARI_NOT_FOUND            1
  490. #define RXARI_PROCESSING_ERROR     2
  491.  
  492. APIRET APIENTRY RexxSetHalt(
  493.    LONG,
  494.    LONG );
  495.  
  496. #endif
  497.