Mercurial > irccd
comparison irccdctl/main.cpp @ 521:e03521cf207b
Common: split util.hpp into more appropriate files, closes #721
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 27 Oct 2017 21:45:32 +0200 |
parents | 16b9ebfd3f08 |
children | a88796ed040a |
comparison
equal
deleted
inserted
replaced
520:defacef00c82 | 521:e03521cf207b |
---|---|
27 #include "ini.hpp" | 27 #include "ini.hpp" |
28 #include "irccdctl.hpp" | 28 #include "irccdctl.hpp" |
29 #include "logger.hpp" | 29 #include "logger.hpp" |
30 #include "options.hpp" | 30 #include "options.hpp" |
31 #include "system.hpp" | 31 #include "system.hpp" |
32 #include "string_util.hpp" | |
32 #include "util.hpp" | 33 #include "util.hpp" |
33 | 34 |
34 using namespace std::string_literals; | 35 using namespace std::string_literals; |
35 using namespace irccd; | 36 using namespace irccd; |
36 | 37 |
139 } | 140 } |
140 } | 141 } |
141 | 142 |
142 address = net::resolveOne(host, port, domain, SOCK_STREAM); | 143 address = net::resolveOne(host, port, domain, SOCK_STREAM); |
143 | 144 |
144 if ((it = sc.find("ssl")) != sc.end() && util::is_boolean(it->value())) | 145 if ((it = sc.find("ssl")) != sc.end() && string_util::is_boolean(it->value())) |
145 #if defined(HAVE_SSL) | 146 #if defined(HAVE_SSL) |
146 client = std::make_unique<TlsClient>(); | 147 client = std::make_unique<TlsClient>(); |
147 #else | 148 #else |
148 throw std::runtime_error("SSL disabled"); | 149 throw std::runtime_error("SSL disabled"); |
149 #endif | 150 #endif |
217 void readGeneral(const ini::section &sc) | 218 void readGeneral(const ini::section &sc) |
218 { | 219 { |
219 auto verbose = sc.find("verbose"); | 220 auto verbose = sc.find("verbose"); |
220 | 221 |
221 if (verbose != sc.end()) | 222 if (verbose != sc.end()) |
222 log::set_verbose(util::is_boolean(verbose->value())); | 223 log::set_verbose(string_util::is_boolean(verbose->value())); |
223 } | 224 } |
224 | 225 |
225 /* | 226 /* |
226 * readAlias | 227 * readAlias |
227 * ------------------------------------------------------------------- | 228 * ------------------------------------------------------------------- |
244 /* | 245 /* |
245 * Iterate over the arguments which are usually a list and the first | 246 * Iterate over the arguments which are usually a list and the first |
246 * argument is a command name. | 247 * argument is a command name. |
247 */ | 248 */ |
248 if (option.size() == 1 && option[0].empty()) | 249 if (option.size() == 1 && option[0].empty()) |
249 throw std::runtime_error(util::sprintf("alias %s: missing command name in '%s'", name, option.key())); | 250 throw std::runtime_error(string_util::sprintf("alias %s: missing command name in '%s'", name, option.key())); |
250 | 251 |
251 std::string command = option[0]; | 252 std::string command = option[0]; |
252 std::vector<AliasArg> args(option.begin() + 1, option.end()); | 253 std::vector<AliasArg> args(option.begin() + 1, option.end()); |
253 | 254 |
254 alias.emplace_back(std::move(command), std::move(args)); | 255 alias.emplace_back(std::move(command), std::move(args)); |
434 cmdArgs.push_back(cmd.command()); | 435 cmdArgs.push_back(cmd.command()); |
435 | 436 |
436 for (const auto &arg : cmd.args()) { | 437 for (const auto &arg : cmd.args()) { |
437 if (arg.isPlaceholder()) { | 438 if (arg.isPlaceholder()) { |
438 if (args.size() < arg.index() + 1) | 439 if (args.size() < arg.index() + 1) |
439 throw std::invalid_argument(util::sprintf("missing argument for placeholder %d", arg.index())); | 440 throw std::invalid_argument(string_util::sprintf("missing argument for placeholder %d", arg.index())); |
440 | 441 |
441 cmdArgs.push_back(args[arg.index()]); | 442 cmdArgs.push_back(args[arg.index()]); |
442 | 443 |
443 if (arg.index() + 1 > toremove) { | 444 if (arg.index() + 1 > toremove) { |
444 toremove = arg.index() + 1; | 445 toremove = arg.index() + 1; |