mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-07-06 04:51:46 -07:00
make things compile
This commit is contained in:
parent
5c73fe9304
commit
0b04f772ef
8 changed files with 700 additions and 72 deletions
|
@ -20,6 +20,7 @@
|
|||
#include "EmbeddedNetworkController.hpp"
|
||||
#include "../version.h"
|
||||
#include "Redis.hpp"
|
||||
#include "CtlUtil.hpp"
|
||||
|
||||
#include <smeeclient.h>
|
||||
|
||||
|
@ -38,73 +39,7 @@ namespace {
|
|||
|
||||
static const int DB_MINIMUM_VERSION = 38;
|
||||
|
||||
static const char *_timestr()
|
||||
{
|
||||
|
||||
time_t t = time(0);
|
||||
char *ts = ctime(&t);
|
||||
char *p = ts;
|
||||
if (!p)
|
||||
return "";
|
||||
while (*p) {
|
||||
if (*p == '\n') {
|
||||
*p = (char)0;
|
||||
break;
|
||||
}
|
||||
++p;
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
|
||||
/*
|
||||
std::string join(const std::vector<std::string> &elements, const char * const separator)
|
||||
{
|
||||
switch(elements.size()) {
|
||||
case 0:
|
||||
return "";
|
||||
case 1:
|
||||
return elements[0];
|
||||
default:
|
||||
std::ostringstream os;
|
||||
std::copy(elements.begin(), elements.end()-1, std::ostream_iterator<std::string>(os, separator));
|
||||
os << *elements.rbegin();
|
||||
return os.str();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
std::vector<std::string> split(std::string str, char delim){
|
||||
std::istringstream iss(str);
|
||||
std::vector<std::string> tokens;
|
||||
std::string item;
|
||||
while(std::getline(iss, item, delim)) {
|
||||
tokens.push_back(item);
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
|
||||
std::string url_encode(const std::string &value) {
|
||||
std::ostringstream escaped;
|
||||
escaped.fill('0');
|
||||
escaped << std::hex;
|
||||
|
||||
for (std::string::const_iterator i = value.begin(), n = value.end(); i != n; ++i) {
|
||||
std::string::value_type c = (*i);
|
||||
|
||||
// Keep alphanumeric and other accepted characters intact
|
||||
if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') {
|
||||
escaped << c;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Any other characters are percent-encoded
|
||||
escaped << std::uppercase;
|
||||
escaped << '%' << std::setw(2) << int((unsigned char) c);
|
||||
escaped << std::nouppercase;
|
||||
}
|
||||
|
||||
return escaped.str();
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue