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