Skip to content

Commit

Permalink
Fix build when EXIV2_BUILD_MESSAGES is ON
Browse files Browse the repository at this point in the history
  • Loading branch information
piponazo committed Feb 19, 2022
1 parent 8b3da36 commit 21eb0ce
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
3 changes: 0 additions & 3 deletions src/crwimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ namespace Exiv2 {
// Parse the image, starting with a CIFF header component
CiffHeader header;
header.read(pData, size);
#ifdef EXIV2_DEBUG_MESSAGES
header.print(std::cerr);
#endif
header.decode(*pCrwImage);

// a hack to get absolute offset of preview image inside CRW structure
Expand Down
1 change: 1 addition & 0 deletions src/crwimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <cassert>
#include <ctime>
#include <iostream>

// *****************************************************************************
// local declarations
Expand Down
2 changes: 2 additions & 0 deletions src/tiffimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "tiffvisitor_int.hpp"
#include "i18n.h" // NLS support.

#include <iostream>

// Shortcuts for the newTiffBinaryArray templates.
#define EXV_BINARY_ARRAY(arrayCfg, arrayDef) (newTiffBinaryArray0<&arrayCfg, EXV_COUNTOF(arrayDef), arrayDef>)
#define EXV_SIMPLE_BINARY_ARRAY(arrayCfg) (newTiffBinaryArray1<&arrayCfg>)
Expand Down
52 changes: 50 additions & 2 deletions src/webpimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,54 @@

#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))

namespace {
[[maybe_unused]] std::string binaryToHex(const uint8_t* data, size_t size)
{
std::stringstream hexOutput;

auto tl = size_t(size / 16) * 16;
auto tl_offset = size_t(size) - tl;

for (size_t loop = 0; loop < size; loop++) {
if (data[loop] < 16) {
hexOutput << "0";
}
hexOutput << std::hex << static_cast<int>(data[loop]);
if ((loop % 8) == 7) {
hexOutput << " ";
}
if ((loop % 16) == 15 || loop == (tl + tl_offset - 1)) {
int max = 15;
if (loop >= tl) {
max = int(tl_offset) - 1;
for (int offset = 0; offset < int(16 - tl_offset); offset++) {
if ((offset % 8) == 7) {
hexOutput << " ";
}
hexOutput << " ";
}
}
hexOutput << " ";
for (int offset = max; offset >= 0; offset--) {
if (offset == (max - 8)) {
hexOutput << " ";
}
uint8_t c = '.';
if (data[loop - offset] >= 0x20 && data[loop - offset] <= 0x7E) {
c = data[loop - offset];
}
hexOutput << static_cast<char>(c);
}
hexOutput << std::endl;
}
}

hexOutput << std::endl << std::endl << std::endl;

return hexOutput.str();
}
} // namespace

// *****************************************************************************
// class member definitions
namespace Exiv2 {
Expand Down Expand Up @@ -688,7 +736,7 @@ namespace Exiv2 {

#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Display Hex Dump [size:" << static_cast<unsigned long>(sizePayload) << "]" << std::endl;
std::cout << Internal::binaryToHex(rawExifData.c_data(), sizePayload);
std::cout << binaryToHex(rawExifData.c_data(), sizePayload);
#endif

if (pos != -1) {
Expand Down Expand Up @@ -716,7 +764,7 @@ namespace Exiv2 {
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Display Hex Dump [size:" << static_cast<unsigned long>(payload.size()) << "]"
<< std::endl;
std::cout << Internal::binaryToHex(payload.c_data(), payload.size());
std::cout << binaryToHex(payload.c_data(), payload.size());
#endif
}
} else {
Expand Down

0 comments on commit 21eb0ce

Please sign in to comment.