C (160/207)

From:DenJS
Date:23 Dec 99 at 22:00:26
Subject:ARexx Programming

From: DenJS <denjs@mail.ru>

Hello,

Please Help me with programming arexx communication programm in C.
All what i need is send a rexx message (command) 'MM_Version' and get reply from programm for
this command, in my case a reply looks like 'VERSION: 1.0; RELEASE 10.0' (two
different deciminal string)
In simple arexx script i can do it very easy, like this:

/* Rexx Proggy */

Address 'MAILMANAGER'

MM_Version buf

echo buf.VERSION
echo buf.RELEASE

And now i need same result in my C programm. Please help me. I make some... but
i have no idea how to continue my work... i can't find any usefull documentation
about rexx programming on C.

#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/rexxsyslib.h>
#include <string.h>

void main(void)
{
struct MsgPort *MyPort;
struct MsgPort *MyPutPort;

Forbid();

if (MyPutPort = FindPort("MAILMANAGER"))
{
Permit();

Printf("Port found!\n");

if (MyPort = CreatePort(NULL,0))
{
struct RexxMsg *MyMsg;

Printf("Port created!\n");

if (MyMsg = CreateRexxMsg(MyPort, NULL, "MAILMANAGER"))
{
UBYTE Command[] = {"MM_Version",NULL};
UBYTE *MyArgString;

Printf("Rexx message created!\n");

if (MyArgString = CreateArgstring(Command, strlen(Command)))
{
struct RexxMsg *MyReplyRexxMsg;

Printf("Arg string created!\n");

MyMsg->rm_Action = RXCOMM;
MyMsg->rm_Args[0] = (STRPTR)MyArgString;

PutMsg(MyPutPort, &MyMsg->rm_Node);

WaitPort(MyPort);

if (MyReplyRexxMsg = (struct RexxMsg *)GetMsg(MyPort))
{
Printf("Got reply message!\n");

if (IsRexxMsg(MyReplyRexxMsg))
Printf("Rexx Msg!\n");
else
Printf("Not a Rexx Msg!\n");

Printf("Buffer: %s\n", MyReplyRexxMsg->rm_Args[0]);
Printf("Buffer: %s\n", MyReplyRexxMsg->rm_Args[1]);
Printf("Buffer: %s\n", MyReplyRexxMsg->rm_Args[2]);
// rm_Args always contain my command or trash, nobody change it :(
}

DeleteArgstring(MyArgString);
}
else
Printf("Can't create arg string!\n");

DeleteRexxMsg(MyMsg);
}
else
Printf("Can't create RexxMsg!\n");

DeletePort(MyPort);
}
else
Printf("Can't creates ports!\n");
}
else
{
Permit();
Printf("Can't find port!\n");
}
}

How can i get a result from MAILMANAGER port? :)

Kind regards



Success is like a fart - only your own smells nice.
-- James P. Hogan

DSS *FingerTip* = 3F7B F842 A848 1C4F 43F5 6542 92BD 1356 D1AB 8136
9CB1 820C F9F4 1B2E D8C1 D316 8209 D71C DFE2 CD61