cleanup: replace fprintf to stderr by report_info()

Let's try to unify debugging output!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-03-24 21:03:08 +01:00 committed by bstoeger
parent b097c0a44f
commit da7ea17b66
29 changed files with 171 additions and 170 deletions

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "command_pictures.h"
#include "core/errorhelper.h"
#include "core/subsurface-qt/divelistnotifier.h"
#include "qt-models/divelocationmodel.h"
@ -24,7 +25,7 @@ void SetPictureOffset::redo()
{
picture *pic = dive_get_picture(d, filename);
if (!pic) {
fprintf(stderr, "SetPictureOffset::redo(): picture disappeared!\n");
report_info("SetPictureOffset::redo(): picture disappeared!");
return;
}
std::swap(pic->offset, offset);
@ -73,7 +74,7 @@ static std::vector<PictureListForAddition> removePictures(std::vector<PictureLis
for (const std::string &fn: list.filenames) {
int idx = get_picture_idx(&list.d->pictures, fn.c_str());
if (idx < 0) {
fprintf(stderr, "removePictures(): picture disappeared!\n");
report_info("removePictures(): picture disappeared!");
continue; // Huh? We made sure that this can't happen by filtering out non-existent pictures.
}
filenames.push_back(QString::fromStdString(fn));
@ -103,7 +104,7 @@ static std::vector<PictureListForDeletion> addPictures(std::vector<PictureListFo
for (const PictureObj &pic: list.pics) {
int idx = get_picture_idx(&list.d->pictures, pic.filename.c_str()); // This should *not* already exist!
if (idx >= 0) {
fprintf(stderr, "addPictures(): picture disappeared!\n");
report_info("addPictures(): picture disappeared!");
continue; // Huh? We made sure that this can't happen by filtering out existing pictures.
}
picsForSignal.push_back(pic);

View file

@ -35,7 +35,7 @@ CheckCloudConnection::CheckCloudConnection(QObject *parent) :
bool CheckCloudConnection::checkServer()
{
if (verbose)
fprintf(stderr, "Checking cloud connection...\n");
report_info("Checking cloud connection...");
QEventLoop loop;
QNetworkAccessManager *mgr = new QNetworkAccessManager();

View file

@ -658,7 +658,7 @@ extern "C" void update_setpoint_events(const struct dive *dive, struct divecompu
ev->value = new_setpoint;
} else {
if (!add_event(dc, 0, SAMPLE_EVENT_PO2, 0, new_setpoint, "SP change"))
fprintf(stderr, "Could not add setpoint change event\n");
report_info("Could not add setpoint change event");
}
}
@ -3063,7 +3063,7 @@ extern "C" struct dive *make_first_dc(const struct dive *d, int dc_number)
;
if (!dc) {
free(newdc);
fprintf(stderr, "data inconsistent: can't find the current DC");
report_info("data inconsistent: can't find the current DC");
return res;
}
dc->next = old_dc->next;
@ -3386,7 +3386,7 @@ extern "C" struct dive *get_dive_by_uniq_id(int id)
}
#ifdef DEBUG
if (dive == NULL) {
fprintf(stderr, "Invalid id %x passed to get_dive_by_diveid, try to fix the code\n", id);
report_info("Invalid id %x passed to get_dive_by_diveid, try to fix the code", id);
exit(1);
}
#endif
@ -3404,7 +3404,7 @@ extern "C" int get_idx_by_uniq_id(int id)
}
#ifdef DEBUG
if (dive == NULL) {
fprintf(stderr, "Invalid id %x passed to get_dive_by_diveid, try to fix the code\n", id);
report_info("Invalid id %x passed to get_dive_by_diveid, try to fix the code", id);
exit(1);
}
#endif

View file

@ -3,6 +3,7 @@
#include "divelist.h"
#include "divesite.h"
#include "device.h"
#include "errorhelper.h"
#include "filterpreset.h"
#include "trip.h"
@ -70,7 +71,7 @@ void divelog::clear()
while (sites->nr)
delete_dive_site(get_dive_site(0, sites), sites);
if (trips->nr != 0) {
fprintf(stderr, "Warning: trip table not empty in divelog::clear()!\n");
report_info("Warning: trip table not empty in divelog::clear()!");
trips->nr = 0;
}
clear_device_table(devices);

View file

@ -4,6 +4,7 @@
#include "dive.h"
#include "divelist.h"
#include "divelog.h"
#include "errorhelper.h"
#include "membuffer.h"
#include "subsurface-string.h"
#include "table.h"
@ -371,17 +372,17 @@ void add_dive_to_dive_site(struct dive *d, struct dive_site *ds)
{
int idx;
if (!d) {
fprintf(stderr, "Warning: add_dive_to_dive_site called with NULL dive\n");
report_info("Warning: add_dive_to_dive_site called with NULL dive");
return;
}
if (!ds) {
fprintf(stderr, "Warning: add_dive_to_dive_site called with NULL dive site\n");
report_info("Warning: add_dive_to_dive_site called with NULL dive site");
return;
}
if (d->dive_site == ds)
return;
if (d->dive_site) {
fprintf(stderr, "Warning: adding dive that already belongs to a dive site to a different site\n");
report_info("Warning: adding dive that already belongs to a dive site to a different site");
unregister_dive_from_dive_site(d);
}
idx = dive_table_get_insertion_index(&ds->dives, d);

View file

@ -16,6 +16,7 @@
#include "dive.h"
#include "divelist.h"
#include "divelog.h"
#include "errorhelper.h"
#include "pref.h"
#include "subsurface-string.h"
#include "table.h"
@ -460,7 +461,7 @@ cylinder_t *get_cylinder(const struct dive *d, int idx)
* in the table to mark no-cylinder surface interavals. This is horrendous. Fix ASAP. */
// if (idx < 0 || idx >= d->cylinders.nr) {
if (idx < 0 || idx >= d->cylinders.nr + 1 || idx >= d->cylinders.allocated) {
fprintf(stderr, "Warning: accessing invalid cylinder %d (%d existing)\n", idx, d->cylinders.nr);
report_info("Warning: accessing invalid cylinder %d (%d existing)", idx, d->cylinders.nr);
return NULL;
}
return &d->cylinders.cylinders[idx];
@ -469,7 +470,7 @@ cylinder_t *get_cylinder(const struct dive *d, int idx)
cylinder_t *get_or_create_cylinder(struct dive *d, int idx)
{
if (idx < 0) {
fprintf(stderr, "Warning: accessing invalid cylinder %d\n", idx);
report_info("Warning: accessing invalid cylinder %d", idx);
return NULL;
}
while (idx >= d->cylinders.nr)

View file

@ -125,7 +125,7 @@ static int try_to_open_db(const char *filename, std::string &mem, struct divelog
retval = sqlite3_open(filename, &handle);
if (retval) {
fprintf(stderr, "Database connection failed '%s'.\n", filename);
report_info("Database connection failed '%s'", filename);
return 1;
}
@ -258,7 +258,7 @@ bool remote_repo_uptodate(const char *filename, struct git_info *info)
if (is_git_repository(filename, info) && open_git_repository(info)) {
std::string sha = get_sha(info->repo, info->branch);
if (!sha.empty() && current_sha == sha) {
fprintf(stderr, "already have loaded SHA %s - don't load again\n", sha.c_str());
report_info("already have loaded SHA %s - don't load again", sha.c_str());
return true;
}
}
@ -314,7 +314,7 @@ extern "C" int parse_file(const char *filename, struct divelog *log)
std::string wl_name = std::string(filename, t - filename) + ".add";
auto [wl_mem, err] = readfile(wl_name.c_str());
if (err < 0) {
fprintf(stderr, "No file %s found. No WLog extensions.\n", wl_name.c_str());
report_info("No file %s found. No WLog extensions.", wl_name.c_str());
wl_mem.clear();
}
return datatrak_import(mem, wl_mem, log);

View file

@ -644,7 +644,7 @@ std::string filter_constraint_data_to_string(const filter_constraint *c)
void filter_constraint_set_stringlist(filter_constraint &c, const QString &s)
{
if (!filter_constraint_is_string(c.type)) {
fprintf(stderr, "Setting strings in non-string constraint!\n");
report_info("Setting strings in non-string constraint!");
return;
}
c.data.string_list->clear();
@ -655,7 +655,7 @@ void filter_constraint_set_stringlist(filter_constraint &c, const QString &s)
void filter_constraint_set_timestamp_from(filter_constraint &c, timestamp_t from)
{
if (!filter_constraint_is_timestamp(c.type)) {
fprintf(stderr, "Setting timestamp from in non-timestamp constraint!\n");
report_info("Setting timestamp from in non-timestamp constraint!");
return;
}
c.data.timestamp_range.from = from;
@ -664,7 +664,7 @@ void filter_constraint_set_timestamp_from(filter_constraint &c, timestamp_t from
void filter_constraint_set_timestamp_to(filter_constraint &c, timestamp_t to)
{
if (!filter_constraint_is_timestamp(c.type)) {
fprintf(stderr, "Setting timestamp to in non-timestamp constraint!\n");
report_info("Setting timestamp to in non-timestamp constraint!");
return;
}
c.data.timestamp_range.to = to;
@ -673,7 +673,7 @@ void filter_constraint_set_timestamp_to(filter_constraint &c, timestamp_t to)
void filter_constraint_set_integer_from(filter_constraint &c, int from)
{
if (!is_numerical_constraint(c.type)) {
fprintf(stderr, "Setting integer from of non-numerical constraint!\n");
report_info("Setting integer from of non-numerical constraint!");
return;
}
c.data.numerical_range.from = from;
@ -682,7 +682,7 @@ void filter_constraint_set_integer_from(filter_constraint &c, int from)
void filter_constraint_set_integer_to(filter_constraint &c, int to)
{
if (!is_numerical_constraint(c.type)) {
fprintf(stderr, "Setting integer to of non-numerical constraint!\n");
report_info("Setting integer to of non-numerical constraint!");
return;
}
c.data.numerical_range.to = to;
@ -691,7 +691,7 @@ void filter_constraint_set_integer_to(filter_constraint &c, int to)
void filter_constraint_set_float_from(filter_constraint &c, double from)
{
if (!is_numerical_constraint(c.type)) {
fprintf(stderr, "Setting float from of non-numerical constraint!\n");
report_info("Setting float from of non-numerical constraint!");
return;
}
c.data.numerical_range.from = display_to_base_unit(from, c.type);
@ -700,7 +700,7 @@ void filter_constraint_set_float_from(filter_constraint &c, double from)
void filter_constraint_set_float_to(filter_constraint &c, double to)
{
if (!is_numerical_constraint(c.type)) {
fprintf(stderr, "Setting float to of non-numerical constraint!\n");
report_info("Setting float to of non-numerical constraint!");
return;
}
c.data.numerical_range.to = display_to_base_unit(to, c.type);
@ -709,7 +709,7 @@ void filter_constraint_set_float_to(filter_constraint &c, double to)
void filter_constraint_set_multiple_choice(filter_constraint &c, uint64_t multiple_choice)
{
if (!filter_constraint_is_multiple_choice(c.type)) {
fprintf(stderr, "Setting multiple-choice to of non-multiple-choice constraint!\n");
report_info("Setting multiple-choice to of non-multiple-choice constraint!");
return;
}
c.data.multiple_choice = multiple_choice;
@ -718,7 +718,7 @@ void filter_constraint_set_multiple_choice(filter_constraint &c, uint64_t multip
QString filter_constraint_get_string(const filter_constraint &c)
{
if (!filter_constraint_is_string(c.type)) {
fprintf(stderr, "Getting string of non-string constraint!\n");
report_info("Getting string of non-string constraint!");
return QString();
}
return c.data.string_list->join(",");
@ -727,7 +727,7 @@ QString filter_constraint_get_string(const filter_constraint &c)
int filter_constraint_get_integer_from(const filter_constraint &c)
{
if (!is_numerical_constraint(c.type)) {
fprintf(stderr, "Getting integer from of non-numerical constraint!\n");
report_info("Getting integer from of non-numerical constraint!");
return -1;
}
return c.data.numerical_range.from;
@ -736,7 +736,7 @@ int filter_constraint_get_integer_from(const filter_constraint &c)
int filter_constraint_get_integer_to(const filter_constraint &c)
{
if (!is_numerical_constraint(c.type)) {
fprintf(stderr, "Getting integer to of non-numerical constraint!\n");
report_info("Getting integer to of non-numerical constraint!");
return -1;
}
return c.data.numerical_range.to;
@ -745,7 +745,7 @@ int filter_constraint_get_integer_to(const filter_constraint &c)
double filter_constraint_get_float_from(const filter_constraint &c)
{
if (!is_numerical_constraint(c.type)) {
fprintf(stderr, "Getting float from of non-numerical constraint!\n");
report_info("Getting float from of non-numerical constraint!");
return 0.0;
}
return base_to_display_unit(c.data.numerical_range.from, c.type);
@ -754,7 +754,7 @@ double filter_constraint_get_float_from(const filter_constraint &c)
double filter_constraint_get_float_to(const filter_constraint &c)
{
if (!is_numerical_constraint(c.type)) {
fprintf(stderr, "Getting float to of non-numerical constraint!\n");
report_info("Getting float to of non-numerical constraint!");
return 0.0;
}
return base_to_display_unit(c.data.numerical_range.to, c.type);
@ -763,7 +763,7 @@ double filter_constraint_get_float_to(const filter_constraint &c)
timestamp_t filter_constraint_get_timestamp_from(const filter_constraint &c)
{
if (!filter_constraint_is_timestamp(c.type)) {
fprintf(stderr, "Getting timestamp from of non-timestamp constraint!\n");
report_info("Getting timestamp from of non-timestamp constraint!");
return 0;
}
return c.data.timestamp_range.from;
@ -772,7 +772,7 @@ timestamp_t filter_constraint_get_timestamp_from(const filter_constraint &c)
timestamp_t filter_constraint_get_timestamp_to(const filter_constraint &c)
{
if (!filter_constraint_is_timestamp(c.type)) {
fprintf(stderr, "Getting timestamp to of non-timestamp constraint!\n");
report_info("Getting timestamp to of non-timestamp constraint!");
return 0;
}
return c.data.timestamp_range.to;
@ -781,7 +781,7 @@ timestamp_t filter_constraint_get_timestamp_to(const filter_constraint &c)
uint64_t filter_constraint_get_multiple_choice(const filter_constraint &c)
{
if (!filter_constraint_is_multiple_choice(c.type)) {
fprintf(stderr, "Getting multiple-choice of non-multiple choice constraint!\n");
report_info("Getting multiple-choice of non-multiple choice constraint!");
return 0;
}
return c.data.multiple_choice;

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "gas.h"
#include "pref.h"
#include "errorhelper.h"
#include "gettext.h"
#include <stdio.h>
#include <string.h>
@ -59,7 +60,7 @@ void sanitize_gasmix(struct gasmix *mix)
/* Sane mix? */
if (o2 <= 1000 && he <= 1000 && o2 + he <= 1000)
return;
fprintf(stderr, "Odd gasmix: %u O2 %u He\n", o2, he);
report_info("Odd gasmix: %u O2 %u He", o2, he);
memset(mix, 0, sizeof(*mix));
}

View file

@ -8,6 +8,7 @@
#include "ssrf.h"
#include "dive.h"
#include "divesite.h"
#include "errorhelper.h"
#include "gas.h"
#include "parse.h"
#include "sample.h"
@ -147,35 +148,35 @@ static int cobalt_dive(void *param, int, char **data, char **)
snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_buffer, &cobalt_cylinders, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query cobalt_cylinders failed.\n");
report_info("Database query cobalt_cylinders failed.");
return 1;
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_buddy_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_buffer, &cobalt_buddies, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query cobalt_buddies failed.\n");
report_info("Database query cobalt_buddies failed.");
return 1;
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_visibility_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_buffer, &cobalt_visibility, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query cobalt_visibility failed.\n");
report_info("Database query cobalt_visibility failed.");
return 1;
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_location_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_buffer, &cobalt_location, &location, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query cobalt_location failed.\n");
report_info("Database query cobalt_location failed.");
return 1;
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_site_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_buffer, &cobalt_location, &location_site, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query cobalt_location (site) failed.\n");
report_info("Database query cobalt_location (site) failed.");
return 1;
}
@ -196,7 +197,7 @@ static int cobalt_dive(void *param, int, char **data, char **)
snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_buffer, &cobalt_profile_sample, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query cobalt_profile_sample failed.\n");
report_info("Database query cobalt_profile_sample failed.");
return 1;
}
@ -219,7 +220,7 @@ extern "C" int parse_cobalt_buffer(sqlite3 *handle, const char *url, const char
retval = sqlite3_exec(handle, get_dives, &cobalt_dive, &state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "Database query failed '%s'.\n", url);
report_info("Database query failed '%s'.\n", url);
return 1;
}

View file

@ -10,6 +10,7 @@
#include "divelist.h"
#include "divelog.h"
#include "file.h"
#include "format.h"
#include "parse.h"
#include "sample.h"
#include "divelist.h"
@ -100,7 +101,7 @@ static char *parse_dan_new_line(char *buf, const char *NL)
if (iter) {
iter += strlen(NL);
} else {
fprintf(stderr, "DEBUG: No new line found\n");
report_info("DEBUG: No new line found");
return NULL;
}
return iter;
@ -128,7 +129,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str
} else if ((ptr = strstr(mem.data(), "\n")) != NULL) {
NL = "\n";
} else {
fprintf(stderr, "DEBUG: failed to detect NL\n");
report_info("DEBUG: failed to detect NL");
return -1;
}
@ -144,7 +145,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str
xml_params_add(params, "diveNro", tmpbuf);
}
//fprintf(stderr, "DEBUG: BEGIN end_ptr %d round %d <%s>\n", end_ptr, j++, ptr);
//report_info("DEBUG: BEGIN end_ptr %d round %d <%s>", end_ptr, j++, ptr);
iter = ptr + 1;
for (i = 0; i <= 4 && iter; ++i) {
iter = strchr(iter, '|');
@ -153,7 +154,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str
}
if (!iter) {
fprintf(stderr, "DEBUG: Data corrupt");
report_info("DEBUG: Data corrupt");
return -1;
}
@ -214,7 +215,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str
/* After ZDH we should get either ZDT (above) or ZDP */
if (strncmp(iter, "ZDP{", 4) != 0) {
fprintf(stderr, "DEBUG: Input appears to violate DL7 specification\n");
report_info("DEBUG: Input appears to violate DL7 specification");
end_ptr = iter - mem.data();
continue;
}
@ -236,7 +237,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str
if (ptr) {
*ptr = 0;
} else {
fprintf(stderr, "DEBUG: failed to find end ZDP\n");
report_info("DEBUG: failed to find end ZDP");
return -1;
}
mem_csv.resize(ptr - mem_csv.data());
@ -313,10 +314,11 @@ extern "C" int parse_csv_file(const char *filename, struct xml_params *params, c
#ifndef SUBSURFACE_MOBILE
if (verbose >= 2) {
fprintf(stderr, "(echo '<csv>'; cat %s;echo '</csv>') | xsltproc ", filename);
std::string info = format_string_std("(echo '<csv>'; cat %s;echo '</csv>') | xsltproc ", filename);
for (int i = 0; i < xml_params_count(params); i++)
fprintf(stderr, "--stringparam %s %s ", xml_params_get_key(params, i), xml_params_get_value(params, i));
fprintf(stderr, "%s/xslt/%s -\n", SUBSURFACE_SOURCE, csvtemplate);
info += format_string_std("--stringparam %s %s ", xml_params_get_key(params, i), xml_params_get_value(params, i));
info += format_string_std("%s/xslt/%s -", SUBSURFACE_SOURCE, csvtemplate);
report_info("%s", info.c_str());
}
#endif
ret = parse_xml_buffer(filename, mem.data(), mem.size(), log, params);
@ -385,8 +387,11 @@ static int try_to_xslt_open_csv(const char *filename, std::string &mem, const ch
memcpy(ptr_out, tag, tag_name_size);
*--ptr_out = '<';
// On Windows, ptrdiff_t is long long int, on Linux it is long int.
// Windows doesn't support the ptrdiff_t format specifier "%td", so
// let's cast to long int.
if (ptr_out != mem.data())
fprintf(stderr, "try_to_xslt_open_csv(): ptr_out off by %ld. This shouldn't happen\n", ptr_out - mem.data());
report_info("try_to_xslt_open_csv(): ptr_out off by %ld. This shouldn't happen", static_cast<long int>(ptr_out - mem.data()));
return 0;
}
@ -719,7 +724,7 @@ int parse_txt_file(const char *filename, const char *csv, struct divelog *log)
case EOF:
break;
default:
printf("Unable to parse input: %s\n", lineptr);
report_info("Unable to parse input: %s\n", lineptr);
break;
}
@ -886,10 +891,11 @@ static int parse_seabear_csv_file(const char *filename, struct xml_params *param
*/
if (verbose >= 2) {
fprintf(stderr, "xsltproc ");
std::string info = "xsltproc ";
for (i = 0; i < xml_params_count(params); i++)
fprintf(stderr, "--stringparam %s %s ", xml_params_get_key(params, i), xml_params_get_value(params, i));
fprintf(stderr, "xslt/csv2xml.xslt\n");
info += format_string_std("--stringparam %s %s ", xml_params_get_key(params, i), xml_params_get_value(params, i));
info += "xslt/csv2xml.xslt";
report_info("%s", info.c_str());
}
ret = parse_xml_buffer(filename, mem.data(), mem.size(), log, params);
@ -926,10 +932,11 @@ int parse_manual_file(const char *filename, struct xml_params *params, struct di
#ifndef SUBSURFACE_MOBILE
if (verbose >= 2) {
fprintf(stderr, "(echo '<manualCSV>'; cat %s;echo '</manualCSV>') | xsltproc ", filename);
std::string info = format_string_std("(echo '<manualCSV>'; cat %s;echo '</manualCSV>') | xsltproc ", filename);
for (int i = 0; i < xml_params_count(params); i++)
fprintf(stderr, "--stringparam %s %s ", xml_params_get_key(params, i), xml_params_get_value(params, i));
fprintf(stderr, "%s/xslt/manualcsv2xml.xslt -\n", SUBSURFACE_SOURCE);
info += format_string_std("--stringparam %s %s ", xml_params_get_key(params, i), xml_params_get_value(params, i));
info += format_string_std("%s/xslt/manualcsv2xml.xslt -", SUBSURFACE_SOURCE);
report_info("%s", info.c_str());
}
#endif
ret = parse_xml_buffer(filename, mem.data(), mem.size(), log, params);

View file

@ -13,6 +13,7 @@
#include "divelist.h"
#include "divelog.h"
#include "device.h"
#include "errorhelper.h"
#include "membuffer.h"
#include "gettext.h"
@ -336,14 +337,14 @@ static int divinglog_dive(void *param, int, char **data, char **)
snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder0_template, diveid);
retval = sqlite3_exec(handle, get_buffer, &divinglog_cylinder, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query divinglog_cylinder0 failed.\n");
report_info("Database query divinglog_cylinder0 failed.");
return 1;
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder_template, diveid);
retval = sqlite3_exec(handle, get_buffer, &divinglog_cylinder, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query divinglog_cylinder failed.\n");
report_info("Database query divinglog_cylinder failed.");
return 1;
}
@ -373,7 +374,7 @@ static int divinglog_dive(void *param, int, char **data, char **)
snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template, diveid);
retval = sqlite3_exec(handle, get_buffer, &divinglog_profile, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query divinglog_profile failed.\n");
report_info("Database query divinglog_profile failed.");
return 1;
}
@ -396,7 +397,7 @@ extern "C" int parse_divinglog_buffer(sqlite3 *handle, const char *url, const ch
retval = sqlite3_exec(handle, get_dives, &divinglog_dive, &state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "Database query failed '%s'.\n", url);
report_info("Database query failed '%s'.", url);
return 1;
}

View file

@ -143,7 +143,7 @@ static int seac_dive(void *param, int, char **data, char **)
break;
default:
if (verbose) {
fprintf(stderr, "Unknown divetype %i", atoi(data[6]));
report_info("Unknown divetype %i", atoi(data[6]));
}
}
}
@ -174,7 +174,7 @@ static int seac_dive(void *param, int, char **data, char **)
break;
default:
if (verbose) {
fprintf(stderr, "Unknown salinity %i", atoi(data[8]));
report_info("Unknown salinity %i", atoi(data[8]));
}
}
}
@ -187,7 +187,7 @@ static int seac_dive(void *param, int, char **data, char **)
// Create sql_stmt type to query DB
retval = sqlite3_prepare_v2(handle, get_samples, -1, &sqlstmt, 0);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Preparing SQL object failed when getting SeacSync dives.\n");
report_info("Preparing SQL object failed when getting SeacSync dives.");
return 1;
}
@ -198,7 +198,7 @@ static int seac_dive(void *param, int, char **data, char **)
// Catch a bad query
retval = sqlite3_step(sqlstmt);
if (retval == SQLITE_ERROR) {
fprintf(stderr, "%s", "Getting dive data from SeacSync DB failed.\n");
report_info("Getting dive data from SeacSync DB failed.");
return 1;
}
@ -293,7 +293,7 @@ extern "C" int parse_seac_buffer(sqlite3 *handle, const char *url, const char *,
retval = sqlite3_exec(handle, get_dives, &seac_dive, &state, &err);
if (retval != SQLITE_OK) {
fprintf(stderr, "Database query failed '%s'.\n", url);
report_info("Database query failed '%s'.", url);
return 1;
}

View file

@ -12,6 +12,7 @@
#include "divelist.h"
#include "divelog.h"
#include "device.h"
#include "errorhelper.h"
#include "membuffer.h"
#include "gettext.h"
@ -300,7 +301,7 @@ static int shearwater_dive(void *param, int, char **data, char **)
snprintf(get_buffer, sizeof(get_buffer) - 1, get_mode_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_mode, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_mode failed.\n");
report_info("Database query shearwater_mode failed.");
return 1;
}
}
@ -308,14 +309,14 @@ static int shearwater_dive(void *param, int, char **data, char **)
snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_cylinders, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_cylinders failed.\n");
report_info("Database query shearwater_cylinders failed.");
return 1;
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_changes_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_changes, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_changes failed.\n");
report_info("Database query shearwater_changes failed.");
return 1;
}
@ -325,7 +326,7 @@ static int shearwater_dive(void *param, int, char **data, char **)
snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_profile_sample, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_profile_sample failed.\n");
report_info("Database query shearwater_profile_sample failed.");
return 1;
}
}
@ -430,7 +431,7 @@ static int shearwater_cloud_dive(void *param, int, char **data, char **)
snprintf(get_buffer, sizeof(get_buffer) - 1, get_mode_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_mode, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_mode failed.\n");
report_info("Database query shearwater_mode failed.");
return 1;
}
}
@ -438,21 +439,21 @@ static int shearwater_cloud_dive(void *param, int, char **data, char **)
snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_cylinders, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_cylinders failed.\n");
report_info("Database query shearwater_cylinders failed.");
return 1;
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_first_gas_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_changes, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_changes failed.\n");
report_info("Database query shearwater_changes failed.");
return 1;
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_changes_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_changes, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_changes failed.\n");
report_info("Database query shearwater_changes failed.");
return 1;
}
@ -462,7 +463,7 @@ static int shearwater_cloud_dive(void *param, int, char **data, char **)
snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template, dive_id, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_profile_sample, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_profile_sample failed.\n");
report_info("Database query shearwater_profile_sample failed.");
return 1;
}
}
@ -488,7 +489,7 @@ extern "C" int parse_shearwater_buffer(sqlite3 *handle, const char *url, const c
retval = sqlite3_exec(handle, get_dives, &shearwater_dive, &state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "Database query failed '%s'.\n", url);
report_info("Database query failed '%s'.", url);
return 1;
}
@ -508,7 +509,7 @@ extern "C" int parse_shearwater_cloud_buffer(sqlite3 *handle, const char *url, c
retval = sqlite3_exec(handle, get_dives, &shearwater_cloud_dive, &state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "Database query failed '%s'.\n", url);
report_info("Database query failed '%s'.", url);
return 1;
}

View file

@ -12,6 +12,7 @@
#include "divelist.h"
#include "divelog.h"
#include "device.h"
#include "errorhelper.h"
#include "membuffer.h"
#include "gettext.h"
#include "tag.h"
@ -260,30 +261,19 @@ static int dm4_dive(void *param, int, char **data, char **)
snprintf(get_events, sizeof(get_events) - 1, get_events_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm4_events, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query dm4_events failed.\n");
report_info("Database query dm4_events failed.");
return 1;
}
snprintf(get_events, sizeof(get_events) - 1, get_tags_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm4_tags, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query dm4_tags failed.\n");
report_info("Database query dm4_tags failed.");
return 1;
}
dive_end(state);
/*
for (i=0; i<columns;++i) {
fprintf(stderr, "%s\t", column[i]);
}
fprintf(stderr, "\n");
for (i=0; i<columns;++i) {
fprintf(stderr, "%s\t", data[i]);
}
fprintf(stderr, "\n");
//exit(0);
*/
return SQLITE_OK;
}
@ -303,7 +293,7 @@ extern "C" int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *,
retval = sqlite3_exec(handle, get_dives, &dm4_dive, &state, &err);
if (retval != SQLITE_OK) {
fprintf(stderr, "Database query failed '%s'.\n", url);
report_info("Database query failed '%s'.", url);
return 1;
}
@ -430,7 +420,7 @@ static int dm5_dive(void *param, int, char **data, char **)
snprintf(get_events, sizeof(get_events) - 1, get_cylinders_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm5_cylinders, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query dm5_cylinders failed.\n");
report_info("Database query dm5_cylinders failed.");
return 1;
}
@ -536,21 +526,21 @@ static int dm5_dive(void *param, int, char **data, char **)
snprintf(get_events, sizeof(get_events) - 1, get_gaschange_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm5_gaschange, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query dm5_gaschange failed.\n");
report_info("Database query dm5_gaschange failed.");
return 1;
}
snprintf(get_events, sizeof(get_events) - 1, get_events_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm4_events, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query dm4_events failed.\n");
report_info("Database query dm4_events failed.");
return 1;
}
snprintf(get_events, sizeof(get_events) - 1, get_tags_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm4_tags, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query dm4_tags failed.\n");
report_info("Database query dm4_tags failed.");
return 1;
}
@ -575,7 +565,7 @@ extern "C" int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *,
retval = sqlite3_exec(handle, get_dives, &dm5_dive, &state, &err);
if (retval != SQLITE_OK) {
fprintf(stderr, "Database query failed '%s'.\n", url);
report_info("Database query failed '%s'.", url);
return 1;
}

View file

@ -51,15 +51,8 @@ static int stoptime, stopdepth, ndl, po2, cns, heartbeat, bearing;
static bool in_deco, first_temp_is_air;
static int current_gas_index;
/* logging bits from libdivecomputer */
#ifndef __ANDROID__
#define INFO(context, fmt, ...) fprintf(stderr, "INFO: " fmt "\n", ##__VA_ARGS__)
#define ERROR(context, fmt, ...) fprintf(stderr, "ERROR: " fmt "\n", ##__VA_ARGS__)
#else
#include <android/log.h>
#define INFO(context, fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, __FILE__, "INFO: " fmt "\n", ##__VA_ARGS__)
#define ERROR(context, fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, __FILE__, "ERROR: " fmt "\n", ##__VA_ARGS__)
#endif
#define INFO(context, fmt, ...) report_info("INFO: " fmt, ##__VA_ARGS__)
#define ERROR(context, fmt, ...) report_info("ERROR: " fmt, ##__VA_ARGS__)
/*
* Directly taken from libdivecomputer's examples/common.c to improve
@ -504,7 +497,7 @@ static void dev_info(device_data_t *, const char *fmt, ...)
va_end(ap);
progress_bar_text = buffer;
if (verbose)
INFO(0, "dev_info: %s\n", buffer);
INFO(0, "dev_info: %s", buffer);
if (progress_callback)
(*progress_callback)(buffer);
@ -1099,14 +1092,14 @@ static void event_cb(dc_device_t *device, dc_event_type_t event, const void *dat
if (dc_descriptor_get_model(devdata->descriptor) != devinfo->model) {
dc_descriptor_t *better_descriptor = get_descriptor(dc_descriptor_get_type(devdata->descriptor), devinfo->model);
if (better_descriptor != NULL) {
fprintf(stderr, "EVENT_DEVINFO gave us a different detected product (model %d instead of %d), which we are using now.\n",
report_info("EVENT_DEVINFO gave us a different detected product (model %d instead of %d), which we are using now.",
devinfo->model, dc_descriptor_get_model(devdata->descriptor));
devdata->descriptor = better_descriptor;
devdata->product = dc_descriptor_get_product(better_descriptor);
devdata->vendor = dc_descriptor_get_vendor(better_descriptor);
devdata->model = str_printf("%s %s", devdata->vendor, devdata->product);
} else {
fprintf(stderr, "EVENT_DEVINFO gave us a different detected product (model %d instead of %d), but that one is unknown.\n",
report_info("EVENT_DEVINFO gave us a different detected product (model %d instead of %d), but that one is unknown.",
devinfo->model, dc_descriptor_get_model(devdata->descriptor));
}
}
@ -1288,7 +1281,7 @@ static dc_status_t usbhid_device_open(dc_iostream_t **iostream, dc_context_t *co
dc_iterator_free (iterator);
if (!device) {
ERROR(context, "didn't find HID device\n");
ERROR(context, "didn't find HID device");
return DC_STATUS_NODEVICE;
}
dev_info(data, "Opening USB HID device for %04x:%04x",
@ -1639,7 +1632,7 @@ dc_descriptor_t *get_descriptor(dc_family_t type, unsigned int model)
rc = dc_descriptor_iterator(&iterator);
if (rc != DC_STATUS_SUCCESS) {
fprintf(stderr, "Error creating the device descriptor iterator.\n");
report_info("Error creating the device descriptor iterator.");
return NULL;
}
while ((dc_iterator_next(iterator, &descriptor)) == DC_STATUS_SUCCESS) {

View file

@ -6,6 +6,7 @@
#include "divesite.h"
#include "dive.h"
#include "divelog.h"
#include "errorhelper.h"
#include "file.h"
#include "sample.h"
#include "strndup.h"
@ -279,11 +280,11 @@ static void parse_dives(int log_version, const unsigned char *buf, unsigned int
}
if (sample_count == 0) {
fprintf(stderr, "DEBUG: sample count 0 - terminating parser\n");
report_info("DEBUG: sample count 0 - terminating parser");
break;
}
if (ptr + sample_count * 4 + 4 > buf_size) {
fprintf(stderr, "DEBUG: BOF - terminating parser\n");
report_info("DEBUG: BOF - terminating parser");
break;
}
// we aren't using the start_cns, dive_mode, and algorithm, yet

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "core/parse-gpx.h"
#include "core/errorhelper.h"
#include "core/subsurface-time.h"
#include "core/namecmp.h"
#include <QFile>
@ -25,7 +26,7 @@ int getCoordsFromGPXFile(struct dive_coords *coords, const QString &fileName)
if (!gpxFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
QByteArray local8bitBAString1 = fileName.toLocal8Bit();
char *fname = local8bitBAString1.data(); // convert QString to a C string fileName
fprintf(stderr, "GPS file open error: file name = %s\n", fname);
report_info("GPS file open error: file name = %s", fname);
return 1;
}
@ -76,7 +77,7 @@ int getCoordsFromGPXFile(struct dive_coords *coords, const QString &fileName)
#ifdef GPSDEBUG
utc_mkdate(trkpt_time, &time); // print coordinates and time of each trkpt element of the GPX file as well as dive start time
fprintf(stderr, " %02d: lat=%f lon=%f timestamp=%ld (%ld) %02d/%02d/%02d %02d:%02d dt=%ld %02d/%02d/%02d %02d:%02d\n", line, lat,
report_info(" %02d: lat=%f lon=%f timestamp=%ld (%ld) %02d/%02d/%02d %02d:%02d dt=%ld %02d/%02d/%02d %02d:%02d", line, lat,
lon, trkpt_time, time_offset, time.tm_year, time.tm_mon+1, time.tm_mday, time.tm_hour, time.tm_min, divetime, dyr, dmon+1, dday,dhr, dmin);
#endif

View file

@ -56,7 +56,7 @@ static void divedate(const char *buffer, timestamp_t *when, struct parser_state
} else if (sscanf(buffer, "%d-%d-%d %d:%d:%d", &y, &m, &d, &hh, &mm, &ss) >= 3) {
/* This is also ok */
} else {
fprintf(stderr, "Unable to parse date '%s'\n", buffer);
report_info("Unable to parse date '%s'", buffer);
return;
}
state->cur_tm.tm_year = y;
@ -166,7 +166,7 @@ static enum number_type parse_float(const char *buffer, double *res, const char
* as this is likely indication of a bug - but right now we don't have
* that information available */
if (first_time) {
fprintf(stderr, "Floating point value with decimal comma (%s)?\n", buffer);
report_info("Floating point value with decimal comma (%s)?", buffer);
first_time = false;
}
/* Try again in permissive mode*/
@ -218,7 +218,7 @@ static void pressure(const char *buffer, pressure_t *pressure, struct parser_sta
}
/* fallthrough */
default:
printf("Strange pressure reading %s\n", buffer);
report_info("Strange pressure reading %s", buffer);
}
}
@ -253,7 +253,7 @@ static void salinity(const char *buffer, int *salinity)
*salinity = lrint(val.fp * 10.0);
break;
default:
printf("Strange salinity reading %s\n", buffer);
report_info("Strange salinity reading %s", buffer);
}
}
@ -273,7 +273,7 @@ static void depth(const char *buffer, depth_t *depth, struct parser_state *state
}
break;
default:
printf("Strange depth reading %s\n", buffer);
report_info("Strange depth reading %s", buffer);
}
}
@ -306,7 +306,7 @@ static void weight(const char *buffer, weight_t *weight, struct parser_state *st
}
break;
default:
printf("Strange weight reading %s\n", buffer);
report_info("Strange weight reading %s", buffer);
}
}
@ -329,7 +329,7 @@ static void temperature(const char *buffer, temperature_t *temperature, struct p
}
break;
default:
printf("Strange temperature reading %s\n", buffer);
report_info("Strange temperature reading %s", buffer);
}
/* temperatures outside -40C .. +70C should be ignored */
if (temperature->mkelvin < ZERO_C_IN_MKELVIN - 40000 ||
@ -358,7 +358,7 @@ static void sampletime(const char *buffer, duration_t *time)
break;
default:
time->seconds = 0;
printf("Strange sample time reading %s\n", buffer);
report_info("Strange sample time reading %s", buffer);
}
}
@ -412,7 +412,7 @@ static void percent(const char *buffer, fraction_t *fraction)
break;
}
default:
printf(translate("gettextFromC", "Strange percentage reading %s\n"), buffer);
report_info(translate("gettextFromC", "Strange percentage reading %s"), buffer);
break;
}
}
@ -440,7 +440,7 @@ static void cylindersize(const char *buffer, volume_t *volume)
break;
default:
printf("Strange volume reading %s\n", buffer);
report_info("Strange volume reading %s", buffer);
break;
}
}
@ -620,7 +620,7 @@ static void fahrenheit(const char *buffer, temperature_t *temperature)
temperature->mkelvin = F_to_mkelvin(val.fp);
break;
default:
fprintf(stderr, "Crazy Diving Log temperature reading %s\n", buffer);
report_info("Crazy Diving Log temperature reading %s", buffer);
}
}
@ -656,7 +656,7 @@ static void psi_or_bar(const char *buffer, pressure_t *pressure)
pressure->mbar = lrint(val.fp * 1000);
break;
default:
fprintf(stderr, "Crazy Diving Log PSI reading %s\n", buffer);
report_info("Crazy Diving Log PSI reading %s", buffer);
}
}
@ -1069,7 +1069,7 @@ static void uddf_datetime(const char *buffer, timestamp_t *when, struct parser_s
if (i == 6)
goto success;
bad_date:
printf("Bad date time %s\n", buffer);
report_info("Bad date time %s", buffer);
return;
success:
@ -1169,7 +1169,7 @@ static void gps_lat(const char *buffer, struct dive *dive, struct parser_state *
add_dive_to_dive_site(dive, create_dive_site_with_gps(NULL, &location, state->log->sites));
} else {
if (ds->location.lat.udeg && ds->location.lat.udeg != location.lat.udeg)
fprintf(stderr, "Oops, changing the latitude of existing dive site id %8x name %s; not good\n", ds->uuid, ds->name ?: "(unknown)");
report_info("Oops, changing the latitude of existing dive site id %8x name %s; not good", ds->uuid, ds->name ?: "(unknown)");
ds->location.lat = location.lat;
}
}
@ -1185,7 +1185,7 @@ static void gps_long(const char *buffer, struct dive *dive, struct parser_state
add_dive_to_dive_site(dive, create_dive_site_with_gps(NULL, &location, state->log->sites));
} else {
if (ds->location.lon.udeg && ds->location.lon.udeg != location.lon.udeg)
fprintf(stderr, "Oops, changing the longitude of existing dive site id %8x name %s; not good\n", ds->uuid, ds->name ?: "(unknown)");
report_info("Oops, changing the longitude of existing dive site id %8x name %s; not good", ds->uuid, ds->name ?: "(unknown)");
ds->location.lon = location.lon;
}
}
@ -1226,7 +1226,7 @@ static void gps_in_dive(const char *buffer, struct dive *dive, struct parser_sta
if (dive_site_has_gps_location(ds) &&
has_location(&location) && !same_location(&ds->location, &location)) {
// Houston, we have a problem
fprintf(stderr, "dive site uuid in dive, but gps location (%10.6f/%10.6f) different from dive location (%10.6f/%10.6f)\n",
report_info("dive site uuid in dive, but gps location (%10.6f/%10.6f) different from dive location (%10.6f/%10.6f)",
ds->location.lat.udeg / 1000000.0, ds->location.lon.udeg / 1000000.0,
location.lat.udeg / 1000000.0, location.lon.udeg / 1000000.0);
std::string coords = printGPSCoordsC(&location);
@ -2219,11 +2219,11 @@ extern "C" int parse_dlf_buffer(unsigned char *buffer, size_t size, struct divel
break;
case 2:
/* Measure He */
//printf("%ds he2 cells(0.01 mV): %d %d\n", time, (ptr[5] << 8) + ptr[4], (ptr[9] << 8) + ptr[8]);
//report_info("%ds he2 cells(0.01 mV): %d %d", time, (ptr[5] << 8) + ptr[4], (ptr[9] << 8) + ptr[8]);
break;
case 3:
/* Measure Oxygen */
//printf("%d s: o2 cells(0.01 mV): %d %d %d %d\n", time, (ptr[5] << 8) + ptr[4], (ptr[7] << 8) + ptr[6], (ptr[9] << 8) + ptr[8], (ptr[11] << 8) + ptr[10]);
//report_info("%d s: o2 cells(0.01 mV): %d %d %d %d", time, (ptr[5] << 8) + ptr[4], (ptr[7] << 8) + ptr[6], (ptr[9] << 8) + ptr[8], (ptr[11] << 8) + ptr[10]);
// [Pa/mV] coeficient O2
// 100 Pa == 1 mbar
sample_start(&state);

View file

@ -11,6 +11,7 @@
#include "dive.h"
#include "divelist.h"
#include "errorhelper.h"
#include "event.h"
#include "interpolate.h"
#include "sample.h"
@ -208,7 +209,7 @@ extern "C" int get_cylinder_index(const struct dive *dive, const struct event *e
* We now match up gas change events with their cylinders at dive
* event fixup time.
*/
report_info("Still looking up cylinder based on gas mix in get_cylinder_index()!\n");
report_info("Still looking up cylinder based on gas mix in get_cylinder_index()!");
mix = get_gasmix_from_event(dive, ev);
best = find_best_gasmix_match(mix, &dive->cylinders);
@ -771,7 +772,7 @@ static void setup_gas_sensor_pressure(const struct dive *dive, const struct dive
if (cyl < 0)
continue; // unknown cylinder
if (cyl >= num_cyl) {
fprintf(stderr, "setup_gas_sensor_pressure(): invalid cylinder idx %d\n", cyl);
report_info("setup_gas_sensor_pressure(): invalid cylinder idx %d", cyl);
continue;
}
@ -965,7 +966,7 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
entry->ambpressure = depth_to_bar(entry->depth, dive);
entry->gfline = get_gf(ds, entry->ambpressure, dive) * (100.0 - AMB_PERCENTAGE) + AMB_PERCENTAGE;
if (t0 > t1) {
report_info("non-monotonous dive stamps %d %d\n", t0, t1);
report_info("non-monotonous dive stamps %d %d", t0, t1);
int xchg = t1;
t1 = t0;
t0 = xchg;

View file

@ -865,7 +865,7 @@ static int export_dives_xslt_doit(const char *filename, struct xml_params *param
int res = 0;
if (verbose)
fprintf(stderr, "export_dives_xslt with stylesheet %s\n", export_xslt);
report_info("export_dives_xslt with stylesheet %s", export_xslt);
if (!filename)
return report_error("No filename for export");

View file

@ -4,6 +4,7 @@
#include "selection.h"
#include "divelist.h"
#include "divelog.h"
#include "errorhelper.h"
#include "trip.h"
#include "subsurface-qt/divelistnotifier.h"
@ -318,6 +319,6 @@ extern "C" struct dive_trip *single_selected_trip()
if (divelog.trips->trips[i]->selected)
return divelog.trips->trips[i];
}
fprintf(stderr, "warning: found no selected trip even though one should be selected\n");
report_info("warning: found no selected trip even though one should be selected");
return NULL; // shouldn't happen
}

View file

@ -37,14 +37,9 @@
#include <time.h> // nanosleep
#endif
#ifndef __ANDROID__
#define INFO(context, fmt, ...) fprintf(stderr, "INFO: " fmt "\n", ##__VA_ARGS__)
#define ERROR(context, fmt, ...) fprintf(stderr, "ERROR: " fmt "\n", ##__VA_ARGS__)
#else
#include <android/log.h>
#define INFO(context, fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, __FILE__, "INFO: " fmt "\n", ##__VA_ARGS__)
#define ERROR(context, fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, __FILE__, "ERROR: " fmt "\n", ##__VA_ARGS__)
#endif
#include "errorhelper.h"
#define INFO(context, fmt, ...) report_info(stderr, "INFO: " fmt, ##__VA_ARGS__)
#define ERROR(context, fmt, ...) report_info(stderr, "ERROR: " fmt, ##__VA_ARGS__)
//#define SYSERROR(context, errcode) ERROR(__FILE__ ":" __LINE__ ": %s", strerror(errcode))
#define SYSERROR(context, errcode) ;
@ -161,7 +156,7 @@ static int serial_ftdi_open_device (struct ftdi_context *ftdi_ctx)
for (i = 0; i < num_accepted_pids; i++) {
pid = accepted_pids[i];
ret = ftdi_usb_open (ftdi_ctx, VID, pid);
INFO(0, "FTDI tried VID %04x pid %04x ret %d\n", VID, pid, ret);
INFO(0, "FTDI tried VID %04x pid %04x ret %d", VID, pid, ret);
if (ret == -3) // Device not found
continue;
else
@ -257,7 +252,7 @@ static dc_status_t serial_ftdi_close (void *io)
int ret = ftdi_usb_close(device->ftdi_ctx);
if (ret < 0) {
ERROR (device->context, "Unable to close the ftdi device : %d (%s)\n",
ERROR (device->context, "Unable to close the ftdi device : %d (%s)",
ret, ftdi_get_error_string(device->ftdi_ctx));
return ret;
}

View file

@ -232,7 +232,7 @@ static void uemis_info(const char *fmt, ...)
va_end(ap);
progress_bar_text = buffer;
if (verbose)
fprintf(stderr, "Uemis downloader: %s\n", buffer);
report_info("Uemis downloader: %s", buffer);
}
static long bytes_available(int file)
@ -643,7 +643,7 @@ static bool uemis_get_answer(const char *path, const char *request, int n_param_
reqtxt_file = subsurface_open(reqtxt_path, O_RDWR | O_CREAT, 0666);
if (reqtxt_file < 0) {
*error_text = "can't open req.txt";
fprintf(stderr, "open %s failed with errno %d\n", reqtxt_path, errno);
report_info("open %s failed with errno %d", reqtxt_path, errno);
return false;
}
trigger_response(reqtxt_file, "n", filenr, file_length);
@ -658,7 +658,7 @@ static bool uemis_get_answer(const char *path, const char *request, int n_param_
reqtxt_file = subsurface_open(reqtxt_path, O_RDWR | O_CREAT, 0666);
if (reqtxt_file < 0) {
*error_text = "can't open req.txt";
fprintf(stderr, "open %s failed with errno %d\n", reqtxt_path, errno);
report_info("open %s failed with errno %d", reqtxt_path, errno);
return false;
}
trigger_response(reqtxt_file, "r", filenr, file_length);
@ -1294,7 +1294,7 @@ static bool get_matching_dive(int idx, char *newmax, int *uemis_mem_status, devi
dive_to_read = -1;
} else if (!strstr(mbuf, "act{") && ++fail_count == 10) {
if (verbose)
fprintf(stderr, "Uemis downloader: Cannot access dive details - searching from start\n");
report_info("Uemis downloader: Cannot access dive details - searching from start");
dive_to_read = -1;
}
}
@ -1367,7 +1367,7 @@ const char *do_uemis_import(device_data_t *data)
param_buff[1] = "notempty";
newmax = uemis_get_divenr(deviceid, data->log->dives, force_download);
if (verbose)
fprintf(stderr, "Uemis downloader: start looking at dive nr %s\n", newmax);
report_info("Uemis downloader: start looking at dive nr %s", newmax);
first = start = atoi(newmax);
dive_to_read = (int)mindiveid < first ? first - mindiveid : first;
@ -1453,7 +1453,7 @@ const char *do_uemis_import(device_data_t *data)
if (!uemis_get_answer(mountpath, "getDeviceId", 0, 1, &result))
goto bail;
if (strcmp(deviceid, param_buff[0]) != 0) {
fprintf(stderr, "Uemis: Device id has changed after reconnect!\n");
report_info("Uemis: Device id has changed after reconnect!");
goto bail;
}
param_buff[0] = strdup(deviceid);

View file

@ -15,6 +15,7 @@
#include "uemis.h"
#include "divesite.h"
#include "errorhelper.h"
#include "sample.h"
#include <libdivecomputer/parser.h>
#include <libdivecomputer/version.h>
@ -85,7 +86,7 @@ static int uemis_convert_base64(char *base64, uint8_t **data)
datalen = (len / 4 + 1) * 3;
if (datalen < 0x123 + 0x25)
/* less than header + 1 sample??? */
fprintf(stderr, "suspiciously short data block %d\n", datalen);
report_info("suspiciously short data block %d", datalen);
*data = malloc(datalen);
if (!*data) {
@ -95,7 +96,7 @@ static int uemis_convert_base64(char *base64, uint8_t **data)
decode((unsigned char *)base64, *data, len);
if (memcmp(*data, "Dive\01\00\00", 7))
fprintf(stderr, "Missing Dive100 header\n");
report_info("Missing Dive100 header");
return datalen;
}
@ -350,7 +351,7 @@ void uemis_parse_divelog_binary(char *base64, void *datap)
while ((i <= datalen) && (data[i] != 0 || data[i + 1] != 0)) {
if (u_sample->active_tank != active) {
if (u_sample->active_tank >= dive->cylinders.nr) {
fprintf(stderr, "got invalid sensor #%d was #%d\n", u_sample->active_tank, active);
report_info("got invalid sensor #%d was #%d", u_sample->active_tank, active);
} else {
active = u_sample->active_tank;
add_gas_switch_event(dive, dc, u_sample->dive_time, active);

View file

@ -32,7 +32,7 @@ static std::string utf16_to_utf8_fl(const std::wstring &utf16, const char *file,
/* estimate buffer size */
const int sz = WideCharToMultiByte(CP_UTF8, 0, utf16.c_str(), -1, NULL, 0, NULL, NULL);
if (!sz) {
fprintf(stderr, "%s:%d: cannot estimate buffer size\n", file, line);
report_info("%s:%d: cannot estimate buffer size", file, line);
return std::string();
}
std::string utf8(sz, ' '); // Note: includes the terminating '\0', just in case.
@ -40,7 +40,7 @@ static std::string utf16_to_utf8_fl(const std::wstring &utf16, const char *file,
utf8.resize(sz - 1); // Chop off final '\0' byte
return utf8;
}
fprintf(stderr, "%s:%d: cannot convert string\n", file, line);
report_info("%s:%d: cannot convert string", file, line);
return std::string();
}
@ -58,7 +58,7 @@ static std::wstring utf8_to_utf16_fl(const char *utf8, const char *file, int lin
utf16.resize(actual_size - 1); // Chop off final '\0' character
return utf16;
}
fprintf(stderr, "%s:%d: cannot convert string\n", file, line);
report_info("%s:%d: cannot convert string", file, line);
return std::wstring();
}
@ -80,7 +80,7 @@ static std::wstring system_default_path()
if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, 0, wpath))) {
path = wpath;
} else {
fprintf(stderr, "%s: cannot obtain path!\n", fname);
report_info("%s: cannot obtain path!", fname);
path = L'.';
}
return path + L"\\Subsurface";
@ -251,7 +251,7 @@ int subsurface_dir_rename(const char *path, const char *newpath)
if (attrib != INVALID_FILE_ATTRIBUTES && attrib & FILE_ATTRIBUTE_DIRECTORY)
exists = TRUE;
if (!exists && verbose) {
fprintf(stderr, "folder not found or path is not a folder: %s\n", path);
report_info("folder not found or path is not a folder: %s", path);
return EXIT_FAILURE;
}
@ -265,11 +265,11 @@ int subsurface_dir_rename(const char *path, const char *newpath)
if (h == INVALID_HANDLE_VALUE) {
errorCode = GetLastError();
if (verbose)
fprintf(stderr, "cannot obtain exclusive write access for folder: %u\n", (unsigned int)errorCode );
report_info("cannot obtain exclusive write access for folder: %u", (unsigned int)errorCode );
return EXIT_FAILURE;
} else {
if (verbose)
fprintf(stderr, "exclusive write access obtained...closing handle!");
report_info("exclusive write access obtained...closing handle!");
CloseHandle(h);
// attempt to rename
@ -277,11 +277,11 @@ int subsurface_dir_rename(const char *path, const char *newpath)
if (!result) {
errorCode = GetLastError();
if (verbose)
fprintf(stderr, "rename failed: %u\n", (unsigned int)errorCode);
report_info("rename failed: %u", (unsigned int)errorCode);
return EXIT_FAILURE;
}
if (verbose > 1)
fprintf(stderr, "folder rename success: %s ---> %s\n", path, newpath);
report_info("folder rename success: %s ---> %s", path, newpath);
}
return EXIT_SUCCESS;
}

View file

@ -5,6 +5,7 @@
#include "core/device.h"
#include "core/divelist.h"
#include "core/divelog.h"
#include "core/errorhelper.h"
#include "core/settings/qPrefDiveComputer.h"
#include "core/subsurface-float.h"
#include "core/subsurface-string.h"
@ -433,7 +434,7 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
if ((colon = strstr(devname, ":\\ (UEMISSDA)")) != NULL) {
*(colon + 2) = '\0';
fprintf(stderr, "shortened devname to \"%s\"", devname);
report_info("shortened devname to \"%s\"", devname);
}
data->setDevName(devname);
} else {

View file

@ -2,6 +2,7 @@
#include "statsmanager.h"
#include "themeinterface.h"
#include "stats/chartlistmodel.h"
#include "core/errorhelper.h"
StatsManager::StatsManager() : view(nullptr), charts(nullptr), themeInitialized(false)
{
@ -15,9 +16,9 @@ StatsManager::~StatsManager()
void StatsManager::init(StatsView *v, ChartListModel *m)
{
if (!v)
fprintf(stderr, "StatsManager::init(): no StatsView - statistics will not work.\n");
report_info("StatsManager::init(): no StatsView - statistics will not work.");
if (!m)
fprintf(stderr, "StatsManager::init(): no ChartListModel - statistics will not work.\n");
report_info("StatsManager::init(): no ChartListModel - statistics will not work.");
view = v;
charts = m;

View file

@ -9,6 +9,7 @@
#include "stats/statsview.h"
#include "core/devicedetails.h"
#include "core/errorhelper.h"
#include "core/globals.h"
#include "core/qt-gui.h"
#include "core/settings/qPref.h"
@ -146,7 +147,7 @@ void run_mobile_ui(double initial_font_size)
qDebug() << "loaded main.qml";
qqWindowObject = engine.rootObjects().value(0);
if (!qqWindowObject) {
fprintf(stderr, "can't create window object\n");
report_info("can't create window object");
exit(1);
}
QQuickWindow *qml_window = qobject_cast<QQuickWindow *>(qqWindowObject);