28#include <libxml/xmlreader.h>
39 int precision, log_level;
44 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"online_resource");
50 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"schema_dir");
56 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"log");
63 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"log_level");
65 log_level = atoi((
char *) a);
66 if (log_level > 0 && log_level < 16) o->
log_level = log_level;
70 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"degree_precision");
72 precision = atoi((
char *) a);
77 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"meter_precision");
79 precision = atoi((
char *) a);
84 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"display_bbox");
90 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"estimated_extent");
96 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"check_schema");
102 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"check_valid_geom");
108 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"encoding");
114 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"expose_pk");
116 if (atoi((
char *) a)) o->
expose_pk =
true;
120 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"wfs_default_version");
139 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"name");
146 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"site");
153 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"individual_name");
160 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"position");
167 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"phone");
174 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"fax");
181 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"online_resource");
188 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"address");
195 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"postcode");
202 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"city");
209 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"administrative_area");
216 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"country");
223 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"email");
230 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"hours_of_service");
237 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"contact_instructions");
260 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"name");
267 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"title");
274 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"keywords");
280 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"fees");
287 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"access_constraints");
308 xmlTextReaderRead(r);
309 v = xmlTextReaderValue(r);
330 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"features");
336 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"geobbox");
356 if (xmlTextReaderMoveToFirstAttribute(r) != 1)
return;
358 a = xmlTextReaderName(r);
360 if ( !strcmp((
char *) a,
"host")
361 || !strcmp((
char *) a,
"user")
362 || !strcmp((
char *) a,
"password")
363 || !strcmp((
char *) a,
"dbname")
364 || !strcmp((
char *) a,
"port")) {
365 v = xmlTextReaderValue(r);
371 }
else if (!strcmp((
char *) a,
"encoding")) {
372 v = xmlTextReaderValue(r);
378 }
while (xmlTextReaderMoveToNextAttribute(r) == 1);
392 if (depth == 1)
return (
ows_layer *) NULL;
399 for ( ; ln ; ln = ln->
prev)
421 layer->
depth = xmlTextReaderDepth(r);
427 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"table");
433 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"name");
446 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"title");
453 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"abstract");
460 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"gml_ns");
469 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"keywords");
478 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"schema");
486 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"retrievable");
487 if (a && atoi((
char *) a) == 1) {
494 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"writable");
495 if (a && atoi((
char *) a) == 1) {
506 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"srid");
518 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"geobbox");
527 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"ns_prefix");
535 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"ns_uri");
543 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"exclude_items");
552 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"include_items");
561 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"pkey");
571 a = xmlTextReaderGetAttribute(r, (xmlChar *)
"pkey_sequence");
601 "parse_config_file");
612 "parse_config_file");
623 "parse_config_file");
629 "parse_config_file");
635 "parse_config_file");
653 r = xmlReaderForFile(filename,
"UTF-8", 0);
661 while ((ret = xmlTextReaderRead(r)) == 1) {
662 if (xmlTextReaderNodeType(r) == XML_READER_TYPE_ELEMENT) {
663 name = xmlTextReaderConstLocalName(r);
665 if (!strcmp((
char *) name,
"tinyows"))
668 if (!strcmp((
char *) name,
"metadata"))
671 if (!strcmp((
char *) name,
"abstract"))
674 if (!strcmp((
char *) name,
"contact"))
677 if (!strcmp((
char *) name,
"pg"))
680 if (!strcmp((
char *) name,
"limits"))
683 if (!strcmp((
char *) name,
"layer"))
689 xmlFreeTextReader(r);
694 xmlFreeTextReader(r);
void buffer_copy(buffer *dest, const buffer *src)
ows_layer * ows_layer_init()
bool ows_version_set_str(ows_version *v, char *str)
void buffer_add_str(buffer *buf, const char *str)
bool ows_version_check(ows_version *v)
ows_meta * ows_metadata_init()
void ows_error(ows *o, enum ows_error_code code, char *message, char *locator)
list * list_explode_str_trim(char separator, const char *value)
void ows_geobbox_free(ows_geobbox *g)
void buffer_add_head_str(buffer *buf, char *str)
ows_layer_list * ows_layer_list_init()
void ows_parse_config_mapfile(ows *o, const char *filename)
void buffer_add_head(buffer *buf, char c)
ows_geobbox * ows_geobbox_copy(ows_geobbox *g)
void list_add_list(list *l, list *l_to_add)
ows_geobbox * ows_geobbox_init()
ows_contact * ows_contact_init()
void ows_layer_list_add(ows_layer_list *ll, ows_layer *l)
ows_geobbox * ows_geobbox_set_from_str(ows *o, ows_geobbox *g, char *str)
list * list_explode_str(char separator, const char *value)
static void ows_config_check(ows *o)
static void ows_parse_config_limits(ows *o, xmlTextReaderPtr r)
static void ows_parse_config_metadata(ows *o, xmlTextReaderPtr r)
static void ows_parse_config_xml(ows *o, const char *filename)
static void ows_parse_config_pg(ows *o, xmlTextReaderPtr r)
static void ows_parse_config_contact(ows *o, xmlTextReaderPtr r)
static void ows_parse_config_tinyows(ows *o, xmlTextReaderPtr r)
static void ows_parse_config_layer(ows *o, xmlTextReaderPtr r)
void ows_parse_config(ows *o, const char *filename)
static void ows_parse_config_abstract(ows *o, xmlTextReaderPtr r)
static ows_layer * ows_parse_config_layer_get_parent(const ows *o, int depth)
#define OWS_DEFAULT_DB_ENCODING
#define OWS_DEFAULT_XML_ENCODING
char * buf
size to next realloc
struct Ows_layer_node * prev
struct Ows_layer * parent
ows_layer_storage * storage
ows_version * wfs_default_version
ows_geobbox * max_geobbox