00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _SOMBOK_H_
00019
00020 #ifdef HAVE_CONFIG_H
00021 # include "config.h"
00022 #endif
00023 #include <errno.h>
00024 #include <stddef.h>
00025 #include <stdlib.h>
00026 #include <string.h>
00027 #ifdef HAVE_STRINGS_H
00028 # include <strings.h>
00029 #endif
00030
00031 #define SOMBOK_VERSION "2.0.5"
00032
00033 #define SOMBOK_UNICHAR_T_IS_WCHAR_T
00034 #define SOMBOK_UNICHAR_T_IS_UNSIGNED_INT
00035 #define SOMBOK_UNICHAR_T_IS_UNSIGNED_LONG
00036
00037
00038
00039
00040
00041
00042
00044 typedef unsigned int unichar_t;
00045
00048 typedef unsigned char propval_t;
00049
00052 typedef struct {
00056 unichar_t *str;
00058 size_t len;
00059 } unistr_t;
00060
00064 typedef struct {
00066 size_t idx;
00068 size_t len;
00070 size_t col;
00072 propval_t lbc;
00074 propval_t elbc;
00076 unsigned char flag;
00077 } gcchar_t;
00078
00081 typedef struct {
00083 unichar_t beg;
00085 unichar_t end;
00087 propval_t lbc;
00089 propval_t eaw;
00091 propval_t gcb;
00093 propval_t scr;
00094 } mapent_t;
00095
00096 struct linebreak_t;
00097
00100 typedef struct {
00104 unichar_t *str;
00106 size_t len;
00109 gcchar_t *gcstr;
00111 size_t gclen;
00113 size_t pos;
00115 struct linebreak_t *lbobj;
00116 } gcstring_t;
00117
00120 typedef struct linebreak_t {
00124 unsigned long int refcount;
00126 int state;
00128 unistr_t bufstr;
00130 unistr_t bufspc;
00132 double bufcols;
00134 unistr_t unread;
00140 size_t charmax;
00142 double colmax;
00144 double colmin;
00146 mapent_t *map;
00147 size_t mapsiz;
00149 unistr_t newline;
00151 unsigned int options;
00153 void *format_data;
00154 void *sizing_data;
00155 void *urgent_data;
00157 void *user_data;
00159 void *stash;
00161 gcstring_t *(*format_func)();
00163 double (*sizing_func)();
00165 gcstring_t *(*urgent_func)();
00168 gcstring_t *(*user_func)();
00176 void (*ref_func)(void *, int, int);
00180 int errnum;
00186 gcstring_t *(**prep_func)();
00188 void **prep_data;
00190 } linebreak_t;
00191
00192
00193
00194
00195
00197 #define PROP_UNKNOWN ((propval_t)~0)
00198
00201 #define LINEBREAK_FLAG_PROHIBIT_BEFORE (1)
00202 #define LINEBREAK_FLAG_ALLOW_BEFORE (2)
00203 #define LINEBREAK_FLAG_BREAK_BEFORE LINEBREAK_FLAG_ALLOW_BEFORE
00204
00207 #define LINEBREAK_DEFAULT_CHARMAX (998)
00208
00211 #define LINEBREAK_OPTION_EASTASIAN_CONTEXT (1)
00212 #define LINEBREAK_OPTION_HANGUL_AS_AL (2)
00213 #define LINEBREAK_OPTION_LEGACY_CM (4)
00214 #define LINEBREAK_OPTION_BREAK_INDENT (8)
00215 #define LINEBREAK_OPTION_COMPLEX_BREAKING (16)
00216
00219 typedef enum {
00220 LINEBREAK_STATE_NONE = 0,
00221 LINEBREAK_STATE_SOT, LINEBREAK_STATE_SOP, LINEBREAK_STATE_SOL,
00222 LINEBREAK_STATE_LINE,
00223 LINEBREAK_STATE_EOL, LINEBREAK_STATE_EOP, LINEBREAK_STATE_EOT,
00224 LINEBREAK_STATE_MAX
00225 } linebreak_state_t;
00228 #define LINEBREAK_STATE_SOT_FORMAT (-LINEBREAK_STATE_SOT)
00229 #define LINEBREAK_STATE_SOP_FORMAT (-LINEBREAK_STATE_SOP)
00230 #define LINEBREAK_STATE_SOL_FORMAT (-LINEBREAK_STATE_SOL)
00231
00234 #define LINEBREAK_REF_STASH (0)
00235 #define LINEBREAK_REF_FORMAT (1)
00236 #define LINEBREAK_REF_SIZING (2)
00237 #define LINEBREAK_REF_URGENT (3)
00238 #define LINEBREAK_REF_USER (4)
00239 #define LINEBREAK_REF_PREP (5)
00240
00243 #define LINEBREAK_ACTION_MANDATORY (4)
00244 #define LINEBREAK_ACTION_DIRECT (3)
00245 #define LINEBREAK_ACTION_INDIRECT (2)
00246 #define LINEBREAK_ACTION_PROHIBITED (1)
00247
00250 #define LINEBREAK_ELONG (-2)
00251 #define LINEBREAK_EEXTN (-3)
00252
00253
00254
00255
00256
00257
00258 extern void linebreak_charprop(linebreak_t *, unichar_t,
00259 propval_t *, propval_t *, propval_t *,
00260 propval_t *);
00261
00262 extern gcstring_t *gcstring_new(unistr_t *, linebreak_t *);
00263 extern gcstring_t *gcstring_newcopy(unistr_t *, linebreak_t *);
00264 extern gcstring_t *gcstring_copy(gcstring_t *);
00265 extern void gcstring_destroy(gcstring_t *);
00266 extern gcstring_t *gcstring_append(gcstring_t *, gcstring_t *);
00267 extern size_t gcstring_columns(gcstring_t *);
00268 extern int gcstring_cmp(gcstring_t *, gcstring_t *);
00269 extern gcstring_t *gcstring_concat(gcstring_t *, gcstring_t *);
00270 extern gcchar_t *gcstring_next(gcstring_t *);
00271 extern void gcstring_setpos(gcstring_t *, int);
00272 extern void gcstring_shrink(gcstring_t *, int);
00273 extern gcstring_t *gcstring_substr(gcstring_t *, int, int);
00274 extern gcstring_t *gcstring_replace(gcstring_t *, int, int, gcstring_t *);
00275
00276 #define gcstring_eos(gcstr) \
00277 ((gcstr)->gclen <= (gcstr)->pos)
00278 #define gcstring_getpos(gcstr) \
00279 ((gcstr)->pos)
00280
00281 extern linebreak_t *linebreak_new();
00282 extern linebreak_t *linebreak_copy(linebreak_t *);
00283 extern linebreak_t *linebreak_incref(linebreak_t *);
00284 extern void linebreak_destroy(linebreak_t *);
00285
00286 extern void linebreak_set_newline(linebreak_t *, unistr_t *);
00287 extern void linebreak_set_stash(linebreak_t *, void *);
00288 extern void linebreak_set_format(linebreak_t *, gcstring_t *(*)(), void *);
00289 extern void linebreak_add_prep(linebreak_t *, gcstring_t *(*)(), void *);
00290 extern void linebreak_set_sizing(linebreak_t *, double (*)(), void *);
00291 extern void linebreak_set_urgent(linebreak_t *, gcstring_t *(*)(), void *);
00292 extern void linebreak_set_user(linebreak_t *, gcstring_t *(*)(), void *);
00293 extern void linebreak_reset(linebreak_t *);
00294 extern void linebreak_update_lbclass(linebreak_t *, unichar_t, propval_t);
00295 extern void linebreak_clear_lbclass(linebreak_t *);
00296 extern void linebreak_update_eawidth(linebreak_t *, unichar_t, propval_t);
00297 extern void linebreak_clear_eawidth(linebreak_t *);
00298
00299 extern propval_t linebreak_eawidth(linebreak_t *, unichar_t);
00300 extern propval_t linebreak_lbclass(linebreak_t *, unichar_t);
00301 extern propval_t linebreak_lbrule(propval_t, propval_t);
00302
00303 extern gcstring_t **linebreak_break(linebreak_t *, unistr_t *);
00304 extern gcstring_t **linebreak_break_fast(linebreak_t *, unistr_t *);
00305 extern gcstring_t **linebreak_break_partial(linebreak_t *, unistr_t *);
00306
00307 extern const char *linebreak_unicode_version;
00308 extern const char *linebreak_propvals_EA[];
00309 extern const char *linebreak_propvals_LB[];
00310 extern const char *linebreak_southeastasian_supported;
00311 extern void linebreak_southeastasian_flagbreak(gcstring_t *);
00312
00313
00314
00315
00316 extern gcstring_t *linebreak_format_SIMPLE(linebreak_t *, linebreak_state_t,
00317 gcstring_t *);
00318 extern gcstring_t *linebreak_format_NEWLINE(linebreak_t *, linebreak_state_t,
00319 gcstring_t *);
00320 extern gcstring_t *linebreak_format_TRIM(linebreak_t *, linebreak_state_t,
00321 gcstring_t *);
00322 extern gcstring_t *linebreak_prep_URIBREAK(linebreak_t *, void *, unistr_t *,
00323 unistr_t *);
00324 extern double linebreak_sizing_UAX11(linebreak_t *, double, gcstring_t *,
00325 gcstring_t *, gcstring_t *);
00326 extern gcstring_t *linebreak_urgent_ABORT(linebreak_t *, gcstring_t *);
00327 extern gcstring_t *linebreak_urgent_FORCE(linebreak_t *, gcstring_t *);
00328
00329 #define _SOMBOK_H_
00330 #endif
00331
00332 #ifdef MALLOC_DEBUG
00333 #include "src/mymalloc.h"
00334 #endif
00335