Detabbed
[AROS.git] / rom / dos / endnotify.c
blob057b313cf0e3b037f02a2b702645df05eb4812ed
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <aros/debug.h>
10 #include <exec/lists.h>
11 #include <proto/exec.h>
13 #include "dos_intern.h"
15 /*****************************************************************************
17 NAME */
19 #include <dos/notify.h>
20 #include <proto/dos.h>
22 #include <string.h>
24 AROS_LH1(void, EndNotify,
26 /* SYNOPSIS */
27 AROS_LHA(struct NotifyRequest *, notify, D1),
29 /* LOCATION */
30 struct DosLibrary *, DOSBase, 149, Dos)
32 /* FUNCTION
34 End a notification (quit notifying for a request previously sent with
35 StartNotify()).
37 INPUTS
39 notify -- NotifyRequest used with StartNotify()
41 RESULT
43 NOTES
45 EXAMPLE
47 BUGS
49 SEE ALSO
51 StartNotify()
53 INTERNALS
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
60 * Packet handlers love to replace nr_Handler of active requests with a pointer
61 * to own real message port. It's not possible to prevent this by (simple) external
62 * means.
63 * This is why we use packet I/O here on all architectures. If nr_Handler points
64 * to packet message port, the packet will be sent directly, bypassing IOFS layer.
65 * This is 100% safe because we don't pass any locks and/or filehandles here.
66 * If nr_Handler still points to IOFS device, packet I/O emulator will take care about
67 * this.
69 dopacket1(DOSBase, NULL, notify->nr_Handler, ACTION_REMOVE_NOTIFY, (SIPTR)notify);
71 /* free fullname if it was built in StartNotify() */
72 if (notify->nr_FullName != notify->nr_Name)
73 FreeVec(notify->nr_FullName);
75 /* if the filesystem has outstanding messages, they need to be replied */
76 if ((notify->nr_Flags & NRF_SEND_MESSAGE) &&
77 ((notify->nr_Flags & NRF_WAIT_REPLY) || notify->nr_MsgCount > 0))
79 struct MsgPort *port = notify->nr_stuff.nr_Msg.nr_Port;
80 struct NotifyMessage *nm, *tmp;
82 notify->nr_Flags &= ~NRF_MAGIC;
84 /* protect access to the message list */
85 Disable();
87 /* loop over the messages */
88 ForeachNodeSafe(&port->mp_MsgList, nm, tmp) {
89 /* if its one of our notify messages */
90 if (nm->nm_Class == NOTIFY_CLASS &&
91 nm->nm_Code == NOTIFY_CODE &&
92 nm->nm_NReq == notify) {
94 /* remove and reply */
95 Remove((struct Node *) nm);
96 ReplyMsg((struct Message *) nm);
98 /* decrement the count. bail early if we've done them all */
99 notify->nr_MsgCount--;
100 if (notify->nr_MsgCount == 0)
101 break;
105 /* unlock the list */
106 Enable();
109 AROS_LIBFUNC_EXIT
110 } /* EndNotify */