summaryrefslogtreecommitdiffstats
path: root/subsurface-core/datatrak.h
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-02 19:54:34 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-02 19:54:34 -0800
commit8ea7f404574c2ee571d2dde6bb6be3791e962150 (patch)
tree6a050178bfc71bf10558968f2a3bc0a12d8c525f /subsurface-core/datatrak.h
parentb273c1b0ca7bfe933e7c83742f1610f6bbe3f4d3 (diff)
parentdf7818a9b8495285b4d9812e5d6d50d6f9c08813 (diff)
downloadsubsurface-8ea7f404574c2ee571d2dde6bb6be3791e962150.tar.gz
Merge branch 'cmakeAndPreferences'
Diffstat (limited to 'subsurface-core/datatrak.h')
-rw-r--r--subsurface-core/datatrak.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/subsurface-core/datatrak.h b/subsurface-core/datatrak.h
new file mode 100644
index 000000000..3a37e0465
--- /dev/null
+++ b/subsurface-core/datatrak.h
@@ -0,0 +1,41 @@
+#ifndef DATATRAK_HEADER_H
+#define DATATRAK_HEADER_H
+
+#include <string.h>
+
+typedef struct dtrakheader_ {
+ int header; //Must be 0xA100;
+ int divesNum;
+ int dc_serial_1;
+ int dc_serial_2;
+} dtrakheader;
+
+#define read_bytes(_n) \
+ switch (_n) { \
+ case 1: \
+ if (fread (&lector_bytes, sizeof(char), _n, archivo) != _n) \
+ goto bail; \
+ tmp_1byte = lector_bytes[0]; \
+ break; \
+ case 2: \
+ if (fread (&lector_bytes, sizeof(char), _n, archivo) != _n) \
+ goto bail; \
+ tmp_2bytes = two_bytes_to_int (lector_bytes[1], lector_bytes[0]); \
+ break; \
+ default: \
+ if (fread (&lector_word, sizeof(char), _n, archivo) != _n) \
+ goto bail; \
+ tmp_4bytes = four_bytes_to_long(lector_word[3], lector_word[2], lector_word[1], lector_word[0]); \
+ break; \
+ }
+
+#define read_string(_property) \
+ unsigned char *_property##tmp = (unsigned char *)calloc(tmp_1byte + 1, 1); \
+ if (fread((char *)_property##tmp, 1, tmp_1byte, archivo) != tmp_1byte) { \
+ free(_property##tmp); \
+ goto bail; \
+ } \
+ _property = (unsigned char *)strcat(to_utf8(_property##tmp), ""); \
+ free(_property##tmp);
+
+#endif // DATATRAK_HEADER_H