Import dive number from DL7 log

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
This commit is contained in:
Miika Turkia 2017-09-06 19:32:04 +03:00 committed by Dirk Hohndel
parent 5b5cab2905
commit 40cc0b0e4b
2 changed files with 15 additions and 6 deletions

View file

@ -911,6 +911,15 @@ int parse_dan_format(const char *filename, char **params, int pnr)
mem_csv.buffer = malloc(mem.size + 1);
mem_csv.size = mem.size;
iter = ptr + 4;
iter = strchr(iter, '|');
if (iter) {
memcpy(tmpbuf, ptr + 4, iter - ptr - 4);
tmpbuf[iter - ptr - 4] = 0;
params[pnr] = "diveNro";
params[pnr + 1] = strdup(tmpbuf);
}
//fprintf(stderr, "DEBUG: BEGIN end_ptr %d round %d <%s>\n", end_ptr, j++, ptr);
iter = ptr + 1;
for (i = 0; i <= 4 && iter; ++i) {
@ -922,8 +931,8 @@ int parse_dan_format(const char *filename, char **params, int pnr)
/* Setting date */
memcpy(tmpbuf, iter, 8);
tmpbuf[8] = 0;
params[pnr] = "date";
params[pnr + 1] = strdup(tmpbuf);
params[pnr + 2] = "date";
params[pnr + 3] = strdup(tmpbuf);
/* Setting time, gotta prepend it with 1 to
* avoid octal parsing (this is stripped out in
@ -931,9 +940,9 @@ int parse_dan_format(const char *filename, char **params, int pnr)
tmpbuf[0] = '1';
memcpy(tmpbuf + 1, iter + 8, 6);
tmpbuf[7] = 0;
params[pnr + 2] = "time";
params[pnr + 3] = strdup(tmpbuf);
params[pnr + 4] = NULL;
params[pnr + 4] = "time";
params[pnr + 5] = strdup(tmpbuf);
params[pnr + 6] = NULL;
ptr = strstr(ptr, "ZDP{");
if (ptr)

View file

@ -926,7 +926,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
parse_manual_file(fileNames[i].toUtf8().data(), params, pnr - 1);
} else {
char *params[49];
char *params[51];
int pnr = 0;
QRegExp apdRe("^.*[/\\][0-9a-zA-Z]*_([0-9]{6})_([0-9]{6})\\.apd");