home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d5xx
/
d599
/
rxilshell.lha
/
RxilShell
/
rxil_shell.doc
< prev
next >
Wrap
Text File
|
1992-02-01
|
7KB
|
185 lines
rxil_shell
==========
This program is not in the public domain, but it may be freely copied
and distributed for no charge providing this header is included.
The code may be modified as required, but any modifications must be
documented so that the person responsible can be identified. If someone
else breaks this code, I don't want to be blamed for code that does not
work! The code may not be sold commercially without prior permission from
the author, although it may be given away free with commercial products,
providing it is made clear that this program is free and that the source
code is provided with the program.
Executables resulting from linking with this code are subject to no
distribution restrictions. This includes the use of STSAutoRequest(),
which normally requires the payment of a licence fee to SciTech Software.
When used *only* as part of rxil_shell, this licence fee is waived.
****************************************************************************
Description:
============
* The Rxil library makes calls to ARexx far easier. Error handling, etc.
is done for the programmer. Rxil_Shell makes these calls even easier.
Some flexibility is missing from these calls (although, when needed,
this can be re-introduced by direct calls to Rxil or ARexx itself).
* The following Rxil routines have been modified:
RxilCheckPort() Fix to memory allocation. ARG0() macro was getting
expanded wrongly causing MungWall hits.
display_message() Changed call to AutoRequest() to use MyAutoRequest()
which looks nicer under V1.3. This is in the
STSLib.lib link library.
RxilHandleReturn() Given a second parameter to control internal display
of returns from functions. Also returns a flag to
indicate whether a return value was obtained.
The modified/corrected routines are in the rxil_fix subdirectory.
* The Rexx command table, an array of RxilFunction's must be created and
passed to SetupREXX(). A line of NULL's and 0's is used to mark the end
of the table. For example:
struct RxilFunction rexx_cmd_table[] = {
{ "help", &rexx_parse, 0, 10, FALSE, RXIL_PUBLIC },
{ "quit", &rexx_parse, 0, 10, FALSE, RXIL_PUBLIC },
{ "command",&cmd_launch_cmd, 0, 1, FALSE, RXIL_PUBLIC },
{ "func", &cmd_launch_func, 0, 16, FALSE, RXIL_PUBLIC },
{ NULL, NULL, 0, 0, FALSE, 0 }
};
The structure members are:
(char *) Command name (in lower case)
(void *)() Function to be called for this command
int Min number of arguments required
int Max number of arguments required
BOOL Should command matching be case sensitive
int Privilege. RXIL_PUBLIC or RXIL_SECRET. Specifies which port
the command is valid from. If REXX_PUBLIC, command may be
executed through either port.
* The functions specified in the command table are called with a single
parameter, a pointer to a RexxMsg structure. The example command table
shows 2 calls to rexx_parse(). This implies an additional layer of
parsing is supplied by the client program. If required, the routine
BuildComLine() may be called in such a parser to rebuild the command
line. The following example shows how this might be done:
void rexx_parse(struct RexxMsg *rexxmsg)
{ char buffer[200];
BuildComLine(buffer); Rebuild the command line
Interpret(buffer); Call our own parser
}
* The only Rexx specific external which needs to be specified by the client
program (and then only if the client is interested in returns from
macros) is:
extern char *Rexx_return;
****************************************************************************
Usage:
======
SetupREXX(portname, extension, conspec, synch, comtab, startup)
---------------------------------------------------------------
Input: char *portname Port name
char *extension Default extension
NULL: "rexx"
else: taken a string pointer
char *conspec Console spec for macros to use.
NULL: none (use CLI)
1: default
else: taken a string pointer
int synch Are macros to be synchronous?
0: Synchronous
1: Asynchronous
struct RxilFunction comtab[] ARexx command table (see above)
char *startup Name of Startup macro
NULL: No startup
Returns: void
Sets up public and private REXX ports and specifies various parameters
for Rexx. Also runs a startup macro if required; thus any other
preparation routines should be called before SetupREXX().
comtab[] should be prepared as shown above.
ProcessReturns()
----------------
Input: void
Returns: void
This routine is for programs which launch macros. Handles any ARexx
invocation returns which may be back. Informs of any problems and
allocates and sets the Rexx_return string if a function returned
with a value.
CloseREXX(wind, force)
----------------------
Input: struct Window *wind Pointer to window
int force 0: Don't force; 1: Do force
Returns: int 0: Didn't close; 1: Did
Clean up all REXX stuff. Unless force is set, will ask whether it
should proceed IF there are any macros waiting. This is done by posting
a requester in wind (or Workbench if wind is NULL).
LaunchCmd(buf)
--------------
Input: char *buf Command macro to be launched
Returns: void
Launch a REXX command.
SetFuncParam(pos, string)
-------------------------
Input: int pos Parameter number (0--15)
char *string Parameter string
Returns: int 0: OK; 1: Failed
Allocate space to put a function parameter and copy in the parameter
string. The name of the function to be called should be placed in
position 0. Returns 0 if succeeded; 1 if not
LaunchFunc()
------------
Input: void
Returns: void
Launch a REXX function. Uses data created by calls to SetFuncParam()
RexxReturnUsed()
----------------
Input: void
Returns: void
Free memory used for Rexx_return. Also sets Rexx_return back to NULL
so its value can be tested to see of we've got a value back from a
function call.
BuildComLine(buffer)
--------------------
Output: char *buffer Pointer to character string
Returns: void
Rebuilds the command line into buffer (which must be pre-allocated).
This is useful if you want to parse commands separately from the
built-in parser.