summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-05 13:45:14 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-05 13:45:14 -0700
commit89593a542aaf0554cceda7f92ad51e9df7e4cbde (patch)
tree8bd341f172e4530bc7f517531b640d99e1c9a6ec /parse-xml.c
parent4f5e3a06ab9ea8dea656b07bff9d0f4022c5b6ba (diff)
downloadsubsurface-89593a542aaf0554cceda7f92ad51e9df7e4cbde.tar.gz
Make the import source an enumeration
Instead of having each import source recognition routine set a separate flag for that import source, just enumerate them and set them in one variable. I'm adding yet another xml importer - divinglog. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 700f0d80f..ce0ae2844 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -91,9 +91,15 @@ static int alloc_samples;
static struct dive *dive;
static struct sample *sample;
static struct tm tm;
-static int suunto, uemis;
static int event_index, cylinder_index;
+static enum import_source {
+ UNKNOWN,
+ LIBDIVECOMPUTER,
+ SUUNTO,
+ UEMIS,
+} import_source;
+
static time_t utc_mktime(struct tm *tm)
{
static const int mdays[] = {
@@ -488,9 +494,14 @@ static void try_to_fill_sample(struct sample *sample, const char *name, char *bu
if (MATCH(".sample.time", sampletime, &sample->time))
return;
- if (uemis) {
+ switch (import_source) {
+ case UEMIS:
if (uemis_fill_sample(sample, name, len, buf))
return;
+ break;
+
+ default:
+ break;
}
nonmatch("sample", name, buf);
@@ -744,13 +755,20 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf)
if (MATCH(".he", gasmix, &dive->cylinder[cylinder_index].gasmix.he))
return;
- /* Suunto XML files are some crazy sh*t. */
- if (suunto && suunto_dive_match(dive, name, len, buf))
- return;
+ switch (import_source) {
+ case SUUNTO:
+ if (suunto_dive_match(dive, name, len, buf))
+ return;
+ break;
- if (uemis && uemis_dive_match(dive, name, len, buf))
- return;
+ case UEMIS:
+ if (uemis_dive_match(dive, name, len, buf))
+ return;
+ break;
+ default:
+ break;
+ }
nonmatch("dive", name, buf);
}
@@ -900,18 +918,17 @@ static void dive_end(void)
static void suunto_start(void)
{
- suunto++;
+ import_source = SUUNTO;
units = SI_units;
}
static void suunto_end(void)
{
- suunto--;
}
static void uemis_start(void)
{
- uemis++;
+ import_source = UEMIS;
units = SI_units;
}
@@ -1115,8 +1132,7 @@ static void reset_all(void)
* dive for that format.
*/
units = SI_units;
- suunto = 0;
- uemis = 0;
+ import_source = UNKNOWN;
}
void parse_xml_file(const char *filename)