From f5e3004ab5e7f0fa33a9ef62ec3f0ced065b956a Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 29 Feb 2024 07:29:11 +0100 Subject: [PATCH] core: convert core/import-*.c to C++ import-csv.c was crazy with implicit (const char *) to (char *) conversions! Signed-off-by: Berthold Stoeger --- Subsurface-mobile.pro | 12 ++--- core/CMakeLists.txt | 12 ++--- core/{import-cobalt.c => import-cobalt.cpp} | 34 +++---------- core/{import-csv.c => import-csv.cpp} | 50 +++++++++---------- ...mport-divinglog.c => import-divinglog.cpp} | 23 +++------ core/{import-seac.c => import-seac.cpp} | 9 +--- ...ort-shearwater.c => import-shearwater.cpp} | 40 ++++----------- core/{import-suunto.c => import-suunto.cpp} | 41 ++++----------- 8 files changed, 73 insertions(+), 148 deletions(-) rename core/{import-cobalt.c => import-cobalt.cpp} (87%) rename core/{import-csv.c => import-csv.cpp} (93%) rename core/{import-divinglog.c => import-divinglog.cpp} (93%) rename core/{import-seac.c => import-seac.cpp} (96%) rename core/{import-shearwater.c => import-shearwater.cpp} (93%) rename core/{import-suunto.c => import-suunto.cpp} (92%) diff --git a/Subsurface-mobile.pro b/Subsurface-mobile.pro index b5ab6e7ec..635dea38e 100644 --- a/Subsurface-mobile.pro +++ b/Subsurface-mobile.pro @@ -67,12 +67,12 @@ SOURCES += subsurface-mobile-main.cpp \ core/picture.c \ core/pictureobj.cpp \ core/sample.cpp \ - core/import-suunto.c \ - core/import-shearwater.c \ - core/import-seac.c \ - core/import-cobalt.c \ - core/import-divinglog.c \ - core/import-csv.c \ + core/import-suunto.cpp \ + core/import-shearwater.cpp \ + core/import-seac.cpp \ + core/import-cobalt.cpp \ + core/import-divinglog.cpp \ + core/import-csv.cpp \ core/save-html.c \ core/statistics.c \ core/worldmap-save.c \ diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 3733fb2c9..51723f4d6 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -113,13 +113,13 @@ set(SUBSURFACE_CORE_LIB_SRCS globals.h imagedownloader.cpp imagedownloader.h - import-cobalt.c - import-csv.c + import-cobalt.cpp + import-csv.cpp import-csv.h - import-divinglog.c - import-shearwater.c - import-suunto.c - import-seac.c + import-divinglog.cpp + import-shearwater.cpp + import-suunto.cpp + import-seac.cpp interpolate.h libdivecomputer.c libdivecomputer.h diff --git a/core/import-cobalt.c b/core/import-cobalt.cpp similarity index 87% rename from core/import-cobalt.c rename to core/import-cobalt.cpp index 93ebae3d4..3e150c64b 100644 --- a/core/import-cobalt.c +++ b/core/import-cobalt.cpp @@ -18,10 +18,8 @@ #include "membuffer.h" #include "gettext.h" -static int cobalt_profile_sample(void *param, int columns, char **data, char **column) +static int cobalt_profile_sample(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; sample_start(state); @@ -37,10 +35,8 @@ static int cobalt_profile_sample(void *param, int columns, char **data, char **c } -static int cobalt_cylinders(void *param, int columns, char **data, char **column) +static int cobalt_cylinders(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; cylinder_t *cyl; @@ -62,10 +58,8 @@ static int cobalt_cylinders(void *param, int columns, char **data, char **column return 0; } -static int cobalt_buddies(void *param, int columns, char **data, char **column) +static int cobalt_buddies(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; if (data[0]) @@ -79,30 +73,21 @@ static int cobalt_buddies(void *param, int columns, char **data, char **column) * Subsurface star rating. */ -static int cobalt_visibility(void *param, int columns, char **data, char **column) +static int cobalt_visibility(void *, int, char **, char **) { - UNUSED(param); - UNUSED(columns); - UNUSED(column); - UNUSED(data); return 0; } -static int cobalt_location(void *param, int columns, char **data, char **column) +static int cobalt_location(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); char **location = (char **)param; *location = data[0] ? strdup(data[0]) : NULL; return 0; } -static int cobalt_dive(void *param, int columns, char **data, char **column) +static int cobalt_dive(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); - int retval = 0; struct parser_state *state = (struct parser_state *)param; sqlite3 *handle = state->sql_handle; @@ -195,7 +180,7 @@ static int cobalt_dive(void *param, int columns, char **data, char **column) } if (location && location_site) { - char *tmp = malloc(strlen(location) + strlen(location_site) + 4); + char *tmp = (char *)malloc(strlen(location) + strlen(location_site) + 4); if (!tmp) { free(location); free(location_site); @@ -221,11 +206,8 @@ static int cobalt_dive(void *param, int columns, char **data, char **column) } -int parse_cobalt_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, struct divelog *log) +extern "C" int parse_cobalt_buffer(sqlite3 *handle, const char *url, const char *, int, struct divelog *log) { - UNUSED(buffer); - UNUSED(size); - int retval; struct parser_state state; diff --git a/core/import-csv.c b/core/import-csv.cpp similarity index 93% rename from core/import-csv.c rename to core/import-csv.cpp index 816084645..288587cec 100644 --- a/core/import-csv.c +++ b/core/import-csv.cpp @@ -123,16 +123,16 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str return report_error(translate("gettextFromC", "Failed to read '%s'"), filename); /* Determine NL (new line) character and the start of CSV data */ - if ((ptr = strstr(mem.buffer, "\r\n")) != NULL) { + if ((ptr = strstr((char *)mem.buffer, "\r\n")) != NULL) { NL = "\r\n"; - } else if ((ptr = strstr(mem.buffer, "\n")) != NULL) { + } else if ((ptr = strstr((char *)mem.buffer, "\n")) != NULL) { NL = "\n"; } else { fprintf(stderr, "DEBUG: failed to detect NL\n"); return -1; } - while ((end_ptr < mem.size) && (ptr = strstr(mem.buffer + end_ptr, "ZDH"))) { + while ((end_ptr < mem.size) && (ptr = strstr((char *)mem.buffer + end_ptr, "ZDH"))) { xml_params_resize(params, params_orig_size); // restart with original parameter block char *iter_end = NULL; @@ -234,7 +234,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str /* Copy the current dive data to start of mem_csv buffer */ memcpy(mem_csv.buffer, ptr, mem.size - (ptr - (char *)mem.buffer)); - ptr = strstr(mem_csv.buffer, "ZDP}"); + ptr = strstr((char *)mem_csv.buffer, "ZDP}"); if (ptr) { *ptr = 0; } else { @@ -265,7 +265,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str if (try_to_xslt_open_csv(filename, &mem_csv, "csv")) return -1; - ret |= parse_xml_buffer(filename, mem_csv.buffer, mem_csv.size, log, params); + ret |= parse_xml_buffer(filename, (char *)mem_csv.buffer, mem_csv.size, log, params); free(mem_csv.buffer); } @@ -275,7 +275,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str return ret; } -int parse_csv_file(const char *filename, struct xml_params *params, const char *csvtemplate, struct divelog *log) +extern "C" int parse_csv_file(const char *filename, struct xml_params *params, const char *csvtemplate, struct divelog *log) { int ret; struct memblock mem; @@ -327,7 +327,7 @@ int parse_csv_file(const char *filename, struct xml_params *params, const char * fprintf(stderr, "%s/xslt/%s -\n", SUBSURFACE_SOURCE, csvtemplate); } #endif - ret = parse_xml_buffer(filename, mem.buffer, mem.size, log, params); + ret = parse_xml_buffer(filename, (char *)mem.buffer, mem.size, log, params); free(mem.buffer); @@ -357,13 +357,13 @@ static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, cons * Tag markers take: strlen("<>") = 5 * Reserve also room for encoding ampersands "&" => "&" */ - buf = realloc(mem->buffer, mem->size + 7 + strlen(tag) * 2 + amp * 4); + buf = (char *)realloc((char *)mem->buffer, mem->size + 7 + strlen(tag) * 2 + amp * 4); if (buf != NULL) { char *starttag = NULL; char *endtag = NULL; - starttag = malloc(3 + strlen(tag)); - endtag = malloc(5 + strlen(tag)); + starttag = (char *)malloc(3 + strlen(tag)); + endtag = (char *)malloc(5 + strlen(tag)); if (starttag == NULL || endtag == NULL) { /* this is fairly silly - so the malloc fails, but we strdup the error? @@ -406,7 +406,7 @@ static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, cons int try_to_open_csv(struct memblock *mem, enum csv_format type, struct divelog *log) { - char *p = mem->buffer; + char *p = (char *)mem->buffer; char *header[8]; int i, time; timestamp_t date; @@ -458,7 +458,7 @@ int try_to_open_csv(struct memblock *mem, enum csv_format type, struct divelog * return 1; } -static char *parse_mkvi_value(const char *haystack, const char *needle) +static char *parse_mkvi_value(char *haystack, const char *needle) { char *lineptr, *valueptr, *endptr, *ret = NULL; @@ -481,7 +481,7 @@ static char *parse_mkvi_value(const char *haystack, const char *needle) return ret; } -static char *next_mkvi_key(const char *haystack) +static char *next_mkvi_key(char *haystack) { char *valueptr, *endptr, *ret = NULL; @@ -520,7 +520,7 @@ int parse_txt_file(const char *filename, const char *csv, struct divelog *log) struct divecomputer *dc; struct tm cur_tm; - value = parse_mkvi_value(memtxt.buffer, "Dive started at"); + value = parse_mkvi_value((char *)memtxt.buffer, "Dive started at"); if (sscanf(value, "%d-%d-%d %d:%d:%d", &y, &m, &d, &hh, &mm, &ss) != 6) { free(value); return -1; @@ -536,7 +536,7 @@ int parse_txt_file(const char *filename, const char *csv, struct divelog *log) dive = alloc_dive(); dive->when = utc_mktime(&cur_tm);; dive->dc.model = strdup("Poseidon MkVI Discovery"); - value = parse_mkvi_value(memtxt.buffer, "Rig Serial number"); + value = parse_mkvi_value((char *)memtxt.buffer, "Rig Serial number"); dive->dc.deviceid = atoi(value); free(value); dive->dc.divemode = CCR; @@ -556,16 +556,16 @@ int parse_txt_file(const char *filename, const char *csv, struct divelog *log) cyl.type.size.mliter = 3000; cyl.type.workingpressure.mbar = 200000; cyl.type.description = "3l Mk6"; - value = parse_mkvi_value(memtxt.buffer, "Helium percentage"); + value = parse_mkvi_value((char *)memtxt.buffer, "Helium percentage"); he = atoi(value); free(value); - value = parse_mkvi_value(memtxt.buffer, "Nitrogen percentage"); + value = parse_mkvi_value((char *)memtxt.buffer, "Nitrogen percentage"); cyl.gasmix.o2.permille = (100 - atoi(value) - he) * 10; free(value); cyl.gasmix.he.permille = he * 10; add_cloned_cylinder(&dive->cylinders, cyl); - lineptr = strstr(memtxt.buffer, "Dive started at"); + lineptr = strstr((char *)memtxt.buffer, "Dive started at"); while (!empty_string(lineptr) && (lineptr = strchr(lineptr, '\n'))) { ++lineptr; // Skip over '\n' key = next_mkvi_key(lineptr); @@ -603,7 +603,7 @@ int parse_txt_file(const char *filename, const char *csv, struct divelog *log) free_dive(dive); return report_error(translate("gettextFromC", "Poseidon import failed: unable to read '%s'"), csv); } - lineptr = memcsv.buffer; + lineptr = (char *)memcsv.buffer; for (;;) { struct sample *sample; int type; @@ -812,7 +812,7 @@ static int parse_seabear_csv_file(const char *filename, struct xml_params *param time_t now; struct tm *timep = NULL; char *ptr, *ptr_old = NULL; - char *NL = NULL; + const char *NL = NULL; char tmpbuf[MAXCOLDIGITS]; /* Increase the limits for recursion and variables on XSLT @@ -840,7 +840,7 @@ static int parse_seabear_csv_file(const char *filename, struct xml_params *param return report_error(translate("gettextFromC", "Failed to read '%s'"), filename); /* Determine NL (new line) character and the start of CSV data */ - ptr = mem.buffer; + ptr = (char *)mem.buffer; while ((ptr = strstr(ptr, "\r\n\r\n")) != NULL) { ptr_old = ptr; ptr += 1; @@ -848,7 +848,7 @@ static int parse_seabear_csv_file(const char *filename, struct xml_params *param } if (!ptr_old) { - ptr = mem.buffer; + ptr = (char *)mem.buffer; while ((ptr = strstr(ptr, "\n\n")) != NULL) { ptr_old = ptr; ptr += 1; @@ -872,7 +872,7 @@ static int parse_seabear_csv_file(const char *filename, struct xml_params *param * line and step through from there. That is the line after * Serial number. */ - ptr = strstr(mem.buffer, "Serial number:"); + ptr = strstr((char *)mem.buffer, "Serial number:"); if (ptr) ptr = strstr(ptr, NL); @@ -923,7 +923,7 @@ static int parse_seabear_csv_file(const char *filename, struct xml_params *param fprintf(stderr, "xslt/csv2xml.xslt\n"); } - ret = parse_xml_buffer(filename, mem.buffer, mem.size, log, params); + ret = parse_xml_buffer(filename, (char *)mem.buffer, mem.size, log, params); free(mem.buffer); return ret; @@ -965,7 +965,7 @@ int parse_manual_file(const char *filename, struct xml_params *params, struct di fprintf(stderr, "%s/xslt/manualcsv2xml.xslt -\n", SUBSURFACE_SOURCE); } #endif - ret = parse_xml_buffer(filename, mem.buffer, mem.size, log, params); + ret = parse_xml_buffer(filename, (char *)mem.buffer, mem.size, log, params); free(mem.buffer); return ret; diff --git a/core/import-divinglog.c b/core/import-divinglog.cpp similarity index 93% rename from core/import-divinglog.c rename to core/import-divinglog.cpp index 69b115f24..e146604f6 100644 --- a/core/import-divinglog.c +++ b/core/import-divinglog.cpp @@ -16,10 +16,8 @@ #include "membuffer.h" #include "gettext.h" -static int divinglog_cylinder(void *param, int columns, char **data, char **column) +static int divinglog_cylinder(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; cylinder_t *cyl; @@ -55,10 +53,8 @@ static int divinglog_cylinder(void *param, int columns, char **data, char **colu return 0; } -static int divinglog_profile(void *param, int columns, char **data, char **column) +static int divinglog_profile(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; int sinterval = 0; @@ -193,8 +189,7 @@ static int divinglog_profile(void *param, int columns, char **data, char **colum int ppo2_1 = atoi_n(ptr5 + 0, 3); int ppo2_2 = atoi_n(ptr5 + 3, 3); int ppo2_3 = atoi_n(ptr5 + 6, 3); - int otu = atoi_n(ptr5 + 9, 4); - UNUSED(otu); // we seem to not store this? Do we understand its format? + //int otu = atoi_n(ptr5 + 9, 4); // we seem to not store this? Do we understand its format? int cns = atoi_n(ptr5 + 13, 4); int setpoint = atoi_n(ptr5 + 17, 2); @@ -262,11 +257,8 @@ static int divinglog_profile(void *param, int columns, char **data, char **colum return 0; } -static int divinglog_dive(void *param, int columns, char **data, char **column) +static int divinglog_dive(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); - int retval = 0, diveid; struct parser_state *state = (struct parser_state *)param; sqlite3 *handle = state->sql_handle; @@ -306,7 +298,7 @@ static int divinglog_dive(void *param, int columns, char **data, char **column) state->cur_dive->watertemp.mkelvin = C_to_mkelvin(atol(data[9])); if (data[10]) { - weightsystem_t ws = { { atol(data[10]) * 1000 }, translate("gettextFromC", "unknown"), false }; + weightsystem_t ws = { { atoi(data[10]) * 1000 }, translate("gettextFromC", "unknown"), false }; add_cloned_weightsystem(&state->cur_dive->weightsystems, ws); } @@ -391,11 +383,8 @@ static int divinglog_dive(void *param, int columns, char **data, char **column) } -int parse_divinglog_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, struct divelog *log) +extern "C" int parse_divinglog_buffer(sqlite3 *handle, const char *url, const char *, int, struct divelog *log) { - UNUSED(buffer); - UNUSED(size); - int retval; struct parser_state state; diff --git a/core/import-seac.c b/core/import-seac.cpp similarity index 96% rename from core/import-seac.c rename to core/import-seac.cpp index 789215c63..4d0efd3dd 100644 --- a/core/import-seac.c +++ b/core/import-seac.cpp @@ -41,10 +41,8 @@ static int seac_gaschange(void *param, sqlite3_stmt *sqlstmt) /* Callback function to parse seac dives. Reads headers_dive table to read dive * information into divecomputer struct. */ -static int seac_dive(void *param, int columns, char **data, char **column) +static int seac_dive(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); int retval = 0, cylnum = 0; int year, month, day, hour, min, sec, tz; char isodatetime[30]; @@ -264,11 +262,8 @@ static int seac_dive(void *param, int columns, char **data, char **column) * The callback function performs another SQL query on the other * table, to read in the sample values. */ -int parse_seac_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, struct divelog *log) +extern "C" int parse_seac_buffer(sqlite3 *handle, const char *url, const char *, int, struct divelog *log) { - UNUSED(buffer); - UNUSED(size); - int retval; char *err = NULL; struct parser_state state; diff --git a/core/import-shearwater.c b/core/import-shearwater.cpp similarity index 93% rename from core/import-shearwater.c rename to core/import-shearwater.cpp index 13ee1ee55..0bf330444 100644 --- a/core/import-shearwater.c +++ b/core/import-shearwater.cpp @@ -17,10 +17,8 @@ #include -static int shearwater_cylinders(void *param, int columns, char **data, char **column) +static int shearwater_cylinders(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; cylinder_t *cyl; @@ -40,10 +38,8 @@ static int shearwater_cylinders(void *param, int columns, char **data, char **co return 0; } -static int shearwater_changes(void *param, int columns, char **data, char **column) +static int shearwater_changes(void *param, int columns, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; cylinder_t *cyl; @@ -83,10 +79,8 @@ static int shearwater_changes(void *param, int columns, char **data, char **colu return 0; } -static int shearwater_profile_sample(void *param, int columns, char **data, char **column) +static int shearwater_profile_sample(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; int d6, d7; @@ -146,10 +140,8 @@ static int shearwater_profile_sample(void *param, int columns, char **data, char return 0; } -static int shearwater_ai_profile_sample(void *param, int columns, char **data, char **column) +static int shearwater_ai_profile_sample(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; int d6, d9; @@ -217,10 +209,8 @@ static int shearwater_ai_profile_sample(void *param, int columns, char **data, c return 0; } -static int shearwater_mode(void *param, int columns, char **data, char **column) +static int shearwater_mode(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; if (data[0]) @@ -229,11 +219,8 @@ static int shearwater_mode(void *param, int columns, char **data, char **column) return 0; } -static int shearwater_dive(void *param, int columns, char **data, char **column) +static int shearwater_dive(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); - int retval = 0; struct parser_state *state = (struct parser_state *)param; sqlite3 *handle = state->sql_handle; @@ -348,11 +335,8 @@ static int shearwater_dive(void *param, int columns, char **data, char **column) return SQLITE_OK; } -static int shearwater_cloud_dive(void *param, int columns, char **data, char **column) +static int shearwater_cloud_dive(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); - int retval = 0; struct parser_state *state = (struct parser_state *)param; sqlite3 *handle = state->sql_handle; @@ -488,11 +472,8 @@ static int shearwater_cloud_dive(void *param, int columns, char **data, char **c return SQLITE_OK; } -int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, struct divelog *log) +extern "C" int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *, int, struct divelog *log) { - UNUSED(buffer); - UNUSED(size); - int retval; struct parser_state state; @@ -516,11 +497,8 @@ int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buffer return 0; } -int parse_shearwater_cloud_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, struct divelog *log) +extern "C" int parse_shearwater_cloud_buffer(sqlite3 *handle, const char *url, const char *, int, struct divelog *log) { - UNUSED(buffer); - UNUSED(size); - int retval; struct parser_state state; diff --git a/core/import-suunto.c b/core/import-suunto.cpp similarity index 92% rename from core/import-suunto.c rename to core/import-suunto.cpp index 3616be942..3d76888e8 100644 --- a/core/import-suunto.c +++ b/core/import-suunto.cpp @@ -18,10 +18,8 @@ #include -static int dm4_events(void *param, int columns, char **data, char **column) +static int dm4_events(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; event_start(state); @@ -151,10 +149,8 @@ static int dm4_events(void *param, int columns, char **data, char **column) return 0; } -static int dm4_tags(void *param, int columns, char **data, char **column) +static int dm4_tags(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; if (data[0]) @@ -163,10 +159,8 @@ static int dm4_tags(void *param, int columns, char **data, char **column) return 0; } -static int dm4_dive(void *param, int columns, char **data, char **column) +static int dm4_dive(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); int i; int interval, retval = 0; struct parser_state *state = (struct parser_state *)param; @@ -293,11 +287,8 @@ static int dm4_dive(void *param, int columns, char **data, char **column) return SQLITE_OK; } -int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, struct divelog *log) +extern "C" int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *, int, struct divelog *log) { - UNUSED(buffer); - UNUSED(size); - int retval; char *err = NULL; struct parser_state state; @@ -321,10 +312,8 @@ int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buffer, int s return 0; } -static int dm5_cylinders(void *param, int columns, char **data, char **column) +static int dm5_cylinders(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; cylinder_t *cyl; @@ -350,10 +339,8 @@ static int dm5_cylinders(void *param, int columns, char **data, char **column) return 0; } -static int dm5_gaschange(void *param, int columns, char **data, char **column) +static int dm5_gaschange(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); struct parser_state *state = (struct parser_state *)param; event_start(state); @@ -372,10 +359,8 @@ static int dm5_gaschange(void *param, int columns, char **data, char **column) return 0; } -static int dm5_dive(void *param, int columns, char **data, char **column) +static int dm5_dive(void *param, int, char **data, char **) { - UNUSED(columns); - UNUSED(column); int i; int tempformat = 0; int interval, retval = 0, block_size; @@ -429,16 +414,15 @@ static int dm5_dive(void *param, int columns, char **data, char **column) utf8_string(data[5], &state->cur_dive->dc.model); if (data[25]) { - //enum divemode_t {OC, CCR, PSCR, FREEDIVE, NUM_DIVEMODE, UNDEF_COMP_TYPE}; // Flags (Open-circuit and Closed-circuit-rebreather) for setting dive computer type switch(atoi(data[25])) { case 1: - state->cur_dive->dc.divemode = 0; + state->cur_dive->dc.divemode = OC; break; case 5: - state->cur_dive->dc.divemode = 1; + state->cur_dive->dc.divemode = CCR; break; default: - state->cur_dive->dc.divemode = 0; + state->cur_dive->dc.divemode = OC; break; } } @@ -575,11 +559,8 @@ static int dm5_dive(void *param, int columns, char **data, char **column) return SQLITE_OK; } -int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, struct divelog *log) +extern "C" int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *, int, struct divelog *log) { - UNUSED(buffer); - UNUSED(size); - int retval; char *err = NULL; struct parser_state state;