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>
static struct dive *dive;
static struct sample *sample;
static struct tm tm;
static struct dive *dive;
static struct sample *sample;
static struct tm tm;
-static int suunto, uemis;
static int event_index, cylinder_index;
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[] = {
static time_t utc_mktime(struct tm *tm)
{
static const int mdays[] = {
if (MATCH(".sample.time", sampletime, &sample->time))
return;
if (MATCH(".sample.time", sampletime, &sample->time))
return;
+ switch (import_source) {
+ case UEMIS:
if (uemis_fill_sample(sample, name, len, buf))
return;
if (uemis_fill_sample(sample, name, len, buf))
return;
+ break;
+
+ default:
+ break;
}
nonmatch("sample", name, buf);
}
nonmatch("sample", name, buf);
if (MATCH(".he", gasmix, &dive->cylinder[cylinder_index].gasmix.he))
return;
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;
nonmatch("dive", name, buf);
}
nonmatch("dive", name, buf);
}
static void suunto_start(void)
{
static void suunto_start(void)
{
+ import_source = SUUNTO;
units = SI_units;
}
static void suunto_end(void)
{
units = SI_units;
}
static void suunto_end(void)
{
}
static void uemis_start(void)
{
}
static void uemis_start(void)
{
* dive for that format.
*/
units = SI_units;
* dive for that format.
*/
units = SI_units;
- suunto = 0;
- uemis = 0;
+ import_source = UNKNOWN;
}
void parse_xml_file(const char *filename)
}
void parse_xml_file(const char *filename)