summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-22 18:02:54 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-22 18:02:54 -0700
commit3a77eb85101a5fb1dc186b88a3a02d2ae27690c7 (patch)
treebf40abf756c788347830b1990423f9c5ce9968b8 /dive.c
parent50c2bb7c71b279237f05c1c0a530d494bad534c8 (diff)
downloadsubsurface-3a77eb85101a5fb1dc186b88a3a02d2ae27690c7.tar.gz
Start handling dive events
Parse them, save them, take them from libdivecomputer. This doesn't merge them or show them in the profile yet, though. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/dive.c b/dive.c
index 1de3759d1..67a78cc8a 100644
--- a/dive.c
+++ b/dive.c
@@ -5,6 +5,29 @@
#include "dive.h"
+void add_event(struct dive *dive, int time, int type, int flags, int value, const char *name)
+{
+ struct event *ev, **p;
+ unsigned int size, len = strlen(name);
+
+ size = sizeof(*ev) + len + 1;
+ ev = malloc(size);
+ if (!ev)
+ return;
+ memset(ev, 0, size);
+ memcpy(ev->name, name, len);
+ ev->time.seconds = time;
+ ev->type = type;
+ ev->flags = flags;
+ ev->value = value;
+ ev->next = NULL;
+
+ p = &dive->events;
+ while (*p)
+ p = &(*p)->next;
+ *p = ev;
+}
+
double get_depth_units(unsigned int mm, int *frac, const char **units)
{
int decimals;