Cleanup: move error reporting function declarations to errorhelper.h

Move the declarations of the "report_error()" and "set_error_cb()"
functions and the "verbose" variable to errorhelper.h.
Thus, error-reporting translation units don't have to import the
big dive.h header file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-08-05 19:41:15 +02:00 committed by Dirk Hohndel
parent 2a966ac2a9
commit 5da09a21bb
55 changed files with 88 additions and 30 deletions

View file

@ -8,11 +8,10 @@
#include "pref.h"
#include "qthelper.h"
#include "git-access.h"
#include "dive.h" // for "verbose"
#include "errorhelper.h"
#include "checkcloudconnection.h"
CheckCloudConnection::CheckCloudConnection(QObject *parent) :
QObject(parent),
reply(0)

View file

@ -2,7 +2,7 @@
#include "cloudstorage.h"
#include "pref.h"
#include "qthelper.h"
#include "dive.h"
#include "errorhelper.h"
#include "settings/qPrefCloudStorage.h"
#include <QApplication>

View file

@ -8,6 +8,8 @@
#include <libxslt/transform.h>
#include <QStringList>
#include <QXmlStreamWriter>
#include "core/dive.h" // for subsurface_fopen()
#include "core/errorhelper.h"
#include "core/version.h"
ConfigureDiveComputer::ConfigureDiveComputer() : readThread(0),

View file

@ -3,6 +3,8 @@
#include "libdivecomputer/hw_ostc.h"
#include "libdivecomputer/hw_ostc3.h"
#include "libdivecomputer.h"
#include "units.h"
#include "errorhelper.h"
#define OSTC3_GAS1 0x10
#define OSTC3_GAS2 0x11

View file

@ -16,6 +16,7 @@
#include "device.h"
#include "file.h"
#include "divesite.h"
#include "errorhelper.h"
#include "ssrf.h"
#include "tag.h"

View file

@ -23,7 +23,8 @@
#include "dive.h"
#include "subsurface-string.h"
#include <assert.h>
#include "core/planner.h"
#include "errorhelper.h"
#include "planner.h"
#include "qthelper.h"
#define cube(x) (x * x * x)

View file

@ -2,10 +2,13 @@
#ifndef DEVICE_H
#define DEVICE_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
struct divecomputer;
extern void fake_dc(struct divecomputer *dc);
extern void set_dc_deviceid(struct divecomputer *dc, unsigned int deviceid);
extern void create_device_node(const char *model, uint32_t deviceid, const char *serial, const char *firmware, const char *nickname);

View file

@ -247,7 +247,7 @@ extern bool autogroup;
struct dive *unregister_dive(int idx);
extern void delete_single_dive(int idx);
extern int run_survey, verbose, quit, force_root;
extern int run_survey, quit, force_root;
extern struct dive_table dive_table;
extern struct dive displayed_dive;
@ -289,9 +289,6 @@ extern bool dive_site_has_gps_location(const struct dive_site *ds);
extern int dive_has_gps_location(const struct dive *dive);
extern location_t dive_get_gps_location(const struct dive *d);
extern int report_error(const char *fmt, ...);
extern void set_error_cb(void(*cb)(char *)); // Callback takes ownership of passed string
extern bool dive_within_time_range(struct dive *dive, timestamp_t when, timestamp_t offset);
extern bool time_during_dive_with_offset(struct dive *dive, timestamp_t when, timestamp_t offset);
struct dive *find_dive_n_near(timestamp_t when, int n, timestamp_t offset);

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "divecomputer.h"
#include "dive.h"
#include "errorhelper.h"
#include "core/settings/qPrefDiveComputer.h"
#include "subsurface-string.h"

View file

@ -5,6 +5,7 @@
#include <QDir>
#include <QTextStream>
#include "divelogexportlogic.h"
#include "errorhelper.h"
#include "qthelper.h"
#include "units.h"
#include "statistics.h"

View file

@ -6,6 +6,7 @@
#include "divesitehelpers.h"
#include "divesite.h"
#include "errorhelper.h"
#include "subsurface-string.h"
#include "qthelper.h"
#include "membuffer.h"

View file

@ -4,11 +4,13 @@
#pragma clang diagnostic ignored "-Wmissing-field-initializers"
#endif
#include <stdarg.h>
#include "dive.h"
#include "errorhelper.h"
#include "membuffer.h"
#define VA_BUF(b, fmt) do { va_list args; va_start(args, fmt); put_vformat(b, fmt, args); va_end(args); } while (0)
int verbose;
static void (*error_cb)(char *) = NULL;
int report_error(const char *fmt, ...)

19
core/errorhelper.h Normal file
View file

@ -0,0 +1,19 @@
// SPDX-License-Identifier: GPL-2.0
#ifndef ERROR_HELPER_H
#define ERROR_HELPER_H
// error reporting functions
#ifdef __cplusplus
extern "C" {
#endif
extern int verbose;
extern int report_error(const char *fmt, ...);
extern void set_error_cb(void(*cb)(char *)); // Callback takes ownership of passed string
#ifdef __cplusplus
}
#endif
#endif

View file

@ -13,6 +13,7 @@
#include "dive.h"
#include "subsurface-string.h"
#include "divelist.h"
#include "errorhelper.h"
#include "file.h"
#include "git-access.h"
#include "qthelper.h"

View file

@ -7,6 +7,8 @@ struct memblock {
size_t size;
};
struct trip_table;
#ifdef __cplusplus
extern "C" {
#endif

View file

@ -22,7 +22,8 @@
#include "membuffer.h"
#include "strndup.h"
#include "qthelper.h"
#include "dive.h"
#include "dive.h" // for subsurface_stat()
#include "errorhelper.h"
#include "git-access.h"
#include "gettext.h"
#include "sha1.h"

View file

@ -5,6 +5,7 @@
#include "core/pref.h"
#include "core/qthelper.h"
#include "core/divelist.h" // for mark_divelist_changed()
#include "core/errorhelper.h"
#include "core/settings/qPrefLocationService.h"
#include <time.h>
#include <unistd.h>

View file

@ -2,7 +2,7 @@
#include <errno.h>
#include <libdivecomputer/parser.h>
#include "dive.h"
#include "errorhelper.h"
#include "ssrf.h"
#include "subsurface-string.h"
#include "divelist.h"

View file

@ -19,6 +19,7 @@
#include "device.h"
#include "divelist.h"
#include "display.h"
#include "errorhelper.h"
#include "sha1.h"
#include <libdivecomputer/version.h>

View file

@ -2,6 +2,7 @@
#ifndef LIBDIVECOMPUTER_H
#define LIBDIVECOMPUTER_H
#include <stdint.h>
/* libdivecomputer */
@ -18,12 +19,15 @@
#define dc_usb_storage_open(stream, context, devname) (DC_STATUS_UNSUPPORTED)
#endif
#include "dive.h"
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#endif
struct dive;
struct dive_computer;
typedef struct dc_user_device_t
{
dc_descriptor_t *descriptor;

View file

@ -16,6 +16,7 @@
#include "gettext.h"
#include "divesite.h"
#include "errorhelper.h"
#include "trip.h"
#include "subsurface-string.h"
#include "device.h"

View file

@ -3,7 +3,7 @@
#include <stdio.h>
#include <string.h>
#include "dive.h"
#include "errorhelper.h"
#include "ssrf.h"
#include "subsurface-string.h"
#include "gettext.h"

View file

@ -23,6 +23,7 @@
#include "gettext.h"
#include "divesite.h"
#include "errorhelper.h"
#include "subsurface-string.h"
#include "parse.h"
#include "trip.h"
@ -31,7 +32,7 @@
#include "qthelper.h"
#include "tag.h"
int verbose, quit, force_root;
int quit, force_root;
int last_xml_version = -1;
static xmlDoc *test_xslt_transforms(xmlDoc *doc, const char **params);

View file

@ -8,6 +8,7 @@
#include <libdivecomputer/parser.h>
#include "divesite.h"
#include "errorhelper.h"
#include "subsurface-string.h"
#include "parse.h"
#include "trip.h"

View file

@ -11,9 +11,10 @@
#include <ctype.h>
#include <string.h>
#include "dive.h"
#include "divelist.h"
#include "subsurface-string.h"
#include "deco.h"
#include "divelist.h"
#include "errorhelper.h"
#include "planner.h"
#include "gettext.h"
#include "libdivecomputer/parser.h"

View file

@ -18,6 +18,7 @@
#include "libdivecomputer.h"
#include "core/qt-ble.h"
#include "core/btdiscovery.h"
#include "core/errorhelper.h"
#include "core/subsurface-string.h"
#define BLE_TIMEOUT 12000 // 12 seconds seems like a very long time to wait

View file

@ -5,7 +5,7 @@
#include <QLibraryInfo>
#include <QTextCodec>
#include "qthelper.h"
#include "dive.h" // for "verbose"
#include "errorhelper.h"
#include "core/settings/qPref.h"
char *settings_suffix = NULL;

View file

@ -10,6 +10,7 @@
#include "subsurfacesysinfo.h"
#include "version.h"
#include "divecomputer.h"
#include "errorhelper.h"
#include "time.h"
#include "gettextfromc.h"
#include "applicationstate.h"

View file

@ -21,6 +21,7 @@
#include "subsurface-string.h"
#include "trip.h"
#include "device.h"
#include "errorhelper.h"
#include "membuffer.h"
#include "git-access.h"
#include "version.h"

View file

@ -8,6 +8,7 @@
#include "qthelper.h"
#include "gettext.h"
#include "divesite.h"
#include "errorhelper.h"
#include "tag.h"
#include "trip.h"
#include <stdio.h>

View file

@ -2,13 +2,14 @@
#ifndef HTML_SAVE_H
#define HTML_SAVE_H
#include "dive.h"
#include "membuffer.h"
#ifdef __cplusplus
extern "C" {
#endif
struct dive;
void put_HTML_date(struct membuffer *b, struct dive *dive, const char *pre, const char *post);
void put_HTML_depth(struct membuffer *b, struct dive *dive, const char *pre, const char *post);
void put_HTML_airtemp(struct membuffer *b, struct dive *dive, const char *pre, const char *post);

View file

@ -1,7 +1,6 @@
#include "core/profile.h"
#include "core/profile.h"
#include "core/dive.h"
#include "core/display.h"
#include "core/errorhelper.h"
#include "core/membuffer.h"
#include "core/subsurface-string.h"
#include "core/save-profiledata.h"

View file

@ -14,6 +14,7 @@
#include <fcntl.h>
#include "divesite.h"
#include "errorhelper.h"
#include "subsurface-string.h"
#include "trip.h"
#include "device.h"

View file

@ -4,6 +4,8 @@
#include "version.h"
#include <stdbool.h>
#include <string.h>
#include "errorhelper.h"
#include "dive.h" // for quit and force_root
#include "gettext.h"
#include "qthelper.h"
#include "git-access.h"

View file

@ -2,10 +2,6 @@
#ifndef SUBSURFACESTARTUP_H
#define SUBSURFACESTARTUP_H
#include "dive.h"
#include "divelist.h"
#include "libdivecomputer.h"
#ifdef __cplusplus
extern "C" {
#else

View file

@ -26,6 +26,7 @@
#include "uemis.h"
#include "divelist.h"
#include "divesite.h"
#include "errorhelper.h"
#include "tag.h"
#include "core/subsurface-string.h"

View file

@ -2,7 +2,7 @@
#include "videoframeextractor.h"
#include "imagedownloader.h"
#include "core/pref.h"
#include "core/dive.h" // for report_error()!
#include "core/errorhelper.h"
#include <QtConcurrent>
#include <QProcess>

View file

@ -11,6 +11,7 @@
#include "membuffer.h"
#include "divesite.h"
#include "errorhelper.h"
#include "save-html.h"
#include "worldmap-save.h"
#include "worldmap-options.h"

View file

@ -8,7 +8,6 @@ extern "C" {
extern void export_worldmap_HTML(const char *file_name, const bool selected_only);
#ifdef __cplusplus
}
#endif

View file

@ -19,6 +19,7 @@
#include <QStandardPaths>
#include <QMessageBox>
#include <QHeaderView>
#include "core/errorhelper.h"
#include "core/qthelper.h"
#include "core/trip.h"
#include "desktop-widgets/command.h"

View file

@ -17,6 +17,7 @@
#include "profile-widget/profilewidget2.h"
#include "core/save-profiledata.h"
#include "core/divesite.h"
#include "core/errorhelper.h"
#include "core/tag.h"
// Retrieves the current unit settings defined in the Subsurface preferences.

View file

@ -21,6 +21,7 @@
#include "core/device.h"
#include "core/divecomputer.h"
#include "core/divesitehelpers.h"
#include "core/errorhelper.h"
#include "core/file.h"
#include "core/gettextfromc.h"
#include "core/git-access.h"

View file

@ -21,7 +21,6 @@
#include "desktop-widgets/filterwidget2.h"
#include "core/applicationstate.h"
#include "core/gpslocation.h"
#include "core/dive.h"
#define NUM_RECENT_FILES 4

View file

@ -3,7 +3,7 @@
#include "ui_preferences_network.h"
#include "subsurfacewebservices.h"
#include "core/cloudstorage.h"
#include "core/dive.h"
#include "core/errorhelper.h"
#include "core/settings/qPrefCloudStorage.h"
#include "core/settings/qPrefProxy.h"
#include <QNetworkProxy>

View file

@ -7,6 +7,7 @@
#include "desktop-widgets/command.h"
#include "desktop-widgets/usersurvey.h"
#include "core/trip.h"
#include "core/errorhelper.h"
#include "core/file.h"
#include "desktop-widgets/mapwidget.h"
#include "desktop-widgets/tab-widgets/maintab.h"

View file

@ -20,6 +20,7 @@
#include "qt-models/divelocationmodel.h"
#include "qt-models/filtermodels.h"
#include "core/divesite.h"
#include "core/errorhelper.h"
#include "core/subsurface-string.h"
#include "core/gettextfromc.h"
#include "desktop-widgets/locationinformation.h"

View file

@ -26,6 +26,7 @@
#include "qt-models/messagehandlermodel.h"
#include "qt-models/tankinfomodel.h"
#include "core/device.h"
#include "core/errorhelper.h"
#include "core/file.h"
#include "core/qthelper.h"
#include "core/qt-gui.h"

View file

@ -2,7 +2,7 @@
#include "divetextitem.h"
#include "profilewidget2.h"
#include "core/color.h"
#include "core/dive.h"
#include "core/errorhelper.h"
#include <QBrush>
#include <QDebug>

View file

@ -19,6 +19,7 @@
#include "qt-models/models.h"
#include "qt-models/divepicturemodel.h"
#include "core/divelist.h"
#include "core/errorhelper.h"
#ifndef SUBSURFACE_MOBILE
#include "desktop-widgets/diveplanner.h"
#include "desktop-widgets/simplewidgets.h"

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "qmlprofile.h"
#include "mobile-widgets/qmlmanager.h"
#include "core/errorhelper.h"
#include "core/subsurface-string.h"
#include "core/metrics.h"
#include <QTransform>

View file

@ -4,6 +4,7 @@
#include "qt-models/filtermodels.h"
#include "core/dive.h"
#include "core/divelist.h"
#include "core/errorhelper.h"
#include "core/settings/qPrefDisplay.h"
#include <QFileDialog>
#include <QFileInfo>

View file

@ -8,6 +8,7 @@
#include "core/color.h"
#include "core/downloadfromdcthread.h" // for fill_computer_list
#include "core/errorhelper.h"
#include "core/qt-gui.h"
#include "core/qthelper.h"
#include "core/subsurfacestartup.h"

View file

@ -3,7 +3,7 @@
#include "core/divesite.h"
#include "core/trip.h"
#include "core/file.h"
#include "core/dive.h"
#include "core/errorhelper.h"
#include <QString>
#include <core/qthelper.h>

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "testparse.h"
#include "core/divesite.h"
#include "core/errorhelper.h"
#include "core/trip.h"
#include "core/file.h"
#include "core/import-csv.h"

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "testpicture.h"
#include "core/divesite.h"
#include "core/errorhelper.h"
#include "core/trip.h"
#include "core/file.h"
#include <QString>