summaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'file.c')
-rw-r--r--file.c71
1 files changed, 57 insertions, 14 deletions
diff --git a/file.c b/file.c
index 25221e635..5646f3ed2 100644
--- a/file.c
+++ b/file.c
@@ -454,6 +454,18 @@ int parse_file(const char *filename)
return -1;
}
+ /* DataTrak/Wlog */
+ if (fmt && !strcasecmp(fmt + 1, "LOG")) {
+ datatrak_import(filename, &dive_table);
+ return 0;
+ }
+
+ /* OSTCtools */
+ if (fmt && (!strcasecmp(fmt + 1, "DIVE"))) {
+ ostctools_import(filename, &dive_table);
+ return 0;
+ }
+
ret = parse_file_buffer(filename, &mem);
free(mem.buffer);
return ret;
@@ -644,6 +656,7 @@ int parse_txt_file(const char *filename, const char *csv)
QT_TRANSLATE_NOOP("gettextFromC", "Mouth piece position not connected"));
break;
}
+ break;
case 3:
//Power Off event
add_event(dc, cur_sampletime, 0, 0, 0,
@@ -900,11 +913,12 @@ int parse_csv_file(const char *filename, int timef, int depthf, int tempf, int p
return ret;
}
-int parse_seabear_csv_file(const char *filename, int timef, int depthf, int tempf, int po2f, int cnsf, int ndlf, int ttsf, int stopdepthf, int pressuref, int sepidx, const char *csvtemplate, int unitidx)
+#define SBPARAMS 29
+int parse_seabear_csv_file(const char *filename, int timef, int depthf, int tempf, int po2f, int cnsf, int ndlf, int ttsf, int stopdepthf, int pressuref, int sepidx, const char *csvtemplate, int unitidx, const char *delta)
{
int ret;
struct memblock mem;
- char *params[27];
+ char *params[SBPARAMS];
char timebuf[MAXCOLDIGITS];
char depthbuf[MAXCOLDIGITS];
char tempbuf[MAXCOLDIGITS];
@@ -916,12 +930,13 @@ int parse_seabear_csv_file(const char *filename, int timef, int depthf, int temp
char pressurebuf[MAXCOLDIGITS];
char unitbuf[MAXCOLDIGITS];
char separator_index[MAXCOLDIGITS];
+ char deltabuf[MAXCOLDIGITS];
time_t now;
struct tm *timep = NULL;
char curdate[DATESTR];
char curtime[TIMESTR];
char *ptr, *ptr_old = NULL;
- char *NL;
+ char *NL = NULL;
if (timef >= MAXCOLS || depthf >= MAXCOLS || tempf >= MAXCOLS || po2f >= MAXCOLS || cnsf >= MAXCOLS || ndlf >= MAXCOLS || cnsf >= MAXCOLS || stopdepthf >= MAXCOLS || pressuref >= MAXCOLS)
return report_error(translate("gettextFromC", "Maximum number of supported columns on CSV import is %d"), MAXCOLS);
@@ -942,24 +957,24 @@ int parse_seabear_csv_file(const char *filename, int timef, int depthf, int temp
NL = "\r\n";
}
- /*
- * If file does not contain empty lines, it is not a valid
- * Seabear CSV file.
- */
- if (!ptr)
- return -1;
-
if (!ptr_old) {
while ((ptr = strstr(ptr, "\n\n")) != NULL) {
ptr_old = ptr;
ptr += 1;
+ NL = "\n";
}
ptr_old += 2;
- NL = "\n";
} else
ptr_old += 4;
/*
+ * If file does not contain empty lines, it is not a valid
+ * Seabear CSV file.
+ */
+ if (NL == NULL)
+ return -1;
+
+ /*
* On my current sample of Seabear DC log file, the date is
* without any identifier. Thus we must search for the previous
* line and step through from there.
@@ -982,6 +997,11 @@ int parse_seabear_csv_file(const char *filename, int timef, int depthf, int temp
params[21][5] = 0;
}
+ snprintf(deltabuf, MAXCOLDIGITS, "%s", delta);
+ params[SBPARAMS - 3] = "delta";
+ params[SBPARAMS - 2] = deltabuf;
+ params[SBPARAMS - 1] = NULL;
+
/* Move the CSV data to the start of mem buffer */
memmove(mem.buffer, ptr_old, mem.size - (ptr_old - (char*)mem.buffer));
mem.size = (int)mem.size - (ptr_old - (char*)mem.buffer);
@@ -994,11 +1014,20 @@ int parse_seabear_csv_file(const char *filename, int timef, int depthf, int temp
return ret;
}
-int parse_manual_file(const char *filename, int sepidx, int units, int dateformat, int durationformat, int numberf, int datef, int timef, int durationf, int locationf, int gpsf, int maxdepthf, int meandepthf, int divemasterf, int buddyf, int notesf, int weightf, int tagsf, int cylsizef, int startpresf, int endpresf, int o2f, int hef, int airtempf, int watertempf)
+int parse_manual_file(const char *filename, int sepidx, int units, int dateformat, int durationformat,
+ int numberf, int datef, int timef, int durationf, int locationf, int gpsf, int maxdepthf, int meandepthf,
+ int divemasterf, int buddyf, int suitf, int notesf, int weightf, int tagsf, int cylsizef, int startpresf, int endpresf,
+ int o2f, int hef, int airtempf, int watertempf)
{
+ if (verbose > 4) {
+ fprintf(stderr, "filename %s, sepidx %d, units %d, dateformat %d, durationformat %d\n", filename, sepidx, units, dateformat, durationformat);
+ fprintf(stderr, "numberf %d, datef %d, timef %d, durationf %d, locationf %d, gpsf %d, maxdepthf %d, meandepthf %d\n", numberf, datef, timef, durationf, locationf, gpsf, maxdepthf, meandepthf);
+ fprintf(stderr, "divemasterf %d, buddyf %d, suitf %d, notesf %d, weightf %d, tagsf %d, cylsizef %d, startpresf %d, endpresf %d\n", divemasterf, buddyf, suitf, notesf, weightf, tagsf, cylsizef, startpresf, endpresf);
+ fprintf(stderr, "o2f %d, hef %d, airtempf %d, watertempf %d\n", o2f, hef, airtempf, watertempf);
+ }
struct memblock mem;
int pnr = 0;
- char *params[53];
+ char *params[55];
char numberbuf[MAXCOLDIGITS];
char datebuf[MAXCOLDIGITS];
char timebuf[MAXCOLDIGITS];
@@ -1009,6 +1038,7 @@ int parse_manual_file(const char *filename, int sepidx, int units, int dateforma
char meandepthbuf[MAXCOLDIGITS];
char divemasterbuf[MAXCOLDIGITS];
char buddybuf[MAXCOLDIGITS];
+ char suitbuf[MAXCOLDIGITS];
char notesbuf[MAXCOLDIGITS];
char weightbuf[MAXCOLDIGITS];
char tagsbuf[MAXCOLDIGITS];
@@ -1029,7 +1059,7 @@ int parse_manual_file(const char *filename, int sepidx, int units, int dateforma
char curtime[6];
int ret;
- if (numberf >= MAXCOLS || datef >= MAXCOLS || timef >= MAXCOLS || durationf >= MAXCOLS || locationf >= MAXCOLS || gpsf >= MAXCOLS || maxdepthf >= MAXCOLS || meandepthf >= MAXCOLS || buddyf >= MAXCOLS || notesf >= MAXCOLS || weightf >= MAXCOLS || tagsf >= MAXCOLS || cylsizef >= MAXCOLS || startpresf >= MAXCOLS || endpresf >= MAXCOLS || o2f >= MAXCOLS || hef >= MAXCOLS || airtempf >= MAXCOLS || watertempf >= MAXCOLS)
+ if (numberf >= MAXCOLS || datef >= MAXCOLS || timef >= MAXCOLS || durationf >= MAXCOLS || locationf >= MAXCOLS || gpsf >= MAXCOLS || maxdepthf >= MAXCOLS || meandepthf >= MAXCOLS || buddyf >= MAXCOLS || suitf >= MAXCOLS || notesf >= MAXCOLS || weightf >= MAXCOLS || tagsf >= MAXCOLS || cylsizef >= MAXCOLS || startpresf >= MAXCOLS || endpresf >= MAXCOLS || o2f >= MAXCOLS || hef >= MAXCOLS || airtempf >= MAXCOLS || watertempf >= MAXCOLS)
return report_error(translate("gettextFromC", "Maximum number of supported columns on CSV import is %d"), MAXCOLS);
snprintf(numberbuf, MAXCOLDIGITS, "%d", numberf);
@@ -1042,6 +1072,7 @@ int parse_manual_file(const char *filename, int sepidx, int units, int dateforma
snprintf(meandepthbuf, MAXCOLDIGITS, "%d", meandepthf);
snprintf(divemasterbuf, MAXCOLDIGITS, "%d", divemasterf);
snprintf(buddybuf, MAXCOLDIGITS, "%d", buddyf);
+ snprintf(suitbuf, MAXCOLDIGITS, "%d", suitf);
snprintf(notesbuf, MAXCOLDIGITS, "%d", notesf);
snprintf(weightbuf, MAXCOLDIGITS, "%d", weightf);
snprintf(tagsbuf, MAXCOLDIGITS, "%d", tagsf);
@@ -1084,6 +1115,8 @@ int parse_manual_file(const char *filename, int sepidx, int units, int dateforma
params[pnr++] = divemasterbuf;
params[pnr++] = "buddyField";
params[pnr++] = buddybuf;
+ params[pnr++] = "suitField";
+ params[pnr++] = suitbuf;
params[pnr++] = "notesField";
params[pnr++] = notesbuf;
params[pnr++] = "weightField";
@@ -1125,7 +1158,17 @@ int parse_manual_file(const char *filename, int sepidx, int units, int dateforma
if (try_to_xslt_open_csv(filename, &mem, "manualCSV"))
return -1;
+ // right now input files created by XSLT processing report being v2 XML which makes
+ // the parse function abort until the dialog about importing v2 files has been shown.
+ // Until the XSLT has been updated we just override this check
+ //
+ // FIXME
+ //
+ bool remember = v2_question_shown;
+ v2_question_shown = true;
ret = parse_xml_buffer(filename, mem.buffer, mem.size, &dive_table, (const char **)params);
+ v2_question_shown = remember;
+
free(mem.buffer);
return ret;
}