Merge branch 'next' into aeonwave
This commit is contained in:
commit
f71e2e0e9f
@ -27,6 +27,8 @@
|
|||||||
#include <memory> // for std::auto_ptr
|
#include <memory> // for std::auto_ptr
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <ctime> // for time_t
|
||||||
|
|
||||||
#include <simgear/structure/SGReferenced.hxx>
|
#include <simgear/structure/SGReferenced.hxx>
|
||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
|
|
||||||
|
@ -82,13 +82,11 @@ public:
|
|||||||
curl_multi_setopt(curlMulti, CURLMOPT_PIPELINING, 1 /* aka CURLPIPE_HTTP1 */);
|
curl_multi_setopt(curlMulti, CURLMOPT_PIPELINING, 1 /* aka CURLPIPE_HTTP1 */);
|
||||||
#if (LIBCURL_VERSION_MINOR >= 30)
|
#if (LIBCURL_VERSION_MINOR >= 30)
|
||||||
curl_multi_setopt(curlMulti, CURLMOPT_MAX_TOTAL_CONNECTIONS, (long) maxConnections);
|
curl_multi_setopt(curlMulti, CURLMOPT_MAX_TOTAL_CONNECTIONS, (long) maxConnections);
|
||||||
#endif
|
|
||||||
curl_multi_setopt(curlMulti, CURLMOPT_MAX_PIPELINE_LENGTH,
|
curl_multi_setopt(curlMulti, CURLMOPT_MAX_PIPELINE_LENGTH,
|
||||||
(long) maxPipelineDepth);
|
(long) maxPipelineDepth);
|
||||||
curl_multi_setopt(curlMulti, CURLMOPT_MAX_HOST_CONNECTIONS,
|
curl_multi_setopt(curlMulti, CURLMOPT_MAX_HOST_CONNECTIONS,
|
||||||
(long) maxHostConnections);
|
(long) maxHostConnections);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::map<Request_ptr, CURL*> RequestCurlMap;
|
typedef std::map<Request_ptr, CURL*> RequestCurlMap;
|
||||||
@ -148,13 +146,17 @@ void Client::setMaxConnections(unsigned int maxCon)
|
|||||||
void Client::setMaxHostConnections(unsigned int maxHostCon)
|
void Client::setMaxHostConnections(unsigned int maxHostCon)
|
||||||
{
|
{
|
||||||
d->maxHostConnections = maxHostCon;
|
d->maxHostConnections = maxHostCon;
|
||||||
|
#if (LIBCURL_VERSION_MINOR >= 30)
|
||||||
curl_multi_setopt(d->curlMulti, CURLMOPT_MAX_HOST_CONNECTIONS, (long) maxHostCon);
|
curl_multi_setopt(d->curlMulti, CURLMOPT_MAX_HOST_CONNECTIONS, (long) maxHostCon);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::setMaxPipelineDepth(unsigned int depth)
|
void Client::setMaxPipelineDepth(unsigned int depth)
|
||||||
{
|
{
|
||||||
d->maxPipelineDepth = depth;
|
d->maxPipelineDepth = depth;
|
||||||
|
#if (LIBCURL_VERSION_MINOR >= 30)
|
||||||
curl_multi_setopt(d->curlMulti, CURLMOPT_MAX_PIPELINE_LENGTH, (long) depth);
|
curl_multi_setopt(d->curlMulti, CURLMOPT_MAX_PIPELINE_LENGTH, (long) depth);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::update(int waitTimeout)
|
void Client::update(int waitTimeout)
|
||||||
|
@ -6,25 +6,24 @@
|
|||||||
//#include <stdint.h>
|
//#include <stdint.h>
|
||||||
//#include <string.h>
|
//#include <string.h>
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__) || defined(__APPLE__)
|
||||||
|
# include <machine/endian.h>
|
||||||
|
#elif !defined(_WIN32)
|
||||||
|
# include <endian.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __BIG_ENDIAN__
|
#ifdef __BIG_ENDIAN__
|
||||||
# define SHA_BIG_ENDIAN
|
# define SHA_BIG_ENDIAN
|
||||||
#elif defined __LITTLE_ENDIAN__
|
|
||||||
/* override */
|
|
||||||
#elif defined __BYTE_ORDER
|
#elif defined __BYTE_ORDER
|
||||||
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
# define SHA_BIG_ENDIAN
|
# define SHA_BIG_ENDIAN
|
||||||
# endif
|
# endif
|
||||||
#elif defined _WIN32
|
#elif defined BYTE_ORDER
|
||||||
/* assume little-endian, there is no endian.h on MSVC */
|
# if BYTE_ORDER == BIG_ENDIAN
|
||||||
#else // ! defined __LITTLE_ENDIAN__
|
# define SHA_BIG_ENDIAN
|
||||||
# include <endian.h> // machine/endian.h
|
|
||||||
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
|
||||||
# define SHA_BIG_ENDIAN
|
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* code */
|
/* code */
|
||||||
#define SHA1_K0 0x5a827999
|
#define SHA1_K0 0x5a827999
|
||||||
#define SHA1_K20 0x6ed9eba1
|
#define SHA1_K20 0x6ed9eba1
|
||||||
|
@ -79,7 +79,7 @@ namespace simgear {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static vector<string>
|
static vector<string>
|
||||||
split_whitespace( const string& str, int maxsplit )
|
split_whitespace( const string& str, int maxsplit )
|
||||||
@ -125,7 +125,7 @@ namespace simgear {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
vector<string>
|
vector<string>
|
||||||
split( const string& str, const char* sep, int maxsplit )
|
split( const string& str, const char* sep, int maxsplit )
|
||||||
@ -229,7 +229,7 @@ namespace simgear {
|
|||||||
return do_strip( s, BOTHSTRIP );
|
return do_strip( s, BOTHSTRIP );
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
rpad( const string & s, string::size_type length, char c )
|
rpad( const string & s, string::size_type length, char c )
|
||||||
{
|
{
|
||||||
string::size_type l = s.length();
|
string::size_type l = s.length();
|
||||||
@ -238,7 +238,7 @@ namespace simgear {
|
|||||||
return reply.append( length-l, c );
|
return reply.append( length-l, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
lpad( const string & s, size_t length, char c )
|
lpad( const string & s, size_t length, char c )
|
||||||
{
|
{
|
||||||
string::size_type l = s.length();
|
string::size_type l = s.length();
|
||||||
@ -268,12 +268,12 @@ namespace simgear {
|
|||||||
string result; // reserve size of 's'?
|
string result; // reserve size of 's'?
|
||||||
string::const_iterator it = s.begin(),
|
string::const_iterator it = s.begin(),
|
||||||
end = s.end();
|
end = s.end();
|
||||||
|
|
||||||
// advance to first non-space char - simplifes logic in main loop,
|
// advance to first non-space char - simplifes logic in main loop,
|
||||||
// since we can always prepend a single space when we see a
|
// since we can always prepend a single space when we see a
|
||||||
// space -> non-space transition
|
// space -> non-space transition
|
||||||
for (; (it != end) && isspace(*it); ++it) { /* nothing */ }
|
for (; (it != end) && isspace(*it); ++it) { /* nothing */ }
|
||||||
|
|
||||||
bool lastWasSpace = false;
|
bool lastWasSpace = false;
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
char c = *it;
|
char c = *it;
|
||||||
@ -281,18 +281,18 @@ namespace simgear {
|
|||||||
lastWasSpace = true;
|
lastWasSpace = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastWasSpace) {
|
if (lastWasSpace) {
|
||||||
result.push_back(' ');
|
result.push_back(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
lastWasSpace = false;
|
lastWasSpace = false;
|
||||||
result.push_back(c);
|
result.push_back(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int to_int(const std::string& s, int base)
|
int to_int(const std::string& s, int base)
|
||||||
{
|
{
|
||||||
stringstream ss(s);
|
stringstream ss(s);
|
||||||
@ -301,12 +301,12 @@ namespace simgear {
|
|||||||
case 16: ss >> std::hex; break;
|
case 16: ss >> std::hex; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
ss >> result;
|
ss >> result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int compare_versions(const string& v1, const string& v2)
|
int compare_versions(const string& v1, const string& v2)
|
||||||
{
|
{
|
||||||
vector<string> v1parts(split(v1, "."));
|
vector<string> v1parts(split(v1, "."));
|
||||||
@ -325,7 +325,7 @@ namespace simgear {
|
|||||||
// reached end - longer wins
|
// reached end - longer wins
|
||||||
return v1parts.size() - v2parts.size();
|
return v1parts.size() - v2parts.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
string join(const string_list& l, const string& joinWith)
|
string join(const string_list& l, const string& joinWith)
|
||||||
{
|
{
|
||||||
string result;
|
string result;
|
||||||
@ -336,10 +336,10 @@ namespace simgear {
|
|||||||
result += joinWith;
|
result += joinWith;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
string uppercase(const string &s) {
|
string uppercase(const string &s) {
|
||||||
string rslt(s);
|
string rslt(s);
|
||||||
for(string::iterator p = rslt.begin(); p != rslt.end(); p++){
|
for(string::iterator p = rslt.begin(); p != rslt.end(); p++){
|
||||||
@ -361,16 +361,16 @@ namespace simgear {
|
|||||||
*p = tolower(*p);
|
*p = tolower(*p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SG_WINDOWS)
|
#if defined(SG_WINDOWS)
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
static WCharVec convertMultiByteToWString(DWORD encoding, const std::string& a)
|
static WCharVec convertMultiByteToWString(DWORD encoding, const std::string& a)
|
||||||
{
|
{
|
||||||
WCharVec result;
|
WCharVec result;
|
||||||
DWORD flags = 0;
|
DWORD flags = 0;
|
||||||
int requiredWideChars = MultiByteToWideChar(encoding, flags,
|
int requiredWideChars = MultiByteToWideChar(encoding, flags,
|
||||||
a.c_str(), a.size(),
|
a.c_str(), a.size(),
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
result.resize(requiredWideChars);
|
result.resize(requiredWideChars);
|
||||||
@ -391,7 +391,7 @@ std::string convertWindowsLocal8BitToUtf8(const std::string& a)
|
|||||||
#ifdef SG_WINDOWS
|
#ifdef SG_WINDOWS
|
||||||
DWORD flags = 0;
|
DWORD flags = 0;
|
||||||
WCharVec wideString = convertMultiByteToWString(CP_ACP, a);
|
WCharVec wideString = convertMultiByteToWString(CP_ACP, a);
|
||||||
|
|
||||||
// convert down to UTF-8
|
// convert down to UTF-8
|
||||||
std::vector<char> result;
|
std::vector<char> result;
|
||||||
int requiredUTF8Chars = WideCharToMultiByte(CP_UTF8, flags,
|
int requiredUTF8Chars = WideCharToMultiByte(CP_UTF8, flags,
|
||||||
@ -454,8 +454,8 @@ static const unsigned char base64_decode_map[128] =
|
|||||||
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
|
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
|
||||||
49, 50, 51, 127, 127, 127, 127, 127
|
49, 50, 51, 127, 127, 127, 127, 127
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static inline bool is_base64(unsigned char c) {
|
static inline bool is_base64(unsigned char c) {
|
||||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||||
}
|
}
|
||||||
@ -471,46 +471,46 @@ void decodeBase64(const std::string& encoded_string, std::vector<unsigned char>&
|
|||||||
int j = 0;
|
int j = 0;
|
||||||
int in_ = 0;
|
int in_ = 0;
|
||||||
unsigned char char_array_4[4], char_array_3[3];
|
unsigned char char_array_4[4], char_array_3[3];
|
||||||
|
|
||||||
while (in_len-- && ( encoded_string[in_] != '=')) {
|
while (in_len-- && ( encoded_string[in_] != '=')) {
|
||||||
if (is_whitespace( encoded_string[in_])) {
|
if (is_whitespace( encoded_string[in_])) {
|
||||||
in_++;
|
in_++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_base64(encoded_string[in_])) {
|
if (!is_base64(encoded_string[in_])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
char_array_4[i++] = encoded_string[in_]; in_++;
|
char_array_4[i++] = encoded_string[in_]; in_++;
|
||||||
if (i ==4) {
|
if (i ==4) {
|
||||||
for (i = 0; i <4; i++)
|
for (i = 0; i <4; i++)
|
||||||
char_array_4[i] = base64_decode_map[char_array_4[i]];
|
char_array_4[i] = base64_decode_map[char_array_4[i]];
|
||||||
|
|
||||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||||
|
|
||||||
for (i = 0; (i < 3); i++)
|
for (i = 0; (i < 3); i++)
|
||||||
ret.push_back(char_array_3[i]);
|
ret.push_back(char_array_3[i]);
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i) {
|
if (i) {
|
||||||
for (j = i; j <4; j++)
|
for (j = i; j <4; j++)
|
||||||
char_array_4[j] = 0;
|
char_array_4[j] = 0;
|
||||||
|
|
||||||
for (j = 0; j <4; j++)
|
for (j = 0; j <4; j++)
|
||||||
char_array_4[j] = base64_decode_map[char_array_4[j]];
|
char_array_4[j] = base64_decode_map[char_array_4[j]];
|
||||||
|
|
||||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||||
|
|
||||||
for (j = 0; (j < i - 1); j++) ret.push_back(char_array_3[j]);
|
for (j = 0; (j < i - 1); j++) ret.push_back(char_array_3[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
const char hexChar[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
const char hexChar[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||||
@ -531,7 +531,7 @@ std::string encodeHex(const unsigned char* rawBytes, unsigned int length)
|
|||||||
hex[i * 2] = hexChar[c >> 4];
|
hex[i * 2] = hexChar[c >> 4];
|
||||||
hex[i * 2 + 1] = hexChar[c & 0x0f];
|
hex[i * 2 + 1] = hexChar[c & 0x0f];
|
||||||
}
|
}
|
||||||
|
|
||||||
return hex;
|
return hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,7 +597,7 @@ string sanitizePrintfFormat(const string& input)
|
|||||||
SG_LOG(SG_IO, SG_WARN, "sanitizePrintfFormat: bad format string:" << input);
|
SG_LOG(SG_IO, SG_WARN, "sanitizePrintfFormat: bad format string:" << input);
|
||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,7 +615,7 @@ std::string error_string(int errnum)
|
|||||||
retcode = strerror_s(buf, sizeof(buf), errnum);
|
retcode = strerror_s(buf, sizeof(buf), errnum);
|
||||||
#elif defined(_GNU_SOURCE)
|
#elif defined(_GNU_SOURCE)
|
||||||
return std::string(strerror_r(errnum, buf, sizeof(buf)));
|
return std::string(strerror_r(errnum, buf, sizeof(buf)));
|
||||||
#elif (_POSIX_C_SOURCE >= 200112L) || defined(SG_MAC)
|
#elif (_POSIX_C_SOURCE >= 200112L) || defined(SG_MAC) || defined(__FreeBSD__)
|
||||||
int retcode;
|
int retcode;
|
||||||
// POSIX.1-2001 and POSIX.1-2008
|
// POSIX.1-2001 and POSIX.1-2008
|
||||||
retcode = strerror_r(errnum, buf, sizeof(buf));
|
retcode = strerror_r(errnum, buf, sizeof(buf));
|
||||||
@ -645,5 +645,5 @@ std::string error_string(int errnum)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace strutils
|
} // end namespace strutils
|
||||||
|
|
||||||
} // end namespace simgear
|
} // end namespace simgear
|
||||||
|
Loading…
Reference in New Issue
Block a user