From 913fc9d2c2935e0faf34657747286ce83af21853 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 10 Mar 2016 04:21:10 +0100 Subject: dbfp: improve error handling Get rid of the complicated dbfp_status structure and use plain old return codes. This leads to a cleaner interface and fixes the problem with unsufficient error handling introduced with 1648e81. The drawback is that the details of curl and expat errors are hidden from the user, but this can be adressed later. --- dbfp.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'dbfp.h') diff --git a/dbfp.h b/dbfp.h index 7c786c7..ca92ed1 100644 --- a/dbfp.h +++ b/dbfp.h @@ -9,16 +9,16 @@ #include -struct dbfp { - char *key; +enum dbfp_error { + DBFP_ERROR_CURL = -1, + DBFP_ERROR_FORMAT = -2, + DBFP_ERROR_STRUCTURE = -3, + DBFP_ERROR_API = -4, + DBFP_ERROR_PARSE = -5 }; -struct dbfp_status { - int error; - int run_error; - int parse_error; - int curl_error; - int api_error; +struct dbfp { + char *key; }; struct dbfp_location { @@ -29,7 +29,7 @@ struct dbfp_location { int dbfp_init(struct dbfp *dbfp, char *key); void dbfp_close(struct dbfp *dbfp); -struct dbfp_status dbfp_query_location_name(struct dbfp *dbfp, char *input, - size_t *n, struct dbfp_location **out); +int dbfp_query_location_name(struct dbfp *dbfp, char *input, + size_t *n, struct dbfp_location **locations); #endif /* DBFP_H_ */ -- cgit v1.2.1