diff options
-rw-r--r-- | dbfp.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -67,6 +67,7 @@ struct dbfp_status dbfp_query_location_name(struct dbfp *dbfp, char *input, XML_Parser parser = NULL; if (!dbfp || !input) { + status.error = 1; status.run_error = EINVAL; goto cleanup; } @@ -77,11 +78,13 @@ struct dbfp_status dbfp_query_location_name(struct dbfp *dbfp, char *input, */ query = malloc(DBFP_URL_LEN); if (!query) { + status.error = 1; status.run_error = ENOMEM; goto cleanup; } len = snprintf(query, DBFP_URL_LEN, "input=%s", input); if (len < 0 || len >= DBFP_URL_LEN) { + status.error = 1; status.run_error = -1; goto cleanup; } @@ -97,7 +100,7 @@ struct dbfp_status dbfp_query_location_name(struct dbfp *dbfp, char *input, dbfp_request(dbfp, "location.name", query, parser, &status); - if (ld.n && ld.locs) { + if (!status.error) { if (n) *n = ld.n; if (out) @@ -112,10 +115,6 @@ cleanup: XML_ParserFree(parser); free(query); - if (status.run_error || status.parse_error || status.curl_error || - status.api_error) - status.error = 1; - return status; } @@ -128,6 +127,7 @@ static int dbfp_parse(void *contents, size_t len, size_t n, void *data) pd = (struct parse_data *)XML_GetUserData(parser); if (!pd->status->parse_error && !XML_Parse(parser, contents, size, 0)) { + pd->status->error = 1; pd->status->parse_error = XML_GetErrorCode(parser); } @@ -147,6 +147,7 @@ static void dbfp_request(struct dbfp *dbfp, char *service, char *query, curl_global_init(CURL_GLOBAL_ALL ^ CURL_GLOBAL_SSL); curl = curl_easy_init(); if (!curl) { + status->error = 1; status->run_error = -1; goto cleanup; } |