typo..
[AROS.git] / test / dos / notify.c
blob9a6a1eaa5261063fc5e20d36f220645f52bfc623
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/types.h>
7 #include <dos/dosextens.h>
8 #include <dos/bptr.h>
9 #include <dos/notify.h>
10 #include <proto/exec.h>
11 #include <proto/dos.h>
12 #include <stdio.h>
13 #include <string.h>
15 int main(int argc, char **argv)
17 struct NotifyRequest *nr;
18 struct MsgPort *port;
19 struct Message *msg;
21 if (argc != 2)
23 printf("usage: %s filename\n", argv[0]);
24 return 1;
27 port = CreateMsgPort();
29 nr = AllocVec(sizeof(struct NotifyRequest) + strlen(argv[1]) + 1, MEMF_PUBLIC | MEMF_CLEAR);
30 nr->nr_Name = (STRPTR) (((UBYTE *) nr) + sizeof(struct NotifyRequest));
32 CopyMem(argv[1], nr->nr_Name, strlen(argv[1]) + 1);
34 nr->nr_Flags = NRF_SEND_MESSAGE;
35 nr->nr_stuff.nr_Msg.nr_Port = port;
37 if (StartNotify(nr) == DOSFALSE)
39 printf("StartNotify failed: %ld\n", (long)IoErr());
40 DeleteMsgPort(port);
41 return 0;
44 Wait((1L << port->mp_SigBit) | SIGBREAKF_CTRL_C);
46 msg = GetMsg(port);
47 if (msg)
49 printf("notified\n");
50 ReplyMsg(msg);
52 else
53 printf("CTRL-C received\n");
55 EndNotify(nr);
56 DeleteMsgPort(port);
58 return 0;