Fix stuff
This commit is contained in:
parent
64f57aa373
commit
3a8b931cda
|
@ -771,9 +771,9 @@ if(HAVE_GNUTLS_GNUTLS_H)
|
|||
HAVE_DECL_GNUTLS_FINGERPRINT)
|
||||
endif(HAVE_GNUTLS_GNUTLS_H)
|
||||
|
||||
if(HAVE_MD5_OPENSSL)
|
||||
if(NOT HAVE_DECL_GNUTLS_FINGERPRINT AND HAVE_MD5_OPENSSL)
|
||||
set(HAVE_DECL_MD5 1)
|
||||
endif(HAVE_MD5_OPENSSL)
|
||||
endif(NOT HAVE_DECL_GNUTLS_FINGERPRINT AND HAVE_MD5_OPENSSL)
|
||||
|
||||
if((NOT HAVE_MD5_OPENSSL) AND (NOT HAVE_DECL_GNUTLS_FINGERPRINT))
|
||||
message(AUTHOR_WARNING
|
||||
|
|
|
@ -24,6 +24,19 @@
|
|||
|
||||
#include "zm_packetqueue.h"
|
||||
|
||||
/* Func ptrs for libcurl functions */
|
||||
static void *curl_lib = nullptr;
|
||||
static CURLcode (*curl_global_init_f)(long) = nullptr;
|
||||
static void (*curl_global_cleanup_f)(void) = nullptr;
|
||||
static const char* (*curl_easy_strerror_f)(CURLcode) = nullptr;
|
||||
static char* (*curl_version_f)(void) = nullptr;
|
||||
static CURL* (*curl_easy_init_f)(void) = nullptr;
|
||||
static CURLcode (*curl_easy_getinfo_f)(CURL* , CURLINFO, ...) = nullptr;
|
||||
static CURLcode (*curl_easy_perform_f)(CURL*) = nullptr;
|
||||
static CURLcode (*curl_easy_setopt_f)(CURL*, CURLoption, ...) = nullptr;
|
||||
static void (*curl_easy_cleanup_f)(CURL*) = nullptr;
|
||||
|
||||
|
||||
#if HAVE_LIBCURL
|
||||
|
||||
#define CURL_MAXRETRY 5
|
||||
|
@ -57,15 +70,15 @@ void cURLCamera::Initialise() {
|
|||
|
||||
databuffer.expand(CURL_BUFFER_INITIAL_SIZE);
|
||||
|
||||
void *curl_lib = dlopen("libcurl.so", 0);
|
||||
curl_lib = dlopen("libcurl.so", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (!curl_lib)
|
||||
curl_lib = dlopen("libcurl.so.3", 0);
|
||||
curl_lib = dlopen("libcurl.so.3", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (!curl_lib)
|
||||
curl_lib = dlopen("libcurl.so.4", 0);
|
||||
curl_lib = dlopen("libcurl.so.4", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (!curl_lib)
|
||||
curl_lib = dlopen("libcurl-gnutls.so.4", 0);
|
||||
curl_lib = dlopen("libcurl-gnutls.so.4", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (!curl_lib)
|
||||
Fatal("Could not load libcurl: ", dlerror());
|
||||
Fatal("Could not load libcurl: %s", dlerror());
|
||||
|
||||
// Load up all required symbols here
|
||||
*(void**) (&curl_global_init_f) = dlsym(curl_lib, "curl_global_init");
|
||||
|
@ -455,7 +468,7 @@ void* cURLCamera::thread_func() {
|
|||
/* Authenication preference */
|
||||
cRet = (*curl_easy_setopt_f)(c, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
||||
if(cRet != CURLE_OK)
|
||||
Warning("Failed setting libcurl acceptable http authenication methods: %s", curl_easy_strerror(cRet));
|
||||
Warning("Failed setting libcurl acceptable http authenication methods: %s", (*curl_easy_strerror_f)(cRet));
|
||||
|
||||
|
||||
/* Work loop */
|
||||
|
@ -517,7 +530,7 @@ void* cURLCamera::thread_func() {
|
|||
}
|
||||
|
||||
/* Cleanup */
|
||||
(*curl_easy_cleanup)(c);
|
||||
(*curl_easy_cleanup_f)(c);
|
||||
c = NULL;
|
||||
|
||||
return (void*)tRet;
|
||||
|
|
|
@ -97,18 +97,6 @@ size_t data_callback_dispatcher(void *buffer, size_t size, size_t nmemb, void *u
|
|||
int progress_callback_dispatcher(void *userdata, double dltotal, double dlnow, double ultotal, double ulnow);
|
||||
void* thread_func_dispatcher(void* object);
|
||||
|
||||
/* Func ptrs for libcurl functions */
|
||||
CURLcode (*curl_global_init_f)(long);
|
||||
void (*curl_global_cleanup_f)(void);
|
||||
const char* (*curl_easy_strerror_f)(CURLcode);
|
||||
char* (*curl_version_f)(void);
|
||||
CURL* (*curl_easy_init_f)(void);
|
||||
CURLcode (*curl_easy_getinfo_f)(CURL* , CURLINFO, ...);
|
||||
CURLcode (*curl_easy_perform_f)(CURL*);
|
||||
CURLcode (*curl_easy_setopt_f)(CURL*, CURLoption, ...);
|
||||
void (*curl_easy_cleanup_f)(CURL*);
|
||||
|
||||
|
||||
#endif // HAVE_LIBCURL
|
||||
|
||||
#endif // ZM_CURL_CAMERA_H
|
||||
|
|
|
@ -403,18 +403,36 @@ char *timeval_to_string( struct timeval tv ) {
|
|||
}
|
||||
|
||||
std::string UriDecode( const std::string &encoded ) {
|
||||
#ifdef HAVE_LIBCURL
|
||||
CURL *curl = curl_easy_init();
|
||||
int outlength;
|
||||
char *cres = curl_easy_unescape(curl, encoded.c_str(), encoded.length(), &outlength);
|
||||
std::string res(cres, cres + outlength);
|
||||
curl_free(cres);
|
||||
curl_easy_cleanup(curl);
|
||||
return res;
|
||||
#else
|
||||
Warning("ZM Compiled without LIBCURL. UriDecoding not implemented.");
|
||||
return encoded;
|
||||
#endif
|
||||
char a, b;
|
||||
const char *src = encoded.c_str();
|
||||
std::string retbuf;
|
||||
retbuf.resize(encoded.length() + 1);
|
||||
char *dst = &retbuf[0];
|
||||
while (*src) {
|
||||
if ((*src == '%') && ((a = src[1]) && (b = src[2])) && (isxdigit(a) && isxdigit(b))) {
|
||||
if (a >= 'a')
|
||||
a -= 'a'-'A';
|
||||
if (a >= 'A')
|
||||
a -= ('A' - 10);
|
||||
else
|
||||
a -= '0';
|
||||
if (b >= 'a')
|
||||
b -= 'a'-'A';
|
||||
if (b >= 'A')
|
||||
b -= ('A' - 10);
|
||||
else
|
||||
b -= '0';
|
||||
*dst++ = 16*a+b;
|
||||
src+=3;
|
||||
} else if (*src == '+') {
|
||||
*dst++ = ' ';
|
||||
src++;
|
||||
} else {
|
||||
*dst++ = *src++;
|
||||
}
|
||||
}
|
||||
*dst++ = '\0';
|
||||
return retbuf;
|
||||
}
|
||||
|
||||
void string_toupper( std::string& str) {
|
||||
|
|
Loading…
Reference in New Issue