mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-16 06:06:16 +00:00
Apply clang-format
This commit is contained in:
+26
-55
@@ -1,39 +1,3 @@
|
|||||||
// rTorrent - BitTorrent client
|
|
||||||
// Copyright (C) 2005-2011, Jari Sundell
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation; either version 2 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
//
|
|
||||||
// In addition, as a special exception, the copyright holders give
|
|
||||||
// permission to link the code of portions of this program with the
|
|
||||||
// OpenSSL library under certain conditions as described in each
|
|
||||||
// individual source file, and distribute linked combinations
|
|
||||||
// including the two.
|
|
||||||
//
|
|
||||||
// You must obey the GNU General Public License in all respects for
|
|
||||||
// all of the code used other than OpenSSL. If you modify file(s)
|
|
||||||
// with this exception, you may extend this exception to your version
|
|
||||||
// of the file(s), but you are not obligated to do so. If you do not
|
|
||||||
// wish to do so, delete this exception statement from your version.
|
|
||||||
// If you delete this exception statement from all source files in the
|
|
||||||
// program, then also delete it here.
|
|
||||||
//
|
|
||||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
|
||||||
//
|
|
||||||
// Skomakerveien 33
|
|
||||||
// 3185 Skoppum, NORWAY
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef HAVE_XMLRPC_TINYXML2
|
#ifdef HAVE_XMLRPC_TINYXML2
|
||||||
@@ -42,19 +6,19 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <string>
|
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <rak/string_manip.h>
|
#include <rak/string_manip.h>
|
||||||
#include <torrent/object.h>
|
|
||||||
#include <torrent/exceptions.h>
|
#include <torrent/exceptions.h>
|
||||||
|
#include <torrent/object.h>
|
||||||
|
|
||||||
|
#include "parse_commands.h"
|
||||||
#include "rpc/tinyxml2/tinyxml2.h"
|
#include "rpc/tinyxml2/tinyxml2.h"
|
||||||
#include "utils/base64.h"
|
#include "utils/base64.h"
|
||||||
#include "xmlrpc.h"
|
#include "xmlrpc.h"
|
||||||
#include "parse_commands.h"
|
|
||||||
|
|
||||||
namespace rpc {
|
namespace rpc {
|
||||||
|
|
||||||
@@ -73,7 +37,8 @@ const int XMLRPC_INVALID_UTF8_ERROR = -510;
|
|||||||
|
|
||||||
class xmlrpc_error : public torrent::base_error {
|
class xmlrpc_error : public torrent::base_error {
|
||||||
public:
|
public:
|
||||||
xmlrpc_error(int type, std::string msg) : m_type(type), m_msg(msg) {}
|
xmlrpc_error(int type, std::string msg) :
|
||||||
|
m_type(type), m_msg(msg) {}
|
||||||
virtual ~xmlrpc_error() throw() {}
|
virtual ~xmlrpc_error() throw() {}
|
||||||
|
|
||||||
virtual int type() const throw() { return m_type; }
|
virtual int type() const throw() { return m_type; }
|
||||||
@@ -235,8 +200,8 @@ print_object_xml(const torrent::Object& obj, tinyxml2::XMLPrinter* printer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
torrent::Object
|
||||||
torrent::Object execute_command(std::string method_name, const tinyxml2::XMLElement* params_element) {
|
execute_command(std::string method_name, const tinyxml2::XMLElement* params_element) {
|
||||||
CommandMap::iterator cmd_itr = commands.find(method_name.c_str());
|
CommandMap::iterator cmd_itr = commands.find(method_name.c_str());
|
||||||
if (cmd_itr == commands.end() || !(cmd_itr->second.m_flags & CommandMap::flag_public_xmlrpc)) {
|
if (cmd_itr == commands.end() || !(cmd_itr->second.m_flags & CommandMap::flag_public_xmlrpc)) {
|
||||||
throw xmlrpc_error(XMLRPC_NO_SUCH_METHOD_ERROR, "method '" + method_name + "' not defined");
|
throw xmlrpc_error(XMLRPC_NO_SUCH_METHOD_ERROR, "method '" + method_name + "' not defined");
|
||||||
@@ -338,7 +303,6 @@ process_document(const tinyxml2::XMLDocument* doc, tinyxml2::XMLPrinter* printer
|
|||||||
printer->CloseElement(true);
|
printer->CloseElement(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
print_xmlrpc_fault(int faultCode, std::string faultString, tinyxml2::XMLPrinter* printer) {
|
print_xmlrpc_fault(int faultCode, std::string faultString, tinyxml2::XMLPrinter* printer) {
|
||||||
printer->PushHeader(false, true);
|
printer->PushHeader(false, true);
|
||||||
@@ -379,7 +343,7 @@ XmlRpc::process(const char* inBuffer, uint32_t length, slot_write slotWrite) {
|
|||||||
if (length > m_sizeLimit) {
|
if (length > m_sizeLimit) {
|
||||||
tinyxml2::XMLPrinter printer(nullptr, true, 0);
|
tinyxml2::XMLPrinter printer(nullptr, true, 0);
|
||||||
print_xmlrpc_fault(XMLRPC_LIMIT_EXCEEDED_ERROR, "Content size exceeds maximum XML-RPC limit", &printer);
|
print_xmlrpc_fault(XMLRPC_LIMIT_EXCEEDED_ERROR, "Content size exceeds maximum XML-RPC limit", &printer);
|
||||||
return slotWrite(printer.CStr(), printer.CStrSize()-1);
|
return slotWrite(printer.CStr(), printer.CStrSize() - 1);
|
||||||
}
|
}
|
||||||
tinyxml2::XMLDocument doc;
|
tinyxml2::XMLDocument doc;
|
||||||
doc.Parse(inBuffer, length);
|
doc.Parse(inBuffer, length);
|
||||||
@@ -389,29 +353,36 @@ XmlRpc::process(const char* inBuffer, uint32_t length, slot_write slotWrite) {
|
|||||||
// remains.
|
// remains.
|
||||||
tinyxml2::XMLPrinter printer(nullptr, true, 0);
|
tinyxml2::XMLPrinter printer(nullptr, true, 0);
|
||||||
process_document(&doc, &printer);
|
process_document(&doc, &printer);
|
||||||
return slotWrite(printer.CStr(), printer.CStrSize()-1);
|
return slotWrite(printer.CStr(), printer.CStrSize() - 1);
|
||||||
} catch (xmlrpc_error& e) {
|
} catch (xmlrpc_error& e) {
|
||||||
tinyxml2::XMLPrinter printer(nullptr, true, 0);
|
tinyxml2::XMLPrinter printer(nullptr, true, 0);
|
||||||
print_xmlrpc_fault(e.type(), e.what(), &printer);
|
print_xmlrpc_fault(e.type(), e.what(), &printer);
|
||||||
return slotWrite(printer.CStr(), printer.CStrSize()-1);
|
return slotWrite(printer.CStr(), printer.CStrSize() - 1);
|
||||||
} catch (torrent::local_error& e) {
|
} catch (torrent::local_error& e) {
|
||||||
tinyxml2::XMLPrinter printer(nullptr, true, 0);
|
tinyxml2::XMLPrinter printer(nullptr, true, 0);
|
||||||
print_xmlrpc_fault(XMLRPC_INTERNAL_ERROR, e.what(), &printer);
|
print_xmlrpc_fault(XMLRPC_INTERNAL_ERROR, e.what(), &printer);
|
||||||
return slotWrite(printer.CStr(), printer.CStrSize()-1);
|
return slotWrite(printer.CStr(), printer.CStrSize() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpc::initialize() { m_isValid = true; }
|
void
|
||||||
void XmlRpc::cleanup() {}
|
XmlRpc::initialize() { m_isValid = true; }
|
||||||
|
void
|
||||||
|
XmlRpc::cleanup() {}
|
||||||
|
|
||||||
void XmlRpc::insert_command(const char*, const char*, const char*) {}
|
void
|
||||||
void XmlRpc::set_dialect(int) {}
|
XmlRpc::insert_command(const char*, const char*, const char*) {}
|
||||||
|
void
|
||||||
|
XmlRpc::set_dialect(int) {}
|
||||||
|
|
||||||
int64_t XmlRpc::size_limit() { return static_cast<int64_t>(m_sizeLimit); }
|
int64_t
|
||||||
void XmlRpc::set_size_limit(uint64_t size) { m_sizeLimit = size; }
|
XmlRpc::size_limit() { return static_cast<int64_t>(m_sizeLimit); }
|
||||||
|
void
|
||||||
|
XmlRpc::set_size_limit(uint64_t size) { m_sizeLimit = size; }
|
||||||
|
|
||||||
bool XmlRpc::is_valid() const { return m_isValid; }
|
bool
|
||||||
|
XmlRpc::is_valid() const { return m_isValid; }
|
||||||
|
|
||||||
}
|
} // namespace rpc
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user