More work on removing old determinism-in-driver code
This commit is contained in:
@@ -1,4 +1,10 @@
|
|||||||
|
|
||||||
|
#define CHBUF_SIZE (256*1024)
|
||||||
|
#define POLLVEC_SIZE (DrivenEngine::MAX_CHAN+1)
|
||||||
|
|
||||||
|
static std::unique_ptr<char[]> chbuf;
|
||||||
|
static std::unique_ptr<struct pollfd[]> pollvec;
|
||||||
|
|
||||||
static MonoClock monoclock;
|
static MonoClock monoclock;
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
@@ -19,13 +25,41 @@ static void initialize_engine() {
|
|||||||
DrivenEngine::register_maker("unittest", make_RunUnitTests);
|
DrivenEngine::register_maker("unittest", make_RunUnitTests);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void if_error_print_and_exit(const UmmString &str) {
|
static void allocate_buffers() {
|
||||||
|
chbuf.reset(new char[CHBUF_SIZE]);
|
||||||
|
pollvec.reset(new struct pollfd[POLLVEC_SIZE]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void if_error_print_and_exit(const std::string &str) {
|
||||||
if (!str.empty()) {
|
if (!str.empty()) {
|
||||||
std::cerr << std::endl << "error: " << str << std::endl;
|
std::cerr << std::endl << "error: " << str << std::endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string_view read_file(const char *fn, char *buf, int bufsize, std::string &err) {
|
||||||
|
FILE *f = fopen(fn, "r");
|
||||||
|
if (f == 0) {
|
||||||
|
err = std::string("cannot read file") + fn;
|
||||||
|
buf[0] = 0;
|
||||||
|
return std::string_view(buf, 0);
|
||||||
|
}
|
||||||
|
int nread = fread(buf, 1, bufsize, f);
|
||||||
|
if (nread < 0) {
|
||||||
|
err = std::string("cannot read file: ") + fn;
|
||||||
|
buf[0] = 0;
|
||||||
|
return std::string_view(buf, 0);
|
||||||
|
}
|
||||||
|
if (nread == bufsize) {
|
||||||
|
err = std::string("file too large: ") + fn;
|
||||||
|
buf[0] = 0;
|
||||||
|
return std::string_view(buf, 0);
|
||||||
|
}
|
||||||
|
err = "";
|
||||||
|
return std::string_view(buf, nread);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static SSL_CTX *new_ssl_context(bool server_cert, bool root_certs, std::string_view require_cert) {
|
static SSL_CTX *new_ssl_context(bool server_cert, bool root_certs, std::string_view require_cert) {
|
||||||
SSL_CTX *ctx = SSL_CTX_new(TLS_method());
|
SSL_CTX *ctx = SSL_CTX_new(TLS_method());
|
||||||
SSL_CTX_set_mode(ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
|
SSL_CTX_set_mode(ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
|
||||||
@@ -40,12 +74,12 @@ static SSL_CTX *new_ssl_context(bool server_cert, bool root_certs, std::string_v
|
|||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static UmmString err_print_errors_str() {
|
static std::string err_print_errors_str() {
|
||||||
BIO *bio = BIO_new(BIO_s_mem());
|
BIO *bio = BIO_new(BIO_s_mem());
|
||||||
ERR_print_errors(bio);
|
ERR_print_errors(bio);
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t len = BIO_get_mem_data(bio, &buf);
|
size_t len = BIO_get_mem_data(bio, &buf);
|
||||||
UmmString ret(buf, len);
|
std::string ret(buf, len);
|
||||||
BIO_free(bio);
|
BIO_free(bio);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -99,8 +133,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
DrivenEngine *driven_;
|
DrivenEngine *driven_;
|
||||||
UmmVector<ChanInfo> chans_;
|
std::vector<ChanInfo> chans_;
|
||||||
UmmMap<int, SOCKET> listen_sockets_;
|
std::map<int, SOCKET> listen_sockets_;
|
||||||
bool read_console_recently_;
|
bool read_console_recently_;
|
||||||
|
|
||||||
SSL_CTX *ssl_ctx_with_root_certs_;
|
SSL_CTX *ssl_ctx_with_root_certs_;
|
||||||
@@ -112,7 +146,7 @@ public:
|
|||||||
const std::vector<int> &listenports = driven_->drv_get_listen_ports();
|
const std::vector<int> &listenports = driven_->drv_get_listen_ports();
|
||||||
for (int port : listenports) {
|
for (int port : listenports) {
|
||||||
if (listen_sockets_.find(port) == listen_sockets_.end()) {
|
if (listen_sockets_.find(port) == listen_sockets_.end()) {
|
||||||
UmmString err;
|
std::string err;
|
||||||
SOCKET sock = listen_on_port(port, err);
|
SOCKET sock = listen_on_port(port, err);
|
||||||
if_error_print_and_exit(err);
|
if_error_print_and_exit(err);
|
||||||
assert(sock != INVALID_SOCKET);
|
assert(sock != INVALID_SOCKET);
|
||||||
@@ -123,13 +157,13 @@ public:
|
|||||||
|
|
||||||
void handle_lua_source() {
|
void handle_lua_source() {
|
||||||
if (driven_->drv_get_rescan_lua_source()) {
|
if (driven_->drv_get_rescan_lua_source()) {
|
||||||
UmmString err;
|
std::string err;
|
||||||
std::string_view ctrl = read_file("lua/control.lst", chbuf.get(), CHBUF_SIZE, err);
|
std::string_view ctrl = read_file("lua/control.lst", chbuf.get(), CHBUF_SIZE, err);
|
||||||
if_error_print_and_exit(err);
|
if_error_print_and_exit(err);
|
||||||
UmmStringVec names = drv::parse_control_lst(ctrl);
|
std::vector<std::string> names = drv::parse_control_lst(ctrl);
|
||||||
driven_->drv_clear_lua_source();
|
driven_->drv_clear_lua_source();
|
||||||
for (const UmmString &str : names) {
|
for (const std::string &str : names) {
|
||||||
UmmString lfn = UmmString("lua/") + str;
|
std::string lfn = std::string("lua/") + str;
|
||||||
std::string_view data = read_file(lfn.c_str(), chbuf.get(), CHBUF_SIZE, err);
|
std::string_view data = read_file(lfn.c_str(), chbuf.get(), CHBUF_SIZE, err);
|
||||||
if_error_print_and_exit(err);
|
if_error_print_and_exit(err);
|
||||||
driven_->drv_add_lua_source(str, data);
|
driven_->drv_add_lua_source(str, data);
|
||||||
@@ -221,7 +255,7 @@ public:
|
|||||||
void handle_new_outgoing_sockets() {
|
void handle_new_outgoing_sockets() {
|
||||||
const std::vector<int> &chans = driven_->drv_get_new_outgoing();
|
const std::vector<int> &chans = driven_->drv_get_new_outgoing();
|
||||||
for (int chid : chans) {
|
for (int chid : chans) {
|
||||||
UmmString err;
|
std::string err;
|
||||||
SOCKET sock = open_connection(driven_->drv_get_target(chid), err);
|
SOCKET sock = open_connection(driven_->drv_get_target(chid), err);
|
||||||
if (sock == INVALID_SOCKET) {
|
if (sock == INVALID_SOCKET) {
|
||||||
driven_->drv_notify_close(chid, err);
|
driven_->drv_notify_close(chid, err);
|
||||||
@@ -236,7 +270,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void accept_connection(int port, SOCKET sock) {
|
void accept_connection(int port, SOCKET sock) {
|
||||||
UmmString err;
|
std::string err;
|
||||||
SOCKET socket = accept_on_socket(sock, err);
|
SOCKET socket = accept_on_socket(sock, err);
|
||||||
if_error_print_and_exit(err);
|
if_error_print_and_exit(err);
|
||||||
if (socket != INVALID_SOCKET) {
|
if (socket != INVALID_SOCKET) {
|
||||||
@@ -247,7 +281,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void advance_plaintext(ChanInfo &chan) {
|
void advance_plaintext(ChanInfo &chan) {
|
||||||
UmmString err;
|
std::string err;
|
||||||
|
|
||||||
// If the channel has no outgoing bytes and has been released,
|
// If the channel has no outgoing bytes and has been released,
|
||||||
// just close it.
|
// just close it.
|
||||||
@@ -384,7 +418,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
void handle_socket_input_output() {
|
void handle_socket_input_output() {
|
||||||
UmmString err;
|
std::string err;
|
||||||
int mstimeout = read_console_recently_ ? 100 : 1000;
|
int mstimeout = read_console_recently_ ? 100 : 1000;
|
||||||
|
|
||||||
// Peek output buffers and determine channel release flags.
|
// Peek output buffers and determine channel release flags.
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/personality.h>
|
#include <sys/personality.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
#include <malloc.h>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <openssl/rsa.h>
|
#include <openssl/rsa.h>
|
||||||
#include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
@@ -36,18 +37,12 @@
|
|||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
#include <openssl/conf.h>
|
#include <openssl/conf.h>
|
||||||
|
|
||||||
#define OPENSSL_HEAP_SIZE (4*1024*1024)
|
|
||||||
#define CHBUF_SIZE (256*1024)
|
|
||||||
#define POLLVEC_SIZE (DrivenEngine::MAX_CHAN+1)
|
|
||||||
|
|
||||||
using SOCKET=int;
|
using SOCKET=int;
|
||||||
const int INVALID_SOCKET = -1;
|
const int INVALID_SOCKET = -1;
|
||||||
|
|
||||||
struct termios orig_termios;
|
struct termios orig_termios;
|
||||||
static std::unique_ptr<char[]> chbuf;
|
|
||||||
static std::unique_ptr<struct pollfd[]> pollvec;
|
|
||||||
|
|
||||||
static UmmString strerror_str(int err) {
|
static std::string strerror_str(int err) {
|
||||||
char errbuf[256];
|
char errbuf[256];
|
||||||
return strerror_r(errno, errbuf, 256);
|
return strerror_r(errno, errbuf, 256);
|
||||||
}
|
}
|
||||||
@@ -77,7 +72,7 @@ static void enable_tty_raw() {
|
|||||||
assert(status >= 0);
|
assert(status >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SOCKET open_connection(std::string_view target, UmmString &err) {
|
static SOCKET open_connection(std::string_view target, std::string &err) {
|
||||||
struct addrinfo *addrs = nullptr;
|
struct addrinfo *addrs = nullptr;
|
||||||
struct addrinfo *goodaddr = nullptr;
|
struct addrinfo *goodaddr = nullptr;
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
@@ -90,7 +85,7 @@ static SOCKET open_connection(std::string_view target, UmmString &err) {
|
|||||||
hints.ai_flags = AI_NUMERICSERV;
|
hints.ai_flags = AI_NUMERICSERV;
|
||||||
|
|
||||||
err.clear();
|
err.clear();
|
||||||
UmmString host, port;
|
std::string host, port;
|
||||||
drv::split_host_port(target, host, port);
|
drv::split_host_port(target, host, port);
|
||||||
int status = getaddrinfo(host.c_str(), port.c_str(), &hints, &addrs);
|
int status = getaddrinfo(host.c_str(), port.c_str(), &hints, &addrs);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
@@ -123,7 +118,7 @@ error_general:
|
|||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SOCKET listen_on_port(int port, UmmString &err) {
|
static SOCKET listen_on_port(int port, std::string &err) {
|
||||||
int status, enable;
|
int status, enable;
|
||||||
err.clear();
|
err.clear();
|
||||||
|
|
||||||
@@ -154,7 +149,7 @@ error_errno:
|
|||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SOCKET accept_on_socket(SOCKET listen_socket, UmmString &err) {
|
static SOCKET accept_on_socket(SOCKET listen_socket, std::string &err) {
|
||||||
err.clear();
|
err.clear();
|
||||||
SOCKET chsock = accept(listen_socket, nullptr, nullptr);
|
SOCKET chsock = accept(listen_socket, nullptr, nullptr);
|
||||||
if (chsock >= 0) {
|
if (chsock >= 0) {
|
||||||
@@ -174,7 +169,7 @@ static SOCKET accept_on_socket(SOCKET listen_socket, UmmString &err) {
|
|||||||
// zero: would block
|
// zero: would block
|
||||||
// negative: channel closed, possibly cleanly or possibly with error
|
// negative: channel closed, possibly cleanly or possibly with error
|
||||||
//
|
//
|
||||||
static int socket_send(SOCKET socket, const char *bytes, int nbytes, UmmString &err) {
|
static int socket_send(SOCKET socket, const char *bytes, int nbytes, std::string &err) {
|
||||||
err.clear();
|
err.clear();
|
||||||
int wbytes = send(socket, bytes, nbytes, 0);
|
int wbytes = send(socket, bytes, nbytes, 0);
|
||||||
if (wbytes < 0) {
|
if (wbytes < 0) {
|
||||||
@@ -189,7 +184,7 @@ static int socket_send(SOCKET socket, const char *bytes, int nbytes, UmmString &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int socket_recv(SOCKET socket, char *bytes, int nbytes, UmmString &err) {
|
static int socket_recv(SOCKET socket, char *bytes, int nbytes, std::string &err) {
|
||||||
err.clear();
|
err.clear();
|
||||||
int nrecv = recv(socket, bytes, nbytes, 0);
|
int nrecv = recv(socket, bytes, nbytes, 0);
|
||||||
if (nrecv < 0) {
|
if (nrecv < 0) {
|
||||||
@@ -210,7 +205,7 @@ static int socket_close(SOCKET socket) {
|
|||||||
return close(socket);
|
return close(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int socket_poll(struct pollfd *pollvec, int pollcount, int mstimeout, UmmString &err) {
|
static int socket_poll(struct pollfd *pollvec, int pollcount, int mstimeout, std::string &err) {
|
||||||
// socket_poll is implicitly expected to also poll stdin,
|
// socket_poll is implicitly expected to also poll stdin,
|
||||||
// if the OS allows that. Linux does, so we add stdin to the
|
// if the OS allows that. Linux does, so we add stdin to the
|
||||||
// poll vector. The poll vector is required to have at
|
// poll vector. The poll vector is required to have at
|
||||||
@@ -236,25 +231,6 @@ static int console_read(char *bytes, int nbytes) {
|
|||||||
return read(0, bytes, nbytes);
|
return read(0, bytes, nbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string_view read_file(const char *fn, char *buf, int bufsize, UmmString &err) {
|
|
||||||
int nread;
|
|
||||||
int fd = open(fn, O_RDONLY);
|
|
||||||
if (fd < 0) goto error_errno;
|
|
||||||
nread = read(fd, buf, bufsize);
|
|
||||||
if (nread < 0) goto error_errno;
|
|
||||||
if (nread == bufsize) {
|
|
||||||
err = "file too large";
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
buf[nread] = 0;
|
|
||||||
err = "";
|
|
||||||
return std::string_view(buf, nread);
|
|
||||||
error_errno:
|
|
||||||
err = strerror_str(errno);
|
|
||||||
error:
|
|
||||||
buf[0] = 0;
|
|
||||||
return std::string_view(buf, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void disable_randomization(int argc, char *argv[]) {
|
static void disable_randomization(int argc, char *argv[]) {
|
||||||
const int old_personality = personality(ADDR_NO_RANDOMIZE);
|
const int old_personality = personality(ADDR_NO_RANDOMIZE);
|
||||||
@@ -290,10 +266,10 @@ public:
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
mallopt(M_MMAP_MAX, 0); // Keep malloc in the 'brk' area.
|
||||||
disable_randomization(argc, argv);
|
disable_randomization(argc, argv);
|
||||||
|
allocate_buffers();
|
||||||
enable_tty_raw();
|
enable_tty_raw();
|
||||||
chbuf.reset(new char[CHBUF_SIZE]);
|
|
||||||
pollvec.reset(new struct pollfd[POLLVEC_SIZE]);
|
|
||||||
OPENSSL_init_ssl(0, NULL);
|
OPENSSL_init_ssl(0, NULL);
|
||||||
initialize_engine();
|
initialize_engine();
|
||||||
driver_drive(argc, argv);
|
driver_drive(argc, argv);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ static PADDRINFOA find_good_addr(PADDRINFOA addrinfo) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SOCKET open_connection(std::string_view target, UmmString &err) {
|
static SOCKET open_connection(std::string_view target, std::string &err) {
|
||||||
PADDRINFOA addrs = nullptr;
|
PADDRINFOA addrs = nullptr;
|
||||||
PADDRINFOA goodaddr = nullptr;
|
PADDRINFOA goodaddr = nullptr;
|
||||||
SOCKET sock = INVALID_SOCKET;
|
SOCKET sock = INVALID_SOCKET;
|
||||||
@@ -104,7 +104,7 @@ error:
|
|||||||
return SOCKET_ERROR;
|
return SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOCKET listen_on_port(int port, UmmString &err) {
|
SOCKET listen_on_port(int port, std::string &err) {
|
||||||
int status;
|
int status;
|
||||||
err.clear();
|
err.clear();
|
||||||
SOCKET sock = socket(AF_INET, SOCK_STREAM, 0);
|
SOCKET sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
@@ -137,7 +137,7 @@ error:
|
|||||||
return SOCKET_ERROR;
|
return SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SOCKET accept_on_socket(SOCKET listen_socket, UmmString &err) {
|
static SOCKET accept_on_socket(SOCKET listen_socket, std::string &err) {
|
||||||
SOCKET chsock = accept(listen_socket, nullptr, nullptr);
|
SOCKET chsock = accept(listen_socket, nullptr, nullptr);
|
||||||
if (chsock != INVALID_SOCKET) {
|
if (chsock != INVALID_SOCKET) {
|
||||||
set_nonblocking(chsock);
|
set_nonblocking(chsock);
|
||||||
@@ -153,7 +153,7 @@ static SOCKET accept_on_socket(SOCKET listen_socket, UmmString &err) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int socket_send(SOCKET socket, const char *bytes, int nbytes, UmmString &err) {
|
static int socket_send(SOCKET socket, const char *bytes, int nbytes, std::string &err) {
|
||||||
err.clear();
|
err.clear();
|
||||||
int wbytes = send(socket, bytes, nbytes, 0);
|
int wbytes = send(socket, bytes, nbytes, 0);
|
||||||
if (wbytes == SOCKET_ERROR) {
|
if (wbytes == SOCKET_ERROR) {
|
||||||
@@ -170,7 +170,7 @@ static int socket_send(SOCKET socket, const char *bytes, int nbytes, UmmString &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int socket_recv(SOCKET socket, char *bytes, int nbytes, UmmString &err) {
|
static int socket_recv(SOCKET socket, char *bytes, int nbytes, std::string &err) {
|
||||||
err.clear();
|
err.clear();
|
||||||
int nrecv = recv(socket, bytes, nbytes, 0);
|
int nrecv = recv(socket, bytes, nbytes, 0);
|
||||||
if (nrecv < 0) {
|
if (nrecv < 0) {
|
||||||
@@ -192,7 +192,7 @@ static int socket_close(SOCKET socket) {
|
|||||||
return closesocket(socket);
|
return closesocket(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int socket_poll(struct pollfd *pollvec, int pollcount, int mstimeout, UmmString &err) {
|
static int socket_poll(struct pollfd *pollvec, int pollcount, int mstimeout, std::string &err) {
|
||||||
int status = WSAPoll(pollvec, pollcount, mstimeout);
|
int status = WSAPoll(pollvec, pollcount, mstimeout);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
err = winsock_error_string(WSAGetLastError());
|
err = winsock_error_string(WSAGetLastError());
|
||||||
@@ -270,9 +270,8 @@ public:
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
allocate_buffers();
|
||||||
init_winsock();
|
init_winsock();
|
||||||
chbuf.reset(new char[CHBUF_SIZE]);
|
|
||||||
pollvec.reset(new struct pollfd[POLLVEC_SIZE]);
|
|
||||||
OPENSSL_init_ssl(0, NULL);
|
OPENSSL_init_ssl(0, NULL);
|
||||||
initialize_engine();
|
initialize_engine();
|
||||||
driver_drive(argc, argv);
|
driver_drive(argc, argv);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
namespace drv {
|
namespace drv {
|
||||||
|
|
||||||
void split_host_port(std::string_view target, UmmString &host, UmmString &port) {
|
void split_host_port(std::string_view target, std::string &host, std::string &port) {
|
||||||
size_t lastcolon = target.rfind(':');
|
size_t lastcolon = target.rfind(':');
|
||||||
if (lastcolon == std::string_view::npos) {
|
if (lastcolon == std::string_view::npos) {
|
||||||
host = ""; port = ""; return;
|
host = ""; port = ""; return;
|
||||||
@@ -17,8 +17,8 @@ void split_host_port(std::string_view target, UmmString &host, UmmString &port)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UmmStringVec parse_control_lst(std::string_view ctrl) {
|
std::vector<std::string> parse_control_lst(std::string_view ctrl) {
|
||||||
UmmStringVec result;
|
std::vector<std::string> result;
|
||||||
while (!ctrl.empty()) {
|
while (!ctrl.empty()) {
|
||||||
std::string_view line = util::sv_read_line(ctrl);
|
std::string_view line = util::sv_read_line(ctrl);
|
||||||
std::string_view trimmed = util::sv_trim(line);
|
std::string_view trimmed = util::sv_trim(line);
|
||||||
@@ -34,7 +34,7 @@ UmmStringVec parse_control_lst(std::string_view ctrl) {
|
|||||||
|
|
||||||
LuaDefine(unittests_driverutil, "", "some unit tests") {
|
LuaDefine(unittests_driverutil, "", "some unit tests") {
|
||||||
// Test split_host_port
|
// Test split_host_port
|
||||||
UmmString host, port;
|
std::string host, port;
|
||||||
drv::split_host_port("stanford.edu:80", host, port);
|
drv::split_host_port("stanford.edu:80", host, port);
|
||||||
LuaAssertStrEq(L, host, "stanford.edu");
|
LuaAssertStrEq(L, host, "stanford.edu");
|
||||||
LuaAssertStrEq(L, port, "80");
|
LuaAssertStrEq(L, port, "80");
|
||||||
|
|||||||
@@ -6,19 +6,12 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
using UmmString = std::string;
|
|
||||||
template <typename T>
|
|
||||||
using UmmVector = std::vector<T>;
|
|
||||||
template <typename K, typename V, class C = std::less<K>>
|
|
||||||
using UmmMap = std::map<K, V, C>;
|
|
||||||
|
|
||||||
using UmmStringVec = UmmVector<UmmString>;
|
|
||||||
|
|
||||||
namespace drv {
|
namespace drv {
|
||||||
|
|
||||||
void split_host_port(std::string_view target, UmmString &host, UmmString &port);
|
void split_host_port(std::string_view target, std::string &host, std::string &port);
|
||||||
|
|
||||||
UmmStringVec parse_control_lst(std::string_view ctrl);
|
std::vector<std::string> parse_control_lst(std::string_view ctrl);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user