00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef GUTHTHILA_XML_WRITER_H
00019 #define GUTHTHILA_XML_WRITER_H
00020
00021 #include <guththila_token.h>
00022 #include <guththila_defines.h>
00023 #include <guththila_buffer.h>
00024 #include <guththila.h>
00025 #include <axutil_utils.h>
00026
00027 EXTERN_C_START()
00028 #define GUTHTHILA_XML_WRITER_TOKEN
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 typedef enum guththila_writer_type_s
00040 {
00041 GUTHTHILA_WRITER_FILE = 1,
00042 GUTHTHILA_WRITER_MEMORY
00043 } guththila_writer_type_t;
00044
00045 typedef struct guththila_writer_s
00046 {
00047 short type;
00048 FILE *out_stream;
00049 guththila_buffer_t *buffer;
00050 int next;
00051 }
00052 guththila_writer_t;
00053
00054 typedef enum guththila_writer_status_s
00055 {
00056
00057 START = 1,
00058
00059 START_EMPTY,
00060
00061 BEGINING
00062 } guththila_writer_status_t;
00063
00064
00065 typedef struct guththila_xml_writer_s
00066 {
00067 guththila_stack_t element;
00068 guththila_stack_t namesp;
00069 guththila_writer_t *writer;
00070 #ifdef GUTHTHILA_XML_WRITER_TOKEN
00071 guththila_tok_list_t tok_list;
00072 #endif
00073
00074 guththila_writer_type_t type;
00075
00076 FILE *out_stream;
00077 guththila_buffer_t buffer;
00078 guththila_writer_status_t status;
00079 int next;
00080 } guththila_xml_writer_t;
00081
00082
00083
00084
00085
00086
00087 typedef struct guththila_xml_writer_element_s
00088 {
00089 #ifdef GUTHTHILA_XML_WRITER_TOKEN
00090 guththila_token_t *prefix;
00091 guththila_token_t *name;
00092 #else
00093 guththila_char_t *prefix;
00094 guththila_char_t *name;
00095 #endif
00096
00097
00098
00099 int name_sp_stack_no;
00100 }
00101 guththila_xml_writer_element_t;
00102
00103 typedef struct guththila_xml_writer_namesp_s
00104 {
00105
00106
00107 #ifdef GUTHTHILA_XML_WRITER_TOKEN
00108 guththila_token_t **name;
00109 guththila_token_t **uri;
00110 #else
00111 guththila_char_t **name;
00112 guththila_char_t **uri;
00113 #endif
00114 int no;
00115 int size;
00116 }
00117 guththila_xml_writer_namesp_t;
00118
00119 #define GUTHTHILA_XML_WRITER_NAMESP_DEF_SIZE 4
00120
00121
00122
00123
00124
00125
00126
00127
00128 GUTHTHILA_EXPORT guththila_xml_writer_t *GUTHTHILA_CALL
00129 guththila_create_xml_stream_writer(
00130 char *file_name,
00131 const axutil_env_t * env);
00132
00133
00134
00135
00136
00137 GUTHTHILA_EXPORT guththila_xml_writer_t *GUTHTHILA_CALL
00138 guththila_create_xml_stream_writer_for_memory(
00139 const axutil_env_t * env);
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_to_buffer(
00150 guththila_xml_writer_t * wr,
00151 char *buff,
00152 int size,
00153 const axutil_env_t * env);
00154
00155
00156
00157
00158
00159
00160
00161
00162 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_namespace(
00163 guththila_xml_writer_t * wr,
00164 char *prefix,
00165 char *uri,
00166 const axutil_env_t * env);
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00178 guththila_do_write_attribute_with_prefix_and_namespace(
00179 guththila_xml_writer_t * wr,
00180 char *prefix,
00181 char *uri,
00182 char *local_name,
00183 char *value,
00184 const axutil_env_t * env);
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_start_document(
00195 guththila_xml_writer_t * wr,
00196 const axutil_env_t * env,
00197 char *encoding,
00198 char *version);
00199
00200
00201
00202
00203
00204
00205
00206 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_start_element(
00207 guththila_xml_writer_t * wr,
00208 char *name,
00209 const axutil_env_t * env);
00210
00211
00212
00213
00214
00215
00216 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_end_element(
00217 guththila_xml_writer_t * wr,
00218 const axutil_env_t * env);
00219
00220
00221
00222
00223
00224
00225 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_close(
00226 guththila_xml_writer_t * wr,
00227 const axutil_env_t * env);
00228
00229
00230
00231
00232
00233
00234
00235 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_characters(
00236 guththila_xml_writer_t * wr,
00237 char *buff,
00238 const axutil_env_t * env);
00239
00240
00241
00242
00243
00244
00245
00246 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_comment(
00247 guththila_xml_writer_t * wr,
00248 char *buff,
00249 const axutil_env_t * env);
00250
00251
00252
00253
00254
00255
00256
00257 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_escape_character(
00258 guththila_xml_writer_t * wr,
00259 char *buff,
00260 const axutil_env_t * env);
00261
00262
00263
00264
00265
00266
00267
00268 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_empty_element(
00269 guththila_xml_writer_t * wr,
00270 char *name,
00271 const axutil_env_t * env);
00272
00273
00274
00275
00276
00277
00278
00279 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_default_namespace(
00280 guththila_xml_writer_t * wr,
00281 char *uri,
00282 const axutil_env_t * env);
00283
00284
00285
00286
00287
00288
00289
00290
00291 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_attribute(
00292 guththila_xml_writer_t * wr,
00293 char *localname,
00294 char *value,
00295 const axutil_env_t * env);
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00307 guththila_write_attribute_with_prefix_and_namespace(
00308 guththila_xml_writer_t * wr,
00309 char *prefix,
00310 char *namespace_uri,
00311 char *localname,
00312 char *value,
00313 const axutil_env_t * env);
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_attribute_with_prefix(
00325 guththila_xml_writer_t * wr,
00326 char *prefix,
00327 char *localname,
00328 char *value,
00329 const axutil_env_t * env);
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_attribute_with_namespace(
00343 guththila_xml_writer_t * wr,
00344 char *namesp,
00345 char *localname,
00346 char *value,
00347 const axutil_env_t * env);
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00359 guththila_write_start_element_with_prefix_and_namespace(
00360 guththila_xml_writer_t * wr,
00361 char *prefix,
00362 char *namespace_uri,
00363 char *local_name,
00364 const axutil_env_t * env);
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00375 guththila_write_start_element_with_namespace(
00376 guththila_xml_writer_t * wr,
00377 char *namespace_uri,
00378 char *local_name,
00379 const axutil_env_t * env);
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00390 guththila_write_start_element_with_prefix(
00391 guththila_xml_writer_t * wr,
00392 char *prefix,
00393 char *local_name,
00394 const axutil_env_t * env);
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00406 guththila_write_empty_element_with_prefix_and_namespace(
00407 guththila_xml_writer_t * wr,
00408 char *prefix,
00409 char *namespace_uri,
00410 char *local_name,
00411 const axutil_env_t * env);
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00422 guththila_write_empty_element_with_namespace(
00423 guththila_xml_writer_t * wr,
00424 char *namespace_uri,
00425 char *local_name,
00426 const axutil_env_t * env);
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00437 guththila_write_empty_element_with_prefix(
00438 guththila_xml_writer_t * wr,
00439 char *prefix,
00440 char *local_name,
00441 const axutil_env_t * env);
00442
00443
00444
00445
00446
00447
00448 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_end_document(
00449 guththila_xml_writer_t * wr,
00450 const axutil_env_t * env);
00451
00452
00453
00454
00455
00456
00457
00458
00459 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_line(
00460 guththila_xml_writer_t * wr,
00461 char *element_name,
00462 char *characters,
00463 const axutil_env_t * env);
00464
00465
00466
00467
00468
00469
00470
00471 GUTHTHILA_EXPORT char *GUTHTHILA_CALL guththila_get_memory_buffer(
00472 guththila_xml_writer_t * wr,
00473 const axutil_env_t * env);
00474
00475
00476
00477
00478
00479
00480
00481 GUTHTHILA_EXPORT unsigned int GUTHTHILA_CALL
00482 guththila_get_memory_buffer_size(
00483 guththila_xml_writer_t * wr,
00484 const axutil_env_t * env);
00485
00486
00487
00488
00489
00490
00491 GUTHTHILA_EXPORT void GUTHTHILA_CALL guththila_xml_writer_free(
00492 guththila_xml_writer_t * wr,
00493 const axutil_env_t * env);
00494
00495
00496
00497
00498
00499
00500
00501 GUTHTHILA_EXPORT char *GUTHTHILA_CALL guththila_get_prefix_for_namespace(
00502 guththila_xml_writer_t * wr,
00503 char *namespace,
00504 const axutil_env_t * env);
00505
00506 EXTERN_C_END()
00507 #endif