home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 612b.lha / RxilShell / rxil_fix.LZH / rxil_fix / rxil.h < prev   
C/C++ Source or Header  |  1992-02-02  |  12KB  |  465 lines

  1. /* rxil.h */
  2.  
  3. /*
  4.  *        General header file for RXIL, the RexX Interface Library.
  5.  *        Version 1.0
  6.  *        18-Nov-89
  7.  */
  8.  
  9. /*        Copyright © 1989 by Donald T. Meyer, Stormgate Software
  10.  *        All Rights Reserved
  11.  *
  12.  *        This source code may be compiled and used in any software
  13.  *        product.
  14.  *        No portion of this source code is to be re-distributed or
  15.  *        sold for profit.
  16.  *
  17.  *        Donald T. Meyer
  18.  *        Stormgate Software
  19.  *        P.O. Box 383
  20.  *        St. Peters, MO  63376
  21.  *
  22.  *        BIX:    donmeyer        (usually daily)
  23.  *        GEnie:    D.MEYER            (weekly)
  24.  *        PLINK:    Stormgate        (weekly)
  25.  */
  26.  
  27. /*
  28.  *    Modified:
  29.  *    Andrew C. R. Martin           13.12.91    11:15
  30.  *    SciTech Software
  31.  *
  32.  *    Changed prototype for RxilHandleReturn()
  33.  *    Added prototypes for Rxil_Shell routines.
  34.  */
  35.  
  36. #ifndef RXIL_H
  37. #define RXIL_H
  38.  
  39.  
  40. /* Include the standard Amiga headers which most, if not all, files
  41.  * will need (these are also needed by the ARexx headers).
  42.  */
  43.  
  44. #include <exec/types.h>
  45. #include <exec/nodes.h>
  46. #include <exec/lists.h>
  47. #include <exec/ports.h>
  48. #include <exec/libraries.h>
  49.  
  50. #include <intuition/intuition.h>
  51.  
  52.  
  53. /* The prototype headers */
  54.  
  55. #ifdef LATTICE
  56.  
  57. #include <proto/exec.h>
  58.  
  59. #endif
  60.  
  61.  
  62.  
  63. /* Include the arexx headers we may need */
  64.  
  65. #ifndef REXX_STORAGE_H
  66. #include <rexx/storage.h>
  67. #endif
  68.  
  69. #ifndef REXX_ERRORS_H
  70. #include <rexx/errors.h>
  71. #endif
  72.  
  73. #ifndef REXX_RXSLIB_H
  74. #include <rexx/rxslib.h>
  75. #endif
  76.  
  77.  
  78.  
  79. /*------------------------------------------------------------------*/
  80. /*                            Defines                                    */
  81. /*------------------------------------------------------------------*/
  82.  
  83. /*---------   I think these are from RJ's ProSuite...   ------------*/
  84. #ifndef SetFlag
  85. #define SetFlag(v,f)        ( (v) |= (f) )
  86. #define ClearFlag(v,f)        ( (v) &= ~(f) )
  87. #define FlagIsSet(v,f)        (  ( (v) & (f) ) != 0  )
  88. #define FlagIsClear(v,f)    (  ( (v) & (f) ) == 0  )
  89. #endif
  90.  
  91.  
  92.  
  93. #define RXIL_VERSION_STRING        "Rxil, the ARexx Interface Library,\
  94.  Version 1.0S1 18-Nov-89\n\
  95. Copyright \xA9 1989 by Donald T. Meyer, Stormgate Software.\
  96. S1 Revision: Andrew C. R. Martin, SciTech Software."
  97.  
  98.  
  99.  
  100. /* Result error codes which may be sent back to the macro program
  101.  * as the primary result code.
  102.  *
  103.  * If you have purchased the database program "Microfiche Filer Plus"
  104.  * from Software Visions, some of these error codes may sound familiar.
  105.  * Gary Samad of Software Visions has a reasonable scheme for error
  106.  * code values, and they are used here with his permission.  It is my
  107.  * feeling that as ARexx ports proliferate, there should be some commmon
  108.  * scheme for error code return values.  Obviously, no single set of
  109.  * error codes will suffice for all possible programs, but a common
  110.  * "core" set of standard error codes should at least be possible.
  111.  */
  112.  
  113. /* Informative */
  114. #define RXERR_NOTOK                         1L
  115. #define RXERR_END_OF_LIST                 2L
  116.  
  117. /* Syntax, content, or user errors */
  118. #define RXERR_REQUIRES_RESULT_FLAG        50L
  119. #define RXERR_NOT_A_HARMLESS_CMD        51L
  120. #define RXERR_NO_ARGUMENT                52L        /* Not enough args */
  121. #define RXERR_BAD_VARIABLE                53L        /* Invalid compound var */
  122. #define RXERR_TOO_MANY_ARGS                54L        /* Too many args */
  123. #define RXERR_INVALID_ARG                55L        /* Invalid keyword */
  124. #define RXERR_NOTHING_TO_UNLOCK            76L
  125. #define RXERR_ALREADY_LOCKED            77L
  126. #define RXERR_UNKNOWN_CMD                80L
  127. #define RXERR_BUSY                        81L
  128.  
  129. /* Fatal */
  130. #define RXERR_NO_AREXX_LIBRARY           100L
  131. #define RXERR_NO_MEMORY                   110L
  132. #define RXERR_FAILED                   150L            /* Misc. failure */
  133. #define RXERR_ABORTED                   200L
  134.  
  135.  
  136.  
  137. #define RXIL_MAX_ARGS    20
  138.     /* This is the maximum number of arguments possible on the
  139.      * command line sent to the ARexx port.  Actually, this is
  140.      * one more than the number of actual argument that will be allowed
  141.      * since the first "argument" is taken to be the command name.
  142.      */
  143.  
  144.  
  145. #define RXIL_MAX_PORTNAME_LEN            40
  146.     /* This is the longest the original portname can be.  Adding
  147.      * the unique instance number, or the private port stuff will
  148.      * make the final name longer than this.  This should *not* be
  149.      * changed!
  150.      */
  151.  
  152.  
  153.  
  154. /* Flags for the diagnostic routine RxilDumpRdef() */
  155.  
  156. #define RXIL_DUMP_CMDS            0x01
  157. #define RXIL_DUMP_ENV            0x02
  158. #define RXIL_DUMP_STATE            0x04
  159.  
  160.  
  161.  
  162. /* These flags are used in the call to RxilInit() and are also
  163.  * set into the variable which is accessed by the FROM_REXX macro
  164.  * to indicate which port an  ARexx command came in at.
  165.  *
  166.  * These are also the command privilege levels.  Setting the privilege
  167.  * to 0 or REXX_PUBLIC means that a command received at either the
  168.  * public or secret ports will be accepted.  If set to REXX_SECRET,
  169.  * the command will be accepted from the secret port only.
  170.  */
  171.  
  172. #define RXIL_PUBLIC        0x01
  173. #define RXIL_SECRET        0x02
  174. #define RXIL_PRIVATE    RXIL_SECRET            /* If "secret" sounds too
  175.                                              * cloak-and-dagger... :-)
  176.                                              */
  177.  
  178. #define RXIL_AS_IS        0x04                /* The default is to append
  179.                                              * an "instance" number onto
  180.                                              * the port name.
  181.                                              * This will inhibit that.
  182.                                              */
  183.  
  184.  
  185. /* RxilInvocation.state  */
  186.  
  187. #define RXIL_STATE_AVAILABLE    0        /* This structure is idle */
  188.  
  189. #define RXIL_STATE_PENDING        1        /* Has been sent to Rexx
  190.                                          * host.
  191.                                          */
  192.  
  193. #define RXIL_STATE_RETURNED        2        /* Returned from Rexx host,
  194.                                          * but has not been "handled"
  195.                                          * yet.
  196.                                          */
  197.  
  198.  
  199. /* RexxDef.Flags */
  200.  
  201. #define RXIL_NOLAUNCH            0x0001
  202.     /* If set, the loopback launch feature will be disabled.
  203.      * In this case, the following functions are not needed:
  204.      *        RxilLaunch()
  205.      *        RxilCreateRxi()
  206.      *        RxilCancel(), RxilPostCancel(), RxilEndCancel()
  207.      *        RxilCheckCancel()
  208.      */
  209.  
  210. #define RXIL_NO_CLEARABORT        0x0002
  211.     /* If set, the Abort flag will NOT be cleared by RxilCheckPort()
  212.      * whenever there are no pending macro invocations.
  213.      */
  214.  
  215. #define RXIL_NO_ABORT            0x0004
  216.     /* Do not post the "Cancel" requester when a macro is
  217.      * launched.
  218.      */
  219.  
  220. #define RXIL_NO_REQ                0x0008
  221.     /* Prevent routines such as RxilHandleReturn() from using requesters.
  222.      * This will force use of the CLI as the way to send messages to
  223.      * the user.
  224.      */
  225.  
  226.  
  227.  
  228. #define RXIL_ARGV(x)        (global_rdef->Arg[(x)])
  229. #define RXIL_ARGC            (global_rdef->ArgCount)
  230.  
  231. #define RXIL_FROM_REXX        (global_rdef ? global_rdef->FromRexx : 0)
  232.  
  233. #define RXIL_WAITFLAG        (global_rdef ? global_rdef->SigBit : 0L)
  234.  
  235.  
  236.  
  237. /*------------------------------------------------------------------*/
  238. /*                    Structure Template Definitions                    */
  239. /*------------------------------------------------------------------*/
  240.  
  241. struct RxilFunction {
  242.     char    *Name;                        /* The function name. */
  243.  
  244.     void    (*Func)(struct RexxMsg *);    /* Vector to the function's 'C'
  245.                                          * code.
  246.                                          */
  247.  
  248.     UWORD    MinArgs;                    /* Minimum number of arguments
  249.                                          * this command requires.
  250.                                          */
  251.  
  252.     UWORD    MaxArgs;                    /* Maximum number of arguments
  253.                                          * this command will accept.
  254.                                          */
  255.  
  256.     BOOL     CaseFlag;                    /* TRUE if we care about upper
  257.                                          * and lower case for the
  258.                                          * function name.
  259.                                          */
  260.  
  261.     UWORD    Privilege;                    /* Set to either RXIL_PUBLIC or
  262.                                          * RXIL_SECRET to control which
  263.                                          * port(s) this command is valid
  264.                                          * from.  If RXIL_PUBLIC, than
  265.                                          * this command may be executed
  266.                                          * from either port.
  267.                                          */
  268. };
  269.  
  270.  
  271.  
  272. struct RxilInvocation {
  273.     struct RxilInvocation    *Next;
  274.     struct RexxMsg            *RexxMsg;
  275.     struct RexxMsg            *Parent;
  276.     char                    *IHostPort;
  277.     UWORD                    State;
  278.     ULONG                    Type;
  279.     char                    *Name;
  280.     char                    *FileExt;
  281.     char                    *CommAddr;
  282.     char                    *Console;
  283.     ULONG                    ActionFlags;
  284.     BOOL                    CountArgs;
  285.     char                    *FuncArg[MAXRMARG];
  286.     UWORD                    ArgLen[MAXRMARG];
  287. };
  288.  
  289.  
  290.  
  291. struct RxilCancelReq {
  292.     struct Window        *win;
  293.     struct Requester    req;
  294. };
  295.  
  296.  
  297.  
  298. struct RxilDef {
  299.     /* Things which need to be inited by the client */
  300.     UWORD                    Flags;
  301.     char                    PortName[RXIL_MAX_PORTNAME_LEN+10];
  302.                                                 /* "MY_APP" */
  303.     char                    *Console;            /* "CON:0/0/20/40/" */
  304.     char                    *Extension;            /* "mapp" */
  305.     char                    *HostPort;            /* "REXX" */
  306.     struct RxilFunction        *CommandTable;        /* &cmd_table[0] */
  307.  
  308.     /* Things which the client may alter */
  309.     BOOL                    Abort;
  310.     char                    SecretPortName[RXIL_MAX_PORTNAME_LEN+30];
  311.     struct Window            *CancelWindow;
  312.  
  313.     /* Things which the client needs to see, but NOT SET */
  314.     ULONG                    SigBit;
  315.     WORD                    FromRexx;
  316.     char                    *Arg[RXIL_MAX_ARGS];
  317.     UWORD                    ArgCount;
  318.  
  319.     /* Things the client may want to look at */
  320.     UWORD                    LockCount;
  321.     char                    *Version;
  322.  
  323.     /* Fairly private stuff, access via function calls only */
  324.     struct MsgPort            *PublicPort;
  325.     struct MsgPort            *SecretPort;
  326.     struct RxilInvocation    *Invocations;
  327.     struct RxilCancelReq    *CReq;
  328. };
  329.  
  330.  
  331.  
  332. /*------------------------------------------------------------------*/
  333. /*                    Variable Declarations                            */
  334. /*------------------------------------------------------------------*/
  335.  
  336. extern struct RxsLib *RexxSysBase;
  337.     /* Defined in "init.c" */
  338.  
  339. extern struct RxilDef *global_rdef;
  340.     /* Defined in a client module */
  341.  
  342.  
  343.  
  344. /*------------------------------------------------------------------*/
  345. /*                    Function Declarations                            */
  346. /*------------------------------------------------------------------*/
  347.  
  348. LONG RxilToRexx( ULONG cmd,
  349.     STRPTR arg0, STRPTR arg1, STRPTR arg2, STRPTR arg3 );
  350.  
  351. void RxilCheckResult( struct RexxMsg *rexxmsg );
  352.  
  353. void RxilOpenConsole( char *console, struct RexxMsg *rexxmsg );
  354.  
  355. void RxilCloseConsole( struct RexxMsg *rexxmsg );
  356.  
  357. void RxilDeletePort( struct MsgPort *port );
  358.  
  359. void RxilDispatch( struct RexxMsg *rexxmsg, char *cmd );
  360.  
  361. LONG RxilLaunch( struct RxilInvocation *rxi );
  362.  
  363. struct RxilInvocation *RxilGetReturn( void );
  364.  
  365. /* Changed ACRM 12.12.91 */
  366. int  RxilHandleReturn( struct RxilInvocation *rxi,
  367.                        int                   noisy);
  368.  
  369. void RxilCleanupReturn( struct RxilInvocation *rxi );
  370.  
  371. struct RxilInvocation *RxilCreateRxi( char *name, ULONG type );
  372.  
  373. void RxilDeleteRxi( struct RxilInvocation *rxi );
  374.  
  375. BOOL RxilPending( void );
  376. BOOL RxilCmdPending( void );
  377. BOOL RxilFuncPending( void );
  378.  
  379. void RxilCheckPort( void );
  380.  
  381. void RxilSetResult( struct RexxMsg *rexxmsg, char *string );
  382.  
  383. struct RxilDef *RxilInit( ULONG flags, char *portname );
  384.  
  385. void RxilCleanup( struct RexxDef *rdef );
  386.  
  387. void RxilCmdLock( struct RexxMsg *rexxmsg );
  388.  
  389. void RxilCmdUnlock( struct RexxMsg *rexxmsg );
  390.  
  391. void RxilDumpRdef( struct RexxDef *rdef, ULONG flags );
  392.  
  393. void RxilCancel( void );
  394.  
  395. void RxilPostCancel( void );
  396.  
  397. BOOL RxilCheckCancel( void );
  398.  
  399. void RxilEndCancel( void );
  400.  
  401.  
  402. /*-----------------  ARexx Function Prototypes  ---------------*/
  403.  
  404. #ifndef REXX_PROTOS
  405. #define REXX_PROTOS
  406.  
  407. struct RexxMsg *CreateRexxMsg( struct MsgPort *, char *, char * );
  408.  
  409. struct RexxArg *CreateArgstring( char *, ULONG );
  410.  
  411. void DeleteArgstring( struct RexxArg * );
  412.  
  413. void DeleteRexxMsg( struct RexxMsg * );
  414.  
  415. LONG IsRexxMsg( struct RexxMsg * );
  416.  
  417. LONG ErrorMsg( ULONG, struct RexxArg ** );
  418.  
  419.  
  420. #ifndef  NO_PRAGMAS
  421.  
  422. /* --- Multiple returns, must use a stub... */
  423. /* pragma libcall RexxSysBase ErrorMsg 60 1 */
  424.  
  425. #pragma libcall RexxSysBase CreateArgstring 7e 802
  426. #pragma libcall RexxSysBase DeleteArgstring 84 801
  427. #pragma libcall RexxSysBase LengthArgstring 8a 801
  428. #pragma libcall RexxSysBase CreateRexxMsg 90 9803
  429. #pragma libcall RexxSysBase DeleteRexxMsg 96 801
  430. #pragma libcall RexxSysBase IsRexxMsg a8 801
  431.  
  432. #endif        /* NO_PRAGMAS */
  433.  
  434. #endif        /* REXX_PROTOS */
  435.  
  436.  
  437.  
  438. /*----------  ACRM: Additional Prototypes for Rxil shell --------*/
  439.  
  440. void  SetupREXX(char *portname,
  441.                 char *extension,
  442.                 char *conspec,
  443.                 int synch,
  444.                 struct RxilFunction *comtab,
  445.                 char *startup);
  446.  
  447. void  ProcessReturns(void);
  448.  
  449. int   CloseREXX(struct Window *wind,
  450.                 int force);
  451.  
  452. void  LaunchCmd(char *buf);
  453.  
  454. int   SetFuncParam(int pos,
  455.                    char *string);
  456.  
  457. void  LaunchFunc(void);
  458.  
  459. void  RexxReturnUsed(void);
  460.  
  461. void  BuildComLine(char *buffer);
  462.  
  463. #endif        /* RXIL_H */
  464.  
  465.