From 635ecce5990cc763160bb7e89b9291f09d06afc5 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Fri, 10 Jun 2016 14:20:19 +0200 Subject: dbfp_query_departure: remove location argument, only use location_id --- dbfp.c | 15 +++++---------- dbfp.h | 5 ++--- dbfp_check.c | 4 ++-- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/dbfp.c b/dbfp.c index 5c54a3d..5b0960d 100644 --- a/dbfp.c +++ b/dbfp.c @@ -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; diff --git a/dbfp.h b/dbfp.h index 82d3801..d2be3f0 100644 --- a/dbfp.h +++ b/dbfp.h @@ -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++; -- cgit v1.2.3