Ticket #239: broken-rtorrent-0.8.7-ip_filter_no_boost-fast-bsd2.patch
| File broken-rtorrent-0.8.7-ip_filter_no_boost-fast-bsd2.patch, 73.3 KB (added by jcuzella, 17 months ago) |
|---|
-
configure.ac
Based on 'rtorrent-0.8.5-ip_filter_no_boost-fast.patch' by Richard Monk and 'yb' Adapted for rtorrent-0.8.6 by Denis Fateyev <denis@fateyev.com> Adapted for rtorrent-0.8.7 by James Cuzella <james.cuzella@lyraphase.com> Rev.2 (BSD/MacOSX support provided) See http://libtorrent.rakshasa.no/ticket/239 for more details.
a b 4 4 AM_CONFIG_HEADER(config.h) 5 5 AM_PATH_CPPUNIT(1.9.6) 6 6 7 AC_CHECK_FUNCS(getline) 7 8 AC_PROG_CXX 8 9 AC_PROG_LIBTOOL 9 10 -
configure.ac.orig
a b 1 AC_INIT(rtorrent, 0.8.7, jaris@ifi.uio.no) 2 3 AM_INIT_AUTOMAKE 4 AM_CONFIG_HEADER(config.h) 5 AM_PATH_CPPUNIT(1.9.6) 6 7 AC_PROG_CXX 8 AC_PROG_LIBTOOL 9 10 TORRENT_CHECK_CXXFLAGS() 11 TORRENT_ENABLE_DEBUG() 12 TORRENT_ENABLE_EXTRA_DEBUG() 13 TORRENT_ENABLE_WERROR() 14 15 TORRENT_DISABLE_IPV6 16 17 AC_SYS_LARGEFILE 18 19 TORRENT_CHECK_EXECINFO() 20 TORRENT_OTFD() 21 22 TORRENT_ENABLE_ARCH 23 TORRENT_WITH_SYSROOT 24 25 TORRENT_WITHOUT_VARIABLE_FDSET() 26 TORRENT_WITHOUT_NCURSESW() 27 TORRENT_WITHOUT_STATVFS() 28 TORRENT_WITHOUT_STATFS() 29 30 PKG_CHECK_MODULES(sigc, sigc++-2.0, 31 CXXFLAGS="$CXXFLAGS $sigc_CFLAGS"; 32 LIBS="$LIBS $sigc_LIBS") 33 34 PKG_CHECK_MODULES(libcurl, libcurl >= 7.15.4, 35 CXXFLAGS="$CXXFLAGS $libcurl_CFLAGS"; 36 LIBS="$LIBS $libcurl_LIBS") 37 38 PKG_CHECK_MODULES(libtorrent, libtorrent >= 0.12.7, 39 CXXFLAGS="$CXXFLAGS $libtorrent_CFLAGS"; 40 LIBS="$LIBS $libtorrent_LIBS") 41 42 AC_LANG_PUSH(C++) 43 TORRENT_WITH_XMLRPC_C 44 AC_LANG_POP(C++) 45 46 AC_DEFINE(HAVE_CONFIG_H, 1, true if config.h was included) 47 AC_DEFINE(USER_AGENT, [std::string(PACKAGE "/" VERSION "/") + torrent::version()], Http user agent) 48 49 AC_CHECK_FUNCS(posix_memalign) 50 TORRENT_CHECK_CACHELINE() 51 52 CC_ATTRIBUTE_UNUSED( 53 AC_DEFINE([__UNUSED], [__attribute__((unused))], [Wrapper around unused attribute]), 54 AC_DEFINE([__UNUSED], [], [Null-wrapper if unused attribute is unsupported]) 55 ) 56 57 AC_OUTPUT([ 58 Makefile 59 doc/Makefile 60 src/Makefile 61 src/core/Makefile 62 src/display/Makefile 63 src/input/Makefile 64 src/rpc/Makefile 65 src/ui/Makefile 66 src/utils/Makefile 67 test/Makefile 68 ]) -
src/command_network.cc
a b 36 36 37 37 #include "config.h" 38 38 39 #include <string> 40 #include <sstream> 41 #include <list> 42 #include <unistd.h> 43 39 44 #include <functional> 40 45 #include <cstdio> 41 46 #include <rak/address_info.h> … … 61 66 #include "control.h" 62 67 #include "command_helpers.h" 63 68 69 #include "utils/pattern.h" 70 #include "core/ip_filter.h" 71 72 64 73 torrent::Object 65 74 apply_throttle(const torrent::Object::list_type& args, bool up) { 66 75 torrent::Object::list_const_iterator argItr = args.begin(); … … 202 211 return torrent::Object(); 203 212 } 204 213 214 torrent::Object 215 apply_ip_filter(const torrent::Object& rawArgs) { 216 const torrent::Object::list_type& args = rawArgs.as_list(); 217 218 std::list<std::string> files; 219 220 for (torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; itr++) { 221 std::string file( itr->as_string() ); 222 utils::trim( file ); 223 if( access(file.c_str(),F_OK | R_OK) ) 224 throw torrent::input_error("IpFilter file '" + file + "' does not exist or not readable. Filter could not be loaded"); 225 files.push_back( file ); 226 } 227 228 std::stringstream logMsg; 229 if( files.empty() ) { 230 logMsg << "IpFilter is empty"; 231 control->core()->push_log( logMsg.str().c_str() ); 232 } 233 else { 234 core::IpFilter* f = new core::IpFilter(); 235 logMsg << "IpFilter is initialized with files: "; 236 int entries = 0; 237 clock_t time_start = clock(); 238 for( std::list<std::string>::iterator itr = files.begin(); itr != files.end(); itr++) { 239 std::cout << "Loading IP filters from '" << *itr << "'..."; 240 std::cout.flush(); 241 if( itr != files.begin() ) 242 logMsg << ", "; 243 logMsg << *itr; 244 int merges = f->add_from_file( *itr ); 245 if( merges < 0 ) { 246 std::cout << "error" << std::endl; 247 std::cout.flush(); 248 throw torrent::input_error("IpFilter could not load file '" + *itr + "'"); 249 } 250 std::cout << "done. Loaded " << (f->size()-entries) << " ranges. " << merges << " ranges were merged." << std::endl; 251 std::cout.flush(); 252 entries = f->size(); 253 } 254 control->core()->push_log( logMsg.str().c_str() ); 255 std::stringstream logMsg2("IpFilter loaded with "); 256 logMsg2 << f->size() << " ranges total. " << f->get_merges() << " ranges were merged."; 257 control->core()->push_log( logMsg2.str().c_str() ); 258 std::cout << logMsg2.str() << std::endl; 259 std::cout << "IP_Filters loaded in " << (double)(clock()-time_start)/CLOCKS_PER_SEC << " seconds" << std::endl; 260 std::cout.flush(); 261 control->core()->set_ip_filter( f ); 262 } 263 264 return torrent::Object(); 265 } 266 205 267 torrent::Object 206 268 apply_tos(const torrent::Object::string_type& arg) { 207 269 rpc::command_base::value_type value; … … 417 479 torrent::FileManager* fileManager = torrent::file_manager(); 418 480 core::CurlStack* httpStack = control->core()->http_stack(); 419 481 482 CMD2_ANY ("reload_ip_filter", rak::make_mem_fun(control->core(), &core::Manager::reload_ip_filter)); 483 CMD2_ANY_LIST ("ip_filter", rak::ptr_fn(&apply_ip_filter)); 484 485 420 486 CMD2_VAR_BOOL ("log.handshake", false); 421 487 CMD2_VAR_STRING ("log.tracker", ""); 422 488 -
src/core/getline.cc
a b 1 #include <string> 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <sys/types.h> 5 #include <sys/stat.h> 6 #include <limits.h> 7 #include <errno.h> 8 9 namespace core { 10 11 /* getline.c --- Implementation of replacement getline function. 12 Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005 Free 13 Software Foundation, Inc. 14 15 /* Ported from glibc by Simon Josefsson. */ 16 17 #ifndef SIZE_MAX 18 # define SIZE_MAX ((size_t) -1) 19 #endif 20 #ifndef SSIZE_MAX 21 # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) 22 #endif 23 #if !HAVE_FLOCKFILE 24 # undef flockfile 25 # define flockfile(x) ((void) 0) 26 #endif 27 #if !HAVE_FUNLOCKFILE 28 # undef funlockfile 29 # define funlockfile(x) ((void) 0) 30 #endif 31 32 /* Read up to (and including) a DELIMITER from FP into *LINEPTR (and 33 NUL-terminate it). *LINEPTR is a pointer returned from malloc (or 34 NULL), pointing to *N characters of space. It is realloc'ed as 35 necessary. Returns the number of characters read (not including 36 the null terminator), or -1 on error or EOF. */ 37 38 ssize_t getline (char **lineptr, size_t *n, FILE *fp) 39 { 40 ssize_t result; 41 size_t cur_len = 0; 42 43 if (lineptr == NULL || n == NULL || fp == NULL) 44 { 45 errno = EINVAL; 46 return -1; 47 } 48 49 flockfile (fp); 50 51 if (*lineptr == NULL || *n == 0) 52 { 53 *n = 120; 54 *lineptr = (char *) malloc (*n); 55 if (*lineptr == NULL) 56 { 57 result = -1; 58 goto unlock_return; 59 } 60 } 61 62 for (;;) 63 { 64 int i; 65 66 i = getc (fp); 67 if (i == EOF) 68 { 69 result = -1; 70 break; 71 } 72 73 /* Make enough space for len+1 (for final NUL) bytes. */ 74 if (cur_len + 1 >= *n) 75 { 76 size_t needed_max = 77 SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; 78 size_t needed = 2 * *n + 1; /* Be generous. */ 79 char *new_lineptr; 80 81 if (needed_max < needed) 82 needed = needed_max; 83 if (cur_len + 1 >= needed) 84 { 85 result = -1; 86 goto unlock_return; 87 } 88 89 new_lineptr = (char *) realloc (*lineptr, needed); 90 if (new_lineptr == NULL) 91 { 92 result = -1; 93 94 95 96 goto unlock_return; 97 } 98 99 *lineptr = new_lineptr; 100 *n = needed; 101 } 102 103 (*lineptr)[cur_len] = i; 104 cur_len++; 105 106 if (i == '\n') 107 break; 108 } 109 (*lineptr)[cur_len] = '\0'; 110 result = cur_len ? cur_len : result; 111 112 unlock_return: 113 funlockfile (fp); 114 return result; 115 } 116 117 } -
src/core/getline.h
a b 1 #include <string> 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <sys/types.h> 5 #include <sys/stat.h> 6 #include <limits.h> 7 #include <errno.h> 8 9 namespace core { 10 11 /* getline.c --- Implementation of replacement getline function. 12 Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005 Free 13 Software Foundation, Inc. 14 15 /* Ported from glibc by Simon Josefsson. */ 16 17 /* Read up to (and including) a DELIMITER from FP into *LINEPTR (and 18 NUL-terminate it). *LINEPTR is a pointer returned from malloc (or 19 NULL), pointing to *N characters of space. It is realloc'ed as 20 necessary. Returns the number of characters read (not including 21 the null terminator), or -1 on error or EOF. */ 22 23 ssize_t getline (char **lineptr, size_t *n, FILE *fp); 24 25 } -
src/core/ip_address.cc
a b 1 #include <cstdlib> 2 #include <string> 3 #include <arpa/inet.h> 4 5 #include "ip_address.h" 6 #include "utils/pattern.h" 7 8 namespace core { 9 10 std::pair<bool,uint32_t> IpAddress::to_int( const std::string& address ) { 11 uint32_t a; 12 int r = inet_pton( AF_INET, address.c_str(), &a); 13 if( r ) 14 a = ntohl( a ); 15 return std::pair<bool,uint32_t>( (r!=0), a ); 16 } 17 18 std::string IpAddress::to_string() const { 19 char buf[128] = ""; 20 uint32_t a = htonl( m_address ); 21 inet_ntop( AF_INET, &a, buf, sizeof(buf) ); 22 return std::string( buf ); 23 } 24 25 } -
src/core/ip_address.h
a b 1 #ifndef IPADDRESS_H 2 #define IPADDRESS_H 3 4 #include <inttypes.h> 5 #include <string> 6 7 #include "printable.h" 8 #include "utils/pattern.h" 9 #include "regex_namespace.h" 10 11 namespace core { 12 13 class IpAddress : public Printable { 14 friend class IpRange; 15 16 private: // constants 17 static const std::string PATTERN_IP_EXPRESSION; 18 static const std::string PATTERN_IP_BYTES_EXPRESSION; 19 static const regex::Pattern PATTERN_IP_BYTES; 20 21 static const int GRP_IP_FIRST_BYTE; 22 static const int GRP_IP_BYTES_COUNT; 23 24 private: // fields 25 uint32_t m_address; 26 27 private: // static methods 28 29 private: // dynamic methods 30 IpAddress() : m_address(0) {} 31 32 void copy( const IpAddress& addr ) { m_address = addr.m_address;} 33 34 public: // static methods 35 static std::pair<bool,uint32_t> to_int( const std::string& strAddress ); 36 static IpAddress* parse( const std::string& strAddress ) { 37 std::pair<bool,uint32_t> result = to_int( strAddress ); 38 return ( !result.first ) ? NULL : new IpAddress( result.second ); 39 } 40 41 public: // dynamic methods 42 IpAddress( uint32_t address ) : m_address(address) {} 43 IpAddress( const IpAddress& addr ) { copy( addr ); } 44 IpAddress& operator= ( const IpAddress& addr ) { copy( addr ); return *this; } 45 46 operator uint32_t() const { return m_address; } 47 48 bool operator>= ( const IpAddress& ip ) const { return (m_address >= ip.m_address); } 49 bool operator<= ( const IpAddress& ip ) const { return (m_address <= ip.m_address); } 50 bool operator< ( const IpAddress& ip ) const { return (m_address < ip.m_address); } 51 bool operator> ( const IpAddress& ip ) const { return (m_address > ip.m_address); } 52 bool operator== ( const IpAddress& ip ) const { return (m_address == ip.m_address); } 53 bool operator!= ( const IpAddress& ip ) const { return (m_address != ip.m_address); } 54 55 bool operator>= ( uint32_t ip ) const { return (m_address >= ip); } 56 bool operator<= ( uint32_t ip ) const { return (m_address <= ip); } 57 bool operator< ( uint32_t ip ) const { return (m_address < ip); } 58 bool operator> ( uint32_t ip ) const { return (m_address > ip); } 59 bool operator== ( uint32_t ip ) const { return (m_address == ip); } 60 bool operator!= ( uint32_t ip ) const { return (m_address != ip); } 61 62 std::string to_string() const; 63 }; 64 } 65 #endif -
src/core/ip_filter.cc
a b 1 #include <sstream> 2 #include <string> 3 #include <map> 4 #include <list> 5 #include <fstream> 6 #include <stdio.h> 7 #include <stdlib.h> 8 9 #ifdef HAVE_CONFIG_H 10 #include <config.h> 11 #endif 12 13 #ifndef __linux__ 14 #ifndef HAVE_GETLINE 15 #include "getline.h" 16 #endif 17 #endif 18 19 #include "ip_filter.h" 20 21 namespace core { 22 23 int IpFilter::merge_and_insert( range_map* rs, IpRange* r ) { 24 if( !r || !r->get_from() ) 25 return 0; 26 27 std::pair<const IpAddress,IpRange::ptr> p( *r->get_from(), IpRange::ptr(r) ); 28 std::pair<range_itr,bool> duo = rs->insert( p ); 29 30 range_itr idx = duo.first; 31 bool wasInserted = duo.second; 32 IpRange* curr = NULL; 33 int mergeCount = 0; 34 35 if( !wasInserted ) { // exactly the same start address already exists 36 curr = idx->second; 37 if( *curr->get_to() < *r->get_to() ) 38 curr->set_to( r->get_to() ); 39 delete r; 40 r = curr; 41 mergeCount++; 42 } 43 else { 44 if( idx != rs->begin() ) { 45 --idx; 46 curr = idx->second; // previous 47 if( *r->get_from() <= *curr->get_to() ) 48 r = curr; 49 else 50 ++idx; 51 } 52 } 53 54 if( idx != rs->end() ) 55 ++idx; 56 57 while( idx != rs->end() ) { 58 curr = idx->second; 59 if( *r->get_to() < *curr->get_from() ) 60 break; 61 62 std::string d = r->get_description(); 63 d += " / " + curr->get_description(); 64 r->set_description( d ); 65 if( *r->get_to() < *curr->get_to() ) 66 r->set_to( curr->get_to() ); 67 rs->erase( idx++ ); 68 delete curr; 69 mergeCount++; 70 } 71 return mergeCount; 72 } 73 74 int IpFilter::add_from_file( const std::string& fileName, range_map* rs, str_list* files ) { 75 FILE *f = fopen(fileName.c_str(),"r"); 76 int mergeCount = 0; 77 if (f==0) return -1; 78 char *line = (char *)malloc(64); 79 size_t sz=64; 80 int charsread = 0; 81 int linesread=0; 82 while( (charsread=getline(&line,&sz,f)) >=0 ) { 83 if( (line[0] == '#' ) || ( charsread <= 1 ) ) 84 continue; 85 86 IpRange* ir = IpRange::parse( line, charsread ); 87 if( !ir || !ir->get_from() || !ir->get_to() ) 88 continue; 89 90 mergeCount += merge_and_insert( rs, ir ); 91 } 92 free(line); 93 files->push_back( std::string(fileName) ); 94 fclose(f); 95 m_merges += mergeCount; 96 return mergeCount; 97 } 98 99 int IpFilter::add_from_file( const std::string& fileName ) { 100 if( !m_ranges ) 101 m_ranges = new range_map(); 102 if( !m_loadedFiles ) 103 m_loadedFiles = new std::list<std::string>(); 104 105 return add_from_file( fileName, m_ranges, m_loadedFiles ); 106 } 107 108 int IpFilter::reload() { 109 if( !m_loadedFiles || m_loadedFiles->empty() ) 110 return 0; 111 112 range_map* rs = new range_map(); 113 str_list* files = new str_list(); 114 int mergeCount = 0; 115 for( str_list::const_iterator it = m_loadedFiles->begin(), end = m_loadedFiles->end(); it != end; it++ ) 116 mergeCount += add_from_file( *it, rs, files ); 117 118 range_map* rsOld = m_ranges; 119 m_ranges = rs; 120 if( rsOld ) { 121 clear( rsOld ); 122 delete rsOld; 123 } 124 125 str_list* filesOld = m_loadedFiles; 126 m_loadedFiles = files; 127 if( filesOld ) { 128 clear( filesOld ); 129 delete filesOld; 130 } 131 132 m_merges = mergeCount; 133 return mergeCount; 134 } 135 136 IpRange* IpFilter::find_range( uint32_t ip ) const { 137 if( (ip >= 0) && m_ranges && !m_ranges->empty() ) { 138 range_itr idx = m_ranges->upper_bound( ip ); 139 if( idx != m_ranges->begin() ) 140 --idx; 141 IpRange* curr = idx->second; 142 if( curr->includes( ip ) ) 143 return curr; 144 } 145 return NULL; 146 } 147 148 std::string IpFilter::to_string() const { 149 std::stringstream result; 150 if( !m_ranges ) 151 result << "NULL" << std::endl; 152 else { 153 for( range_map::const_iterator it = m_ranges->begin() ; it != m_ranges->end(); it++ ) { 154 const IpAddress a = it->first; 155 IpRange* ir = it->second; 156 result << a << ": " << *ir << std::endl; 157 } 158 } 159 return result.str(); 160 } 161 162 void IpFilter::clear( range_map* map ) { 163 if( map ) { 164 for( range_itr i = map->begin(), j = map->end(); i != j; i++ ) 165 delete i->second; 166 map->clear(); 167 } 168 } 169 170 void IpFilter::clear( str_list* list ) { 171 if( list ) 172 list->clear(); 173 } 174 175 } -
src/core/ip_filter.h
a b 1 #ifndef IPFILTER_H 2 #define IPFILTER_H 3 4 #include <string> 5 #include <map> 6 #include <list> 7 8 #include "printable.h" 9 #include "ip_address.h" 10 #include "ip_range.h" 11 12 namespace core { 13 14 typedef std::map<const IpAddress,IpRange::ptr> range_map; 15 typedef range_map::iterator range_itr; 16 typedef std::list<std::string> str_list; 17 18 class IpFilter : public Printable { 19 private: // fields 20 int m_merges; 21 range_map* m_ranges; 22 str_list* m_loadedFiles; 23 24 private: // static methods 25 static void clear( range_map* map ); 26 static void clear( str_list* list ); 27 28 private: // dynamic methods 29 void init_members(void) { // to avoid long constructor lines for every ctor 30 m_ranges = NULL; 31 m_loadedFiles = NULL; 32 m_merges = 0; 33 } 34 int merge_and_insert( range_map* rs, IpRange* r ); 35 int add_from_file( const std::string& fileName, range_map* rs, str_list* files ); 36 37 public: // static methods 38 39 public: // dynamic methods 40 IpFilter() { init_members(); } 41 ~IpFilter() { 42 clear(); 43 if( m_ranges ) delete m_ranges; 44 if( m_loadedFiles ) delete m_loadedFiles; 45 m_ranges = NULL; 46 m_loadedFiles = NULL; 47 } 48 IpFilter( std::string* files, int size ) { 49 init_members(); 50 for( int i = 0; i < size; i++, files++ ) 51 add_from_file( *files ); 52 } 53 IpFilter( str_list& files ) { 54 init_members(); 55 for( str_list::const_iterator i = files.begin(), last = files.end(); i != last; i++ ) 56 add_from_file( *i ); 57 } 58 IpFilter( IpFilter& f ) { 59 init_members(); 60 m_ranges = new range_map( *f.m_ranges ); 61 m_loadedFiles = new str_list( *f.m_loadedFiles ); 62 } 63 64 int reload(); 65 int add_from_file( const std::string& fileName ); 66 int add_from_file( char* fileName ) { std::string s( fileName ); return add_from_file(s); } 67 void clear() { clear( m_ranges ); clear( m_loadedFiles ); } 68 69 IpRange* find_range( uint32_t ip ) const; 70 71 bool is_filtered( uint32_t ip ) const { return (find_range( ip ) != NULL); } 72 bool is_filtered( std::string ip ) const { 73 static std::pair<bool,uint32_t> ipInt = IpAddress::to_int( ip ); 74 return (!ipInt.first ? false : is_filtered( ipInt.second )); 75 } 76 77 std::string to_string() const; 78 79 int size(void) { return ( m_ranges ? m_ranges->size() : 0 ); } 80 int get_merges(void) { return m_merges; } 81 void set_files( str_list& files) { m_loadedFiles = new str_list( files ); } 82 }; 83 84 } 85 #endif -
src/core/ip_filter_statics.cc
a b 1 #include "ip_address.h" 2 #include "ip_range.h" 3 #include "utils/pattern.h" 4 5 namespace core { 6 7 const std::string IpAddress::PATTERN_IP_EXPRESSION = "(([0-9]{1,3}\\.){3}[0-9]{1,3})"; 8 const std::string IpAddress::PATTERN_IP_BYTES_EXPRESSION = "([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})"; 9 const regex::Pattern IpAddress::PATTERN_IP_BYTES = PATTERN_IP_BYTES_EXPRESSION; 10 11 const int IpAddress::GRP_IP_FIRST_BYTE = 1; 12 const int IpAddress::GRP_IP_BYTES_COUNT = 4; 13 14 const std::string IpRange::PATTERN_RANGE_EXPRESSION = "[[:space:]]*(.*)[[:space:]]*:[[:space:]]*" + IpAddress::PATTERN_IP_EXPRESSION + "[[:space:]]*-[[:space:]]*" + IpAddress::PATTERN_IP_EXPRESSION + "[[:space:]]*"; 15 const regex::Pattern IpRange::PATTERN_RANGE = PATTERN_RANGE_EXPRESSION; 16 17 const int IpRange::GRP_DESCRIPTION = 1; 18 const int IpRange::GRP_FIRST_IP = 2; 19 const int IpRange::GRP_SECOND_IP = 4; 20 21 } -
src/core/ip_range.cc
a b 1 #include <sstream> 2 #include <string> 3 4 #include "ip_range.h" 5 #include "utils/pattern.h" 6 #include "regex_namespace.h" 7 8 namespace core { 9 10 IpRange* IpRange::parse( const std::string& s ) { 11 regex::Match m = PATTERN_RANGE.match( s ); 12 13 if( !m.matches() ) { 14 std::cout << "!! range format is invalid: '" << s << "'" << std::endl; 15 return NULL; 16 } 17 18 std::string description = m.group( GRP_DESCRIPTION ); 19 std::string ip1 = m.group( GRP_FIRST_IP ); 20 std::string ip2 = m.group( GRP_SECOND_IP ); 21 IpAddress* from = IpAddress::parse( ip1 ); 22 IpAddress* to = IpAddress::parse( ip2 ); 23 24 if( !from ) { 25 std::cout << "!! from is invalid: description='" << description << ", ip1=" << ip1 << ", ip2=" << ip2 << std::endl; 26 return NULL; 27 } 28 if( !to ) { 29 std::cout << "!! to is invalid: description='" << description << ", ip1=" << ip1 << ", ip2=" << ip2 << std::endl; 30 return NULL; 31 } 32 33 // if( !from || !to || (*to < *from) ) 34 // return NULL; 35 36 IpRange* r = new IpRange(); 37 38 r->m_description = description; 39 r->m_from = from; 40 r->m_to = to; 41 42 if( to && from && (*to < *from) ) { 43 std::cout << "!! to < from: " << r->to_string() << std::endl; 44 delete r; 45 return NULL; 46 } 47 48 return r; 49 } 50 51 //fast version 52 IpRange* IpRange::parse( const char *s, const int size ){ 53 static char description[256]; 54 static char ip1[24], ip2[24]; 55 int pos=0, post=0, enddesc=size-1; 56 while (enddesc>0 && s[enddesc]!=':') enddesc--; //find last ':' in the line 57 while((pos<enddesc) && (unsigned char)s[pos]<=' ') pos++; // strip from start 58 while ((pos<enddesc)){ 59 if (post<255) description[post++]=s[pos]; 60 pos++; 61 } 62 description[post]=0; 63 if (s[pos]==':') pos++; 64 post=0; 65 while ((pos<size) && s[pos]!='-'){ 66 if (post<23) ip1[post++]=s[pos]; 67 pos++; 68 } 69 ip1[post]=0; 70 if (s[pos]=='-'){ 71 pos++; 72 post=0; 73 while ((pos<size) && s[pos]>' '){ 74 if (post<23) ip2[post++]=s[pos]; 75 pos++; 76 } 77 ip2[post]=0; 78 } else ip2[0]=0; 79 80 IpAddress* from = IpAddress::parse(ip1); 81 IpAddress* to = IpAddress::parse(ip2); 82 83 if( !from ) { 84 std::cout << "!! from is invalid: description='" << description << ", ip1=" << ip1 << ", ip2=" << ip2 << std::endl; 85 return NULL; 86 } 87 if( !to ) { 88 std::cout << "!! to is invalid: description='" << description << ", ip1=" << ip1 << ", ip2=" << ip2 << std::endl; 89 return NULL; 90 } 91 92 IpRange* r = new IpRange(); 93 r->m_description = description; 94 r->m_from = from; 95 r->m_to = to; 96 97 if( (*to < *from) ) { 98 std::cout << "!! to < from: " << r->to_string() << std::endl; 99 delete r; 100 return NULL; 101 } 102 103 return r; 104 } 105 106 std::string IpRange::to_string() const { 107 std::stringstream result; 108 result << m_description << ": [" << m_from->to_string() << " - " << m_to->to_string() << ']'; 109 return result.str(); 110 } 111 112 } -
src/core/ip_range.h
a b 1 #ifndef IPRANGE_H 2 #define IPRANGE_H 3 4 #include <string> 5 6 #include "printable.h" 7 #include "ip_address.h" 8 #include "utils/pattern.h" 9 #include "regex_namespace.h" 10 11 namespace core { 12 13 class IpRange : public Printable { 14 public: // constants 15 static const std::string PATTERN_RANGE_EXPRESSION; 16 static const regex::Pattern PATTERN_RANGE; 17 18 static const int GRP_DESCRIPTION; 19 static const int GRP_FIRST_IP; 20 static const int GRP_SECOND_IP; 21 22 private: // fields 23 std::string m_description; 24 const IpAddress* m_from; 25 const IpAddress* m_to; 26 27 private: // dynamic methods 28 IpRange() : m_description(), m_from(NULL), m_to(NULL) {} 29 30 public: // static methods 31 typedef IpRange* ptr; 32 static IpRange* parse( const std::string& s ); 33 static IpRange* parse( const char *s, const int size ); 34 35 public: // dynamic methods 36 IpRange( IpRange& rng ) { copy(rng); } 37 IpRange& operator= ( IpRange& rng ) { copy(rng); return *this; } 38 39 void copy( IpRange& rng ) { 40 m_description = rng.m_description; 41 m_from = (!rng.m_from) ? NULL : new IpAddress( *rng.m_from ); 42 m_to = (!rng.m_to) ? NULL : new IpAddress( *rng.m_to ); 43 } 44 45 const std::string& get_description ( void ) const { return m_description; } 46 const IpAddress* get_from ( void ) const { return m_from; } 47 const IpAddress* get_to ( void ) const { return m_to; } 48 49 void set_description ( const std::string& description ) { m_description = description; } 50 void set_from ( const IpAddress* from ) { if( m_from ) delete m_from; m_from = new IpAddress( *from ); } 51 void set_to ( const IpAddress* to ) { if( m_to ) delete m_to; m_to = new IpAddress( *to ); } 52 53 bool includes( const IpAddress& ip ) const { return includes((uint32_t)ip); } 54 bool includes( uint32_t ip ) const { return (*m_from <= ip) && (*m_to >= ip); } 55 56 ~IpRange() { 57 delete m_from; 58 m_from = NULL; 59 delete m_to; 60 m_to = NULL; 61 } 62 63 std::string to_string() const; 64 }; 65 66 } 67 #endif -
src/core/Makefile.am
a b 36 36 view.cc \ 37 37 view.h \ 38 38 view_manager.cc \ 39 view_manager.h 39 view_manager.h \ 40 ip_address.cc \ 41 ip_address.h \ 42 ip_filter.cc \ 43 ip_filter.h \ 44 ip_range.cc \ 45 ip_range.h \ 46 printable.h \ 47 regex_namespace.h \ 48 ip_filter_statics.cc \ 49 getline.h \ 50 getline.cc 40 51 41 52 INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) -
src/core/Makefile.in
a b 63 63 manager.$(OBJEXT) poll_manager.$(OBJEXT) \ 64 64 poll_manager_epoll.$(OBJEXT) poll_manager_kqueue.$(OBJEXT) \ 65 65 poll_manager_select.$(OBJEXT) view.$(OBJEXT) \ 66 view_manager.$(OBJEXT) 66 view_manager.$(OBJEXT) \ 67 ip_address.$(OBJEXT) \ 68 ip_filter.$(OBJEXT) \ 69 ip_range.$(OBJEXT) \ 70 ip_filter_statics.$(OBJEXT) \ 71 getline.$(OBJEXT) 67 72 libsub_core_a_OBJECTS = $(am_libsub_core_a_OBJECTS) 68 73 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 69 74 depcomp = $(SHELL) $(top_srcdir)/depcomp … … 256 261 view.cc \ 257 262 view.h \ 258 263 view_manager.cc \ 259 view_manager.h 264 view_manager.h \ 265 ip_address.cc \ 266 ip_address.h \ 267 ip_filter.cc \ 268 ip_filter.h \ 269 ip_range.cc \ 270 ip_range.h \ 271 printable.h \ 272 regex_namespace.h \ 273 ip_filter_statics.cc \ 274 getline.cc \ 275 getline.h 260 276 261 277 INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) 262 278 all: all-am … … 324 340 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poll_manager_select.Po@am__quote@ 325 341 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/view.Po@am__quote@ 326 342 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/view_manager.Po@am__quote@ 343 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ip_address.Po@am__quote@ 344 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ip_range.Po@am__quote@ 345 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ip_filter_statics.Po@am__quote@ 346 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getline.Po@am__quote@ 327 347 328 348 .cc.o: 329 349 @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -
src/core/Makefile.in.orig
a b 1 # Makefile.in generated by automake 1.11.1 from Makefile.am. 2 # @configure_input@ 3 4 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 5 # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, 6 # Inc. 7 # This Makefile.in is free software; the Free Software Foundation 8 # gives unlimited permission to copy and/or distribute it, 9 # with or without modifications, as long as this notice is preserved. 10 11 # This program is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 13 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 # PARTICULAR PURPOSE. 15 16 @SET_MAKE@ 17 18 VPATH = @srcdir@ 19 pkgdatadir = $(datadir)/@PACKAGE@ 20 pkgincludedir = $(includedir)/@PACKAGE@ 21 pkglibdir = $(libdir)/@PACKAGE@ 22 pkglibexecdir = $(libexecdir)/@PACKAGE@ 23 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 24 install_sh_DATA = $(install_sh) -c -m 644 25 install_sh_PROGRAM = $(install_sh) -c 26 install_sh_SCRIPT = $(install_sh) -c 27 INSTALL_HEADER = $(INSTALL_DATA) 28 transform = $(program_transform_name) 29 NORMAL_INSTALL = : 30 PRE_INSTALL = : 31 POST_INSTALL = : 32 NORMAL_UNINSTALL = : 33 PRE_UNINSTALL = : 34 POST_UNINSTALL = : 35 build_triplet = @build@ 36 host_triplet = @host@ 37 subdir = src/core 38 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 39 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 40 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ 41 $(top_srcdir)/scripts/checks.m4 \ 42 $(top_srcdir)/scripts/common.m4 \ 43 $(top_srcdir)/scripts/libtool.m4 \ 44 $(top_srcdir)/scripts/ltoptions.m4 \ 45 $(top_srcdir)/scripts/ltsugar.m4 \ 46 $(top_srcdir)/scripts/ltversion.m4 \ 47 $(top_srcdir)/scripts/lt~obsolete.m4 \ 48 $(top_srcdir)/configure.ac 49 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 50 $(ACLOCAL_M4) 51 mkinstalldirs = $(install_sh) -d 52 CONFIG_HEADER = $(top_builddir)/config.h 53 CONFIG_CLEAN_FILES = 54 CONFIG_CLEAN_VPATH_FILES = 55 LIBRARIES = $(noinst_LIBRARIES) 56 ARFLAGS = cru 57 libsub_core_a_AR = $(AR) $(ARFLAGS) 58 libsub_core_a_LIBADD = 59 am_libsub_core_a_OBJECTS = curl_get.$(OBJEXT) curl_socket.$(OBJEXT) \ 60 curl_stack.$(OBJEXT) dht_manager.$(OBJEXT) download.$(OBJEXT) \ 61 download_factory.$(OBJEXT) download_list.$(OBJEXT) \ 62 download_store.$(OBJEXT) http_queue.$(OBJEXT) log.$(OBJEXT) \ 63 manager.$(OBJEXT) poll_manager.$(OBJEXT) \ 64 poll_manager_epoll.$(OBJEXT) poll_manager_kqueue.$(OBJEXT) \ 65 poll_manager_select.$(OBJEXT) view.$(OBJEXT) \ 66 view_manager.$(OBJEXT) 67 libsub_core_a_OBJECTS = $(am_libsub_core_a_OBJECTS) 68 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 69 depcomp = $(SHELL) $(top_srcdir)/depcomp 70 am__depfiles_maybe = depfiles 71 am__mv = mv -f 72 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ 73 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) 74 LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ 75 --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ 76 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) 77 CXXLD = $(CXX) 78 CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ 79 --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ 80 $(LDFLAGS) -o $@ 81 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 82 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 83 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ 84 --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ 85 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 86 CCLD = $(CC) 87 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ 88 --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ 89 $(LDFLAGS) -o $@ 90 SOURCES = $(libsub_core_a_SOURCES) 91 DIST_SOURCES = $(libsub_core_a_SOURCES) 92 ETAGS = etags 93 CTAGS = ctags 94 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 95 ACLOCAL = @ACLOCAL@ 96 AMTAR = @AMTAR@ 97 AR = @AR@ 98 AUTOCONF = @AUTOCONF@ 99 AUTOHEADER = @AUTOHEADER@ 100 AUTOMAKE = @AUTOMAKE@ 101 AWK = @AWK@ 102 CC = @CC@ 103 CCDEPMODE = @CCDEPMODE@ 104 CFLAGS = @CFLAGS@ 105 CPP = @CPP@ 106 CPPFLAGS = @CPPFLAGS@ 107 CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ 108 CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ 109 CPPUNIT_LIBS = @CPPUNIT_LIBS@ 110 CXX = @CXX@ 111 CXXCPP = @CXXCPP@ 112 CXXDEPMODE = @CXXDEPMODE@ 113 CXXFLAGS = @CXXFLAGS@ 114 CYGPATH_W = @CYGPATH_W@ 115 DEFS = @DEFS@ 116 DEPDIR = @DEPDIR@ 117 DSYMUTIL = @DSYMUTIL@ 118 DUMPBIN = @DUMPBIN@ 119 ECHO_C = @ECHO_C@ 120 ECHO_N = @ECHO_N@ 121 ECHO_T = @ECHO_T@ 122 EGREP = @EGREP@ 123 EXEEXT = @EXEEXT@ 124 FGREP = @FGREP@ 125 GREP = @GREP@ 126 INSTALL = @INSTALL@ 127 INSTALL_DATA = @INSTALL_DATA@ 128 INSTALL_PROGRAM = @INSTALL_PROGRAM@ 129 INSTALL_SCRIPT = @INSTALL_SCRIPT@ 130 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 131 LD = @LD@ 132 LDFLAGS = @LDFLAGS@ 133 LIBOBJS = @LIBOBJS@ 134 LIBS = @LIBS@ 135 LIBTOOL = @LIBTOOL@ 136 LIPO = @LIPO@ 137 LN_S = @LN_S@ 138 LTLIBOBJS = @LTLIBOBJS@ 139 MAKEINFO = @MAKEINFO@ 140 MKDIR_P = @MKDIR_P@ 141 NM = @NM@ 142 NMEDIT = @NMEDIT@ 143 OBJDUMP = @OBJDUMP@ 144 OBJEXT = @OBJEXT@ 145 OTOOL = @OTOOL@ 146 OTOOL64 = @OTOOL64@ 147 PACKAGE = @PACKAGE@ 148 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 149 PACKAGE_NAME = @PACKAGE_NAME@ 150 PACKAGE_STRING = @PACKAGE_STRING@ 151 PACKAGE_TARNAME = @PACKAGE_TARNAME@ 152 PACKAGE_URL = @PACKAGE_URL@ 153 PACKAGE_VERSION = @PACKAGE_VERSION@ 154 PATH_SEPARATOR = @PATH_SEPARATOR@ 155 PKG_CONFIG = @PKG_CONFIG@ 156 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ 157 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ 158 RANLIB = @RANLIB@ 159 SED = @SED@ 160 SET_MAKE = @SET_MAKE@ 161 SHELL = @SHELL@ 162 STRIP = @STRIP@ 163 VERSION = @VERSION@ 164 abs_builddir = @abs_builddir@ 165 abs_srcdir = @abs_srcdir@ 166 abs_top_builddir = @abs_top_builddir@ 167 abs_top_srcdir = @abs_top_srcdir@ 168 ac_ct_CC = @ac_ct_CC@ 169 ac_ct_CXX = @ac_ct_CXX@ 170 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ 171 am__include = @am__include@ 172 am__leading_dot = @am__leading_dot@ 173 am__quote = @am__quote@ 174 am__tar = @am__tar@ 175 am__untar = @am__untar@ 176 bindir = @bindir@ 177 build = @build@ 178 build_alias = @build_alias@ 179 build_cpu = @build_cpu@ 180 build_os = @build_os@ 181 build_vendor = @build_vendor@ 182 builddir = @builddir@ 183 datadir = @datadir@ 184 datarootdir = @datarootdir@ 185 docdir = @docdir@ 186 dvidir = @dvidir@ 187 exec_prefix = @exec_prefix@ 188 host = @host@ 189 host_alias = @host_alias@ 190 host_cpu = @host_cpu@ 191 host_os = @host_os@ 192 host_vendor = @host_vendor@ 193 htmldir = @htmldir@ 194 includedir = @includedir@ 195 infodir = @infodir@ 196 install_sh = @install_sh@ 197 libcurl_CFLAGS = @libcurl_CFLAGS@ 198 libcurl_LIBS = @libcurl_LIBS@ 199 libdir = @libdir@ 200 libexecdir = @libexecdir@ 201 libtorrent_CFLAGS = @libtorrent_CFLAGS@ 202 libtorrent_LIBS = @libtorrent_LIBS@ 203 localedir = @localedir@ 204 localstatedir = @localstatedir@ 205 mandir = @mandir@ 206 mkdir_p = @mkdir_p@ 207 oldincludedir = @oldincludedir@ 208 pdfdir = @pdfdir@ 209 prefix = @prefix@ 210 program_transform_name = @program_transform_name@ 211 psdir = @psdir@ 212 sbindir = @sbindir@ 213 sharedstatedir = @sharedstatedir@ 214 sigc_CFLAGS = @sigc_CFLAGS@ 215 sigc_LIBS = @sigc_LIBS@ 216 srcdir = @srcdir@ 217 sysconfdir = @sysconfdir@ 218 target_alias = @target_alias@ 219 top_build_prefix = @top_build_prefix@ 220 top_builddir = @top_builddir@ 221 top_srcdir = @top_srcdir@ 222 noinst_LIBRARIES = libsub_core.a 223 libsub_core_a_SOURCES = \ 224 curl_get.cc \ 225 curl_get.h \ 226 curl_socket.cc \ 227 curl_socket.h \ 228 curl_stack.cc \ 229 curl_stack.h \ 230 dht_manager.cc \ 231 dht_manager.h \ 232 download.cc \ 233 download.h \ 234 download_factory.cc \ 235 download_factory.h \ 236 download_list.cc \ 237 download_list.h \ 238 download_slot_map.h \ 239 download_store.cc \ 240 download_store.h \ 241 http_queue.cc \ 242 http_queue.h \ 243 log.cc \ 244 log.h \ 245 manager.cc \ 246 manager.h \ 247 poll_manager.cc \ 248 poll_manager.h \ 249 poll_manager_epoll.cc \ 250 poll_manager_epoll.h \ 251 poll_manager_kqueue.cc \ 252 poll_manager_kqueue.h \ 253 poll_manager_select.cc \ 254 poll_manager_select.h \ 255 range_map.h \ 256 view.cc \ 257 view.h \ 258 view_manager.cc \ 259 view_manager.h 260 261 INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) 262 all: all-am 263 264 .SUFFIXES: 265 .SUFFIXES: .cc .lo .o .obj 266 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 267 @for dep in $?; do \ 268 case '$(am__configure_deps)' in \ 269 *$$dep*) \ 270 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 271 && { if test -f $@; then exit 0; else break; fi; }; \ 272 exit 1;; \ 273 esac; \ 274 done; \ 275 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/core/Makefile'; \ 276 $(am__cd) $(top_srcdir) && \ 277 $(AUTOMAKE) --gnu src/core/Makefile 278 .PRECIOUS: Makefile 279 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 280 @case '$?' in \ 281 *config.status*) \ 282 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 283 *) \ 284 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 285 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 286 esac; 287 288 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 289 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 290 291 $(top_srcdir)/configure: $(am__configure_deps) 292 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 293 $(ACLOCAL_M4): $(am__aclocal_m4_deps) 294 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 295 $(am__aclocal_m4_deps): 296 297 clean-noinstLIBRARIES: 298 -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) 299 libsub_core.a: $(libsub_core_a_OBJECTS) $(libsub_core_a_DEPENDENCIES) 300 -rm -f libsub_core.a 301 $(libsub_core_a_AR) libsub_core.a $(libsub_core_a_OBJECTS) $(libsub_core_a_LIBADD) 302 $(RANLIB) libsub_core.a 303 304 mostlyclean-compile: 305 -rm -f *.$(OBJEXT) 306 307 distclean-compile: 308 -rm -f *.tab.c 309 310 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/curl_get.Po@am__quote@ 311 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/curl_socket.Po@am__quote@ 312 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/curl_stack.Po@am__quote@ 313 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dht_manager.Po@am__quote@ 314 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/download.Po@am__quote@ 315 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/download_factory.Po@am__quote@ 316 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/download_list.Po@am__quote@ 317 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/download_store.Po@am__quote@ 318 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http_queue.Po@am__quote@ 319 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@ 320 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/manager.Po@am__quote@ 321 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poll_manager.Po@am__quote@ 322 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poll_manager_epoll.Po@am__quote@ 323 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poll_manager_kqueue.Po@am__quote@ 324 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poll_manager_select.Po@am__quote@ 325 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/view.Po@am__quote@ 326 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/view_manager.Po@am__quote@ 327 328 .cc.o: 329 @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 330 @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 331 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 332 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 333 @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< 334 335 .cc.obj: 336 @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` 337 @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 338 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 339 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 340 @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` 341 342 .cc.lo: 343 @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 344 @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo 345 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ 346 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 347 @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< 348 349 mostlyclean-libtool: 350 -rm -f *.lo 351 352 clean-libtool: 353 -rm -rf .libs _libs 354 355 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 356 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 357 unique=`for i in $$list; do \ 358 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 359 done | \ 360 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 361 END { if (nonempty) { for (i in files) print i; }; }'`; \ 362 mkid -fID $$unique 363 tags: TAGS 364 365 TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 366 $(TAGS_FILES) $(LISP) 367 set x; \ 368 here=`pwd`; \ 369 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 370 unique=`for i in $$list; do \ 371 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 372 done | \ 373 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 374 END { if (nonempty) { for (i in files) print i; }; }'`; \ 375 shift; \ 376 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 377 test -n "$$unique" || unique=$$empty_fix; \ 378 if test $$# -gt 0; then \ 379 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 380 "$$@" $$unique; \ 381 else \ 382 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 383 $$unique; \ 384 fi; \ 385 fi 386 ctags: CTAGS 387 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 388 $(TAGS_FILES) $(LISP) 389 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 390 unique=`for i in $$list; do \ 391 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 392 done | \ 393 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 394 END { if (nonempty) { for (i in files) print i; }; }'`; \ 395 test -z "$(CTAGS_ARGS)$$unique" \ 396 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 397 $$unique 398 399 GTAGS: 400 here=`$(am__cd) $(top_builddir) && pwd` \ 401 && $(am__cd) $(top_srcdir) \ 402 && gtags -i $(GTAGS_ARGS) "$$here" 403 404 distclean-tags: 405 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 406 407 distdir: $(DISTFILES) 408 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 409 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 410 list='$(DISTFILES)'; \ 411 dist_files=`for file in $$list; do echo $$file; done | \ 412 sed -e "s|^$$srcdirstrip/||;t" \ 413 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 414 case $$dist_files in \ 415 */*) $(MKDIR_P) `echo "$$dist_files" | \ 416 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 417 sort -u` ;; \ 418 esac; \ 419 for file in $$dist_files; do \ 420 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 421 if test -d $$d/$$file; then \ 422 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 423 if test -d "$(distdir)/$$file"; then \ 424 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 425 fi; \ 426 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 427 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 428 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 429 fi; \ 430 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 431 else \ 432 test -f "$(distdir)/$$file" \ 433 || cp -p $$d/$$file "$(distdir)/$$file" \ 434 || exit 1; \ 435 fi; \ 436 done 437 check-am: all-am 438 check: check-am 439 all-am: Makefile $(LIBRARIES) 440 installdirs: 441 install: install-am 442 install-exec: install-exec-am 443 install-data: install-data-am 444 uninstall: uninstall-am 445 446 install-am: all-am 447 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 448 449 installcheck: installcheck-am 450 install-strip: 451 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 452 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 453 `test -z '$(STRIP)' || \ 454 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 455 mostlyclean-generic: 456 457 clean-generic: 458 459 distclean-generic: 460 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 461 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 462 463 maintainer-clean-generic: 464 @echo "This command is intended for maintainers to use" 465 @echo "it deletes files that may require special tools to rebuild." 466 clean: clean-am 467 468 clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ 469 mostlyclean-am 470 471 distclean: distclean-am 472 -rm -rf ./$(DEPDIR) 473 -rm -f Makefile 474 distclean-am: clean-am distclean-compile distclean-generic \ 475 distclean-tags 476 477 dvi: dvi-am 478 479 dvi-am: 480 481 html: html-am 482 483 html-am: 484 485 info: info-am 486 487 info-am: 488 489 install-data-am: 490 491 install-dvi: install-dvi-am 492 493 install-dvi-am: 494 495 install-exec-am: 496 497 install-html: install-html-am 498 499 install-html-am: 500 501 install-info: install-info-am 502 503 install-info-am: 504 505 install-man: 506 507 install-pdf: install-pdf-am 508 509 install-pdf-am: 510 511 install-ps: install-ps-am 512 513 install-ps-am: 514 515 installcheck-am: 516 517 maintainer-clean: maintainer-clean-am 518 -rm -rf ./$(DEPDIR) 519 -rm -f Makefile 520 maintainer-clean-am: distclean-am maintainer-clean-generic 521 522 mostlyclean: mostlyclean-am 523 524 mostlyclean-am: mostlyclean-compile mostlyclean-generic \ 525 mostlyclean-libtool 526 527 pdf: pdf-am 528 529 pdf-am: 530 531 ps: ps-am 532 533 ps-am: 534 535 uninstall-am: 536 537 .MAKE: install-am install-strip 538 539 .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ 540 clean-libtool clean-noinstLIBRARIES ctags distclean \ 541 distclean-compile distclean-generic distclean-libtool \ 542 distclean-tags distdir dvi dvi-am html html-am info info-am \ 543 install install-am install-data install-data-am install-dvi \ 544 install-dvi-am install-exec install-exec-am install-html \ 545 install-html-am install-info install-info-am install-man \ 546 install-pdf install-pdf-am install-ps install-ps-am \ 547 install-strip installcheck installcheck-am installdirs \ 548 maintainer-clean maintainer-clean-generic mostlyclean \ 549 mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ 550 pdf pdf-am ps ps-am tags uninstall uninstall-am 551 552 553 # Tell versions [3.59,3.63) of GNU make to not export all variables. 554 # Otherwise a system limit (for SysV at least) may be exceeded. 555 .NOEXPORT: -
src/core/manager.cc
a b 153 153 } 154 154 } 155 155 156 uint32_t 157 Manager::filter_ip(const sockaddr* sa) { 158 IpRange* r = NULL; 159 // if something's wrong with filter or address it's gonna be allowed 160 if( m_ipFilter && sa ) { 161 const rak::socket_address* socketAddress = rak::socket_address::cast_from(sa); 162 if( socketAddress->is_valid() && (socketAddress->family() == rak::socket_address::af_inet) ) 163 r = m_ipFilter->find_range( socketAddress->sa_inet()->address_h() ); 164 if( r ) 165 m_logComplete.push_front("Address '" + socketAddress->address_str() + "' is rejected by IP filter range '" + r->to_string()); 166 else 167 if( rpc::call_command_value("get_handshake_log") ) 168 m_logComplete.push_front("IP Filter allowed connection with '" + socketAddress->address_str() + "'"); 169 } 170 return (r==NULL); 171 } 172 173 156 174 void 157 175 Manager::push_log(const char* msg) { 158 176 m_logImportant.push_front(msg); … … 160 178 } 161 179 162 180 Manager::Manager() : 163 m_hashingView(NULL) 181 m_hashingView(NULL), 182 m_ipFilter(NULL) 164 183 // m_pollManager(NULL) { 165 184 { 166 185 m_downloadStore = new DownloadStore(); … … 181 200 delete m_downloadStore; 182 201 delete m_httpQueue; 183 202 delete m_fileStatusCache; 203 204 set_ip_filter( NULL ); 184 205 } 185 206 186 207 void … … 226 247 CurlStack::global_init(); 227 248 228 249 torrent::connection_manager()->set_signal_handshake_log(sigc::mem_fun(this, &Manager::handshake_log)); 250 torrent::connection_manager()->set_filter(sigc::mem_fun(this, &Manager::filter_ip)); 229 251 } 230 252 231 253 void … … 585 607 } 586 608 } 587 609 610 void Manager::reload_ip_filter(void) { 611 if( m_ipFilter ) { 612 push_log("Reloading IP filter"); 613 m_ipFilter->reload(); 614 std::stringstream logMsg("IpFilter reloaded with "); 615 logMsg << m_ipFilter->size() << " ranges total. " << m_ipFilter->get_merges() << " ranges were merged."; 616 push_log( logMsg.str().c_str() ); 617 } 618 } 619 588 620 } -
src/core/manager.h
a b 47 47 #include "range_map.h" 48 48 #include "log.h" 49 49 50 #include "ip_filter.h" 51 50 52 namespace torrent { 51 53 class Bencode; 52 54 } … … 118 120 119 121 void handshake_log(const sockaddr* sa, int msg, int err, const torrent::HashString* hash); 120 122 123 uint32_t filter_ip(const sockaddr* sa); 124 125 void set_ip_filter( IpFilter* ipFilter ) { 126 IpFilter* old = m_ipFilter; 127 m_ipFilter = ipFilter; 128 if( old ) delete old; 129 } 130 void reload_ip_filter(void); 131 121 132 static const int create_start = 0x1; 122 133 static const int create_tied = 0x2; 123 134 static const int create_quiet = 0x4; … … 154 165 155 166 Log m_logImportant; 156 167 Log m_logComplete; 168 169 IpFilter* m_ipFilter; 157 170 }; 158 171 159 172 // Meh, cleanup. -
src/core/manager.h.orig
a b 1 // rTorrent - BitTorrent client 2 // Copyright (C) 2005-2007, Jari Sundell 3 // 4 // This program is free software; you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation; either version 2 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program; if not, write to the Free Software 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 // 18 // In addition, as a special exception, the copyright holders give 19 // permission to link the code of portions of this program with the 20 // OpenSSL library under certain conditions as described in each 21 // individual source file, and distribute linked combinations 22 // including the two. 23 // 24 // You must obey the GNU General Public License in all respects for 25 // all of the code used other than OpenSSL. If you modify file(s) 26 // with this exception, you may extend this exception to your version 27 // of the file(s), but you are not obligated to do so. If you do not 28 // wish to do so, delete this exception statement from your version. 29 // If you delete this exception statement from all source files in the 30 // program, then also delete it here. 31 // 32 // Contact: Jari Sundell <jaris@ifi.uio.no> 33 // 34 // Skomakerveien 33 35 // 3185 Skoppum, NORWAY 36 37 #ifndef RTORRENT_CORE_MANAGER_H 38 #define RTORRENT_CORE_MANAGER_H 39 40 #include <iosfwd> 41 #include <vector> 42 43 #include <torrent/connection_manager.h> 44 45 #include "download_list.h" 46 #include "poll_manager.h" 47 #include "range_map.h" 48 #include "log.h" 49 50 namespace torrent { 51 class Bencode; 52 } 53 54 namespace utils { 55 class FileStatusCache; 56 } 57 58 namespace core { 59 60 class DownloadStore; 61 class HttpQueue; 62 63 typedef std::map<std::string, torrent::ThrottlePair> ThrottleMap; 64 65 class View; 66 67 class Manager { 68 public: 69 typedef DownloadList::iterator DListItr; 70 typedef utils::FileStatusCache FileStatusCache; 71 72 typedef sigc::slot1<void, DownloadList::iterator> SlotReady; 73 typedef sigc::slot0<void> SlotFailed; 74 75 Manager(); 76 ~Manager(); 77 78 DownloadList* download_list() { return m_downloadList; } 79 DownloadStore* download_store() { return m_downloadStore; } 80 FileStatusCache* file_status_cache() { return m_fileStatusCache; } 81 82 HttpQueue* http_queue() { return m_httpQueue; } 83 CurlStack* http_stack() { return m_httpStack; } 84 85 View* hashing_view() { return m_hashingView; } 86 void set_hashing_view(View* v); 87 88 Log& get_log_important() { return m_logImportant; } 89 Log& get_log_complete() { return m_logComplete; } 90 91 ThrottleMap& throttles() { return m_throttles; } 92 torrent::ThrottlePair get_throttle(const std::string& name); 93 94 // Use custom throttle for the given range of IP addresses. 95 void set_address_throttle(uint32_t begin, uint32_t end, torrent::ThrottlePair throttles); 96 torrent::ThrottlePair get_address_throttle(const sockaddr* addr); 97 98 // Really should find a more descriptive name. 99 void initialize_second(); 100 void cleanup(); 101 102 void listen_open(); 103 104 std::string bind_address() const; 105 void set_bind_address(const std::string& addr); 106 107 std::string local_address() const; 108 void set_local_address(const std::string& addr); 109 110 std::string proxy_address() const; 111 void set_proxy_address(const std::string& addr); 112 113 void shutdown(bool force); 114 115 void push_log(const char* msg); 116 void push_log_std(const std::string& msg) { m_logImportant.push_front(msg); m_logComplete.push_front(msg); } 117 void push_log_complete(const std::string& msg) { m_logComplete.push_front(msg); } 118 119 void handshake_log(const sockaddr* sa, int msg, int err, const torrent::HashString* hash); 120 121 static const int create_start = 0x1; 122 static const int create_tied = 0x2; 123 static const int create_quiet = 0x4; 124 static const int create_raw_data = 0x8; 125 126 typedef std::vector<std::string> command_list_type; 127 128 // Temporary, find a better place for this. 129 void try_create_download(const std::string& uri, int flags, const command_list_type& commands); 130 void try_create_download_expand(const std::string& uri, int flags, command_list_type commands = command_list_type()); 131 void try_create_download_from_meta_download(torrent::Object* bencode, const std::string& metafile); 132 133 private: 134 typedef RangeMap<uint32_t, torrent::ThrottlePair> AddressThrottleMap; 135 136 void create_http(const std::string& uri); 137 void create_final(std::istream* s); 138 139 void initialize_bencode(Download* d); 140 141 void receive_http_failed(std::string msg); 142 void receive_hashing_changed(); 143 144 DownloadList* m_downloadList; 145 DownloadStore* m_downloadStore; 146 FileStatusCache* m_fileStatusCache; 147 HttpQueue* m_httpQueue; 148 CurlStack* m_httpStack; 149 150 View* m_hashingView; 151 152 ThrottleMap m_throttles; 153 AddressThrottleMap m_addressThrottles; 154 155 Log m_logImportant; 156 Log m_logComplete; 157 }; 158 159 // Meh, cleanup. 160 extern void receive_tracker_dump(const std::string& url, const char* data, size_t size); 161 162 } 163 164 #endif -
src/core/printable.h
a b 1 #ifndef PRINTABLE_H 2 #define PRINTABLE_H 3 4 #include <iostream> 5 6 class Printable { 7 public: 8 virtual std::string to_string() const = 0; 9 }; 10 11 template<typename _CharT,class _Traits> inline std::basic_ostream<_CharT,_Traits>& 12 operator<<( std::basic_ostream<_CharT,_Traits>& out, const Printable& val) { 13 return out << val.to_string(); 14 } 15 16 #endif -
src/core/regex_namespace.h
a b 1 #ifndef REGEXNAMESPACE_H 2 #define REGEXNAMESPACE_H 3 4 namespace regex = utils; 5 6 #endif -
src/utils/Makefile.am
a b 9 9 lockfile.cc \ 10 10 lockfile.h \ 11 11 socket_fd.cc \ 12 socket_fd.h 12 socket_fd.h \ 13 pattern.cc \ 14 pattern.h 13 15 14 16 INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) -
src/utils/Makefile.in
a b 58 58 libsub_utils_a_LIBADD = 59 59 am_libsub_utils_a_OBJECTS = directory.$(OBJEXT) \ 60 60 file_status_cache.$(OBJEXT) lockfile.$(OBJEXT) \ 61 socket_fd.$(OBJEXT) 61 socket_fd.$(OBJEXT) pattern.$(OBJEXT) 62 62 libsub_utils_a_OBJECTS = $(am_libsub_utils_a_OBJECTS) 63 63 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 64 64 depcomp = $(SHELL) $(top_srcdir)/depcomp … … 224 224 lockfile.cc \ 225 225 lockfile.h \ 226 226 socket_fd.cc \ 227 socket_fd.h 227 socket_fd.h \ 228 pattern.cc \ 229 pattern.h 228 230 229 231 INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) 230 232 all: all-am … … 279 281 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_status_cache.Po@am__quote@ 280 282 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lockfile.Po@am__quote@ 281 283 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket_fd.Po@am__quote@ 284 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pattern.Po@am__quote@ 282 285 283 286 .cc.o: 284 287 @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -
src/utils/Makefile.in.orig
a b 1 # Makefile.in generated by automake 1.11.1 from Makefile.am. 2 # @configure_input@ 3 4 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 5 # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, 6 # Inc. 7 # This Makefile.in is free software; the Free Software Foundation 8 # gives unlimited permission to copy and/or distribute it, 9 # with or without modifications, as long as this notice is preserved. 10 11 # This program is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 13 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 # PARTICULAR PURPOSE. 15 16 @SET_MAKE@ 17 18 VPATH = @srcdir@ 19 pkgdatadir = $(datadir)/@PACKAGE@ 20 pkgincludedir = $(includedir)/@PACKAGE@ 21 pkglibdir = $(libdir)/@PACKAGE@ 22 pkglibexecdir = $(libexecdir)/@PACKAGE@ 23 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 24 install_sh_DATA = $(install_sh) -c -m 644 25 install_sh_PROGRAM = $(install_sh) -c 26 install_sh_SCRIPT = $(install_sh) -c 27 INSTALL_HEADER = $(INSTALL_DATA) 28 transform = $(program_transform_name) 29 NORMAL_INSTALL = : 30 PRE_INSTALL = : 31 POST_INSTALL = : 32 NORMAL_UNINSTALL = : 33 PRE_UNINSTALL = : 34 POST_UNINSTALL = : 35 build_triplet = @build@ 36 host_triplet = @host@ 37 subdir = src/utils 38 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 39 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 40 am__aclocal_m4_deps = $(top_srcdir)/scripts/attributes.m4 \ 41 $(top_srcdir)/scripts/checks.m4 \ 42 $(top_srcdir)/scripts/common.m4 \ 43 $(top_srcdir)/scripts/libtool.m4 \ 44 $(top_srcdir)/scripts/ltoptions.m4 \ 45 $(top_srcdir)/scripts/ltsugar.m4 \ 46 $(top_srcdir)/scripts/ltversion.m4 \ 47 $(top_srcdir)/scripts/lt~obsolete.m4 \ 48 $(top_srcdir)/configure.ac 49 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 50 $(ACLOCAL_M4) 51 mkinstalldirs = $(install_sh) -d 52 CONFIG_HEADER = $(top_builddir)/config.h 53 CONFIG_CLEAN_FILES = 54 CONFIG_CLEAN_VPATH_FILES = 55 LIBRARIES = $(noinst_LIBRARIES) 56 ARFLAGS = cru 57 libsub_utils_a_AR = $(AR) $(ARFLAGS) 58 libsub_utils_a_LIBADD = 59 am_libsub_utils_a_OBJECTS = directory.$(OBJEXT) \ 60 file_status_cache.$(OBJEXT) lockfile.$(OBJEXT) \ 61 socket_fd.$(OBJEXT) 62 libsub_utils_a_OBJECTS = $(am_libsub_utils_a_OBJECTS) 63 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 64 depcomp = $(SHELL) $(top_srcdir)/depcomp 65 am__depfiles_maybe = depfiles 66 am__mv = mv -f 67 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ 68 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) 69 LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ 70 --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ 71 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) 72 CXXLD = $(CXX) 73 CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ 74 --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ 75 $(LDFLAGS) -o $@ 76 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 77 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 78 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ 79 --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ 80 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 81 CCLD = $(CC) 82 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ 83 --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ 84 $(LDFLAGS) -o $@ 85 SOURCES = $(libsub_utils_a_SOURCES) 86 DIST_SOURCES = $(libsub_utils_a_SOURCES) 87 ETAGS = etags 88 CTAGS = ctags 89 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 90 ACLOCAL = @ACLOCAL@ 91 AMTAR = @AMTAR@ 92 AR = @AR@ 93 AUTOCONF = @AUTOCONF@ 94 AUTOHEADER = @AUTOHEADER@ 95 AUTOMAKE = @AUTOMAKE@ 96 AWK = @AWK@ 97 CC = @CC@ 98 CCDEPMODE = @CCDEPMODE@ 99 CFLAGS = @CFLAGS@ 100 CPP = @CPP@ 101 CPPFLAGS = @CPPFLAGS@ 102 CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ 103 CPPUNIT_CONFIG = @CPPUNIT_CONFIG@ 104 CPPUNIT_LIBS = @CPPUNIT_LIBS@ 105 CXX = @CXX@ 106 CXXCPP = @CXXCPP@ 107 CXXDEPMODE = @CXXDEPMODE@ 108 CXXFLAGS = @CXXFLAGS@ 109 CYGPATH_W = @CYGPATH_W@ 110 DEFS = @DEFS@ 111 DEPDIR = @DEPDIR@ 112 DSYMUTIL = @DSYMUTIL@ 113 DUMPBIN = @DUMPBIN@ 114 ECHO_C = @ECHO_C@ 115 ECHO_N = @ECHO_N@ 116 ECHO_T = @ECHO_T@ 117 EGREP = @EGREP@ 118 EXEEXT = @EXEEXT@ 119 FGREP = @FGREP@ 120 GREP = @GREP@ 121 INSTALL = @INSTALL@ 122 INSTALL_DATA = @INSTALL_DATA@ 123 INSTALL_PROGRAM = @INSTALL_PROGRAM@ 124 INSTALL_SCRIPT = @INSTALL_SCRIPT@ 125 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 126 LD = @LD@ 127 LDFLAGS = @LDFLAGS@ 128 LIBOBJS = @LIBOBJS@ 129 LIBS = @LIBS@ 130 LIBTOOL = @LIBTOOL@ 131 LIPO = @LIPO@ 132 LN_S = @LN_S@ 133 LTLIBOBJS = @LTLIBOBJS@ 134 MAKEINFO = @MAKEINFO@ 135 MKDIR_P = @MKDIR_P@ 136 NM = @NM@ 137 NMEDIT = @NMEDIT@ 138 OBJDUMP = @OBJDUMP@ 139 OBJEXT = @OBJEXT@ 140 OTOOL = @OTOOL@ 141 OTOOL64 = @OTOOL64@ 142 PACKAGE = @PACKAGE@ 143 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 144 PACKAGE_NAME = @PACKAGE_NAME@ 145 PACKAGE_STRING = @PACKAGE_STRING@ 146 PACKAGE_TARNAME = @PACKAGE_TARNAME@ 147 PACKAGE_URL = @PACKAGE_URL@ 148 PACKAGE_VERSION = @PACKAGE_VERSION@ 149 PATH_SEPARATOR = @PATH_SEPARATOR@ 150 PKG_CONFIG = @PKG_CONFIG@ 151 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ 152 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ 153 RANLIB = @RANLIB@ 154 SED = @SED@ 155 SET_MAKE = @SET_MAKE@ 156 SHELL = @SHELL@ 157 STRIP = @STRIP@ 158 VERSION = @VERSION@ 159 abs_builddir = @abs_builddir@ 160 abs_srcdir = @abs_srcdir@ 161 abs_top_builddir = @abs_top_builddir@ 162 abs_top_srcdir = @abs_top_srcdir@ 163 ac_ct_CC = @ac_ct_CC@ 164 ac_ct_CXX = @ac_ct_CXX@ 165 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ 166 am__include = @am__include@ 167 am__leading_dot = @am__leading_dot@ 168 am__quote = @am__quote@ 169 am__tar = @am__tar@ 170 am__untar = @am__untar@ 171 bindir = @bindir@ 172 build = @build@ 173 build_alias = @build_alias@ 174 build_cpu = @build_cpu@ 175 build_os = @build_os@ 176 build_vendor = @build_vendor@ 177 builddir = @builddir@ 178 datadir = @datadir@ 179 datarootdir = @datarootdir@ 180 docdir = @docdir@ 181 dvidir = @dvidir@ 182 exec_prefix = @exec_prefix@ 183 host = @host@ 184 host_alias = @host_alias@ 185 host_cpu = @host_cpu@ 186 host_os = @host_os@ 187 host_vendor = @host_vendor@ 188 htmldir = @htmldir@ 189 includedir = @includedir@ 190 infodir = @infodir@ 191 install_sh = @install_sh@ 192 libcurl_CFLAGS = @libcurl_CFLAGS@ 193 libcurl_LIBS = @libcurl_LIBS@ 194 libdir = @libdir@ 195 libexecdir = @libexecdir@ 196 libtorrent_CFLAGS = @libtorrent_CFLAGS@ 197 libtorrent_LIBS = @libtorrent_LIBS@ 198 localedir = @localedir@ 199 localstatedir = @localstatedir@ 200 mandir = @mandir@ 201 mkdir_p = @mkdir_p@ 202 oldincludedir = @oldincludedir@ 203 pdfdir = @pdfdir@ 204 prefix = @prefix@ 205 program_transform_name = @program_transform_name@ 206 psdir = @psdir@ 207 sbindir = @sbindir@ 208 sharedstatedir = @sharedstatedir@ 209 sigc_CFLAGS = @sigc_CFLAGS@ 210 sigc_LIBS = @sigc_LIBS@ 211 srcdir = @srcdir@ 212 sysconfdir = @sysconfdir@ 213 target_alias = @target_alias@ 214 top_build_prefix = @top_build_prefix@ 215 top_builddir = @top_builddir@ 216 top_srcdir = @top_srcdir@ 217 noinst_LIBRARIES = libsub_utils.a 218 libsub_utils_a_SOURCES = \ 219 directory.cc \ 220 directory.h \ 221 file_status_cache.cc \ 222 file_status_cache.h \ 223 list_focus.h \ 224 lockfile.cc \ 225 lockfile.h \ 226 socket_fd.cc \ 227 socket_fd.h 228 229 INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir) 230 all: all-am 231 232 .SUFFIXES: 233 .SUFFIXES: .cc .lo .o .obj 234 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 235 @for dep in $?; do \ 236 case '$(am__configure_deps)' in \ 237 *$$dep*) \ 238 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 239 && { if test -f $@; then exit 0; else break; fi; }; \ 240 exit 1;; \ 241 esac; \ 242 done; \ 243 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/utils/Makefile'; \ 244 $(am__cd) $(top_srcdir) && \ 245 $(AUTOMAKE) --gnu src/utils/Makefile 246 .PRECIOUS: Makefile 247 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 248 @case '$?' in \ 249 *config.status*) \ 250 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 251 *) \ 252 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 253 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 254 esac; 255 256 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 257 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 258 259 $(top_srcdir)/configure: $(am__configure_deps) 260 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 261 $(ACLOCAL_M4): $(am__aclocal_m4_deps) 262 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 263 $(am__aclocal_m4_deps): 264 265 clean-noinstLIBRARIES: 266 -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) 267 libsub_utils.a: $(libsub_utils_a_OBJECTS) $(libsub_utils_a_DEPENDENCIES) 268 -rm -f libsub_utils.a 269 $(libsub_utils_a_AR) libsub_utils.a $(libsub_utils_a_OBJECTS) $(libsub_utils_a_LIBADD) 270 $(RANLIB) libsub_utils.a 271 272 mostlyclean-compile: 273 -rm -f *.$(OBJEXT) 274 275 distclean-compile: 276 -rm -f *.tab.c 277 278 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/directory.Po@am__quote@ 279 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_status_cache.Po@am__quote@ 280 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lockfile.Po@am__quote@ 281 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket_fd.Po@am__quote@ 282 283 .cc.o: 284 @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 285 @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 286 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 287 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 288 @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< 289 290 .cc.obj: 291 @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` 292 @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 293 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 294 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 295 @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` 296 297 .cc.lo: 298 @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 299 @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo 300 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ 301 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 302 @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< 303 304 mostlyclean-libtool: 305 -rm -f *.lo 306 307 clean-libtool: 308 -rm -rf .libs _libs 309 310 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 311 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 312 unique=`for i in $$list; do \ 313 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 314 done | \ 315 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 316 END { if (nonempty) { for (i in files) print i; }; }'`; \ 317 mkid -fID $$unique 318 tags: TAGS 319 320 TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 321 $(TAGS_FILES) $(LISP) 322 set x; \ 323 here=`pwd`; \ 324 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 325 unique=`for i in $$list; do \ 326 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 327 done | \ 328 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 329 END { if (nonempty) { for (i in files) print i; }; }'`; \ 330 shift; \ 331 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 332 test -n "$$unique" || unique=$$empty_fix; \ 333 if test $$# -gt 0; then \ 334 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 335 "$$@" $$unique; \ 336 else \ 337 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 338 $$unique; \ 339 fi; \ 340 fi 341 ctags: CTAGS 342 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 343 $(TAGS_FILES) $(LISP) 344 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 345 unique=`for i in $$list; do \ 346 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 347 done | \ 348 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 349 END { if (nonempty) { for (i in files) print i; }; }'`; \ 350 test -z "$(CTAGS_ARGS)$$unique" \ 351 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 352 $$unique 353 354 GTAGS: 355 here=`$(am__cd) $(top_builddir) && pwd` \ 356 && $(am__cd) $(top_srcdir) \ 357 && gtags -i $(GTAGS_ARGS) "$$here" 358 359 distclean-tags: 360 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 361 362 distdir: $(DISTFILES) 363 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 364 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 365 list='$(DISTFILES)'; \ 366 dist_files=`for file in $$list; do echo $$file; done | \ 367 sed -e "s|^$$srcdirstrip/||;t" \ 368 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 369 case $$dist_files in \ 370 */*) $(MKDIR_P) `echo "$$dist_files" | \ 371 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 372 sort -u` ;; \ 373 esac; \ 374 for file in $$dist_files; do \ 375 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 376 if test -d $$d/$$file; then \ 377 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 378 if test -d "$(distdir)/$$file"; then \ 379 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 380 fi; \ 381 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 382 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 383 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 384 fi; \ 385 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 386 else \ 387 test -f "$(distdir)/$$file" \ 388 || cp -p $$d/$$file "$(distdir)/$$file" \ 389 || exit 1; \ 390 fi; \ 391 done 392 check-am: all-am 393 check: check-am 394 all-am: Makefile $(LIBRARIES) 395 installdirs: 396 install: install-am 397 install-exec: install-exec-am 398 install-data: install-data-am 399 uninstall: uninstall-am 400 401 install-am: all-am 402 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 403 404 installcheck: installcheck-am 405 install-strip: 406 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 407 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 408 `test -z '$(STRIP)' || \ 409 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 410 mostlyclean-generic: 411 412 clean-generic: 413 414 distclean-generic: 415 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 416 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 417 418 maintainer-clean-generic: 419 @echo "This command is intended for maintainers to use" 420 @echo "it deletes files that may require special tools to rebuild." 421 clean: clean-am 422 423 clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ 424 mostlyclean-am 425 426 distclean: distclean-am 427 -rm -rf ./$(DEPDIR) 428 -rm -f Makefile 429 distclean-am: clean-am distclean-compile distclean-generic \ 430 distclean-tags 431 432 dvi: dvi-am 433 434 dvi-am: 435 436 html: html-am 437 438 html-am: 439 440 info: info-am 441 442 info-am: 443 444 install-data-am: 445 446 install-dvi: install-dvi-am 447 448 install-dvi-am: 449 450 install-exec-am: 451 452 install-html: install-html-am 453 454 install-html-am: 455 456 install-info: install-info-am 457 458 install-info-am: 459 460 install-man: 461 462 install-pdf: install-pdf-am 463 464 install-pdf-am: 465 466 install-ps: install-ps-am 467 468 install-ps-am: 469 470 installcheck-am: 471 472 maintainer-clean: maintainer-clean-am 473 -rm -rf ./$(DEPDIR) 474 -rm -f Makefile 475 maintainer-clean-am: distclean-am maintainer-clean-generic 476 477 mostlyclean: mostlyclean-am 478 479 mostlyclean-am: mostlyclean-compile mostlyclean-generic \ 480 mostlyclean-libtool 481 482 pdf: pdf-am 483 484 pdf-am: 485 486 ps: ps-am 487 488 ps-am: 489 490 uninstall-am: 491 492 .MAKE: install-am install-strip 493 494 .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ 495 clean-libtool clean-noinstLIBRARIES ctags distclean \ 496 distclean-compile distclean-generic distclean-libtool \ 497 distclean-tags distdir dvi dvi-am html html-am info info-am \ 498 install install-am install-data install-data-am install-dvi \ 499 install-dvi-am install-exec install-exec-am install-html \ 500 install-html-am install-info install-info-am install-man \ 501 install-pdf install-pdf-am install-ps install-ps-am \ 502 install-strip installcheck installcheck-am installdirs \ 503 maintainer-clean maintainer-clean-generic mostlyclean \ 504 mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ 505 pdf pdf-am ps ps-am tags uninstall uninstall-am 506 507 508 # Tell versions [3.59,3.63) of GNU make to not export all variables. 509 # Otherwise a system limit (for SysV at least) may be exceeded. 510 .NOEXPORT: -
src/utils/pattern.cc
a b 1 #include <string> 2 #include <sys/types.h> 3 #include <ctype.h> 4 #include <regex.h> 5 6 #include "pattern.h" 7 8 namespace utils { 9 10 int Pattern::countGroups( const std::string& str ) { 11 int count1 = 0; 12 int count2 = 0; 13 14 for( size_t index = -1; (index = str.find( '(', index+1 )) != std::string::npos; ) 15 count1++; 16 for( size_t index = -1; (index = str.find( ')', index+1 )) != std::string::npos; ) 17 count2++; 18 19 return (count1 < count2) ? count1 : count2; 20 } 21 22 Pattern::Pattern( const std::string& pattern, Flags flags ) : lastResult(-1), 23 preg(NULL) { 24 int regFlags = REG_EXTENDED | REG_ICASE | REG_NEWLINE; 25 if( !(flags & CASE_SENSITIVE) ) 26 regFlags ^= REG_ICASE; 27 if( (flags & DOT_MATCH_NEWLINE) ) 28 regFlags ^= REG_NEWLINE; 29 30 preg = new regex_t; 31 numGroups = countGroups( pattern ) + 1; 32 33 lastResult = regcomp( preg, pattern.c_str(), regFlags ); 34 } 35 36 Pattern::~Pattern() { 37 regfree( preg ); 38 delete( preg ); 39 } 40 41 std::string Pattern::getLastError() const { 42 char errBuf[1024]; 43 regerror( lastResult, preg, errBuf, sizeof(errBuf) ); 44 return std::string(errBuf); 45 } 46 47 Match Pattern::match( const std::string& expression ) const { 48 49 regmatch_t* pmatch = new regmatch_t[numGroups]; 50 int res = regexec( preg, expression.c_str(), numGroups, pmatch, 0 ); 51 return Match( expression, numGroups, pmatch, res, getLastError() ); 52 } 53 54 Match::Match( const std::string& expr, int ngroups, regmatch_t* groups, int result, const std::string& message ) : 55 expression( expr ), 56 nmatch( ngroups ), 57 pmatch( groups ), 58 matchResult( result ), 59 matchMessage( message ) { 60 } 61 62 std::string Match::group( int i ) { 63 if( (i >= nmatch) || (pmatch[i].rm_so < 0) ) 64 return ""; 65 66 return expression.substr( pmatch[i].rm_so, pmatch[i].rm_eo - pmatch[i].rm_so ); 67 } 68 69 std::string& trim( std::string& str ) { 70 std::string::iterator it; 71 for( it = str.begin(); (it < str.end()) && ( isspace(*it) || (*it == 0) ) ; it++ ); 72 str.erase( str.begin(), it ); 73 for( it = str.end()-1; (it >= str.begin()) && ( isspace(*it) || (*it == 0) ) ; it-- ); 74 str.erase( ++it, str.end() ); 75 return str; 76 } 77 78 } 79 -
src/utils/pattern.h
a b 1 #ifndef PATTERN_H 2 #define PATTERN_H 3 4 #include <string> 5 #include <sys/types.h> 6 #include <ctype.h> 7 #include <regex.h> 8 9 namespace utils { 10 11 class Match { 12 public: 13 Match( const std::string& expr, int ngroups, regmatch_t* pmatch, int matchResult, const std::string& matchMessage ); 14 ~Match() { delete[] pmatch; } 15 std::string group( int i ); 16 bool found() { return (matchResult == 0); } 17 bool matches() { return found(); } 18 std::string& getMatchMessage() { return matchMessage; } 19 20 private: 21 std::string expression; 22 int nmatch; 23 regmatch_t* pmatch; 24 int matchResult; 25 std::string matchMessage; 26 }; 27 28 class Pattern { 29 public: 30 enum Flags { 31 DEFAULT = 0, // REG_EXTENDED | REG_ICASE | REG_NEWLINE 32 CASE_SENSITIVE, 33 DOT_MATCH_NEWLINE 34 }; 35 36 public: 37 Pattern( const std::string& pattern, Flags f = Pattern::DEFAULT ); 38 ~Pattern(); 39 bool isSuccess() { return (lastResult == 0); } 40 std::string getLastError() const; 41 Match match( const std::string& expression ) const; 42 43 private: 44 int countGroups( const std::string& str ); 45 46 private: 47 regex_t* preg; 48 int lastResult; 49 int numGroups; 50 }; 51 52 53 std::string& trim( std::string& str ); 54 55 } 56 57 // end of ifdef PATTERN_H 58 #endif 59
