summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-08 17:42:15 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-08 17:44:01 -0700
commit98e1b36a9887d252f6c331b76c4a807e66b4bb99 (patch)
treec9101e218a5dfb4282b83cdf0c5ae31430b0cba8 /parse-xml.c
parent1604299a5b4ed183187d7cb13df445d306eda60e (diff)
downloadsubsurface-98e1b36a9887d252f6c331b76c4a807e66b4bb99.tar.gz
Picture handling: parse XML data
Using XML data files we can now save picture data and load it back in again. The corresponding code for save-git and load-git is still missing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 062e231be..22b11e7ea 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -98,6 +98,7 @@ static struct divecomputer *cur_dc;
static struct dive *cur_dive;
static dive_trip_t *cur_trip = NULL;
static struct sample *cur_sample;
+static struct picture *cur_picture;
static struct {
int active;
duration_t time;
@@ -1034,6 +1035,14 @@ static void gps_location(char *buffer, struct dive *dive)
dive->longitude = parse_degrees(end, &end);
}
+static void gps_picture_location(char *buffer, struct picture *pic)
+{
+ char *end;
+
+ pic->latitude = parse_degrees(buffer, &end);
+ pic->longitude = parse_degrees(end, &end);
+}
+
/* We're in the top-level dive xml. Try to convert whatever value to a dive value */
static void try_to_fill_dive(struct dive *dive, const char *name, char *buf)
{
@@ -1073,6 +1082,12 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf)
if (match_dc_data_fields(&dive->dc, name, buf))
return;
+ if (MATCH("filename.picture", utf8_string, &cur_picture->filename))
+ return;
+ if (MATCH("offset.picture", get_index, &cur_picture->offset))
+ return;
+ if (MATCH("gps.picture", gps_picture_location, cur_picture))
+ return;
if (MATCH("cylinderstartpressure", pressure, &dive->cylinder[0].start))
return;
if (MATCH("cylinderendpressure", pressure, &dive->cylinder[0].end))
@@ -1284,6 +1299,17 @@ static void event_end(void)
cur_event.active = 0;
}
+static void picture_start(void)
+{
+ cur_picture = alloc_picture();
+}
+
+static void picture_end(void)
+{
+ dive_add_picture(cur_dive, cur_picture);
+ cur_picture = NULL;
+}
+
static void cylinder_start(void)
{
}
@@ -1523,6 +1549,7 @@ static struct nesting {
{ "divecomputer", divecomputer_start, divecomputer_end },
{ "P", sample_start, sample_end },
{ "userid", userid_start, userid_stop},
+ { "picture", picture_start, picture_end },
/* Import type recognition */
{ "Divinglog", DivingLog_importer },