* Working on new infrastructure for parseing commands. It now passes a

list instead of a string when calling a multi-parameter command, which
handles escaped spaces, commas and quotes correctly.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@877 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2007-03-25 18:03:07 +00:00
parent 0ab5bae22e
commit ee6eae6c84
10 changed files with 506 additions and 248 deletions
+11 -11
View File
@@ -116,21 +116,21 @@ CommandScheduler::call_item(value_type item) {
}
void
CommandScheduler::parse(const std::string& arg) {
char key[21];
char bufAbsolute[21];
char bufInterval[21];
char command[2048];
CommandScheduler::parse(const std::string& key, const std::string& bufAbsolute, const std::string& bufInterval, const std::string& command) {
// char key[21];
// char bufAbsolute[21];
// char bufInterval[21];
// char command[2048];
if (std::sscanf(arg.c_str(), "%20[^,],%20[^,],%20[^,],%2047[^\n]", key, bufAbsolute, bufInterval, command) != 4)
throw torrent::input_error("Invalid arguments to command.");
// if (std::sscanf(arg.c_str(), "%20[^,],%20[^,],%20[^,],%2047[^\n]", key, bufAbsolute, bufInterval, command) != 4)
// throw torrent::input_error("Invalid arguments to command.");
uint32_t absolute = parse_absolute(bufAbsolute);
uint32_t interval = parse_interval(bufInterval);
uint32_t absolute = parse_absolute(bufAbsolute.c_str());
uint32_t interval = parse_interval(bufInterval.c_str());
CommandSchedulerItem* item = *insert(rak::trim(std::string(key)));
CommandSchedulerItem* item = *insert(key);
item->set_command(rak::trim(std::string(command)));
item->set_command(command);
item->set_interval(interval);
item->enable((cachedTime + rak::timer::from_seconds(absolute)).round_seconds());