home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
au1_inf.zip
/
U1_HOOKS.INF
(
.txt
)
< prev
next >
Wrap
OS/2 Help File
|
1995-07-02
|
20KB
|
460 lines
ΓòÉΓòÉΓòÉ 1. Title Page ΓòÉΓòÉΓòÉ
ΓòÉΓòÉΓòÉ <hidden> Dummy ΓòÉΓòÉΓòÉ
U1 Rexx Hooks
Guide & Reference
Beta Version!
Dmitry Zavalishin
Artworks by Dmitry Zavalishin and Kira Stratonnikova
Moscow, 1995
ΓòÉΓòÉΓòÉ <hidden> Dummy ΓòÉΓòÉΓòÉ
ΓòÉΓòÉΓòÉ 2. What is REXX hook? ΓòÉΓòÉΓòÉ
There it a lot of things in a gate, that different people like to be done some
unusual way. Examples are address translation, data compression, accounting,
etc etc. Instead of adding to the U1 all of the possible ways of doing those
things and, thus, making it grow bigger, it's configs to become clumsier, I
decided to let users control the way gate works themselves by writing scripts
in REXX that will intercept some data, processed by gate and convert that data
the way user likes. The best example of such hook is UU2Fido uucp address
hook, which is called before gateing letter and given uucp address this letter
is addressed to. Hook script can convert that address to anything user seems
to be appropriate and then return new address for gate to use instead of the
original one. If no hook provided, address will be passed as is to U1 uucp to
fido address converter.
ΓòÉΓòÉΓòÉ 3. How can I write my own REXX hook? ΓòÉΓòÉΓòÉ
Every OS/2 system has a simple book on REXX language. Please make sure you're
familiar enough with REXX before trying to use REXX hooks. Each hook is
described separately below, please read carefully about hook arguments, return
value and situation, in which that hook is called. REXX hook is a rexx program
file, which name is given in corresponding U1 setup file parameter. Most hooks
are started with arguments and all of them must return some value.
Hook parameters
The following line of REXX code will retrieve first argument of REXX
hook into the variable 'First_Arg':
Parse Arg First_Arg
Return values
The following line of REXX code will return result of script to the
caller and terminate execution of script:
/**
* Assume that variable 'result' contains the value we
* want to return.
**/
Return result
If no return value is needed for the hook you're writing, return 0
(zero) on success and -1 on failure.
/**
* We're failed, failed, failed :(
**/
Return -1
ΓòÉΓòÉΓòÉ 4. Additional REXX operators in general ΓòÉΓòÉΓòÉ
When writing U1 REXX hooks you can use additional operators, described below.
Please don't forget that additional operators are defined in "U1" environment
only, and if you change environment with 'ADDRESS' operator all of them will be
unavailable. To switch environment back use 'ADDRESS "U1"' command. See Rexx
reference book, keyword instruction 'ADDRESS' for further information on
environments.
ΓòÉΓòÉΓòÉ 4.1. Operator 'log': Writing debug info to U1 log file ΓòÉΓòÉΓòÉ
Purpose
Can be used to write debugging information to U1 log file.
Parameters
Text to be logged.
Notes
U1 setup parameter LogLevel must have 'x' character in it's value,
or debug mode must be turned on in order for log operator to be
effective.
Sample
/* Log value of variable 'input' */
log 'Rexx Hook is running. Parameter is: 'input
ΓòÉΓòÉΓòÉ 4.2. Operator 'warning': Displaying warning message ΓòÉΓòÉΓòÉ
Purpose
Can be used to warn user about unusual conditions.
Parameters
Text to be displayed and logged.
Notes
Text will be prepended with 'Warning: ' before displaying it.
Sample
/* Issue a warning message */
warning 'Address 'in_address' seems to be strange.'
ΓòÉΓòÉΓòÉ 4.3. Operator 'error': Displaying error message ΓòÉΓòÉΓòÉ
Purpose
Can be used to tell user about non-fatal error.
Parameters
Text to be displayed and logged.
Notes
Text will be prepended with 'Error: ' before displaying it.
Sample
/* Issue an error message */
error 'No username in address 'in_address'. Forwarding letter to postmaster.'
ΓòÉΓòÉΓòÉ 4.4. Operator 'fatal': Displaying fatal error message and halting ΓòÉΓòÉΓòÉ
Purpose
Can be used to tell user about fatal error.
Parameters
Text to be displayed and logged.
Notes
Text will be prepended with 'Fatal: ' before displaying it.
CAUTION:
Executing operator 'fatal' you'll stop currently running gate module
non-gracefully, possibly loosing some data (letters or articles).
Sample
/* Issue an error message and terminate gate */
fatal 'Out of disk space!'
ΓòÉΓòÉΓòÉ 5. Additional REXX operators for GRemote hooks ΓòÉΓòÉΓòÉ
U1's remote control unit has it's own extension to the Rexx operator set, which
is accessible via "GRemote" Rexx environment (you need to use 'ADDRESS
"GRemote"' to use those operators).
ΓòÉΓòÉΓòÉ 5.1. Operator 'GetLetterLine': Reading lines from user letter ΓòÉΓòÉΓòÉ
Purpose
Lets you get line from the user's letter text when processing user
command.
Parameters
Name of the variable to put line to.
Notes
If no line can be read, variable is not changed. If you pass
variable with no value (it is possible to remove value from variable
with DROP statement) it can be checked after calling this operator
to make sure you have read something.
Sample
/* Read a line into the variable 'input' */
/* and display it onscreen */
address "gremote" "GetLetterLine" "line"
say 'next line: 'line
ΓòÉΓòÉΓòÉ 5.2. Operator 'PutLetterLine': Writing lines to the reply letter ΓòÉΓòÉΓòÉ
Purpose
Lets you put line to the reply letter when processing user command.
Parameters
Text to put.
Notes
None.
Sample
/* Write a line to user */
address "gremote" "PutLetterLine" "Hi, Rexx command processor online."
ΓòÉΓòÉΓòÉ 6. Sample (NULL) script (Rexx.U2F.Address) ΓòÉΓòÉΓòÉ
/*********************************************************************/
/* address conversion hook for U1 UU2Fido.exe */
/* */
/* Input: uucp address of recipient */
/* */
/* Output: replacement address */
/* */
/*********************************************************************/
/* Here's we are loading variable 'inaddr' with value of the first argument */
Parse Arg inaddr
/* initialize output to default */
OutString = inaddr
/* Put debug info to log file */
log 'Rexx.U2F.Address: InAddr is 'inaddr
/* return string, removing any blanks on the front or back. */
Return Strip(OutString)
/* end */
ΓòÉΓòÉΓòÉ 7. Detailed hooks descriptions ΓòÉΓòÉΓòÉ
The hooks that are currently available are follow.
ΓòÉΓòÉΓòÉ 7.1. Rexx.U2F.Address: UU2Fido UUCP Address Hook ΓòÉΓòÉΓòÉ
Description
Example
ΓòÉΓòÉΓòÉ 7.1.1. Description of Rexx.U2F.Address ΓòÉΓòÉΓòÉ
Purpose
This hook can be used to preprocess (convert) uucp destination
address of the letter before passing it to uucp to fido address
translator of U1. Note that translating address to user@p#.f#.n#.z#
form you can avoid nearly all further translation of the address by
gate.
Call reason
This hook is called for each destination address of letter passed to
UU2Fido.
Parameters
The only parameter is destination uucp address.
Return value
This hook must return new uucp address for message or its first
parameter if no replacement needed.
ΓòÉΓòÉΓòÉ 7.1.2. Sample script for Rexx.U2F.Address ΓòÉΓòÉΓòÉ
/**
* Address conversion hook for UU2Fido.exe. Does nothing.
*
* Input: uucp address of recipient
*
* Output: replacement address
*
**/
/* Load variable 'inaddr' with value of the first arg. */
Parse Arg inaddr
/* initialize output to default */
OutString = inaddr
/* Put debug info to log file */
log 'Rexx.U2F.Address: InAddr is 'inaddr
/* return string, removing blanks on the front or back. */
Return Strip(OutString)
ΓòÉΓòÉΓòÉ 7.2. Rexx.U2F.Pack: UU2Fido UUCP File Compression Hook ΓòÉΓòÉΓòÉ
Description
Example
ΓòÉΓòÉΓòÉ 7.2.1. Description of Rexx.U2F.Pack ΓòÉΓòÉΓòÉ
Purpose
This hook can be used to compress files, attached to the FIDO
letters by UU2Fido, with the archiving program you like.
Call reason
This hook is called when letter passed to UU2Fido is large enough to
be sent as an attached file instead of simple FIDO message.
Parameters
The first parameter is full name of the file to be compressed,
second one points to the directory where compressed file must be
created.
Return value
This hook must return name of resulting compressed file. If
compression failed, return name of the original file, and, please,
leave the file itself intact. If compression is succeded, it is your
responsibility to delete original file.
ΓòÉΓòÉΓòÉ 7.2.2. Sample script for Rexx.U2F.Pack ΓòÉΓòÉΓòÉ
/*****************************************************/
/* attachment packing hook for U1 UU2Fido.exe */
/* */
/* */
/* Input: unpacked file name (full) */
/* directory to put packed file to */
/* */
/* Output: packed file name (full) */
/* */
/*****************************************************/
/* get parameters */
Parse Arg unp_name, out_dir
/* make sure execution environment is U1's */
address "U1"
/* log parameters */
log "Rexx packer ("unp_name", "out_dir")"
/* initialize output to default */
OutString = unp_name
/* extract filename.extension part form the full name */
p=lastpos('\',unp_name)
if p = 0 then unp_file_ext=unp_name
else unp_file_ext=substr(unp_name,p+1)
p=lastpos('/',unp_file_ext)
if \ (p = 0) then unp_file_ext=substr(unp_file_ext,p+1)
debug "unp_file_ext: "unp_file_ext
/* cut extension off */
p=lastpos('.',unp_file_ext)
if p = 0 then unp_file=unp_file_ext
else unp_file=substr(unp_file_ext,1,p-1)
debug "unp_file: "unp_file
/* build name of compressed file */
p_name=out_dir||'\'||unp_file||'.zip'
debug "p_name: "p_name
say "Compressing with zip "unp_name
/* execute command */
Address "CMD" 'zip -oj '||p_name||' '||unp_name
if rc = 0 then
do
/* Success. Set return value to compressed file name... */
OutString=p_name
/* ...and delete uncompressed file */
call SysDeleteFile unp_name
end
else
Error "Unable to zip file, exit code = "||rc
/* return string, removing any blanks on the front or back. */
Return Strip(OutString)
ΓòÉΓòÉΓòÉ 7.3. Rexx.Gremote.Cmd: U1 Remote Control Command Execution Hook ΓòÉΓòÉΓòÉ
Description
Example
ΓòÉΓòÉΓòÉ 7.3.1. Description of Rexx.Gremote.Cmd ΓòÉΓòÉΓòÉ
Purpose
This hook can be used to extend command set of gremote.exe remote
control unit.
Call reason
During parsing the letter from user GRemote checks command verb
against internal table first, then, if no match found, this hook is
called.
Parameters
The first parameter is command verb, second is tail of the command
line.
Return value
This hook must return 0 if command verb is correct, nonzero
otherwise.
ΓòÉΓòÉΓòÉ 7.3.2. Sample script for Rexx.Gremote.Cmd ΓòÉΓòÉΓòÉ
/*****************************************************/
/* Command hook for U1 GRemote.exe */
/* */
/* */
/* Input: command, parameters */
/* */
/* Output: 0 if successfull, nonzero otherwise. */
/* */
/*****************************************************/
/* Get command and parameters */
cmd=arg(1)
par=arg(2)
/* GRemote will send user a reply letter. */
/* The following operator adds */
/* a line of text to that letter */
call ans "Rexx subsystem online..."
call ans "Processing command "cmd" with parameters "par
/* Log what do we do */
address "U1" log "Rexx processing command "cmd' with parameters 'par
/* Read the following line of user's */
/* letter to the variable 'line' */
address "gremote" "GetLetterLine" "line"
/* print onscreen what do we got */
say 'command is 'cmd', parameters: 'par
say 'next line of letter is: 'line
return 0
ans: procedure
address "gremote" "PutLetterLine" arg(1)
return
ΓòÉΓòÉΓòÉ <hidden> ΓòÉΓòÉΓòÉ
To reach that book open the 'Information' folder on your desktop and
double-click 'Rexx Information' object in it.
ΓòÉΓòÉΓòÉ <hidden> ΓòÉΓòÉΓòÉ
usually with an extension of .Rexx