home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 291.lha / ArexxInterfaceLibrary_v.8 / Rxil.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-02  |  8.5 KB  |  359 lines

  1. /* rxil.h */
  2.  
  3. /*        Copyright © 1989 by Donald T. Meyer, Stormgate Software
  4.  *        All Rights Reserved
  5.  *
  6.  *        This source code may be compiled and used in any software
  7.  *        product.
  8.  *        No portion of this source code is to be re-distributed or
  9.  *        sold for profit.
  10.  *
  11.  *        Donald T. Meyer
  12.  *        Stormgate Software
  13.  *        P.O. Box 383
  14.  *        St. Peters, MO  63376
  15.  *
  16.  *        BIX:    donmeyer        (usually daily)
  17.  *        GEnie:    D.MEYER            (weekly)
  18.  *        PLINK:    Stormgate        (weekly)
  19.  */
  20.  
  21.  
  22. #ifndef RXIL_H
  23. #define RXIL_H
  24.  
  25.  
  26.  
  27.  
  28. /* Include the rexx headers we may need */
  29.  
  30. #ifndef REXX_STORAGE_H
  31. #include <rexx/storage.h>
  32. #endif
  33.  
  34. #ifndef REXX_ERRORS_H
  35. #include <rexx/errors.h>
  36. #endif
  37.  
  38. #ifndef REXX_RXSLIB_H
  39. #include <rexx/rxslib.h>
  40. #endif
  41.  
  42.  
  43.  
  44. /*------------------------------------------------------------------*/
  45. /*                            Defines                                    */
  46. /*------------------------------------------------------------------*/
  47.  
  48. /*----------   I think these are from RJ's ProSuite   --------------*/
  49. #ifndef SetFlag
  50. #define SetFlag(v,f)        ( (v) |= (f) )
  51. #define ClearFlag(v,f)        ( (v) &= ~(f) )
  52. #define FlagIsSet(v,f)        (  ( (v) & (f) ) != 0  )
  53. #define FlagIsClear(v,f)    (  ( (v) & (f) ) == 0  )
  54. #endif
  55.  
  56.  
  57.  
  58. /* Result error codes which may be sent back to the macro program
  59.  * as the primary result code.
  60.  *
  61.  * If you have purchased the database program "Microfiche Filer Plus"
  62.  * from Software Visions, some of these error codes may sound familiar.
  63.  * Gary Samad of Software Visions has a reasonable scheme for error
  64.  * code values, and they are used here with his permission.  It is my
  65.  * feeling that as ARexx ports proliferate, there should be some commmon
  66.  * scheme for error code return values.  Obviously, no single set of
  67.  * error codes will suffice for all possible programs, but a common
  68.  * "core" set of standard error codes should at least be possible.
  69.  */
  70.  
  71. /* Informative */
  72. #define RXERR_NOTOK                         1L
  73. #define RXERR_END_OF_LIST                 2L
  74.  
  75. /* Syntax, content, or user errors */
  76. #define RXERR_REQUIRES_RESULT_FLAG        50L
  77. #define RXERR_NOT_A_HARMLESS_CMD        51L
  78. #define RXERR_NO_ARGUMENT                52L
  79. #define RXERR_BAD_VARIABLE                53L
  80. #define RXERR_ARG_COUNT                    54L
  81. #define RXERR_NOTHING_TO_UNLOCK            76L
  82. #define RXERR_ALREADY_LOCKED            77L
  83. #define RXERR_UNKNOWN_CMD                80L
  84. #define RXERR_BUSY                        81L
  85.  
  86. /* Fatal */
  87. #define RXERR_NO_AREXX_LIBRARY           100L
  88. #define RXERR_NO_MEMORY                   110L
  89. #define RXERR_FAILED                   150L            /* Misc. failure */
  90. #define RXERR_ABORTED                   200L
  91.  
  92.  
  93.  
  94. #define RXIL_MAX_ARGS    20
  95.  
  96.  
  97.  
  98. /* These flags are used in the call to init_rexx() and are also
  99.  * set into the from_rexx flag to indicate which port a rexx command
  100.  * comes from.
  101.  *
  102.  * These are also the command privledge levels.  Setting the privledge
  103.  * to 0 or REXX_PUBLIC means that a command received at either the
  104.  * public or secret ports will be accepted.  If set to REXX_SECRET,
  105.  * the command will be accepted from the secret port only.
  106.  */
  107.  
  108. #define RXIL_PUBLIC        0x01
  109. #define RXIL_SECRET        0x02
  110. #define RXIL_PRIVATE    RXIL_SECRET            /* If "secret" sounds too
  111.                                              * cloak-and-dagger...
  112.                                              */
  113. /* #define REXX_REENTRANT    0x80 */
  114.  
  115.  
  116.  
  117. #define RXIL_NO_ARGCHECK        -1
  118.  
  119.  
  120. /* RexxInvocation.state  */
  121.  
  122. #define RXIL_STATE_AVAILABLE    0        /* This structure is idle */
  123.  
  124. #define RXIL_STATE_PENDING        1        /* Has been sent to Rexx
  125.                                          * host.
  126.                                          */
  127.  
  128. #define RXIL_STATE_RETURNED        2        /* Returned from Rexx host,
  129.                                          * but has not been "handled"
  130.                                          * yet.
  131.                                          */
  132.  
  133.  
  134. /* RexxDef.Flags */
  135.  
  136. #define RXIL_NOLAUNCH            0x0001
  137.     /* If set, the loopback launch feature will be disabled.
  138.      * If set, the following functions are not needed:
  139.      *        RxilLaunch()
  140.      *        RxilCreateRxi()
  141.      *        RxilCancel(), RxilPostCancel(), RxilEndCancel()
  142.      *        RxilCheckCancel()
  143.      */
  144.  
  145. #define RXIL_NO_CLEARABORT        0x0002
  146.     /* If set, the Abort flag will NOT be cleared by check_rexx_port()
  147.      * whenever there are no pending macro invocations.
  148.      */
  149.  
  150. #define RXIL_NO_ABORT            0x0004
  151.     /* Do not post the "Cancel" requester when a macro is
  152.      * launched.
  153.      */
  154.  
  155.  
  156.  
  157.  
  158. #define RXIL_ARGV(x)        (global_rdef->Arg[(x)])
  159. #define RXIL_ARGC            (global_rdef->ArgCount)
  160.  
  161. #define RXIL_FROM_REXX        (global_rdef ? global_rdef->FromRexx : 0)
  162.  
  163. #define RXIL_WAITFLAG        (global_rdef ? global_rdef->SigBit : 0L)
  164.  
  165.  
  166.  
  167. /*------------------------------------------------------------------*/
  168. /*                    Structure Template Definitions                    */
  169. /*------------------------------------------------------------------*/
  170.  
  171. struct RxilFunction {
  172.     char    *Name;                        /* The function name. */
  173.  
  174.     void    (*Func)(struct RexxMsg *);    /* Vector to the function's 'C'
  175.                                          * code.
  176.                                          */
  177.  
  178.     WORD    ArgCount;                    /* Number of args expected.
  179.                                          * Set to NO_ARGCHECK
  180.                                          * if we don't care or
  181.                                          * will ascertain within the
  182.                                          * function.
  183.                                          */
  184.  
  185.     BOOL     CaseFlag;                    /* TRUE if we care about upper
  186.                                          * and lower case for the
  187.                                          * function name.
  188.                                          */
  189.  
  190.     UWORD    Privlege;                    /* Set to either REXX_PUBLIC or
  191.                                          * REXX_SECRET to control which
  192.                                          * port(s) this command is valid
  193.                                          * from.  If REXX_PUBLIC, than
  194.                                          * this command may be executed
  195.                                          * from either port.
  196.                                          */
  197. };
  198.  
  199.  
  200.  
  201. struct RxilInvocation {
  202.     struct RxilInvocation    *Next;
  203.     struct RexxMsg            *RexxMsg;
  204.     struct RexxMsg            *Parent;
  205.     char                    *IHostPort;
  206.     UWORD                    State;
  207.     ULONG                    Type;
  208.     char                    *Name;
  209.     char                    *FileExt;
  210.     char                    *CommAddr;
  211.     char                    *Console;
  212.     ULONG                    ActionFlags;
  213.     BOOL                    CountArgs;
  214.     char                    *FuncArg[MAXRMARG];
  215.     UWORD                    ArgLen[MAXRMARG];
  216. };
  217.  
  218.  
  219.  
  220. struct RxilCancelReq {
  221.     struct Window        *win;
  222.     struct Requester    req;
  223. };
  224.  
  225.  
  226.  
  227. struct RxilDef {
  228.     /* Things which need to be inited by the client */
  229.     UWORD                    Flags;
  230.     char                    *PortName;            /* "MY_APP" */
  231.     char                    *Console;            /* "CON:0/0/20/40/" */
  232.     char                    *Extension;            /* "mapp" */
  233.     char                    *HostPort;            /* "REXX" */
  234.     struct RxilFunction        *CommandTable;        /* &cmd_table[0] */
  235.  
  236. /* Should the above become a separate structure?  The client may want
  237.  * to change what are essentialy launch & dispatch parameters on the fly
  238.  * and as a set?
  239.  */
  240.  
  241.     /* Things which the client may alter */
  242.     BOOL                    Abort;
  243.     char                    SecretPortName[80];
  244.     struct Window            *CancelWindow;
  245.  
  246.     /* Things which the client needs to see, but NOT SET */
  247.     ULONG                    SigBit;
  248.     int                        FromRexx;
  249.     char                    *Arg[RXIL_MAX_ARGS];
  250.     UWORD                    ArgCount;
  251.  
  252.     /* Things the client may want to look at */
  253.     int                        LockCount;
  254.  
  255.     /* Fairly private stuff, access via function calls only */
  256.     struct MsgPort            *PublicPort;
  257.     struct MsgPort            *SecretPort;
  258.     struct RxilInvocation    *Invocations;
  259.     struct RxilCancelReq    *CReq;
  260. };
  261.  
  262.  
  263.  
  264. /*------------------------------------------------------------------*/
  265. /*                    Variable Declarations                            */
  266. /*------------------------------------------------------------------*/
  267.  
  268. extern struct RxsLib *RexxSysBase;
  269.     /* Defined in "init.c" */
  270.  
  271. extern struct RxilDef *global_rdef;
  272.     /* Defined in a client module */
  273.  
  274.  
  275.  
  276. /*------------------------------------------------------------------*/
  277. /*                    Function Declarations                            */
  278. /*------------------------------------------------------------------*/
  279.  
  280. LONG RxilToRexx( ULONG cmd,
  281.     STRPTR arg0, STRPTR arg1, STRPTR arg2, STRPTR arg3 );
  282.  
  283. void RxilCheckResult( struct RexxMsg *rexxmsg );
  284.  
  285. void RxilOpenConsole( char *console, struct RexxMsg *rexxmsg );
  286.  
  287. void RxilCloseConsole( struct RexxMsg *rexxmsg );
  288.  
  289. void RxilDeletePort( struct MsgPort *port );
  290.  
  291. void RxilDispatch( struct RexxMsg *rexxmsg, char *cmd );
  292.  
  293. LONG RxilLaunch( struct RexxInvocation *rxi );
  294.  
  295. struct RexxInvocation *RxilGetReturn( void );
  296.  
  297. void RxilHandleReturn( struct RexxInvocation *rxi );
  298.  
  299. void RxilCleanupReturn( struct RexxInvocation *rxi );
  300.  
  301. struct RexxInvocation *RxilCreateRxi( char *name, ULONG type );
  302.  
  303. void RxilDeleteRxi( struct RexxInvocation *rxi );
  304.  
  305. BOOL RxilPending( void );
  306. BOOL RxilCmdPending( void );
  307. BOOL RxilFuncPending( void );
  308.  
  309. void RxilCheckPort( void );
  310.  
  311. void RxilSetResult( struct RexxMsg *rexxmsg, char *string );
  312.  
  313. struct RexxDef *RxilInit( int flags, char *portname );
  314.  
  315. void RxilCleanup( struct RexxDef *rdef );
  316.  
  317. void RxilCmdLock( struct RexxMsg *rexxmsg );
  318.  
  319. void RxilCmdUnlock( struct RexxMsg *rexxmsg );
  320.  
  321. void RxilDumpRdef( struct RexxDef *rdef );
  322.  
  323. void RxilCancel( void );
  324.  
  325. void RxilPostCancel( void );
  326.  
  327. BOOL RxilCheckCancel( void );
  328.  
  329. void RxilEndCancel( void );
  330.  
  331.  
  332.  
  333. /*-----------------  ARexx Function Prototypes  ---------------*/
  334.  
  335. #ifndef REXX_PROTOS
  336. #define REXX_PROTOS
  337.  
  338. void LockRexxBase( ULONG );
  339.  
  340. void UnlockRexxBase( ULONG );
  341.  
  342. struct RexxMsg *CreateRexxMsg( struct MsgPort *, char *, char * );
  343.  
  344. struct RexxArg *CreateArgstring( char *, ULONG );
  345.  
  346. void DeleteArgstring( struct RexxArg * );
  347.  
  348. void DeleteRexxMsg( struct RexxMsg * );
  349.  
  350. LONG IsRexxMsg( struct RexxMsg * );
  351.  
  352. LONG ErrorMsg( ULONG, struct RexxArg ** );
  353.  
  354. #endif
  355.  
  356.  
  357. #endif
  358.  
  359.