Convert to unix style line endings.
This commit is contained in:
parent
ffe99a8724
commit
537f8a51c1
@ -19,8 +19,8 @@ struct device_t {
|
|||||||
void *userdata;
|
void *userdata;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct device_backend_t {
|
struct device_backend_t {
|
||||||
device_type_t type;
|
device_type_t type;
|
||||||
|
|
||||||
device_status_t (*handshake) (device_t *device, unsigned char data[], unsigned int size);
|
device_status_t (*handshake) (device_t *device, unsigned char data[], unsigned int size);
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ struct device_backend_t {
|
|||||||
|
|
||||||
device_status_t (*foreach) (device_t *device, dive_callback_t callback, void *userdata);
|
device_status_t (*foreach) (device_t *device, dive_callback_t callback, void *userdata);
|
||||||
|
|
||||||
device_status_t (*close) (device_t *device);
|
device_status_t (*close) (device_t *device);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define INFINITE ((unsigned int)-1)
|
#define INFINITE ((unsigned int)-1)
|
||||||
|
|||||||
@ -1,53 +1,53 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "suunto_common.h"
|
|
||||||
#include "ringbuffer.h"
|
|
||||||
|
|
||||||
|
|
||||||
device_status_t
|
#include "suunto_common.h"
|
||||||
|
#include "ringbuffer.h"
|
||||||
|
|
||||||
|
|
||||||
|
device_status_t
|
||||||
suunto_common_extract_dives (const unsigned char data[], unsigned int begin, unsigned int end, unsigned int eop, unsigned int peek, dive_callback_t callback, void *userdata)
|
suunto_common_extract_dives (const unsigned char data[], unsigned int begin, unsigned int end, unsigned int eop, unsigned int peek, dive_callback_t callback, void *userdata)
|
||||||
{
|
{
|
||||||
assert (eop >= begin && eop < end);
|
assert (eop >= begin && eop < end);
|
||||||
assert (data[eop] == 0x82);
|
assert (data[eop] == 0x82);
|
||||||
|
|
||||||
unsigned char buffer[0x2000 - 0x4C] = {0};
|
unsigned char buffer[0x2000 - 0x4C] = {0};
|
||||||
assert (sizeof (buffer) >= end - begin);
|
assert (sizeof (buffer) >= end - begin);
|
||||||
|
|
||||||
unsigned int current = eop;
|
unsigned int current = eop;
|
||||||
unsigned int previous = eop;
|
unsigned int previous = eop;
|
||||||
for (unsigned int i = 0; i < end - begin; ++i) {
|
for (unsigned int i = 0; i < end - begin; ++i) {
|
||||||
// Move backwards through the ringbuffer.
|
// Move backwards through the ringbuffer.
|
||||||
if (current == begin)
|
if (current == begin)
|
||||||
current = end;
|
current = end;
|
||||||
current--;
|
current--;
|
||||||
|
|
||||||
// Check for an end of profile marker.
|
// Check for an end of profile marker.
|
||||||
if (data[current] == 0x82)
|
if (data[current] == 0x82)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Check for an end of dive marker (of the next dive),
|
// Check for an end of dive marker (of the next dive),
|
||||||
// to find the start of the current dive.
|
// to find the start of the current dive.
|
||||||
unsigned int index = ringbuffer_decrement (current, peek, begin, end);
|
unsigned int index = ringbuffer_decrement (current, peek, begin, end);
|
||||||
if (data[index] == 0x80) {
|
if (data[index] == 0x80) {
|
||||||
unsigned int len = ringbuffer_distance (current, previous, begin, end);
|
unsigned int len = ringbuffer_distance (current, previous, begin, end);
|
||||||
if (current + len > end) {
|
if (current + len > end) {
|
||||||
unsigned int a = end - current;
|
unsigned int a = end - current;
|
||||||
unsigned int b = (current + len) - end;
|
unsigned int b = (current + len) - end;
|
||||||
memcpy (buffer + 0, data + current, a);
|
memcpy (buffer + 0, data + current, a);
|
||||||
memcpy (buffer + a, data + begin, b);
|
memcpy (buffer + a, data + begin, b);
|
||||||
} else {
|
} else {
|
||||||
memcpy (buffer, data + current, len);
|
memcpy (buffer, data + current, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callback && !callback (buffer, len, userdata))
|
if (callback && !callback (buffer, len, userdata))
|
||||||
return DEVICE_STATUS_SUCCESS;
|
return DEVICE_STATUS_SUCCESS;
|
||||||
|
|
||||||
previous = current;
|
previous = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (data[current] == 0x82);
|
assert (data[current] == 0x82);
|
||||||
|
|
||||||
return DEVICE_STATUS_SUCCESS;
|
return DEVICE_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user