Use memset instead of bzero
[platform/upstream/libxkbcommon.git] / src / XKBcommonint.h
1 /*
2 Copyright 2008  Dan Nicholson
3
4 Permission is hereby granted, free of charge, to any person obtaining a
5 copy of this software and associated documentation files (the "Software"),
6 to deal in the Software without restriction, including without limitation
7 the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 and/or sell copies of the Software, and to permit persons to whom the
9 Software is furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21 Except as contained in this notice, the names of the authors or their
22 institutions shall not be used in advertising or otherwise to promote the
23 sale, use or other dealings in this Software without prior written
24 authorization from the authors.
25 */
26
27 #ifndef _XKBCOMMONINT_H_
28 #define _XKBCOMMONINT_H_
29
30 #include <stdlib.h>
31 #include <string.h>
32
33 #ifndef True
34 #define True  1
35 #define False 0
36 #endif
37
38 #define _XkbTypedAlloc(t)       ((t *)malloc(sizeof(t)))
39 #define _XkbTypedCalloc(n,t)    ((t *)calloc((n),sizeof(t)))
40 #define _XkbTypedRealloc(o,n,t) \
41     ((o)?(t *)realloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
42 #define _XkbClearElems(a,f,l,t) memset(&(a)[f], 0, ((l) - (f) + 1) * sizeof(t))
43
44 #define _XkbDupString(s)        ((s) ? strdup(s) : NULL)
45 #define _XkbStrCaseCmp          strcasecmp
46
47 /* From XKM.h */
48 #define XkmFileVersion          15
49
50 #define XkmIllegalFile          -1
51 #define XkmSemanticsFile        20
52 #define XkmLayoutFile           21
53 #define XkmKeymapFile           22
54 #define XkmGeometryFile         23
55 #define XkmRulesFile            24
56
57 #define XkmTypesIndex           0
58 #define XkmCompatMapIndex       1
59 #define XkmSymbolsIndex         2
60 #define XkmIndicatorsIndex      3
61 #define XkmKeyNamesIndex        4
62 #define XkmGeometryIndex        5
63 #define XkmVirtualModsIndex     6
64 #define XkmLastIndex            XkmVirtualModsIndex
65
66 #define XkmTypesMask            (1<<0)
67 #define XkmCompatMapMask        (1<<1)
68 #define XkmSymbolsMask          (1<<2)
69 #define XkmIndicatorsMask       (1<<3)
70 #define XkmKeyNamesMask         (1<<4)
71 #define XkmGeometryMask         (1<<5)
72 #define XkmVirtualModsMask      (1<<6)
73 #define XkmLegalIndexMask       (0x7f)
74 #define XkmAllIndicesMask       (0x7f)
75
76 #define XkmSemanticsRequired    (XkmCompatMapMask)
77 #define XkmSemanticsOptional    (XkmTypesMask|XkmVirtualModsMask|XkmIndicatorsMask)
78 #define XkmSemanticsLegal       (XkmSemanticsRequired|XkmSemanticsOptional)
79 #define XkmLayoutRequired       (XkmKeyNamesMask|XkmSymbolsMask|XkmTypesMask)
80 #define XkmLayoutOptional       (XkmVirtualModsMask|XkmGeometryMask)
81 #define XkmLayoutLegal          (XkmLayoutRequired|XkmLayoutOptional)
82 #define XkmKeymapRequired       (XkmSemanticsRequired|XkmLayoutRequired)
83 #define XkmKeymapOptional       ((XkmSemanticsOptional|XkmLayoutOptional)&(~XkmKeymapRequired))
84 #define XkmKeymapLegal          (XkmKeymapRequired|XkmKeymapOptional)
85
86 #define XkmLegalSection(m)      (((m)&(~XkmKeymapLegal))==0)
87 #define XkmSingleSection(m)     (XkmLegalSection(m)&&(((m)&(~(m)+1))==(m)))
88
89 #endif /* _XKBCOMMONINT_H_ */