root / Whitix / branches / hybrid / lib / bitmap.c

Revision 546, 2.0 kB (checked in by mwhitworth, 3 months ago)

Add some SYMBOL_EXPORT functions.

Line 
1/*  This file is part of Whitix.
2 *
3 *  Whitix is free software; you can redistribute it and/or modify
4 *  it under the terms of the GNU General Public License as published by
5 *  the Free Software Foundation; either version 2 of the License, or
6 *  (at your option) any later version.
7 *
8 *  Whitix is distributed in the hope that it will be useful,
9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 *  GNU General Public License for more details.
12 *
13 *  You should have received a copy of the GNU General Public License
14 *  along with Whitix; if not, write to the Free Software
15 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16 *
17 */
18
19#include <bitmap.h>
20#include <module.h>
21#include <typedefs.h>
22
23const BYTE bMasks[2][8]={
24        {0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F},
25        {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}
26};
27
28/***********************************************************************
29 *
30 * FUNCTION:    BmapSetBit
31 *
32 * DESCRIPTION: Set a bit in a bitmap.
33 *
34 * PARAMETERS:  array - bitmap in question.
35 *                              index - index (in bits) of the value to be set.
36 *                              value - value to set bit to - 0 or 1.
37 *
38 * RETURNS:             Nothing.
39 *
40 ***********************************************************************/
41
42void BmapSetBit(void* array,DWORD index,int value)
43{       
44        DWORD offset=index/8;
45
46        if (value)
47                ((BYTE*)array)[offset]|=bMasks[value][index & 7];
48        else
49                ((BYTE*)array)[offset]&=bMasks[value][index & 7];
50}
51
52SYMBOL_EXPORT(BmapSetBit);
53
54/***********************************************************************
55 *
56 * FUNCTION:    BmapGetBit
57 *
58 * DESCRIPTION: Get the value of a bit in a bitmap.
59 *
60 * PARAMETERS:  array - bitmap in question.
61 *                              index - index (in bits) of the bit.
62 *
63 * RETURNS:             Value of the bit at index.
64 *
65 ***********************************************************************/
66
67int BmapGetBit(void* array,DWORD index)
68{
69        return ((BYTE*)array)[index/8] & (1 << (index & 7));
70}
71
72SYMBOL_EXPORT(BmapGetBit);
Note: See TracBrowser for help on using the browser.