From 1648e81474b552ba499102e13f9f3ed863501757 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 8 Mar 2016 04:43:39 +0100 Subject: add rudimentary location support The function dbfp_query_location_name performs the location.name query and returns a list of all stations that match the search term. The implementation has two flaws: there is no URL encoding, and malformatted query results will not lead to a meaningful error message. There are two new test cases: basic tests some basic functionality, as setting the API key and accessing the API. location adds a simple test for the location.name query. --- dbfp.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'dbfp.h') diff --git a/dbfp.h b/dbfp.h index 2efd5e1..7c786c7 100644 --- a/dbfp.h +++ b/dbfp.h @@ -7,13 +7,29 @@ #ifndef DBFP_H_ #define DBFP_H_ -#define DBFP_BASE_URL "http://open-api.bahn.de/bin/rest.exe" +#include struct dbfp { char *key; }; +struct dbfp_status { + int error; + int run_error; + int parse_error; + int curl_error; + int api_error; +}; + +struct dbfp_location { + char *name; + char *id; +}; + 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); + #endif /* DBFP_H_ */ -- cgit v1.2.1