summaryrefslogtreecommitdiffstats
path: root/liquivision.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-07 21:08:54 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-07 21:20:02 -0800
commitdbc7dbb0741cd6fc5af1c8c389c3ed0caba4ad57 (patch)
treeed5586503c92c46e4239fa13ad2642f9a3ad9f2d /liquivision.c
parent0a27978014162f88f1ac26695e7180f502e66498 (diff)
downloadsubsurface-dbc7dbb0741cd6fc5af1c8c389c3ed0caba4ad57.tar.gz
Cleanup liquivision.c
strndup doesn't exist on Windows. Mark / remove unused variables. Plus codying style cleanup. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'liquivision.c')
-rw-r--r--liquivision.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/liquivision.c b/liquivision.c
index 2ba9b2d9f..a3f5d3a83 100644
--- a/liquivision.c
+++ b/liquivision.c
@@ -12,9 +12,23 @@
+ ((p)[1]<<8) + ((p)[2]<<16) \
+ ((p)[3]<<24))
+#if __WIN32__
+static char *strndup (const char *s, size_t n)
+{
+ char *cpy;
+ size_t len = strlen(s);
+ if (n < len)
+ len = n;
+ if ((cpy = malloc(len + 1)) != NULL) {
+ cpy[len] = '\0';
+ memcpy(cpy, s, len);
+ }
+ return cpy;
+}
+#endif
-static void
-parse_dives (int log_version, const unsigned char *buf, unsigned int buf_size) {
+static void parse_dives (int log_version, const unsigned char *buf, unsigned int buf_size)
+{
unsigned int ptr = 0;
unsigned char model;
@@ -142,6 +156,11 @@ parse_dives (int log_version, const unsigned char *buf, unsigned int buf_size) {
algorithm = *(buf + ptr++); // 0=ZH-L16C+GF
sample_count = array_uint32_le(buf + ptr);
}
+ // we aren't using the start_cns, dive_mode, and algorithm, yet
+ (void)start_cns;
+ (void)dive_mode;
+ (void)algorithm;
+
ptr += 4;
// Parse dive samples
@@ -206,7 +225,7 @@ parse_dives (int log_version, const unsigned char *buf, unsigned int buf_size) {
continue;
}
- int sample_time, next_time, last_time;
+ int sample_time, last_time;
int depth_mm, last_depth, temp_mk, last_temp;
while (true) {
@@ -216,7 +235,6 @@ parse_dives (int log_version, const unsigned char *buf, unsigned int buf_size) {
sample_time = d * sample_interval;
depth_mm = array_uint16_le(ds + d * 2) * 10; // cm->mm
temp_mk = C_to_mkelvin((float)array_uint16_le(ts + d * 2) / 10); // dC->mK
- next_time = (d < sample_count - 1 ? (d + 1) * sample_interval : sample_time);
last_time = (d ? (d - 1) * sample_interval : 0);
if (d == sample_count) {
@@ -317,9 +335,7 @@ parse_dives (int log_version, const unsigned char *buf, unsigned int buf_size) {
save_dives("/tmp/test.xml");
}
-
-int
-try_to_open_liquivision(const char *filename, struct memblock *mem)
+int try_to_open_liquivision(const char *filename, struct memblock *mem)
{
void *name;
const unsigned char *buf = mem->buffer;