Xjail/Spartancoin Project

Check-in [c034ed9ced]
Login
Overview
Comment:xjail::toLower xjail::toUpper
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | boost-1.66.0
Files: files | file ages | folders
SHA3-256:c034ed9ced4c48a05ca81ac7a5e667ff58726195aed640117fd552e0ef7fd81f
User & Date: xjail 2018-07-20 17:53:18
Context
2019-01-20
19:54
merge from boost-1.66.0 to openssl-1.1.1 check-in: 1c008c07c4 user: xjail tags: openssl-1.1.1
19:47
Create new branch named "openssl-1.1.1" check-in: de1d4824c8 user: xjail tags: openssl-1.1.1
2018-07-20
17:53
xjail::toLower xjail::toUpper Closed-Leaf check-in: c034ed9ced user: xjail tags: boost-1.66.0
2018-07-19
03:14
xjail_spn_util.h xjail_spn_util.cpp check-in: 3bd8d24615 user: xjail tags: boost-1.66.0
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/bitcoinrpc.cpp.

8
9
10
11
12
13
14


15
16
17
18
19
20
21
...
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
#include "util.h"
#include "sync.h"
#include "ui_interface.h"
#include "base58.h"
#include "bitcoinrpc.h"
#include "db.h"



#include <boost/asio.hpp>
#include <boost/asio/ip/v6_only.hpp>
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/algorithm/string.hpp>
................................................................................
        if (str.empty() || str == "\r")
            break;
        string::size_type nColon = str.find(":");
        if (nColon != string::npos)
        {
            string strHeader = str.substr(0, nColon);
            boost::trim(strHeader);
            boost::to_lower(strHeader);
            string strValue = str.substr(nColon+1);
            boost::trim(strValue);
            mapHeadersRet[strHeader] = strValue;
            if (strHeader == "content-length")
                nLen = atoi(strValue.c_str());
        }
    }







>
>







 







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
#include "util.h"
#include "sync.h"
#include "ui_interface.h"
#include "base58.h"
#include "bitcoinrpc.h"
#include "db.h"

#include "xjail_spn_util.h"

#include <boost/asio.hpp>
#include <boost/asio/ip/v6_only.hpp>
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/algorithm/string.hpp>
................................................................................
        if (str.empty() || str == "\r")
            break;
        string::size_type nColon = str.find(":");
        if (nColon != string::npos)
        {
            string strHeader = str.substr(0, nColon);
            boost::trim(strHeader);
	    xjail::toLower(strHeader);
            string strValue = str.substr(nColon+1);
            boost::trim(strValue);
            mapHeadersRet[strHeader] = strValue;
            if (strHeader == "content-length")
                nLen = atoi(strValue.c_str());
        }
    }

Changes to src/netbase.cpp.

4
5
6
7
8
9
10


11
12
13
14
15
16
17
18
19
20
21
22
..
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "netbase.h"
#include "util.h"
#include "sync.h"
#include "hash.h"



#ifndef WIN32
#include <sys/fcntl.h>
#endif

#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()

using namespace std;

// Settings
static proxyType proxyInfo[NET_MAX];
static proxyType nameproxyInfo;
................................................................................
static CCriticalSection cs_proxyInfos;
int nConnectTimeout = 5000;
bool fNameLookup = false;

static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };

enum Network ParseNetwork(std::string net) {
    boost::to_lower(net);
    if (net == "ipv4") return NET_IPV4;
    if (net == "ipv6") return NET_IPV6;
    if (net == "tor")  return NET_TOR;
    return NET_UNROUTABLE;
}

void SplitHostPort(std::string in, int &portOut, std::string &hostOut) {







>
>




<







 







|







4
5
6
7
8
9
10
11
12
13
14
15
16

17
18
19
20
21
22
23
..
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "netbase.h"
#include "util.h"
#include "sync.h"
#include "hash.h"

#include "xjail_spn_util.h"

#ifndef WIN32
#include <sys/fcntl.h>
#endif


#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()

using namespace std;

// Settings
static proxyType proxyInfo[NET_MAX];
static proxyType nameproxyInfo;
................................................................................
static CCriticalSection cs_proxyInfos;
int nConnectTimeout = 5000;
bool fNameLookup = false;

static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };

enum Network ParseNetwork(std::string net) {
    xjail::toLower(net);
    if (net == "ipv4") return NET_IPV4;
    if (net == "ipv6") return NET_IPV6;
    if (net == "tor")  return NET_TOR;
    return NET_UNROUTABLE;
}

void SplitHostPort(std::string in, int &portOut, std::string &hostOut) {

Changes to src/util.cpp.

14
15
16
17
18
19
20



21
22
23
24
25
26
27
28
29
...
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
#include <sys/resource.h>
#endif

#include "util.h"
#include "sync.h"
#include "version.h"
#include "ui_interface.h"



#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()

#include <iomanip>
#include <sstream>

// Work around clang compilation problem in Boost 1.46:
// /usr/include/boost/program_options/detail/config_file.hpp:163:17: error: call to function 'to_internal' that is neither visible in the template definition nor found by argument-dependent lookup
................................................................................
        size_t is_index = str.find('=');
        if (is_index != std::string::npos)
        {
            strValue = str.substr(is_index+1);
            str = str.substr(0, is_index);
        }
#ifdef WIN32
        boost::to_lower(str);
        if (boost::algorithm::starts_with(str, "/"))
            str = "-" + str.substr(1);
#endif
        if (str[0] != '-')
            break;

        mapArgs[str] = strValue;







>
>
>

<







 







|







14
15
16
17
18
19
20
21
22
23
24

25
26
27
28
29
30
31
...
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
#include <sys/resource.h>
#endif

#include "util.h"
#include "sync.h"
#include "version.h"
#include "ui_interface.h"

#include "xjail_spn_util.h"

#include <boost/algorithm/string/join.hpp>

#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()

#include <iomanip>
#include <sstream>

// Work around clang compilation problem in Boost 1.46:
// /usr/include/boost/program_options/detail/config_file.hpp:163:17: error: call to function 'to_internal' that is neither visible in the template definition nor found by argument-dependent lookup
................................................................................
        size_t is_index = str.find('=');
        if (is_index != std::string::npos)
        {
            strValue = str.substr(is_index+1);
            str = str.substr(0, is_index);
        }
#ifdef WIN32
	xjail::toLower(str);
        if (boost::algorithm::starts_with(str, "/"))
            str = "-" + str.substr(1);
#endif
        if (str[0] != '-')
            break;

        mapArgs[str] = strValue;

Changes to src/xjail_spn_util.cpp.

2
3
4
5
6
7
8

9
10
11
12
13
14
15
..
22
23
24
25
26
27
28
































// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "xjail_spn_util.h"
#include <map>
#include <vector>
#include <string>


void xjail::addStaticNodes(
	std::map<std::string, std::string> & mapArgs_node, 
	std::map<std::string, std::vector<std::string>> & mapMultiArgs_node
) {
	const std::string & key = "-addnode";
	const std::vector<std::string> & addrs {
................................................................................
		"2001:19f0:9002:2ef:5400:ff:fe79:3d75" 
	};
	for (std::size_t i=0; i<addrs.size(); i++) {
		mapArgs_node[key] = addrs[i];
		mapMultiArgs_node[key].push_back(addrs[i]);
	}
}







































>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "xjail_spn_util.h"
#include <map>
#include <vector>
#include <string>
#include <functional>

void xjail::addStaticNodes(
	std::map<std::string, std::string> & mapArgs_node, 
	std::map<std::string, std::vector<std::string>> & mapMultiArgs_node
) {
	const std::string & key = "-addnode";
	const std::vector<std::string> & addrs {
................................................................................
		"2001:19f0:9002:2ef:5400:ff:fe79:3d75" 
	};
	for (std::size_t i=0; i<addrs.size(); i++) {
		mapArgs_node[key] = addrs[i];
		mapMultiArgs_node[key].push_back(addrs[i]);
	}
}

char xjail::lower(char ch) {
	if ((ch >= 'A' && ch <= 'Z') || (ch >= 'Z' && ch <= 'A'))
		return ch - ('A' - 'a');
	return ch;
}

char xjail::upper(char ch) {
	if ((ch >= 'a' && ch <= 'z') || (ch >= 'z' && ch <= 'a'))
		return ch + ('A' - 'a');
	return ch;
}

std::string & xjail::toLower(std::string && str) {
	std::transform(str.begin(), str.end(), str.begin(), xjail::lower);
	return str;
}

std::string & xjail::toLower(std::string & str) {
	std::transform(str.begin(), str.end(), str.begin(), xjail::lower);
	return str;
}

std::string & xjail::toUpper(std::string && str) {
	std::transform(str.begin(), str.end(), str.begin(), xjail::upper);
	return str;
}

std::string & xjail::toUpper(std::string & str) {
	std::transform(str.begin(), str.end(), str.begin(), xjail::upper);
	return str;
}

Changes to src/xjail_spn_util.h.

5
6
7
8
9
10
11


12
13
14
15
16
17
18







19
20
21
#ifndef __xjail_spn_util_h__
#define __xjail_spn_util_h__

#include <map>
#include <vector>
#include <string>



namespace xjail {

void addStaticNodes(
	std::map<std::string, std::string> & mapArgs_node, 
	std::map<std::string, std::vector<std::string>> & mapMultiArgs_node
);








} // namespace xjail

#endif







>
>







>
>
>
>
>
>
>



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef __xjail_spn_util_h__
#define __xjail_spn_util_h__

#include <map>
#include <vector>
#include <string>

using namespace std::string_literals;

namespace xjail {

void addStaticNodes(
	std::map<std::string, std::string> & mapArgs_node, 
	std::map<std::string, std::vector<std::string>> & mapMultiArgs_node
);

char lower(char ch);
char upper(char ch);
std::string & toLower(std::string && str);
std::string & toLower(std::string & str);
std::string & toUpper(std::string && str);
std::string & toUpper(std::string & str);

} // namespace xjail

#endif