mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
Use the new extra data interface for Poseidon import
Rather than overflowing the notes field, let's add all the details from DC using the extra data API. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
77220cd2c5
commit
9cf7a5d968
1 changed files with 30 additions and 3 deletions
33
file.c
33
file.c
|
@ -432,6 +432,22 @@ char *parse_mkvi_value(const char *haystack, const char *needle)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *next_mkvi_key(const char *haystack)
|
||||||
|
{
|
||||||
|
char *valueptr, *endptr, *ret = NULL;
|
||||||
|
|
||||||
|
if ((valueptr = strstr(haystack, "\n")) != NULL) {
|
||||||
|
valueptr += 1;
|
||||||
|
}
|
||||||
|
if ((endptr = strstr(valueptr, ": ")) != NULL) {
|
||||||
|
*endptr = 0;
|
||||||
|
ret = strdup(valueptr);
|
||||||
|
*endptr = ':';
|
||||||
|
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int parse_txt_file(const char *filename, const char *csv)
|
int parse_txt_file(const char *filename, const char *csv)
|
||||||
{
|
{
|
||||||
struct memblock memtxt, memcsv;
|
struct memblock memtxt, memcsv;
|
||||||
|
@ -449,7 +465,7 @@ int parse_txt_file(const char *filename, const char *csv)
|
||||||
int hh = 0, mm = 0, ss = 0;
|
int hh = 0, mm = 0, ss = 0;
|
||||||
int prev_depth = 0, cur_sampletime = 0, prev_setpoint = -1;
|
int prev_depth = 0, cur_sampletime = 0, prev_setpoint = -1;
|
||||||
bool has_depth = false, has_setpoint = false;
|
bool has_depth = false, has_setpoint = false;
|
||||||
char *lineptr;
|
char *lineptr, *key, *value;
|
||||||
int diluent_pressure = 0, cylinder_pressure = 0, cur_cylinder_index = 0;
|
int diluent_pressure = 0, cylinder_pressure = 0, cur_cylinder_index = 0;
|
||||||
|
|
||||||
struct dive *dive;
|
struct dive *dive;
|
||||||
|
@ -492,8 +508,19 @@ int parse_txt_file(const char *filename, const char *csv)
|
||||||
cur_cylinder_index++;
|
cur_cylinder_index++;
|
||||||
|
|
||||||
lineptr = strstr(memtxt.buffer, "Dive started at");
|
lineptr = strstr(memtxt.buffer, "Dive started at");
|
||||||
if (lineptr)
|
while (lineptr && *lineptr && (lineptr = strchr(lineptr, '\n')) && ++lineptr) {
|
||||||
dive->notes = strdup(lineptr);
|
key = next_mkvi_key(lineptr);
|
||||||
|
if (!key)
|
||||||
|
break;
|
||||||
|
value = parse_mkvi_value(lineptr, key);
|
||||||
|
if (!value) {
|
||||||
|
free(key);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
add_extra_data(&dive->dc, key, value);
|
||||||
|
free(key);
|
||||||
|
free(value);
|
||||||
|
}
|
||||||
dc = &dive->dc;
|
dc = &dive->dc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue