Fixed compatibility of output.
[AROS.git] / external / openurl / library / handler.c
blobb9d237579fcdcf6098674cd03317a946d4205259
1 /***************************************************************************
3 openurl.library - universal URL display and browser launcher library
4 Copyright (C) 1998-2005 by Troels Walsted Hansen, et al.
5 Copyright (C) 2005-2013 by openurl.library Open Source Team
7 This library is free software; it has been placed in the public domain
8 and you can freely redistribute it and/or modify it. Please note, however,
9 that some components may be under the LGPL or GPL license.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 openurl.library project: http://sourceforge.net/projects/openurllib/
17 $Id$
19 ***************************************************************************/
21 #include "lib.h"
22 #include "debug.h"
24 /***********************************************************************/
26 static BOOL localSendRexxMsg(struct MsgPort *reply, STRPTR rxport, STRPTR rxcmd)
28 BOOL success = FALSE;
29 struct RexxMsg *rxmsg;
31 ENTER();
33 if((rxmsg = CreateRexxMsg(reply, NULL, NULL)) != NULL)
35 rxmsg->rm_Action = RXCOMM|RXFF_STRING|RXFF_NOIO;
37 if((rxmsg->rm_Args[0] = (IPTR)CreateArgstring(rxcmd,strlen(rxcmd))) != 0)
39 struct MsgPort *port;
41 Forbid();
43 if((port = FindPort(rxport)) != NULL)
45 PutMsg(port, (struct Message *)rxmsg);
47 success = TRUE;
50 Permit();
52 if(success == FALSE)
53 DeleteArgstring((APTR)rxmsg->rm_Args[0]);
56 if(success == FALSE)
57 DeleteRexxMsg(rxmsg);
60 RETURN(success);
61 return success;
64 /**************************************************************************/
66 void SAVEDS handler(void)
68 struct Process *me = (struct Process *)FindTask(NULL);
69 struct startMsg *smsg;
70 struct MsgPort *port;
71 BOOL res = FALSE;
73 ENTER();
75 WaitPort(&me->pr_MsgPort);
76 smsg = (struct startMsg *)GetMsg(&me->pr_MsgPort);
78 #if defined(__amigaos4__)
79 port = AllocSysObject(ASOT_PORT, TAG_DONE);
80 #else
81 port = CreateMsgPort();
82 #endif
84 if(port != NULL)
85 res = localSendRexxMsg(port, smsg->port, smsg->cmd);
87 smsg->res = res;
88 ReplyMsg((struct Message *)smsg);
90 if(res == TRUE)
92 struct RexxMsg *rxmsg;
94 WaitPort(port);
95 rxmsg = (struct RexxMsg *)GetMsg(port);
97 DeleteArgstring((APTR)rxmsg->rm_Args[0]);
98 DeleteRexxMsg(rxmsg);
101 if(port != NULL)
103 #if defined(__amigaos4__)
104 FreeSysObject(ASOT_PORT, port);
105 #else
106 DeleteMsgPort(port);
107 #endif
110 ObtainSemaphore(&OpenURLBase->libSem);
111 OpenURLBase->rexx_use--;
112 ReleaseSemaphore(&OpenURLBase->libSem);
114 #if !defined(__amigaos4__)
115 // all systems except OS4 should leave this function in forbidden state
116 Forbid();
117 #endif
119 LEAVE();
122 /**************************************************************************/