X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=parse-xml.c;h=1eb6e95fdd1007aff73d326c7d6b073c7fe36f36;hb=99859dad54f88fdd911da2dee980be1cec18ca6f;hp=6bb78fdf6077e1db2a85ee6ee194e5793c8ae802;hpb=3a6652634b2152352f6f5a2b9ee3d549140ae337;p=ext%2Fsubsurface.git diff --git a/parse-xml.c b/parse-xml.c index 6bb78fd..1eb6e95 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -882,6 +882,20 @@ static int uddf_dive_match(struct dive *dive, const char *name, int len, char *b 0; } +static void gps_location(char *buffer, void *_dive) +{ + int i; + struct dive *dive = _dive; + double latitude, longitude; + + i = sscanf(buffer, "%lf %lf", &latitude, &longitude); + if (i == 2) { + dive->latitude = latitude; + dive->longitude = longitude; + } + free(buffer); +} + /* 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) { @@ -950,6 +964,8 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf) return; if (MATCH(".cylinderendpressure", pressure, &dive->cylinder[0].end)) return; + if (MATCH(".gps", gps_location, dive)) + return; if (MATCH(".location", utf8_string, &dive->location)) return; if (MATCH(".notes", utf8_string, &dive->notes)) @@ -1364,7 +1380,9 @@ void parse_xml_file(const char *filename, GError **error) } return; } - + /* we assume that the last (or only) filename passed as argument is a + * great filename to use as default when saving the dives */ + set_filename(filename); reset_all(); dive_start(); traverse(xmlDocGetRootElement(doc));