aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2016-03-10 18:14:14 +0100
committerRobin Krahl <me@robin-krahl.de>2016-03-10 18:14:14 +0100
commit285c16c44b8e12aa5b7a7e71855399de7449cae4 (patch)
tree4314e33484801671f5941b12138faf16168219e8
parent99319968f3e3ebbdce6c37f04243f734e98b28b3 (diff)
downloaddbfp-285c16c44b8e12aa5b7a7e71855399de7449cae4.tar.gz
dbfp-285c16c44b8e12aa5b7a7e71855399de7449cae4.tar.bz2
dbfp: introduce dbfp_departure and dbfp_departure_close
The dbfp_departure structure stores a single departure with its metadata. The dbfp_departure_close function releases the resources allocated by a dbfp_departure structure, but does not free the structure itself.
-rw-r--r--dbfp.c13
-rw-r--r--dbfp.h13
2 files changed, 26 insertions, 0 deletions
diff --git a/dbfp.c b/dbfp.c
index ec9543b..0b41810 100644
--- a/dbfp.c
+++ b/dbfp.c
@@ -157,6 +157,19 @@ cleanup:
return err;
}
+void dbfp_departure_close(struct dbfp_departure *departure)
+{
+ if (!departure)
+ return;
+
+ free(departure->name);
+ free(departure->type);
+ free(departure->stopid);
+ free(departure->stop);
+ free(departure->direction);
+ free(departure->track);
+}
+
static int dbfp_parse(void *contents, size_t len, size_t n, void *data)
{
XML_Parser parser = (XML_Parser)data;
diff --git a/dbfp.h b/dbfp.h
index 589ac06..e1e1247 100644
--- a/dbfp.h
+++ b/dbfp.h
@@ -9,6 +9,7 @@
#include <curl/curl.h>
#include <stddef.h>
+#include <time.h>
enum dbfp_error {
DBFP_ERROR_CURL = -1,
@@ -30,6 +31,16 @@ struct dbfp_location {
float lat;
};
+struct dbfp_departure {
+ char *name;
+ char *type;
+ char *stopid;
+ char *stop;
+ time_t time;
+ char *direction;
+ char *track;
+};
+
int dbfp_init(struct dbfp *dbfp, char *key);
void dbfp_close(struct dbfp *dbfp);
@@ -37,4 +48,6 @@ void dbfp_location_close(struct dbfp_location *location);
int dbfp_query_location_name(struct dbfp *dbfp, char *input,
size_t *n, struct dbfp_location **locations);
+void dbfp_departure_close(struct dbfp_departure *departure);
+
#endif /* DBFP_H_ */