aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dbfp.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/dbfp.c b/dbfp.c
index 57fbcad..d1fd29c 100644
--- a/dbfp.c
+++ b/dbfp.c
@@ -35,7 +35,7 @@ struct object_data {
static int dbfp_parse(void *contents, size_t len, size_t n, void *data);
static int dbfp_request(struct dbfp *dbfp, char *service, char *query,
- XML_Parser parser);
+ XML_Parser parser, struct parse_data *pd);
static int dbfp_url(struct dbfp *dbfp, char *service, char *query, char **url);
static int dbfp_format_url(struct dbfp *dbfp, char **out, const char *format,
...);
@@ -135,12 +135,9 @@ int dbfp_query_location_name(struct dbfp *dbfp, char *input,
goto cleanup;
parser = XML_ParserCreateNS(NULL, '\0');
- XML_SetUserData(parser, &pd);
XML_SetElementHandler(parser, location_start, location_end);
- err = dbfp_request(dbfp, "location.name", query, parser);
- if (pd.error)
- err = pd.error;
+ err = dbfp_request(dbfp, "location.name", query, parser, &pd);
if (err)
goto cleanup;
@@ -187,7 +184,7 @@ static int dbfp_parse(void *contents, size_t len, size_t n, void *data)
}
static int dbfp_request(struct dbfp *dbfp, char *service, char *query,
- XML_Parser parser)
+ XML_Parser parser, struct parse_data *pd)
{
int err = 0;
char *url = NULL;
@@ -196,6 +193,8 @@ static int dbfp_request(struct dbfp *dbfp, char *service, char *query,
if (err)
goto cleanup;
+ XML_SetUserData(parser, pd);
+
curl_easy_setopt(dbfp->curl, CURLOPT_URL, url);
curl_easy_setopt(dbfp->curl, CURLOPT_WRITEFUNCTION, dbfp_parse);
curl_easy_setopt(dbfp->curl, CURLOPT_WRITEDATA, (void *)parser);
@@ -203,6 +202,9 @@ static int dbfp_request(struct dbfp *dbfp, char *service, char *query,
if (curl_easy_perform(dbfp->curl) != CURLE_OK)
err = DBFP_ERROR_CURL;
+ if (pd->error)
+ err = pd->error;
+
cleanup:
free(url);