From: Arvin Schnell Date: Mon, 15 Jul 2013 15:15:16 +0000 (+0200) Subject: - con't include config.h in header files X-Git-Tag: v0.1.6~10 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=9ee584cd83142dbcd88df613c0ed4a8ba13a73ab;p=thirdparty%2Fsnapper.git - con't include config.h in header files --- diff --git a/snapper/Compare.cc b/snapper/Compare.cc index 29c66b74..9b62baab 100644 --- a/snapper/Compare.cc +++ b/snapper/Compare.cc @@ -20,6 +20,8 @@ */ +#include "config.h" + #include #include #include @@ -30,17 +32,12 @@ #include #include -#include "config.h" #include "snapper/Log.h" #include "snapper/AppUtil.h" #include "snapper/File.h" #include "snapper/Compare.h" #include "snapper/Exception.h" - - -#ifdef ENABLE_XATTRS - #include "snapper/XAttributes.h" -#endif +#include "snapper/XAttributes.h" namespace snapper @@ -223,13 +220,13 @@ namespace snapper } #ifdef ENABLE_XATTRS - if (file1.xaSupported() && file2.xaSupported()) - { - if (!cmpFilesXattrs(file1, file2)) - { - status |= XATTRS; - } - } + if (file1.xaSupported() && file2.xaSupported()) + { + if (!cmpFilesXattrs(file1, file2)) + { + status |= XATTRS; + } + } #endif return status; @@ -470,8 +467,6 @@ namespace snapper } -#ifdef ENABLE_XATTRS - bool cmpFilesXattrs(const SFile& file1, const SFile& file2) { @@ -488,6 +483,4 @@ namespace snapper } } -#endif - } diff --git a/snapper/Compare.h b/snapper/Compare.h index b88c4302..2975280c 100644 --- a/snapper/Compare.h +++ b/snapper/Compare.h @@ -48,10 +48,9 @@ namespace snapper void cmpDirs(const SDir& dir1, const SDir& dir2, cmpdirs_cb_t cb); -#ifdef ENABLE_XATTRS bool cmpFilesXattrs(const SFile&, const SFile&); -#endif + } diff --git a/snapper/Comparison.cc b/snapper/Comparison.cc index 100e967a..c1204636 100644 --- a/snapper/Comparison.cc +++ b/snapper/Comparison.cc @@ -20,13 +20,14 @@ */ +#include "config.h" + #include #include #include #include #include -#include "config.h" #include "snapper/Comparison.h" #include "snapper/Snapper.h" #include "snapper/Log.h" @@ -259,7 +260,7 @@ namespace snapper return files.getUndoStatistic(); } -#ifdef ENABLE_XATTRS + XAUndoStatistic Comparison::getXAUndoStatistic() const { @@ -268,7 +269,6 @@ namespace snapper return files.getXAUndoStatistic(); } -#endif vector diff --git a/snapper/Comparison.h b/snapper/Comparison.h index c0884c44..a99a8417 100644 --- a/snapper/Comparison.h +++ b/snapper/Comparison.h @@ -50,9 +50,7 @@ namespace snapper void umount() const; UndoStatistic getUndoStatistic() const; -#ifdef ENABLE_XATTRS XAUndoStatistic getXAUndoStatistic() const; -#endif vector getUndoSteps() const; diff --git a/snapper/Exception.h b/snapper/Exception.h index 39730359..5deadd99 100644 --- a/snapper/Exception.h +++ b/snapper/Exception.h @@ -75,13 +75,12 @@ namespace snapper const char* msg; }; -#ifdef ENABLE_XATTRS struct XAttributesException : public SnapperException { - explicit XAttributesException() throw() {} - virtual const char* what() const throw() { return "XAttributes error"; } + explicit XAttributesException() throw() {} + virtual const char* what() const throw() { return "XAttributes error"; } }; -#endif + } diff --git a/snapper/File.cc b/snapper/File.cc index 0f26d7db..bc40ba01 100644 --- a/snapper/File.cc +++ b/snapper/File.cc @@ -20,6 +20,8 @@ */ +#include "config.h" + #include #include #include @@ -29,7 +31,6 @@ #include #include -#include "config.h" #include "snapper/File.h" #include "snapper/Snapper.h" #include "snapper/AppUtil.h" @@ -38,10 +39,8 @@ #include "snapper/SnapperDefines.h" #include "snapper/Compare.h" #include "snapper/Exception.h" +#include "snapper/XAttributes.h" -#ifdef ENABLE_XATTRS -#include -#endif namespace snapper { @@ -528,7 +527,7 @@ namespace snapper return true; } -#ifdef ENABLE_XATTRS + bool File::modifyXattributes() { @@ -593,7 +592,7 @@ namespace snapper return xs; } -#endif + bool File::doUndo() @@ -630,6 +629,7 @@ namespace snapper error = true; } #endif + pre_to_system_status = (unsigned int) -1; post_to_system_status = (unsigned int) -1; diff --git a/snapper/File.h b/snapper/File.h index 74732975..19c3dc41 100644 --- a/snapper/File.h +++ b/snapper/File.h @@ -23,7 +23,7 @@ #ifndef SNAPPER_FILE_H #define SNAPPER_FILE_H -#include "config.h" + #include #include @@ -71,7 +71,7 @@ namespace snapper friend std::ostream& operator<<(std::ostream& s, const UndoStatistic& rs); }; -#ifdef ENABLE_XATTRS + struct XAUndoStatistic { XAUndoStatistic(): numCreate(0), numReplace(0), numDelete(0) {} @@ -82,7 +82,6 @@ namespace snapper friend XAUndoStatistic& operator+=(XAUndoStatistic&, const XAUndoStatistic&); }; -#endif struct UndoStep @@ -109,10 +108,8 @@ namespace snapper File(const FilePaths* file_paths, const string& name, unsigned int pre_to_post_status) : file_paths(file_paths), name(name), pre_to_post_status(pre_to_post_status), - pre_to_system_status(-1), post_to_system_status(-1), undo(false) -#ifdef ENABLE_XATTRS - ,xaCreated(0), xaDeleted(0), xaReplaced(0) -#endif + pre_to_system_status(-1), post_to_system_status(-1), undo(false), + xaCreated(0), xaDeleted(0), xaReplaced(0) {} const string& getName() const { return name; } @@ -133,9 +130,8 @@ namespace snapper friend std::ostream& operator<<(std::ostream& s, const File& file); -#ifdef ENABLE_XATTRS - XAUndoStatistic getXAUndoStatistic() const; -#endif + XAUndoStatistic getXAUndoStatistic() const; + private: bool createParentDirectories(const string& path) const; @@ -159,13 +155,12 @@ namespace snapper bool undo; -#ifdef ENABLE_XATTRS - bool modifyXattributes(); + bool modifyXattributes(); + + unsigned int xaCreated; + unsigned int xaDeleted; + unsigned int xaReplaced; - unsigned int xaCreated; - unsigned int xaDeleted; - unsigned int xaReplaced; -#endif }; @@ -202,9 +197,9 @@ namespace snapper vector getUndoSteps() const; bool doUndoStep(const UndoStep& undo_step); -#ifdef ENABLE_XATTRS + XAUndoStatistic getXAUndoStatistic() const; -#endif + protected: void push_back(File file) { entries.push_back(file); } diff --git a/snapper/FileUtils.cc b/snapper/FileUtils.cc index fa30a774..f693ede5 100644 --- a/snapper/FileUtils.cc +++ b/snapper/FileUtils.cc @@ -20,10 +20,13 @@ */ +#include "config.h" + #include #include #include #include +#include #include #include #include @@ -33,10 +36,6 @@ #include #include -#include "config.h" -#ifdef ENABLE_XATTRS - #include -#endif #include "snapper/FileUtils.h" #include "snapper/AppUtil.h" #include "snapper/Log.h" @@ -69,9 +68,7 @@ namespace snapper throw IOErrorException(); } -#ifdef ENABLE_XATTRS setXaStatus(); -#endif } @@ -97,9 +94,7 @@ namespace snapper throw IOErrorException(); } -#ifdef ENABLE_XATTRS xastatus = dir.xastatus; -#endif } @@ -113,9 +108,7 @@ namespace snapper throw IOErrorException(); } -#ifdef ENABLE_XATTRS xastatus = dir.xastatus; -#endif } @@ -132,9 +125,7 @@ namespace snapper throw IOErrorException(); } -#ifdef ENABLE_XATTRS xastatus = dir.xastatus; -#endif } return *this; @@ -399,8 +390,6 @@ namespace snapper } -#ifdef ENABLE_XATTRS - bool SDir::xaSupported() const { @@ -485,6 +474,7 @@ namespace snapper { xastatus = XA_UNKNOWN; +#ifdef ENABLE_XATTRS ssize_t ret = flistxattr(dirfd, NULL, 0); if (ret < 0) { @@ -503,9 +493,8 @@ namespace snapper { xastatus = XA_SUPPORTED; } - } - #endif + } bool @@ -599,8 +588,6 @@ namespace snapper } -#ifdef ENABLE_XATTRS - bool SFile::xaSupported() const { @@ -621,6 +608,4 @@ namespace snapper return dir.getxattr(SFile::name, name, value, size); } -#endif - } diff --git a/snapper/FileUtils.h b/snapper/FileUtils.h index eec9adc6..bccf31b0 100644 --- a/snapper/FileUtils.h +++ b/snapper/FileUtils.h @@ -23,7 +23,6 @@ #ifndef SNAPPER_FILE_UTILS_H #define SNAPPER_FILE_UTILS_H -#include "config.h" #include #include @@ -36,13 +35,12 @@ namespace snapper using std::string; using std::vector; -#ifdef ENABLE_XATTRS + enum XaAttrsStatus { XA_UNKNOWN, XA_UNSUPPORTED, XA_SUPPORTED }; -#endif /* @@ -93,12 +91,10 @@ namespace snapper int mktemp(string& name) const; -#ifdef ENABLE_XATTRS bool xaSupported() const; ssize_t listxattr(const string& path, char* list, size_t size) const; ssize_t getxattr(const string& path, const char* name, void* value, size_t size) const; -#endif bool mount(const string& device, const string& mount_type, unsigned long mount_flags, const string& mount_data) const; @@ -106,10 +102,8 @@ namespace snapper private: -#ifdef ENABLE_XATTRS XaAttrsStatus xastatus; void setXaStatus(); -#endif const string base_path; const string path; @@ -133,12 +127,10 @@ namespace snapper int open(int flags) const; int readlink(string& buf) const; -#ifdef ENABLE_XATTRS bool xaSupported() const; ssize_t listxattr(char* list, size_t size) const; ssize_t getxattr(const char* name, void* value, size_t size) const; -#endif private: diff --git a/snapper/Makefile.am b/snapper/Makefile.am index 83bd5797..335d885c 100644 --- a/snapper/Makefile.am +++ b/snapper/Makefile.am @@ -8,10 +8,6 @@ INCLUDES = -I/usr/include/libxml2 lib_LTLIBRARIES = libsnapper.la -if HAVE_XATTRS -TMP_XA = XAttributes.cc XAttributes.h -endif - libsnapper_la_SOURCES = \ Factory.cc Factory.h \ Snapper.cc Snapper.h \ @@ -23,6 +19,7 @@ libsnapper_la_SOURCES = \ Enum.cc Enum.h \ AppUtil.cc AppUtil.h \ FileUtils.cc FileUtils.h \ + XAttributes.cc XAttributes.h \ Log.cc Log.h \ Logger.cc Logger.h \ Compare.cc Compare.h \ diff --git a/snapper/XAttributes.cc b/snapper/XAttributes.cc index 3f65c6f4..756e0a03 100644 --- a/snapper/XAttributes.cc +++ b/snapper/XAttributes.cc @@ -27,16 +27,14 @@ #include #include #include - #include +#include #include "snapper/AppUtil.h" #include "snapper/Exception.h" #include "snapper/Log.h" #include "snapper/XAttributes.h" -#include - namespace snapper { diff --git a/snapper/XAttributes.h b/snapper/XAttributes.h index c74e000d..70482108 100644 --- a/snapper/XAttributes.h +++ b/snapper/XAttributes.h @@ -23,7 +23,6 @@ #include - #include #include #include