Cleanup: move parse-function declarations out of "dive.h"

Move the declaration of these functions to "file.h" and "parse.h"
according to the translation unit they are defined in. Thus, not
all users of "dive.h" have to suck in "sqlite3.h".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-03-03 22:29:40 +01:00 committed by Dirk Hohndel
parent 7c64822b9b
commit f3e1187e65
11 changed files with 27 additions and 12 deletions

View file

@ -10,7 +10,6 @@
#include <time.h> #include <time.h>
#include <math.h> #include <math.h>
#include <zip.h> #include <zip.h>
#include <sqlite3.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "divesite.h" #include "divesite.h"
@ -478,15 +477,6 @@ extern int parse_xml_buffer(const char *url, const char *buf, int size, struct d
extern void parse_xml_exit(void); extern void parse_xml_exit(void);
extern void set_filename(const char *filename); extern void set_filename(const char *filename);
extern int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
extern int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
extern int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
extern int parse_shearwater_cloud_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
extern int parse_cobalt_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
extern int parse_divinglog_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
extern int parse_dlf_buffer(unsigned char *buffer, size_t size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
extern int parse_file(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
extern int save_dives(const char *filename); extern int save_dives(const char *filename);
extern int save_dives_logic(const char *filename, bool select_only, bool anonymize); extern int save_dives_logic(const char *filename, bool select_only, bool anonymize);
extern int save_dive(FILE *f, struct dive *dive, bool anonymize); extern int save_dive(FILE *f, struct dive *dive, bool anonymize);

View file

@ -17,6 +17,7 @@
#include "git-access.h" #include "git-access.h"
#include "qthelper.h" #include "qthelper.h"
#include "import-csv.h" #include "import-csv.h"
#include "parse.h"
/* For SAMPLE_* */ /* For SAMPLE_* */
#include <libdivecomputer/parser.h> #include <libdivecomputer/parser.h>

View file

@ -16,6 +16,7 @@ extern int datatrak_import(struct memblock *mem, struct dive_table *table, struc
extern void ostctools_import(const char *file, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); extern void ostctools_import(const char *file, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
extern int readfile(const char *filename, struct memblock *mem); extern int readfile(const char *filename, struct memblock *mem);
extern int parse_file(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
extern int try_to_open_zip(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); extern int try_to_open_zip(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -4,6 +4,8 @@
#define MAX_EVENT_NAME 128 #define MAX_EVENT_NAME 128
#include <sqlite3.h>
typedef union { typedef union {
struct event event; struct event event;
char allocation[sizeof(struct event) + MAX_EVENT_NAME]; char allocation[sizeof(struct event) + MAX_EVENT_NAME];
@ -68,6 +70,9 @@ struct parser_state {
#define cur_event event_allocation.event #define cur_event event_allocation.event
#ifdef __cplusplus
extern "C" {
#endif
void init_parser_state(struct parser_state *state); void init_parser_state(struct parser_state *state);
void free_parser_state(struct parser_state *state); void free_parser_state(struct parser_state *state);
@ -113,4 +118,15 @@ void utf8_string(char *buffer, void *_res);
void add_dive_site(char *ds_name, struct dive *dive, struct parser_state *state); void add_dive_site(char *ds_name, struct dive *dive, struct parser_state *state);
int atoi_n(char *ptr, unsigned int len); int atoi_n(char *ptr, unsigned int len);
int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
int parse_shearwater_cloud_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
int parse_cobalt_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
int parse_divinglog_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
int parse_dlf_buffer(unsigned char *buffer, size_t size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites);
#ifdef __cplusplus
}
#endif
#endif #endif

View file

@ -20,6 +20,7 @@
#include "core/color.h" #include "core/color.h"
#include "core/divecomputer.h" #include "core/divecomputer.h"
#include "core/divesitehelpers.h" #include "core/divesitehelpers.h"
#include "core/file.h"
#include "core/gettextfromc.h" #include "core/gettextfromc.h"
#include "core/git-access.h" #include "core/git-access.h"
#include "core/import-csv.h" #include "core/import-csv.h"

View file

@ -7,11 +7,11 @@
#include "desktop-widgets/command.h" #include "desktop-widgets/command.h"
#include "desktop-widgets/usersurvey.h" #include "desktop-widgets/usersurvey.h"
#include "core/divelist.h" #include "core/divelist.h"
#include "core/file.h"
#include "desktop-widgets/mapwidget.h" #include "desktop-widgets/mapwidget.h"
#include "desktop-widgets/tab-widgets/maintab.h" #include "desktop-widgets/tab-widgets/maintab.h"
#include "core/display.h" #include "core/display.h"
#include "core/membuffer.h" #include "core/membuffer.h"
#include <errno.h>
#include "core/cloudstorage.h" #include "core/cloudstorage.h"
#include "core/subsurface-string.h" #include "core/subsurface-string.h"
@ -23,6 +23,7 @@
#include <qdesktopservices.h> #include <qdesktopservices.h>
#include <QShortcut> #include <QShortcut>
#include <QDebug> #include <QDebug>
#include <errno.h>
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
#include <unistd.h> // for dup(2) #include <unistd.h> // for dup(2)

View file

@ -8,6 +8,8 @@
#include "core/qt-gui.h" #include "core/qt-gui.h"
#include "core/qthelper.h" #include "core/qthelper.h"
#include "core/file.h"
#include "core/divesite.h"
#include "core/save-html.h" #include "core/save-html.h"
#include <stdio.h> #include <stdio.h>
#include "git2.h" #include "git2.h"

View file

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

View file

@ -2,6 +2,7 @@
#include "testdivesiteduplication.h" #include "testdivesiteduplication.h"
#include "core/dive.h" #include "core/dive.h"
#include "core/divesite.h" #include "core/divesite.h"
#include "core/file.h"
void TestDiveSiteDuplication::testReadV2() void TestDiveSiteDuplication::testReadV2()
{ {

View file

@ -2,6 +2,7 @@
#include "testparseperformance.h" #include "testparseperformance.h"
#include "core/dive.h" #include "core/dive.h"
#include "core/divelist.h" #include "core/divelist.h"
#include "core/file.h"
#include "core/git-access.h" #include "core/git-access.h"
#include "core/settings/qPrefProxy.h" #include "core/settings/qPrefProxy.h"
#include "core/settings/qPrefCloudStorage.h" #include "core/settings/qPrefCloudStorage.h"
@ -41,7 +42,6 @@ void TestParsePerformance::initTestCase()
QString localCacheDir(get_local_dir(LARGE_TEST_REPO, "git")); QString localCacheDir(get_local_dir(LARGE_TEST_REPO, "git"));
QDir localCacheDirectory(localCacheDir); QDir localCacheDirectory(localCacheDir);
QCOMPARE(localCacheDirectory.removeRecursively(), true); QCOMPARE(localCacheDirectory.removeRecursively(), true);
} }
void TestParsePerformance::init() void TestParsePerformance::init()

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "testprofile.h" #include "testprofile.h"
#include "core/dive.h" #include "core/dive.h"
#include "core/file.h"
void TestProfile::testRedCeiling() void TestProfile::testRedCeiling()
{ {