GME
13
|
00001 00027 #ifndef SVN_XML_H 00028 #define SVN_XML_H 00029 00030 #include <apr.h> 00031 #include <apr_pools.h> 00032 #include <apr_hash.h> 00033 00034 #include "svn_types.h" 00035 #include "svn_string.h" 00036 00037 #ifdef __cplusplus 00038 extern "C" { 00039 #endif /* __cplusplus */ 00040 00042 #define SVN_XML_NAMESPACE "svn:" 00043 00045 enum svn_xml_open_tag_style { 00047 svn_xml_normal = 1, 00048 00050 svn_xml_protect_pcdata, 00051 00053 svn_xml_self_closing 00054 }; 00055 00056 00057 00070 svn_boolean_t 00071 svn_xml_is_xml_safe(const char *data, 00072 apr_size_t len); 00073 00080 void 00081 svn_xml_escape_cdata_stringbuf(svn_stringbuf_t **outstr, 00082 const svn_stringbuf_t *string, 00083 apr_pool_t *pool); 00084 00088 void 00089 svn_xml_escape_cdata_string(svn_stringbuf_t **outstr, 00090 const svn_string_t *string, 00091 apr_pool_t *pool); 00092 00096 void 00097 svn_xml_escape_cdata_cstring(svn_stringbuf_t **outstr, 00098 const char *string, 00099 apr_pool_t *pool); 00100 00101 00108 void 00109 svn_xml_escape_attr_stringbuf(svn_stringbuf_t **outstr, 00110 const svn_stringbuf_t *string, 00111 apr_pool_t *pool); 00112 00116 void 00117 svn_xml_escape_attr_string(svn_stringbuf_t **outstr, 00118 const svn_string_t *string, 00119 apr_pool_t *pool); 00120 00124 void 00125 svn_xml_escape_attr_cstring(svn_stringbuf_t **outstr, 00126 const char *string, 00127 apr_pool_t *pool); 00128 00148 const char * 00149 svn_xml_fuzzy_escape(const char *string, 00150 apr_pool_t *pool); 00151 00152 00153 /*---------------------------------------------------------------*/ 00154 00155 /* Generalized Subversion XML Parsing */ 00156 00158 typedef struct svn_xml_parser_t svn_xml_parser_t; 00159 00160 typedef void (*svn_xml_start_elem)(void *baton, 00161 const char *name, 00162 const char **atts); 00163 00164 typedef void (*svn_xml_end_elem)(void *baton, const char *name); 00165 00166 /* data is not NULL-terminated. */ 00167 typedef void (*svn_xml_char_data)(void *baton, 00168 const char *data, 00169 apr_size_t len); 00170 00171 00173 svn_xml_parser_t * 00174 svn_xml_make_parser(void *baton, 00175 svn_xml_start_elem start_handler, 00176 svn_xml_end_elem end_handler, 00177 svn_xml_char_data data_handler, 00178 apr_pool_t *pool); 00179 00180 00182 void 00183 svn_xml_free_parser(svn_xml_parser_t *svn_parser); 00184 00185 00197 svn_error_t * 00198 svn_xml_parse(svn_xml_parser_t *svn_parser, 00199 const char *buf, 00200 apr_size_t len, 00201 svn_boolean_t is_final); 00202 00203 00204 00209 void 00210 svn_xml_signal_bailout(svn_error_t *error, 00211 svn_xml_parser_t *svn_parser); 00212 00213 00214 00215 00216 00217 /*** Helpers for dealing with the data Expat gives us. ***/ 00218 00229 const char * 00230 svn_xml_get_attr_value(const char *name, 00231 const char *const *atts); 00232 00233 00234 00235 /* Converting between Expat attribute lists and APR hash tables. */ 00236 00237 00244 apr_hash_t * 00245 svn_xml_ap_to_hash(va_list ap, 00246 apr_pool_t *pool); 00247 00255 apr_hash_t * 00256 svn_xml_make_att_hash(const char **atts, 00257 apr_pool_t *pool); 00258 00259 00263 void 00264 svn_xml_hash_atts_preserving(const char **atts, 00265 apr_hash_t *ht, 00266 apr_pool_t *pool); 00267 00271 void 00272 svn_xml_hash_atts_overlaying(const char **atts, 00273 apr_hash_t *ht, 00274 apr_pool_t *pool); 00275 00276 00277 00278 /* Printing XML */ 00279 00295 void 00296 svn_xml_make_header2(svn_stringbuf_t **str, 00297 const char *encoding, 00298 apr_pool_t *pool); 00299 00304 SVN_DEPRECATED 00305 void 00306 svn_xml_make_header(svn_stringbuf_t **str, 00307 apr_pool_t *pool); 00308 00309 00321 void 00322 svn_xml_make_open_tag(svn_stringbuf_t **str, 00323 apr_pool_t *pool, 00324 enum svn_xml_open_tag_style style, 00325 const char *tagname, 00326 ...); 00327 00328 00332 void 00333 svn_xml_make_open_tag_v(svn_stringbuf_t **str, 00334 apr_pool_t *pool, 00335 enum svn_xml_open_tag_style style, 00336 const char *tagname, 00337 va_list ap); 00338 00339 00358 void 00359 svn_xml_make_open_tag_hash(svn_stringbuf_t **str, 00360 apr_pool_t *pool, 00361 enum svn_xml_open_tag_style style, 00362 const char *tagname, 00363 apr_hash_t *attributes); 00364 00365 00371 void 00372 svn_xml_make_close_tag(svn_stringbuf_t **str, 00373 apr_pool_t *pool, 00374 const char *tagname); 00375 00376 00377 #ifdef __cplusplus 00378 } 00379 #endif /* __cplusplus */ 00380 00381 #endif /* SVN_XML_H */