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 GUTHTHILA_EXPORT guththila_xml_writer_t *GUTHTHILA_CALL
00123 guththila_create_xml_stream_writer(
00124 char *file_name,
00125 const axutil_env_t * env);
00126
00127 GUTHTHILA_EXPORT guththila_xml_writer_t *GUTHTHILA_CALL
00128 guththila_create_xml_stream_writer_for_memory(
00129 const axutil_env_t * env);
00130
00131 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_to_buffer(
00132 guththila_xml_writer_t * wr,
00133 char *buff,
00134 int size,
00135 const axutil_env_t * env);
00136
00137 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_namespace(
00138 guththila_xml_writer_t * wr,
00139 char *prefix,
00140 char *uri,
00141 const axutil_env_t * env);
00142
00143 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00144 guththila_do_write_attribute_with_prefix_and_namespace(
00145 guththila_xml_writer_t * wr,
00146 char *prefix,
00147 char *namespace_uri,
00148 char *local_name,
00149 char *value,
00150 const axutil_env_t * env);
00151
00152 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_start_document(
00153 guththila_xml_writer_t * wr,
00154 const axutil_env_t * env,
00155 char *encoding,
00156 char *version);
00157
00158 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_start_element(
00159 guththila_xml_writer_t * wr,
00160 char *start_element,
00161 const axutil_env_t * env);
00162
00163 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_end_element(
00164 guththila_xml_writer_t * wr,
00165 const axutil_env_t * env);
00166
00167 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_close(
00168 guththila_xml_writer_t * wr,
00169 const axutil_env_t * env);
00170
00171 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_characters(
00172 guththila_xml_writer_t * wr,
00173 char *buff,
00174 const axutil_env_t * env);
00175
00176 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_comment(
00177 guththila_xml_writer_t * wr,
00178 char *buff,
00179 const axutil_env_t * env);
00180
00181 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_escape_character(
00182 guththila_xml_writer_t * wr,
00183 char *buff,
00184 const axutil_env_t * env);
00185
00186 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_empty_element(
00187 guththila_xml_writer_t * wr,
00188 char *empty_element,
00189 const axutil_env_t * env);
00190
00191 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_default_namespace(
00192 guththila_xml_writer_t * wr,
00193 char *namespace_uri,
00194 const axutil_env_t * env);
00195
00196 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_attribute(
00197 guththila_xml_writer_t * wr,
00198 char *localname,
00199 char *value,
00200 const axutil_env_t * env);
00201
00202 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00203 guththila_write_attribute_with_prefix_and_namespace(
00204 guththila_xml_writer_t * wr,
00205 char *prefix,
00206 char *namespace_uri,
00207 char *localname,
00208 char *value,
00209 const axutil_env_t * env);
00210
00211 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_attribute_with_prefix(
00212 guththila_xml_writer_t * wr,
00213 char *prefix,
00214 char *localname,
00215 char *value,
00216 const axutil_env_t * env);
00217
00218 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_attribute_with_namespace(
00219 guththila_xml_writer_t * wr,
00220 char *namesp,
00221 char *localname,
00222 char *value,
00223 const axutil_env_t * env);
00224
00225 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00226 guththila_write_start_element_with_prefix_and_namespace(
00227 guththila_xml_writer_t * wr,
00228 char *prefix,
00229 char *namespace_uri,
00230 char *local_name,
00231 const axutil_env_t * env);
00232
00233 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00234 guththila_write_start_element_with_namespace(
00235 guththila_xml_writer_t * wr,
00236 char *namespace_uri,
00237 char *local_name,
00238 const axutil_env_t * env);
00239
00240 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00241 guththila_write_start_element_with_prefix(
00242 guththila_xml_writer_t * wr,
00243 char *prefix,
00244 char *local_name,
00245 const axutil_env_t * env);
00246
00247 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00248 guththila_write_empty_element_with_prefix_and_namespace(
00249 guththila_xml_writer_t * wr,
00250 char *prefix,
00251 char *namespace_uri,
00252 char *local_name,
00253 const axutil_env_t * env);
00254
00255 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00256 guththila_write_empty_element_with_namespace(
00257 guththila_xml_writer_t * wr,
00258 char *namespace_uri,
00259 char *local_name,
00260 const axutil_env_t * env);
00261
00262 GUTHTHILA_EXPORT int GUTHTHILA_CALL
00263 guththila_write_empty_element_with_prefix(
00264 guththila_xml_writer_t * wr,
00265 char *prefix,
00266 char *local_name,
00267 const axutil_env_t * env);
00268
00269 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_end_document(
00270 guththila_xml_writer_t * wr,
00271 const axutil_env_t * env);
00272
00273 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_write_line(
00274 guththila_xml_writer_t * wr,
00275 char *element_name,
00276 char *characters,
00277 const axutil_env_t * env);
00278
00279 GUTHTHILA_EXPORT char *GUTHTHILA_CALL guththila_get_memory_buffer(
00280 guththila_xml_writer_t * wr,
00281 const axutil_env_t * env);
00282
00283 GUTHTHILA_EXPORT unsigned int GUTHTHILA_CALL
00284 guththila_get_memory_buffer_size(
00285 guththila_xml_writer_t * wr,
00286 const axutil_env_t * env);
00287
00288 GUTHTHILA_EXPORT void GUTHTHILA_CALL guththila_xml_writer_free(
00289 guththila_xml_writer_t * wr,
00290 const axutil_env_t * env);
00291
00292 GUTHTHILA_EXPORT char *GUTHTHILA_CALL guththila_get_prefix_for_namespace(
00293 guththila_xml_writer_t * wr,
00294 char *namespace,
00295 const axutil_env_t * env);
00296
00297 int GUTHTHILA_CALL guththila_write(
00298 guththila_xml_writer_t * wr,
00299 char *buff,
00300 size_t buff_size,
00301 const axutil_env_t * env);
00302
00303 int GUTHTHILA_CALL guththila_write_token(
00304 guththila_xml_writer_t * wr,
00305 guththila_token_t * tok,
00306 const axutil_env_t * env);
00307
00308 int GUTHTHILA_CALL guththila_write_xtoken(
00309 guththila_xml_writer_t * wr,
00310 char *buff,
00311 size_t buff_len,
00312 const axutil_env_t * env);
00313
00314 EXTERN_C_END()
00315 #endif