diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 3f546ed5..de3a9de7 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -30,8 +30,6 @@ set( SAMPLES xmpprint.cpp xmpsample.cpp xmpdump.cpp - crwedit.cpp - crwparse.cpp ) ## diff --git a/samples/crwedit.cpp b/samples/crwedit.cpp deleted file mode 100644 index 920477b7..00000000 --- a/samples/crwedit.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// ***************************************************************** -*- C++ -*- -// crwedit.cpp -// Print the CIFF structure of a CRW file - -#include "crwimage.hpp" -#include "crwimage_int.hpp" -#include "futils.hpp" - -#include -#include -#include - -void remove(Exiv2::Internal::CiffHeader* pHead); -void add(Exiv2::Internal::CiffHeader* pHead); -void help(); -void write(const std::string& filename, const Exiv2::Internal::CiffHeader* pHead); - -int main(int argc, char* const argv[]) -{ - try { - if (argc != 2) { - std::cout << "Usage: " << argv[0] << " file\n"; - std::cout << "Edit the CIFF structure of a CRW file\n"; - return 1; - } - - std::string filename(argv[1]); - Exiv2::FileIo io(filename); - if (io.open() != 0) { - throw Exiv2::Error(Exiv2::kerDataSourceOpenFailed, io.path(), Exiv2::strError()); - } - Exiv2::IoCloser closer(io); - - // Ensure that this is a CRW image - if (!Exiv2::isCrwType(io, false)) { - if (io.error() || io.eof()) - throw Exiv2::Error(Exiv2::kerFailedToReadImageData); - throw Exiv2::Error(Exiv2::kerNotACrwImage); - } - - // Read the image into a memory buffer - long len = (long)io.size(); - Exiv2::DataBuf buf(len); - io.read(buf.pData_, len); - if (io.error() || io.eof()) - throw Exiv2::Error(Exiv2::kerFailedToReadImageData); - - // Parse the image, starting with a CIFF header component - Exiv2::Internal::CiffHeader::AutoPtr parseTree(new Exiv2::Internal::CiffHeader); - parseTree->read(buf.pData_, buf.size_); - - // Allow user to make changes - bool go = true; - while (go) { - char cmd; - std::cout << "command> "; - std::cin >> cmd; - switch (cmd) { - case 'q': - go = false; - break; - case 'p': - parseTree->print(std::cout); - break; - case 'a': - add(parseTree.get()); - break; - case 'd': - remove(parseTree.get()); - break; - case 'w': - write(filename, parseTree.get()); - break; - case 'h': - help(); - break; - } - } - - return 0; - } catch (Exiv2::AnyError& e) { - std::cerr << e << "\n"; - return -1; - } -} - -void write(const std::string& filename, const Exiv2::Internal::CiffHeader* pHead) -{ - Exiv2::Blob blob; - pHead->write(blob); - - Exiv2::FileIo io(filename); - if (io.open("wb") != 0) { - throw Exiv2::Error(Exiv2::kerDataSourceOpenFailed, io.path(), Exiv2::strError()); - } - Exiv2::IoCloser closer(io); - long ret = io.write(&blob[0], (long)blob.size()); - if (static_cast(ret) != blob.size()) - throw Exiv2::Error(Exiv2::kerImageWriteFailed); - io.close(); -} - -void remove(Exiv2::Internal::CiffHeader* pHead) -{ - uint16_t crwTag, crwDir; - std::cout << "crwTag> 0x"; - std::cin >> std::hex >> crwTag; - std::cout << "crwDir> 0x"; - std::cin >> std::hex >> crwDir; - std::cout << "Deleting tag 0x" << std::hex << crwTag << " in dir 0x" << crwDir << ", ok? "; - char cmd; - std::cin >> cmd; - if (cmd != 'n' && cmd != 'N') { - pHead->remove(crwTag, crwDir); - } else { - std::cout << "Canceled.\n"; - } -} - -void add(Exiv2::Internal::CiffHeader* pHead) -{ - uint16_t crwTag, crwDir; - uint32_t size; - std::cout << "crwTag> 0x"; - std::cin >> std::hex >> crwTag; - std::cout << "crwDir> 0x"; - std::cin >> std::hex >> crwDir; - std::cout << "size> "; - std::cin >> std::dec >> size; - std::cout << "Adding tag 0x" << std::hex << crwTag << " in dir 0x" << crwDir << ", " << size << " bytes, ok? "; - char cmd; - std::cin >> cmd; - if (cmd != 'n' && cmd != 'N') { - Exiv2::DataBuf buf(size); - std::memset(buf.pData_, 0xaa, size); - pHead->add(crwTag, crwDir, buf); - } else { - std::cout << "Canceled.\n"; - } -} - -void help() -{ - std::cout << "a: add tag, d: delete tag, p: print tags, w: write file, q: quit\n"; -} diff --git a/samples/crwparse.cpp b/samples/crwparse.cpp deleted file mode 100644 index 62a0846d..00000000 --- a/samples/crwparse.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// ***************************************************************** -*- C++ -*- -// crwparse.cpp -// Print the CIFF structure of a CRW file - -#include "crwimage.hpp" -#include "crwimage_int.hpp" -#include "futils.hpp" - -#include - -int main(int argc, char* const argv[]) -{ - try { - if (argc != 2) { - std::cout << "Usage: " << argv[0] << " file\n"; - std::cout << "Print the CIFF structure of a CRW file\n"; - return 1; - } - - Exiv2::FileIo io(argv[1]); - if (io.open() != 0) { - throw Exiv2::Error(Exiv2::kerDataSourceOpenFailed, io.path(), Exiv2::strError()); - } - Exiv2::IoCloser closer(io); - - // Ensure that this is a CRW image - if (!Exiv2::isCrwType(io, false)) { - if (io.error() || io.eof()) - throw Exiv2::Error(Exiv2::kerFailedToReadImageData); - throw Exiv2::Error(Exiv2::kerNotACrwImage); - } - - // Read the image into a memory buffer - long len = io.size(); - Exiv2::DataBuf buf(len); - io.read(buf.pData_, len); - if (io.error() || io.eof()) - throw Exiv2::Error(Exiv2::kerFailedToReadImageData); - - // Parse the image, starting with a CIFF header component - Exiv2::Internal::CiffHeader::AutoPtr parseTree(new Exiv2::Internal::CiffHeader); - parseTree->read(buf.pData_, buf.size_); - parseTree->print(std::cout); - - return 0; - } catch (Exiv2::AnyError& e) { - std::cerr << e << "\n"; - return -1; - } -} diff --git a/src/timegm.h b/src/timegm.h index 76839130..7353db95 100644 --- a/src/timegm.h +++ b/src/timegm.h @@ -3,22 +3,10 @@ @brief Declaration of timegm(). The implementation is in localtime.c */ #pragma once - #include -#ifdef __cplusplus -extern "C" { -#endif - // The UTC version of mktime -/* rmills - timegm is replaced with _mkgmtime on VC 2005 and up */ -/* - see localtime.c */ -#if !defined(_MSC_VER) || (_MSC_VER < 1400) -time_t timegm(struct tm * const tmp); -#else +/* timegm is replaced with _mkgmtime on Windows (msvc && mingw) */ +#if defined(__MINGW__) || defined(_MSC_VER) #define timegm _mkgmtime #endif - -#ifdef __cplusplus -} -#endif