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