* Proper fault handling for bad SCGI requests.

* Cleaned up duplicate code in 'xmlrpc.cc'.

* Cleaned up 'parse_commands.h'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@966 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2007-08-27 23:00:48 +00:00
parent 02b790c0bf
commit 32b74ffc48
19 changed files with 161 additions and 191 deletions
+17
View File
@@ -144,4 +144,21 @@ CommandMap::call_command(key_type key, const mapped_type& arg, target_type targe
}
}
const CommandMap::mapped_type
CommandMap::call_command(const_iterator itr, const mapped_type& arg, target_type target) {
if ((itr->second.m_target != target.first && itr->second.m_target != target_generic) ||
(itr->second.m_target != target_generic && target.second == NULL))
throw torrent::input_error("Command type mis-match.");
// This _should_ be optimized int just two calls.
switch (itr->second.m_target) {
case target_generic: return itr->second.m_genericSlot(itr->second.m_variable, arg);
case target_download: return itr->second.m_downloadSlot(itr->second.m_variable, (core::Download*)target.second, arg);
case target_file: return itr->second.m_fileSlot(itr->second.m_variable, (torrent::File*)target.second, arg);
case target_peer: return itr->second.m_peerSlot(itr->second.m_variable, (torrent::Peer*)target.second, arg);
case target_tracker: return itr->second.m_trackerSlot(itr->second.m_variable, (torrent::Tracker*)target.second, arg);
default: throw torrent::internal_error("CommandMap::call_command(...) Invalid target.");
}
}
}