diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/cochran.c | 9 | ||||
-rw-r--r-- | core/datatrak.c | 2 | ||||
-rw-r--r-- | core/file.c | 10 | ||||
-rw-r--r-- | core/file.h | 4 | ||||
-rw-r--r-- | core/import-csv.c | 34 | ||||
-rw-r--r-- | core/import-csv.h | 10 | ||||
-rw-r--r-- | core/liquivision.c | 8 |
7 files changed, 39 insertions, 38 deletions
diff --git a/core/cochran.c b/core/cochran.c index a8f008c4c..164b94bee 100644 --- a/core/cochran.c +++ b/core/cochran.c @@ -600,7 +600,8 @@ static void cochran_parse_samples(struct dive *dive, const unsigned char *log, } static void cochran_parse_dive(const unsigned char *decode, unsigned mod, - const unsigned char *in, unsigned size) + const unsigned char *in, unsigned size, + struct dive_table *table) { unsigned char *buf = malloc(size); struct dive *dive; @@ -785,13 +786,13 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod, } dive->downloaded = true; - record_dive(dive); + record_dive_to_table(dive, table); mark_divelist_changed(true); free(buf); } -int try_to_open_cochran(const char *filename, struct memblock *mem) +int try_to_open_cochran(const char *filename, struct memblock *mem, struct dive_table *table) { UNUSED(filename); unsigned int i; @@ -822,7 +823,7 @@ int try_to_open_cochran(const char *filename, struct memblock *mem) break; cochran_parse_dive(decode, mod, mem->buffer + dive1, - dive2 - dive1); + dive2 - dive1, table); } return 1; // no further processing needed diff --git a/core/datatrak.c b/core/datatrak.c index 1c728aa45..582fb512f 100644 --- a/core/datatrak.c +++ b/core/datatrak.c @@ -602,7 +602,7 @@ int datatrak_import(struct memblock *mem, struct dive_table *table) rc = 1; goto out; } else { - record_dive(ptdive); + record_dive_to_table(ptdive, table); } i++; } diff --git a/core/file.c b/core/file.c index abef20a7d..6f2edcf8d 100644 --- a/core/file.c +++ b/core/file.c @@ -220,16 +220,16 @@ static int open_by_filename(const char *filename, const char *fmt, struct memblo return report_error(translate("gettextFromC", csv_warning), filename); /* Truly nasty intentionally obfuscated Cochran Anal software */ if (!strcasecmp(fmt, "CAN")) - return try_to_open_cochran(filename, mem); + return try_to_open_cochran(filename, mem, table); /* Cochran export comma-separated-value files */ if (!strcasecmp(fmt, "DPT")) - return try_to_open_csv(mem, CSV_DEPTH); + return try_to_open_csv(mem, CSV_DEPTH, table); if (!strcasecmp(fmt, "LVD")) - return try_to_open_liquivision(filename, mem); + return try_to_open_liquivision(filename, mem, table); if (!strcasecmp(fmt, "TMP")) - return try_to_open_csv(mem, CSV_TEMP); + return try_to_open_csv(mem, CSV_TEMP, table); if (!strcasecmp(fmt, "HP1")) - return try_to_open_csv(mem, CSV_PRESSURE); + return try_to_open_csv(mem, CSV_PRESSURE, table); return 0; } diff --git a/core/file.h b/core/file.h index 7dbd07b48..e0033d94e 100644 --- a/core/file.h +++ b/core/file.h @@ -7,8 +7,8 @@ struct memblock { size_t size; }; -extern int try_to_open_cochran(const char *filename, struct memblock *mem); -extern int try_to_open_liquivision(const char *filename, struct memblock *mem); +extern int try_to_open_cochran(const char *filename, struct memblock *mem, struct dive_table *table); +extern int try_to_open_liquivision(const char *filename, struct memblock *mem, struct dive_table *table); extern int datatrak_import(struct memblock *mem, struct dive_table *table); extern void ostctools_import(const char *file, struct dive_table *table); diff --git a/core/import-csv.c b/core/import-csv.c index b3ff4261f..15255e191 100644 --- a/core/import-csv.c +++ b/core/import-csv.c @@ -101,7 +101,7 @@ static char *parse_dan_new_line(char *buf, const char *NL) } static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, const char *tag); -static int parse_dan_format(const char *filename, char **params, int pnr) +static int parse_dan_format(const char *filename, char **params, int pnr, struct dive_table *table) { int ret = 0, i; size_t end_ptr = 0; @@ -219,7 +219,7 @@ static int parse_dan_format(const char *filename, char **params, int pnr) } } params[pnr_local] = NULL; - ret |= parse_xml_buffer(filename, "<csv></csv>", 11, &dive_table, (const char **)params); + ret |= parse_xml_buffer(filename, "<csv></csv>", 11, table, (const char **)params); continue; } @@ -276,7 +276,7 @@ static int parse_dan_format(const char *filename, char **params, int pnr) if (try_to_xslt_open_csv(filename, &mem_csv, "csv")) return -1; - ret |= parse_xml_buffer(filename, mem_csv.buffer, mem_csv.size, &dive_table, (const char **)params); + ret |= parse_xml_buffer(filename, mem_csv.buffer, mem_csv.size, table, (const char **)params); end_ptr += ptr - (char *)mem_csv.buffer; free(mem_csv.buffer); } @@ -288,7 +288,7 @@ static int parse_dan_format(const char *filename, char **params, int pnr) return ret; } -int parse_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate) +int parse_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate, struct dive_table *table) { int ret, i; struct memblock mem; @@ -308,7 +308,7 @@ int parse_csv_file(const char *filename, char **params, int pnr, const char *csv mem.size = 0; if (!strcmp("DL7", csvtemplate)) { - return parse_dan_format(filename, params, pnr); + return parse_dan_format(filename, params, pnr, table); } else if (strcmp(params[0], "date")) { time(&now); timep = localtime(&now); @@ -343,7 +343,7 @@ int parse_csv_file(const char *filename, char **params, int pnr, const char *csv fprintf(stderr, "%s/xslt/csv2xml.xslt -\n", SUBSURFACE_SOURCE); } #endif - ret = parse_xml_buffer(filename, mem.buffer, mem.size, &dive_table, (const char **)params); + ret = parse_xml_buffer(filename, mem.buffer, mem.size, table, (const char **)params); free(mem.buffer); for (i = 0; params[i]; i += 2) @@ -402,7 +402,7 @@ static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, cons return 0; } -int try_to_open_csv(struct memblock *mem, enum csv_format type) +int try_to_open_csv(struct memblock *mem, enum csv_format type, struct dive_table *table) { char *p = mem->buffer; char *header[8]; @@ -452,7 +452,7 @@ int try_to_open_csv(struct memblock *mem, enum csv_format type) break; p = end + 1; } - record_dive(dive); + record_dive_to_table(dive, table); return 1; } @@ -494,7 +494,7 @@ static char *next_mkvi_key(const char *haystack) return ret; } -int parse_txt_file(const char *filename, const char *csv) +int parse_txt_file(const char *filename, const char *csv, struct dive_table *table) { struct memblock memtxt, memcsv; @@ -773,7 +773,7 @@ int parse_txt_file(const char *filename, const char *csv) if (!lineptr || !*lineptr) break; } - record_dive(dive); + record_dive_to_table(dive, table); return 1; } else { return 0; @@ -786,15 +786,15 @@ int parse_txt_file(const char *filename, const char *csv) #define TIMESTR 6 #define SBPARAMS 40 -static int parse_seabear_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate); -int parse_seabear_log(const char *filename) +static int parse_seabear_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate, struct dive_table *table); +int parse_seabear_log(const char *filename, struct dive_table *table) { char *params[SBPARAMS]; int pnr = 0; pnr = parse_seabear_header(filename, params, pnr); - if (parse_seabear_csv_file(filename, params, pnr, "csv") < 0) { + if (parse_seabear_csv_file(filename, params, pnr, "csv", table) < 0) { return -1; } @@ -802,7 +802,7 @@ int parse_seabear_log(const char *filename) } -static int parse_seabear_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate) +static int parse_seabear_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate, struct dive_table *table) { int ret, i; struct memblock mem; @@ -921,7 +921,7 @@ static int parse_seabear_csv_file(const char *filename, char **params, int pnr, fprintf(stderr, "xslt/csv2xml.xslt\n"); } - ret = parse_xml_buffer(filename, mem.buffer, mem.size, &dive_table, (const char **)params); + ret = parse_xml_buffer(filename, mem.buffer, mem.size, table, (const char **)params); free(mem.buffer); for (i = 0; params[i]; i += 2) free(params[i + 1]); @@ -929,7 +929,7 @@ static int parse_seabear_csv_file(const char *filename, char **params, int pnr, return ret; } -int parse_manual_file(const char *filename, char **params, int pnr) +int parse_manual_file(const char *filename, char **params, int pnr, struct dive_table *table) { struct memblock mem; time_t now; @@ -969,7 +969,7 @@ int parse_manual_file(const char *filename, char **params, int pnr) fprintf(stderr, "%s/xslt/manualcsv2xml.xslt -\n", SUBSURFACE_SOURCE); } #endif - ret = parse_xml_buffer(filename, mem.buffer, mem.size, &dive_table, (const char **)params); + ret = parse_xml_buffer(filename, mem.buffer, mem.size, table, (const char **)params); free(mem.buffer); for (i = 0; i < pnr - 2; ++i) diff --git a/core/import-csv.h b/core/import-csv.h index 1f1d330e7..363daa291 100644 --- a/core/import-csv.h +++ b/core/import-csv.h @@ -21,12 +21,12 @@ enum csv_format { extern "C" { #endif -int parse_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate); -int try_to_open_csv(struct memblock *mem, enum csv_format type); -int parse_txt_file(const char *filename, const char *csv); +int parse_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate, struct dive_table *table); +int try_to_open_csv(struct memblock *mem, enum csv_format type, struct dive_table *table); +int parse_txt_file(const char *filename, const char *csv, struct dive_table *table); -int parse_seabear_log(const char *filename); -int parse_manual_file(const char *filename, char **params, int pnr); +int parse_seabear_log(const char *filename, struct dive_table *table); +int parse_manual_file(const char *filename, char **params, int pnr, struct dive_table *table); #ifdef __cplusplus } diff --git a/core/liquivision.c b/core/liquivision.c index 28d571b3c..99641835c 100644 --- a/core/liquivision.c +++ b/core/liquivision.c @@ -132,7 +132,7 @@ static int handle_event_ver3(int code, const unsigned char *ps, unsigned int ps_ return skip; } -static void parse_dives (int log_version, const unsigned char *buf, unsigned int buf_size) +static void parse_dives (int log_version, const unsigned char *buf, unsigned int buf_size, struct dive_table *table) { unsigned int ptr = 0; unsigned char model; @@ -428,7 +428,7 @@ static void parse_dives (int log_version, const unsigned char *buf, unsigned int // End dive dive->downloaded = true; - record_dive(dive); + record_dive_to_table(dive, table); dive = NULL; mark_divelist_changed(true); @@ -442,7 +442,7 @@ static void parse_dives (int log_version, const unsigned char *buf, unsigned int free(dive); } -int try_to_open_liquivision(const char *filename, struct memblock *mem) +int try_to_open_liquivision(const char *filename, struct memblock *mem, struct dive_table *table) { UNUSED(filename); const unsigned char *buf = mem->buffer; @@ -466,7 +466,7 @@ int try_to_open_liquivision(const char *filename, struct memblock *mem) } ptr += 4; - parse_dives(log_version, buf + ptr, buf_size - ptr); + parse_dives(log_version, buf + ptr, buf_size - ptr, table); return 1; } |