home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
200-299
/
ff227.lzh
/
PickPacket
/
src
/
sendpkt.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-25
|
2KB
|
69 lines
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* |_o_o|\\ Copyright (c) 1989 The Software Distillery. *
* |. o.| || All Rights Reserved *
* | . | || Written by John Toebes and Doug Walker *
* | o | || The Software Distillery *
* | . |// 235 Trillingham Lane *
* ====== Cary, NC 27513 *
* BBS:(919)-471-6436 *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <exec/types.h>
#include <exec/memory.h>
#include <exec/ports.h>
#include <libraries/dosextens.h>
#include <proto/exec.h>
#include <proto/dos.h>
LONG sendpkt(struct MsgPort *, long, long*, long, long*);
LONG sendpkt(pid,action,args,nargs,res)
struct MsgPort *pid; /* process indentifier ... (handlers message port ) */
LONG action, /* packet type ... (what you want handler to do ) */
args[], /* a pointer to a argument list */
nargs, /* number of arguments in list */
res[]; /* pointer to 2 longs for result, or NULL */
{
struct MsgPort *replyport;
struct StandardPacket *packet;
LONG count, lres, *pargs;
replyport = (struct MsgPort *) CreatePort(NULL,0);
if(!replyport) return(0L);
packet = (struct StandardPacket *)
AllocMem((long)sizeof(struct StandardPacket),MEMF_PUBLIC|MEMF_CLEAR);
if(!packet)
{
DeletePort(replyport);
return(0L);
}
packet->sp_Msg.mn_Node.ln_Name = (char *)&(packet->sp_Pkt);
packet->sp_Pkt.dp_Link = &(packet->sp_Msg);
packet->sp_Pkt.dp_Port = replyport;
packet->sp_Pkt.dp_Type = action;
/* copy the args into the packet */
pargs = &(packet->sp_Pkt.dp_Arg1); /* address of first argument */
for(count=0;count < nargs;count++)
pargs[count]=args[count];
PutMsg(pid,(struct Message *)packet); /* send packet */
WaitPort(replyport);
GetMsg(replyport);
if(res)
{
lres = res[0] = packet->sp_Pkt.dp_Res1;
res[1] = packet->sp_Pkt.dp_Res2;
}
FreeMem((char *)packet,(long)sizeof(struct StandardPacket));
DeletePort(replyport);
return(lres);
}