diff options
author | Robin Krahl <me@robin-krahl.de> | 2016-06-10 14:20:19 +0200 |
---|---|---|
committer | Robin Krahl <me@robin-krahl.de> | 2016-06-10 14:20:19 +0200 |
commit | 635ecce5990cc763160bb7e89b9291f09d06afc5 (patch) | |
tree | efeebe916fa07afbc6f1e48d63cb2555a194920d | |
parent | 08c86a69b964ca5183fbf93bf29d9a2fa9cb7663 (diff) | |
download | dbfp-635ecce5990cc763160bb7e89b9291f09d06afc5.tar.gz dbfp-635ecce5990cc763160bb7e89b9291f09d06afc5.tar.bz2 |
dbfp_query_departure: remove location argument, only use location_id
-rw-r--r-- | dbfp.c | 15 | ||||
-rw-r--r-- | dbfp.h | 5 | ||||
-rw-r--r-- | dbfp_check.c | 4 |
3 files changed, 9 insertions, 15 deletions
@@ -183,9 +183,8 @@ void dbfp_departure_close(struct dbfp_departure *departure) free(departure->track); } -int dbfp_query_departure(struct dbfp *dbfp, struct dbfp_location *location, - char *location_id, time_t time, size_t *n, - struct dbfp_departure **departures) +int dbfp_query_departure(struct dbfp *dbfp, char *location_id, time_t time, + size_t *n, struct dbfp_departure **departures) { int err = 0; char *query = 0; @@ -196,9 +195,7 @@ int dbfp_query_departure(struct dbfp *dbfp, struct dbfp_location *location, struct parse_data pd = { .error = 0, .data = &dd }; struct tm *tm; - if (!dbfp || !n || !departures) - return EINVAL; - if ((!location && !location_id) || (location && !location->id)) + if (!dbfp || !location_id || !n || !departures) return EINVAL; *n = 0; @@ -220,11 +217,9 @@ int dbfp_query_departure(struct dbfp *dbfp, struct dbfp_location *location, goto cleanup; err = dbfp_format_url(&query, "id=%s&date=%s&time=%s", - location ? location->id : location_id, - query_date, query_time); + location_id, query_date, query_time); } else { - err = dbfp_format_url(&query, "id=%s", - location ? location->id : location_id); + err = dbfp_format_url(&query, "id=%s", location_id); } if (err) goto cleanup; @@ -53,8 +53,7 @@ int dbfp_query_location(struct dbfp *dbfp, char *input, size_t *n, struct dbfp_location **locations); void dbfp_departure_close(struct dbfp_departure *departure); -int dbfp_query_departure(struct dbfp *dbfp, struct dbfp_location *location, - char *location_id, time_t time, size_t *n, - struct dbfp_departure **departures); +int dbfp_query_departure(struct dbfp *dbfp, char *location_id, time_t time, + size_t *n, struct dbfp_departure **departures); #endif /* DBFP_H_ */ diff --git a/dbfp_check.c b/dbfp_check.c index b17945b..a5ec7f7 100644 --- a/dbfp_check.c +++ b/dbfp_check.c @@ -104,14 +104,14 @@ START_TEST(test_dbfp_departure_simple) err = dbfp_init(&dbfp, api_key); ck_assert_int_eq(err, 0); - err = dbfp_query_departure(&dbfp, NULL, "8000105", 0, &n, &departures); + err = dbfp_query_departure(&dbfp, "8000105", 0, &n, &departures); ck_assert_int_eq(err, 0); ck_assert_int_gt(n, 0); for (i = 0; i < n; i++) dbfp_departure_close(&departures[i]); free(departures); - err = dbfp_query_departure(&dbfp, NULL, "8000105", time, &n, + err = dbfp_query_departure(&dbfp, "8000105", time, &n, &departures); ck_assert_int_eq(err, 0); tm.tm_hour++; |