diff --git a/src/command_download.cc b/src/command_download.cc index 8c67d1a1..57b9e67d 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -175,7 +175,7 @@ apply_d_delete_link(core::Download* download, const torrent::Object& rawArgs) { #define ADD_COMMAND_DOWNLOAD_SLOT(key, function, slot, parm, doc) \ commandDownloadSlotsItr->set_slot(slot); \ - variables->insert(key, commandDownloadSlotsItr++, NULL, &utils::CommandDownloadSlot::function, utils::VariableMap::flag_dont_delete | utils::VariableMap::flag_public_xmlrpc, parm, doc); + variables->insert(key, commandDownloadSlotsItr++, NULL, &utils::CommandDownloadSlot::function, utils::CommandMap::flag_dont_delete | utils::CommandMap::flag_public_xmlrpc, parm, doc); #define ADD_COMMAND_DOWNLOAD_VOID(key, slot) \ ADD_COMMAND_DOWNLOAD_SLOT(key, call_unknown, utils::object_d_fn(slot), "i:", "") @@ -207,7 +207,7 @@ apply_d_delete_link(core::Download* download, const torrent::Object& rawArgs) { void add_copy_to_download(const char* key) { - utils::VariableMap::iterator itr = control->variable()->find(key); + utils::CommandMap::iterator itr = control->variable()->find(key); if (itr == control->variable()->end()) throw torrent::internal_error("add_copy_to_download(...) key not found."); @@ -217,7 +217,7 @@ add_copy_to_download(const char* key) { void initialize_command_download() { - utils::VariableMap* variables = control->download_variables(); + utils::CommandMap* variables = control->download_variables(); ADD_COMMAND_DOWNLOAD_VOID("base_path", &retrieve_d_base_path); ADD_COMMAND_DOWNLOAD_VOID("base_filename", &retrieve_d_base_filename); diff --git a/src/command_events.cc b/src/command_events.cc index 9994e3e8..a67311c8 100644 --- a/src/command_events.cc +++ b/src/command_events.cc @@ -216,7 +216,7 @@ apply_close_low_diskspace(int64_t arg) { void initialize_command_events() { - utils::VariableMap* variables = control->variable(); + utils::CommandMap* variables = control->variable(); core::DownloadList* downloadList = control->core()->download_list(); ADD_VARIABLE_BOOL("check_hash", true); diff --git a/src/command_helpers.cc b/src/command_helpers.cc index dd7a22c3..b596d843 100644 --- a/src/command_helpers.cc +++ b/src/command_helpers.cc @@ -79,14 +79,14 @@ initialize_commands() { void add_variable(const char* getKey, const char* setKey, const char* defaultSetKey, - utils::VariableMap::generic_slot getSlot, utils::VariableMap::generic_slot setSlot, + utils::CommandMap::generic_slot getSlot, utils::CommandMap::generic_slot setSlot, const torrent::Object& defaultObject) { utils::CommandVariable* variable = commandVariablesItr++; variable->set_variable(defaultObject); - control->variable()->insert(getKey, variable, getSlot, NULL, utils::VariableMap::flag_dont_delete | utils::VariableMap::flag_public_xmlrpc, "i:", ""); - control->variable()->insert(setKey, variable, setSlot, NULL, utils::VariableMap::flag_dont_delete | utils::VariableMap::flag_public_xmlrpc, "i:", ""); + control->variable()->insert(getKey, variable, getSlot, NULL, utils::CommandMap::flag_dont_delete | utils::CommandMap::flag_public_xmlrpc, "i:", ""); + control->variable()->insert(setKey, variable, setSlot, NULL, utils::CommandMap::flag_dont_delete | utils::CommandMap::flag_public_xmlrpc, "i:", ""); if (defaultSetKey) - control->variable()->insert(defaultSetKey, variable, setSlot, NULL, utils::VariableMap::flag_dont_delete, "i:", ""); + control->variable()->insert(defaultSetKey, variable, setSlot, NULL, utils::CommandMap::flag_dont_delete, "i:", ""); } diff --git a/src/command_helpers.h b/src/command_helpers.h index 0670e5ea..262645f3 100644 --- a/src/command_helpers.h +++ b/src/command_helpers.h @@ -37,7 +37,7 @@ #ifndef RTORRENT_UTILS_COMMAND_HELPERS_H #define RTORRENT_UTILS_COMMAND_HELPERS_H -#include "utils/variable_map.h" +#include "rpc/command_map.h" namespace utils { class CommandSlot; @@ -64,7 +64,7 @@ void initialize_commands(); void add_variable(const char* getKey, const char* setKey, const char* defaultSetKey, - utils::VariableMap::generic_slot getSlot, utils::VariableMap::generic_slot setSlot, + utils::CommandMap::generic_slot getSlot, utils::CommandMap::generic_slot setSlot, const torrent::Object& defaultObject); #define ADD_VARIABLE_BOOL(key, defaultValue) \ @@ -78,17 +78,17 @@ add_variable("get_" key, "set_" key, key, &utils::CommandVariable::get_string, & #define ADD_COMMAND_SLOT(key, function, slot, parm, doc) \ commandSlotsItr->set_slot(slot); \ - variables->insert(key, commandSlotsItr++, &utils::CommandSlot::function, NULL, utils::VariableMap::flag_dont_delete | utils::VariableMap::flag_public_xmlrpc, parm, doc); + variables->insert(key, commandSlotsItr++, &utils::CommandSlot::function, NULL, utils::CommandMap::flag_dont_delete | utils::CommandMap::flag_public_xmlrpc, parm, doc); #define ADD_COMMAND_SLOT_PRIVATE(key, function, slot) \ commandSlotsItr->set_slot(slot); \ - variables->insert(key, commandSlotsItr++, &utils::CommandSlot::function, NULL, utils::VariableMap::flag_dont_delete, NULL, NULL); + variables->insert(key, commandSlotsItr++, &utils::CommandSlot::function, NULL, utils::CommandMap::flag_dont_delete, NULL, NULL); #define ADD_COMMAND_COPY(key, function, parm, doc) \ - variables->insert(key, (commandSlotsItr - 1), &utils::CommandSlot::function, NULL, utils::VariableMap::flag_dont_delete | utils::VariableMap::flag_public_xmlrpc, parm, doc); + variables->insert(key, (commandSlotsItr - 1), &utils::CommandSlot::function, NULL, utils::CommandMap::flag_dont_delete | utils::CommandMap::flag_public_xmlrpc, parm, doc); #define ADD_COMMAND_COPY_PRIVATE(key, function) \ - variables->insert(key, (commandSlotsItr - 1), &utils::CommandSlot::function, NULL, utils::VariableMap::flag_dont_delete, NULL, NULL); + variables->insert(key, (commandSlotsItr - 1), &utils::CommandSlot::function, NULL, utils::CommandMap::flag_dont_delete, NULL, NULL); #define ADD_COMMAND_VALUE_TRI(key, set, get) \ ADD_COMMAND_SLOT_PRIVATE(key, call_value, utils::object_value_fn(set)) \ diff --git a/src/command_local.cc b/src/command_local.cc index 12c26bdb..3a552f10 100644 --- a/src/command_local.cc +++ b/src/command_local.cc @@ -46,7 +46,7 @@ #include "core/manager.h" #include "rpc/command_slot.h" #include "rpc/command_variable.h" -#include "utils/variable_map.h" +#include "rpc/command_map.h" #include "globals.h" #include "control.h" @@ -56,7 +56,7 @@ typedef torrent::ChunkManager CM_t; void initialize_command_local() { - utils::VariableMap* variables = control->variable(); + utils::CommandMap* variables = control->variable(); // core::DownloadList* downloadList = control->core()->download_list(); torrent::ChunkManager* chunkManager = torrent::chunk_manager(); core::DownloadList* dList = control->core()->download_list(); diff --git a/src/command_network.cc b/src/command_network.cc index 7db82bd9..b3c8ba4c 100644 --- a/src/command_network.cc +++ b/src/command_network.cc @@ -54,7 +54,7 @@ #include "rpc/command_slot.h" #include "rpc/command_variable.h" #include "rpc/parse.h" -#include "utils/variable_map.h" +#include "rpc/command_map.h" #include "globals.h" #include "control.h" @@ -146,12 +146,12 @@ apply_enable_trackers(int64_t arg) { void initialize_xmlrpc() { control->set_xmlrpc(new rpc::XmlRpc); - control->xmlrpc()->set_slot_call_command(rak::mem_fn(control->variable(), &utils::VariableMap::call_command)); + control->xmlrpc()->set_slot_call_command(rak::mem_fn(control->variable(), &utils::CommandMap::call_command)); unsigned int count = 0; - for (utils::VariableMap::const_iterator itr = control->variable()->begin(), last = control->variable()->end(); itr != last; itr++) - if (itr->second.m_flags & utils::VariableMap::flag_public_xmlrpc) { + for (utils::CommandMap::const_iterator itr = control->variable()->begin(), last = control->variable()->end(); itr != last; itr++) + if (itr->second.m_flags & utils::CommandMap::flag_public_xmlrpc) { control->xmlrpc()->insert_command(itr->first, itr->second.m_parm, itr->second.m_doc); count++; @@ -238,7 +238,7 @@ apply_scgi(const std::string& arg, int type) { void initialize_command_network() { - utils::VariableMap* variables = control->variable(); + utils::CommandMap* variables = control->variable(); // core::DownloadList* downloadList = control->core()->download_list(); torrent::ConnectionManager* cm = torrent::connection_manager(); core::CurlStack* httpStack = control->core()->get_poll_manager()->get_http_stack(); diff --git a/src/command_ui.cc b/src/command_ui.cc index 3d075c1d..ca603bc4 100644 --- a/src/command_ui.cc +++ b/src/command_ui.cc @@ -99,7 +99,7 @@ apply_view_sort(const torrent::Object& rawArgs) { void initialize_command_ui() { - utils::VariableMap* variables = control->variable(); + utils::CommandMap* variables = control->variable(); // core::DownloadList* downloadList = control->core()->download_list(); ADD_VARIABLE_STRING("key_layout", "qwerty"); diff --git a/src/control.cc b/src/control.cc index e22adc09..dc0170cd 100644 --- a/src/control.cc +++ b/src/control.cc @@ -55,7 +55,7 @@ #include "rpc/scgi.h" #include "rpc/xmlrpc.h" #include "ui/root.h" -#include "utils/variable_map.h" +#include "rpc/command_map.h" #include "command_scheduler.h" @@ -71,8 +71,8 @@ Control::Control() : m_inputStdin(new input::InputEvent(STDIN_FILENO)), m_commandScheduler(new CommandScheduler()), - m_variables(new utils::VariableMap()), - m_downloadVariables(new utils::VariableMap()), + m_variables(new utils::CommandMap()), + m_downloadVariables(new utils::CommandMap()), m_fastCgi(NULL), m_scgi(NULL), diff --git a/src/control.h b/src/control.h index 002041a1..82f1ecea 100644 --- a/src/control.h +++ b/src/control.h @@ -69,7 +69,7 @@ namespace rpc { } namespace utils { - class VariableMap; + class CommandMap; } class CommandScheduler; @@ -104,8 +104,8 @@ public: CommandScheduler* command_scheduler() { return m_commandScheduler; } - utils::VariableMap* variable() { return m_variables; } - utils::VariableMap* download_variables() { return m_downloadVariables; } + utils::CommandMap* variable() { return m_variables; } + utils::CommandMap* download_variables() { return m_downloadVariables; } rpc::FastCgi* fast_cgi() { return m_fastCgi; } void set_fast_cgi(rpc::FastCgi* f) { m_fastCgi = f; } @@ -142,8 +142,8 @@ private: input::InputEvent* m_inputStdin; CommandScheduler* m_commandScheduler; - utils::VariableMap* m_variables; - utils::VariableMap* m_downloadVariables; + utils::CommandMap* m_variables; + utils::CommandMap* m_downloadVariables; rpc::FastCgi* m_fastCgi; rpc::SCgi* m_scgi; diff --git a/src/core/download.cc b/src/core/download.cc index c8dbbea1..18e44cf0 100644 --- a/src/core/download.cc +++ b/src/core/download.cc @@ -48,7 +48,7 @@ #include #include -#include "utils/variable_map.h" +#include "rpc/command_map.h" #include "control.h" #include "download.h" diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc index eccfee85..63139486 100644 --- a/src/core/download_factory.cc +++ b/src/core/download_factory.cc @@ -47,7 +47,7 @@ #include #include -#include "utils/variable_map.h" +#include "rpc/command_map.h" #include "curl_get.h" #include "control.h" diff --git a/src/core/download_list.cc b/src/core/download_list.cc index 3fe33416..fb40c366 100644 --- a/src/core/download_list.cc +++ b/src/core/download_list.cc @@ -46,7 +46,7 @@ #include #include -#include "utils/variable_map.h" +#include "rpc/command_map.h" #include "control.h" #include "globals.h" diff --git a/src/core/manager.cc b/src/core/manager.cc index 66db7a7e..893edce5 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -55,7 +55,7 @@ #include #include -#include "utils/variable_map.h" +#include "rpc/command_map.h" #include "globals.h" #include "curl_get.h" diff --git a/src/main.cc b/src/main.cc index 0d88880d..d96a74f5 100644 --- a/src/main.cc +++ b/src/main.cc @@ -60,7 +60,7 @@ #include "rpc/parse_commands.h" #include "utils/directory.h" -#include "utils/variable_map.h" +#include "rpc/command_map.h" #include "control.h" #include "globals.h" @@ -82,14 +82,14 @@ parse_options(Control* c, int argc, char** argv) { optionParser.insert_flag('h', sigc::ptr_fun(&print_help)); optionParser.insert_flag('n', OptionParser::Slot()); - optionParser.insert_option('b', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::VariableMap::call_command_set_string), "bind")); - optionParser.insert_option('d', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::VariableMap::call_command_set_string), "directory")); - optionParser.insert_option('i', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::VariableMap::call_command_set_string), "ip")); - optionParser.insert_option('p', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::VariableMap::call_command_set_string), "port_range")); - optionParser.insert_option('s', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::VariableMap::call_command_set_string), "session")); + optionParser.insert_option('b', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::CommandMap::call_command_set_string), "bind")); + optionParser.insert_option('d', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::CommandMap::call_command_set_string), "directory")); + optionParser.insert_option('i', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::CommandMap::call_command_set_string), "ip")); + optionParser.insert_option('p', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::CommandMap::call_command_set_string), "port_range")); + optionParser.insert_option('s', sigc::bind<0>(sigc::mem_fun(c->variable(), &utils::CommandMap::call_command_set_string), "session")); optionParser.insert_option('O', sigc::bind<0>(&utils::parse_command_single_std, c->variable())); - optionParser.insert_option_list('o', sigc::mem_fun(c->variable(), &utils::VariableMap::call_command_set_std_string)); + optionParser.insert_option_list('o', sigc::mem_fun(c->variable(), &utils::CommandMap::call_command_set_std_string)); return optionParser.process(argc, argv); diff --git a/src/rpc/Makefile.am b/src/rpc/Makefile.am index 1bb81112..f2569d66 100644 --- a/src/rpc/Makefile.am +++ b/src/rpc/Makefile.am @@ -2,6 +2,8 @@ noinst_LIBRARIES = libsub_rpc.a libsub_rpc_a_SOURCES = \ command.h \ + command_map.cc \ + command_map.h \ command_slot.cc \ command_slot.h \ command_variable.cc \ diff --git a/src/utils/variable_map.cc b/src/rpc/command_map.cc similarity index 74% rename from src/utils/variable_map.cc rename to src/rpc/command_map.cc index 55f3869a..d70b3f8b 100644 --- a/src/utils/variable_map.cc +++ b/src/rpc/command_map.cc @@ -45,45 +45,45 @@ #include #include -#include "rpc/command.h" -#include "variable_map.h" +#include "command.h" +#include "command_map.h" namespace utils { -struct variable_map_get_ptr : std::unary_function { - Command* operator () (VariableMap::value_type& value) { return value.second.m_variable; } +struct command_map_get_ptr : std::unary_function { + Command* operator () (CommandMap::value_type& value) { return value.second.m_variable; } }; -VariableMap::~VariableMap() { +CommandMap::~CommandMap() { for (iterator itr = base_type::begin(), last = base_type::end(); itr != last; itr++) if (!(itr->second.m_flags & flag_dont_delete)) delete itr->second.m_variable; } void -VariableMap::insert(key_type key, Command* variable, generic_slot genericSlot, download_slot downloadSlot, int flags, +CommandMap::insert(key_type key, Command* variable, generic_slot genericSlot, download_slot downloadSlot, int flags, const char* parm, const char* doc) { iterator itr = base_type::find(key); if (itr != base_type::end()) - throw torrent::internal_error("VariableMap::insert(...) tried to insert an already existing key."); + throw torrent::internal_error("CommandMap::insert(...) tried to insert an already existing key."); - base_type::insert(itr, value_type(key, variable_map_data_type(variable, genericSlot, downloadSlot, flags, parm, doc))); + base_type::insert(itr, value_type(key, command_map_data_type(variable, genericSlot, downloadSlot, flags, parm, doc))); } void -VariableMap::insert(key_type key, const variable_map_data_type src) { +CommandMap::insert(key_type key, const command_map_data_type src) { iterator itr = base_type::find(key); if (itr != base_type::end()) - throw torrent::internal_error("VariableMap::insert(...) tried to insert an already existing key."); + throw torrent::internal_error("CommandMap::insert(...) tried to insert an already existing key."); - base_type::insert(itr, value_type(key, variable_map_data_type(src.m_variable, src.m_genericSlot, src.m_downloadSlot, + base_type::insert(itr, value_type(key, command_map_data_type(src.m_variable, src.m_genericSlot, src.m_downloadSlot, src.m_flags | flag_dont_delete, src.m_parm, src.m_doc))); } -const VariableMap::mapped_type -VariableMap::call_command(key_type key, const mapped_type& arg) { +const CommandMap::mapped_type +CommandMap::call_command(key_type key, const mapped_type& arg) { const_iterator itr = base_type::find(key); if (itr == base_type::end()) @@ -95,8 +95,8 @@ VariableMap::call_command(key_type key, const mapped_type& arg) { return itr->second.m_genericSlot(itr->second.m_variable, arg); } -const VariableMap::mapped_type -VariableMap::call_command_d(key_type key, core::Download* download, const mapped_type& arg) { +const CommandMap::mapped_type +CommandMap::call_command_d(key_type key, core::Download* download, const mapped_type& arg) { const_iterator itr = base_type::find(key); if (itr == base_type::end()) diff --git a/src/utils/variable_map.h b/src/rpc/command_map.h similarity index 86% rename from src/utils/variable_map.h rename to src/rpc/command_map.h index c0760085..27a9f62e 100644 --- a/src/utils/variable_map.h +++ b/src/rpc/command_map.h @@ -34,39 +34,34 @@ // Skomakerveien 33 // 3185 Skoppum, NORWAY -#ifndef RTORRENT_UTILS_VARIABLE_MAP_H -#define RTORRENT_UTILS_VARIABLE_MAP_H +#ifndef RTORRENT_UTILS_COMMAND_MAP_H +#define RTORRENT_UTILS_COMMAND_MAP_H #include #include #include -#include #include namespace core { class Download; } -namespace torrent { - class Object; -} - namespace utils { -struct variable_map_comp : public std::binary_function { - bool operator () (const char* arg1, const char* arg2) const { return std::strcmp(arg1, arg2) < 0; } -}; - class Command; -struct variable_map_data_type { +struct command_map_comp : public std::binary_function { + bool operator () (const char* arg1, const char* arg2) const { return std::strcmp(arg1, arg2) < 0; } +}; + +struct command_map_data_type { // Some commands will need to share data, like get/set a variable. So // instead of using a single virtual member function, each command // will register a member function pointer to be used instead. typedef const torrent::Object (*generic_slot)(Command*, const torrent::Object&); typedef const torrent::Object (*download_slot)(Command*, core::Download*, const torrent::Object&); - variable_map_data_type(Command* variable, generic_slot genericSlot, download_slot downloadSlot, int flags, + command_map_data_type(Command* variable, generic_slot genericSlot, download_slot downloadSlot, int flags, const char* parm, const char* doc) : m_variable(variable), m_genericSlot(genericSlot), m_downloadSlot(downloadSlot), m_flags(flags), m_parm(parm), m_doc(doc) {} @@ -80,12 +75,12 @@ struct variable_map_data_type { const char* m_doc; }; -class VariableMap : public std::map { +class CommandMap : public std::map { public: - typedef std::map base_type; + typedef std::map base_type; - typedef variable_map_data_type::generic_slot generic_slot; - typedef variable_map_data_type::download_slot download_slot; + typedef command_map_data_type::generic_slot generic_slot; + typedef command_map_data_type::download_slot download_slot; typedef torrent::Object mapped_type; typedef mapped_type::value_type mapped_value_type; @@ -105,8 +100,8 @@ public: static const int flag_dont_delete = 0x1; static const int flag_public_xmlrpc = 0x2; - VariableMap() {} - ~VariableMap(); + CommandMap() {} + ~CommandMap(); bool has(const char* key) const { return base_type::find(key) != base_type::end(); } bool has(const std::string& key) const { return has(key.c_str()); } @@ -114,7 +109,7 @@ public: void insert(key_type key, Command* variable, generic_slot genericSlot, download_slot downloadSlot, int flags, const char* parm, const char* doc); - void insert(key_type key, const variable_map_data_type src); + void insert(key_type key, const command_map_data_type src); const mapped_type call_command(key_type key, const mapped_type& arg); const mapped_type call_command_void(key_type key) { return call_command(key, torrent::Object()); } @@ -134,8 +129,8 @@ public: void call_command_d_set_std_string(const std::string& key, core::Download* download, const std::string& arg) { call_command_d(key.c_str(), download, mapped_type(arg)); } private: - VariableMap(const VariableMap&); - void operator = (const VariableMap&); + CommandMap(const CommandMap&); + void operator = (const CommandMap&); }; } diff --git a/src/rpc/parse_commands.cc b/src/rpc/parse_commands.cc index dd098189..f28376be 100644 --- a/src/rpc/parse_commands.cc +++ b/src/rpc/parse_commands.cc @@ -45,17 +45,17 @@ #include "parse.h" #include "parse_commands.h" -#include "utils/variable_map.h" +#include "command_map.h" namespace utils { -struct variable_map_is_space : std::unary_function { +struct command_map_is_space : std::unary_function { bool operator () (char c) const { return std::isspace(c); } }; -struct variable_map_is_newline : std::unary_function { +struct command_map_is_newline : std::unary_function { bool operator () (char c) const { return c == '\n' || c == '\0'; } @@ -74,13 +74,13 @@ parse_command_name(const char* first, const char* last, std::string* dest) { } const char* -parse_command_single(VariableMap* varMap, const char* first) { +parse_command_single(CommandMap* varMap, const char* first) { return parse_command_single(varMap, first, first + std::strlen(first)); } const char* -parse_command_single(VariableMap* varMap, const char* first, const char* last) { - first = std::find_if(first, last, std::not1(variable_map_is_space())); +parse_command_single(CommandMap* varMap, const char* first, const char* last) { + first = std::find_if(first, last, std::not1(command_map_is_space())); if (first == last || *first == '#') return last; @@ -88,7 +88,7 @@ parse_command_single(VariableMap* varMap, const char* first, const char* last) { // Avoid using a string here? std::string key; first = parse_command_name(first, last, &key); - first = std::find_if(first, last, std::not1(variable_map_is_space())); + first = std::find_if(first, last, std::not1(command_map_is_space())); if (first == last || *first != '=') throw torrent::input_error("Could not find '='."); @@ -102,15 +102,15 @@ parse_command_single(VariableMap* varMap, const char* first, const char* last) { } const char* -parse_command_d_single(VariableMap* varMap, core::Download* download, const char* first, const char* last) { - first = std::find_if(first, last, std::not1(variable_map_is_space())); +parse_command_d_single(CommandMap* varMap, core::Download* download, const char* first, const char* last) { + first = std::find_if(first, last, std::not1(command_map_is_space())); if (first == last || *first == '#') return last; std::string key; first = parse_command_name(first, last, &key); - first = std::find_if(first, last, std::not1(variable_map_is_space())); + first = std::find_if(first, last, std::not1(command_map_is_space())); if (first == last || *first != '=') throw torrent::input_error("Could not find '='."); @@ -124,7 +124,7 @@ parse_command_d_single(VariableMap* varMap, core::Download* download, const char } void -parse_command_multiple(VariableMap* varMap, const char* first) { +parse_command_multiple(CommandMap* varMap, const char* first) { try { while (first != '\0') { const char* last = first; @@ -147,7 +147,7 @@ parse_command_multiple(VariableMap* varMap, const char* first) { } bool -parse_command_file(VariableMap* varMap, const std::string& path) { +parse_command_file(CommandMap* varMap, const std::string& path) { std::fstream file(rak::path_expand(path).c_str(), std::ios::in); if (!file.is_open()) diff --git a/src/rpc/parse_commands.h b/src/rpc/parse_commands.h index 61fa1301..9a8f8ba4 100644 --- a/src/rpc/parse_commands.h +++ b/src/rpc/parse_commands.h @@ -45,25 +45,25 @@ namespace core { namespace utils { -class VariableMap; +class CommandMap; const char* parse_command_name(const char* first, const char* last, std::string* dest); -const char* parse_command_single(VariableMap* varMap, const char* first); -const char* parse_command_single(VariableMap* varMap, const char* first, const char* last); +const char* parse_command_single(CommandMap* varMap, const char* first); +const char* parse_command_single(CommandMap* varMap, const char* first, const char* last); -const char* parse_command_d_single(VariableMap* varMap, core::Download* download, const char* first, const char* last); +const char* parse_command_d_single(CommandMap* varMap, core::Download* download, const char* first, const char* last); -void parse_command_multiple(VariableMap* varMap, const char* first); -bool parse_command_file(VariableMap* varMap, const std::string& path); +void parse_command_multiple(CommandMap* varMap, const char* first); +bool parse_command_file(CommandMap* varMap, const std::string& path); inline void -parse_command_single_std(VariableMap* varMap, const std::string& cmd) { +parse_command_single_std(CommandMap* varMap, const std::string& cmd) { parse_command_single(varMap, cmd.c_str(), cmd.c_str() + cmd.size()); } inline void -parse_command_d_single_std(VariableMap* varMap, core::Download* download, const std::string& cmd) { +parse_command_d_single_std(CommandMap* varMap, core::Download* download, const std::string& cmd) { parse_command_d_single(varMap, download, cmd.c_str(), cmd.c_str() + cmd.size()); } diff --git a/src/ui/download_list.cc b/src/ui/download_list.cc index d366b19e..8318621e 100644 --- a/src/ui/download_list.cc +++ b/src/ui/download_list.cc @@ -56,7 +56,7 @@ #include "display/window_log.h" #include "display/window_title.h" -#include "utils/variable_map.h" +#include "rpc/command_map.h" #include "rpc/parse_commands.h" #include "control.h" diff --git a/src/ui/root.cc b/src/ui/root.cc index 1483d8f7..2b3494cc 100644 --- a/src/ui/root.cc +++ b/src/ui/root.cc @@ -49,7 +49,7 @@ #include "display/window_statusbar.h" #include "input/manager.h" #include "input/text_input.h" -#include "utils/variable_map.h" +#include "rpc/command_map.h" #include "control.h" #include "download_list.h" diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am index 0e111859..f0704f6d 100644 --- a/src/utils/Makefile.am +++ b/src/utils/Makefile.am @@ -7,8 +7,6 @@ libsub_utils_a_SOURCES = \ lockfile.cc \ lockfile.h \ socket_fd.cc \ - socket_fd.h \ - variable_map.cc \ - variable_map.h + socket_fd.h INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)