Fixes for MinGW and MSVC

This commit is contained in:
Andreas Huggel 2006-01-18 11:34:45 +00:00
parent cbc9a5bbaa
commit 7eac9bbe92
6 changed files with 68 additions and 21 deletions

View File

@ -253,6 +253,9 @@
<File
RelativePath="..\..\src\jpgimage.cpp">
</File>
<File
RelativePath="..\..\src\localtime.c">
</File>
<File
RelativePath="..\..\src\makernote.cpp">
<FileConfiguration

View File

@ -53,7 +53,7 @@ extern "C"
enum DllTypeId { invalidTypeId, unsignedByte, asciiString, unsignedShort,
unsignedLong, unsignedRational, invalid6, undefined,
signedShort, signedLong, signedRational,
string, date, time,
string, isoDate, isoTime,
lastTypeId };
typedef bool (CALLBACK* METAENUMPROC)(const char *key, const char *value, void *user);

View File

@ -55,15 +55,19 @@ CCSRC = basicio.cpp canonmn.cpp crwimage.cpp datasets.cpp error.cpp exif.cpp \
makernote.cpp metadatum.cpp nikonmn.cpp olympusmn.cpp panasonicmn.cpp \
sigmamn.cpp sonymn.cpp tags.cpp types.cpp value.cpp
# Add library C source files to this list
ifndef HAVE_TIMEGM
CSRC = localtime.c
endif
# Add source files of simple applications to this list
BINSRC = addmoddel.cpp dataarea-test.cpp exifcomment.cpp exifdata-test.cpp \
exifprint.cpp ifd-test.cpp iotest.cpp iptceasy.cpp iptcprint.cpp \
iptctest.cpp key-test.cpp makernote-test.cpp taglist.cpp write-test.cpp \
write2-test.cpp crwparse.cpp crwedit.cpp
BINSRC = addmoddel.cpp crwedit.cpp crwparse.cpp dataarea-test.cpp \
exifcomment.cpp exifdata-test.cpp exifprint.cpp ifd-test.cpp iotest.cpp \
iptceasy.cpp iptcprint.cpp iptctest.cpp key-test.cpp makernote-test.cpp \
taglist.cpp write-test.cpp write2-test.cpp
# Main source file of the Exiv2 application
EXIV2MAIN = exiv2.cpp
# Add additional source files of the Exiv2 application to this list
EXIV2SRC = actions.cpp utils.cpp
# C source files of the Exiv2 application
@ -73,7 +77,6 @@ endif
# State the main source file of the metacopy application here
MCMAIN = metacopy.cpp
# Add additional source files of the metacopy application to this list
MCSRC = utils.cpp
@ -105,13 +108,17 @@ CCHDR := $(CCHDR) $(CCSRC:.cpp=.hpp)
CCOBJ = $(CCSRC:.cpp=.o)
CCLOBJ = $(CCSRC:.cpp=.lo)
SRC = $(CCSRC)
COBJ = $(CSRC:.c=.o)
CLOBJ = $(CSRC:.c=.lo)
SRC = $(CCSRC) $(CSRC)
HDR = $(CCHDR)
OBJ = $(CCOBJ)
LOBJ = $(CCLOBJ)
OBJ = $(CCOBJ) $(COBJ)
LOBJ = $(CCLOBJ) $(CLOBJ)
DEPDIR = .deps
DEP = $(CCSRC:%.cpp=$(DEPDIR)/%.d) $(BINSRC:%.cpp=$(DEPDIR)/%.d) \
DEP = $(CCSRC:%.cpp=$(DEPDIR)/%.d) $(CSRC:%.c=$(DEPDIR)/%.d) \
$(BINSRC:%.cpp=$(DEPDIR)/%.d) \
$(EXIV2MAIN:%.cpp=$(DEPDIR)/%.d) $(EXIV2SRC:%.cpp=$(DEPDIR)/%.d) \
$(EXIVCSRC:%.c=$(DEPDIR)/%.d) $(MCMAIN:%.cpp=$(DEPDIR)/%.d) \
$(MCSRC:%.cpp=$(DEPDIR)/%.d) $(DEPDIR)/path-test.d
@ -143,11 +150,16 @@ LINK.cc = $(CXX) $(CXXFLAGS) $(LDLIBS) $(LDFLAGS) -rpath $(libdir)
# ******************************************************************************
# Rules
$(OBJ): %.o: %.cpp
$(CCOBJ): %.o: %.cpp
@$(LIBTOOL) --mode=compile $(COMPILE.cc) -o $@ $<
@$(MAKEDEPEND)
@$(POSTDEPEND)
$(COBJ): %.o: %.c
@$(LIBTOOL) --mode=compile $(COMPILE.c) -o $@ $<
@$(MAKEDEPEND)
@$(POSTDEPEND)
$(sort $(BINOBJ) $(EXIV2OBJ) $(MCOBJ) path-test.o): %.o: %.cpp
$(COMPILE.cc) -o $@ $<
@$(MAKEDEPEND)
@ -241,7 +253,7 @@ uninstall: uninstall-lib
-rmdir $(DESTDIR)$(bindir)
ctags:
ebrowse $(CCHDR) $(CCSRC)
ebrowse $(HDR) $(SRC)
# ctags-exuberant --extra=+q -e *
# ctags-exuberant --extra=+q *
@ -253,7 +265,7 @@ mostlyclean:
$(RM) $(CCSRC:.cpp=.ii)
$(RM) lib
$(RM) path-test.o
$(RM) $(CCSRC:%.cpp=.libs/%.d)
$(RM) $(CCSRC:%.cpp=.libs/%.d) $(CSRC:%.c=.libs/%.d)
@$(LIBTOOL) --mode=clean $(RM) $(LOBJ) $(sort $(BINOBJ) $(EXIV2OBJ) $(EXIV2COBJ) $(MCOBJ))
clean: mostlyclean

View File

@ -38,7 +38,6 @@ EXIV2_RCSID("@(#) $Id$");
#ifdef _MSC_VER
# include "exv_msvc.h"
#else
# define _XOPEN_SOURCE /* glibc2 needs this for strptime */
# include "exv_conf.h"
#endif
@ -57,6 +56,7 @@ EXIV2_RCSID("@(#) $Id$");
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#ifndef EXV_HAVE_TIMEGM
# include "timegm.h"
#endif
@ -242,7 +242,7 @@ namespace Exiv2 {
// Write new buffer to file
BasicIo::AutoPtr tempIo(io_->temporary()); // may throw
assert (tempIo.get() != 0);
tempIo->write(&blob[0], blob.size());
tempIo->write(&blob[0], static_cast<long>(blob.size()));
io_->close();
io_->transfer(*tempIo); // may throw
@ -1004,7 +1004,7 @@ namespace Exiv2 {
if (tm) {
const size_t m = 20;
char s[m];
std::strftime(s, m, "%Y:%m:%d %T", tm);
std::strftime(s, m, "%Y:%m:%d %H:%M:%S", tm);
ExifKey key(pCrwMapping->tag_, ExifTags::ifdItem(pCrwMapping->ifdId_));
AsciiValue value;
@ -1132,7 +1132,7 @@ namespace Exiv2 {
CiffComponent* cc = pHead->findComponent(pCrwMapping->crwTagId_,
pCrwMapping->crwDir_);
if (!comment.empty()) {
uint32_t size = comment.size();
uint32_t size = static_cast<uint32_t>(comment.size());
if (cc && cc->size() > size) size = cc->size();
DataBuf buf(size);
memset(buf.pData_, 0x0, buf.size_);
@ -1197,7 +1197,7 @@ namespace Exiv2 {
}
if (buf.size_ > 0) {
// Write the number of shorts to the beginning of buf
us2Data(buf.pData_, buf.size_, pHead->byteOrder());
us2Data(buf.pData_, static_cast<uint16_t>(buf.size_), pHead->byteOrder());
pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, buf);
}
else {
@ -1217,8 +1217,9 @@ namespace Exiv2 {
const ExifData::const_iterator ed = image.exifData().findKey(key);
if (ed != image.exifData().end()) {
struct tm tm;
char* p = strptime(ed->toString().c_str(), "%Y:%m:%d %T", &tm);
if (p != 0) t = timegm(&tm);
memset(&tm, 0x0, sizeof(tm));
int rc = exifTime(ed->toString().c_str(), &tm);
if (rc == 0) t = timegm(&tm);
}
if (t != 0) {
DataBuf buf(12);

View File

@ -40,6 +40,9 @@ EXIV2_RCSID("@(#) $Id$");
#include <sstream>
#include <utility>
#include <cctype>
#include <ctime>
#include <cstdio>
#include <cassert>
// *****************************************************************************
// class member definitions
@ -311,4 +314,24 @@ namespace Exiv2 {
return true;
} // isHex
int exifTime(const char* buf, struct tm* tm)
{
assert(buf != 0);
assert(tm != 0);
int rc = 1;
int year, mon, mday, hour, min, sec;
int scanned = sscanf(buf, "%4d:%2d:%2d %2d:%2d:%2d",
&year, &mon, &mday, &hour, &min, &sec);
if (scanned == 6) {
tm->tm_year = year - 1900;
tm->tm_mon = mon - 1;
tm->tm_mday = mday;
tm->tm_hour = hour;
tm->tm_min = min;
tm->tm_sec = sec;
rc = 0;
}
return rc;
} // exifTime
} // namespace Exiv2

View File

@ -48,6 +48,7 @@
#ifdef EXV_HAVE_STDINT_H
# include <stdint.h>
#endif
#include <ctime>
// MSVC doesn't provide C99 types, but it has MS specific variants
#ifdef _MSC_VER
@ -284,6 +285,13 @@ namespace Exiv2 {
size_t size =0,
const std::string& prefix ="");
/*!
@brief Converts a string in the form "%Y:%m:%d %H:%M:%S", e.g.,
"2007:05:24 12:31:55" to broken down time format,
returns 0 if successful, else 1.
*/
int exifTime(const char* buf, struct tm* tm);
// *****************************************************************************
// template and inline definitions