From 02facf915763b215cb3b0713776b136c53af98fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz=20M=C3=A1s?= Date: Fri, 28 Jun 2019 19:40:01 +0200 Subject: [PATCH] Replace DEBUG with EXIV2_DEBUG_MESSAGES Fixes #926 --- README.md | 10 +++---- samples/geotag.cpp | 2 +- src/actions.cpp | 2 +- src/basicio.cpp | 14 ++++----- src/bmpimage.cpp | 2 +- src/convert.cpp | 12 ++++---- src/cr2image.cpp | 6 ++-- src/crwimage.cpp | 6 ++-- src/crwimage_int.cpp | 16 +++++----- src/exif.cpp | 6 ++-- src/gifimage.cpp | 2 +- src/iptc.cpp | 2 +- src/jp2image.cpp | 62 +++++++++++++++++++-------------------- src/jpgimage.cpp | 36 +++++++++++------------ src/mrwimage.cpp | 2 +- src/orfimage.cpp | 6 ++-- src/pgfimage.cpp | 18 ++++++------ src/pngchunk_int.cpp | 24 +++++++-------- src/pngimage.cpp | 31 ++++++++++---------- src/properties.cpp | 2 +- src/psdimage.cpp | 22 +++++++------- src/rafimage.cpp | 2 +- src/rw2image.cpp | 8 ++--- src/tgaimage.cpp | 2 +- src/tiffcomposite_int.cpp | 10 +++---- src/tiffimage.cpp | 6 ++-- src/tiffimage_int.cpp | 14 ++++----- src/tiffvisitor_int.cpp | 34 ++++++++++----------- src/webpimage.cpp | 8 ++--- src/xmp.cpp | 6 ++-- src/xmpsidecar.cpp | 2 +- 31 files changed, 187 insertions(+), 188 deletions(-) diff --git a/README.md b/README.md index 36e31b701a..e8e93dcd7e 100644 --- a/README.md +++ b/README.md @@ -424,22 +424,22 @@ $ [TOC](#TOC) -2) About preprocessor symbols **NDEBUG** and **DEBUG** +2) About preprocessor symbols `NDEBUG` and `EXIV2_DEBUG_MESSAGES` -In accordance with current practice, exiv2 respects the symbol *NDEBUG* which is set for Release builds. There are sequences of code which are defined within: +Exiv2 respects the symbol `NDEBUG` which is set only for Release builds. There are sequences of code which are defined within: ```C++ -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES .... #endif ``` -Those blocks of code are not compiled for debug builds. They are provided for additional debugging information. For example, if you are interested in additonal output from webpimage.cpp, you can update your build as follows: +Those blocks of code are not compiled unless you define `EXIV2_DEBUG_MESSAGES` by yourself. They are provided for additional debugging information. For example, if you are interested in additional output from webpimage.cpp, you can update your build as follows: ```bash $ cd $ touch src/webpimage.cpp -$ make CXXFLAGS=-DDEBUG +$ make CXXFLAGS=-DEXIV2_DEBUG_MESSAGESDEBUG $ bin/exiv2 ... -- or -- $ sudo make install diff --git a/samples/geotag.cpp b/samples/geotag.cpp index f6dbe0b00e..666f5aeb66 100644 --- a/samples/geotag.cpp +++ b/samples/geotag.cpp @@ -450,7 +450,7 @@ int timeZoneAdjust() struct tm local = *localtime(&now) ; offset = local.tm_gmtoff ; -#if DEBUG +#if EXIV2_DEBUG_MESSAGES struct tm utc = *gmtime(&now); printf("utc : offset = %6d dst = %d time = %s", 0 ,utc .tm_isdst, asctime(&utc )); printf("local: offset = %6d dst = %d time = %s", offset,local.tm_isdst, asctime(&local)); diff --git a/src/actions.cpp b/src/actions.cpp index 68260186de..967ba1bcac 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -2070,7 +2070,7 @@ namespace { int targetType, bool preserve) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "actions.cpp::metacopy" << " source = " << source << " target = " << tgt << std::endl; #endif diff --git a/src/basicio.cpp b/src/basicio.cpp index 9b39124007..ea0cb9d182 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -306,7 +306,7 @@ namespace Exiv2 { } // #906. Mountain Lion 'sandbox' terminates the app when we call setxattr #ifndef __APPLE__ -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES EXV_DEBUG << "Copying xattr \"" << name << "\" with value size " << valueSize << "\n"; #endif if (::setxattr(path_.c_str(), name, value, valueSize, 0, 0) != 0) { @@ -337,19 +337,19 @@ namespace Exiv2 { if (pfcn_GetFileInformationByHandle(hFd, &fi)) { nlink = fi.nNumberOfLinks; } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES else EXV_DEBUG << "GetFileInformationByHandle failed\n"; #endif } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES else EXV_DEBUG << "GetProcAddress(hKernel, \"GetFileInformationByHandle\") failed\n"; #endif } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES else EXV_DEBUG << "GetModuleHandleA(\"kernel32.dll\") failed\n"; #endif } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES else EXV_DEBUG << "_get_osfhandle failed: INVALID_HANDLE_VALUE\n"; #endif @@ -1730,7 +1730,7 @@ namespace Exiv2 { p_->eof_ = false; p_->idx_ = 0; } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "RemoteIo::close totalRead_ = " << p_->totalRead_ << std::endl; #endif if ( bigBlock_ ) { @@ -1950,7 +1950,7 @@ namespace Exiv2 { memcpy(bigBlock_+(block*blockSize),p,blockSize); } } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "RemoteIo::mmap nRealData = " << nRealData << std::endl; #endif } diff --git a/src/bmpimage.cpp b/src/bmpimage.cpp index 3a021c2316..cdc3908e28 100644 --- a/src/bmpimage.cpp +++ b/src/bmpimage.cpp @@ -70,7 +70,7 @@ namespace Exiv2 void BmpImage::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::BmpImage::readMetadata: Reading Windows bitmap file " << io_->path() << "\n"; #endif if (io_->open() != 0) { diff --git a/src/convert.cpp b/src/convert.cpp index be8bdbc7c7..ef83a23f48 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -1374,7 +1374,7 @@ namespace { { // Naive byte-swapping, I'm sure this can be done more efficiently if (str.size() & 1) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES EXV_DEBUG << "swapBytes: Size " << str.size() << " of input string is not even.\n"; #endif return false; @@ -1392,7 +1392,7 @@ namespace { if (str.empty()) return true; int len = MultiByteToWideChar(cp, 0, str.c_str(), (int)str.size(), 0, 0); if (len == 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES EXV_DEBUG << "mb2wc: Failed to determine required size of output buffer.\n"; #endif return false; @@ -1401,7 +1401,7 @@ namespace { out.resize(len * 2); int ret = MultiByteToWideChar(cp, 0, str.c_str(), (int)str.size(), (LPWSTR)&out[0], len * 2); if (ret == 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES EXV_DEBUG << "mb2wc: Failed to convert the input string to a wide character string.\n"; #endif return false; @@ -1414,14 +1414,14 @@ namespace { { if (str.empty()) return true; if (str.size() & 1) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES EXV_DEBUG << "wc2mb: Size " << str.size() << " of input string is not even.\n"; #endif return false; } int len = WideCharToMultiByte(cp, 0, (LPCWSTR)str.data(), (int)str.size() / 2, 0, 0, 0, 0); if (len == 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES EXV_DEBUG << "wc2mb: Failed to determine required size of output buffer.\n"; #endif return false; @@ -1430,7 +1430,7 @@ namespace { out.resize(len); int ret = WideCharToMultiByte(cp, 0, (LPCWSTR)str.data(), (int)str.size() / 2, (LPSTR)&out[0], len, 0, 0); if (ret == 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES EXV_DEBUG << "wc2mb: Failed to convert the input string to a multi byte string.\n"; #endif return false; diff --git a/src/cr2image.cpp b/src/cr2image.cpp index fcfff75b45..e1d8be328e 100644 --- a/src/cr2image.cpp +++ b/src/cr2image.cpp @@ -89,7 +89,7 @@ namespace Exiv2 { void Cr2Image::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Reading CR2 file " << io_->path() << "\n"; #endif if (io_->open() != 0) { @@ -112,7 +112,7 @@ namespace Exiv2 { void Cr2Image::writeMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Writing CR2 file " << io_->path() << "\n"; #endif ByteOrder bo = byteOrder(); @@ -174,7 +174,7 @@ namespace Exiv2 { panaRawId }; for (unsigned int i = 0; i < EXV_COUNTOF(filteredIfds); ++i) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Warning: Exif IFD " << filteredIfds[i] << " not encoded\n"; #endif ed.erase(std::remove_if(ed.begin(), diff --git a/src/crwimage.cpp b/src/crwimage.cpp index d11249927d..e742988269 100644 --- a/src/crwimage.cpp +++ b/src/crwimage.cpp @@ -88,7 +88,7 @@ namespace Exiv2 { void CrwImage::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Reading CRW file " << io_->path() << "\n"; #endif if (io_->open() != 0) { @@ -110,7 +110,7 @@ namespace Exiv2 { void CrwImage::writeMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Writing CRW file " << io_->path() << "\n"; #endif // Read existing image @@ -148,7 +148,7 @@ namespace Exiv2 { // Parse the image, starting with a CIFF header component CiffHeader::AutoPtr head(new CiffHeader); head->read(pData, size); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES head->print(std::cerr); #endif head->decode(*pCrwImage); diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp index 58f1f46760..29311fdb79 100644 --- a/src/crwimage_int.cpp +++ b/src/crwimage_int.cpp @@ -250,7 +250,7 @@ namespace Exiv2 { offset_ = start + 2; } pData_ = pData + offset_; -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << " Entry for tag 0x" << std::hex << tagId() << " (0x" << tag() << "), " << std::dec << size_ @@ -265,11 +265,11 @@ namespace Exiv2 { ByteOrder byteOrder) { CiffComponent::doRead(pData, size, start, byteOrder); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Reading directory 0x" << std::hex << tag() << "\n"; #endif readDirectory(pData + offset(), this->size(), byteOrder); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "<---- 0x" << std::hex << tag() << "\n"; #endif } // CiffDirectory::doRead @@ -284,7 +284,7 @@ namespace Exiv2 { if ( o > size-2 ) throw Error(kerCorruptedMetadata); uint16_t count = getUShort(pData + o, byteOrder); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Directory at offset " << std::dec << o <<", " << count << " entries \n"; #endif @@ -383,7 +383,7 @@ namespace Exiv2 { uint32_t CiffComponent::writeValueData(Blob& blob, uint32_t offset) { if (dataLocation() == valueData) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << " Data for tag 0x" << std::hex << tagId() << ", " << std::dec << size_ << " Bytes\n"; #endif @@ -403,7 +403,7 @@ namespace Exiv2 { ByteOrder byteOrder, uint32_t offset) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Writing directory 0x" << std::hex << tag() << "---->\n"; #endif // Ciff offsets are relative to the start of the directory @@ -438,7 +438,7 @@ namespace Exiv2 { setOffset(offset); setSize(dirOffset); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Directory is at offset " << std::dec << dirStart << ", " << components_.size() << " entries\n" << "<---- 0x" << std::hex << tag() << "\n"; @@ -448,7 +448,7 @@ namespace Exiv2 { void CiffComponent::writeDirEntry(Blob& blob, ByteOrder byteOrder) const { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << " Directory entry for tag 0x" << std::hex << tagId() << " (0x" << tag() << "), " << std::dec << size_ diff --git a/src/exif.cpp b/src/exif.cpp index 254d3da618..26a8a2cd37 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -665,7 +665,7 @@ namespace Exiv2 { for (unsigned int i = 0; i < EXV_COUNTOF(filteredIfd0Tags); ++i) { ExifData::iterator pos = ed.findKey(ExifKey(filteredIfd0Tags[i])); if (pos != ed.end()) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Warning: Exif tag " << pos->key() << " not encoded\n"; #endif ed.erase(pos); @@ -689,7 +689,7 @@ namespace Exiv2 { ifd3Id }; for (unsigned int i = 0; i < EXV_COUNTOF(filteredIfds); ++i) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Warning: Exif IFD " << filteredIfds[i] << " not encoded\n"; #endif eraseIfd(ed, filteredIfds[i]); @@ -816,7 +816,7 @@ namespace Exiv2 { header.get(), 0); append(blob, mio2.mmap(), (uint32_t) mio2.size()); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES if (wm == wmIntrusive) { std::cerr << "SIZE OF EXIF DATA IS " << std::dec << mio2.size() << " BYTES\n"; } diff --git a/src/gifimage.cpp b/src/gifimage.cpp index 2583d17a95..72a198e79d 100644 --- a/src/gifimage.cpp +++ b/src/gifimage.cpp @@ -71,7 +71,7 @@ namespace Exiv2 { void GifImage::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::GifImage::readMetadata: Reading GIF file " << io_->path() << "\n"; #endif if (io_->open() != 0) diff --git a/src/iptc.cpp b/src/iptc.cpp index a3bb6e1d6c..1ffc759c20 100644 --- a/src/iptc.cpp +++ b/src/iptc.cpp @@ -435,7 +435,7 @@ namespace Exiv2 { uint32_t size ) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "IptcParser::decode, size = " << size << "\n"; #endif const byte* pRead = pData; diff --git a/src/jp2image.cpp b/src/jp2image.cpp index 0c50ee49c8..d5cd1340aa 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -142,13 +142,13 @@ namespace Exiv2 { if (io_->open() == 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::Jp2Image:: Creating JPEG2000 image to memory" << std::endl; #endif IoCloser closer(*io_); if (io_->write(Jp2Blank, sizeof(Jp2Blank)) != sizeof(Jp2Blank)) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::Jp2Image:: Failed to create JPEG2000 image on memory" << std::endl; #endif } @@ -199,7 +199,7 @@ namespace Exiv2 void Jp2Image::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::Jp2Image::readMetadata: Reading JPEG-2000 file " << io_->path() << std::endl; #endif if (io_->open() != 0) @@ -225,7 +225,7 @@ namespace Exiv2 position = io_->tell(); box.length = getLong((byte*)&box.length, bigEndian); box.type = getLong((byte*)&box.type, bigEndian); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::readMetadata: " << "Position: " << position << " box type: " << toAscii(box.type) @@ -244,7 +244,7 @@ namespace Exiv2 { case kJp2BoxTypeJp2Header: { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::readMetadata: JP2Header box found" << std::endl; #endif long restore = io_->tell(); @@ -253,13 +253,13 @@ namespace Exiv2 { subBox.length = getLong((byte*)&subBox.length, bigEndian); subBox.type = getLong((byte*)&subBox.type, bigEndian); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::readMetadata: " << "subBox = " << toAscii(subBox.type) << " length = " << subBox.length << std::endl; #endif if(subBox.type == kJp2BoxTypeColorHeader && subBox.length != 15) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::readMetadata: " << "Color data found" << std::endl; #endif @@ -280,7 +280,7 @@ namespace Exiv2 } DataBuf icc(iccLength); ::memcpy(icc.pData_,data.pData_+pad,icc.size_); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES const char* iccPath = "/tmp/libexiv2_jp2.icc"; FILE* f = fopen(iccPath,"wb"); if ( f ) { @@ -295,7 +295,7 @@ namespace Exiv2 if( subBox.type == kJp2BoxTypeImageHeader) { io_->read((byte*)&ihdr, sizeof(ihdr)); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::readMetadata: Ihdr data found" << std::endl; #endif ihdr.imageHeight = getLong((byte*)&ihdr.imageHeight, bigEndian); @@ -316,7 +316,7 @@ namespace Exiv2 case kJp2BoxTypeUuid: { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::readMetadata: UUID box found" << std::endl; #endif @@ -330,7 +330,7 @@ namespace Exiv2 if(bIsExif) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::readMetadata: Exif data found" << std::endl ; #endif rawData.alloc(box.length - (sizeof(box) + sizeof(uuid))); @@ -362,7 +362,7 @@ namespace Exiv2 // If found it, store only these data at from this place. if (pos >= 0 ) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::readMetadata: Exif header found at position " << pos << std::endl; #endif ByteOrder bo = TiffParser::decode(exifData(), @@ -384,7 +384,7 @@ namespace Exiv2 if(bIsIPTC) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::readMetadata: Iptc data found" << std::endl; #endif rawData.alloc(box.length - (sizeof(box) + sizeof(uuid))); @@ -403,7 +403,7 @@ namespace Exiv2 if(bIsXMP) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::readMetadata: Xmp data found" << std::endl; #endif rawData.alloc(box.length - (uint32_t)(sizeof(box) + sizeof(uuid))); @@ -646,7 +646,7 @@ namespace Exiv2 if ( count < length ) { subBox.length = getLong((byte*)&subBox.length, bigEndian); subBox.type = getLong((byte*)&subBox.type , bigEndian); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Jp2Image::encodeJp2Header subbox: "<< toAscii(subBox.type) << " length = " << subBox.length << std::endl; #endif count += subBox.length; @@ -703,7 +703,7 @@ namespace Exiv2 if (!io_->isopen()) throw Error(kerInputDataReadFailed); if (!outIo.isopen()) throw Error(kerImageWriteFailed); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: Writing JPEG-2000 file " << io_->path() << std::endl; std::cout << "Exiv2::Jp2Image::doWriteMetadata: tmp file created " << outIo.path() << std::endl; #endif @@ -729,7 +729,7 @@ namespace Exiv2 while(io_->tell() < (long) io_->size()) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: Position: " << io_->tell() << " / " << io_->size() << std::endl; #endif @@ -745,14 +745,14 @@ namespace Exiv2 box.length = getLong(bheaderBuf.pData_, bigEndian); box.type = getLong(bheaderBuf.pData_ + 4, bigEndian); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: box type: " << toAscii(box.type) << " length: " << box.length << std::endl; #endif if (box.length == 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: Null Box size has been found. " "This is the last box of file." << std::endl; #endif @@ -770,7 +770,7 @@ namespace Exiv2 bufRead = io_->read(boxBuf.pData_ + 8, box.length - 8); // Extract box data. if (io_->error()) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: Error reading source file" << std::endl; #endif @@ -779,7 +779,7 @@ namespace Exiv2 if (bufRead != (long)(box.length - 8)) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: Cannot read source file data" << std::endl; #endif throw Error(kerInputDataReadFailed); @@ -791,7 +791,7 @@ namespace Exiv2 { DataBuf newBuf; encodeJp2Header(boxBuf,newBuf); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: Write JP2Header box (length: " << box.length << ")" << std::endl; #endif if (outIo.write(newBuf.pData_, newBuf.size_) != newBuf.size_) throw Error(kerImageWriteFailed); @@ -817,7 +817,7 @@ namespace Exiv2 memcpy(boxData.pData_ + 8, kJp2UuidExif, 16); memcpy(boxData.pData_ + 8 + 16, rawExif.pData_, rawExif.size_); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: Write box with Exif metadata (length: " << boxData.size_ << std::endl; #endif @@ -840,7 +840,7 @@ namespace Exiv2 memcpy(boxData.pData_ + 8, kJp2UuidIptc, 16); memcpy(boxData.pData_ + 8 + 16, rawIptc.pData_, rawIptc.size_); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: Write box with Iptc metadata (length: " << boxData.size_ << std::endl; #endif @@ -870,7 +870,7 @@ namespace Exiv2 memcpy(boxData.pData_ + 8, kJp2UuidXmp, 16); memcpy(boxData.pData_ + 8 + 16, xmp.pData_, xmp.size_); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: Write box with XMP metadata (length: " << boxData.size_ << ")" << std::endl; #endif @@ -884,25 +884,25 @@ namespace Exiv2 { if(memcmp(boxBuf.pData_ + 8, kJp2UuidExif, 16) == 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: strip Exif Uuid box" << std::endl; #endif } else if(memcmp(boxBuf.pData_ + 8, kJp2UuidIptc, 16) == 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: strip Iptc Uuid box" << std::endl; #endif } else if(memcmp(boxBuf.pData_ + 8, kJp2UuidXmp, 16) == 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: strip Xmp Uuid box" << std::endl; #endif } else { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: write Uuid box (length: " << box.length << ")" << std::endl; #endif if (outIo.write(boxBuf.pData_, boxBuf.size_) != boxBuf.size_) throw Error(kerImageWriteFailed); @@ -912,7 +912,7 @@ namespace Exiv2 default: { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: write box (length: " << box.length << ")" << std::endl; #endif if (outIo.write(boxBuf.pData_, boxBuf.size_) != boxBuf.size_) throw Error(kerImageWriteFailed); @@ -922,7 +922,7 @@ namespace Exiv2 } } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: EOF" << std::endl; #endif diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index dffd611de2..48ba24662a 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -151,7 +151,7 @@ namespace Exiv2 { assert(sizeData); // Used for error checking long position = 0; -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Photoshop::locateIrb: "; #endif // Data should follow Photoshop format, if not exit @@ -160,7 +160,7 @@ namespace Exiv2 { position += 4; uint16_t type = getUShort(pPsData + position, bigEndian); position += 2; -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "0x" << std::hex << type << std::dec << " "; #endif // Pascal string is padded to have an even size (including size byte) @@ -168,7 +168,7 @@ namespace Exiv2 { psSize += (psSize & 1); position += psSize; if (position + 4 > sizePsData) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Warning: " << "Invalid or extended Photoshop IRB\n"; #endif @@ -177,14 +177,14 @@ namespace Exiv2 { uint32_t dataSize = getULong(pPsData + position, bigEndian); position += 4; if (dataSize > static_cast(sizePsData - position)) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Warning: " << "Invalid Photoshop IRB data size " << dataSize << " or extended Photoshop IRB\n"; #endif return -2; } -#ifndef DEBUG +#ifndef EXIV2_DEBUG_MESSAGES if ( (dataSize & 1) && position + dataSize == static_cast(sizePsData)) { std::cerr << "Warning: " @@ -192,7 +192,7 @@ namespace Exiv2 { } #endif if (type == psTag) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "ok\n"; #endif *sizeData = dataSize; @@ -203,11 +203,11 @@ namespace Exiv2 { // Data size is also padded to be even position += dataSize + (dataSize & 1); } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "pPsData doesn't start with '8BIM'\n"; #endif if (position < sizePsData) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Warning: " << "Invalid or extended Photoshop IRB\n"; #endif @@ -241,7 +241,7 @@ namespace Exiv2 { const IptcData& iptcData) { if (sizePsData > 0) assert(pPsData); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "IRB block at the beginning of Photoshop::setIptcIrb\n"; if (sizePsData == 0) std::cerr << " None.\n"; else hexdump(std::cerr, pPsData, sizePsData); @@ -293,7 +293,7 @@ namespace Exiv2 { } // Data is rounded to be even if (psBlob.size() > 0) rc = DataBuf(&psBlob[0], static_cast(psBlob.size())); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "IRB block at the end of Photoshop::setIptcIrb\n"; if (rc.size_ == 0) std::cerr << " None.\n"; else hexdump(std::cerr, rc.pData_, rc.size_); @@ -427,7 +427,7 @@ namespace Exiv2 { DataBuf psData(size - 16); io_->read(psData.pData_, psData.size_); if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Found app13 segment, size = " << size << "\n"; //hexdump(std::cerr, psData.pData_, psData.size_); #endif @@ -476,7 +476,7 @@ namespace Exiv2 { // chunk/chunks are a single byte // Spec 7.2 Profile bytes 0-3 size uint32_t s = getULong(buf.pData_ + (2+14) , bigEndian); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Found ICC Profile chunk " << chunk << " of " << chunks << (chunk==1 ? " size: " : "" ) << (chunk==1 ? s : 0) @@ -544,7 +544,7 @@ namespace Exiv2 { while ( pCur < pEnd && 0 == Photoshop::locateIptcIrb(pCur, static_cast(pEnd - pCur), &record, &sizeHdr, &sizeIptc)) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Found IPTC IRB, size = " << sizeIptc << "\n"; #endif if (sizeIptc) { @@ -706,7 +706,7 @@ namespace Exiv2 { DataBuf icc(size - (14 + 2)); io_->read(icc.pData_, icc.size_); out.write(reinterpret_cast(icc.pData_), icc.size_); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "iccProfile size = " << icc.size_ << std::endl; #endif bufRead = size; @@ -835,7 +835,7 @@ namespace Exiv2 { } } if (option == kpsIptcErase && iptcDataSegs.size()) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "iptc data blocks: " << iptcDataSegs.size() << std::endl; uint32_t toggle = 0; for (Uint32Vector_i i = iptcDataSegs.begin(); i != iptcDataSegs.end(); i++) { @@ -860,7 +860,7 @@ namespace Exiv2 { ++it; } pos[count + 1] = io_->size() - pos[count]; -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES for (uint64_t i = 0; i < count + 2; i++) std::cout << pos[i] << " "; std::cout << std::endl; @@ -880,7 +880,7 @@ namespace Exiv2 { start = 0; // read the file 2 byte SOI long length = (long)(pos[2 * i + 1] - start); if (length) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << start << ":" << length << std::endl; #endif io_->seek(start, BasicIo::beg); @@ -999,7 +999,7 @@ namespace Exiv2 { if (io_->seek(size - bufRead, BasicIo::cur)) throw Error(kerNoImageInInputData); } else if (!foundCompletePsData && marker == app13_ && memcmp(buf.pData_ + 2, Photoshop::ps3Id_, 14) == 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Found APP13 Photoshop PS3 segment\n"; #endif if (size < 16) diff --git a/src/mrwimage.cpp b/src/mrwimage.cpp index 5a3d84af3a..a4c7bfb250 100644 --- a/src/mrwimage.cpp +++ b/src/mrwimage.cpp @@ -93,7 +93,7 @@ namespace Exiv2 { void MrwImage::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Reading MRW file " << io_->path() << "\n"; #endif if (io_->open() != 0) { diff --git a/src/orfimage.cpp b/src/orfimage.cpp index 8a36a6bb8f..2637ac6d20 100644 --- a/src/orfimage.cpp +++ b/src/orfimage.cpp @@ -101,7 +101,7 @@ namespace Exiv2 { void OrfImage::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Reading ORF file " << io_->path() << "\n"; #endif if (io_->open() != 0) { @@ -124,7 +124,7 @@ namespace Exiv2 { void OrfImage::writeMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Writing ORF file " << io_->path() << "\n"; #endif ByteOrder bo = byteOrder(); @@ -186,7 +186,7 @@ namespace Exiv2 { panaRawId }; for (unsigned int i = 0; i < EXV_COUNTOF(filteredIfds); ++i) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Warning: Exif IFD " << filteredIfds[i] << " not encoded\n"; #endif ed.erase(std::remove_if(ed.begin(), diff --git a/src/pgfimage.cpp b/src/pgfimage.cpp index c78efdd58c..f6a942f1d8 100644 --- a/src/pgfimage.cpp +++ b/src/pgfimage.cpp @@ -90,13 +90,13 @@ namespace Exiv2 { { if (io_->open() == 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PgfImage:: Creating PGF image to memory\n"; #endif IoCloser closer(*io_); if (io_->write(pgfBlank, sizeof(pgfBlank)) != sizeof(pgfBlank)) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PgfImage:: Failed to create PGF image on memory\n"; #endif } @@ -106,7 +106,7 @@ namespace Exiv2 { void PgfImage::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PgfImage::readMetadata: Reading PGF file " << io_->path() << "\n"; #endif if (io_->open() != 0) @@ -136,7 +136,7 @@ namespace Exiv2 { #endif long size = static_cast(headerSize) + 8 - io_->tell(); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PgfImage::readMetadata: Found Image data (" << size << " bytes)\n"; #endif @@ -178,7 +178,7 @@ namespace Exiv2 { if (!io_->isopen()) throw Error(kerInputDataReadFailed); if (!outIo.isopen()) throw Error(kerImageWriteFailed); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PgfImage::doWriteMetadata: Writing PGF file " << io_->path() << "\n"; std::cout << "Exiv2::PgfImage::doWriteMetadata: tmp file created " << outIo.path() << "\n"; #endif @@ -207,7 +207,7 @@ namespace Exiv2 { long imgSize = (long) img->io().size(); DataBuf imgBuf = img->io().read(imgSize); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PgfImage::doWriteMetadata: Creating image to host metadata (" << imgSize << " bytes)\n"; #endif @@ -226,7 +226,7 @@ namespace Exiv2 { byteSwap_(buffer,0,bSwap_); if (outIo.write(buffer.pData_, 4) != 4) throw Error(kerImageWriteFailed); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PgfImage: new PGF header size : " << newHeaderSize << " bytes\n"; printf("%x\n", buffer.pData_[0]); @@ -261,7 +261,7 @@ namespace Exiv2 { if (b < 0x36) // 0x36 = '6'. { // Not right Magick version. -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PgfImage::readMetadata: wrong Magick number\n"; #endif } @@ -279,7 +279,7 @@ namespace Exiv2 { int headerSize = (int) byteSwap_(buffer,0,bSwap_); if (headerSize <= 0 ) throw Error(kerNoImageInInputData); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PgfImage: PGF header size : " << headerSize << " bytes\n"; #endif diff --git a/src/pngchunk_int.cpp b/src/pngchunk_int.cpp index adab5715ac..378a1aaf9f 100644 --- a/src/pngchunk_int.cpp +++ b/src/pngchunk_int.cpp @@ -83,7 +83,7 @@ namespace Exiv2 { DataBuf key = keyTXTChunk(data); DataBuf arr = parseTXTChunk(data, key.size_, type); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngChunk::decodeTXTChunk: TXT chunk data: " << std::string((const char*)arr.pData_, arr.size_) << std::endl; #endif @@ -96,7 +96,7 @@ namespace Exiv2 { { DataBuf key = keyTXTChunk(data); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngChunk::decodeTXTChunk: TXT chunk key: " << std::string((const char*)key.pData_, key.size_) << std::endl; #endif @@ -143,7 +143,7 @@ namespace Exiv2 { if ( *compressionMethod != 0x00 ) { // then it isn't zlib compressed and we are sunk -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PngChunk::parseTXTChunk: Non-standard zTXt compression method.\n"; #endif throw Error(kerFailedToReadImageData); @@ -208,7 +208,7 @@ namespace Exiv2 { if (compressionFlag == 0x00) { // then it's an uncompressed iTXt chunk -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngChunk::parseTXTChunk: We found an uncompressed iTXt field\n"; #endif @@ -216,7 +216,7 @@ namespace Exiv2 { arr = DataBuf(text, textsize); } else if (compressionFlag == 0x01 && compressionMethod == 0x00) { // then it's a zlib compressed iTXt chunk -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngChunk::parseTXTChunk: We found a zlib compressed iTXt field\n"; #endif @@ -225,7 +225,7 @@ namespace Exiv2 { } } else { // then it isn't zlib compressed and we are sunk -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PngChunk::parseTXTChunk: Non-standard iTXt compression method.\n"; #endif throw Error(kerFailedToReadImageData); @@ -278,7 +278,7 @@ namespace Exiv2 { if (pos !=-1) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngChunk::parseChunkContent: Exif header found at position " << pos << "\n"; #endif pos = pos + sizeof(exifHeader); @@ -320,7 +320,7 @@ namespace Exiv2 { &sizeHdr, &sizeIptc)) { if (sizeIptc) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Found IPTC IRB, size = " << sizeIptc << "\n"; #endif append(iptcBlob, record + sizeHdr, sizeIptc); @@ -510,7 +510,7 @@ namespace Exiv2 { break; case Z_BUF_ERROR: // The compressed array needs to be larger -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngChunk::parsePngChunk: doubling size for compression.\n"; #endif compressedLen *= 2; @@ -680,14 +680,14 @@ namespace Exiv2 { // Allocate space if (length == 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PngChunk::readRawProfile: Unable To Copy Raw Profile: invalid profile length\n"; #endif } info.alloc(length); if (info.size_ != length) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PngChunk::readRawProfile: Unable To Copy Raw Profile: cannot allocate memory\n"; #endif return DataBuf(); @@ -705,7 +705,7 @@ namespace Exiv2 { { if (*sp == '\0') { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PngChunk::readRawProfile: Unable To Copy Raw Profile: ran out of data\n"; #endif return DataBuf(); diff --git a/src/pngimage.cpp b/src/pngimage.cpp index ea3606a463..72a2b0fe11 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -61,7 +61,6 @@ namespace { inline bool compare(const char* str, const Exiv2::DataBuf& buf, size_t length) { - // str & length should compile time constants => only running this in DEBUG mode is ok assert(strlen(str) <= length); return memcmp(str, buf.pData_, std::min(static_cast(length), buf.size_)) == 0; } @@ -80,13 +79,13 @@ namespace Exiv2 { { if (io_->open() == 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PngImage:: Creating PNG image to memory\n"; #endif IoCloser closer(*io_); if (io_->write(pngBlank, sizeof(pngBlank)) != sizeof(pngBlank)) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PngImage:: Failed to create PNG image on memory\n"; #endif } @@ -350,7 +349,7 @@ namespace Exiv2 { if ( bExif || bIptc ) { DataBuf parsedBuf = PngChunk::readRawProfile(dataBuf,tEXt); -#if DEBUG +#if EXIV2_DEBUG_MESSAGES std::cerr << Exiv2::Internal::binaryToString(parsedBuf.pData_, parsedBuf.size_>50?50:parsedBuf.size_,0) << std::endl; #endif if ( parsedBuf.size_ ) { @@ -397,7 +396,7 @@ namespace Exiv2 { void readChunk(DataBuf& buffer, BasicIo& io) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::readMetadata: Position: " << io.tell() << std::endl; #endif long bufRead = io.read(buffer.pData_, buffer.size_); @@ -411,7 +410,7 @@ namespace Exiv2 { void PngImage::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PngImage::readMetadata: Reading PNG file " << io_->path() << std::endl; #endif if (io_->open() != 0) @@ -442,7 +441,7 @@ namespace Exiv2 { } std::string chunkType(reinterpret_cast(cheaderBuf.pData_) + 4, 4); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::readMetadata: chunk type: " << chunkType << " length: " << chunkLength << std::endl; #endif @@ -477,7 +476,7 @@ namespace Exiv2 { enforce(iccOffset <= chunkLength, Exiv2::kerCorruptedMetadata); zlibToDataBuf(chunkData.pData_ + iccOffset, chunkLength - iccOffset, iccProfile_); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::readMetadata: profile name: " << profileName_ << std::endl; std::cout << "Exiv2::PngImage::readMetadata: iccProfile.size_ (uncompressed) : " << iccProfile_.size_ << std::endl; @@ -491,7 +490,7 @@ namespace Exiv2 { // Move to the next chunk: chunk data size + 4 CRC bytes. -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::readMetadata: Seek to offset: " << chunkLength + 4 << std::endl; #endif io_->seek(chunkLength + 4 , BasicIo::cur); @@ -522,7 +521,7 @@ namespace Exiv2 { if (!io_->isopen()) throw Error(kerInputDataReadFailed); if (!outIo.isopen()) throw Error(kerImageWriteFailed); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::doWriteMetadata: Writing PNG file " << io_->path() << "\n"; std::cout << "Exiv2::PngImage::doWriteMetadata: tmp file created " << outIo.path() << "\n"; #endif @@ -565,7 +564,7 @@ namespace Exiv2 { if (!memcmp(cheaderBuf.pData_ + 4, "IEND", 4)) { // Last chunk found: we write it and done. -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::doWriteMetadata: Write IEND chunk (length: " << dataOffset << ")\n"; #endif if (outIo.write(chunkBuf.pData_, chunkBuf.size_) != chunkBuf.size_) throw Error(kerImageWriteFailed); @@ -573,7 +572,7 @@ namespace Exiv2 { } else if (!memcmp(cheaderBuf.pData_ + 4, "IHDR", 4)) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::doWriteMetadata: Write IHDR chunk (length: " << dataOffset << ")\n"; #endif if (outIo.write(chunkBuf.pData_, chunkBuf.size_) != chunkBuf.size_) throw Error(kerImageWriteFailed); @@ -651,7 +650,7 @@ namespace Exiv2 { ){ throw Error(kerImageWriteFailed); } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::doWriteMetadata: build iCCP" << " chunk (length: " << compressed.size_ + chunkLength << ")" << std::endl; #endif @@ -688,14 +687,14 @@ namespace Exiv2 { compare("ICC", key, 3) || compare("Description", key, 11)) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::doWriteMetadata: strip " << szChunk << " chunk (length: " << dataOffset << ")" << std::endl; #endif } else { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::doWriteMetadata: write " << szChunk << " chunk (length: " << dataOffset << ")" << std::endl; #endif @@ -705,7 +704,7 @@ namespace Exiv2 { else { // Write all others chunk as well. -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::doWriteMetadata: copy " << szChunk << " chunk (length: " << dataOffset << ")" << std::endl; #endif diff --git a/src/properties.cpp b/src/properties.cpp index 084f5af171..402c37879c 100644 --- a/src/properties.cpp +++ b/src/properties.cpp @@ -2618,7 +2618,7 @@ namespace Exiv2 { prefix = property.substr(0, i); property = property.substr(i+1); } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Nested key: " << key.key() << ", prefix: " << prefix << ", property: " << property << "\n"; #endif diff --git a/src/psdimage.cpp b/src/psdimage.cpp index 0f6b25493a..f27e5e5a0a 100644 --- a/src/psdimage.cpp +++ b/src/psdimage.cpp @@ -141,7 +141,7 @@ namespace Exiv2 { void PsdImage::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PsdImage::readMetadata: Reading Photoshop file " << io_->path() << "\n"; #endif if (io_->open() != 0) @@ -232,7 +232,7 @@ namespace Exiv2 { uint32_t resourceSize = getULong(buf, bigEndian); uint32_t curOffset = io_->tell(); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << std::hex << "resourceId: " << resourceId << std::dec << " length: " << resourceSize << std::hex << "\n"; #endif @@ -370,7 +370,7 @@ namespace Exiv2 { if (!io_->isopen()) throw Error(kerInputDataReadFailed); if (!outIo.isopen()) throw Error(kerImageWriteFailed); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PsdImage::doWriteMetadata: Writing PSD file " << io_->path() << "\n"; std::cout << "Exiv2::PsdImage::doWriteMetadata: tmp file created " << outIo.path() << "\n"; #endif @@ -401,7 +401,7 @@ namespace Exiv2 { // Write colorDataLength ul2Data(buf, colorDataLength, bigEndian); if (outIo.write(buf, 4) != 4) throw Error(kerImageWriteFailed); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << std::dec << "colorDataLength: " << colorDataLength << "\n"; #endif // Copy colorData @@ -428,7 +428,7 @@ namespace Exiv2 { ul2Data(buf, oldResLength, bigEndian); if (outIo.write(buf, 4) != 4) throw Error(kerImageWriteFailed); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << std::dec << "oldResLength: " << oldResLength << "\n"; #endif @@ -491,7 +491,7 @@ namespace Exiv2 { if ( resourceId != kPhotoshopResourceID_IPTC_NAA && resourceId != kPhotoshopResourceID_ExifInfo && resourceId != kPhotoshopResourceID_XMPPacket) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << std::hex << "copy : resourceType: " << resourceType << "\n"; std::cerr << std::hex << "copy : resourceId: " << resourceId << "\n"; std::cerr << std::dec; @@ -560,7 +560,7 @@ namespace Exiv2 { if (outIo.error()) throw Error(kerImageWriteFailed); // Update length of resources -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "newResLength: " << newResLength << "\n"; #endif outIo.seek(resLenOffset, BasicIo::beg); @@ -577,7 +577,7 @@ namespace Exiv2 { if (iptcData.count() > 0) { DataBuf rawIptc = IptcParser::encode(iptcData); if (rawIptc.size_ > 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << std::hex << "write: resourceId: " << kPhotoshopResourceID_IPTC_NAA << "\n"; std::cerr << std::dec << "Writing IPTC_NAA: size: " << rawIptc.size_ << "\n"; #endif @@ -617,7 +617,7 @@ namespace Exiv2 { ExifParser::encode(blob, bo, exifData); if (blob.size() > 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << std::hex << "write: resourceId: " << kPhotoshopResourceID_ExifInfo << "\n"; std::cerr << std::dec << "Writing ExifInfo: size: " << blob.size() << "\n"; #endif @@ -648,7 +648,7 @@ namespace Exiv2 { uint32_t resLength = 0; byte buf[8]; -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "writeXmpFromPacket(): " << writeXmpFromPacket() << "\n"; #endif // writeXmpFromPacket(true); @@ -661,7 +661,7 @@ namespace Exiv2 { } if (xmpPacket.size() > 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << std::hex << "write: resourceId: " << kPhotoshopResourceID_XMPPacket << "\n"; std::cerr << std::dec << "Writing XMPPacket: size: " << xmpPacket.size() << "\n"; #endif diff --git a/src/rafimage.cpp b/src/rafimage.cpp index bf3d29c703..d42577c310 100644 --- a/src/rafimage.cpp +++ b/src/rafimage.cpp @@ -278,7 +278,7 @@ namespace Exiv2 { void RafImage::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Reading RAF file " << io_->path() << "\n"; #endif if (io_->open() != 0) throw Error(kerDataSourceOpenFailed, io_->path(), strError()); diff --git a/src/rw2image.cpp b/src/rw2image.cpp index faf5126168..c9629a56db 100644 --- a/src/rw2image.cpp +++ b/src/rw2image.cpp @@ -37,7 +37,7 @@ #include "futils.hpp" // + standard includes -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES # include #endif @@ -112,7 +112,7 @@ namespace Exiv2 { void Rw2Image::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Reading RW2 file " << io_->path() << "\n"; #endif if (io_->open() != 0) { @@ -160,7 +160,7 @@ namespace Exiv2 { if (pos->ifdId() == panaRawId) continue; ExifData::iterator dup = prevData.findKey(ExifKey(pos->key())); if (dup != prevData.end()) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Filtering duplicate tag " << pos->key() << " (values '" << pos->value() << "' and '" << dup->value() << "')\n"; @@ -203,7 +203,7 @@ namespace Exiv2 { for (unsigned int i = 0; i < EXV_COUNTOF(filteredTags); ++i) { ExifData::iterator pos = prevData.findKey(ExifKey(filteredTags[i])); if (pos != prevData.end()) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exif tag " << pos->key() << " removed\n"; #endif prevData.erase(pos); diff --git a/src/tgaimage.cpp b/src/tgaimage.cpp index e07e03107a..3ddb9713d8 100644 --- a/src/tgaimage.cpp +++ b/src/tgaimage.cpp @@ -71,7 +71,7 @@ namespace Exiv2 { void TgaImage::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::TgaImage::readMetadata: Reading TARGA file " << io_->path() << "\n"; #endif if (io_->open() != 0) diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index 3fe73263e0..8c792c0031 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -1099,7 +1099,7 @@ namespace Exiv2 { // Remember the offset of the CR2 RAW IFD if (group() == ifd3Id) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Directory " << groupName(group()) << " offset is 0x" << std::setw(8) << std::setfill('0') << std::hex << offset << std::dec << "\n"; @@ -1314,7 +1314,7 @@ namespace Exiv2 { uint32_t o2 = imageIdx; // For makernotes, write TIFF image data to the data area if (group() > mnId) o2 = offset + dataIdx; -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "TiffImageEntry, Directory " << groupName(group()) << ", entry 0x" << std::setw(4) << std::setfill('0') << std::hex << tag() << std::dec @@ -1613,7 +1613,7 @@ namespace Exiv2 { uint32_t len = pValue()->sizeDataArea(); if (len > 0) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "TiffImageEntry, Directory " << groupName(group()) << ", entry 0x" << std::setw(4) << std::setfill('0') << std::hex << tag() << std::dec @@ -1626,7 +1626,7 @@ namespace Exiv2 { len += align; } else { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "TiffImageEntry, Directory " << groupName(group()) << ", entry 0x" << std::setw(4) << std::setfill('0') << std::hex << tag() << std::dec @@ -1641,7 +1641,7 @@ namespace Exiv2 { len += align; } } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << ", len = " << len << " bytes\n"; #endif return len; diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp index c255d0a6cc..21f672971f 100644 --- a/src/tiffimage.cpp +++ b/src/tiffimage.cpp @@ -168,7 +168,7 @@ namespace Exiv2 { void TiffImage::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Reading TIFF file " << io_->path() << "\n"; #endif if (io_->open() != 0) { @@ -207,7 +207,7 @@ namespace Exiv2 { void TiffImage::writeMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Writing TIFF file " << io_->path() << "\n"; #endif ByteOrder bo = byteOrder(); @@ -283,7 +283,7 @@ namespace Exiv2 { panaRawId }; for (unsigned int i = 0; i < EXV_COUNTOF(filteredIfds); ++i) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Warning: Exif IFD " << filteredIfds[i] << " not encoded\n"; #endif ed.erase(std::remove_if(ed.begin(), diff --git a/src/tiffimage_int.cpp b/src/tiffimage_int.cpp index fba115068e..a052a6a308 100644 --- a/src/tiffimage_int.cpp +++ b/src/tiffimage_int.cpp @@ -1562,7 +1562,7 @@ namespace Exiv2 { if (ts && ts->newTiffCompFct_) { tc = ts->newTiffCompFct_(tag, group); } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES else { if (!ts) { std::cerr << "Warning: No TIFF structure entry found for "; @@ -1944,13 +1944,13 @@ namespace Exiv2 { // If tag, group is one of the image tags listed above -> bingo! if (find(tiffImageTags, TiffImgTagStruct::Key(tag, group))) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES ExifKey key(tag, groupName(group)); std::cerr << "Image tag: " << key << " (3)\n"; #endif return true; } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Not an image tag: " << tag << " (4)\n"; #endif return false; @@ -1971,12 +1971,12 @@ namespace Exiv2 { const PrimaryGroups* pPrimaryGroups) const { if (!hasImageTags_) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "No image tags in this image\n"; #endif return false; } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES ExifKey key(tag, groupName(group)); #endif // If there are primary groups and none matches group, we're done @@ -1984,7 +1984,7 @@ namespace Exiv2 { && !pPrimaryGroups->empty() && std::find(pPrimaryGroups->begin(), pPrimaryGroups->end(), group) == pPrimaryGroups->end()) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Not an image tag: " << key << " (1)\n"; #endif return false; @@ -1994,7 +1994,7 @@ namespace Exiv2 { if ( pPrimaryGroups != 0 && !pPrimaryGroups->empty() && group != ifd0Id) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES ExifKey key(tag, groupName(group)); std::cerr << "Image tag: " << key << " (2)\n"; #endif diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index 7521213d6e..1e8615a461 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -218,7 +218,7 @@ namespace Exiv2 { TiffPath tiffPath; TiffCreator::getPath(tiffPath, object->tag(), object->group(), root_); pRoot_->addPath(object->tag(), tiffPath, pRoot_, clone); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES ExifKey key(object->tag(), groupName(object->group())); std::cerr << "Copied " << key << "\n"; #endif @@ -698,7 +698,7 @@ namespace Exiv2 { ul2Data(buf + 4, pTiffEntry->count(), byteOrder); // Move data to offset field, if it fits and is not yet there. if (pTiffEntry->size() <= 4 && buf + 8 != pTiffEntry->pData()) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Copying data for tag " << pTiffEntry->tag() << " to offset area.\n"; #endif @@ -843,7 +843,7 @@ namespace Exiv2 { } else { setDirty(); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "DELETING " << key << ", idx = " << object->idx() << "\n"; #endif } @@ -870,7 +870,7 @@ namespace Exiv2 { if (del_ && pos != exifData_.end()) { exifData_.erase(pos); } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "\n"; #endif } // TiffEncoder::encodeTiffComponent @@ -894,7 +894,7 @@ namespace Exiv2 { assert(object->pValue()); if ( object->sizeDataArea_ < static_cast(object->pValue()->sizeDataArea())) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES ExifKey key(object->tag(), groupName(object->group())); std::cerr << "DATAAREA GREW " << key << "\n"; #endif @@ -902,7 +902,7 @@ namespace Exiv2 { } else { // Write the new dataarea, fill with 0x0 -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES ExifKey key(object->tag(), groupName(object->group())); std::cerr << "Writing data area for " << key << "\n"; #endif @@ -929,14 +929,14 @@ namespace Exiv2 { uint32_t sizeDataArea = object->pValue()->sizeDataArea(); if (sizeDataArea > 0 && writeMethod() == wmNonIntrusive) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "\t DATAAREA IS SET (NON-INTRUSIVE WRITING)"; #endif setDirty(); } if (sizeDataArea > 0 && writeMethod() == wmIntrusive) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "\t DATAAREA IS SET (INTRUSIVE WRITING)"; #endif // Set pseudo strips (without a data pointer) from the size tag @@ -972,7 +972,7 @@ namespace Exiv2 { } if (sizeDataArea == 0 && writeMethod() == wmIntrusive) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "\t USE STRIPS FROM SOURCE TREE IMAGE ENTRY"; #endif // Set strips from source tree @@ -1015,18 +1015,18 @@ namespace Exiv2 { assert(object != 0); assert(datum != 0); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES bool tooLarge = false; #endif uint32_t newSize = datum->size(); if (newSize > object->size_) { // value doesn't fit, encode for intrusive writing setDirty(); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES tooLarge = true; #endif } object->updateValue(datum->getValue(), byteOrder()); // clones the value -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES ExifKey key(object->tag(), groupName(object->group())); std::cerr << "UPDATING DATA " << key; if (tooLarge) { @@ -1044,7 +1044,7 @@ namespace Exiv2 { if (newSize > object->size_) { // value doesn't fit, encode for intrusive writing setDirty(); object->updateValue(datum->getValue(), byteOrder()); // clones the value -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES ExifKey key(object->tag(), groupName(object->group())); std::cerr << "UPDATING DATA " << key; std::cerr << "\t\t\t ALLOCATED " << object->size() << " BYTES"; @@ -1052,7 +1052,7 @@ namespace Exiv2 { } else { object->setValue(datum->getValue()); // clones the value -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES ExifKey key(object->tag(), groupName(object->group())); std::cerr << "NOT UPDATING " << key; std::cerr << "\t\t\t PRESERVE VALUE DATA"; @@ -1098,7 +1098,7 @@ namespace Exiv2 { TiffCreator::getPath(tiffPath, i->tag(), group, root); TiffComponent* tc = pRootDir->addPath(i->tag(), tiffPath, pRootDir); TiffEntryBase* object = dynamic_cast(tc); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES if (object == 0) { std::cerr << "Warning: addPath() didn't add an entry for " << i->groupName() @@ -1425,11 +1425,11 @@ namespace Exiv2 { EXV_ERROR << "Failed to read " << groupName(object->ifd_.group()) << " IFD Makernote header.\n"; -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES if (static_cast(pLast_ - object->start()) >= 16) { hexdump(std::cerr, object->start(), 16); } -#endif // DEBUG +#endif // EXIV2_DEBUG_MESSAGES #endif // SUPPRESS_WARNINGS setGo(geKnownMakernote, false); return; diff --git a/src/webpimage.cpp b/src/webpimage.cpp index ea6041ef01..3e4773f0af 100644 --- a/src/webpimage.cpp +++ b/src/webpimage.cpp @@ -140,7 +140,7 @@ namespace Exiv2 { if (!io_->isopen()) throw Error(kerInputDataReadFailed); if (!outIo.isopen()) throw Error(kerImageWriteFailed); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Writing metadata" << std::endl; #endif @@ -518,7 +518,7 @@ namespace Exiv2 { byte size_buff[WEBP_TAG_SIZE]; bool has_canvas_data = false; -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Reading metadata" << std::endl; #endif @@ -674,7 +674,7 @@ namespace Exiv2 { memcpy(rawExifData + offset, payload.pData_, payload.size_); -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Display Hex Dump [size:" << (unsigned long)size << "]" << std::endl; std::cout << Internal::binaryToHex(rawExifData, size); #endif @@ -703,7 +703,7 @@ namespace Exiv2 { EXV_WARNING << "Failed to decode XMP metadata." << std::endl; #endif } else { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cout << "Display Hex Dump [size:" << (unsigned long)payload.size_ << "]" << std::endl; std::cout << Internal::binaryToHex(payload.pData_, payload.size_); #endif diff --git a/src/xmp.cpp b/src/xmp.cpp index a880da3392..d426c1ef1c 100644 --- a/src/xmp.cpp +++ b/src/xmp.cpp @@ -753,7 +753,7 @@ namespace Exiv2 { // Register custom namespaces with XMP-SDK for (XmpProperties::NsRegistry::iterator i = XmpProperties::nsRegistry_.begin(); i != XmpProperties::nsRegistry_.end(); ++i) { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Registering " << i->second.prefix_ << " : " << i->first << "\n"; #endif registerNs(i->first, i->second.prefix_); @@ -930,7 +930,7 @@ namespace { return var; } -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES void printNode(const std::string& schemaNs, const std::string& propPath, const std::string& propValue, @@ -973,7 +973,7 @@ namespace { const std::string& , const XMP_OptionBits& ) {} -#endif // DEBUG +#endif // EXIV2_DEBUG_MESSAGES Exiv2::XmpKey::AutoPtr makeXmpKey(const std::string& schemaNs, const std::string& propPath) diff --git a/src/xmpsidecar.cpp b/src/xmpsidecar.cpp index b9fa62c6f6..3146721769 100644 --- a/src/xmpsidecar.cpp +++ b/src/xmpsidecar.cpp @@ -75,7 +75,7 @@ namespace Exiv2 { void XmpSidecar::readMetadata() { -#ifdef DEBUG +#ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Reading XMP file " << io_->path() << "\n"; #endif if (io_->open() != 0) {