Fixed misleading naming "strcmp" returning gboolean: -> "compare"
[captive.git] / src / libcaptive / include / captive / unicode.h
1 /* $Id$
2  * Include file for unicode add-ons to reactos ntoskrnl/rtl/unicode.c for libcaptive
3  * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #ifndef _CAPTIVE_UNICODE_H
21 #define _CAPTIVE_UNICODE_H 1
22
23
24 #include <glib/gmacros.h>
25 #include <glib/gtypes.h>
26 #include <glib/galloca.h>
27 #include "reactos/napi/types.h"  /* for PUNICODE_STRING etc. */
28 #include "reactos/ddk/rtltypes.h"       /* for ANSI_STRING */
29 #include <stddef.h>     /* for size_t and wchar_t */
30 #include <glib/gunicode.h>      /* for gunichar */
31
32
33 G_BEGIN_DECLS
34
35 /**
36  * captive_UnicodeString_to_utf8_alloca:
37  * @string_UnicodeString: #PUNICODE_STRING type of string to convert.
38  *
39  * alloca(3)-based conversion from #PUNICODE_STRING to plain #utf8 string.
40  *
41  * @Returns: #const #gchar * alloca(3)ed converted string @string_UnicodeString.
42  */
43 #define captive_UnicodeString_to_utf8_alloca(string_UnicodeString) \
44                 ({ /* GCC dependent */ \
45                         /* detect required memory size, g_alloca() cannot safely fail (really?) */ \
46                         gchar *mem=g_alloca(_captive_UnicodeString_to_utf8_alloca_internal_sizeof(string_UnicodeString)); \
47                         /* convert+copy the string to the prepared memory */ \
48                         _captive_UnicodeString_to_utf8_alloca_internal_fill(mem,string_UnicodeString); \
49                         (const gchar *)mem; \
50                         })
51 size_t _captive_UnicodeString_to_utf8_alloca_internal_sizeof(const UNICODE_STRING *string_UnicodeString);
52 void _captive_UnicodeString_to_utf8_alloca_internal_fill(gchar *mem,const UNICODE_STRING *string_UnicodeString);
53
54
55 /**
56  * captive_utf8_to_UnicodeString_alloca:
57  * @string_utf8: #const #gchar * string in #utf8 to convert.
58  *
59  * alloca(3)-based conversion from plain #utf8 string to #PUNICODE_STRING.
60  *
61  * @Returns: #PUNICODE_STRING alloca(3)ed converted string @string_utf8.
62  */
63 #define captive_utf8_to_UnicodeString_alloca(string_utf8) \
64                 ({ /* GCC dependent */ \
65                         /* detect required memory size, g_alloca() cannot safely fail (really?) */ \
66                         UNICODE_STRING *mem=g_alloca(_captive_utf8_to_UnicodeString_alloca_internal_sizeof(string_utf8)); \
67                         /* convert+copy the string to the prepared memory */ \
68                         _captive_utf8_to_UnicodeString_alloca_internal_fill(mem,string_utf8); \
69                         (PUNICODE_STRING)mem; \
70                         })
71 size_t _captive_utf8_to_UnicodeString_alloca_internal_sizeof(const gchar *string_utf8);
72 void _captive_utf8_to_UnicodeString_alloca_internal_fill(UNICODE_STRING *mem,const gchar *string_utf8);
73
74
75 gboolean captive_validate_ucs4(const gunichar *string_ucs4);
76 gboolean captive_validate_ucs2(const captive_ucs2 *string_ucs2);
77 gboolean captive_validate_ucs2_fixlen(const captive_ucs2 *string_ucs2,glong string_ucs2_fixlen);
78 gboolean captive_validate_utf8(const gchar *string_utf8);
79 glong captive_ucs2_strlen(const captive_ucs2 *string_ucs2) G_GNUC_PURE;
80 gboolean captive_validate_UnicodeString(const UNICODE_STRING *string_UnicodeString);
81 gboolean captive_validate_UnicodeString_noterm(const UNICODE_STRING *string_UnicodeString_noterm);
82 gboolean captive_validate_AnsiString(const ANSI_STRING *string_AnsiString);
83 gchar *captive_UnicodeString_to_utf8_malloc(const UNICODE_STRING *string_UnicodeString);
84 PUNICODE_STRING captive_utf8_to_UnicodeString_malloc(const gchar *string_utf8);
85 /* We can be G_GNUC_CONST as we really just map the pointer values.
86  * Initially we create the result content from the input content but it should not harm.
87  */
88 const gunichar2 *captive_ucs4_to_utf16_const(const gunichar *string_ucs4) G_GNUC_CONST;
89 gboolean captive_ucs2_compare(const captive_ucs2 *string_a_ucs2,const captive_ucs2 *string_b_ucs2);
90 gboolean captive_UnicodeString_compare
91                 (const UNICODE_STRING *string_a_UnicodeString,const UNICODE_STRING *string_b_UnicodeString);
92 gboolean captive_ucs2_compare_insensitive(const captive_ucs2 *string_a_ucs2,const captive_ucs2 *string_b_ucs2);
93 gboolean captive_UnicodeString_compare_insensitive
94                 (const UNICODE_STRING *string_a_UnicodeString,const UNICODE_STRING *string_b_UnicodeString);
95
96 /* internal: */
97 void captive_FsRtlLegalAnsiCharacterArray_init(void);
98
99 G_END_DECLS
100
101
102 #endif /* _CAPTIVE_UNICODE_H */