]> git.sur5r.net Git - openldap/blob - libraries/liblunicode/ure/ure.h
Initial revision
[openldap] / libraries / liblunicode / ure / ure.h
1 /*
2  * Copyright 1997, 1998, 1999 Computing Research Labs,
3  * New Mexico State University
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
20  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 #ifndef _h_ure
24 #define _h_ure
25
26 /*
27  * $Id: ure.h,v 1.2 1999/09/21 15:47:44 mleisher Exp $
28  */
29
30 #include <stdio.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 #undef __
37 #ifdef __STDC__
38 #define __(x) x
39 #else
40 #define __(x) ()
41 #endif
42
43 /*
44  * Set of character class flags.
45  */
46 #define _URE_NONSPACING  0x00000001
47 #define _URE_COMBINING   0x00000002
48 #define _URE_NUMDIGIT    0x00000004
49 #define _URE_NUMOTHER    0x00000008
50 #define _URE_SPACESEP    0x00000010
51 #define _URE_LINESEP     0x00000020
52 #define _URE_PARASEP     0x00000040
53 #define _URE_CNTRL       0x00000080
54 #define _URE_PUA         0x00000100
55
56 #define _URE_UPPER       0x00000200
57 #define _URE_LOWER       0x00000400
58 #define _URE_TITLE       0x00000800
59 #define _URE_MODIFIER    0x00001000
60 #define _URE_OTHERLETTER 0x00002000
61 #define _URE_DASHPUNCT   0x00004000
62 #define _URE_OPENPUNCT   0x00008000
63 #define _URE_CLOSEPUNCT  0x00010000
64 #define _URE_OTHERPUNCT  0x00020000
65 #define _URE_MATHSYM     0x00040000
66 #define _URE_CURRENCYSYM 0x00080000
67 #define _URE_OTHERSYM    0x00100000
68
69 #define _URE_LTR         0x00200000
70 #define _URE_RTL         0x00400000
71
72 #define _URE_EURONUM     0x00800000
73 #define _URE_EURONUMSEP  0x01000000
74 #define _URE_EURONUMTERM 0x02000000
75 #define _URE_ARABNUM     0x04000000
76 #define _URE_COMMONSEP   0x08000000
77
78 #define _URE_BLOCKSEP    0x10000000
79 #define _URE_SEGMENTSEP  0x20000000
80
81 #define _URE_WHITESPACE  0x40000000
82 #define _URE_OTHERNEUT   0x80000000
83
84 /*
85  * Error codes.
86  */
87 #define _URE_OK               0
88 #define _URE_UNEXPECTED_EOS   -1
89 #define _URE_CCLASS_OPEN      -2
90 #define _URE_UNBALANCED_GROUP -3
91 #define _URE_INVALID_PROPERTY -4
92
93 /*
94  * Options that can be combined for searching.
95  */
96 #define URE_IGNORE_NONSPACING      0x01
97 #define URE_DOT_MATCHES_SEPARATORS 0x02
98
99 typedef unsigned long ucs4_t;
100 typedef unsigned short ucs2_t;
101
102 /*
103  * Opaque type for memory used when compiling expressions.
104  */
105 typedef struct _ure_buffer_t *ure_buffer_t;
106
107 /*
108  * Opaque type for the minimal DFA used when matching.
109  */
110 typedef struct _ure_dfa_t *ure_dfa_t;
111
112 /*************************************************************************
113  *
114  * API.
115  *
116  *************************************************************************/
117
118 extern ure_buffer_t ure_buffer_create __((void));
119
120 extern void ure_buffer_free __((ure_buffer_t buf));
121
122 extern ure_dfa_t ure_compile __((ucs2_t *re, unsigned long relen,
123                                  int casefold, ure_buffer_t buf));
124
125 extern void ure_dfa_free __((ure_dfa_t dfa));
126
127 extern void ure_write_dfa __((ure_dfa_t dfa, FILE *out));
128
129 extern int ure_exec __((ure_dfa_t dfa, int flags,
130                         ucs2_t *text, unsigned long textlen,
131                         unsigned long *match_start, unsigned long *match_end));
132
133 /*************************************************************************
134  *
135  * Prototypes for stub functions used for URE.  These need to be rewritten to
136  * use the Unicode support available on the system.
137  *
138  *************************************************************************/
139
140 extern ucs4_t _ure_tolower __((ucs4_t c));
141
142 extern int _ure_matches_properties __((unsigned long props, ucs4_t c));
143
144 #undef __
145
146 #ifdef __cplusplus
147 }
148 #endif
149
150 #endif /* _h_ure */