summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2014-12-28 23:38:42 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-12-28 20:19:24 -0800
commitc5467b0d734b9935c585b1cbe2be539d6542e16a (patch)
treed84a959b523bf012a52aecf5476895583bb28fa3 /parse-xml.c
parente86d298734ce76b9c66cc57dca68919fffb68789 (diff)
downloadsubsurface-c5467b0d734b9935c585b1cbe2be539d6542e16a.tar.gz
Parse time on only one place in DLF import
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/parse-xml.c b/parse-xml.c
index a14c3e71f..e8589fadf 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -2535,6 +2535,7 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size)
{
unsigned char *ptr = buffer;
bool event, found;
+ unsigned int time = 0;
int i;
target_table = &dive_table;
@@ -2545,15 +2546,16 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size)
dive_start();
while (ptr < buffer + size) {
+ time = ((ptr[0] >> 4) & 0x0f) +
+ ((ptr[1] << 4) & 0xff0) +
+ (ptr[2] & 0x0f) * 3600; /* hours */
event = ptr[0] & 0x0f;
if (event == 1) {
/* dive event */
switch(ptr[4]) {
case 5:
event_start();
- cur_event.time.seconds = ((ptr[0] >> 4) & 0x0f) +
- ((ptr[1] << 4) & 0xff0) +
- (ptr[2] & 0x0f) * 3600; /* hours */
+ cur_event.time.seconds = time;
strcpy(cur_event.name, "gaschange");
cur_event.type = 25;
cur_event.value = ptr[6];
@@ -2573,13 +2575,11 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size)
}
break;
default:
- fprintf(stderr, "DEBUG (event): %d\n", ptr[4]);
+ fprintf(stderr, "DEBUG (event): %d at time %d\n", ptr[4], time);
}
} else {
sample_start();
- cur_sample->time.seconds = ((ptr[0] >> 4) & 0x0f) +
- ((ptr[1] << 4) & 0xff0) +
- (ptr[2] & 0x0f) * 3600; /* hours */
+ cur_sample->time.seconds = time;
cur_sample->depth.mm = ((ptr[4] & 0xff) + ((ptr[5] << 8) & 0xff00)) * 10;
sample_end();
}