home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
programs
/
system
/
filerexx
/
txt
/
simplerexx.mod
< prev
next >
Wrap
Text File
|
1995-02-27
|
4KB
|
184 lines
(*************************************************************************
:Program. SimpleRexx.mod
:Contents. simple rexx interface for use with ARexxBox
:Author. Hartmut Goebel [hG]
:Copyright. Copyright © 1990 by Hartmut Goebel
:Copyright. original 'C' definitions copyright © 1990 by Martin Balzer
:Language. Oberon-2
:Translator. Amiga Oberon V2.43
:History. V1.0, 31 Aug 1992 [hG]
:History. V1.02 24 Oct 1992 [hG]
:Date. 24 Oct 1992 01:52:38
*************************************************************************)
(* $StackChk- $NilChk- $RangeChk- $CaseChk- $OvflChk- $ReturnChk- $ClearVars- *)
MODULE SimpleRexx;
IMPORT
BT := BasicTypes,
e := Exec,
d := Dos,
pf := Printf,
RVI,
rx := Rexx,
rxs := RexxSysLib,
y := SYSTEM,
str := Strings;
CONST
RexxExtension * = "";
RexxPortBaseName = "FILEREXX";
TYPE
RexxHostPtr * = POINTER TO RexxHost;
RexxHost * = STRUCT
port *: e.MsgPortPtr;
(* name -: ARRAY 80 OF CHAR; *)
replies *: LONGINT;
(* rdargs *: d.RDArgsPtr; *)
(* flags *: LONGSET; *)
(* userdata *: e.APTR; *)
END;
PROCEDURE ReplyRexxCommand*(rxmsg: rx.RexxMsgPtr;
primary: LONGINT;
secondary: e.ADDRESS;
result: e.STRPTR);
VAR
buf: ARRAY 16 OF CHAR;
rc2: e.STRPTR;
BEGIN
(* Ist OPTIONS RESULTS gesetzt? *)
IF rx.rxfResult IN rx.ActionFlags(rxmsg.action) THEN
(* Ja, also Resultat generieren *)
IF primary = 0 THEN
(* Primärer Resultcode = 0 bedeutet Resultat-String in result oder gar nix *)
IF result = NIL THEN
secondary := NIL;
ELSE
secondary := rxs.CreateArgstring(result^,str.Length(result^))
END;
ELSE
(* Primär # 0: Fehlercode in primary, Zweitcode _oder_ String in secondary *)
IF primary > 0 THEN
(* secondary ist Code *)
pf.SPrintf1(buf,"%ld", secondary );
rc2 := y.ADR(buf);
ELSE
(* secondary ist String *)
primary := -primary;
rc2 := y.VAL(e.STRPTR,secondary);
END;
(* Rexx-Variable setzen (amiga.lib) *)
IF RVI.SetRexxVar(rxmsg,"RC2", rc2^, str.Length(result^))#0 THEN END;
secondary := NIL;
END
ELSIF primary < 0 THEN
(* User will zwar kein Result, aber Fehlercode darf nicht <0 sein *)
primary := -primary;
END;
rxmsg.result1 := primary;
rxmsg.result2 := secondary;
e.ReplyMsg(rxmsg);
END ReplyRexxCommand;
PROCEDURE FreeRexxCommand*(rxmsg: rx.RexxMsgPtr);
BEGIN
IF (rxmsg.result1 = 0) & (rxmsg.result2 # 0) THEN
rxs.DeleteArgstring(rxmsg.result2); END;
IF rxmsg.stdin # NIL THEN
d.OldClose(rxmsg.stdin); END;
IF (rxmsg.stdout # NIL) & (rxmsg.stdout # rxmsg.stdin) THEN
d.OldClose(rxmsg.stdout); END;
rxs.DeleteArgstring(rxmsg.args[0]);
rxs.DeleteRexxMsg(rxmsg);
END FreeRexxCommand;
PROCEDURE CreateRexxCommand*(host: RexxHost;
buff: ARRAY OF CHAR;
fh: d.FileHandlePtr): rx.RexxMsgPtr;
VAR
rxCmdMsg: rx.RexxMsgPtr;
BEGIN
rxCmdMsg := rxs.CreateRexxMsg(host.port,RexxExtension,host.port.node.name^);
IF rxCmdMsg = NIL THEN
RETURN NIL;
END;
rxCmdMsg.args[0] := rxs.CreateArgstring(buff,str.Length(buff));
IF rxCmdMsg.args[0] = NIL THEN
rxs.DeleteRexxMsg(rxCmdMsg);
RETURN NIL;
END;
rxCmdMsg.action := rx.rxComm + rx.rxResult;
rxCmdMsg.stdin := fh;
rxCmdMsg.stdout := fh;
END CreateRexxCommand;
PROCEDURE CommandToRexx*(host: RexxHost;
rxCmdMsg: rx.RexxMsgPtr): rx.RexxMsgPtr;
VAR
rexxport: e.MsgPortPtr;
BEGIN
e.Forbid();
(* rexxport := e.FindPort(rx.rxsDir); *)
rexxport := e.FindPort(host.port.node.name^);
IF rexxport = NIL THEN
e.Permit();
RETURN NIL;
END;
e.PutMsg(rexxport, rxCmdMsg);
e.Permit();
INC(host.replies);
RETURN rxCmdMsg;
END CommandToRexx;
PROCEDURE SendRexxCommand*(host: RexxHost;
buff: ARRAY OF CHAR): rx.RexxMsgPtr;
VAR
rcm: rx.RexxMsgPtr;
BEGIN
rcm := CreateRexxCommand(host, buff, NIL);
IF rcm # NIL THEN
RETURN CommandToRexx(host,rcm);
ELSE
RETURN NIL;
END;
END SendRexxCommand;
PROCEDURE IsARexxReply*(msg: e.MessagePtr): BOOLEAN;
VAR
BEGIN
IF msg # NIL THEN
RETURN (msg.node.type = e.replyMsg);
ELSE
RETURN FALSE;
END;
END IsARexxReply;
END SimpleRexx.