Made comments and debug output more consistent.
[AROS.git] / rom / filesys / fat / support.c
blob8e1a13b0d25e64a1577ce05604a316b3388e9494
1 /*
2 * fat-handler - FAT12/16/32 filesystem handler
4 * Copyright © 2006 Marek Szyprowski
5 * Copyright © 2007-2015 The AROS Development Team
7 * This program is free software; you can redistribute it and/or modify it
8 * under the same terms as AROS itself.
10 * $Id$
13 #include <exec/types.h>
14 #include <exec/execbase.h>
15 #include <dos/dosextens.h>
16 #include <dos/filehandler.h>
17 #include <devices/input.h>
18 #include <devices/inputevent.h>
19 #include <intuition/intuition.h>
20 #include <intuition/intuitionbase.h>
22 #include <proto/intuition.h>
23 #include <proto/exec.h>
25 #include <stdarg.h>
26 #include <string.h>
28 #include "fat_fs.h"
30 void SendEvent(LONG event, struct Globals *glob)
32 struct IOStdReq *InputRequest;
33 struct MsgPort *InputPort;
34 struct InputEvent *ie;
36 if ((InputPort = (struct MsgPort *)CreateMsgPort()))
39 if ((InputRequest = (struct IOStdReq *)CreateIORequest(InputPort,
40 sizeof(struct IOStdReq))))
43 if (!OpenDevice("input.device", 0,
44 (struct IORequest *)InputRequest, 0))
47 if ((ie = AllocVec(sizeof(struct InputEvent),
48 MEMF_PUBLIC | MEMF_CLEAR)))
50 ie->ie_Class = event;
51 InputRequest->io_Command = IND_WRITEEVENT;
52 InputRequest->io_Data = ie;
53 InputRequest->io_Length = sizeof(struct InputEvent);
55 DoIO((struct IORequest *)InputRequest);
57 FreeVec(ie);
59 CloseDevice((struct IORequest *)InputRequest);
61 DeleteIORequest((struct IORequest *)InputRequest);
63 DeleteMsgPort(InputPort);
67 int ilog2(ULONG data)
69 int bitoffset = 31;
70 ULONG bitmask = 1 << bitoffset;
74 if ((data & bitmask) != 0)
75 return bitoffset;
77 bitoffset--;
78 bitmask >>= 1;
80 while (bitmask != 0);
82 return 0;
85 void ErrorMessageArgs(char *fmt, IPTR *ap, struct Globals *glob)
87 struct IntuitionBase *IntuitionBase;
89 IntuitionBase =
90 (struct IntuitionBase *)OpenLibrary("intuition.library", 36);
91 if (IntuitionBase)
93 struct EasyStruct es =
95 sizeof(struct EasyStruct),
97 "FAT filesystem critical error",
98 NULL,
99 "Ok"
102 es.es_TextFormat = fmt;
103 EasyRequestArgs(NULL, &es, NULL, ap);
104 CloseLibrary((struct Library *)IntuitionBase);