* Fixed the log redraw which didn't happen as the display's scheduler

didn't get re-added to the task scheduler until a new event happened.

* Added redraw delay interval of 100ms, consider 50ms.

* Removed exceptions from core::DownloadStore::save.

* Added load, load_run, tied_stop and tied_remove to man-page.

* Cleaned up the command/option instances, move them to Control.

* PCB::load_up_chunk grabbed the errno from m_downChunk, not m_upChunk.

* Various string operations were moved to rak/string_manip.h.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@617 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-01-06 21:14:49 +00:00
parent 4431fd1652
commit f32c15878a
33 changed files with 471 additions and 482 deletions
+1
View File
@@ -6,6 +6,7 @@ EXTRA_DIST= \
autogen.sh \
rak/algorithm.h \
rak/error_number.h \
rak/file_stat.h \
rak/functional.h \
rak/functional_fun.h \
rak/priority_queue.h \
+26
View File
@@ -436,6 +436,32 @@ seconds, starting from <emphasis>start</emphasis>. An
</para></listitem>
</varlistentry>
<varlistentry>
<term>load = <replaceable>file</replaceable></term>
<term>load_start = <replaceable>file</replaceable></term>
<listitem><para>
Load and possibly start a file, or possibly mutiple files by using the
wildcard "*". This is meant for use with
<emphasis>schedule</emphasis>, though ensure that the
<emphasis>start</emphasis> is non-zero. The loaded file will be tied
to the filename provided.
</para></listitem>
</varlistentry>
<varlistentry>
<term>stop_untied =</term>
<term>remove_untied =</term>
<listitem><para>
Stop or remove the torrents that are tied to filenames that has been
deleted, the association is then cleared. Don't use
<emphasis>remove_untied</emphasis> as it crashes the client.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
+8 -8
View File
@@ -2,23 +2,18 @@
# ~/.rtorrent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.
# Minumum amount of peers to connect per torrent, if available.
# Maximum and minimum number of peers to connect to per torrent.
#min_peers = 40
# Minumum amount of peers to connect per torrent.
#max_peers = 100
# Maximum number of simultanious uploads per torrent.
#max_uploads = 15
# Global download rate in KiB. "0" for unlimited.
# Global upload and download rate in KiB. "0" for unlimited.
#download_rate = 0
# Global upload rate in KiB. "0" for unlimited.
#upload_rate = 0
# Default directory to save downloaded files. Note it doesn't support
# space yet.
# Default directory to save the downloaded torrents.
#directory = ./
# Default session directory. Make sure you don't run multiple instance
@@ -26,6 +21,11 @@
# relative path?
#session = ./session
# Watch a directory for new torrents, and stop those that have been
# deleted.
#schedule = watch_directory,5,5,load_start=./watch/*.torrent
#schedule = untied_directory,5,5,stop_untied=
# The ip address reported to the tracker.
#ip = rakshasa
+148
View File
@@ -0,0 +1,148 @@
// rak - Rakshasa's toolbox
// Copyright (C) 2005, 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
#ifndef RAK_FILE_STAT_H
#define RAK_FILE_STAT_H
#include <string>
#include <inttypes.h>
#include <sys/stat.h>
namespace rak {
class file_stat {
public:
// Consider storing rak::error_number.
bool update(int fd) { return fstat(fd, &m_stat) == 0; }
bool update(const char* filename) { return stat(filename, &m_stat) == 0; }
bool update(const std::string& filename) { return update(filename.c_str()); }
bool is_regular() const { return S_ISREG(m_stat.st_mode); }
bool is_directory() const { return S_ISDIR(m_stat.st_mode); }
bool is_character() const { return S_ISCHR(m_stat.st_mode); }
bool is_block() const { return S_ISBLK(m_stat.st_mode); }
bool is_fifo() const { return S_ISFIFO(m_stat.st_mode); }
bool is_link() const { return S_ISLNK(m_stat.st_mode); }
bool is_socket() const { return S_ISSOCK(m_stat.st_mode); }
off_t size() const { return m_stat.st_size; }
time_t access_time() const { return m_stat.st_atime; }
time_t change_time() const { return m_stat.st_ctime; }
time_t modified_time() const { return m_stat.st_mtime; }
private:
struct stat m_stat;
};
}
#endif
// rak - Rakshasa's toolbox
// Copyright (C) 2005, 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
#ifndef RAK_FILE_STAT_H
#define RAK_FILE_STAT_H
#include <string>
#include <inttypes.h>
#include <sys/stat.h>
namespace rak {
class file_stat {
public:
// Consider storing rak::error_number.
bool update(int fd) { return fstat(fd, &m_stat) == 0; }
bool update(const char* filename) { return stat(filename, &m_stat) == 0; }
bool update(const std::string& filename) { return update(filename.c_str()); }
bool is_regular() const { return S_ISREG(m_stat.st_mode); }
bool is_directory() const { return S_ISDIR(m_stat.st_mode); }
bool is_character() const { return S_ISCHR(m_stat.st_mode); }
bool is_block() const { return S_ISBLK(m_stat.st_mode); }
bool is_fifo() const { return S_ISFIFO(m_stat.st_mode); }
bool is_link() const { return S_ISLNK(m_stat.st_mode); }
bool is_socket() const { return S_ISSOCK(m_stat.st_mode); }
off_t size() const { return m_stat.st_size; }
time_t access_time() const { return m_stat.st_atime; }
time_t change_time() const { return m_stat.st_ctime; }
time_t modified_time() const { return m_stat.st_mtime; }
private:
struct stat m_stat;
};
}
#endif
+79
View File
@@ -39,6 +39,9 @@
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <iterator>
#include <locale>
namespace rak {
@@ -127,6 +130,82 @@ split_iterator(const Sequence& seq) {
return split_iterator_t<Sequence>();
}
template <int pos, typename Value>
inline char
value_to_hexchar(Value v) {
v >>= pos * 4;
v &= 0xf;
if (v < 0xA)
return '0' + v;
else
return 'A' + v - 0xA;
}
template <typename InputIterator, typename OutputIterator>
OutputIterator
copy_escape_html(InputIterator first, InputIterator last, OutputIterator dest) {
while (first != last) {
if (std::isalpha(*first) ||
std::isdigit(*first) ||
*first == '-') {
*(dest++) = *first;
} else {
*(dest++) = '%';
*(dest++) = value_to_hexchar<1>(*first);
*(dest++) = value_to_hexchar<0>(*first);
}
++first;
}
return dest;
}
template <typename Sequence>
Sequence
copy_escape_html(const Sequence& src) {
Sequence dest;
copy_escape_html(src.begin(), src.end(), std::back_inserter(dest));
return dest;
}
// Consider support for larger than char type.
template <typename InputIterator, typename OutputIterator>
OutputIterator
transform_hex(InputIterator first, InputIterator last, OutputIterator dest) {
while (first != last) {
*(dest++) = value_to_hexchar<1>(*first);
*(dest++) = value_to_hexchar<0>(*first);
++first;
}
return dest;
}
template <typename Sequence>
Sequence
transform_hex(const Sequence& src) {
Sequence dest;
transform_hex(src.begin(), src.end(), std::back_inserter(dest));
return dest;
}
template <typename Sequence>
Sequence
generate_random(size_t length) {
Sequence s;
s.reserve(length);
std::generate_n(std::back_inserter(s), length, &std::rand);
return s;
}
}
#endif
+10 -2
View File
@@ -47,6 +47,7 @@
#include "ui/root.h"
#include "command_scheduler.h"
#include "option_handler.h"
#include "control.h"
@@ -59,11 +60,15 @@ Control::Control() :
m_input(new input::Manager()),
m_inputStdin(new input::InputEvent(STDIN_FILENO)),
m_commandScheduler(new CommandScheduler()) {
m_commandScheduler(new CommandScheduler()),
m_optionHandler(new OptionHandler()) {
m_inputStdin->slot_pressed(sigc::mem_fun(m_input, &input::Manager::pressed));
m_taskShutdown.set_slot(rak::mem_fn(this, &Control::receive_shutdown));
m_commandScheduler->set_slot_command(rak::mem_fn(m_optionHandler, &OptionHandler::process_command));
m_commandScheduler->set_slot_error_message(rak::mem_fn(m_core, &core::Manager::push_log));
}
Control::~Control() {
@@ -71,6 +76,7 @@ Control::~Control() {
delete m_input;
delete m_commandScheduler;
delete m_optionHandler;
delete m_ui;
delete m_display;
@@ -80,7 +86,9 @@ Control::~Control() {
void
Control::initialize() {
display::Canvas::initialize();
display::Window::slot_adjust(sigc::mem_fun(m_display, &display::Manager::adjust_layout));
display::Window::slot_schedule(rak::make_mem_fun(m_display, &display::Manager::schedule));
display::Window::slot_unschedule(rak::make_mem_fun(m_display, &display::Manager::unschedule));
display::Window::slot_adjust(rak::make_mem_fun(m_display, &display::Manager::adjust_layout));
m_core->get_poll_manager()->signal_interrupted().connect(sigc::mem_fun(*m_inputStdin, &input::InputEvent::event_read));
m_core->get_poll_manager()->signal_interrupted().connect(sigc::ptr_fun(display::Canvas::do_update));
+3
View File
@@ -58,6 +58,7 @@ namespace input {
class Manager;
}
class OptionHandler;
class CommandScheduler;
class Control {
@@ -80,6 +81,7 @@ public:
input::InputEvent* input_stdin() { return m_inputStdin; }
CommandScheduler* command_scheduler() { return m_commandScheduler; }
OptionHandler* option_handler() { return m_optionHandler; }
private:
Control(const Control&);
@@ -94,6 +96,7 @@ private:
input::InputEvent* m_inputStdin;
CommandScheduler* m_commandScheduler;
OptionHandler* m_optionHandler;
rak::priority_item m_taskShutdown;
};
+15 -9
View File
@@ -34,16 +34,18 @@
// Skomakerveien 33
// 3185 Skoppum, NORWAY
// DownloadStore handles the saving and listing of session torrents.
#include "config.h"
#include <fstream>
#include <stdexcept>
#include <stdio.h>
#include <unistd.h>
#include <rak/string_manip.h>
#include <torrent/bencode.h>
#include <torrent/exceptions.h>
#include <torrent/torrent.h>
#include "utils/parse.h"
#include "download.h"
#include "download_store.h"
@@ -62,15 +64,19 @@ DownloadStore::save(Download* d) {
if (!is_active())
return;
std::fstream f(create_filename(d).c_str(), std::ios::out | std::ios::trunc);
std::fstream f((create_filename(d) + ".new").c_str(), std::ios::out | std::ios::trunc);
if (!f.is_open())
throw std::runtime_error("core::DownloadStore::save(...) could not open file");
return;
f << d->get_bencode();
if (f.fail())
throw std::runtime_error("core::DownloadStore::save(...) could not write torrent");
return;
f.close();
::rename((create_filename(d) + ".new").c_str(), create_filename(d).c_str());
}
void
@@ -78,7 +84,7 @@ DownloadStore::remove(Download* d) {
if (!is_active())
return;
unlink(create_filename(d).c_str());
::unlink(create_filename(d).c_str());
}
utils::Directory
@@ -89,7 +95,7 @@ DownloadStore::get_formated_entries() {
utils::Directory d(m_path);
if (!d.update())
throw std::runtime_error("core::DownloadStore::update() could not open directory \"" + m_path + "\"");
throw torrent::storage_error("core::DownloadStore::update() could not open directory \"" + m_path + "\"");
d.erase(std::remove_if(d.begin(), d.end(), std::not1(std::ptr_fun(&DownloadStore::is_correct_format))), d.end());
@@ -111,7 +117,7 @@ DownloadStore::is_correct_format(std::string f) {
std::string
DownloadStore::create_filename(Download* d) {
return m_path + utils::string_to_hex(d->get_hash()) + ".torrent";
return m_path + rak::transform_hex(d->get_hash()) + ".torrent";
}
}
+2 -2
View File
@@ -180,7 +180,7 @@ Manager::erase(DListItr itr) {
void
Manager::start(Download* d, bool printLog) {
try {
d->get_bencode().get_key("rtorrent").get_key("state") = "started";
d->get_bencode().get_key("rtorrent").insert_key("state", "started");
if (d->get_download().is_active())
return;
@@ -205,7 +205,7 @@ Manager::start(Download* d, bool printLog) {
void
Manager::stop(Download* d) {
try {
d->get_bencode().get_key("rtorrent").get_key("state") = "stopped";
d->get_bencode().get_key("rtorrent").insert_key("state", "stopped");
m_downloadList.stop(d);
+54 -17
View File
@@ -47,6 +47,28 @@
namespace display {
Manager::Manager() {
m_taskUpdate.set_slot(rak::mem_fn(this, &Manager::receive_update));
}
Manager::~Manager() {
priority_queue_erase(&taskScheduler, &m_taskUpdate);
}
Manager::iterator
Manager::insert(iterator pos, Window* w) {
return Base::insert(pos, w);
}
// Swap with the function below.
Manager::iterator
Manager::erase(iterator pos) {
if (pos != end())
return erase(*pos);
else
return end();
}
Manager::iterator
Manager::erase(Window* w) {
iterator itr = std::find(begin(), end(), w);
@@ -62,6 +84,19 @@ Manager::find(Window* w) {
return std::find(begin(), end(), w);
}
void
Manager::schedule(Window* w, rak::timer t) {
rak::priority_queue_erase(&m_scheduler, w->task_update());
rak::priority_queue_insert(&m_scheduler, w->task_update(), t);
schedule_update();
}
void
Manager::unschedule(Window* w) {
rak::priority_queue_erase(&m_scheduler, w->task_update());
schedule_update();
}
void
Manager::adjust_layout() {
int staticHeight = std::for_each(begin(), end(),
@@ -95,28 +130,30 @@ Manager::adjust_layout() {
}
void
Manager::do_update() {
Manager::receive_update() {
Canvas::refresh_std();
// std::list<rak::priority_item*> workQueue;
// std::copy(rak::queue_popper(displayScheduler, rak::bind2nd(std::mem_fun(&rak::priority_item::compare), cachedTime)),
// rak::queue_popper(displayScheduler, rak::bind2nd(std::mem_fun(&rak::priority_item::compare), rak::timer())),
// std::back_inserter(workQueue));
// std::for_each(workQueue.begin(), workQueue.end(), std::mem_fun(&rak::priority_item::clear_time));
// std::for_each(workQueue.begin(), workQueue.end(), std::mem_fun(&rak::priority_item::call));
while (!displayScheduler.empty() && displayScheduler.top()->time() <= cachedTime) {
rak::priority_item* v = displayScheduler.top();
displayScheduler.pop();
v->clear_time();
v->call();
}
rak::priority_queue_perform(&m_scheduler, cachedTime);
std::for_each(begin(), end(), rak::if_then(std::mem_fun(&Window::is_active), std::mem_fun(&Window::refresh)));
Canvas::do_update();
m_timeLastUpdate = cachedTime;
schedule_update();
}
void
Manager::schedule_update() {
if (m_scheduler.empty()) {
rak::priority_queue_erase(&taskScheduler, &m_taskUpdate);
return;
}
if (!m_taskUpdate.is_queued() || m_taskUpdate.time() > m_scheduler.top()->time()) {
rak::priority_queue_erase(&taskScheduler, &m_taskUpdate);
rak::priority_queue_insert(&taskScheduler, &m_taskUpdate,
std::max(m_scheduler.top()->time(), m_timeLastUpdate + 100000));
}
}
}
+20 -6
View File
@@ -38,6 +38,7 @@
#define RTORRENT_DISPLAY_MANAGER_H
#include <list>
#include <rak/priority_queue_default.h>
namespace display {
@@ -57,19 +58,32 @@ public:
using Base::rbegin;
using Base::rend;
using Base::insert;
using Base::erase;
using Base::push_front;
using Base::push_back;
iterator erase(Window* w);
Manager();
~Manager();
iterator find(Window* w);
iterator insert(iterator pos, Window* w);
iterator erase(iterator pos);
iterator erase(Window* w);
void adjust_layout();
void do_update();
iterator find(Window* w);
void schedule(Window* w, rak::timer t);
void unschedule(Window* w);
void adjust_layout();
private:
void receive_update();
void schedule_update();
rak::timer m_timeLastUpdate;
rak::priority_queue_default m_scheduler;
rak::priority_item m_taskUpdate;
};
}
+5 -3
View File
@@ -42,7 +42,9 @@
namespace display {
Window::Slot Window::m_slotAdjust;
Window::SlotTimer Window::m_slotSchedule;
Window::SlotWindow Window::m_slotUnschedule;
Window::Slot Window::m_slotAdjust;
Window::Window(Canvas* c, bool d, int h) :
m_canvas(c),
@@ -54,7 +56,7 @@ Window::Window(Canvas* c, bool d, int h) :
}
Window::~Window() {
priority_queue_erase(&displayScheduler, &m_taskUpdate);
m_slotUnschedule(this);
delete m_canvas;
}
@@ -63,7 +65,7 @@ Window::set_active(bool a) {
if (a)
mark_dirty();
else
priority_queue_erase(&displayScheduler, &m_taskUpdate);
m_slotUnschedule(this);
m_active = a;
}
+13 -11
View File
@@ -38,7 +38,7 @@
#define RTORRENT_WINDOW_BASE_H
#include <rak/timer.h>
#include <sigc++/slot.h>
#include <rak/functional.h>
#include "canvas.h"
#include "globals.h"
@@ -46,10 +46,13 @@
namespace display {
class Canvas;
class Manager;
class Window {
public:
typedef sigc::slot0<void> Slot;
typedef rak::mem_fun0<Manager, void> Slot;
typedef rak::mem_fun1<Manager, void, Window*> SlotWindow;
typedef rak::mem_fun2<Manager, void, Window*, rak::timer> SlotTimer;
Window(Canvas* c = NULL, bool d = false, int h = 1);
@@ -59,8 +62,6 @@ public:
bool is_dynamic() { return m_dynamic; }
bool is_dirty() { return m_taskUpdate.is_queued(); }
//utils::rak::timer get_next_draw() { return m_nextDraw; }
int get_min_height() { return m_minHeight; }
bool get_active() { return m_active; }
@@ -69,16 +70,23 @@ public:
void refresh() { m_canvas->refresh(); }
void resize(int x, int y, int w, int h);
void mark_dirty();
void mark_dirty() { m_slotSchedule(this, cachedTime + 1); }
virtual void redraw() = 0;
rak::priority_item* task_update() { return &m_taskUpdate; }
// Slot for adjust and refresh.
static void slot_schedule(SlotTimer s) { m_slotSchedule = s; }
static void slot_unschedule(SlotWindow s) { m_slotUnschedule = s; }
static void slot_adjust(Slot s) { m_slotAdjust = s; }
protected:
Window(const Window&);
void operator = (const Window&);
static SlotTimer m_slotSchedule;
static SlotWindow m_slotUnschedule;
static Slot m_slotAdjust;
Canvas* m_canvas;
@@ -90,12 +98,6 @@ protected:
rak::priority_item m_taskUpdate;
};
inline void
Window::mark_dirty() {
priority_queue_erase(&displayScheduler, &m_taskUpdate);
priority_queue_insert(&displayScheduler, &m_taskUpdate, cachedTime + 1);
}
}
#endif
+1 -1
View File
@@ -60,7 +60,7 @@ WindowDownloadList::~WindowDownloadList() {
void
WindowDownloadList::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
m_canvas->erase();
+1 -1
View File
@@ -54,7 +54,7 @@ WindowDownloadStatusbar::WindowDownloadStatusbar(core::Download* d) :
void
WindowDownloadStatusbar::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
m_canvas->erase();
+1 -1
View File
@@ -54,7 +54,7 @@ WindowFileList::WindowFileList(core::Download* d, unsigned int* focus) :
void
WindowFileList::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 10 * 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 10 * 1000000).round_seconds());
m_canvas->erase();
if (m_download->get_download().size_file_entries() == 0 ||
+1 -1
View File
@@ -58,7 +58,7 @@ WindowHttpQueue::WindowHttpQueue(core::HttpQueue* q) :
void
WindowHttpQueue::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
cleanup_list();
+6 -6
View File
@@ -37,11 +37,11 @@
#include "config.h"
#include <stdexcept>
#include <rak/string_manip.h>
#include <torrent/rate.h>
#include "core/download.h"
#include "utils/parse.h"
#include "canvas.h"
#include "utils.h"
#include "window_peer_info.h"
@@ -57,14 +57,14 @@ WindowPeerInfo::WindowPeerInfo(core::Download* d, PList* l, PList::iterator* f)
void
WindowPeerInfo::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
m_canvas->erase();
int y = 0;
torrent::Download d = m_download->get_download();
m_canvas->print(0, y++, "Hash: %s", utils::string_to_hex(d.info_hash()).c_str());
m_canvas->print(0, y++, "Id: %s", utils::escape_string(d.local_id()).c_str());
m_canvas->print(0, y++, "Hash: %s", rak::transform_hex(d.info_hash()).c_str());
m_canvas->print(0, y++, "Id: %s", rak::copy_escape_html(d.local_id()).c_str());
m_canvas->print(0, y++, "Chunks: %u / %u * %u",
d.chunks_done(),
d.chunks_total(),
@@ -97,8 +97,8 @@ WindowPeerInfo::redraw() {
m_canvas->print(0, y++, "*** Peer Info ***");
m_canvas->print(0, y++, "DNS: %s:%hu", (*m_focus)->address().c_str(), (*m_focus)->port());
m_canvas->print(0, y++, "Id: %s" , utils::escape_string((*m_focus)->id()).c_str());
m_canvas->print(0, y++, "Options: %s" , utils::string_to_hex(std::string((*m_focus)->options(), 8)).c_str());
m_canvas->print(0, y++, "Id: %s" , rak::copy_escape_html((*m_focus)->id()).c_str());
m_canvas->print(0, y++, "Options: %s" , rak::transform_hex(std::string((*m_focus)->options(), 8)).c_str());
m_canvas->print(0, y++, "Snubbed: %s", (*m_focus)->is_snubbed() ? "yes" : "no");
m_canvas->print(0, y++, "Connected: %s", (*m_focus)->is_incoming() ? "remote" : "local");
+1 -1
View File
@@ -56,7 +56,7 @@ WindowPeerList::WindowPeerList(core::Download* d, PList* l, PList::iterator* f)
void
WindowPeerList::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
m_canvas->erase();
int x = 2;
+1 -1
View File
@@ -56,7 +56,7 @@ WindowStatusbar::WindowStatusbar(core::Manager* c) :
void
WindowStatusbar::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
m_canvas->erase();
+1 -1
View File
@@ -48,7 +48,7 @@ WindowTitle::WindowTitle(const std::string& s) :
void
WindowTitle::redraw() {
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 1000000).round_seconds());
m_canvas->erase();
m_canvas->print(std::max(0, (m_canvas->get_width() - (int)m_title.size()) / 2 - 4), 0,
+4 -4
View File
@@ -37,10 +37,10 @@
#include "config.h"
#include <stdexcept>
#include <rak/algorithm.h>
#include <rak/string_manip.h>
#include "core/download.h"
#include "rak/algorithm.h"
#include "utils/parse.h"
#include "window_tracker_list.h"
@@ -55,7 +55,7 @@ WindowTrackerList::WindowTrackerList(core::Download* d, unsigned int* focus) :
void
WindowTrackerList::redraw() {
// TODO: Make this depend on tracker signal.
priority_queue_insert(&displayScheduler, &m_taskUpdate, (cachedTime + 10 * 1000000).round_seconds());
m_slotSchedule(this, (cachedTime + 10 * 1000000).round_seconds());
m_canvas->erase();
int pos = 0;
@@ -87,7 +87,7 @@ WindowTrackerList::redraw() {
m_canvas->print(0, pos++, "%c Group: %2i Id: %s Focus: %s Enabled: %s Open: %s",
range.first == *m_focus ? '*' : ' ',
t.group(),
utils::escape_string(t.tracker_id()).c_str(),
rak::copy_escape_html(t.tracker_id()).c_str(),
range.first == m_download->get_download().tracker_focus() ? "yes" : " no",
t.is_enabled() ? "yes" : " no",
t.is_open() ? "yes" : " no");
-1
View File
@@ -39,5 +39,4 @@
#include "globals.h"
rak::priority_queue_default taskScheduler;
rak::priority_queue_default displayScheduler;
rak::timer cachedTime;
-1
View File
@@ -41,7 +41,6 @@
#include <rak/priority_queue_default.h>
extern rak::priority_queue_default taskScheduler;
extern rak::priority_queue_default displayScheduler;
extern rak::timer cachedTime;
#endif
+3 -3
View File
@@ -38,9 +38,9 @@
#include <functional>
#include <rak/algorithm.h>
#include <rak/file_stat.h>
#include "path_input.h"
#include "utils/file_stat.h"
namespace input {
@@ -68,9 +68,9 @@ struct _transform_filename {
_transform_filename(const std::string& base) : m_base(base) {}
void operator () (std::string& filename) {
utils::FileStat fs;
rak::file_stat fs;
if (fs.update((m_base + filename).c_str()))
if (!fs.update((m_base + filename)))
return;
else if (fs.is_directory())
+16 -58
View File
@@ -115,49 +115,6 @@ parse_options(Control* c, OptionHandler* optionHandler, int argc, char** argv) {
}
}
void
initialize_option_handler(Control* c, OptionHandler* optionHandler) {
optionHandler->insert("max_peers", new OptionHandlerInt(c, &apply_download_max_peers));
optionHandler->insert("min_peers", new OptionHandlerInt(c, &apply_download_min_peers));
optionHandler->insert("max_uploads", new OptionHandlerInt(c, &apply_download_max_uploads));
optionHandler->insert("download_rate", new OptionHandlerInt(c, &apply_global_download_rate));
optionHandler->insert("upload_rate", new OptionHandlerInt(c, &apply_global_upload_rate));
optionHandler->insert("bind", new OptionHandlerString(c, &apply_bind));
optionHandler->insert("ip", new OptionHandlerString(c, &apply_ip));
optionHandler->insert("port_range", new OptionHandlerString(c, &apply_port_range));
optionHandler->insert("port_random", new OptionHandlerString(c, &apply_port_random));
optionHandler->insert("check_hash", new OptionHandlerString(c, &apply_check_hash));
optionHandler->insert("directory", new OptionHandlerString(c, &apply_download_directory));
optionHandler->insert("hash_read_ahead", new OptionHandlerInt(c, &apply_hash_read_ahead));
optionHandler->insert("hash_interval", new OptionHandlerInt(c, &apply_hash_interval));
optionHandler->insert("hash_max_tries", new OptionHandlerInt(c, &apply_hash_max_tries));
optionHandler->insert("max_open_files", new OptionHandlerInt(c, &apply_max_open_files));
optionHandler->insert("max_open_sockets", new OptionHandlerInt(c, &apply_max_open_sockets));
optionHandler->insert("umask", new OptionHandlerOctal(c, &apply_umask));
optionHandler->insert("connection_leech", new OptionHandlerString(c, &apply_connection_leech));
optionHandler->insert("connection_seed", new OptionHandlerString(c, &apply_connection_seed));
optionHandler->insert("load", new OptionHandlerString(c, &apply_load));
optionHandler->insert("load_run", new OptionHandlerString(c, &apply_load_run));
optionHandler->insert("stop_untied", new OptionHandlerString(c, &apply_stop_untied));
optionHandler->insert("remove_untied", new OptionHandlerString(c, &apply_remove_untied));
optionHandler->insert("session", new OptionHandlerString(c, &apply_session_directory));
optionHandler->insert("encoding_list", new OptionHandlerString(c, &apply_encoding_list));
optionHandler->insert("tracker_dump", new OptionHandlerString(c, &apply_tracker_dump));
optionHandler->insert("use_udp_trackers", new OptionHandlerString(c, &apply_use_udp_trackers));
optionHandler->insert("http_proxy", new OptionHandlerString(c, &apply_http_proxy));
optionHandler->insert("schedule", new OptionHandlerString(c, &apply_schedule));
optionHandler->insert("schedule_remove", new OptionHandlerString(c, &apply_schedule_remove));
}
void
load_session_torrents(Control* c) {
// Load session torrents.
@@ -188,25 +145,28 @@ load_arg_torrents(Control* c, char** first, char** last) {
}
}
rak::timer
client_next_timeout() {
if (taskScheduler.empty())
return 60 * 1000000;
else if (taskScheduler.top()->time() <= cachedTime)
return 0;
else
return taskScheduler.top()->time() - cachedTime;
}
int
main(int argc, char** argv) {
try {
cachedTime = rak::timer::current();
OptionHandler optionHandler;
Control control;
control.command_scheduler()->set_slot_command(rak::mem_fn(&optionHandler, &OptionHandler::process_command));
control.command_scheduler()->set_slot_error_message(rak::mem_fn(control.core(), &core::Manager::push_log));
srandom(cachedTime.usec());
srand48(cachedTime.usec());
initialize_option_handler(&control, &optionHandler);
OptionFile optionFile;
optionFile.slot_option(sigc::mem_fun(optionHandler, &OptionHandler::process));
initialize_option_handler(&control);
SignalHandler::set_ignore(SIGPIPE);
SignalHandler::set_handler(SIGINT, sigc::mem_fun(control, &Control::receive_shutdown));
@@ -216,10 +176,13 @@ main(int argc, char** argv) {
control.core()->initialize_first();
OptionFile optionFile;
optionFile.slot_option(sigc::mem_fun(control.option_handler(), &OptionHandler::process));
if (getenv("HOME") && !optionFile.process_file(getenv("HOME") + std::string("/.rtorrent.rc")))
control.core()->get_log_important().push_front("Could not load \"~/.rtorrent.rc\".");
int firstArg = parse_options(&control, &optionHandler, argc, argv);
int firstArg = parse_options(&control, control.option_handler(), argc, argv);
control.initialize();
@@ -244,13 +207,8 @@ main(int argc, char** argv) {
cachedTime = rak::timer::current();
rak::priority_queue_perform(&taskScheduler, cachedTime);
// This needs to be called every second or so. Currently done by
// the throttle task in libtorrent.
if (!displayScheduler.empty() && displayScheduler.top()->time() <= cachedTime)
control.display()->do_update();
// Do shutdown check before poll, not after.
control.core()->get_poll_manager()->poll(!taskScheduler.empty() ? taskScheduler.top()->time() - cachedTime : 60 * 1000000);
control.core()->get_poll_manager()->poll(client_next_timeout());
}
control.cleanup();
+49 -6
View File
@@ -42,6 +42,7 @@
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <rak/file_stat.h>
#include <rak/functional.h>
#include <rak/string_manip.h>
#include <torrent/bencode.h>
@@ -51,7 +52,6 @@
#include "core/manager.h"
#include "ui/root.h"
#include "utils/directory.h"
#include "utils/file_stat.h"
#include "control.h"
#include "option_handler_rules.h"
@@ -228,7 +228,7 @@ apply_load(Control* m, const std::string& arg) {
}
void
apply_load_run(Control* m, const std::string& arg) {
apply_load_start(Control* m, const std::string& arg) {
m->core()->try_create_download_expand(arg, true, false, true);
}
@@ -239,9 +239,9 @@ apply_stop_untied(Control* m, const std::string& arg) {
while ((itr = std::find_if(itr, m->core()->get_download_list().end(),
rak::on(std::mem_fun(&core::Download::tied_to_file), std::not1(std::mem_fun_ref(&std::string::empty)))))
!= m->core()->get_download_list().end()) {
utils::FileStat fs;
rak::file_stat fs;
if (fs.update((*itr)->tied_to_file().c_str()) != 0) {
if (!fs.update((*itr)->tied_to_file())) {
(*itr)->set_tied_to_file(std::string());
(*itr)->get_bencode().get_key("rtorrent").erase_key("tied");
@@ -259,9 +259,9 @@ apply_remove_untied(Control* m, const std::string& arg) {
while ((itr = std::find_if(itr, m->core()->get_download_list().end(),
rak::on(std::mem_fun(&core::Download::tied_to_file), std::not1(std::mem_fun_ref(&std::string::empty)))))
!= m->core()->get_download_list().end()) {
utils::FileStat fs;
rak::file_stat fs;
if (fs.update((*itr)->tied_to_file().c_str()) != 0) {
if (!fs.update((*itr)->tied_to_file())) {
(*itr)->set_tied_to_file(std::string());
(*itr)->get_bencode().get_key("rtorrent").erase_key("tied");
@@ -306,3 +306,46 @@ void
apply_schedule_remove(Control* m, const std::string& arg) {
m->command_scheduler()->erase(m->command_scheduler()->find(rak::trim(arg)));
}
void
initialize_option_handler(Control* c) {
c->option_handler()->insert("max_peers", new OptionHandlerInt(c, &apply_download_max_peers));
c->option_handler()->insert("min_peers", new OptionHandlerInt(c, &apply_download_min_peers));
c->option_handler()->insert("max_uploads", new OptionHandlerInt(c, &apply_download_max_uploads));
c->option_handler()->insert("download_rate", new OptionHandlerInt(c, &apply_global_download_rate));
c->option_handler()->insert("upload_rate", new OptionHandlerInt(c, &apply_global_upload_rate));
c->option_handler()->insert("bind", new OptionHandlerString(c, &apply_bind));
c->option_handler()->insert("ip", new OptionHandlerString(c, &apply_ip));
c->option_handler()->insert("port_range", new OptionHandlerString(c, &apply_port_range));
c->option_handler()->insert("port_random", new OptionHandlerString(c, &apply_port_random));
c->option_handler()->insert("check_hash", new OptionHandlerString(c, &apply_check_hash));
c->option_handler()->insert("directory", new OptionHandlerString(c, &apply_download_directory));
c->option_handler()->insert("hash_read_ahead", new OptionHandlerInt(c, &apply_hash_read_ahead));
c->option_handler()->insert("hash_interval", new OptionHandlerInt(c, &apply_hash_interval));
c->option_handler()->insert("hash_max_tries", new OptionHandlerInt(c, &apply_hash_max_tries));
c->option_handler()->insert("max_open_files", new OptionHandlerInt(c, &apply_max_open_files));
c->option_handler()->insert("max_open_sockets", new OptionHandlerInt(c, &apply_max_open_sockets));
c->option_handler()->insert("umask", new OptionHandlerOctal(c, &apply_umask));
c->option_handler()->insert("connection_leech", new OptionHandlerString(c, &apply_connection_leech));
c->option_handler()->insert("connection_seed", new OptionHandlerString(c, &apply_connection_seed));
c->option_handler()->insert("load", new OptionHandlerString(c, &apply_load));
c->option_handler()->insert("load_start", new OptionHandlerString(c, &apply_load_start));
c->option_handler()->insert("stop_untied", new OptionHandlerString(c, &apply_stop_untied));
c->option_handler()->insert("remove_untied", new OptionHandlerString(c, &apply_remove_untied));
c->option_handler()->insert("session", new OptionHandlerString(c, &apply_session_directory));
c->option_handler()->insert("encoding_list", new OptionHandlerString(c, &apply_encoding_list));
c->option_handler()->insert("tracker_dump", new OptionHandlerString(c, &apply_tracker_dump));
c->option_handler()->insert("use_udp_trackers", new OptionHandlerString(c, &apply_use_udp_trackers));
c->option_handler()->insert("http_proxy", new OptionHandlerString(c, &apply_http_proxy));
c->option_handler()->insert("schedule", new OptionHandlerString(c, &apply_schedule));
c->option_handler()->insert("schedule_remove", new OptionHandlerString(c, &apply_schedule_remove));
}
+1 -42
View File
@@ -42,51 +42,10 @@
#include <sigc++/bind.h>
#include "option_handler.h"
#include "core/download_slot_map.h"
class Control;
// Not pretty, but it is simple and easy to modify.
void apply_download_min_peers(Control* m, int arg);
void apply_download_max_peers(Control* m, int arg);
void apply_download_max_uploads(Control* m, int arg);
void apply_download_directory(Control* m, const std::string& arg);
void apply_connection_leech(Control* m, const std::string& arg);
void apply_connection_seed(Control* m, const std::string& arg);
void apply_global_download_rate(Control* m, int arg);
void apply_global_upload_rate(Control* m, int arg);
void apply_umask(Control* m, int arg);
void apply_hash_read_ahead(Control* m, int arg);
void apply_hash_interval(Control* m, int arg);
void apply_hash_max_tries(Control* m, int arg);
void apply_max_open_files(Control* m, int arg);
void apply_max_open_sockets(Control* m, int arg);
void apply_ip(Control* m, const std::string& arg);
void apply_bind(Control* m, const std::string& arg);
void apply_port_range(Control* m, const std::string& arg);
void apply_port_random(Control* m, const std::string& arg);
void apply_tracker_dump(Control* m, const std::string& arg);
void apply_use_udp_trackers(Control* m, const std::string& arg);
void apply_check_hash(Control* m, const std::string& arg);
void apply_http_proxy(Control* m, const std::string& arg);
void apply_load(Control* m, const std::string& arg);
void apply_load_run(Control* m, const std::string& arg);
void apply_stop_untied(Control* m, const std::string& arg);
void apply_remove_untied(Control* m, const std::string& arg);
void apply_session_directory(Control* m, const std::string& arg);
void apply_encoding_list(Control* m, const std::string& arg);
void apply_schedule(Control* m, const std::string& arg);
void apply_schedule_remove(Control* m, const std::string& arg);
void initialize_option_handler(Control* c);
class OptionHandlerInt : public OptionHandlerBase {
public:
+1 -5
View File
@@ -3,10 +3,6 @@ noinst_LIBRARIES = libsub_utils.a
libsub_utils_a_SOURCES = \
directory.cc \
directory.h \
file_stat.cc \
file_stat.h \
list_focus.h \
parse.cc \
parse.h
list_focus.h
INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
-85
View File
@@ -1,85 +0,0 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005, 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 <errno.h>
#include <stdexcept>
#include "file_stat.h"
namespace utils {
void
FileStat::update_throws(int fd) {
int r = update(fd);
if (r < 0)
throw std::runtime_error(error_string(r));
}
void
FileStat::update_throws(const char* filename) {
int r = update(filename);
if (r < 0)
throw std::runtime_error(error_string(r));
}
std::string
FileStat::error_string(int err) {
switch (err) {
case 0:
return "Success";
case EBADF:
return "Bad file descriptor";
case ENOENT:
return "Filename does not exist";
case ENOTDIR:
return "Path not a directory";
case EACCES:
return "Permission denied";
default:
return "Unknown error";
}
}
}
-80
View File
@@ -1,80 +0,0 @@
// libTorrent - BitTorrent library
// Copyright (C) 2005, 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
#ifndef RTORRENT_UTILS_FILE_STAT_H
#define RTORRENT_UTILS_FILE_STAT_H
#include <string>
#include <inttypes.h>
#include <sys/stat.h>
namespace utils {
class FileStat {
public:
FileStat() {}
FileStat(const char* filename) { update_throws(filename); }
explicit FileStat(int fd) { update_throws(fd); }
int update(int fd) { return fstat(fd, &m_stat); }
int update(const char* filename) { return stat(filename, &m_stat); }
void update_throws(int fd);
void update_throws(const char* filename);
bool is_regular() const { return S_ISREG(m_stat.st_mode); }
bool is_directory() const { return S_ISDIR(m_stat.st_mode); }
bool is_character() const { return S_ISCHR(m_stat.st_mode); }
bool is_block() const { return S_ISBLK(m_stat.st_mode); }
bool is_fifo() const { return S_ISFIFO(m_stat.st_mode); }
bool is_link() const { return S_ISLNK(m_stat.st_mode); }
bool is_sockt() const { return S_ISSOCK(m_stat.st_mode); }
off_t get_size() const { return m_stat.st_size; }
time_t get_atime() const { return m_stat.st_atime; }
time_t get_ctime() const { return m_stat.st_ctime; }
time_t get_mtime() const { return m_stat.st_mtime; }
static std::string error_string(int err);
private:
struct stat m_stat;
};
}
#endif
-75
View File
@@ -1,75 +0,0 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005, 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 <sstream>
#include "utils/parse.h"
namespace utils {
std::string
escape_string(const std::string& src) {
std::stringstream stream;
stream << std::hex << std::uppercase;
for (std::string::const_iterator itr = src.begin(); itr != src.end(); ++itr)
if ((*itr >= 'A' && *itr <= 'Z') ||
(*itr >= 'a' && *itr <= 'z') ||
(*itr >= '0' && *itr <= '9') ||
*itr == '-')
stream << *itr;
else
stream << '%' << ((unsigned char)*itr >> 4) << ((unsigned char)*itr & 0xf);
return stream.str();
}
std::string
string_to_hex(const std::string& src) {
std::stringstream stream;
stream << std::hex << std::uppercase;
for (std::string::const_iterator itr = src.begin(); itr != src.end(); ++itr)
stream << ((unsigned char)*itr >> 4) << ((unsigned char)*itr & 0xf);
return stream.str();
}
}
-51
View File
@@ -1,51 +0,0 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005, 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
#ifndef RTORRENT_UTILS_PARSE_H
#define RTORRENT_UTILS_PARSE_H
#include <string>
namespace utils {
// Various functinos for manipulating strings.
std::string escape_string(const std::string& src);
std::string string_to_hex(const std::string& src);
}
#endif