aboutsummaryrefslogtreecommitdiffstats
path: root/uemis-downloader.c
diff options
context:
space:
mode:
authorGravatar glerch <guido.lerch@gmail.com>2015-09-07 20:51:49 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-07 17:43:12 -0700
commit0790dfdad54a0173a557ddefdd6db4f14a0c5368 (patch)
tree62996f019df896e98cc57933ad897150769d15a1 /uemis-downloader.c
parente77d9cbd556570d06c421b1a018cadae7c2d6aa6 (diff)
downloadsubsurface-0790dfdad54a0173a557ddefdd6db4f14a0c5368.tar.gz
Uemis downloader: original dive number support
- enabled capturing of the original Uemis dive number - previousely the object_id was passed to dive as dive number - I am using a workaround (not nice but effective) by parsing the dive_no out of a copy of inbuf before the object_id is parsed. The reason why is that the dive_no comes before the object_id hence the normal parsing would miss it. Signed-off-by: glerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'uemis-downloader.c')
-rw-r--r--uemis-downloader.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/uemis-downloader.c b/uemis-downloader.c
index 325b3f2ab..1c639aa67 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -792,6 +792,7 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char *
char *sections[10];
int s, nr_sections = 0;
struct dive *dive = NULL;
+ char dive_no[10];
#if UEMIS_DEBUG & 4
fprintf(debugfile, "p_r_b %s\n", inbuf);
@@ -835,6 +836,18 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char *
free(buf);
return false;
}
+ /* quickhack and workaround to capture the original dive_no
+ * i am doing this so I dont have to change the original design
+ * but when parsing a dive we never parse the dive number because
+ * at the time it's being read the *dive varible is not set because
+ * the dive_no tag comes before the object_id in the uemis ans file
+ */
+ char *dive_no_buf = strdup(inbuf);
+ char *dive_no_ptr = strstr(dive_no_buf, "dive_no{int{") + 12;
+ char *dive_no_end = strstr(dive_no_ptr, "{");
+ *dive_no_end = 0;
+ strcpy(dive_no, dive_no_ptr);
+ free(dive_no_buf);
}
while (!done) {
/* the valid buffer ends with a series of delimiters */
@@ -873,14 +886,11 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char *
#if UEMIS_DEBUG % 2
fprintf(debugfile, "Adding new dive from log with object_id %d.\n", atoi(val));
#endif
- /* glerch Sep. 2015
- * maybe I am missing something here but this seems wrong
- if (keep_number)
- dive->number = atoi(val);
- */
} else if (is_dive && strcmp(tag, "logfilenr") == 0) {
/* this one tells us which dive we are adding data to */
dive = get_dive_by_uemis_diveid(devdata, atoi(val));
+ if (strcmp(dive_no, "0"))
+ dive->number = atoi(dive_no);
if (for_dive)
*for_dive = atoi(val);
} else if (!is_log && dive && !strcmp(tag, "divespot_id")) {