diff options
author | Robin Krahl <me@robin-krahl.de> | 2016-03-10 04:21:10 +0100 |
---|---|---|
committer | Robin Krahl <me@robin-krahl.de> | 2016-03-10 04:21:10 +0100 |
commit | 913fc9d2c2935e0faf34657747286ce83af21853 (patch) | |
tree | bb4c060bd6de36642a0b54bf7dc0cbe8c7c57938 /dbfp.h | |
parent | 2ae18059f986154efe06fe7fda92a1bb53cca50a (diff) | |
download | dbfp-913fc9d2c2935e0faf34657747286ce83af21853.tar.gz dbfp-913fc9d2c2935e0faf34657747286ce83af21853.tar.bz2 |
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.
Diffstat (limited to 'dbfp.h')
-rw-r--r-- | dbfp.h | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -9,16 +9,16 @@ #include <stddef.h> -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_ */ |