From 594d1d3514f91221884bdc31f29a09e8f325f1e8 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 5 Aug 2019 20:07:10 +0200 Subject: [PATCH] Cleanup: move file-related function declarations to file.h A number of architecture-dependent functions were declared in dive.h. Move them to file.h so that not all file-manipulating translation units have to include dive.h. This is a small step in avoiding mass-recompilation on every change to dive.h Signed-off-by: Berthold Stoeger --- core/android.cpp | 2 ++ core/configuredivecomputer.cpp | 2 +- core/deco.c | 5 +++-- core/dive.h | 12 +----------- core/file.h | 17 +++++++++++++++++ core/git-access.c | 2 +- core/ios.cpp | 2 ++ core/ostctools.c | 1 + core/save-html.c | 1 + core/save-profiledata.c | 1 + core/save-profiledata.h | 2 -- core/save-xml.c | 1 + core/uemis-downloader.c | 1 + core/unix.c | 2 ++ core/windows.c | 2 ++ core/worldmap-save.c | 1 + desktop-widgets/divelogexportdialog.cpp | 13 +++++++------ desktop-widgets/subsurfacewebservices.cpp | 1 + 18 files changed, 45 insertions(+), 23 deletions(-) diff --git a/core/android.cpp b/core/android.cpp index 08b34dc73..0ef1219fd 100644 --- a/core/android.cpp +++ b/core/android.cpp @@ -2,6 +2,7 @@ /* implements Android specific functions */ #include "dive.h" #include "display.h" +#include "file.h" #include "qthelper.h" #include #include @@ -10,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/core/configuredivecomputer.cpp b/core/configuredivecomputer.cpp index 31811c91b..7574ceb6b 100644 --- a/core/configuredivecomputer.cpp +++ b/core/configuredivecomputer.cpp @@ -8,7 +8,7 @@ #include #include #include -#include "core/dive.h" // for subsurface_fopen() +#include "core/file.h" #include "core/errorhelper.h" #include "core/version.h" diff --git a/core/deco.c b/core/deco.c index e0b112150..46f57c9da 100644 --- a/core/deco.c +++ b/core/deco.c @@ -17,12 +17,13 @@ * restore_deco_state() * dump_tissues() */ -#include "ssrf.h" #include #include +#include + +#include "ssrf.h" #include "dive.h" #include "subsurface-string.h" -#include #include "errorhelper.h" #include "planner.h" #include "qthelper.h" diff --git a/core/dive.h b/core/dive.h index fcd9483f7..57bb6e297 100644 --- a/core/dive.h +++ b/core/dive.h @@ -9,9 +9,8 @@ #include #include #include -#include #include -#include +#include #include "equipment.h" @@ -317,15 +316,6 @@ struct user_info { }; extern void subsurface_user_info(struct user_info *); -extern int subsurface_rename(const char *path, const char *newpath); -extern int subsurface_dir_rename(const char *path, const char *newpath); -extern int subsurface_open(const char *path, int oflags, mode_t mode); -extern FILE *subsurface_fopen(const char *path, const char *mode); -extern void *subsurface_opendir(const char *path); -extern int subsurface_access(const char *path, int mode); -extern int subsurface_stat(const char* path, struct stat* buf); -extern struct zip *subsurface_zip_open_readonly(const char *path, int flags, int *errorp); -extern int subsurface_zip_close(struct zip *zip); extern void subsurface_console_init(void); extern void subsurface_console_exit(void); extern bool subsurface_user_is_root(void); diff --git a/core/file.h b/core/file.h index f8f59ead2..012d7e727 100644 --- a/core/file.h +++ b/core/file.h @@ -2,12 +2,17 @@ #ifndef FILE_H #define FILE_H +#include + struct memblock { void *buffer; size_t size; }; struct trip_table; +struct dive_site_table; +struct dive_table; +struct zip; #ifdef __cplusplus extern "C" { @@ -20,6 +25,18 @@ extern void ostctools_import(const char *file, struct dive_table *table, struct 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); + +// Platform specific functions +extern int subsurface_rename(const char *path, const char *newpath); +extern int subsurface_dir_rename(const char *path, const char *newpath); +extern int subsurface_open(const char *path, int oflags, mode_t mode); +extern FILE *subsurface_fopen(const char *path, const char *mode); +extern void *subsurface_opendir(const char *path); +extern int subsurface_access(const char *path, int mode); +extern int subsurface_stat(const char* path, struct stat* buf); +extern struct zip *subsurface_zip_open_readonly(const char *path, int flags, int *errorp); +extern int subsurface_zip_close(struct zip *zip); + #ifdef __cplusplus } #endif diff --git a/core/git-access.c b/core/git-access.c index a142dd8f0..3688cb90c 100644 --- a/core/git-access.c +++ b/core/git-access.c @@ -22,7 +22,7 @@ #include "membuffer.h" #include "strndup.h" #include "qthelper.h" -#include "dive.h" // for subsurface_stat() +#include "file.h" #include "errorhelper.h" #include "git-access.h" #include "gettext.h" diff --git a/core/ios.cpp b/core/ios.cpp index 614107d2b..d54f2b4b8 100644 --- a/core/ios.cpp +++ b/core/ios.cpp @@ -4,6 +4,7 @@ #include #include #include "dive.h" +#include "file.h" #include "display.h" #include "core/qthelper.h" #include @@ -15,6 +16,7 @@ #include #include #include +#include #include diff --git a/core/ostctools.c b/core/ostctools.c index e80df794e..02056abcc 100644 --- a/core/ostctools.c +++ b/core/ostctools.c @@ -8,6 +8,7 @@ #include "subsurface-string.h" #include "gettext.h" #include "divelist.h" +#include "file.h" #include "libdivecomputer.h" /* diff --git a/core/save-html.c b/core/save-html.c index cd82d1d44..09d7152d4 100644 --- a/core/save-html.c +++ b/core/save-html.c @@ -9,6 +9,7 @@ #include "gettext.h" #include "divesite.h" #include "errorhelper.h" +#include "file.h" #include "tag.h" #include "trip.h" #include diff --git a/core/save-profiledata.c b/core/save-profiledata.c index 347d5249f..b2279148e 100644 --- a/core/save-profiledata.c +++ b/core/save-profiledata.c @@ -1,6 +1,7 @@ #include "core/profile.h" #include "core/display.h" #include "core/errorhelper.h" +#include "core/file.h" #include "core/membuffer.h" #include "core/subsurface-string.h" #include "core/save-profiledata.h" diff --git a/core/save-profiledata.h b/core/save-profiledata.h index fd38e48ca..3720dc46c 100644 --- a/core/save-profiledata.h +++ b/core/save-profiledata.h @@ -2,8 +2,6 @@ #ifndef SAVE_PROFILE_DATA_H #define SAVE_PROFILE_DATA_H -#include "dive.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/core/save-xml.c b/core/save-xml.c index c9e997f01..e0a09df16 100644 --- a/core/save-xml.c +++ b/core/save-xml.c @@ -18,6 +18,7 @@ #include "subsurface-string.h" #include "trip.h" #include "device.h" +#include "file.h" #include "membuffer.h" #include "strndup.h" #include "git-access.h" diff --git a/core/uemis-downloader.c b/core/uemis-downloader.c index 78ae9b7d6..3d5119968 100644 --- a/core/uemis-downloader.c +++ b/core/uemis-downloader.c @@ -27,6 +27,7 @@ #include "divelist.h" #include "divesite.h" #include "errorhelper.h" +#include "file.h" #include "tag.h" #include "core/subsurface-string.h" diff --git a/core/unix.c b/core/unix.c index 5b1cc3720..a867d5013 100644 --- a/core/unix.c +++ b/core/unix.c @@ -3,6 +3,7 @@ /* implements UNIX specific functions */ #include "ssrf.h" #include "dive.h" +#include "file.h" #include "subsurface-string.h" #include "display.h" #include "membuffer.h" @@ -14,6 +15,7 @@ #include #include #include +#include // the DE should provide us with a default font and font size... const char unix_system_divelist_default_font[] = "Sans"; diff --git a/core/windows.c b/core/windows.c index 85ef1bbf2..4ca0c621a 100644 --- a/core/windows.c +++ b/core/windows.c @@ -5,6 +5,8 @@ #include #include "dive.h" #include "display.h" +#include "file.h" +#include "errorhelper.h" #undef _WIN32_WINNT #define _WIN32_WINNT 0x500 #include diff --git a/core/worldmap-save.c b/core/worldmap-save.c index 3aa91e929..48a5fcf5f 100644 --- a/core/worldmap-save.c +++ b/core/worldmap-save.c @@ -12,6 +12,7 @@ #include "membuffer.h" #include "divesite.h" #include "errorhelper.h" +#include "file.h" #include "save-html.h" #include "worldmap-save.h" #include "worldmap-options.h" diff --git a/desktop-widgets/divelogexportdialog.cpp b/desktop-widgets/divelogexportdialog.cpp index 229909137..9bf8c16a8 100644 --- a/desktop-widgets/divelogexportdialog.cpp +++ b/desktop-widgets/divelogexportdialog.cpp @@ -5,20 +5,21 @@ #include #include // Allows string comparisons and substitutions in TeX export -#include "desktop-widgets/divelogexportdialog.h" -#include "core/divelogexportlogic.h" -#include "desktop-widgets/diveshareexportdialog.h" #include "ui_divelogexportdialog.h" -#include "desktop-widgets/subsurfacewebservices.h" +#include "core/divelogexportlogic.h" #include "core/worldmap-save.h" #include "core/save-html.h" #include "core/settings/qPrefDisplay.h" -#include "desktop-widgets/mainwindow.h" -#include "profile-widget/profilewidget2.h" #include "core/save-profiledata.h" #include "core/divesite.h" #include "core/errorhelper.h" +#include "core/file.h" #include "core/tag.h" +#include "desktop-widgets/mainwindow.h" +#include "desktop-widgets/divelogexportdialog.h" +#include "desktop-widgets/diveshareexportdialog.h" +#include "desktop-widgets/subsurfacewebservices.h" +#include "profile-widget/profilewidget2.h" // Retrieves the current unit settings defined in the Subsurface preferences. #define GET_UNIT(name, field, f, t) \ diff --git a/desktop-widgets/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp index 6bb6d44aa..57f3c2876 100644 --- a/desktop-widgets/subsurfacewebservices.cpp +++ b/desktop-widgets/subsurfacewebservices.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #ifdef Q_OS_UNIX #include // for dup(2)