grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / filesys / fat / support.c
bloba5017e59f6640ecf03177d5e854e49f92eb3490b
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>
24 #include <proto/alib.h>
26 #include <stdarg.h>
27 #include <string.h>
29 #include "fat_fs.h"
31 void SendEvent(LONG event, struct Globals *glob)
33 struct IOStdReq *InputRequest;
34 struct MsgPort *InputPort;
35 struct InputEvent *ie;
37 if ((InputPort = (struct MsgPort *)CreateMsgPort()))
40 if ((InputRequest = (struct IOStdReq *)CreateIORequest(InputPort,
41 sizeof(struct IOStdReq))))
44 if (!OpenDevice("input.device", 0,
45 (struct IORequest *)InputRequest, 0))
48 if ((ie = AllocVec(sizeof(struct InputEvent),
49 MEMF_PUBLIC | MEMF_CLEAR)))
51 ie->ie_Class = event;
52 InputRequest->io_Command = IND_WRITEEVENT;
53 InputRequest->io_Data = ie;
54 InputRequest->io_Length = sizeof(struct InputEvent);
56 DoIO((struct IORequest *)InputRequest);
58 FreeVec(ie);
60 CloseDevice((struct IORequest *)InputRequest);
62 DeleteIORequest((struct IORequest *)InputRequest);
64 DeleteMsgPort(InputPort);
68 int ilog2(ULONG data)
70 int bitoffset = 31;
71 ULONG bitmask = 1 << bitoffset;
75 if ((data & bitmask) != 0)
76 return bitoffset;
78 bitoffset--;
79 bitmask >>= 1;
81 while (bitmask != 0);
83 return 0;
86 LONG ErrorMessageArgs(struct Globals *glob, char *options, CONST_STRPTR format, ...)
88 struct IntuitionBase *IntuitionBase;
89 LONG answer = 0;
91 AROS_SLOWSTACKFORMAT_PRE(format);
93 IntuitionBase =
94 (struct IntuitionBase *)OpenLibrary("intuition.library", 36);
95 if (IntuitionBase)
97 struct EasyStruct es =
99 sizeof(struct EasyStruct),
101 "FAT filesystem",
102 NULL,
103 options
106 es.es_TextFormat = format;
107 answer = EasyRequestArgs(NULL, &es, NULL, AROS_SLOWSTACKFORMAT_ARG(format));
108 CloseLibrary((struct Library *)IntuitionBase);
111 AROS_SLOWSTACKFORMAT_POST(format);
113 return answer;