aboutsummaryrefslogtreecommitdiffstats
path: root/load-git.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-06 11:23:34 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-07 13:00:14 -0800
commit4ccddf95d7660b9c2c91da1d72f08bd45988c83e (patch)
tree650029d8cb9fb8631478c93b4da6feada3c6e3a5 /load-git.c
parentd6b410940975c7ccaf63c3509eda4ff25d16190f (diff)
downloadsubsurface-4ccddf95d7660b9c2c91da1d72f08bd45988c83e.tar.gz
Load and save extra data in git format
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'load-git.c')
-rw-r--r--load-git.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/load-git.c b/load-git.c
index f65126abf..53172f61e 100644
--- a/load-git.c
+++ b/load-git.c
@@ -540,6 +540,32 @@ static void parse_event_keyvalue(void *_event, const char *key, const char *valu
report_error("Unexpected event key/value pair (%s/%s)", key, value);
}
+/* keyvalue "key" "value"
+ * so we have two strings (possibly empty) in the membuffer, separated by a '\0' */
+static void parse_dc_keyvalue(char *line, struct membuffer *str, void *_dc)
+{
+ const char *key, *value;
+ struct divecomputer *dc = _dc;
+
+ // Let's make sure we have two strings...
+ int string_counter = 0;
+ while(*line) {
+ if (*line == '"')
+ string_counter++;
+ line++;
+ }
+ if (string_counter != 2)
+ return;
+
+ // stupidly the second string in the membuffer isn't NUL terminated;
+ // asking for a cstring fixes that; interestingly enough, given that there are two
+ // strings in the mb, the next command at the same time assigns a pointer to the
+ // first string to 'key' and NUL terminates the second string (which then goes to 'value')
+ key = mb_cstring(str);
+ value = key + strlen(key) + 1;
+ add_extra_data(dc, key, value);
+}
+
static void parse_dc_event(char *line, struct membuffer *str, void *_dc)
{
int m, s = 0;
@@ -699,7 +725,7 @@ struct keyword_action dc_action[] = {
#undef D
#define D(x) { #x, parse_dc_ ## x }
D(airtemp), D(date), D(deviceid), D(diveid), D(duration),
- D(event), D(maxdepth), D(meandepth), D(model), D(salinity),
+ D(event), D(keyvalue), D(maxdepth), D(meandepth), D(model), D(salinity),
D(surfacepressure), D(surfacetime), D(time), D(watertemp),
};