diff --git a/Makefile.am b/Makefile.am index 2dfbb58c..5d3d5379 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,6 +5,7 @@ SUBDIRS = \ EXTRA_DIST= \ autogen.sh \ rak/algorithm.h \ + rak/error_number.h \ rak/functional.h \ scripts/checks.m4 \ scripts/common.m4 diff --git a/configure.ac b/configure.ac index e72c22df..1c7fb75a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT(rtorrent, 0.3.3, jaris@ifi.uio.no) +AC_INIT(rtorrent, 0.3.4, jaris@ifi.uio.no) AM_INIT_AUTOMAKE AM_CONFIG_HEADER(config.h) @@ -22,7 +22,7 @@ TORRENT_OTFD() TORRENT_WITHOUT_VARIABLE_FDSET() -PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.7.3, +PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.7.4, CXXFLAGS="$CXXFLAGS $STUFF_CFLAGS $CURL_CFLAGS"; LIBS="$LIBS $STUFF_LIBS $CURL_LIBS") diff --git a/rak/algorithm.h b/rak/algorithm.h index 8148451c..341e2904 100644 --- a/rak/algorithm.h +++ b/rak/algorithm.h @@ -1,4 +1,4 @@ -// rTorrent - BitTorrent client +// rak - Rakshasa's toolbox // Copyright (C) 2005, Jari Sundell // // This program is free software; you can redistribute it and/or modify @@ -34,8 +34,8 @@ // Skomakerveien 33 // 3185 Skoppum, NORWAY -#ifndef RTORRENT_UTILS_ALGORITHM_H -#define RTORRENT_UTILS_ALGORITHM_H +#ifndef RAK_ALGORITHM_H +#define RAK_ALGORITHM_H #include diff --git a/rak/error_number.h b/rak/error_number.h new file mode 100644 index 00000000..7f2a4706 --- /dev/null +++ b/rak/error_number.h @@ -0,0 +1,66 @@ +// 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 +// +// Skomakerveien 33 +// 3185 Skoppum, NORWAY + +#ifndef RAK_ERROR_NUMBER_H +#define RAK_ERROR_NUMBER_H + +#include +#include + +namespace rak { + +class error_number { +public: + error_number() : m_errno(0) {} + error_number(int e) : m_errno(e) {} + + int value() const { return m_errno; } + const char* c_str() const { return strerror(m_errno); } + + bool is_blocked_momentary() const { return m_errno == EAGAIN || m_errno == EINTR; } + bool is_blocked_prolonged() const { return m_errno == EDEADLK; } + + bool is_closed() const { return m_errno == ECONNRESET || m_errno == ECONNABORTED; } + + static error_number current() { return errno; } + +private: + int m_errno; +}; + +} + +#endif diff --git a/rak/functional.h b/rak/functional.h index 8066555f..19acbb23 100644 --- a/rak/functional.h +++ b/rak/functional.h @@ -1,4 +1,4 @@ -// rTorrent - BitTorrent client +// rak - Rakshasa's toolbox // Copyright (C) 2005, Jari Sundell // // This program is free software; you can redistribute it and/or modify @@ -34,8 +34,8 @@ // Skomakerveien 33 // 3185 Skoppum, NORWAY -#ifndef RTORRENT_UTILS_FUNCTIONAL_H -#define RTORRENT_UTILS_FUNCTIONAL_H +#ifndef RAK_FUNCTIONAL_H +#define RAK_FUNCTIONAL_H #include @@ -52,8 +52,8 @@ struct reference_fix { }; template -struct _accumulate { - _accumulate(Type& t, Ftor f) : m_t(t), m_f(f) {} +struct accumulate_t { + accumulate_t(Type& t, Ftor f) : m_t(t), m_f(f) {} template void operator () (Arg& a) { m_t += m_f(a); } @@ -63,18 +63,18 @@ struct _accumulate { }; template -inline _accumulate +inline accumulate_t accumulate(Type& t, Ftor f) { - return _accumulate(t, f); + return accumulate_t(t, f); } // Operators: template -struct _equal { +struct equal_t { typedef bool result_type; - _equal(Type t, Ftor f) : m_t(t), m_f(f) {} + equal_t(Type t, Ftor f) : m_t(t), m_f(f) {} template bool operator () (Arg& a) { @@ -86,16 +86,16 @@ struct _equal { }; template -inline _equal +inline equal_t equal(Type t, Ftor f) { - return _equal(t, f); + return equal_t(t, f); } template -struct _less { +struct less_t { typedef bool result_type; - _less(Type t, Ftor f) : m_t(t), m_f(f) {} + less_t(Type t, Ftor f) : m_t(t), m_f(f) {} template bool operator () (Arg& a) { @@ -107,9 +107,9 @@ struct _less { }; template -inline _less +inline less_t less(Type t, Ftor f) { - return _less(t, f); + return less_t(t, f); } template @@ -134,10 +134,10 @@ greater(Type t, Ftor f) { } template -struct _less_equal { +struct less_equal_t { typedef bool result_type; - _less_equal(Type t, Ftor f) : m_t(t), m_f(f) {} + less_equal_t(Type t, Ftor f) : m_t(t), m_f(f) {} template bool operator () (Arg& a) { @@ -149,16 +149,16 @@ struct _less_equal { }; template -inline _less_equal +inline less_equal_t less_equal(Type t, Ftor f) { - return _less_equal(t, f); + return less_equal_t(t, f); } template -struct _greater_equal { +struct greater_equal_t { typedef bool result_type; - _greater_equal(Type t, Ftor f) : m_t(t), m_f(f) {} + greater_equal_t(Type t, Ftor f) : m_t(t), m_f(f) {} template bool operator () (Arg& a) { @@ -170,16 +170,16 @@ struct _greater_equal { }; template -inline _greater_equal +inline greater_equal_t greater_equal(Type t, Ftor f) { - return _greater_equal(t, f); + return greater_equal_t(t, f); } template -struct _on : public std::unary_function { +struct on_t : public std::unary_function { typedef typename Dest::result_type result_type; - _on(Src s, Dest d) : m_dest(d), m_src(s) {} + on_t(Src s, Dest d) : m_dest(d), m_src(s) {} result_type operator () (typename reference_fix::type arg) { return m_dest(m_src(arg)); @@ -190,15 +190,15 @@ struct _on : public std::unary_function -inline _on +inline on_t on(Src s, Dest d) { - return _on(s, d); + return on_t(s, d); } // Creates a functor for accessing a member. template -struct _mem_ptr_ref : public std::unary_function { - _mem_ptr_ref(Member Class::*m) : m_member(m) {} +struct mem_ptr_ref_t : public std::unary_function { + mem_ptr_ref_t(Member Class::*m) : m_member(m) {} Member& operator () (Class& c) { return c.*m_member; @@ -208,14 +208,14 @@ struct _mem_ptr_ref : public std::unary_function { }; template -inline _mem_ptr_ref +inline mem_ptr_ref_t mem_ptr_ref(Member Class::*m) { - return _mem_ptr_ref(m); + return mem_ptr_ref_t(m); } template -struct _if_then { - _if_then(Cond c, Then t) : m_cond(c), m_then(t) {} +struct if_then_t { + if_then_t(Cond c, Then t) : m_cond(c), m_then(t) {} template void operator () (Arg& a) { @@ -228,9 +228,9 @@ struct _if_then { }; template -inline _if_then +inline if_then_t if_then(Cond c, Then t) { - return _if_then(c, t); + return if_then_t(c, t); } template diff --git a/src/option_file.cc b/src/option_file.cc index bd711258..57966740 100644 --- a/src/option_file.cc +++ b/src/option_file.cc @@ -66,8 +66,8 @@ OptionFile::parse_line(const char* line) { opt[0] = '\0'; // Check for empty lines, and options within "abc". - if ((result = std::sscanf(line, "%64s = \"%512[^\"]s", key, opt)) != 2 && - (result = std::sscanf(line, "%64s = %512s", key, opt)) != 2 && + if ((result = std::sscanf(line, "%63s = \"%511[^\"]s", key, opt)) != 2 && + (result = std::sscanf(line, "%63s = %511s", key, opt)) != 2 && result == 1) throw std::runtime_error("Error parseing option file.");