00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __CR_DEFS_H__
00024 #define __CR_DEFS_H__
00025
00026 #include "libcroco-config.h"
00027 #include <stdio.h>
00028 #include <glib.h>
00029
00030
00031 G_BEGIN_DECLS
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 enum CRStatus {
00044 CR_OK,
00045 CR_BAD_PARAM_ERROR,
00046 CR_INSTANCIATION_FAILED_ERROR,
00047 CR_UNKNOWN_TYPE_ERROR,
00048 CR_UNKNOWN_PROP_ERROR,
00049 CR_UNKNOWN_PROP_VAL_ERROR,
00050 CR_UNEXPECTED_POSITION_SCHEME,
00051 CR_START_OF_INPUT_ERROR,
00052 CR_END_OF_INPUT_ERROR,
00053 CR_OUTPUT_TOO_SHORT_ERROR,
00054 CR_INPUT_TOO_SHORT_ERROR,
00055 CR_OUT_OF_BOUNDS_ERROR,
00056 CR_EMPTY_PARSER_INPUT_ERROR,
00057 CR_ENCODING_ERROR,
00058 CR_ENCODING_NOT_FOUND_ERROR,
00059 CR_PARSING_ERROR,
00060 CR_SYNTAX_ERROR,
00061 CR_NO_ROOT_NODE_ERROR,
00062 CR_NO_TOKEN,
00063 CR_ERROR
00064 } ;
00065
00066
00067
00068
00069
00070 enum CRSeekPos {
00071 CR_SEEK_CUR,
00072 CR_SEEK_BEGIN,
00073 CR_SEEK_END
00074 } ;
00075
00076
00077
00078
00079 enum CREncoding
00080 {
00081 CR_UCS_4 = 1,
00082 CR_UCS_1,
00083 CR_ISO_8859_1,
00084 CR_ASCII,
00085 CR_UTF_8,
00086 CR_UTF_16,
00087 CR_AUTO
00088 } ;
00089
00090
00091
00092
00093 #define CROCO_LOG_DOMAIN "LIBCROCO"
00094
00095 #ifdef __GNUC__
00096 #define cr_utils_trace(a_log_level, a_msg) \
00097 g_log (CROCO_LOG_DOMAIN, \
00098 G_LOG_LEVEL_CRITICAL, \
00099 "file %s: line %d (%s): %s\n", \
00100 __FILE__, \
00101 __LINE__, \
00102 __PRETTY_FUNCTION__, \
00103 a_msg)
00104 #else
00105
00106 #define cr_utils_trace(a_log_level, a_msg) \
00107 g_log (CROCO_LOG_DOMAIN, \
00108 G_LOG_LEVEL_CRITICAL, \
00109 "file %s: line %d: %s\n", \
00110 __FILE__, \
00111 __LINE__, \
00112 a_msg)
00113 #endif
00114
00115
00116
00117
00118
00119
00120
00121
00122 #define cr_utils_trace_info(a_msg) \
00123 cr_utils_trace (G_LOG_LEVEL_INFO, a_msg)
00124
00125
00126
00127
00128
00129
00130
00131
00132 #define cr_utils_trace_debug(a_msg) \
00133 cr_utils_trace (G_LOG_LEVEL_DEBUG, a_msg) ;
00134
00135
00136
00137
00138
00139
00140
00141 enum CRStatus
00142 cr_utils_read_char_from_utf8_buf (const guchar * a_in, gulong a_in_len,
00143 guint32 *a_out, gulong *a_consumed) ;
00144
00145 enum CRStatus
00146 cr_utils_ucs1_to_utf8 (const guchar *a_in, gulong *a_in_len,
00147 guchar *a_out, gulong *a_out_len) ;
00148
00149 enum CRStatus
00150 cr_utils_utf8_to_ucs1 (const guchar * a_in, gulong * a_in_len,
00151 guchar *a_out, gulong *a_out_len) ;
00152
00153 enum CRStatus
00154 cr_utils_ucs4_to_utf8 (const guint32 *a_in, gulong *a_in_len,
00155 guchar *a_out, gulong *a_out_len) ;
00156
00157 enum CRStatus
00158 cr_utils_utf8_str_len_as_ucs4 (const guchar *a_in_start,
00159 const guchar *a_in_end,
00160 gulong *a_len) ;
00161 enum CRStatus
00162 cr_utils_ucs1_str_len_as_utf8 (const guchar *a_in_start,
00163 const guchar *a_in_end,
00164 gulong *a_len) ;
00165 enum CRStatus
00166 cr_utils_utf8_str_len_as_ucs1 (const guchar *a_in_start,
00167 const guchar *a_in_end,
00168 gulong *a_len) ;
00169 enum CRStatus
00170 cr_utils_ucs4_str_len_as_utf8 (const guint32 *a_in_start,
00171 const guint32 *a_in_end,
00172 gulong *a_len) ;
00173
00174 enum CRStatus
00175 cr_utils_ucs1_str_to_utf8 (const guchar *a_in_start,
00176 gulong *a_in_len,
00177 guchar **a_out,
00178 gulong *a_len) ;
00179
00180 enum CRStatus
00181 cr_utils_utf8_str_to_ucs1 (const guchar * a_in_start,
00182 gulong * a_in_len,
00183 guchar **a_out,
00184 gulong *a_out_len) ;
00185
00186 enum CRStatus
00187 cr_utils_utf8_to_ucs4 (const guchar * a_in,
00188 gulong * a_in_len,
00189 guint32 *a_out, gulong *a_out_len) ;
00190
00191 enum CRStatus
00192 cr_utils_ucs4_str_to_utf8 (const guint32 *a_in,
00193 gulong *a_in_len,
00194 guchar **a_out, gulong *a_out_len) ;
00195
00196 enum CRStatus
00197 cr_utils_utf8_str_to_ucs4 (const guchar * a_in,
00198 gulong *a_in_len,
00199 guint32 **a_out,
00200 gulong *a_out_len) ;
00201
00202
00203
00204
00205
00206
00207 gboolean
00208 cr_utils_is_newline (guint32 a_char) ;
00209
00210 gboolean
00211 cr_utils_is_white_space (guint32 a_char) ;
00212
00213 gboolean
00214 cr_utils_is_nonascii (guint32 a_char) ;
00215
00216 gboolean
00217 cr_utils_is_hexa_char (guint32 a_char) ;
00218
00219
00220
00221
00222
00223
00224 void
00225 cr_utils_dump_n_chars (guchar a_char,
00226 FILE *a_fp,
00227 glong a_nb) ;
00228
00229 void
00230 cr_utils_dump_n_chars2 (guchar a_char,
00231 GString *a_string,
00232 glong a_nb) ;
00233 gdouble
00234 cr_utils_n_to_0_dot_n (glong a_n) ;
00235
00236 GList *
00237 cr_dup_glist_of_string (GList *a_list) ;
00238
00239 G_END_DECLS
00240
00241 #endif