Convert to unix style line endings.

This commit is contained in:
Jef Driesen 2008-09-27 06:09:56 +00:00
parent ffe99a8724
commit 537f8a51c1
2 changed files with 47 additions and 47 deletions

View File

@ -19,8 +19,8 @@ struct device_t {
void *userdata;
};
struct device_backend_t {
device_type_t type;
struct device_backend_t {
device_type_t type;
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 (*close) (device_t *device);
device_status_t (*close) (device_t *device);
};
#define INFINITE ((unsigned int)-1)

View File

@ -1,53 +1,53 @@
#include <assert.h>
#include <string.h>
#include "suunto_common.h"
#include "ringbuffer.h"
#include <assert.h>
#include <string.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)
{
assert (eop >= begin && eop < end);
assert (data[eop] == 0x82);
assert (eop >= begin && eop < end);
assert (data[eop] == 0x82);
unsigned char buffer[0x2000 - 0x4C] = {0};
assert (sizeof (buffer) >= end - begin);
unsigned int current = eop;
unsigned int previous = eop;
for (unsigned int i = 0; i < end - begin; ++i) {
// Move backwards through the ringbuffer.
if (current == begin)
current = end;
current--;
// Check for an end of profile marker.
if (data[current] == 0x82)
break;
// Check for an end of dive marker (of the next dive),
unsigned int current = eop;
unsigned int previous = eop;
for (unsigned int i = 0; i < end - begin; ++i) {
// Move backwards through the ringbuffer.
if (current == begin)
current = end;
current--;
// Check for an end of profile marker.
if (data[current] == 0x82)
break;
// Check for an end of dive marker (of the next dive),
// to find the start of the current dive.
unsigned int index = ringbuffer_decrement (current, peek, begin, end);
if (data[index] == 0x80) {
unsigned int len = ringbuffer_distance (current, previous, begin, end);
if (current + len > end) {
unsigned int a = end - current;
unsigned int b = (current + len) - end;
memcpy (buffer + 0, data + current, a);
memcpy (buffer + a, data + begin, b);
} else {
memcpy (buffer, data + current, len);
}
if (callback && !callback (buffer, len, userdata))
return DEVICE_STATUS_SUCCESS;
previous = current;
}
}
assert (data[current] == 0x82);
unsigned int index = ringbuffer_decrement (current, peek, begin, end);
if (data[index] == 0x80) {
unsigned int len = ringbuffer_distance (current, previous, begin, end);
if (current + len > end) {
unsigned int a = end - current;
unsigned int b = (current + len) - end;
memcpy (buffer + 0, data + current, a);
memcpy (buffer + a, data + begin, b);
} else {
memcpy (buffer, data + current, len);
}
if (callback && !callback (buffer, len, userdata))
return DEVICE_STATUS_SUCCESS;
previous = current;
}
}
assert (data[current] == 0x82);
return DEVICE_STATUS_SUCCESS;
}