Back to index

im-sdk  12.3.91
EIMILint.h
Go to the documentation of this file.
00001 /*
00002   EIMILint.h
00003     EIMIL internal declarations.
00004 */
00005 
00006 #ifndef _EIMILINT_H_
00007 #define _EIMILINT_H_
00008 #include <threaddef.h>
00009 
00010 #define EIMIL_MAXERRMSG 1024
00011 
00012 /********************************************************************************
00013                      type definition.
00014  ********************************************************************************/
00015 
00016 typedef struct EIMIL_attrs EIMIL_attrs;
00017 typedef struct EIMIL_attr_template EIMIL_attr_template;
00018 typedef struct EIMIL_element_template EIMIL_element_template;
00019 typedef struct EIMIL_dictionary EIMIL_dictionary;
00020 typedef struct EIMIL_XMLNS EIMIL_XMLNS;
00021 typedef struct EIMIL_parser_state EIMIL_parser_state;
00022 typedef struct EIMIL_engine_table EIMIL_engine_table;
00023 typedef struct EIMIL_engine EIMIL_engine;
00024 typedef struct EIMIL_cdata EIMIL_cdata;
00025 typedef struct EIMIL_data EIMIL_data;
00026 typedef struct EIMIL_journal EIMIL_journal;
00027 
00028 enum EIMIL_TAG_TYPE {
00029        EIMIL_START_TAG,
00030        EIMIL_END_TAG,
00031        EIMIL_EMPTY_TAG,
00032        EIMIL_PI_TAG,
00033        EIMIL_DOCTYPE_TAG,
00034        EIMIL_COMMENT_TAG,
00035        EIMIL_CDATA_TAG,
00036        EIMIL_CHARDATA,
00037        EIMIL_INVALID_TAG
00038 };
00039 
00040 typedef int (*EIMIL_parser_function)(
00041     EIMIL_data*,
00042     EIMIL_attrs*,
00043     enum EIMIL_TAG_TYPE type,
00044     UTF8 *pchars,
00045     void** pprivate
00046 );
00047 
00048 struct EIMIL_attrs {
00049     UTF8 *name;
00050     Ebyte *val;
00051 };
00052 
00053 enum EIMIL_attr_template_option {
00054        EIMIL_attr_NORMAL,
00055        EIMIL_attr_REQUIRED,
00056        EIMIL_attr_IMPLIED,
00057        EIMIL_attr_FIXED,
00058 };
00059 
00060 struct EIMIL_attr_template {
00061     char *name;
00062     enum EIMIL_attr_template_option type;
00063     char *default_value;
00064 };
00065 
00066 enum EIMIL_element_template_option {
00067        EIMIL_element_single = (1 << 0),
00068        EIMIL_element_0or1,
00069        EIMIL_element_multiple,
00070        EIMIL_element_morethan1,
00071        EIMIL_element_option_mask = ((1 << 8) - 1),
00072        EIMIL_subelement_ordered = (1 << 8),
00073        EIMIL_allow_PCDATA = (1 << 9),
00074        EIMIL_PCDATA_TOKEN = (1 << 10),
00075        EIMIL_PCDATA_QUOTED_TOKEN = (1 << 11),
00076        EIMIL_element_lock_template = (1 << 12),
00077        EIMIL_element_EMPTY = (1 << 13)
00078 };
00079 
00080 struct EIMIL_element_template {
00081     const char *name;
00082     EIMIL_parser_function func;
00083     EIMIL_attr_template *attrtpls;
00084     const int option;
00085     EIMIL_element_template *subelems;
00086     void *private;
00087 };
00088 #define EIMIL_element_contain_pcdatap(pdt) ((pdt)->option | EIMIL_allow_PCDATA)
00089 
00090 /*
00091   element template
00092  */
00093 
00094 /*
00095   dictionary & parser_state.
00096  */
00097 
00098 struct EIMIL_XMLNS {
00099     UTF8 *prefix;
00100     UTF8 *uri;
00101 };
00102 
00103 struct EIMIL_parser_state {
00104     int element_depth;
00105     unsigned char *buf;
00106     Ebyte *start;
00107     Ebyte *end;
00108     Ebyte *current;
00109     int lineno;
00110 
00111     int element_idx;
00112     EIMIL_element_template *pcet;
00113     EIMIL_element_template *psubet;
00114 
00115     const UTF8 *current_uri;
00116 
00117     int xmlns_alloced;
00118     int xmlns_entries;
00119     EIMIL_XMLNS *pxmlns;
00120 };
00121 #define EIMIL_SET_CURRENT_SUBELEMENT_TEMPLATE(pps, pet) \
00122  ((pps)->psubet = (pet))
00123 
00124 enum EIMIL_ENGINE_STATUS {
00125        EIMIL_ENGINE_STATUS_SUCCESS = 0,
00126        EIMIL_ENGINE_STATUS_SUSPENDED,
00127        EIMIL_ENGINE_STATUS_INTERRUPTED,
00128        EIMIL_ENGINE_STATUS_SKIPPED,
00129        EIMIL_ENGINE_STATUS_ERROR
00130 };
00131 
00132 typedef enum EIMIL_ENGINE_STATUS
00133 (*EIMIL_engine_execute_handler) (
00134     void *private
00135 );
00136 
00137 enum EIMIL_ENGINE_COMMAND {
00138        EIMIL_ENGINE_INSTANCIATE,
00139        EIMIL_ENGINE_DUPLICATE,
00140        EIMIL_ENGINE_DESTRUCT,
00141        EIMIL_ENGINE_UNINSTANCIATE
00142 };
00143 typedef void*
00144 (*EIMIL_engine_handler) (
00145     enum EIMIL_ENGINE_COMMAND m,
00146     EIMIL_data *ped,
00147     void *class_private,
00148     void *handle_private
00149 );
00150 
00151 struct EIMIL_engine_table {
00152     UTF8 *classname;
00153     EIMIL_engine_handler handler;
00154     EIMIL_engine_execute_handler execute_handler;
00155     EIMIL_element_template *pet;
00156     UTF8 *uri;
00157 };
00158 
00159 struct EIMIL_engine {
00160     int idx;
00161     UTF8* name;
00162     EIMIL_engine_table *ptable;
00163     void *private;
00164 };
00165 
00166 struct EIMIL_cdata {
00167     EIMIL_parser_state ps;
00168 
00169     EIMIL_EVENT_PROC evproc;
00170     EIMIL_UICHANGE_PROC uiproc;
00171     EIMIL_OPISSUE_PROC opproc;
00172 
00173     int num_engines;
00174     EIMIL_engine *pengine;
00175     int id_counter;
00176     THREAD_SYNC_OBJECT sync_object;
00177 };
00178 
00179 #define EIMIL_EVENT_QUEUESIZE 16
00180 struct EIMIL_data {
00181     EIMIL_cdata *pcommon;
00182     int duplicated;
00183     char errstr[EIMIL_MAXERRMSG];
00184 
00185     /* context-dependent dictionary */
00186     EIMIL_dictionary *pdic;
00187 
00188     /* engine */
00189     void** pengine_context;
00190 
00191     /* UI */
00192     EIMIL_symbol *psym_uidata;
00193 
00194     /* commit */
00195     int commitnotify_numops;
00196     EIMIL_symbol **commitnotify_ops;
00197 
00198     /* event queue */
00199     EIMIL_value **pcur_ev;
00200     EIMIL_value **pqueue_ev;
00201     EIMIL_value *queueslots[EIMIL_EVENT_QUEUESIZE];
00202 
00203     /* journal */
00204     EIMIL_TID current_journal_id;
00205     EIMIL_journal *pjst;
00206 
00207     /* private */
00208     void *private;
00209 };
00210 #define EIMIL_JOURNAL_ID_MAX ((1 << 28) - 2)
00211 #define EIMIL_JOURNAL_NONRECORD_TID (EIMIL_JOURNAL_ID_MAX + 1)
00212 #define EIMIL_JOURNAL_EMPTY_TID 0
00213 
00214 /* constitute ring buffer. */
00215 struct EIMIL_journal {
00216     EIMIL_TID id;
00217     EIMIL_symbol *psym;
00218     EIMIL_value *pv;
00219     struct EIMIL_journal *next, *prev;
00220 };
00221 #define EIMIL_JOURNAL_EMPTY_SLOT(ej) ((ej).id == 0)
00222 
00223 #ifdef __cplusplus
00224 extern "C" {
00225 #endif
00226 
00227 extern EIMIL_symbol* EIMIL_intern_soft(
00228     EIMIL_dictionary *pdic,
00229     unsigned char *name
00230 );
00231 
00232 extern EIMIL_symbol* EIMIL_register_symbol(
00233     EIMIL_data *ped,
00234     EIMIL_dictionary *pdic,
00235     unsigned char *name,
00236     enum EIMIL_CATEGORY cat,
00237     enum EIMIL_TYPE type
00238 );
00239 
00240 extern EIMIL_symbol* EIMIL_lookup_symbol_internal(
00241     EIMIL_dictionary *pdic,
00242     CARD32BIT id
00243 );
00244 
00245 extern void EIMIL_destruct_symbol(
00246     EIMIL_symbol *psym
00247 );
00248 
00249 extern Ebyte* EIMIL_get_attr_cdata(
00250     Ebyte *val,
00251     UTF8 **result
00252 );
00253 
00254 extern Ebyte* EIMIL_get_attr_nmtoken(
00255     Ebyte *val,
00256     UTF8 **result
00257 );
00258 
00259 extern Ebyte* EIMIL_get_attr_nmtokens(
00260     Ebyte *val,
00261     UTF8 **result
00262 );
00263 
00264 extern void EIMIL_remove_attr(
00265     EIMIL_attrs *patr
00266 );
00267 
00268 extern int EIMIL_register_engine(
00269     const UTF8 *classname,
00270     EIMIL_element_template *pet,
00271     EIMIL_engine_handler handler,
00272     EIMIL_engine_execute_handler execute_handler,
00273     const UTF8 *uri
00274 );
00275 
00276 extern EIMIL_data* EIMIL_make_handle_data(
00277     EIMIL_cdata *pbase
00278 );
00279 extern char* EIMIL_class_to_pathname(
00280     char *classname
00281 );
00282 extern void EIMIL_destruct_mtext(
00283     EIMIL_mtext *pm
00284 );
00285 extern int EIMIL_journal_initialize(
00286     EIMIL_handle eh
00287 );
00288 extern void EIMIL_journal_free(
00289     EIMIL_handle eh
00290 );
00291 extern void EIMIL_set_error(
00292     EIMIL_data *pps,
00293     const char* fmt,
00294     ...
00295 );
00296 extern void EIMIL_set_outof_memory(
00297     EIMIL_data *pps
00298 );
00299 extern int EIMIL_parse_start(
00300     EIMIL_data *ped
00301 );
00302 
00303 extern EIMIL_dictionary* EIMIL_new_dictionary(
00304     int size,
00305     int id_req_p
00306 );
00307 
00308 extern void EIMIL_free_dictionary(
00309     EIMIL_dictionary *pdic
00310 );
00311 extern void EIMIL_free_dictionary_and_symbol(
00312     EIMIL_dictionary *pdic
00313 );
00314 extern EIMIL_dictionary* EIMIL_duplicate_dictionary(
00315     EIMIL_dictionary *psdic
00316 );
00317 extern EIMIL_symbol* EIMIL_register_symbol(
00318     EIMIL_data *ped,
00319     EIMIL_dictionary *pdic,
00320     unsigned char *name,
00321     enum EIMIL_CATEGORY cat,
00322     enum EIMIL_TYPE type
00323 );
00324 
00325 extern int EIMIL_toggle_preedit(
00326     EIMIL_data *ped,
00327     int flag
00328 );
00329 
00330 extern int EIMIL_update_preedit(
00331     EIMIL_data *ped
00332 );
00333 
00334 extern int EIMIL_toggle_lookup_choice(
00335     EIMIL_data *ped,
00336     int flag
00337 );
00338 
00339 extern int EIMIL_update_lookup_choice(
00340     EIMIL_data *ped
00341 );
00342 
00343 extern int EIMIL_reply_event(
00344     EIMIL_data *ped,
00345     EIMIL_value *pv_event
00346 );
00347 
00348 extern int EIMIL_queue_event(
00349     EIMIL_data *ped,
00350     EIMIL_value *pv_event
00351 );
00352 
00353 extern EIMIL_value* EIMIL_next_event(
00354     EIMIL_data *ped
00355 );
00356 
00357 
00358 extern void EIMIL_set_out_of_memory(
00359     EIMIL_data *ped
00360 );
00361 
00362 /* EIMILFile.c */
00363 
00364 extern int EIMILFile_init();
00365 
00366 /* PCE.c */
00367 
00368 extern int PCE_init();
00369 
00370 /* EIMILTextUtil.c */
00371 
00372 extern int
00373 EIMIL_mtext_diff(
00374     EIMIL_mtext *porig,
00375     EIMIL_mtext *pnew,
00376     IMDifferential *pdiff
00377 );
00378 
00379 #ifdef __cplusplus
00380 }
00381 #endif
00382 
00383 #endif /* not _EIMILINT_H_ */
00384 
00385 /* Local Variables: */
00386 /* c-file-style: "iiim-project" */
00387 /* End: */