[Javanetsim-cvs] IceScan/icesockets csocket.h, 1.4, 1.5 iceregex.h, 1.1, 1.2 sock_types.h, 1.1, 1.2
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2006-11-30 15:13:10
|
Update of /cvsroot/javanetsim/IceScan/icesockets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30155 Modified Files: csocket.h iceregex.h sock_types.h test.cc Log Message: no message Index: sock_types.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/sock_types.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sock_types.h 30 Nov 2006 12:27:36 -0000 1.1 --- sock_types.h 30 Nov 2006 15:13:05 -0000 1.2 *************** *** 3,6 **** --- 3,12 ---- #include <iostream> //for std + #include <sys/types.h> + #include <sys/socket.h> + #include <arpa/inet.h> + #include <netinet/in.h> + #include <netinet/ip.h> + #include <netdb.h> // Re-Defining string type; use icestring instead of string Index: test.cc =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/test.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test.cc 30 Nov 2006 15:02:41 -0000 1.1 --- test.cc 30 Nov 2006 15:13:05 -0000 1.2 *************** *** 5,10 **** int main(){ ! std::string rg = "^\\d+$"; ! IceRegex re(rg); std::cout << re.match("1234r5678") << std::endl; --- 5,9 ---- int main(){ ! IceRegex re("^\\d+$"); std::cout << re.match("1234r5678") << std::endl; Index: iceregex.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/iceregex.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** iceregex.h 30 Nov 2006 15:02:41 -0000 1.1 --- iceregex.h 30 Nov 2006 15:13:05 -0000 1.2 *************** *** 18,27 **** class IceRegex { public: ! IceRegex (const icestring& pattern){ const char *error; int error_offset; pcre_ = pcre_compile ( ! pattern.c_str(), 0, &error, --- 18,35 ---- class IceRegex { public: ! IceRegex (const icestring& pattern){ ! init_regex(pattern.c_str()); ! } ! ! IceRegex (const char pattern[]){ ! init_regex(pattern); ! } ! ! void init_regex(const char pattern[]){ const char *error; int error_offset; pcre_ = pcre_compile ( ! pattern, 0, &error, *************** *** 42,91 **** ovector_ = new int[3*(capture_count_+1)]; ! } ! bool match(icestring const& s, std::vector<icestring> &v){ ! int rc = pcre_exec ( ! pcre_, /* the compiled pattern */ ! 0, /* no extra data - pattern was not studied */ ! s.c_str(), /* the string to match */ ! s.length(), /* the length of the string */ ! 0, /* start at offset 0 in the subject */ ! 0, /* default options */ ! ovector_, /* output vector for substring information */ ! 3*(capture_count_+1)); /* number of elements in the output vector */ ! if (rc < 0) { ! switch (rc) { ! case PCRE_ERROR_NOMATCH: ! return false; ! default: ! std::cout << "IceRegex strange error!" << std::endl; ! exit(-1); ! } } ! else { ! for (int i=0; i<rc; i++) { ! v.push_back(s.substr(ovector_[2*i], ovector_[2*i+1] - ovector_[2*i])); ! } } ! return true; ! } ! ! bool match(icestring const& s){ ! std::vector<icestring> v; ! return match(s, v); ! } ! ! bool match(const char s[]){ ! icestring is(s); ! return match(is); ! } private: pcre* pcre_; unsigned long int capture_count_; ! int* ovector_; //UGLY }; --- 50,99 ---- ovector_ = new int[3*(capture_count_+1)]; ! } ! bool match(icestring const& s, std::vector<icestring> &v){ ! int rc = pcre_exec ( ! pcre_, /* the compiled pattern */ ! 0, /* no extra data - pattern was not studied */ ! s.c_str(), /* the string to match */ ! s.length(), /* the length of the string */ ! 0, /* start at offset 0 in the subject */ ! 0, /* default options */ ! ovector_, /* output vector for substring information */ ! 3*(capture_count_+1)); /* number of elements in the output vector */ ! if (rc < 0) { ! switch (rc) { ! case PCRE_ERROR_NOMATCH: ! return false; ! default: ! std::cout << "IceRegex strange error!" << std::endl; ! exit(-1); ! } ! } ! else { ! for (int i=0; i<rc; i++) { ! v.push_back(s.substr(ovector_[2*i], ovector_[2*i+1] - ovector_[2*i])); ! } ! } ! ! return true; } ! ! bool match(icestring const& s){ ! std::vector<icestring> v; ! return match(s, v); } ! bool match(const char s[]){ ! icestring is(s); ! return match(is); ! } private: pcre* pcre_; unsigned long int capture_count_; ! int* ovector_; //UGLY }; Index: csocket.h =================================================================== RCS file: /cvsroot/javanetsim/IceScan/icesockets/csocket.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** csocket.h 30 Nov 2006 12:27:36 -0000 1.4 --- csocket.h 30 Nov 2006 15:13:05 -0000 1.5 *************** *** 4,13 **** #include <iostream> - #include <sys/types.h> - #include <sys/socket.h> - #include <arpa/inet.h> - #include <netinet/in.h> - #include <netinet/ip.h> - #include <netdb.h> #include <cstdio> #include <cstdlib> --- 4,7 ---- |