diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..58f9066 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,129 @@ +PROJECT(aff4-cpp-lite) + +CMAKE_MINIMUM_REQUIRED(VERSION 3.0) + +FIND_PACKAGE(Raptor2 REQUIRED) + +FIND_PACKAGE(Snappy REQUIRED) + +FIND_PACKAGE(ZLIB REQUIRED) + +FIND_PACKAGE(OpenSSL REQUIRED) + +FIND_PACKAGE(LZ4 REQUIRED) + +add_definitions(-DUNICODE -DLIBAFF4_EXPORTS=0 -DRAPTOR_STATIC) + +SET(SOURCES + win32/libaff4/aff4config.h + win32/libaff4/src/stdafx.h + + src/aff4.cc + src/aff4-c.cc + src/AFF4Lexicon.cc + src/RDFValue.cc + src/AFF4Containers.cc + + src/utils/StringUtil.cc src/utils/StringUtil.h + src/utils/FileUtil.h + src/utils/Cache.h + src/utils/PortableEndian.h + src/rdf/Model.cc src/rdf/Model.h + src/resource/AFF4Resource.cc src/resource/AFF4Resource.h + src/zip/Zip.cc src/zip/Zip.h + src/zip/ZipStream.cc src/zip/ZipStream.h + src/container/AFF4ZipContainer.cc src/container/AFF4ZipContainer.h + src/image/AFF4Image.cc src/image/AFF4Image.h + src/stream/ImageStreamFactory.cc src/stream/ImageStreamFactory.h + src/stream/RepeatedImageStream.cc src/stream/RepeatedImageStream.h + src/stream/SymbolicImageStream.cc src/stream/SymbolicImageStream.h + src/stream/ImageStream.cc src/stream/ImageStream.h + src/stream/MapStream.cc src/stream/MapStream.h + src/stream/struct/BevvyIndex.cc src/stream/struct/BevvyIndex.h + src/stream/struct/BevvyIndexLoader.cc src/stream/struct/BevvyIndexLoader.h + src/stream/struct/ChunkLoader.cc src/stream/struct/ChunkLoader.h + src/stream/struct/ImageStreamPoint.h + src/stream/struct/MapEntryPoint.h + src/map/AFF4Map.cc src/map/AFF4Map.h + src/codec/CompressionCodec.cc src/codec/CompressionCodec.h + src/codec/NullCompression.cc src/codec/NullCompression.h + src/codec/DeflateCompression.cc src/codec/DeflateCompression.h + src/codec/ZlibCompression.cc src/codec/ZlibCompression.h + src/codec/LZ4Compression.cc src/codec/LZ4Compression.h + src/codec/SnappyCompression.cc src/codec/SnappyCompression.h + src/resolver/LightResolver.cc src/resolver/LightResolver.h +) + +ADD_LIBRARY(aff4-cpp-lite ${SOURCES}) + +target_include_directories(aff4-cpp-lite PUBLIC + win32/libaff4/src + win32/libaff4 + + src + src/codec + src/container + src/image + src/map + src/rdf + src/resolver + src/resource + src/stream + src/stream/struct + src/utils + src/zip +) + +TARGET_LINK_LIBRARIES(aff4-cpp-lite PRIVATE Raptor2) +TARGET_LINK_LIBRARIES(aff4-cpp-lite PRIVATE Snappy) +TARGET_LINK_LIBRARIES(aff4-cpp-lite PRIVATE OpenSSL) +TARGET_LINK_LIBRARIES(aff4-cpp-lite PRIVATE ZLIB) +TARGET_LINK_LIBRARIES(aff4-cpp-lite PRIVATE LZ4::LZ4) + +FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libaff4.pc +"prefix=${CMAKE_INSTALL_PREFIX} +exec_prefix=\${prefix} +libdir=\${exec_prefix}/${CMAKE_INSTALL_LIBDIR} +includedir=\${prefix}/${CMAKE_INSTALL_INCLUDEDIR} + +Name: aff4-cpp-lite library +Description: aff4-cpp-lite library +Version: ${VERSION} +Libs: -L\${libdir} -libaff4 +Cflags: -I\${includedir} +") + +SET(INSTALL_HEADERS + ${CMAKE_CURRENT_BINARY_DIR}/src/aff4.h + ${CMAKE_CURRENT_BINARY_DIR}/src/aff4-c.h + ${CMAKE_CURRENT_BINARY_DIR}/src/AFF4Containers.h + ${CMAKE_CURRENT_BINARY_DIR}/src/AFF4Defaults.h + ${CMAKE_CURRENT_BINARY_DIR}/src/AFF4Lexicon.h + ${CMAKE_CURRENT_BINARY_DIR}/src/IAFF4Container.h + ${CMAKE_CURRENT_BINARY_DIR}/src/IAFF4Image.h + ${CMAKE_CURRENT_BINARY_DIR}/src/IAFF4Map.h + ${CMAKE_CURRENT_BINARY_DIR}/src/IAFF4Resolver.h + ${CMAKE_CURRENT_BINARY_DIR}/src/IAFF4Resource.h + ${CMAKE_CURRENT_BINARY_DIR}/src/IAFF4Stream.h + ${CMAKE_CURRENT_BINARY_DIR}/src/RDFValue.h +) + +if (WIN32) + SET(INSTALL_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/win32/libaff4/src/stdafx.h + ${CMAKE_CURRENT_SOURCE_DIR}/win32/libaff4/src/targetver.h + ${INSTALL_HEADERS} + ) +endif() + +INSTALL(FILES + ${INSTALL_HEADERS} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + +INSTALL( + TARGETS aff4-cpp-lite + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) \ No newline at end of file diff --git a/src/AFF4Containers.cc b/src/AFF4Containers.cc index bd06a53..26fb755 100644 --- a/src/AFF4Containers.cc +++ b/src/AFF4Containers.cc @@ -48,7 +48,7 @@ namespace aff4 { * @throws std::system_error If opening the file failed. */ std::shared_ptr openContainer(const std::string& filename) noexcept { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : %s \n", __FILE__, __LINE__, filename.c_str()); #endif /* @@ -56,7 +56,7 @@ namespace aff4 { */ if (!aff4::util::isFile(filename)) { // failed. -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : %s is NOT a file.\n", __FILE__, __LINE__, filename.c_str()); #endif return nullptr; @@ -67,7 +67,7 @@ namespace aff4 { */ if (!isAFF4Container(filename)) { // failed. -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : %s does not have .af4 or .aff4 extension\n", __FILE__, __LINE__, filename.c_str()); #endif return nullptr; @@ -76,7 +76,7 @@ namespace aff4 { std::string resource = getResourceID(filename); if (resource.empty()) { // No resource? -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : %s does not have a resource ID\n", __FILE__, __LINE__, filename.c_str()); #endif return nullptr; @@ -90,7 +90,7 @@ namespace aff4 { * failed, actually, we should never see this, unless the file has been removed between the last * getResourceID() call and reopening it here. */ -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : %s has NO entries?\n", __FILE__, __LINE__, filename.c_str()); #endif return nullptr; @@ -129,7 +129,7 @@ namespace aff4 { int fileHandle = ::open(filename.c_str(), O_RDONLY | O_LARGEFILE); if (fileHandle == -1) { // we failed, so return nothing. (error will be in errno). -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Unable to open container : %s \n", __FILE__, __LINE__, filename.c_str()); #endif return ""; @@ -137,7 +137,7 @@ namespace aff4 { int read = ::pread64(fileHandle, buffer.get(), AFF4_RESOURCE_BUFFER_SIZE, 0); ::close(fileHandle); if (read != AFF4_RESOURCE_BUFFER_SIZE) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Unable to read %d bytes from the container : %s = %d \n", __FILE__, __LINE__, AFF4_RESOURCE_BUFFER_SIZE, filename.c_str(), read); #endif return ""; @@ -150,7 +150,7 @@ namespace aff4 { std::wstring wpath = aff4::util::s2ws(filename); // Convert the filename to UTF-16/WString for Win32 API HANDLE fileHandle = CreateFile(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); if (fileHandle == INVALID_HANDLE_VALUE) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Unable to open container : %s \n", __FILE__, __LINE__, filename.c_str()); #endif return ""; @@ -159,7 +159,7 @@ namespace aff4 { BOOL res = ReadFile(fileHandle, buffer.get(), AFF4_RESOURCE_BUFFER_SIZE, &read, NULL); ::CloseHandle(fileHandle); if (res == FALSE || read != AFF4_RESOURCE_BUFFER_SIZE) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Unable to read %d bytes from the container : %s = %d \n", __FILE__, __LINE__, AFF4_RESOURCE_BUFFER_SIZE, filename.c_str(), read); #endif return ""; @@ -174,19 +174,19 @@ namespace aff4 { aff4::zip::structs::ZipFileHeader* header = (aff4::zip::structs::ZipFileHeader*)(buffer.get()); // Start sanity check. if (header->magic != 0x4034b50) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Invalid PKZIP Magic number : %s = 0x%x \n", __FILE__, __LINE__, filename.c_str(), header->magic); #endif return ""; } if (header->compression_method != 0) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Invalid PKZIP compression method : %s = %d \n", __FILE__, __LINE__, filename.c_str(), header->compression_method); #endif goto slowPath; } if (header->file_name_length != 0x15) { // 'container.description' -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Invalid segment name length : %s = %d != 0x15\n", __FILE__, __LINE__, filename.c_str(), header->file_name_length); #endif goto slowPath; @@ -195,7 +195,7 @@ namespace aff4 { filenameLength = le16toh(header->file_name_length); segmentName = std::string((char*)(buffer.get() + sizeof(aff4::zip::structs::ZipFileHeader)), filenameLength); if (segmentName.compare(AFF4_FILEDESCRIPTOR) != 0) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Invalid segment name : %s = %s\n", __FILE__, __LINE__, filename.c_str(), segmentName.c_str()); #endif goto slowPath; @@ -252,7 +252,7 @@ namespace aff4 { if ((segmentEntrySize == 0) || // (segmentEntrySize > (AFF4_RESOURCE_BUFFER_SIZE - (sizeof(aff4::zip::structs::ZipFileHeader) - header->file_name_length - header->extra_field_len)))) { // Too large... -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Segment appears too large for container.description? : %s \n", __FILE__, __LINE__, filename.c_str()); #endif goto slowPath; @@ -310,7 +310,7 @@ namespace aff4 { } aff4::IAFF4Resolver* createResolver(std::string path, bool scanSubFolders) noexcept { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create Resolver : %s, %d \n", __FILE__, __LINE__, path.c_str(), scanSubFolders); #endif if (path.empty()) { @@ -326,7 +326,7 @@ namespace aff4 { * See if it exists. */ if (!aff4::util::fileExists(path)) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create Resolver Path doesn't exist? %s, %d \n", __FILE__, __LINE__, path.c_str(), scanSubFolders); #endif return nullptr; diff --git a/src/AFF4Lexicon.cc b/src/AFF4Lexicon.cc index 372dd4f..030360e 100644 --- a/src/AFF4Lexicon.cc +++ b/src/AFF4Lexicon.cc @@ -117,7 +117,7 @@ std::string getLexiconString(aff4::Lexicon lexicon) noexcept { aff4::Lexicon getLexicon(const std::string& lexicon) noexcept { if (lexicon.length() == 0) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Unknown lexicon? %s\n", __FILE__, __LINE__, lexicon.c_str()); #endif return Lexicon::UNKNOWN; @@ -127,7 +127,7 @@ aff4::Lexicon getLexicon(const std::string& lexicon) noexcept { return it->first; } } -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Unknown lexicon? %s\n", __FILE__, __LINE__,lexicon.c_str()); #endif return Lexicon::UNKNOWN; diff --git a/src/RDFValue.cc b/src/RDFValue.cc index 7ecdb71..5b2bb75 100644 --- a/src/RDFValue.cc +++ b/src/RDFValue.cc @@ -55,7 +55,7 @@ static const std::map aff4Mappings = { // }; XSDType getType(const std::string& type) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Determine XSD type: %s\n", __FILE__, __LINE__, type.c_str()); #endif if (type.empty()) { @@ -70,7 +70,7 @@ XSDType getType(const std::string& type) { } aff4::Lexicon getAFF4Type(const std::string& type) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Determine AFF4 Data type: %s\n", __FILE__, __LINE__, type.c_str()); #endif if (type.empty()) { @@ -80,7 +80,7 @@ aff4::Lexicon getAFF4Type(const std::string& type) { if (it != aff4Mappings.end()) { return it->second; } -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Unknown AFF4 type? %s\n", __FILE__, __LINE__, type.c_str()); #endif // Default as unknown. @@ -129,7 +129,7 @@ time_t my_timegm(register struct tm * t) } std::chrono::system_clock::time_point getTime(const std::string& value) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Convert XSDDateTime: %s\n", __FILE__, __LINE__, value.c_str()); #endif // The time format should be RFC3339 diff --git a/src/codec/CompressionCodec.cc b/src/codec/CompressionCodec.cc index 9f33390..4708d9c 100644 --- a/src/codec/CompressionCodec.cc +++ b/src/codec/CompressionCodec.cc @@ -34,34 +34,34 @@ std::shared_ptr getCodec(aff4::Lexicon resource, uint32_t chun switch (resource) { case Lexicon::AFF4_IMAGE_COMPRESSION_SNAPPY: case Lexicon::AFF4_IMAGE_COMPRESSION_SNAPPY2: -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create Snappy Decompressor \n", __FILE__, __LINE__); #endif return std::make_shared(chunkSize); case Lexicon::AFF4_IMAGE_COMPRESSION_LZ4: -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create LZ4 Decompressor \n", __FILE__, __LINE__); #endif return std::make_shared(chunkSize); case Lexicon::AFF4_IMAGE_COMPRESSION_DEFLATE: -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create Deflate Decompressor \n", __FILE__, __LINE__); #endif return std::make_shared(chunkSize); case Lexicon::AFF4_IMAGE_COMPRESSION_STORED: -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create Stored Decompressor \n", __FILE__, __LINE__); #endif return std::make_shared(chunkSize); case Lexicon::AFF4_IMAGE_COMPRESSION_ZLIB: -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create ZLib Decompressor \n", __FILE__, __LINE__); #endif return std::make_shared(chunkSize); default: break; } -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Unknown Compression Codec : %s\n", __FILE__, __LINE__, aff4::lexicon::getLexiconString(resource).c_str()); #endif diff --git a/src/codec/SnappyCompression.cc b/src/codec/SnappyCompression.cc index 22ab3eb..c755c07 100644 --- a/src/codec/SnappyCompression.cc +++ b/src/codec/SnappyCompression.cc @@ -36,7 +36,7 @@ uint64_t SnappyCompression::decompress(void* source, uint64_t srcSize, void* des if (snappy::RawUncompress((char*) source, srcSize, (char*) destination)) { return destSize; } else { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Snappy decompression failure\n", __FILE__, __LINE__); #endif return 0; diff --git a/src/container/AFF4ZipContainer.cc b/src/container/AFF4ZipContainer.cc index 5988dc9..4521870 100644 --- a/src/container/AFF4ZipContainer.cc +++ b/src/container/AFF4ZipContainer.cc @@ -22,7 +22,7 @@ namespace container { AFF4ZipContainer::AFF4ZipContainer(const std::string& resource, std::unique_ptr parent) : AFF4Resource(resource), parent(std::move(parent)) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : New AFF4 Zip Container: %s : %s \n", __FILE__, __LINE__, this->parent->getFilename().c_str(), resource.c_str()); #endif @@ -79,19 +79,19 @@ void AFF4ZipContainer::loadVersionInformation() noexcept { if (!line.empty()) { if (aff4::util::hasPrefix(line, MAJOR)) { addProperty(aff4::Lexicon::AFF4_MAJOR_VERSION, aff4::rdf::RDFValue(line.substr(MAJOR.size()))); -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Major Version : %s\n", __FILE__, __LINE__, line.substr(MAJOR.size()).c_str()); #endif } else if (aff4::util::hasPrefix(line, MINOR)) { addProperty(aff4::Lexicon::AFF4_MINOR_VERSION, aff4::rdf::RDFValue(line.substr(MINOR.size()))); -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Minor Version : %s\n", __FILE__, __LINE__, line.substr(MINOR.size()).c_str()); #endif } else if (aff4::util::hasPrefix(line, TOOL)) { addProperty(aff4::Lexicon::AFF4_TOOL, aff4::rdf::RDFValue(line.substr(TOOL.size()))); -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Tool Version : %s\n", __FILE__, __LINE__, line.substr(TOOL.size()).c_str()); #endif @@ -100,7 +100,7 @@ void AFF4ZipContainer::loadVersionInformation() noexcept { } } } else { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : version.txt file is missing from container? : %s\n", __FILE__, __LINE__, parent->getFilename().c_str()); #endif @@ -147,7 +147,7 @@ int64_t AFF4ZipContainer::fileRead(void *buf, uint64_t count, uint64_t offset) n } std::shared_ptr AFF4ZipContainer::getImageStream(const std::string& resource) noexcept { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : aff4:ImageStream : %s \n", __FILE__, __LINE__, resource.c_str()); #endif // No stream resource @@ -207,7 +207,7 @@ std::shared_ptr AFF4ZipContainer::getImageStream(const std::string& std::string AFF4ZipContainer::sanitizeResource(const std::string& resource) noexcept { std::string res = resource; -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : sanitize Resource: %s\n", __FILE__, __LINE__, res.c_str()); #endif @@ -224,7 +224,7 @@ std::string AFF4ZipContainer::sanitizeResource(const std::string& resource) noex while (aff4::util::hasPrefix(res, "/")) { res = res.substr(1); } -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : sanitized Resource: %s\n", __FILE__, __LINE__, res.c_str()); #endif return res; @@ -283,7 +283,7 @@ void AFF4ZipContainer::close() noexcept { * From IAFF4Resolver */ std::shared_ptr AFF4ZipContainer::open(const std::string& resource) noexcept { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : open %s\n", __FILE__, __LINE__, resource.c_str()); #endif if (resource.empty()) { @@ -293,7 +293,7 @@ std::shared_ptr AFF4ZipContainer::open(const std::string& r // See if the request is for an aff4::image in us. std::shared_ptr image = getImage(resource); if (image != nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Found Resource %s = %s\n", __FILE__, __LINE__, resource.c_str(), aff4::lexicon::getLexiconString(image->getBaseType()).c_str()); #endif @@ -303,7 +303,7 @@ std::shared_ptr AFF4ZipContainer::open(const std::string& r // See if the request is for a aff4::map in us. std::shared_ptr map = getMap(resource); if (map != nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Found Resource %s = %s\n", __FILE__, __LINE__, resource.c_str(), aff4::lexicon::getLexiconString(map->getBaseType()).c_str()); #endif @@ -313,7 +313,7 @@ std::shared_ptr AFF4ZipContainer::open(const std::string& r // See if the request is for a aff4::map in us. std::shared_ptr stream = getImageStream(resource); if (stream != nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Found Resource %s = %s\n", __FILE__, __LINE__, resource.c_str(), aff4::lexicon::getLexiconString(stream->getBaseType()).c_str()); #endif @@ -323,7 +323,7 @@ std::shared_ptr AFF4ZipContainer::open(const std::string& r // See if a zip segment. stream = getSegment(resource); if (stream != nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Found Resource %s = %s\n", __FILE__, __LINE__, resource.c_str(), aff4::lexicon::getLexiconString(stream->getBaseType()).c_str()); #endif @@ -334,14 +334,14 @@ std::shared_ptr AFF4ZipContainer::open(const std::string& r } bool AFF4ZipContainer::hasResource(const std::string& resource) noexcept { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : hasResource %s\n", __FILE__, __LINE__, resource.c_str()); #endif std::shared_ptr res = open(resource); if (res == nullptr) { return false; } -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Found Resource %s = %s\n", __FILE__, __LINE__, resource.c_str(), aff4::lexicon::getLexiconString(res->getBaseType()).c_str()); #endif diff --git a/src/image/AFF4Image.cc b/src/image/AFF4Image.cc index c957795..5d956f0 100644 --- a/src/image/AFF4Image.cc +++ b/src/image/AFF4Image.cc @@ -22,7 +22,7 @@ namespace image { AFF4Image::AFF4Image(const std::string& resource, aff4::container::AFF4ZipContainer* parent) : AFF4Resource(resource), parent(parent) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create Image? %s\n", __FILE__, __LINE__, resource.c_str()); #endif std::shared_ptr model = parent->getRDFModel(); @@ -72,7 +72,7 @@ AFF4Image::~AFF4Image() { std::shared_ptr AFF4Image::getMap() noexcept { // Find our dependentStream instance. -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Open Map for Image. %s\n", __FILE__, __LINE__, getResourceID().c_str()); #endif std::vector values = getProperty(aff4::Lexicon::AFF4_DATASTREAM); @@ -92,7 +92,7 @@ std::shared_ptr AFF4Image::getMap() noexcept { } } } -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : No Map Stream found for %s \n", __FILE__, __LINE__, getResourceID().c_str()); #endif return nullptr; diff --git a/src/map/AFF4Map.cc b/src/map/AFF4Map.cc index d6531f1..e93caa8 100644 --- a/src/map/AFF4Map.cc +++ b/src/map/AFF4Map.cc @@ -22,7 +22,7 @@ namespace map { AFF4Map::AFF4Map(const std::string& resource, aff4::container::AFF4ZipContainer* parent) : AFF4Resource(resource), parent(parent), length(0), unknownOverride(nullptr), mapGapStreamOverride(nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create Map %s \n", __FILE__, __LINE__, getResourceID().c_str()); #endif @@ -52,7 +52,7 @@ AFF4Map::AFF4Map(const std::string& resource, aff4::container::AFF4ZipContainer* } } } -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Map Length %" PRIu64 " (%" PRIx64 ")\n", __FILE__, __LINE__, length, length); #endif @@ -73,7 +73,7 @@ AFF4Map::AFF4Map(const std::string& resource, aff4::container::AFF4ZipContainer* if (mapGapStreamOverride == nullptr) { mapGapStreamOverride = aff4::stream::createZeroStream(); } -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : mapGapDefaultStream = %s\n", __FILE__, __LINE__, mapGapStreamOverride->getResourceID().c_str()); #endif values = getProperty(aff4::Lexicon::AFF4_DEPENDENT_STREAM); @@ -99,7 +99,7 @@ AFF4Map::AFF4Map(const std::string& resource, aff4::container::AFF4ZipContainer* std::vector streams; while (std::getline(data, line, '\n')) { if (!line.empty()) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : IDX Stream : %s\n", __FILE__, __LINE__, line.c_str()); #endif /* diff --git a/src/rdf/Model.cc b/src/rdf/Model.cc index 683d69e..b936faf 100644 --- a/src/rdf/Model.cc +++ b/src/rdf/Model.cc @@ -146,7 +146,7 @@ std::unique_ptr Model::getValueFromRaptorTerm(aff4::Lexicon break; } } catch (...) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : RDFValue construction failed? %d : %s\n", __FILE__, __LINE__, type, value_string.c_str()); #endif @@ -176,7 +176,7 @@ void Model::statementHandler(raptor_statement* statement) { // Get the value. std::unique_ptr v = getValueFromRaptorTerm(property, statement->object); if (v != nullptr) { -#if DEBUG +#if DEBUG_VERBOSE raptor_statement_print_as_ntriples(statement, aff4::getDebugOutput()); fprintf(aff4::getDebugOutput(), "\n%s[%d] :%s : %s : %s\n", __FILE__, __LINE__, subjectURN.c_str(), propertryURN.c_str(), v->toString().c_str()); diff --git a/src/resolver/LightResolver.cc b/src/resolver/LightResolver.cc index 0cfdf22..ccdb377 100644 --- a/src/resolver/LightResolver.cc +++ b/src/resolver/LightResolver.cc @@ -26,7 +26,7 @@ LightResolver::LightResolver(const std::string& resource, const std::string& pat // Single property. addProperty(aff4::Lexicon::AFF4_FILENAME, aff4::rdf::RDFValue(path)); -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : LightResolver: %s\n", __FILE__, __LINE__, resource.c_str()); #endif // refresh @@ -42,7 +42,7 @@ LightResolver::~LightResolver() { * From IAFF4Resolver */ std::shared_ptr LightResolver::open(const std::string& resource) noexcept { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Open Resource %s\n", __FILE__, __LINE__, resource.c_str()); #endif if (hasResource(resource)) { @@ -60,7 +60,7 @@ std::shared_ptr LightResolver::open(const std::string& reso } bool LightResolver::hasResource(const std::string& resource) noexcept { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Has Resource %s\n", __FILE__, __LINE__, resource.c_str()); #endif if (resource.empty()) { @@ -93,7 +93,7 @@ void LightResolver::scanForAFF4Volumes(const std::string& path) { if (path.empty()) { return; } -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Scanning Path %s\n", __FILE__, __LINE__, path.c_str()); #endif #ifdef _WIN32 @@ -117,7 +117,7 @@ void LightResolver::scanForAFF4Volumes(const std::string& path) { // We don't have this file std::string resID = aff4::container::getResourceID(absoluteFilename); if (!resID.empty()) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Adding Volume %s => %s \n", __FILE__, __LINE__, resID.c_str(), absoluteFilename.c_str()); #endif volumes[resID] = absoluteFilename; @@ -148,7 +148,7 @@ void LightResolver::scanForAFF4Volumes(const std::string& path) { // We don't have this file std::string resID = aff4::container::getResourceID(absoluteFilename); if (!resID.empty()) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Adding Volume %s => %s \n", __FILE__, __LINE__, resID.c_str(), absoluteFilename.c_str()); #endif volumes[resID] = absoluteFilename; diff --git a/src/stream/ImageStream.cc b/src/stream/ImageStream.cc index a0fa755..f02b059 100644 --- a/src/stream/ImageStream.cc +++ b/src/stream/ImageStream.cc @@ -26,7 +26,7 @@ ImageStream::ImageStream(const std::string& resource, aff4::container::AFF4ZipCo AFF4Resource(resource), parent(parent), closed(false), length(0), chunkSize(AFF4_DEFAULT_CHUNK_SIZE), chunksInSegment( AFF4_DEFAULT_CHUNKS_PER_SEGMENT) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Create Image Stream %s \n", __FILE__, __LINE__, getResourceID().c_str()); #endif @@ -53,7 +53,7 @@ ImageStream::ImageStream(const std::string& resource, aff4::container::AFF4ZipCo length = values[0].getInteger(); } } -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Length %" PRIu64 " (%" PRIx64 ") \n", __FILE__, __LINE__, length, length); #endif // Get the chunksize @@ -71,7 +71,7 @@ ImageStream::ImageStream(const std::string& resource, aff4::container::AFF4ZipCo } } } -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : ChunkSize %" PRIu32 " (%" PRIx32 ")\n", __FILE__, __LINE__, chunkSize, chunkSize); #endif // Get the chunksInSegments value. @@ -89,7 +89,7 @@ ImageStream::ImageStream(const std::string& resource, aff4::container::AFF4ZipCo } } } -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : ChunksInSegment %" PRIu32 " (%" PRIx32 ") \n", __FILE__, __LINE__, chunksInSegment, chunksInSegment); #endif // Get the compression algorithm @@ -112,7 +112,7 @@ ImageStream::ImageStream(const std::string& resource, aff4::container::AFF4ZipCo close(); return; } -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Compression %s \n", __FILE__, __LINE__, codec->getResourceID().c_str()); #endif @@ -140,7 +140,7 @@ ImageStream::ImageStream(const std::string& resource, aff4::container::AFF4ZipCo // determine cache size; uint64_t cacheSize = aff4::stream::getImageStreamCacheSize() / chunkSize; -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Number of Chunk Cache Entries %" PRIu64 " \n", __FILE__, __LINE__, cacheSize); #endif chunkCache = std::make_shared>(cacheSize, chunkLoaderFunction); @@ -156,7 +156,7 @@ uint64_t ImageStream::size() noexcept { void ImageStream::close() noexcept { if (!closed.exchange(true)) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Close aff4:ImageStream %s \n", __FILE__, __LINE__, getResourceID().c_str()); #endif parent = nullptr; @@ -175,7 +175,7 @@ inline uint64_t floor(uint64_t offset, uint64_t size) { int64_t ImageStream::read(void *buf, uint64_t count, uint64_t offset) noexcept { if (closed) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Reading %" PRIu64 " : %" PRIu64 " on Closed Stream \n", __FILE__, __LINE__, offset, count); #endif errno = EPERM; @@ -183,7 +183,7 @@ int64_t ImageStream::read(void *buf, uint64_t count, uint64_t offset) noexcept { } // If offset beyond end, return. if (offset > size()) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Reading %" PRIu64 " : %" PRIu64 "? Offset Greater than Stream size \n", __FILE__, __LINE__, offset, count); #endif return 0; @@ -193,7 +193,7 @@ int64_t ImageStream::read(void *buf, uint64_t count, uint64_t offset) noexcept { count -= ((offset + count) - size()); } -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Reading %" PRIx64 " : %" PRIx64 " \n", __FILE__, __LINE__, offset, count); #endif @@ -210,7 +210,7 @@ int64_t ImageStream::read(void *buf, uint64_t count, uint64_t offset) noexcept { cacheBuffer_t entry = chunkCache->get(chunkOffset); if (entry.second == 0) { // failed to read. -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Reading %" PRIx64 " : %" PRIx64 " => %" PRIx64 " FAILED READ \n", __FILE__, __LINE__, offset, count, chunkOffset); #endif return -1; @@ -225,7 +225,7 @@ int64_t ImageStream::read(void *buf, uint64_t count, uint64_t offset) noexcept { leftToRead -= toCopy; buffer += toCopy; } -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Completed Read %" PRIx64 " : %" PRIx64 " => %" PRIx64 " \n", __FILE__, __LINE__, offset - actualRead, count, actualRead); #endif return actualRead; diff --git a/src/stream/ImageStreamFactory.cc b/src/stream/ImageStreamFactory.cc index d81c924..d4ddc6c 100644 --- a/src/stream/ImageStreamFactory.cc +++ b/src/stream/ImageStreamFactory.cc @@ -20,42 +20,42 @@ namespace aff4 { namespace stream { std::shared_ptr createZeroStream() { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create aff4:Zero stream \n", __FILE__, __LINE__); #endif return std::make_shared(aff4::lexicon::getLexiconString(aff4::Lexicon::AFF4_IMAGESTREAM_ZERO), (uint8_t) 0); } std::shared_ptr createUnknownStream() { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create aff4:Unknown stream \n", __FILE__, __LINE__); #endif return std::make_shared(aff4::lexicon::getLexiconString(aff4::Lexicon::AFF4_IMAGESTREAM_UNKNOWN), "UNKNOWN"); } std::shared_ptr createUnknownStream(const std::string& resource) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create aff4:Unknown stream with Resource %s \n", __FILE__, __LINE__, resource.c_str()); #endif return std::make_shared(resource, "UNKNOWN"); } std::shared_ptr createUnreadableStream() { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create aff4:Unreadable stream \n", __FILE__, __LINE__); #endif return std::make_shared(aff4::lexicon::getLexiconString(aff4::Lexicon::AFF4_IMAGESTREAM_UNREADABLE), "UNREADABLEDATA"); } std::shared_ptr createSymbolicStream(const std::string& resource) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create aff4:Symbolic stream %s \n", __FILE__, __LINE__, resource.c_str()); #endif return std::make_shared(resource); } std::shared_ptr createSymbolicStream(uint8_t symbol) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Create aff4:Symbolic stream %02X \n", __FILE__, __LINE__, symbol); #endif std::string resource = aff4::lexicon::getLexiconString(aff4::Lexicon::AFF4_IMAGESTREAM_SYMBOLIC_PREFIX); diff --git a/src/stream/MapStream.cc b/src/stream/MapStream.cc index f067f91..27497b3 100644 --- a/src/stream/MapStream.cc +++ b/src/stream/MapStream.cc @@ -50,7 +50,7 @@ uint64_t MapStream::size() noexcept { void MapStream::close() noexcept { if (!closed.exchange(true)) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Close aff4:Map %s \n", __FILE__, __LINE__, getResourceID().c_str()); #endif parent = nullptr; @@ -61,7 +61,7 @@ void MapStream::close() noexcept { int64_t MapStream::read(void *buf, uint64_t count, uint64_t offset) noexcept { if (closed) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Reading %" PRIu64 " : %" PRIu64 " on Closed Map Stream \n", __FILE__, __LINE__, offset, count); #endif errno = EPERM; @@ -69,7 +69,7 @@ int64_t MapStream::read(void *buf, uint64_t count, uint64_t offset) noexcept { } // If offset beyond end, return. if (offset > size()) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Reading %" PRIu64 " : %" PRIu64 "? Offset Greater than Stream size \n", __FILE__, __LINE__, offset, count); #endif return 0; @@ -79,7 +79,7 @@ int64_t MapStream::read(void *buf, uint64_t count, uint64_t offset) noexcept { count -= ((offset + count) - size()); } -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Reading %" PRIx64 " : %" PRIx64 " \n", __FILE__, __LINE__, offset, count); #endif @@ -116,7 +116,7 @@ int64_t MapStream::read(void *buf, uint64_t count, uint64_t offset) noexcept { int64_t res = stream->read(buffer, streadReadLength, streamReadOffset); if (res <= 0) { // fail it. -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Reading %s %" PRIx64 " : %" PRIx64 " FAILED READ \n", __FILE__, __LINE__, stream->getResourceID().c_str(), streamReadOffset, streadReadLength); #endif @@ -127,7 +127,7 @@ int64_t MapStream::read(void *buf, uint64_t count, uint64_t offset) noexcept { leftToRead -= streadReadLength; buffer += streadReadLength; } -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Completed Read %" PRIx64 " : %" PRIx64 " => %" PRIx64 " \n", __FILE__, __LINE__, offset - actualRead, count, actualRead); #endif return actualRead; @@ -139,7 +139,7 @@ void MapStream::initStreamVector(std::shared_ptr& unknownOver std::string segmentName = getResourceID() + "/idx"; std::shared_ptr stream = parent->getSegment(segmentName); if (stream == nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Missing 'idx' %s \n", __FILE__, __LINE__, segmentName.c_str()); #endif return; @@ -156,7 +156,7 @@ void MapStream::initStreamVector(std::shared_ptr& unknownOver while (std::getline(data, line, '\n')) { if (!line.empty()) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Stream : %s\n", __FILE__, __LINE__, line.c_str()); #endif std::shared_ptr stream; @@ -168,24 +168,24 @@ void MapStream::initStreamVector(std::shared_ptr& unknownOver } // We have this stream from the parent container if (stream != nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Local for Stream %s \n", __FILE__, __LINE__, line.c_str()); #endif streams.push_back(stream); } else { // look at the resolver for this stream. -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Query Resolver for Stream %s \n", __FILE__, __LINE__, line.c_str()); #endif stream = queryResolver(parent->getResolver(), line); if (stream != nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Resolver provided Stream %s \n", __FILE__, __LINE__, line.c_str()); #endif streams.push_back(stream); } else { // Nothing from the resolver. -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Resolver FAILED to locate Stream %s \n", __FILE__, __LINE__, line.c_str()); #endif streams.push_back(aff4::stream::createUnknownStream(line)); @@ -202,7 +202,7 @@ void MapStream::initMap(std::shared_ptr& mapGapStream) { std::shared_ptr stream = parent->getSegment(segmentName); if (stream == nullptr) { // reset the stream length -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Missing 'map' %s \n", __FILE__, __LINE__, segmentName.c_str()); #endif length = 0; @@ -251,7 +251,7 @@ void MapStream::initMap(std::shared_ptr& mapGapStream) { // Construct the map. for (uint32_t i = 0; i < size; i++) { MapEntryPoint mapPoint = points[i]; -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : MapEntry : %" PRIx64" : %" PRIx64" : %" PRIx64" : %" PRIx32"\n", __FILE__, __LINE__, mapPoint.offset, mapPoint.length, mapPoint.streamOffset, mapPoint.streamID); #endif @@ -263,7 +263,7 @@ void MapStream::initMap(std::shared_ptr& mapGapStream) { sparseRegion.length = mapPoint.offset - offset; sparseRegion.streamOffset = offset; sparseRegion.streamID = (uint32_t)mapGPSid; -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Insert Sparse Region MapEntry : %" PRIx64" : %" PRIx64" : %" PRIx64" : %" PRIx32"\n", __FILE__, __LINE__, sparseRegion.offset, sparseRegion.length, sparseRegion.streamOffset, sparseRegion.streamID); #endif @@ -271,7 +271,7 @@ void MapStream::initMap(std::shared_ptr& mapGapStream) { offset = mapPoint.offset; } if (mapPoint.streamID >= streams.size()) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Unknown Stream ID for : %" PRIx64" : %" PRIx64" : %" PRIx64" : %" PRIx32"\n", __FILE__, __LINE__, mapPoint.offset, mapPoint.length, mapPoint.streamOffset, mapPoint.streamID); #endif @@ -289,7 +289,7 @@ void MapStream::initMap(std::shared_ptr& mapGapStream) { sparseRegion.length = length - offset; sparseRegion.streamOffset = offset; sparseRegion.streamID = (uint32_t)mapGPSid; -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Insert Sparse Region MapEntry : %" PRIx64" : %" PRIx64" : %" PRIx64" : %" PRIx32"\n", __FILE__, __LINE__, sparseRegion.offset, sparseRegion.length, sparseRegion.streamOffset, sparseRegion.streamID); #endif @@ -299,7 +299,7 @@ void MapStream::initMap(std::shared_ptr& mapGapStream) { if (length == 0) { length = offset; } -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Created aff4:Map %s on length %" PRIu64 " \n", __FILE__, __LINE__, segmentName.c_str(), length); #endif @@ -308,7 +308,7 @@ void MapStream::initMap(std::shared_ptr& mapGapStream) { std::shared_ptr MapStream::queryResolver(aff4::IAFF4Resolver* resolver, const std::string& resource) { if (resolver == nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : No resolver? \n", __FILE__, __LINE__); #endif return nullptr; diff --git a/src/stream/RepeatedImageStream.cc b/src/stream/RepeatedImageStream.cc index 4ae66c8..5afa840 100644 --- a/src/stream/RepeatedImageStream.cc +++ b/src/stream/RepeatedImageStream.cc @@ -75,7 +75,7 @@ int64_t RepeatedImageStream::read(void *buf, uint64_t count, uint64_t offset) no return 0; } uint64_t remaining = count; -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Reading %" PRIx64 " : %" PRIx64 " \n", __FILE__, __LINE__, offset, count); #endif @@ -93,7 +93,7 @@ int64_t RepeatedImageStream::read(void *buf, uint64_t count, uint64_t offset) no // calculate next read/copy size. limit = std::min(remainder, (uint64_t)UNITS_M); } -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Completed Read %" PRIx64 " : %" PRIx64 " => %" PRIx64 " \n", __FILE__, __LINE__, offset, count, remaining); #endif return remaining; diff --git a/src/stream/SymbolicImageStream.cc b/src/stream/SymbolicImageStream.cc index 146f579..84f1e62 100644 --- a/src/stream/SymbolicImageStream.cc +++ b/src/stream/SymbolicImageStream.cc @@ -39,7 +39,7 @@ SymbolicImageStream::SymbolicImageStream(const std::string& resource) : symbol = std::stoi(value, nullptr, 16); } catch (...) { // ignore. -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Unable to determine symbol for symbolic stream : %s\n", __FILE__, __LINE__, resource.c_str()); #endif @@ -76,11 +76,11 @@ int64_t SymbolicImageStream::read(void *buf, uint64_t count, uint64_t offset) no if ((count == 0) || (buf == nullptr)) { return 0; } -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Reading %" PRIx64 " : %" PRIx64 " \n", __FILE__, __LINE__, offset, count); #endif ::memset(buf, symbol, count); -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Completed Read %" PRIx64 " : %" PRIx64 " => %" PRIx64 " \n", __FILE__, __LINE__, offset, count, count); #endif return count; diff --git a/src/stream/struct/BevvyIndex.cc b/src/stream/struct/BevvyIndex.cc index 9e81db9..3906baa 100644 --- a/src/stream/struct/BevvyIndex.cc +++ b/src/stream/struct/BevvyIndex.cc @@ -42,12 +42,12 @@ BevvyIndex::BevvyIndex(const std::string& resource, uint32_t bevvyID, aff4::cont // Load the contents of the bevvy Index. segmentName = segmentName + ".index"; -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Loading Bevvy Index : %s \n", __FILE__, __LINE__, segmentName.c_str()); #endif std::shared_ptr stream = parent->getSegment(segmentName); if (stream == nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Loading Bevvy Index Failed - missing segment? \n", __FILE__, __LINE__); #endif buffer = nullptr; @@ -59,7 +59,7 @@ BevvyIndex::BevvyIndex(const std::string& resource, uint32_t bevvyID, aff4::cont buffer = std::unique_ptr(new ImageStreamPoint[size]); stream->read(buffer.get(), streamSize, 0); } -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Loading Bevvy Index Size %" PRIu64 "? \n", __FILE__, __LINE__, streamSize); #endif stream->close(); @@ -90,7 +90,7 @@ uint64_t BevvyIndex::getDataOffset() const noexcept { ImageStreamPoint BevvyIndex::getPoint(uint32_t offset) const noexcept { if (offset >= size || buffer == nullptr || parent == nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Unknown Point? %x \n", __FILE__, __LINE__, offset); #endif ImageStreamPoint pt; diff --git a/src/stream/struct/ChunkLoader.cc b/src/stream/struct/ChunkLoader.cc index 350bb45..a2f1b75 100644 --- a/src/stream/struct/ChunkLoader.cc +++ b/src/stream/struct/ChunkLoader.cc @@ -36,7 +36,7 @@ ChunkLoader::~ChunkLoader() { cacheBuffer_t ChunkLoader::load(uint64_t offset) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Loading Buffer: %" PRIu64 " \n", __FILE__, __LINE__, offset); #endif @@ -45,7 +45,7 @@ cacheBuffer_t ChunkLoader::load(uint64_t offset) { std::shared_ptr index = bevvyCache->get((uint32_t) bevvyID); if (index == nullptr) { // failed to load. -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Failed to acquire Bevvy Index %" PRIu64 " for Buffer: %" PRIu64 " \n", __FILE__, __LINE__, bevvyID, offset); #endif @@ -57,7 +57,7 @@ cacheBuffer_t ChunkLoader::load(uint64_t offset) { ImageStreamPoint point = index->getPoint((uint32_t) chunkID); if (point.length == 0) { // point has no length -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Failed to read Bevvy Index Point (bevvy: %" PRIu64 ") for Buffer: %" PRIu64 " \n", __FILE__, __LINE__, bevvyID, offset); #endif @@ -67,7 +67,7 @@ cacheBuffer_t ChunkLoader::load(uint64_t offset) { uint64_t chunkOffset = index->getDataOffset() + point.offset; uint64_t chunkLength = point.length; -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : ChunkOffset %" PRIu64 " ChunkLength %" PRIu64 " \n", __FILE__, __LINE__, chunkOffset, chunkLength); #endif @@ -83,7 +83,7 @@ cacheBuffer_t ChunkLoader::load(uint64_t offset) { uint64_t toRead = chunkLength; uint8_t* buf = buffer.get(); while (toRead > 0) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Reading Chunk [%" PRIu64 ":%" PRIu64 "] for Buffer: %" PRIu64 " \n", __FILE__, __LINE__, chunkOffset, toRead, offset); #endif @@ -98,19 +98,19 @@ cacheBuffer_t ChunkLoader::load(uint64_t offset) { } if (chunkLength != chunkSize) { // decompress -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Decompress Chunk [%" PRIu32 " : %" PRIu64 "] \n", __FILE__, __LINE__, chunkSize, chunkLength); #endif std::shared_ptr dest(new uint8_t[chunkSize], std::default_delete()); uint64_t decSize = codec->decompress(buffer.get(), chunkLength, dest.get(), chunkSize); -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Decompressed Chunk [%" PRIu32 " : %" PRIu64 "] => %" PRIu64 " \n", __FILE__, __LINE__, chunkSize, chunkLength, decSize); #endif return std::make_pair(dest, chunkSize); } -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Stored Chunk [%" PRIu32 " : %" PRIu64 "] \n", __FILE__, __LINE__, chunkSize, chunkLength); #endif diff --git a/src/zip/Zip.cc b/src/zip/Zip.cc index 27f5d5a..bf3b8c4 100644 --- a/src/zip/Zip.cc +++ b/src/zip/Zip.cc @@ -45,7 +45,7 @@ ZipEntry::ZipEntry(const std::string& segmentName, uint64_t headerOffset, uint64 uint64_t compressedLength, int compressionMethod) : segmentName(segmentName), headerOffset(headerOffset), offset(offset), length(length), compressedLength( compressedLength), compressionMethod(compressionMethod) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : ZipEntry : %s %" PRIu64 " : %" PRIu64 "\n", __FILE__, __LINE__, segmentName.c_str(), offset, compressedLength); #endif @@ -65,7 +65,7 @@ Zip::Zip(const std::string& filename) : fileHandle = ::open(filename.c_str(), O_RDONLY | O_LARGEFILE); if (fileHandle == -1) { // we failed, so return nothing. (error will be in errno). -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Unable to open Zip : %s \n", __FILE__, __LINE__, filename.c_str()); #endif return; @@ -81,7 +81,7 @@ Zip::Zip(const std::string& filename) : std::wstring wpath = aff4::util::s2ws(filename); fileHandle = CreateFile(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); if (fileHandle == INVALID_HANDLE_VALUE) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Unable to open Zip : %s \n", __FILE__, __LINE__, filename.c_str()); #endif return; @@ -90,7 +90,7 @@ Zip::Zip(const std::string& filename) : LARGE_INTEGER plength; plength.QuadPart = 0; if (!GetFileSizeEx(fileHandle, &plength)) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Unable to get File Length of Zip : %s \n", __FILE__, __LINE__, filename.c_str()); #endif return; @@ -99,7 +99,7 @@ Zip::Zip(const std::string& filename) : #endif closed = false; -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Zip : %s : %" PRIu64 "\n", __FILE__, __LINE__, filename.c_str(), length); #endif parseCD(); @@ -139,7 +139,7 @@ std::vector> Zip::getEntries() const noexcept { } bool Zip::hasEntry(const std::string& segmentName) const noexcept { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Has Entry: %s \n", __FILE__, __LINE__, segmentName.c_str()); #endif // Find the Zip Entry. @@ -152,7 +152,7 @@ bool Zip::hasEntry(const std::string& segmentName) const noexcept { } std::shared_ptr Zip::getStream(const std::string& segmentName) noexcept { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Zip Open Segment: %s \n", __FILE__, __LINE__, segmentName.c_str()); #endif // Find the Zip Entry. @@ -160,7 +160,7 @@ std::shared_ptr Zip::getStream(const std::string& segmentName) noex if (entry->getSegmentName().compare(segmentName) == 0) { std::shared_ptr stream = std::make_shared( entry->getSegmentName(), entry, this); -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Zip Open Segment: %s Found: %" PRIu64 " : %" PRIu64 "\n", __FILE__, __LINE__, segmentName.c_str(), entry->getHeaderOffset(), entry->getCompressedLength()); #endif @@ -168,7 +168,7 @@ std::shared_ptr Zip::getStream(const std::string& segmentName) noex } } // Unknown? -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Zip Open Segment: %s is UNKNOWN?\n", __FILE__, __LINE__, segmentName.c_str()); #endif std::shared_ptr s = nullptr; @@ -201,7 +201,7 @@ void Zip::parseCD() noexcept { } // Not found. if (le32toh(endCD->magic) != 0x6054b50) { -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Zip EOCD Not Found: %s\n", __FILE__, __LINE__, filename.c_str()); #endif return; @@ -222,7 +222,7 @@ void Zip::parseCD() noexcept { std::string rComment(commentBuffer.get(), l); this->comment = rComment; -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Zip Comment: %s\n", __FILE__, __LINE__, rComment.c_str()); #endif } @@ -271,7 +271,7 @@ void Zip::parseCD() noexcept { // Now iterate over all entries in the CD... uint64_t entryOffset = directoryOffset; -#if DEBUG +#if DEBUG_VERBOSE fprintf( aff4::getDebugOutput(), "%s[%d] : Zip directoryNumberOfEntries: %" PRIu64 "\n", __FILE__, __LINE__, directoryNumberOfEntries); #endif for (uint64_t i = 0; i < directoryNumberOfEntries; i++) { @@ -353,7 +353,7 @@ void Zip::parseCD() noexcept { } int64_t Zip::fileRead(void *buf, uint64_t count, uint64_t offset) noexcept { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Reading %" PRIx64 " : %" PRIx64 " \n", __FILE__, __LINE__, offset, count); #endif if ((count == 0) || (buf == nullptr)) { @@ -391,12 +391,12 @@ int64_t Zip::fileRead(void *buf, uint64_t count, uint64_t offset) noexcept { readDetails.OffsetHigh = (DWORD)((offset & 0xffffffff00000000L) >> 32); if (!ReadFile(fileHandle, buf, byteRead, &bytesRead, &readDetails)) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Reading %" PRIx64 " : %" PRIx64 " FAILED \n", __FILE__, __LINE__, offset, count); #endif return -1; } -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Completed Read %" PRIx64 " : %" PRIx64 " => %" PRIx32 " \n", __FILE__, __LINE__, offset, count, byteRead); #endif return byteRead; diff --git a/src/zip/ZipStream.cc b/src/zip/ZipStream.cc index e8a34c9..e5a61a0 100644 --- a/src/zip/ZipStream.cc +++ b/src/zip/ZipStream.cc @@ -101,7 +101,7 @@ std::vector ZipSegmentStream::getProperty(aff4::Lexicon res */ int64_t ZipSegmentStream::readCompressed(void *buf, uint64_t count, uint64_t offset) noexcept { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Reading Compressed Zip Segment %" PRIx64 " : %" PRIx64 " \n", __FILE__, __LINE__, offset, count); #endif // If the size of the stream is less than 32MB, take a poor mans implementation. @@ -139,7 +139,7 @@ int64_t ZipSegmentStream::readCompressed(void *buf, uint64_t count, uint64_t off } else { // greater than 32MB -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Reading Compressed Zip Segment TOO LARGE %" PRIx64 " : %" PRIx64 " \n", __FILE__, __LINE__, offset, count); #endif // FIXME: IMPLEMENT. diff --git a/win32/libaff4/aff4config.h b/win32/libaff4/aff4config.h index 66e828e..70f07ce 100644 --- a/win32/libaff4/aff4config.h +++ b/win32/libaff4/aff4config.h @@ -36,13 +36,13 @@ along with AFF4 CPP. If not, see . /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 -#ifdef _DEBUG - #ifndef DEBUG - #define DEBUG 1 +#if defined(_DEBUG) && !defined(REDUCE_VERBOSE) + #ifndef DEBUG_VERBOSE + #define DEBUG_VERBOSE 1 #endif #else - #ifndef DEBUG - #define DEBUG 0 + #ifndef DEBUG_VERBOSE + #define DEBUG_VERBOSE 0 #endif #endif diff --git a/win32/xwaysPlugin/xwaysPlugin.cc b/win32/xwaysPlugin/xwaysPlugin.cc index cacd67c..a652487 100644 --- a/win32/xwaysPlugin/xwaysPlugin.cc +++ b/win32/xwaysPlugin/xwaysPlugin.cc @@ -61,7 +61,7 @@ static std::shared_ptr> handles = std::make_shared lock(apiLock); mainWnd = (HWND)hMainWnd; -#if DEBUG +#if DEBUG_VERBOSE setupLog(); #endif if (lpFilePath == NULL) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : No Filename provided? \n", __FILE__, __LINE__); #endif return NULL; } if (pImgInfo == NULL) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : No Image Information Packet provided? \n", __FILE__, __LINE__); #endif return NULL; @@ -171,24 +171,24 @@ extern "C" { std::wstring wfile(lpFilePath); if (wfile.empty()) { errno = ENOENT; -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Filename provided is empty? \n", __FILE__, __LINE__); #endif return NULL; } // Convert wstring (utf-16) to string (utf-8) std::string file = ws2s(wfile); -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Attempt to open: %s \n", __FILE__, __LINE__, file.c_str()); #endif // Attempt to open the file. std::shared_ptr container = aff4::container::openAFF4Container(file); if (container == nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : No AFF4 Container materialised? %s \n", __FILE__, __LINE__, file.c_str()); #endif if (!aff4::container::isAFF4Container(file)) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Filename does not appear to be an AFF4 Container? %s \n", __FILE__, __LINE__, file.c_str()); #endif errno = ENOENT; @@ -197,13 +197,13 @@ extern "C" { std::string resource = aff4::container::getResourceID(file); pImgInfo->nFlags = IIO_INIT_ERROR_GIVE_UP; if (resource.empty()) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Invalid AFF4 Container - Missing Resource Identifier? %s \n", __FILE__, __LINE__, file.c_str()); #endif pImgInfo->lpTextualDescr = createText(L"Invalid AFF4 Container - Missing Resource Identifier"); } else { // Have a Resource ID? Possible empty container. -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Invalid AFF4 Container - Missing Contents? %s \n", __FILE__, __LINE__, file.c_str()); #endif pImgInfo->lpTextualDescr = createText(L"Invalid AFF4 Container - Missing Contents"); @@ -215,7 +215,7 @@ extern "C" { // Attempt to start a resolver std::shared_ptr resolver(aff4::container::createResolver(file, false)); if (resolver == nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Unable to construct Resolver at location. \n", __FILE__, __LINE__); #endif errno = ENOENT; @@ -228,7 +228,7 @@ extern "C" { // Open the first image. std::vector> images = container->getImages(); if (images.empty()) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : No Images contained or available in the AFF4 Container.\n", __FILE__, __LINE__); #endif errno = ENOENT; @@ -237,7 +237,7 @@ extern "C" { return (PVOID)(nextHandle++); } if (images[0] == nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : No Images contained or available in the AFF4 Container.\n", __FILE__, __LINE__); #endif errno = ENOENT; @@ -248,7 +248,7 @@ extern "C" { // Get the map for the first image. std::shared_ptr map = images[0]->getMap(); if (map == nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Primary Image is missing required Datastream Map.\n", __FILE__, __LINE__); #endif errno = ENOENT; @@ -258,7 +258,7 @@ extern "C" { } std::shared_ptr stream = map->getStream(); if (stream == nullptr) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Datastream for Image is not available or corrupted.\n", __FILE__, __LINE__); #endif errno = ENOENT; @@ -269,7 +269,7 @@ extern "C" { container_t handleEntry = std::make_tuple(resolver, container, stream); int handle = nextHandle++; (*handles)[handle] = handleEntry; -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Created aff4:Image instance. Handle %d\n", __FILE__, __LINE__, handle); #endif /* @@ -283,14 +283,14 @@ extern "C" { if (!properties.empty()) { for (aff4::rdf::RDFValue v : properties) { if (v.getType() == aff4::Lexicon::AFF4_DISK_IMAGE_TYPE) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Setting Disk Image\n", __FILE__, __LINE__); #endif pImgInfo->nFlags |= IIO_INIT_DISK; break; } if (v.getType() == aff4::Lexicon::AFF4_VOLUME_IMAGE_TYPE) { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Setting Volume Image\n", __FILE__, __LINE__); #endif pImgInfo->nFlags |= IIO_INIT_VOLUME; @@ -308,7 +308,7 @@ extern "C" { || v.getType() == aff4::Lexicon::BBT_APFS_CONTAINER_TYPE_STANDARD) { // Big assumption that these all represent a volume... // I'm sure someone will file a bug report if this is incorrect. -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Setting Volume Image (bbt:Std/T2/Fusion)\n", __FILE__, __LINE__); #endif pImgInfo->nFlags |= IIO_INIT_VOLUME; @@ -329,7 +329,7 @@ extern "C" { pImgInfo->nSectorSize = (DWORD)v.getLong(); } } -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Setting Sector Size %d\n", __FILE__, __LINE__, pImgInfo->nSectorSize); #endif @@ -348,7 +348,7 @@ extern "C" { // No defined sector size, so get the size of the stream and divide by block size. pImgInfo->nSectorCount = (INT64)stream->size() / (INT64)pImgInfo->nSectorSize; } -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Setting Sector Count %" PRIi64 "\n", __FILE__, __LINE__, pImgInfo->nSectorCount); #endif /* @@ -390,7 +390,7 @@ extern "C" { container = it->second; } else { -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Unknown Handle %d\n", __FILE__, __LINE__, handle); #endif errno = ENOENT; @@ -403,7 +403,7 @@ extern "C" { } std::shared_ptr stream = std::get<2>(container); -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : (%d) Read : %" PRIx64 ":%" PRIx64 "\n", __FILE__, __LINE__, handle, nOfs, nSize); #endif @@ -427,7 +427,7 @@ extern "C" { if (isSparse(stream, nOfs, nSize)) { // Only set the bit as required leaving the contents as is. *pFlags |= IIO_SPARSE_DETECTED; -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : (%d) Returning Sparse Region %" PRIx64 ":%" PRIx64 "\n", __FILE__, __LINE__, handle, nOfs, nSize); #endif return nSize; @@ -445,7 +445,7 @@ extern "C" { if (read < 0) { read = 0; } -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : (%d) Read complete: %" PRIx64 ":%" PRIx64 " => %" PRIx64 "\n", __FILE__, __LINE__, handle, nOfs, nSize, read); #endif return read; @@ -461,7 +461,7 @@ extern "C" { ) { std::lock_guard lock(apiLock); INT handle = (INT)lpImage; -#if DEBUG +#if DEBUG_VERBOSE fprintf(aff4::getDebugOutput(), "%s[%d] : Close Handle %d\n", __FILE__, __LINE__, handle); #endif auto it = handles->find(handle); @@ -472,7 +472,7 @@ extern "C" { // And remove the map entry. handles->erase(it); } -#if DEBUG +#if DEBUG_VERBOSE else { fprintf(aff4::getDebugOutput(), "%s[%d] : Unknown Handle %d\n", __FILE__, __LINE__, handle); } @@ -481,7 +481,7 @@ extern "C" { ::free(lpTextualDescr); } -#if DEBUG +#if DEBUG_VERBOSE if (handles->empty()) { closeLog(); }