Refactoring EXV_USE_CURL and EXV_USE_SSH
This commit is contained in:
parent
1b3ea05155
commit
d366943297
@ -2,46 +2,33 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// Defined to 1 if when using `libssh' for SshIO.
|
||||
#cmakedefine01 EXV_USE_SSH
|
||||
// Defined if you want to use libssh for SshIO.
|
||||
#cmakedefine EXV_USE_SSH
|
||||
|
||||
// Define to 1 if you want to use `libcurl' in httpIO.
|
||||
#cmakedefine01 EXV_USE_CURL
|
||||
// Define to 1 if you want to use libcurl in httpIO.
|
||||
#cmakedefine EXV_USE_CURL
|
||||
|
||||
// Define if you require webready support.
|
||||
#cmakedefine EXV_ENABLE_WEBREADY
|
||||
|
||||
// Define to 1 if you have the `gmtime_r' function.
|
||||
// Define if you have the `gmtime_r' function.
|
||||
#cmakedefine EXV_HAVE_GMTIME_R
|
||||
|
||||
// Define to 1 if you have the <libintl.h> header file.
|
||||
// Define if you have the <libintl.h> header file.
|
||||
#cmakedefine EXV_HAVE_LIBINTL_H
|
||||
|
||||
// Define to 1 if translation of program messages to the user's native language is requested.
|
||||
// Define if you want translation of program messages to the user's native language
|
||||
#cmakedefine EXV_ENABLE_NLS
|
||||
|
||||
// Define to 1 if you require video support.
|
||||
// Define if you want video support.
|
||||
#cmakedefine EXV_ENABLE_VIDEO
|
||||
|
||||
// Define if you have correct declaration of strerror_r().
|
||||
#cmakedefine EXV_HAVE_DECL_STRERROR_R
|
||||
|
||||
#ifndef EXV_COMMERCIAL_VERSION
|
||||
|
||||
// Definition to enable translation of Nikon lens names.
|
||||
#cmakedefine EXV_HAVE_LENSDATA
|
||||
|
||||
// Define to 1 if you have the `iconv' function.
|
||||
#cmakedefine EXV_HAVE_ICONV
|
||||
|
||||
// Definition to enable conversion of UCS2 encoded Windows tags to UTF-8.
|
||||
#cmakedefine EXV_HAVE_PRINTUCS2
|
||||
|
||||
#endif /* !EXV_COMMERCIAL_VERSION */
|
||||
|
||||
// Definition to enable the Windows unicode path support.
|
||||
// Define to enable the Windows unicode path support.
|
||||
#cmakedefine EXV_UNICODE_PATH
|
||||
|
||||
|
||||
/* Define to `const' or to empty, depending on the second argument of `iconv'. */
|
||||
#cmakedefine ICONV_ACCEPTS_CONST_INPUT
|
||||
#if defined ICONV_ACCEPTS_CONST_INPUT
|
||||
@ -50,22 +37,22 @@
|
||||
#define EXV_ICONV_CONST
|
||||
#endif
|
||||
|
||||
// Definition to indicate if you have the <regex> header file.
|
||||
// Define if you have the <regex> header file.
|
||||
#cmakedefine EXV_HAVE_REGEX
|
||||
|
||||
// Definition to indicate if you have the <regex.h> header file.
|
||||
// Define if you have the <regex.h> header file.
|
||||
#cmakedefine EXV_HAVE_REGEX_H
|
||||
|
||||
// Definition to indicate you have the <memory.h> header file.
|
||||
// Define if have the <memory.h> header file.
|
||||
#cmakedefine EXV_HAVE_MEMORY_H
|
||||
|
||||
// Definition to indicate if you have the `memset' function.
|
||||
// Define if you have the memset function.
|
||||
#cmakedefine EXV_HAVE_MEMSET
|
||||
|
||||
// Definition to indicate if stdbool.h conforms to C99.
|
||||
// Define if stdbool.h conforms to C99.
|
||||
#cmakedefine EXV_HAVE_STDBOOL_H
|
||||
|
||||
// Definition to indicate if you have the <stdint.h> header file.
|
||||
// Define if you have the <stdint.h> header file.
|
||||
#cmakedefine EXV_HAVE_STDINT_H
|
||||
|
||||
#ifndef EXV_HAVE_STDINT_H
|
||||
@ -74,53 +61,53 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Definition to indicate if you have the <stdlib.h> header file.
|
||||
// Define if you have the <stdlib.h> header file.
|
||||
#cmakedefine EXV_HAVE_STDLIB_H
|
||||
|
||||
// Definition to indicate if you have the `strchr' function.
|
||||
// Define if you have the strchr function.
|
||||
#cmakedefine EXV_HAVE_STRCHR
|
||||
|
||||
// Definition to indicate if you have the `strerror' function.
|
||||
// Define if you have the strerror function.
|
||||
#cmakedefine EXV_HAVE_STRERROR
|
||||
|
||||
// Definition to indicate if you have the `strerror_r' function.
|
||||
// Define if you have the strerror_r function.
|
||||
#cmakedefine EXV_HAVE_STRERROR_R
|
||||
|
||||
// Definition to indicate if strerror_r returns char *.
|
||||
// Define if strerror_r returns char *.
|
||||
#cmakedefine STRERROR_R_CHAR_P
|
||||
|
||||
// Definition to indicate if you have the <strings.h> header file.
|
||||
// Define if you have the <strings.h> header file.
|
||||
#cmakedefine EXV_HAVE_STRINGS_H
|
||||
|
||||
// Definition to indicate if you have the `strtol' function.
|
||||
// Define if you have the strtol function.
|
||||
#cmakedefine EXV_HAVE_STRTOL
|
||||
|
||||
// Definition to indicate if you have the `mmap' function.
|
||||
// Define if you have the mmap function.
|
||||
#cmakedefine EXV_HAVE_MMAP
|
||||
|
||||
// Definition to indicate if you have the `munmap' function.
|
||||
// Define if you have the munmap function.
|
||||
#cmakedefine EXV_HAVE_MUNMAP
|
||||
|
||||
// Definition to indicate if you have the <sys/stat.h> header file.
|
||||
// Define if you have <sys/stat.h> header file.
|
||||
#cmakedefine EXV_HAVE_SYS_STAT_H
|
||||
|
||||
// Definition to indicate if you have the <sys/types.h> header file.
|
||||
// Define if you have the <sys/types.h> header file.
|
||||
#cmakedefine EXV_HAVE_SYS_TYPES_H
|
||||
|
||||
// Definition to indicate if you have the `timegm' function.
|
||||
// Define if you have the timegm function.
|
||||
#cmakedefine EXV_HAVE_TIMEGM
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#cmakedefine EXV_HAVE_UNISTD_H 1
|
||||
|
||||
#if !defined( EXV_HAVE_UNISTD_H) && defined(__CYGWIN__)
|
||||
#define EXV_HAVE_UNISTD_H 1
|
||||
#endif
|
||||
|
||||
// Definition to indicate if you have the <sys/mman.h> header file.
|
||||
// Define if you have the <sys/mman.h> header file.
|
||||
#cmakedefine EXV_HAVE_SYS_MMAN_H
|
||||
|
||||
// Definition to indicate if the `zlib' library will be used
|
||||
// Define if you have are using the zlib library.
|
||||
#cmakedefine EXV_HAVE_LIBZ
|
||||
|
||||
#if defined(_MSC_VER) && HAVE_LIBZ
|
||||
@ -129,11 +116,11 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Definition to indicate if you have the <process.h> header file.
|
||||
// Define if you have the <process.h> header file.
|
||||
#cmakedefine EXV_HAVE_PROCESS_H
|
||||
|
||||
/* Define to 1 if you have the Adobe XMP Toolkit. */
|
||||
#cmakedefine EXV_HAVE_XMP_TOOLKIT 1
|
||||
/* Define if you have (Exiv2/xmpsdk) Adobe XMP Toolkit. */
|
||||
#cmakedefine EXV_HAVE_XMP_TOOLKIT
|
||||
|
||||
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
|
||||
slash. */
|
||||
@ -168,3 +155,22 @@
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
#cmakedefine size_t
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// The following features are not available for Commercial use
|
||||
#ifndef EXV_COMMERCIAL_VERSION
|
||||
|
||||
// Definition to enable translation of Nikon lens names.
|
||||
#cmakedefine EXV_HAVE_LENSDATA
|
||||
|
||||
// Define if you have the iconv function.
|
||||
#cmakedefine EXV_HAVE_ICONV
|
||||
|
||||
// Definition to enable conversion of UCS2 encoded Windows tags to UTF-8.
|
||||
#cmakedefine EXV_HAVE_PRINTUCS2
|
||||
|
||||
#endif /* !EXV_COMMERCIAL_VERSION */
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
// That's All Folks!
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
@ -43,12 +43,6 @@
|
||||
#ifndef EXV_XPATH_MEMIO
|
||||
#define EXV_XPATH_MEMIO 0
|
||||
#endif
|
||||
#ifndef EXV_USE_CURL
|
||||
#define EXV_USE_CURL 0
|
||||
#endif
|
||||
#ifndef EXV_USE_SSH
|
||||
#define EXV_USE_SSH 0
|
||||
#endif
|
||||
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
@ -1117,7 +1111,7 @@ namespace Exiv2 {
|
||||
//@}
|
||||
};
|
||||
|
||||
#if EXV_USE_CURL == 1
|
||||
#ifdef EXV_USE_CURL
|
||||
/*!
|
||||
@brief Provides the http, https read/write access and ftp read access for the RemoteIo.
|
||||
This class is based on libcurl.
|
||||
@ -1173,7 +1167,7 @@ namespace Exiv2 {
|
||||
};
|
||||
#endif
|
||||
|
||||
#if EXV_USE_SSH == 1
|
||||
#ifdef EXV_USE_SSH
|
||||
/*!
|
||||
@brief Provides the ssh read/write access and sftp read access for the RemoteIo.
|
||||
This class is based on libssh.
|
||||
@ -1262,7 +1256,7 @@ namespace Exiv2 {
|
||||
EXIV2API std::wstring ReplaceStringInPlace(std::wstring subject, const std::wstring& search,
|
||||
const std::wstring& replace);
|
||||
#endif
|
||||
#if EXV_USE_CURL == 1
|
||||
#ifdef EXV_USE_CURL
|
||||
/*!
|
||||
@brief The callback function is called by libcurl to write the data
|
||||
*/
|
||||
|
||||
@ -53,17 +53,21 @@
|
||||
#include "exiv2/mrwimage.hpp"
|
||||
#include "exiv2/orfimage.hpp"
|
||||
#include "exiv2/pgfimage.hpp"
|
||||
|
||||
#ifdef EXV_HAVE_LIBZ
|
||||
#include "exiv2/pngimage.hpp"
|
||||
#endif
|
||||
|
||||
#include "exiv2/preview.hpp"
|
||||
#include "exiv2/properties.hpp"
|
||||
#include "exiv2/psdimage.hpp"
|
||||
#include "exiv2/rafimage.hpp"
|
||||
#include "exiv2/rw2image.hpp"
|
||||
#if EXV_USE_SSH == 1
|
||||
|
||||
#ifdef EXV_USE_SSH
|
||||
#include "exiv2/ssh.hpp"
|
||||
#endif
|
||||
|
||||
#include "exiv2/tags.hpp"
|
||||
#include "exiv2/tgaimage.hpp"
|
||||
#include "exiv2/tiffimage.hpp"
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#ifndef HTTP_HPP_
|
||||
#define HTTP_HPP_
|
||||
|
||||
#include "config.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
@ -18,10 +19,7 @@ namespace Exiv2 {
|
||||
EXIV2API int http(Exiv2::Dictionary& request,Exiv2::Dictionary& response,std::string& errors);
|
||||
}
|
||||
|
||||
#ifndef EXV_USE_CURL
|
||||
#define EXV_USE_CURL 0
|
||||
#endif
|
||||
#if EXV_USE_CURL == 1
|
||||
#ifdef EXV_USE_CURL
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
// included header files
|
||||
#include "config.h"
|
||||
|
||||
#if EXV_USE_SSH == 1
|
||||
#ifdef EXV_USE_SSH
|
||||
#include <libssh/libssh.h>
|
||||
#include <libssh/sftp.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -26,7 +26,7 @@ void httpcon(const std::string& url, bool useHttp1_0 = false) {
|
||||
}
|
||||
}
|
||||
|
||||
#if EXV_USE_CURL == 1
|
||||
#ifdef EXV_USE_CURL
|
||||
void curlcon(const std::string& url, bool useHttp1_0 = false) {
|
||||
CURL* curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
@ -68,7 +68,7 @@ void curlcon(const std::string& url, bool useHttp1_0 = false) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if EXV_USE_SSH == 1
|
||||
#ifdef EXV_USE_SSH
|
||||
void sshcon(const std::string& url) {
|
||||
Exiv2::Uri uri = Exiv2::Uri::Parse(url);
|
||||
Exiv2::Uri::Decode(uri);
|
||||
@ -125,7 +125,7 @@ int main(int argc,const char** argv)
|
||||
|
||||
bool isOk = false;
|
||||
try {
|
||||
#if EXV_USE_SSH == 1
|
||||
#ifdef EXV_USE_SSH
|
||||
if (prot == Exiv2::pSsh) {
|
||||
sshcon(url);
|
||||
isOk = true;
|
||||
@ -134,7 +134,7 @@ int main(int argc,const char** argv)
|
||||
isOk = true;
|
||||
}
|
||||
#endif
|
||||
#if EXV_USE_CURL == 1
|
||||
#ifdef EXV_USE_CURL
|
||||
if (prot == Exiv2::pHttp || prot == Exiv2::pHttps || prot == Exiv2::pFtp) {
|
||||
curlcon(url, useHttp1_0);
|
||||
isOk = true;
|
||||
|
||||
@ -46,6 +46,7 @@ EXIV2_RCSID("@(#) $Id$")
|
||||
#include <cstdlib> // for alloc, realloc, free
|
||||
#include <sys/types.h> // for stat, chmod
|
||||
#include <sys/stat.h> // for stat, chmod
|
||||
|
||||
#ifdef EXV_HAVE_SYS_MMAN_H
|
||||
# include <sys/mman.h> // for mmap and munmap
|
||||
#endif
|
||||
@ -55,13 +56,15 @@ EXIV2_RCSID("@(#) $Id$")
|
||||
#ifdef EXV_HAVE_UNISTD_H
|
||||
# include <unistd.h> // for getpid, stat
|
||||
#endif
|
||||
#if EXV_USE_CURL == 1
|
||||
#include <curl/curl.h>
|
||||
|
||||
#ifdef EXV_USE_CURL
|
||||
# include <curl/curl.h>
|
||||
#endif
|
||||
#if EXV_USE_SSH == 1
|
||||
#include "ssh.hpp"
|
||||
|
||||
#ifdef EXV_USE_SSH
|
||||
# include "ssh.hpp"
|
||||
#else
|
||||
#define mode_t unsigned short
|
||||
# define mode_t unsigned short
|
||||
#endif
|
||||
|
||||
// Platform specific headers for handling extended attributes (xattr)
|
||||
@ -2079,7 +2082,7 @@ namespace Exiv2 {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if EXV_USE_CURL == 1
|
||||
#ifdef EXV_USE_CURL
|
||||
//! Internal Pimpl structure of class RemoteIo.
|
||||
class CurlIo::CurlImpl : public Impl {
|
||||
public:
|
||||
@ -2328,7 +2331,7 @@ namespace Exiv2 {
|
||||
|
||||
#endif
|
||||
|
||||
#if EXV_USE_SSH == 1
|
||||
#ifdef EXV_USE_SSH
|
||||
//! Internal Pimpl structure of class RemoteIo.
|
||||
class SshIo::SshImpl : public Impl {
|
||||
public:
|
||||
@ -2627,7 +2630,7 @@ namespace Exiv2 {
|
||||
return subject;
|
||||
}
|
||||
#endif
|
||||
#if EXV_USE_CURL == 1
|
||||
#ifdef EXV_USE_CURL
|
||||
size_t curlWriter(char* data, size_t size, size_t nmemb,
|
||||
std::string* writerData)
|
||||
{
|
||||
|
||||
@ -798,16 +798,19 @@ namespace Exiv2 {
|
||||
BasicIo::AutoPtr ImageFactory::createIo(const std::string& path, bool useCurl)
|
||||
{
|
||||
Protocol fProt = fileProtocol(path);
|
||||
#if EXV_USE_SSH == 1
|
||||
|
||||
#ifdef EXV_USE_SSH
|
||||
if (fProt == pSsh || fProt == pSftp) {
|
||||
return BasicIo::AutoPtr(new SshIo(path)); // may throw
|
||||
}
|
||||
#endif
|
||||
#if EXV_USE_CURL == 1
|
||||
|
||||
#ifdef EXV_USE_CURL
|
||||
if (useCurl && (fProt == pHttp || fProt == pHttps || fProt == pFtp)) {
|
||||
return BasicIo::AutoPtr(new CurlIo(path)); // may throw
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fProt == pHttp)
|
||||
return BasicIo::AutoPtr(new HttpIo(path)); // may throw
|
||||
if (fProt == pFileUri)
|
||||
|
||||
@ -32,7 +32,8 @@ EXIV2_RCSID("@(#) $Id: rw2image.cpp 3201 2013-12-01 12:13:42Z ahuggel $")
|
||||
// included header files
|
||||
#include "config.h"
|
||||
#include "ssh.hpp"
|
||||
#if EXV_USE_SSH == 1
|
||||
|
||||
#ifdef EXV_USE_SSH
|
||||
// class member definitions
|
||||
namespace Exiv2 {
|
||||
|
||||
|
||||
@ -31,15 +31,7 @@ EXIV2_RCSID("@(#) $Id$")
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef EXV_USE_SSH
|
||||
#define EXV_USE_SSH 0
|
||||
#endif
|
||||
|
||||
#ifndef EXV_USE_CURL
|
||||
#define EXV_USE_CURL 0
|
||||
#endif
|
||||
|
||||
#if EXV_USE_CURL == 1
|
||||
#ifdef EXV_USE_CURL
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
|
||||
@ -53,32 +45,12 @@ EXIV2_RCSID("@(#) $Id$")
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef EXV_HAVE_XMP_TOOLKIT
|
||||
#define EXV_HAVE_XMP_TOOLKIT 0
|
||||
#endif
|
||||
|
||||
#ifndef EXV_HAVE_STRINGS
|
||||
#define EXV_HAVE_STRINGS 0
|
||||
#endif
|
||||
|
||||
#ifndef EXV_SYS_TYPES
|
||||
#define EXV_SYS_TYPES 0
|
||||
#endif
|
||||
|
||||
#ifndef EXV_HAVE_UNISTD
|
||||
#define EXV_HAVE_UNISTD 0
|
||||
#endif
|
||||
|
||||
#ifndef EXV_UNICODE_PATH
|
||||
#define EXV_UNICODE_PATH 0
|
||||
#endif
|
||||
|
||||
#include "http.hpp"
|
||||
#include "version.hpp"
|
||||
#include "makernote_int.hpp"
|
||||
|
||||
// Adobe XMP Toolkit
|
||||
#if EXV_HAVE_XMP_TOOLKIT
|
||||
#ifdef EXV_HAVE_XMP_TOOLKIT
|
||||
#include "xmp_exiv2.hpp"
|
||||
#endif
|
||||
|
||||
@ -319,6 +291,8 @@ void Exiv2::dumpLibraryInfo(std::ostream& os,const exv_grep_keys_t& keys)
|
||||
|
||||
int enable_video =0;
|
||||
int enable_webready =0;
|
||||
int use_curl =0;
|
||||
int use_ssh =0;
|
||||
|
||||
#ifdef EXV_HAVE_GMTIME_R
|
||||
have_gmtime_r=1;
|
||||
@ -460,6 +434,14 @@ void Exiv2::dumpLibraryInfo(std::ostream& os,const exv_grep_keys_t& keys)
|
||||
enable_webready=1;
|
||||
#endif
|
||||
|
||||
#ifdef EXV_USE_CURL
|
||||
use_curl=1;
|
||||
#endif
|
||||
|
||||
#ifdef EXV_USE_SSH
|
||||
use_ssh=1;
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW__)
|
||||
// enumerate loaded libraries and determine path to executable
|
||||
HMODULE handles[200];
|
||||
@ -516,8 +498,8 @@ void Exiv2::dumpLibraryInfo(std::ostream& os,const exv_grep_keys_t& keys)
|
||||
output(os,keys,"version" , __VERSION__);
|
||||
output(os,keys,"date" , __DATE__ );
|
||||
output(os,keys,"time" , __TIME__ );
|
||||
output(os,keys,"ssh" , EXV_USE_SSH);
|
||||
#if EXV_USE_CURL == 1
|
||||
|
||||
#ifdef EXV_USE_CURL
|
||||
std::string curl_protocols;
|
||||
curl_version_info_data* vinfo = curl_version_info(CURLVERSION_NOW);
|
||||
for (int i = 0; vinfo->protocols[i]; i++) {
|
||||
@ -525,9 +507,9 @@ void Exiv2::dumpLibraryInfo(std::ostream& os,const exv_grep_keys_t& keys)
|
||||
curl_protocols += " " ;
|
||||
}
|
||||
output(os,keys,"curlprotocols" ,curl_protocols);
|
||||
#else
|
||||
output(os,keys,"curl" , EXV_USE_CURL);
|
||||
#endif
|
||||
|
||||
output(os,keys,"curl" , use_curl);
|
||||
output(os,keys,"id" , "$Id$");
|
||||
if ( libs.begin() != libs.end() ) {
|
||||
output(os,keys,"executable" ,*libs.begin());
|
||||
@ -570,6 +552,9 @@ void Exiv2::dumpLibraryInfo(std::ostream& os,const exv_grep_keys_t& keys)
|
||||
output(os,keys,"have_unicode_path" ,have_unicode_path);
|
||||
output(os,keys,"enable_video" ,enable_video );
|
||||
output(os,keys,"enable_webready" ,enable_webready );
|
||||
output(os,keys,"use_curl" ,use_curl );
|
||||
output(os,keys,"use_ssh" ,use_ssh );
|
||||
|
||||
output(os,keys,"config_path" ,Exiv2::Internal::getExiv2ConfigPath());
|
||||
|
||||
// #1147
|
||||
@ -579,7 +564,7 @@ void Exiv2::dumpLibraryInfo(std::ostream& os,const exv_grep_keys_t& keys)
|
||||
uid_t gid = getgid() ; output(os,keys,"gid" , gid );
|
||||
#endif
|
||||
|
||||
#if EXV_HAVE_XMP_TOOLKIT
|
||||
#ifdef EXV_HAVE_XMP_TOOLKIT
|
||||
const char* name = "xmlns";
|
||||
|
||||
Exiv2::Dictionary ns;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user