add remtask before addtask
[AROS.git] / rom / filesys / fat / support.c
blob1529dbc3ce00214bf55f987a3c608daf45eed0c4
1 /*
2 * fat-handler - FAT12/16/32 filesystem handler
4 * Copyright © 2006 Marek Szyprowski
5 * Copyright © 2007-2008 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) {
31 struct IOStdReq *InputRequest;
32 struct MsgPort *InputPort;
33 struct InputEvent *ie;
35 if ((InputPort = (struct MsgPort*)CreateMsgPort())) {
37 if ((InputRequest = (struct IOStdReq*)CreateIORequest(InputPort, sizeof(struct IOStdReq)))) {
39 if (!OpenDevice("input.device", 0, (struct IORequest*)InputRequest, 0)) {
41 if ((ie = AllocVec(sizeof(struct InputEvent), MEMF_PUBLIC | MEMF_CLEAR))) {
42 ie->ie_Class = event;
43 InputRequest->io_Command = IND_WRITEEVENT;
44 InputRequest->io_Data = ie;
45 InputRequest->io_Length = sizeof(struct InputEvent);
47 DoIO((struct IORequest*)InputRequest);
49 FreeVec(ie);
51 CloseDevice((struct IORequest*)InputRequest);
53 DeleteIORequest((struct IORequest *)InputRequest);
55 DeleteMsgPort (InputPort);
59 /*-------------------------------------------------------------------------*/
61 int ilog2(ULONG data) {
62 int bitoffset = 31;
63 ULONG bitmask = 1 << bitoffset;
65 do {
66 if ((data & bitmask) != 0)
67 return bitoffset;
69 bitoffset--;
70 bitmask >>= 1;
71 } while (bitmask != 0);
73 return 0;
76 /*-----------------------------------------------------------------------*/
78 void ErrorMessageArgs(char *fmt, IPTR *ap, struct Globals *glob)
80 struct IntuitionBase *IntuitionBase;
82 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 36);
83 if (IntuitionBase) {
84 struct EasyStruct es = {
85 sizeof (struct EasyStruct),
87 "FAT filesystem critical error",
88 NULL,
89 "Ok"
92 es.es_TextFormat = fmt;
93 EasyRequestArgs(NULL, &es, NULL, ap);
94 CloseLibrary((struct Library *)IntuitionBase);