From 4ba5dd85d4078d320b4d16d94fb3f973e54fcadb Mon Sep 17 00:00:00 2001 From: Guido Lerch Date: Sat, 5 Sep 2015 11:09:10 -0700 Subject: Uemis downloader: parse_divespot should return if it was successful But sadly the code then doesn't actually use that return value, so this is not quite perfect, yet. [Dirk Hohndel: refactored one huge commit into smaller pieces] Signed-off-by: Guido Lerch Signed-off-by: Dirk Hohndel --- uemis-downloader.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'uemis-downloader.c') diff --git a/uemis-downloader.c b/uemis-downloader.c index b263072ee..8c72354ef 100644 --- a/uemis-downloader.c +++ b/uemis-downloader.c @@ -637,7 +637,7 @@ fs_error: return false; } -static void parse_divespot(char *buf) +static bool parse_divespot(char *buf) { char *bp = buf + 1; char *tp = next_token(&bp); @@ -646,14 +646,17 @@ static void parse_divespot(char *buf) int divespot, len; double latitude = 0.0, longitude = 0.0; - + // dive spot got deleted, so fail here + if (strstr(bp, "deleted{bool{true")) + return false; + // not a dive spot, fail here if (strcmp(tp, "divespot")) - return; + return false; do tag = next_token(&bp); while (*tag && strcmp(tag, "object_id")); if (!*tag) - return; + return false; next_token(&bp); val = next_token(&bp); divespot = atoi(val); @@ -672,7 +675,9 @@ static void parse_divespot(char *buf) latitude = ascii_strtod(val, NULL); } } while (tag && *tag); + uemis_set_divelocation(divespot, locationstring, longitude, latitude); + return true; } static void track_divespot(char *val, int diveid, uint32_t dive_site_uuid) -- cgit v1.2.3-70-g09d2