home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / thesrc15.zip / regina.h < prev    next >
C/C++ Source or Header  |  1993-09-01  |  10KB  |  428 lines

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