Fixed a few warnings.
[tangerine.git] / workbench / libs / openurl / library / handler.c
blob3f4ae8a4963774e8c59aa400e6f056e4dd4f1914
1 /*
2 ** OpenURL-Handler - Asynch ARexx handler for openurl.library
3 **
4 ** Written by Troels Walsted Hansen <troels@thule.no>
5 ** Placed in the public domain.
6 **
7 ** Developed by:
8 ** - Alfonso Ranieri <alforan@tin.it>
9 ** - Stefan Kost <ensonic@sonicpulse.de>
13 #include "lib.h"
15 /***********************************************************************/
17 static ULONG
18 sendRexxMsg(struct MsgPort *reply,UBYTE *rxport,UBYTE *rxcmd)
20 struct RexxMsg *rxmsg;
22 if ((rxmsg = CreateRexxMsg(reply,NULL,NULL)))
24 rxmsg->rm_Action = RXCOMM|RXFF_STRING|RXFF_NOIO;
26 if ((rxmsg->rm_Args[0] = CreateArgstring(rxcmd,strlen(rxcmd))))
28 struct MsgPort *port;
30 Forbid();
32 if ((port = FindPort(rxport)))
34 PutMsg(port,(struct Message *)rxmsg);
35 Permit();
37 return TRUE;
40 Permit();
42 DeleteArgstring(rxmsg->rm_Args[0]);
45 DeleteRexxMsg(rxmsg);
48 return FALSE;
51 /**************************************************************************/
53 #ifdef __MORPHOS__
54 void handler(void)
55 #else
56 void SAVEDS handler(void)
57 #endif
59 struct MsgPort port;
60 struct Process *me = (struct Process *)FindTask(NULL);
61 struct startMsg *smsg;
62 ULONG res;
63 int sig;
65 WaitPort(&me->pr_MsgPort);
66 smsg = (struct startMsg *)GetMsg(&me->pr_MsgPort);
68 if ((sig = AllocSignal(-1))>=0)
70 INITPORT(&port,sig);
71 res = sendRexxMsg(&port,smsg->port,smsg->cmd);
73 else res = FALSE;
75 smsg->res = res;
76 ReplyMsg((struct Message *)smsg);
78 if (res)
80 struct RexxMsg *rxmsg;
82 WaitPort(&port);
83 rxmsg = (struct RexxMsg *)GetMsg(&port);
85 DeleteArgstring(rxmsg->rm_Args[0]);
86 DeleteRexxMsg(rxmsg);
89 if (sig>=0) FreeSignal(sig);
91 Forbid();
92 lib_use--;
95 /**************************************************************************/