From 4b590ba5e2cb616725fc5bde83c178ec33f9bc40 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Thu, 4 Feb 2010 10:46:42 +0000 Subject: [PATCH] Pass the fingerprint data to the callback function. --- examples/universal.c | 7 +++++-- src/device.h | 2 +- src/mares_common.c | 2 +- src/oceanic_common.c | 3 ++- src/reefnet_sensus.c | 2 +- src/reefnet_sensuspro.c | 2 +- src/reefnet_sensusultra.c | 2 +- src/suunto_common.c | 2 +- src/suunto_common2.c | 9 +++++---- src/suunto_solution.c | 2 +- src/suunto_vyper.c | 2 +- src/uwatec_aladin.c | 2 +- src/uwatec_memomouse.c | 2 +- src/uwatec_smart.c | 2 +- 14 files changed, 23 insertions(+), 18 deletions(-) diff --git a/examples/universal.c b/examples/universal.c index b82cdda..a3c6f8c 100644 --- a/examples/universal.c +++ b/examples/universal.c @@ -118,13 +118,16 @@ event_cb (device_t *device, device_event_t event, const void *data, void *userda } static int -dive_cb (const unsigned char *data, unsigned int size, void *userdata) +dive_cb (const unsigned char *data, unsigned int size, const unsigned char *fingerprint, unsigned int fsize, void *userdata) { static unsigned int count = 0; count++; - message ("Dive: number=%u, size=%u\n", count, size); + message ("Dive: number=%u, size=%u, fingerprint=", count, size); + for (unsigned int i = 0; i < fsize; ++i) + message ("%02X", fingerprint[i]); + message ("\n"); return 1; } diff --git a/src/device.h b/src/device.h index 1cbe7d1..0704ee4 100644 --- a/src/device.h +++ b/src/device.h @@ -89,7 +89,7 @@ typedef struct device_clock_t { typedef void (*device_event_callback_t) (device_t *device, device_event_t event, const void *data, void *userdata); -typedef int (*dive_callback_t) (const unsigned char *data, unsigned int size, void *userdata); +typedef int (*dive_callback_t) (const unsigned char *data, unsigned int size, const unsigned char *fingerprint, unsigned int fsize, void *userdata); device_type_t device_get_type (device_t *device); diff --git a/src/mares_common.c b/src/mares_common.c index 8bd354c..5da2e50 100644 --- a/src/mares_common.c +++ b/src/mares_common.c @@ -172,7 +172,7 @@ mares_common_extract_dives (mares_common_device_t *device, const mares_common_la return DEVICE_STATUS_SUCCESS; } - if (callback && !callback (buffer + offset, nbytes, userdata)) { + if (callback && !callback (buffer + offset, nbytes, buffer + fp_offset, sizeof (device->fingerprint), userdata)) { free (buffer); return DEVICE_STATUS_SUCCESS; } diff --git a/src/oceanic_common.c b/src/oceanic_common.c index 1b232b5..f7d8d41 100644 --- a/src/oceanic_common.c +++ b/src/oceanic_common.c @@ -469,7 +469,8 @@ oceanic_common_device_foreach (device_t *abstract, dive_callback_t callback, voi offset -= PAGESIZE / 2; memcpy (profiles + offset + available, logbooks + current, PAGESIZE / 2); - if (callback && !callback (profiles + offset + available, rb_entry_size + PAGESIZE / 2, userdata)) { + unsigned char *p = profiles + offset + available; + if (callback && !callback (p, rb_entry_size + PAGESIZE / 2, p, PAGESIZE / 2, userdata)) { free (logbooks); free (profiles); return DEVICE_STATUS_SUCCESS; diff --git a/src/reefnet_sensus.c b/src/reefnet_sensus.c index d91b028..5fe00a6 100644 --- a/src/reefnet_sensus.c +++ b/src/reefnet_sensus.c @@ -459,7 +459,7 @@ reefnet_sensus_extract_dives (device_t *abstract, const unsigned char data[], un if (device && timestamp <= device->timestamp) return DEVICE_STATUS_SUCCESS; - if (callback && !callback (data + current, offset - current, userdata)) + if (callback && !callback (data + current, offset - current, data + current + 2, 4, userdata)) return DEVICE_STATUS_SUCCESS; // Prepare for the next dive. diff --git a/src/reefnet_sensuspro.c b/src/reefnet_sensuspro.c index 413c9e3..c3b3dbc 100644 --- a/src/reefnet_sensuspro.c +++ b/src/reefnet_sensuspro.c @@ -435,7 +435,7 @@ reefnet_sensuspro_extract_dives (device_t *abstract, const unsigned char data[], if (device && timestamp <= device->timestamp) return DEVICE_STATUS_SUCCESS; - if (callback && !callback (data + current, offset + 2 - current, userdata)) + if (callback && !callback (data + current, offset + 2 - current, data + current + 6, 4, userdata)) return DEVICE_STATUS_SUCCESS; // Prepare for the next dive. diff --git a/src/reefnet_sensusultra.c b/src/reefnet_sensusultra.c index 35838e8..f7c2336 100644 --- a/src/reefnet_sensusultra.c +++ b/src/reefnet_sensusultra.c @@ -672,7 +672,7 @@ reefnet_sensusultra_parse (reefnet_sensusultra_device_t *device, return DEVICE_STATUS_SUCCESS; } - if (callback && !callback (current, previous - current, userdata)) { + if (callback && !callback (current, previous - current, current + 4, 4, userdata)) { if (aborted) *aborted = 1; return DEVICE_STATUS_SUCCESS; diff --git a/src/suunto_common.c b/src/suunto_common.c index 97964ce..13595f4 100644 --- a/src/suunto_common.c +++ b/src/suunto_common.c @@ -127,7 +127,7 @@ suunto_common_extract_dives (suunto_common_device_t *device, const suunto_common return DEVICE_STATUS_SUCCESS; } - if (callback && !callback (buffer, len, userdata)) { + if (callback && !callback (buffer, len, buffer + layout->fp_offset, sizeof (device->fingerprint), userdata)) { free (buffer); return DEVICE_STATUS_SUCCESS; } diff --git a/src/suunto_common2.c b/src/suunto_common2.c index 3162d6c..058091e 100644 --- a/src/suunto_common2.c +++ b/src/suunto_common2.c @@ -365,8 +365,9 @@ suunto_common2_device_foreach (device_t *abstract, dive_callback_t callback, voi remaining -= size; available = nbytes - size; - unsigned int prev = array_uint16_le (data + offset + available + 0); - unsigned int next = array_uint16_le (data + offset + available + 2); + unsigned char *p = data + offset + available; + unsigned int prev = array_uint16_le (p + 0); + unsigned int next = array_uint16_le (p + 2); if (next != previous) { WARNING ("Profiles are not continuous."); return DEVICE_STATUS_ERROR; @@ -376,10 +377,10 @@ suunto_common2_device_foreach (device_t *abstract, dive_callback_t callback, voi previous = current; current = prev; - if (memcmp (data + offset + available + FP_OFFSET, device->fingerprint, sizeof (device->fingerprint)) == 0) + if (memcmp (p + FP_OFFSET, device->fingerprint, sizeof (device->fingerprint)) == 0) return DEVICE_STATUS_SUCCESS; - if (callback && !callback (data + offset + available + 4, size - 4, userdata)) + if (callback && !callback (p + 4, size - 4, p + FP_OFFSET, sizeof (device->fingerprint), userdata)) return DEVICE_STATUS_SUCCESS; } diff --git a/src/suunto_solution.c b/src/suunto_solution.c index b1b8d23..fddf123 100644 --- a/src/suunto_solution.c +++ b/src/suunto_solution.c @@ -327,7 +327,7 @@ suunto_solution_extract_dives (device_t *abstract, const unsigned char data[], u if (data[peek] == 0x80) { unsigned int len = ringbuffer_distance (previous, current, 0, RB_PROFILE_BEGIN, RB_PROFILE_END); - if (callback && !callback (buffer + idx, len, userdata)) + if (callback && !callback (buffer + idx, len, NULL, 0, userdata)) return DEVICE_STATUS_SUCCESS; previous = current; diff --git a/src/suunto_vyper.c b/src/suunto_vyper.c index 38da227..35f6742 100644 --- a/src/suunto_vyper.c +++ b/src/suunto_vyper.c @@ -563,7 +563,7 @@ suunto_vyper_device_foreach (device_t *abstract, dive_callback_t callback, void return DEVICE_STATUS_SUCCESS; } - if (callback && !callback (data, size, userdata)) { + if (callback && !callback (data, size, data + layout->fp_offset, sizeof (device->fingerprint), userdata)) { dc_buffer_free (buffer); return DEVICE_STATUS_SUCCESS; } diff --git a/src/uwatec_aladin.c b/src/uwatec_aladin.c index 7914f02..142fbf2 100644 --- a/src/uwatec_aladin.c +++ b/src/uwatec_aladin.c @@ -413,7 +413,7 @@ uwatec_aladin_extract_dives (device_t *abstract, const unsigned char* data, unsi if (device && timestamp <= device->timestamp) return DEVICE_STATUS_SUCCESS; - if (callback && !callback (buffer, len + 18, userdata)) + if (callback && !callback (buffer, len + 18, buffer + 11, 4, userdata)) return DEVICE_STATUS_SUCCESS; } diff --git a/src/uwatec_memomouse.c b/src/uwatec_memomouse.c index 22c17f9..5ec17ea 100644 --- a/src/uwatec_memomouse.c +++ b/src/uwatec_memomouse.c @@ -575,7 +575,7 @@ uwatec_memomouse_extract_dives (device_t *abstract, const unsigned char data[], // Get the length of the profile data. unsigned int length = array_uint16_le (data + offset + 16); - if (callback && !callback (data + offset, length + 18, userdata)) + if (callback && !callback (data + offset, length + 18, data + offset + 11, 4, userdata)) return DEVICE_STATUS_SUCCESS; } diff --git a/src/uwatec_smart.c b/src/uwatec_smart.c index b98f668..b4bd692 100644 --- a/src/uwatec_smart.c +++ b/src/uwatec_smart.c @@ -475,7 +475,7 @@ uwatec_smart_extract_dives (device_t *abstract, const unsigned char data[], unsi if (current + len > previous) return DEVICE_STATUS_ERROR; - if (callback && !callback (data + current, len, userdata)) + if (callback && !callback (data + current, len, data + current + 8, 4, userdata)) return DEVICE_STATUS_SUCCESS; // Prepare for the next dive.