/********************************************************************
 ** PARALLEL PORT STUFF
 **
 ** (c) Spak, Darrell Tam, c9107253@ee.newcastle.edu.au (1994)
 ** phone (Australia) 049-829-710
 **                    49-829-710
 ** (c) SST 1994
 **
 ** LITTLE TEST CLIENT (A "SENDER") FOR SENDING
 **
 ** DOES THE FOLLOWING - SETS UP A PACKET TO SEND OUT 2 MEMORY AREAS
 ** AND THEN RECEIVE BACK 2 MEMORY AREAS (WHICH IS THE NORMAL PACKET)
 **
 ** TABS to 4
 ********************************************************************/

#include "/snd/everything.h"
#include <st/st_proto.h>
#include "parstuff.h"

#define OUR_SERVER_PORT 11

char	send[1000];
char	recv1[1000];
char	recv2[1000];

long out;

main(int argc, char *argv[])
{
struct MsgPort *port = NULL, *theport = NULL;
char destmach = argv[1][0];

	out = Output();

	if(!(port = CreatePort(0,0))) {
		fpf(out, "No ports\n");
		goto nomore;
	}

	if(!(theport = FindPort("ParServer")) ) {
		fpf(out, "Couldn't find par port packet thingy\n");
		goto nomore;
	}


/** TRY AND SEND OUT SOME TEXT */
{
struct PktMsg our_pm;
struct StdReq our_sr;
	spf(send,100,argv[2]);

/** SEND OUT OUR MESSAGE */
	INIT_PKTMSG_ORIGINAL(&our_pm, port,
						destmach, OUR_SERVER_PORT,
						&our_sr, sizeof(our_sr),
						send, 1000,
						recv1, 1000,
						recv2, 40);

	fpf(out, "Sending...\n");
	PutMsg(theport, &our_pm); WaitPort(port);

	if(&our_pm != (struct PktMsg *)GetMsg(port)) 
		fpf(out, "Some kind of error just happened - spurious message recv'd\n");

	recv2[40] = 0;
	fpf(out, "Return code=(%ld)\n"
			"Got back [%s]\n",
			our_pm.smsg.result, recv2);

}

nomore:
	if(port) DeletePort(port);
}

