commit 07655896cad10d25f407714341fb07e2a7c5bba0 parent 8aca9dac797109fec1234bc99cdc87ad439d34d2 Author: Christian Grothoff <christian@grothoff.org> Date: Sun, 3 Jul 2005 19:52:16 +0000 fixes Diffstat:
| A | src/plugins/exiv2/exv_conf.h | | | 161 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/plugins/exiv2/exv_msvc.h | | | 41 | +++++++++++++++++++++++++++++++++++++++++ |
| A | src/plugins/exiv2/getopt_win32.h | | | 140 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| D | src/plugins/exiv2/metacopy.cpp | | | 182 | ------------------------------------------------------------------------------- |
| D | src/plugins/exiv2/metacopy.hpp | | | 86 | ------------------------------------------------------------------------------- |
| A | src/plugins/exiv2/private.h | | | 235 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/plugins/exiv2/timegm.h | | | 88 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/plugins/exiv2/tzfile.h | | | 193 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
8 files changed, 858 insertions(+), 268 deletions(-)
diff --git a/src/plugins/exiv2/exv_conf.h b/src/plugins/exiv2/exv_conf.h @@ -0,0 +1,161 @@ +/* ./config/config.h. Generated by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +/* #undef EXV_CRAY_STACKSEG_END */ + +/* Define to 1 if using `alloca.c'. */ +/* #undef EXV_C_ALLOCA */ + +/* Define to 1 if you have the `alarm' function. */ +#define EXV_HAVE_ALARM 1 + +/* Define to 1 if you have `alloca', as a function or macro. */ +#define EXV_HAVE_ALLOCA 1 + +/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). + */ +#define EXV_HAVE_ALLOCA_H 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define EXV_HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the <libintl.h> header file. */ +#define EXV_HAVE_LIBINTL_H 1 + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#define EXV_HAVE_MALLOC 1 + +/* Define to 1 if you have the <malloc.h> header file. */ +#define EXV_HAVE_MALLOC_H 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define EXV_HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define EXV_HAVE_MEMSET 1 + +/* Define to 1 if `stat' has the bug that it succeeds when given the + zero-length file name argument. */ +/* #undef EXV_HAVE_STAT_EMPTY_STRING_BUG */ + +/* Define to 1 if stdbool.h conforms to C99. */ +#define EXV_HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define EXV_HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define EXV_HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strchr' function. */ +#define EXV_HAVE_STRCHR 1 + +/* Define to 1 if you have the `strerror' function. */ +#define EXV_HAVE_STRERROR 1 + +/* Define to 1 if you have the `strftime' function. */ +#define EXV_HAVE_STRFTIME 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define EXV_HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define EXV_HAVE_STRING_H 1 + +/* Define to 1 if you have the `strtol' function. */ +#define EXV_HAVE_STRTOL 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define EXV_HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/time.h> header file. */ +#define EXV_HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define EXV_HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the `timegm' function. */ +#define EXV_HAVE_TIMEGM 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define EXV_HAVE_UNISTD_H 1 + +/* Define to 1 if you have the <wchar.h> header file. */ +#define EXV_HAVE_WCHAR_H 1 + +/* Define to 1 if the system has the type `_Bool'. */ +#define EXV_HAVE__BOOL 1 + +/* Define to 1 if `lstat' dereferences a symlink specified with a trailing + slash. */ +#define EXV_LSTAT_FOLLOWS_SLASHED_SYMLINK 1 + +/* Define to the address where bug reports for this package should be sent. */ +#define EXV_PACKAGE_BUGREPORT "ahuggel@gmx.net" + +/* Define to the full name of this package. */ +#define EXV_PACKAGE_NAME "Exiv2" + +/* Define to the full name and version of this package. */ +#define EXV_PACKAGE_STRING "Exiv2 0.7" + +/* Define to the one symbol short name of this package. */ +#define EXV_PACKAGE_TARNAME "exiv2" + +/* Define to the version of this package. */ +#define EXV_PACKAGE_VERSION "0.7" + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +/* #undef EXV_STACK_DIRECTION */ + +/* Define to 1 if you have the ANSI C header files. */ +#define EXV_STDC_HEADERS 1 + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +#define EXV_TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your <sys/time.h> declares `struct tm'. */ +/* #undef EXV_TM_IN_SYS_TIME */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to rpl_malloc if the replacement function should be used. */ +/* #undef malloc */ + +/* Define to `int' if <sys/types.h> does not define. */ +/* #undef pid_t */ + +/* Define to `unsigned' if <sys/types.h> does not define. */ +/* #undef size_t */ + +#if defined __CYGWIN32__ && !defined __CYGWIN__ + /* For backwards compatibility with Cygwin b19 and + earlier, we define __CYGWIN__ here, so that + we can rely on checking just for that macro. */ +#define __CYGWIN__ __CYGWIN32__ +#endif + +/* File path seperator */ +#if defined WIN32 && !defined __CYGWIN__ +#define EXV_SEPERATOR_STR "\\" +#define EXV_SEPERATOR_CHR '\\' +#else +#define EXV_SEPERATOR_STR "/" +#define EXV_SEPERATOR_CHR '/' +#endif diff --git a/src/plugins/exiv2/exv_msvc.h b/src/plugins/exiv2/exv_msvc.h @@ -0,0 +1,41 @@ +/* ***************************************************************** -*- C -*- */ +/*! + @file exv_msvc.h + @brief Configuration settings for MSVC + @version $Rev$ + @author Andreas Huggel (ahu) + <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a> + @date 07-Feb-04, ahu: created + 26-Feb-05, ahu: renamed and moved to src directory + */ + +/* Todo: The PACKAGE_* defines should be generated */ + +#ifdef _MSC_VER + +/* Define to 1 if you have the <process.h> header file. */ +#define EXV_HAVE_PROCESS_H 1 + +/* Define to the address where bug reports for this package should be sent. */ +#define EXV_PACKAGE_BUGREPORT "ahuggel@gmx.net" + +/* Define to the full name of this package. */ +#define EXV_PACKAGE_NAME "Exiv2" + +/* Define to the full name and version of this package. */ +#define EXV_PACKAGE_STRING "Exiv2 0.7" + +/* Define to the one symbol short name of this package. */ +#define EXV_PACKAGE_TARNAME "exiv2" + +/* Define to the version of this package. */ +#define EXV_PACKAGE_VERSION "0.7" + +/* Define to `int' if <sys/types.h> does not define pid_t. */ +#define pid_t int + +/* File path seperator */ +#define EXV_SEPERATOR_STR "\\" +#define EXV_SEPERATOR_CHR '\\' + +#endif /* _MSC_VER */ diff --git a/src/plugins/exiv2/getopt_win32.h b/src/plugins/exiv2/getopt_win32.h @@ -0,0 +1,140 @@ +/* Declarations for getopt. + Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef _GETOPT_H +#define _GETOPT_H 1 + +#ifdef _MSC_VER + +#if defined(_MSC_VER) && !defined(BUILD_GETOPT) +# ifdef _DEBUG +# pragma comment(lib,"getopt_debug.lib") +# else +# pragma comment(lib,"getopt.lib") +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ +#if __STDC__ || _MSC_VER || defined(XP_OS2_VACPP) + const char *name; +#else + char *name; +#endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +#if __STDC__ || _MSC_VER || defined( XP_OS2_VACPP ) +#if defined(__GNU_LIBRARY__) || defined( XP_OS2_VACPP ) || defined(_MSC_VER) +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int argc, char *const *argv, const char *shortopts); +#else /* not __GNU_LIBRARY__ */ +extern int getopt (); +#endif /* not __GNU_LIBRARY__ */ +extern int getopt_long (int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); +extern int getopt_long_only (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind, + int long_only); +#else /* not __STDC__ */ +extern int getopt (); +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +#endif /* not __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _MSC_VER */ +#endif /* _GETOPT_H */ diff --git a/src/plugins/exiv2/metacopy.cpp b/src/plugins/exiv2/metacopy.cpp @@ -1,182 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/* - Abstract : Tester application for image file handling - - File : metacopy.cpp - Version : $Rev: 560 $ - Author(s): Brad Schick (brad) <brad@robotbattle.com> - History : 13-Jul-04, brad: created - */ -// ***************************************************************************** -// included header files -#include "image.hpp" -#include "iptc.hpp" -#include "exif.hpp" -#include "types.hpp" -#include "metacopy.hpp" -#include <iostream> -#include <fstream> -#include <cassert> - -// ***************************************************************************** -// Main -int main(int argc, char* const argv[]) -{ -try { - // Handle command line arguments - Params params; - if (params.getopt(argc, argv)) { - params.usage(); - return 1; - } - if (params.help_) { - params.help(); - return 2; - } - - // Use MemIo to increase test coverage. - Exiv2::BasicIo::AutoPtr fileIo(new Exiv2::FileIo(params.read_)); - Exiv2::BasicIo::AutoPtr memIo(new Exiv2::MemIo); - memIo->transfer(*fileIo); - - Exiv2::Image::AutoPtr readImg = Exiv2::ImageFactory::open(memIo); - assert(readImg.get() != 0); - readImg->readMetadata(); - - Exiv2::Image::AutoPtr writeImg = Exiv2::ImageFactory::open(params.write_); - assert(writeImg.get() != 0); - if (params.preserve_) writeImg->readMetadata(); - if (params.iptc_) { - writeImg->setIptcData(readImg->iptcData()); - } - if (params.exif_) { - writeImg->setExifData(readImg->exifData()); - } - if (params.comment_) { - writeImg->setComment(readImg->comment()); - } - - try { - writeImg->writeMetadata(); - } - catch (const Exiv2::AnyError&) { - std::cerr << params.progname() << - ": Could not write metadata to (" << params.write_ << ")\n"; - return 8; - } - - return 0; -} -catch (Exiv2::AnyError& e) { - std::cerr << "Caught Exiv2 exception '" << e << "'\n"; - return 10; -} -} - -int Params::option(int opt, const std::string& optarg, int optopt) -{ - int rc = 0; - switch (opt) { - case 'h': help_ = true; break; - case 'i': iptc_ = true; break; - case 'e': exif_ = true; break; - case 'c': comment_ = true; break; - case 'p': preserve_ = true; break; - case 'a': - iptc_ =true; - exif_ =true; - comment_ =true; - break; - case ':': - std::cerr << progname() << ": Option -" << static_cast<char>(optopt) - << " requires an argument\n"; - rc = 1; - break; - case '?': - std::cerr << progname() << ": Unrecognized option -" - << static_cast<char>(optopt) << "\n"; - rc = 1; - break; - default: - std::cerr << progname() - << ": getopt returned unexpected character code " - << std::hex << opt << "\n"; - rc = 1; - break; - } - - return rc; -} - -int Params::nonoption(const std::string& argv) -{ - if (!write_.empty()) { - std::cerr << progname() << ": Unexpected extra argument (" << argv << ")\n"; - return 1; - } - if (first_) read_ = argv; - else write_ = argv; - first_ = false; - return 0; -} - -int Params::getopt(int argc, char* const argv[]) -{ - int rc = Util::Getopt::getopt(argc, argv, optstring_); - // Further consistency checks - if (help_==false) { - if (rc==0 && read_.empty() ) { - std::cerr << progname() << ": Read and write files must be specified\n"; - rc = 1; - } - if (rc==0 && write_.empty() ) { - std::cerr << progname() << ": Write file must be specified\n"; - rc = 1; - } - if (preserve_ && iptc_ && exif_ && comment_ ) { - std::cerr << progname() << ": Option -p has no effect when all metadata types are specified.\n"; - rc = 1; - } - } - return rc; -} // Params::getopt - - -void Params::usage(std::ostream& os) const -{ - os << "\nReads and writes raw metadata. Use -h option for help.\n" - << "Usage: " << progname() - << " [-iecaph] readfile writefile\n"; -} - -void Params::help(std::ostream& os) const -{ - usage(os); - os << "\nOptions:\n" - << " -i Read Iptc data from readfile and write to writefile.\n" - << " -e Read Exif data from readfile and write to writefile.\n" - << " -c Read Jpeg comment from readfile and write to writefile.\n" - << " -a Read all metadata from readfile and write to writefile.\n" - << " -p Preserve existing metadata in writefile if not replaced.\n" - << " -h Display this help and exit.\n\n"; -} // Params::help - diff --git a/src/plugins/exiv2/metacopy.hpp b/src/plugins/exiv2/metacopy.hpp @@ -1,86 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/*! - @file metacopy.hpp - @brief Defines class Params, used for the command line handling - @version $Rev: 538 $ - @author Brad Schick (brad) <brad@robotbattle.com> - @date 13-Jul-04, brad: created - */ -#ifndef METACOPY_HPP_ -#define METACOPY_HPP_ - -#include "utils.hpp" - -class Params : public Util::Getopt { -private: - std::string optstring_; - bool first_; - -public: - bool help_; //!< Help option flag. - bool iptc_; //!< Iptc option flag. - bool exif_; //!< Exif option flag. - bool comment_; //!< JPEG comment option flag. - bool preserve_; //!< Preserve existing metadata option flag. - std::string read_; //!< Source file - std::string write_; //!< Destination file - -public: - /*! - @brief Default constructor. Note that optstring_ is initialized here. - */ - Params() : optstring_(":iecaph"), - first_(true), - help_(false), - iptc_(false), - exif_(false), - comment_(false), - preserve_(false) - {} - - /*! - @brief Call Getopt::getopt() with optstring, to initiate command line - argument parsing, perform consistency checks after all command line - arguments are parsed. - - @param argc Argument count as passed to main() on program invocation. - @param argv Argument array as passed to main() on program invocation. - - @return 0 if successful, >0 in case of errors. - */ - int getopt(int argc, char* const argv[]); - - //! Handle options and their arguments. - virtual int option(int opt, const std::string& optarg, int optopt); - - //! Handle non-option parameters. - virtual int nonoption(const std::string& argv); - - //! Print a minimal usage note to an output stream. - void usage(std::ostream& os =std::cout) const; - - //! Print further usage explanations to an output stream. - void help(std::ostream& os =std::cout) const; - -}; // class Params - -#endif // METACOPY_HPP_ diff --git a/src/plugins/exiv2/private.h b/src/plugins/exiv2/private.h @@ -0,0 +1,235 @@ +/*! + @file private.h + @brief This file is from the tz distribution at ftp://elsie.nci.nih.gov/pub/ + @version $Rev: 544 $ +*/ +#ifndef PRIVATE_H + +#define PRIVATE_H + +/* +** This file is in the public domain, so clarified as of +** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). +*/ + +/* +** This header is for use ONLY with the time conversion code. +** There is no guarantee that it will remain unchanged, +** or that it will remain at all. +** Do NOT copy it to any system include directory. +** Thank you! +*/ + +/* +** ID +*/ + +#ifndef lint +#ifndef NOID +static char privatehid[] = "@(#)private.h 7.53"; +#endif /* !defined NOID */ +#endif /* !defined lint */ + +/* ahu: moved required preprocessor symbols to config.h */ + +/* ahu: disable warnings */ +#ifdef _MSC_VER +// disable warning 'uses old-style declarator' C4131 +#pragma warning (disable: 4131) +#endif + +/* +** Nested includes +*/ + +#include "sys/types.h" /* for time_t */ +#include "stdio.h" +#include "errno.h" +#include "string.h" +#include "limits.h" /* for CHAR_BIT */ +#include "time.h" +#include "stdlib.h" + +/* ahu: added io.h for MSVC */ +#ifdef _MSC_VER +# include "io.h" +#endif + +/* ahu: deleted include libintl.h */ + +/* ahu: deleted include sys/wait.h and WIFEXITED, WEXITSTATUS macros */ + +#if EXV_HAVE_UNISTD_H - 0 +#include "unistd.h" /* for F_OK and R_OK */ +#endif /* EXV_HAVE_UNISTD_H - 0 */ + +#if !(EXV_HAVE_UNISTD_H - 0) +#ifndef F_OK +#define F_OK 0 +#endif /* !defined F_OK */ +#ifndef R_OK +#define R_OK 4 +#endif /* !defined R_OK */ +#endif /* !(EXV_HAVE_UNISTD_H - 0) */ + +/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ +#define is_digit(c) ((unsigned)(c) - '0' <= 9) + +/* +** Workarounds for compilers/systems. +*/ + +/* +** SunOS 4.1.1 cc lacks prototypes. +*/ + +#ifndef P +#ifdef __STDC__ +#define P(x) x +#endif /* defined __STDC__ */ +#ifndef __STDC__ +#define P(x) () +#endif /* !defined __STDC__ */ +#endif /* !defined P */ + +/* +** SunOS 4.1.1 headers lack EXIT_SUCCESS. +*/ + +#ifndef EXIT_SUCCESS +#define EXIT_SUCCESS 0 +#endif /* !defined EXIT_SUCCESS */ + +/* +** SunOS 4.1.1 headers lack EXIT_FAILURE. +*/ + +#ifndef EXIT_FAILURE +#define EXIT_FAILURE 1 +#endif /* !defined EXIT_FAILURE */ + +/* +** SunOS 4.1.1 headers lack FILENAME_MAX. +*/ + +#ifndef FILENAME_MAX + +#ifndef MAXPATHLEN +#ifdef unix +#include "sys/param.h" +#endif /* defined unix */ +#endif /* !defined MAXPATHLEN */ + +#ifdef MAXPATHLEN +#define FILENAME_MAX MAXPATHLEN +#endif /* defined MAXPATHLEN */ +#ifndef MAXPATHLEN +#define FILENAME_MAX 1024 /* Pure guesswork */ +#endif /* !defined MAXPATHLEN */ + +#endif /* !defined FILENAME_MAX */ + +/* +** SunOS 4.1.1 libraries lack remove. +*/ + +#ifndef remove +extern int unlink P((const char * filename)); +#define remove unlink +#endif /* !defined remove */ + +/* +** Some ancient errno.h implementations don't declare errno. +** But some newer errno.h implementations define it as a macro. +** Fix the former without affecting the latter. +*/ +#ifndef errno +extern int errno; +#endif /* !defined errno */ + +/* +** Private function declarations. +*/ +char * icalloc P((int nelem, int elsize)); +char * icatalloc P((char * old, const char * new)); +char * icpyalloc P((const char * string)); +char * imalloc P((int n)); +void * irealloc P((void * pointer, int size)); +void icfree P((char * pointer)); +void ifree P((char * pointer)); +char * scheck P((const char *string, const char *format)); + + +/* +** Finally, some convenience items. +*/ + +#ifndef TRUE +#define TRUE 1 +#endif /* !defined TRUE */ + +#ifndef FALSE +#define FALSE 0 +#endif /* !defined FALSE */ + +#ifndef TYPE_BIT +#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) +#endif /* !defined TYPE_BIT */ + +#ifndef TYPE_SIGNED +#define TYPE_SIGNED(type) (((type) -1) < 0) +#endif /* !defined TYPE_SIGNED */ + +#ifndef INT_STRLEN_MAXIMUM +/* +** 302 / 1000 is log10(2.0) rounded up. +** Subtract one for the sign bit if the type is signed; +** add one for integer division truncation; +** add one more for a minus sign if the type is signed. +*/ +#define INT_STRLEN_MAXIMUM(type) \ + ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) +#endif /* !defined INT_STRLEN_MAXIMUM */ + +/* +** INITIALIZE(x) +*/ + +#ifndef GNUC_or_lint +#ifdef lint +#define GNUC_or_lint +#endif /* defined lint */ +#ifndef lint +#ifdef __GNUC__ +#define GNUC_or_lint +#endif /* defined __GNUC__ */ +#endif /* !defined lint */ +#endif /* !defined GNUC_or_lint */ + +#ifndef INITIALIZE +#ifdef GNUC_or_lint +#define INITIALIZE(x) ((x) = 0) +#endif /* defined GNUC_or_lint */ +#ifndef GNUC_or_lint +#define INITIALIZE(x) +#endif /* !defined GNUC_or_lint */ +#endif /* !defined INITIALIZE */ + +/* ahu: deleted definition of _(msgid) macro */ + +#ifndef TZ_DOMAIN +#define TZ_DOMAIN "tz" +#endif /* !defined TZ_DOMAIN */ + +#if HAVE_INCOMPATIBLE_CTIME_R +#undef asctime_r +#undef ctime_r +char *asctime_r P((struct tm const *, char *)); +char *ctime_r P((time_t const *, char *)); +#endif /* HAVE_INCOMPATIBLE_CTIME_R */ + +/* +** UNIX was a registered trademark of The Open Group in 2003. +*/ + +#endif /* !defined PRIVATE_H */ diff --git a/src/plugins/exiv2/timegm.h b/src/plugins/exiv2/timegm.h @@ -0,0 +1,88 @@ +/*! + @file timegm.h + @brief Declaration of timegm(). The implementation is in localtime.c + @version $Rev: 392 $ +*/ +#ifndef TIMEGM_H_ +#define TIMEGM_H_ + +#include <time.h> + +/* + The following comments are copied from the Makefile of the tz distribution, + available at ftp://elsie.nci.nih.gov/pub/: + + NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put + out by the National Institute of Standards and Technology + which claims to test C and Posix conformance. If you want to pass PCTS, add + -DPCTS + to the end of the "CFLAGS=" line. + + If your system has a "zone abbreviation" field in its "struct tm"s + (or if you decide to add such a field in your system's "time.h" file), + add the name to a define such as + -DTM_ZONE=tm_zone + or + -DTM_ZONE=_tm_zone + to the end of the "CFLAGS=" line. + + If you want functions that were inspired by early versions of X3J11's work, + add + -DSTD_INSPIRED + to the end of the "CFLAGS=" line. + + If you want to allocate state structures in localtime, add + -DALL_STATE + to the end of the "CFLAGS=" line. Storage is obtained by calling malloc. + + If you want Source Code Control System ID's left out of object modules, add + -DNOID + + Add the following to the end of the "CFLAGS=" line as needed. + -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified + DST transitions if the time zone files cannot be accessed + + If you want to use System V compatibility code, add + -DUSG_COMPAT + to the end of the "CFLAGS=" line. This arrange for "timezone" and "daylight" + variables to be kept up-to-date by the time conversion functions. Neither + "timezone" nor "daylight" is described in X3J11's work. + + If you want an "altzone" variable (a la System V Release 3.1), add + -DALTZONE + to the end of the "CFLAGS=" line. + This variable is not described in X3J11's work. + + If your system has a "GMT offset" field in its "struct tm"s + (or if you decide to add such a field in your system's "time.h" file), + add the name to a define such as + -DTM_GMTOFF=tm_gmtoff + or + -DTM_GMTOFF=_tm_gmtoff + to the end of the "CFLAGS=" line. + Neither tm_gmtoff nor _tm_gmtoff is described in X3J11's work; + in its work, use of "tm_gmtoff" is described as non-conforming. + Both Linux and BSD have done the equivalent of defining TM_GMTOFF in + their recent releases. + + If you want a "gtime" function (a la MACH), add + -DCMUCS + to the end of the "CFLAGS=" line + This function is not described in X3J11's work. +*/ + +#define STD_INSPIRED +#define NOID + +#ifdef __cplusplus +extern "C" { +#endif + +// The UTC version of mktime +time_t timegm(struct tm * const tmp); + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef TIMEGM_H_ diff --git a/src/plugins/exiv2/tzfile.h b/src/plugins/exiv2/tzfile.h @@ -0,0 +1,193 @@ +/*! + @file tzfile.h + @brief This file is from the tz distribution at ftp://elsie.nci.nih.gov/pub/ + @version $Rev: 392 $ +*/ +#ifndef TZFILE_H + +#define TZFILE_H + +/* +** This file is in the public domain, so clarified as of +** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). +*/ + +/* +** This header is for use ONLY with the time conversion code. +** There is no guarantee that it will remain unchanged, +** or that it will remain at all. +** Do NOT copy it to any system include directory. +** Thank you! +*/ + +/* +** ID +*/ + +#ifndef lint +#ifndef NOID +static char tzfilehid[] = "@(#)tzfile.h 7.14"; +#endif /* !defined NOID */ +#endif /* !defined lint */ + +/* +** Information about time zone files. +*/ + +#ifndef TZDIR +#define TZDIR "/usr/local/etc/zoneinfo" /* Time zone object file directory */ +#endif /* !defined TZDIR */ + +#ifndef TZDEFAULT +#define TZDEFAULT "localtime" +#endif /* !defined TZDEFAULT */ + +#ifndef TZDEFRULES +#define TZDEFRULES "posixrules" +#endif /* !defined TZDEFRULES */ + +/* +** Each file begins with. . . +*/ + +#define TZ_MAGIC "TZif" + +struct tzhead { + char tzh_magic[4]; /* TZ_MAGIC */ + char tzh_reserved[16]; /* reserved for future use */ + char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */ + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ + char tzh_leapcnt[4]; /* coded number of leap seconds */ + char tzh_timecnt[4]; /* coded number of transition times */ + char tzh_typecnt[4]; /* coded number of local time types */ + char tzh_charcnt[4]; /* coded number of abbr. chars */ +}; + +/* +** . . .followed by. . . +** +** tzh_timecnt (char [4])s coded transition times a la time(2) +** tzh_timecnt (unsigned char)s types of local time starting at above +** tzh_typecnt repetitions of +** one (char [4]) coded UTC offset in seconds +** one (unsigned char) used to set tm_isdst +** one (unsigned char) that's an abbreviation list index +** tzh_charcnt (char)s '\0'-terminated zone abbreviations +** tzh_leapcnt repetitions of +** one (char [4]) coded leap second transition times +** one (char [4]) total correction after above +** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition +** time is standard time, if FALSE, +** transition time is wall clock time +** if absent, transition times are +** assumed to be wall clock time +** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition +** time is UTC, if FALSE, +** transition time is local time +** if absent, transition times are +** assumed to be local time +*/ + +/* +** In the current implementation, "tzset()" refuses to deal with files that +** exceed any of the limits below. +*/ + +#ifndef TZ_MAX_TIMES +/* +** The TZ_MAX_TIMES value below is enough to handle a bit more than a +** year's worth of solar time (corrected daily to the nearest second) or +** 138 years of Pacific Presidential Election time +** (where there are three time zone transitions every fourth year). +*/ +#define TZ_MAX_TIMES 370 +#endif /* !defined TZ_MAX_TIMES */ + +#ifndef TZ_MAX_TYPES +#ifndef NOSOLAR +#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ +#endif /* !defined NOSOLAR */ +#ifdef NOSOLAR +/* +** Must be at least 14 for Europe/Riga as of Jan 12 1995, +** as noted by Earl Chew <earl@hpato.aus.hp.com>. +*/ +#define TZ_MAX_TYPES 20 /* Maximum number of local time types */ +#endif /* !defined NOSOLAR */ +#endif /* !defined TZ_MAX_TYPES */ + +#ifndef TZ_MAX_CHARS +#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ + /* (limited by what unsigned chars can hold) */ +#endif /* !defined TZ_MAX_CHARS */ + +#ifndef TZ_MAX_LEAPS +#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ +#endif /* !defined TZ_MAX_LEAPS */ + +#define SECSPERMIN 60 +#define MINSPERHOUR 60 +#define HOURSPERDAY 24 +#define DAYSPERWEEK 7 +#define DAYSPERNYEAR 365 +#define DAYSPERLYEAR 366 +#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) +#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) +#define MONSPERYEAR 12 + +#define TM_SUNDAY 0 +#define TM_MONDAY 1 +#define TM_TUESDAY 2 +#define TM_WEDNESDAY 3 +#define TM_THURSDAY 4 +#define TM_FRIDAY 5 +#define TM_SATURDAY 6 + +#define TM_JANUARY 0 +#define TM_FEBRUARY 1 +#define TM_MARCH 2 +#define TM_APRIL 3 +#define TM_MAY 4 +#define TM_JUNE 5 +#define TM_JULY 6 +#define TM_AUGUST 7 +#define TM_SEPTEMBER 8 +#define TM_OCTOBER 9 +#define TM_NOVEMBER 10 +#define TM_DECEMBER 11 + +#define TM_YEAR_BASE 1900 + +#define EPOCH_YEAR 1970 +#define EPOCH_WDAY TM_THURSDAY + +/* +** Accurate only for the past couple of centuries; +** that will probably do. +*/ + +#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) + +#ifndef USG + +/* +** Use of the underscored variants may cause problems if you move your code to +** certain System-V-based systems; for maximum portability, use the +** underscore-free variants. The underscored variants are provided for +** backward compatibility only; they may disappear from future versions of +** this file. +*/ + +#define SECS_PER_MIN SECSPERMIN +#define MINS_PER_HOUR MINSPERHOUR +#define HOURS_PER_DAY HOURSPERDAY +#define DAYS_PER_WEEK DAYSPERWEEK +#define DAYS_PER_NYEAR DAYSPERNYEAR +#define DAYS_PER_LYEAR DAYSPERLYEAR +#define SECS_PER_HOUR SECSPERHOUR +#define SECS_PER_DAY SECSPERDAY +#define MONS_PER_YEAR MONSPERYEAR + +#endif /* !defined USG */ + +#endif /* !defined TZFILE_H */