Permalink
Browse files

Removed dependency on glog. (#48)

All logging is now done by spdlog which is superior.
  • Loading branch information...
scudette committed Dec 28, 2017
1 parent 8ab7ca8 commit 546fdfe03d95d9d67a5d49abece0c959ceb9c9ff
Showing with 539 additions and 469 deletions.
  1. +12 −12 configure.ac
  2. +0 −1 m4/libtool.m4
  3. +0 −2 src/aff4_base.h
  4. +29 −30 src/aff4_directory.cc
  5. +2 −2 src/aff4_directory.h
  6. +24 −22 src/aff4_file.cc
  7. +67 −46 src/aff4_image.cc
  8. +62 −47 src/aff4_imager_utils.cc
  9. +8 −5 src/aff4_imager_utils.h
  10. +16 −17 src/aff4_map.cc
  11. +0 −2 src/aff4_registry.h
  12. +10 −13 src/aff4_symstream.h
  13. +1 −8 src/aff4imager.cc
  14. +30 −34 src/data_store.cc
  15. +58 −54 src/data_store.h
  16. +3 −1 src/lexicon.cc
  17. +3 −2 src/lexicon.h
  18. +69 −69 src/lexicon.inc
  19. +1 −7 src/libaff4-c.cc
  20. +23 −13 src/libaff4.cc
  21. +3 −1 src/libaff4.h
  22. +22 −11 src/rdf.cc
  23. +13 −4 src/rdf.h
  24. +78 −66 src/zip.cc
  25. +5 −0 src/zip.h
@@ -52,7 +52,7 @@ AC_CHECK_FUNCS([ftruncate localtime_r memset setenv])
# Only add these additional CFLAGS if we are using GCC. Other C compilers may
# not support them.
if test x"$GCC" == "xyes" ; then
AX_CHECK_COMPILE_FLAG([ -Wall -Wextra -Wpedantic -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare ],
AX_CHECK_COMPILE_FLAG([ -Wall -Wextra -Wpedantic -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare ],
[CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wpedantic -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare "])
fi
@@ -61,22 +61,22 @@ PKG_CHECK_MODULES([RAPTOR2], [raptor2], [], [AC_MSG_ERROR([raptor RDF library (l
PKG_CHECK_MODULES([UUID], [uuid], [AC_DEFINE([HAVE_LIBUUID], [1], ["Have UUID"])], [AC_MSG_ERROR([uuid library (uuid-dev) not found])])
PKG_CHECK_MODULES([ZLIB], [zlib], [], [AC_MSG_ERROR([zlib library (zlib1g-dev) not found])])
AC_CHECK_LIB([pcre++], [main], [], [AC_MSG_ERROR([pcre++ library (libpcre++-dev) not found])])
PKG_CHECK_MODULES([GLOG], [libglog], [], [AC_MSG_ERROR([Google Logging library (libgoogle-glog-dev) not found])])
AC_CHECK_LIB([snappy], [main], [], [AC_MSG_ERROR([Google Snappy Compression library (libsnappy-dev) not found])])
AC_CHECK_LIB([pthread], [pthread_create], [], [AC_MSG_ERROR([pthread library not found])])
#Check for cpp header only libs
PKG_CHECK_MODULES([TCLAP], [tclap], [], [AC_MSG_ERROR([The TCLAP flag parsing library (libtclap-dev) is not found])])
# configure options.
AC_ARG_WITH([yaml], [AS_HELP_STRING([--with-yaml], [Enable YAML support (default is no)])], [WITH_YAML=$withval], [WITH_YAML=no])
#AC_ARG_ENABLE([static-binaries], AS_HELP_STRING([--enable-static-binaries], [Build completely static binaries])
AC_ARG_WITH([yaml], [AS_HELP_STRING([--with-yaml], [Enable YAML support (default is no)])], [WITH_YAML=$withval], [WITH_YAML=no])
AC_ARG_ENABLE([static-binaries],
AS_HELP_STRING([--enable-static-binaries], [Build completely static binaries]))
# Check for optional libraries
AS_IF([test "x$WITH_YAML" = "xyes"],
[PKG_CHECK_MODULES([YAML_CPP], [yaml-cpp],
[AC_SUBST(HAVE_LIBYAML_CPP, [AFF4_HAS_LIBYAML_CPP])],
[AC_MSG_ERROR([libyaml-cpp library (libyamp-cpp-dev) not found])])]
[PKG_CHECK_MODULES([YAML_CPP], [yaml-cpp],
[AC_SUBST(HAVE_LIBYAML_CPP, [AFF4_HAS_LIBYAML_CPP])],
[AC_MSG_ERROR([libyaml-cpp library (libyamp-cpp-dev) not found])])]
)
# Setup doxygen if present.
@@ -92,9 +92,9 @@ URIPARSER_CHECK
# Set Makefile / config.h values.
AM_CONDITIONAL([HAVE_LIBYAML_CPP], [test "x$WITH_YAML" = "xyes"])
if test "x$WITH_YAML" = "xyes"; then
AC_DEFINE([AFF4_HAS_LIBYAML_CPP], [1], ["Enable Yaml Support"])
else
AC_MSG_NOTICE([yaml-cpp disabled])
AC_DEFINE([AFF4_HAS_LIBYAML_CPP], [1], ["Enable Yaml Support"])
else
AC_MSG_NOTICE([yaml-cpp disabled])
fi
AM_CONDITIONAL([GCC], test "$GCC" = yes) # let the Makefile know if we're gcc
AM_CONDITIONAL([STATIC_BUILD], [test x$enable_static_binaries = xyes])
@@ -105,8 +105,8 @@ AC_SUBST(SO_VERSION)
AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
AM_COND_IF([HAVE_DOXYGEN],
[AC_CONFIG_FILES([ docs/Doxyfile ])])
[AC_CONFIG_FILES([ docs/Doxyfile ])])
AC_CONFIG_FILES([
Makefile
src/Makefile
@@ -728,7 +728,6 @@ _LT_CONFIG_SAVE_COMMANDS([
cat <<_LT_EOF >> "$cfgfile"
#! $SHELL
# Generated automatically by $as_me ($PACKAGE) $VERSION
# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
# Provide generalized library-building support services.
@@ -55,8 +55,6 @@ specific language governing permissions and limitations under the License.
#include "lexicon.h"
#include "aff4_errors.h"
#include "rdf.h"
#include <glog/logging.h>
namespace aff4 {
@@ -16,7 +16,6 @@ specific language governing permissions and limitations under the License.
#include "config.h"
#include "libaff4.h"
#include <glog/logging.h>
#include "aff4_directory.h"
#include <sys/types.h>
@@ -40,18 +39,19 @@ AFF4ScopedPtr<AFF4Directory> AFF4Directory::NewAFF4Directory(
// If mode is truncate we need to clear the directory.
if (mode == "truncate") {
RemoveDirectory(root_path.c_str());
RemoveDirectory(resolver, root_path.c_str());
}
if (stat(root_path.c_str(), &s) < 0) {
if (mode == "truncate" || mode == "append") {
// Path does not exist. Try to create it.
if (MkDir(root_path.c_str()) != STATUS_OK) {
if (MkDir(resolver, root_path.c_str()) != STATUS_OK) {
return AFF4ScopedPtr<AFF4Directory>();
}
} else {
LOG(ERROR) << "Directory " << root_path << " does not exist, and "
"AFF4_STREAM_WRITE_MODE is not truncate";
resolver->logger->error(
"Directory {} does not exist, and "
"AFF4_STREAM_WRITE_MODE is not truncate", root_path);
return AFF4ScopedPtr<AFF4Directory>();
}
@@ -105,8 +105,8 @@ AFF4ScopedPtr<AFF4Stream> AFF4Directory::CreateMember(URN child) {
AFF4Status AFF4Directory::LoadFromURN() {
if (resolver->Get(urn, AFF4_STORED, storage) != STATUS_OK) {
LOG(ERROR) << "Unable to find storage for AFF4Directory " <<
urn.SerializeToString();
resolver->logger->error(
"Unable to find storage for AFF4Directory {}", urn);
return NOT_FOUND;
}
@@ -126,8 +126,7 @@ AFF4Status AFF4Directory::LoadFromURN() {
resolver->Set(urn, AFF4_TYPE, new URN(AFF4_DIRECTORY_TYPE));
resolver->Set(urn, AFF4_STORED, new URN(storage));
LOG(INFO) << "AFF4Directory volume found: " <<
urn.SerializeToString();
resolver->logger->info("AFF4Directory volume found: {}", urn);
}
}
@@ -146,8 +145,7 @@ AFF4Status AFF4Directory::LoadFromURN() {
AFF4Status res = resolver->LoadFromTurtle(*turtle_stream);
if (res != STATUS_OK) {
LOG(ERROR) << "Unable to parse " <<
turtle_stream->urn.SerializeToString();
resolver->logger->error("Unable to parse {} ", turtle_stream->urn);
return IO_ERROR;
}
@@ -158,7 +156,8 @@ AFF4Status AFF4Directory::LoadFromURN() {
if (resolver->Get(subject, AFF4_DIRECTORY_CHILD_FILENAME,
child_filename) == STATUS_OK) {
resolver->Set(subject, AFF4_FILE_NAME, new XSDString(
root_path + PATH_SEP_STR + child_filename.SerializeToString()));
root_path + PATH_SEP_STR +
child_filename.SerializeToString()));
}
}
@@ -229,7 +228,7 @@ bool AFF4Directory::IsDirectory(const URN& urn) {
// path: Absolute path of the directory that will be deleted
// The path must not be terminated with a path separator.
AFF4Status AFF4Directory::RemoveDirectory(const string& path) {
AFF4Status AFF4Directory::RemoveDirectory(DataStore *resolver, const string& path) {
WIN32_FIND_DATA ffd;
string search_str = path + PATH_SEP_STR + "*";
HANDLE hFind = INVALID_HANDLE_VALUE;
@@ -248,23 +247,23 @@ AFF4Status AFF4Directory::RemoveDirectory(const string& path) {
// Recurse into the subdir.
AFF4Status result = AFF4Directory::RemoveDirectory(
path + PATH_SEP_STR + ffd.cFileName);
resolver, path + PATH_SEP_STR + ffd.cFileName);
if (result != STATUS_OK) {
return result;
}
} else {
string filename = path + PATH_SEP_STR + ffd.cFileName;
LOG(INFO) << "Deleting file " << filename;
resolver->logger->info("Deleting file {}", filename);
if (!::DeleteFile(filename.c_str())) {
LOG(ERROR) << "Failed: " << GetLastErrorMessage();
resolver->logger->error("Failed: {}", GetLastErrorMessage());
return IO_ERROR;
}
}
} while (FindNextFile(hFind, &ffd) != 0);
LOG(INFO) << "Deleting directory " << path;
resolver->logger->info("Deleting directory {}", path);
if (!::RemoveDirectory(path.c_str())) {
LOG(ERROR) << "Failed: " << GetLastErrorMessage();
resolver->logger->error("Failed: {}", GetLastErrorMessage());
FindClose(hFind);
return IO_ERROR;
}
@@ -273,17 +272,17 @@ AFF4Status AFF4Directory::RemoveDirectory(const string& path) {
return STATUS_OK;
}
AFF4Status AFF4Directory::MkDir(const string& path) {
LOG(INFO) << "MkDir " << path;
AFF4Status AFF4Directory::MkDir(DataStore* resolver, const string& path) {
resolver->logger->info("MkDir {}", path);
if (!CreateDirectory(path.c_str(), nullptr)) {
DWORD res = GetLastError();
if (res == ERROR_ALREADY_EXISTS) {
return STATUS_OK;
}
LOG(ERROR) << "Cant create directory " << path << ": " <<
GetLastErrorMessage();
resolver->logger->error("Cant create directory {}: {}", path,
GetLastErrorMessage());
return IO_ERROR;
}
@@ -301,17 +300,17 @@ bool AFF4Directory::IsDirectory(const string& filename) {
char last = *(filename.rbegin());
result |= (last == '/' || last == '\\');
LOG(INFO) << "IsDirectory " << filename << ": " << result;
resolver->logger->info("IsDirectory {}: {}", filename, result);
return result;
}
#else
AFF4Status AFF4Directory::MkDir(const std::string& path) {
AFF4Status AFF4Directory::MkDir(DataStore *resolver, const std::string& path) {
if (mkdir(path.c_str(), 0777) < 0) {
LOG(ERROR) << "Failed to create directory " << path.c_str() <<
" : " << GetLastErrorMessage();
resolver->logger->error("Failed to create directory {}: {}", path,
GetLastErrorMessage());
return IO_ERROR;
}
return STATUS_OK;
@@ -335,7 +334,7 @@ bool AFF4Directory::IsDirectory(const std::string& filename) {
// Recursively remove all files and subdirectories in the directory.
AFF4Status AFF4Directory::RemoveDirectory(const std::string& path) {
AFF4Status AFF4Directory::RemoveDirectory(DataStore *resolver, const std::string& path) {
DIR* dir;
std::string dirname = path;
@@ -358,14 +357,14 @@ AFF4Status AFF4Directory::RemoveDirectory(const std::string& path) {
switch (ent->d_type) {
case DT_REG: {
LOG(INFO) << "Removing file " << full_path.c_str();
resolver->logger->info("Removing file {}", full_path);
unlink(full_path.c_str());
}
break;
case DT_DIR: {
AFF4Status result = AFF4Directory::RemoveDirectory(full_path);
LOG(INFO) << "Removing directory " << full_path;
AFF4Status result = AFF4Directory::RemoveDirectory(resolver, full_path);
resolver->logger->info("Removing directory {}", full_path);
rmdir(full_path.c_str());
closedir(dir);
return result;
@@ -60,10 +60,10 @@ class AFF4Directory: public AFF4Volume {
virtual AFF4Status Flush();
// Some handy static methods.
static AFF4Status RemoveDirectory(const std::string& root_path);
static bool IsDirectory(const URN& urn);
static bool IsDirectory(const std::string& filename);
static AFF4Status MkDir(const std::string& path);
static AFF4Status RemoveDirectory(DataStore *resolver, const std::string& root_path);
static AFF4Status MkDir(DataStore *resolver, const std::string& path);
};
void aff4_directory_init();
Oops, something went wrong.

0 comments on commit 546fdfe

Please sign in to comment.