/* * Retrieve an ows_version, related to current PostGIS version. */ ows_version * ows_psql_postgis_version(ows *o) { list *l; PGresult * res; ows_version * v = NULL; res = ows_psql_exec(o, "SELECT substr(postgis_full_version(), 10, 5)"); if (PQresultStatus(res) != PGRES_TUPLES_OK || PQntuples(res) != 1) { PQclear(res); return NULL; } l = list_explode_str('.', (char *) PQgetvalue(res, 0, 0)); if ( l->size == 3 && check_regexp(l->first->value->buf, "^[0-9]+$") && check_regexp(l->first->next->value->buf, "^[0-9]+$") && check_regexp(l->last->value->buf, "^[0-9]+$") ) { v = ows_version_init(); v->major = atoi(l->first->value->buf); v->minor = atoi(l->first->next->value->buf); v->release = atoi(l->last->value->buf); } list_free(l); PQclear(res); return v; }
/* * Initialize an ows struct */ static ows *ows_init() { ows *o; o = malloc(sizeof(ows)); assert(o); o->init = true; o->exit = false; o->request = NULL; o->cgi = NULL; o->psql_requests = NULL; o->pg = NULL; o->pg_dsn = buffer_init(); o->output = stdout; o->config_file = NULL; o->mapfile = false; o->online_resource = buffer_init(); o->schema_dir = buffer_init(); o->log_file = NULL; o->log = NULL; o->log_level=0; o->encoding = buffer_init(); o->db_encoding = buffer_init(); o->layers = NULL; o->max_features = 0; o->degree_precision = 6; o->meter_precision = 0; o->max_geobbox = NULL; o->display_bbox = true; o->estimated_extent = false; o->expose_pk = false; o->check_schema = true; o->check_valid_geom = true; o->metadata = NULL; o->contact = NULL; o->postgis_version = NULL; o->schema_wfs_100 = NULL; o->schema_wfs_110 = NULL; o->wfs_default_version = ows_version_init(); ows_version_set(o->wfs_default_version, 1, 1, 0); return o; }