Trust uboot's device list only if it does not look suspicious.
[AROS.git] / test / dos / notify.c
blobb522985b77da6c8c88e6fa48c9ff460f8bcbc5f5
1 #include <exec/types.h>
2 #include <dos/dosextens.h>
3 #include <dos/bptr.h>
4 #include <dos/notify.h>
5 #include <proto/exec.h>
6 #include <proto/dos.h>
7 #include <stdio.h>
8 #include <string.h>
10 int main(int argc, char **argv)
12 struct NotifyRequest *nr;
13 struct MsgPort *port;
14 struct Message *msg;
16 if (argc != 2)
18 printf("usage: %s filename\n", argv[0]);
19 return 1;
22 port = CreateMsgPort();
24 nr = AllocVec(sizeof(struct NotifyRequest) + strlen(argv[1]) + 1, MEMF_PUBLIC | MEMF_CLEAR);
25 nr->nr_Name = (STRPTR) (((UBYTE *) nr) + sizeof(struct NotifyRequest));
27 CopyMem(argv[1], nr->nr_Name, strlen(argv[1]) + 1);
29 nr->nr_Flags = NRF_SEND_MESSAGE;
30 nr->nr_stuff.nr_Msg.nr_Port = port;
32 if (StartNotify(nr) == DOSFALSE)
34 printf("StartNotify failed: %ld\n", (long)IoErr());
35 DeleteMsgPort(port);
36 return 0;
39 Wait((1L << port->mp_SigBit) | SIGBREAKF_CTRL_C);
41 msg = GetMsg(port);
42 if (msg)
44 printf("notified\n");
45 ReplyMsg(msg);
47 else
48 printf("CTRL-C received\n");
50 EndNotify(nr);
51 DeleteMsgPort(port);
53 return 0;