added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / fs / fat / support.c
blob1da06b29030029c7042ea5e093e742cc798dbd7f
1 /*
2 * fat.handler - FAT12/16/32 filesystem handler
4 * Copyright © 2006 Marek Szyprowski
5 * Copyright © 2007 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 <string.h>
27 #include "fat_fs.h"
29 void SendEvent(LONG event) {
30 struct IOStdReq *InputRequest;
31 struct MsgPort *InputPort;
32 struct InputEvent *ie;
34 if ((InputPort = (struct MsgPort*)CreateMsgPort())) {
36 if ((InputRequest = (struct IOStdReq*)CreateIORequest(InputPort, sizeof(struct IOStdReq)))) {
38 if (!OpenDevice("input.device", 0, (struct IORequest*)InputRequest, 0)) {
40 if ((ie = AllocVec(sizeof(struct InputEvent), MEMF_PUBLIC | MEMF_CLEAR))) {
41 ie->ie_Class = event;
42 InputRequest->io_Command = IND_WRITEEVENT;
43 InputRequest->io_Data = ie;
44 InputRequest->io_Length = sizeof(struct InputEvent);
46 DoIO((struct IORequest*)InputRequest);
48 FreeVec(ie);
50 CloseDevice((struct IORequest*)InputRequest);
52 DeleteIORequest (InputRequest);
54 DeleteMsgPort (InputPort);
58 /*-------------------------------------------------------------------------*/
60 int ilog2(ULONG data) {
61 int bitoffset = 31;
62 ULONG bitmask = 1 << bitoffset;
64 do {
65 if ((data & bitmask) != 0)
66 return bitoffset;
68 bitoffset--;
69 bitmask >>= 1;
70 } while (bitmask != 0);
72 return 0;
75 /*-----------------------------------------------------------------------*/