Imported Upstream version 1.0.5
[platform/upstream/fribidi.git] / lib / fribidi-types.h
1 /* FriBidi
2  * fribidi-types.h - define data types for the rest of the library
3  *
4  * Author:
5  *   Behdad Esfahbod, 2001, 2002, 2004
6  *
7  * Copyright (C) 2004 Sharif FarsiWeb, Inc.
8  * Copyright (C) 2001,2002 Behdad Esfahbod
9  * 
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  * 
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  * 
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this library, in a file named COPYING; if not, write to the
22  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  * Boston, MA 02110-1301, USA
24  *
25  * For licensing issues, contact <fribidi.license@gmail.com>.
26  */
27 #ifndef _FRIBIDI_TYPES_H
28 #define _FRIBIDI_TYPES_H
29
30 #ifdef HAVE_CONFIG_H
31 # include <config.h>
32 #endif
33
34 #include "fribidi-common.h"
35
36 #include "fribidi-begindecls.h"
37
38
39 # if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || \
40      defined (_sgi) || defined (__sun) || defined (sun) || \
41      defined (__digital__) || defined (__HP_cc)
42 #  include <inttypes.h>
43 # elif defined (_AIX)
44 #  include <sys/inttypes.h>
45 # else
46 #  include <stdint.h>
47 # endif
48
49 typedef int fribidi_boolean;
50
51 typedef uint32_t FriBidiChar;
52 typedef int FriBidiStrIndex;
53
54 /* The MSB is used to indicate an opening bracket */
55 typedef FriBidiChar FriBidiBracketType;
56
57 /* Use FRIBIDI_NO_BRACKET for assigning to a non-bracket */
58 #define FRIBIDI_NO_BRACKET 0
59
60 /* A few macros for working with bits */
61
62 #define FRIBIDI_TEST_BITS(x, mask) (((x) & (mask)) ? 1 : 0)
63
64 #define FRIBIDI_INCLUDE_BITS(x, mask) ((x) | (mask))
65
66 #define FRIBIDI_EXCLUDE_BITS(x, mask) ((x) & ~(mask))
67
68 #define FRIBIDI_SET_BITS(x, mask)       ((x) |= (mask))
69
70 #define FRIBIDI_UNSET_BITS(x, mask)     ((x) &= ~(mask))
71
72 #define FRIBIDI_ADJUST_BITS(x, mask, cond)      \
73         ((x) = ((x) & ~(mask)) | ((cond) ? (mask) : 0))
74
75 #define FRIBIDI_ADJUST_AND_TEST_BITS(x, mask, cond)     \
76         FRIBIDI_TEST_BITS(FRIBIDI_ADJUST_BITS((x), (mask), (cond)), (mask))
77
78 #include "fribidi-enddecls.h"
79
80 #endif /* !_FRIBIDI_TYPES_H */
81 /* Editor directions:
82  * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
83  */