r26391@plastic: rob | 2007-05-14 21:47:02 +1000
[cake.git] / rom / dos / endnotify.c
blobac7039fb4d3003b963851c4e3a0fa4be4ff18916
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include "dos_intern.h"
10 #include <exec/lists.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
15 NAME */
17 #include <dos/notify.h>
18 #include <proto/dos.h>
20 #include <string.h>
22 AROS_LH1(void, EndNotify,
24 /* SYNOPSIS */
25 AROS_LHA(struct NotifyRequest *, notify, D1),
27 /* LOCATION */
28 struct DosLibrary *, DOSBase, 149, Dos)
30 /* FUNCTION
32 End a notification (quit notifying for a request previously sent with
33 StartNotify()).
35 INPUTS
37 notify -- NotifyRequest used with StartNotify()
39 RESULT
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
49 StartNotify()
51 INTERNALS
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
57 struct IOFileSys iofs;
58 struct DevProc *dvp;
60 if ((dvp = GetDeviceProc(notify->nr_FullName, NULL)) == NULL)
61 return;
63 InitIOFS(&iofs, FSA_REMOVE_NOTIFY, DOSBase);
64 iofs.io_Union.io_NOTIFY.io_NotificationRequest = notify;
66 iofs.IOFS.io_Device = (struct Device *) dvp->dvp_Port;
68 if (dvp->dvp_Lock != NULL)
69 iofs.IOFS.io_Unit = ((struct FileHandle *) BADDR(dvp->dvp_Lock))->fh_Unit;
70 else
71 iofs.IOFS.io_Unit = dvp->dvp_DevNode->dol_Ext.dol_AROS.dol_Unit;
73 FreeDeviceProc(dvp);
75 DoIO(&iofs.IOFS);
77 if (notify->nr_FullName != notify->nr_Name)
78 FreeVec(notify->nr_FullName);
80 if (notify->nr_Flags & NRF_SEND_MESSAGE &&
81 (notify->nr_Flags & NRF_WAIT_REPLY || notify->nr_MsgCount)) {
83 struct MsgPort *port = notify->nr_stuff.nr_Msg.nr_Port;
84 struct NotifyMessage *nm, *tmp;
86 notify->nr_Flags &= ~NRF_MAGIC;
88 Disable();
90 ForeachNodeSafe(&port->mp_MsgList, nm, tmp) {
91 if (nm->nm_Class == NOTIFY_CLASS &&
92 nm->nm_Code == NOTIFY_CODE &&
93 nm->nm_NReq == notify) {
95 Remove((struct Node *) nm);
96 ReplyMsg((struct Message *) nm);
98 notify->nr_MsgCount--;
99 if (notify->nr_MsgCount == 0)
100 break;
104 Enable();
107 AROS_LIBFUNC_EXIT
108 } /* EndNotify */