Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Utils.h

Go to the documentation of this file.
00001 #ifndef NETLIB_UTILS_H
00002 #define NETLIB_UTILS_H
00003 
00004 #ifdef WIN32
00005 //#define NO_PCRE
00006 #endif
00007 #include <string>
00008 #include <stdexcept>
00009 #include <utility>
00010 #include <abuse/Dnsbl.h> //for Result
00011 #ifndef NO_PCRE
00012 #include <abuse/RegEx.h>
00013 #endif
00014 
00022 
00023 
00028 std::string getDomain(const std::string& email)throw(std::runtime_error);
00030 
00036 std::string codeToString(Result r)throw(std::runtime_error);
00038 
00044 Result stringToCode(const std::string& s)throw(std::runtime_error);
00045 
00047 bool similar(const std::string& s1,const std::string& s2);
00049 
00053 std::string domainFromHostname(const std::string& host);
00055 
00059 std::string tolow(const std::string&);
00061 
00065 std::string tolowCopy(const std::string&);      // Don't change passed string
00067 
00071 std::string toAnsi(const std::wstring&);
00073 
00078 std::string skipchars(const std::string& str,const std::string& chars=" \t");
00080 
00087 size_t findWordInsens(const std::string& where,const std::string& what,size_t pos=0);
00089 
00096 size_t findWord(const std::string& where,const std::string& what,size_t pos0);
00097 
00098 std::pair<size_t,size_t> nextWord(const std::string& where,size_t pos);
00099 std::pair<size_t,size_t> isolateWord(const std::string& where,size_t pos);
00100 std::string fetchKeyword(const std::string& line);
00101 size_t LocEmailInComment(const std::string& str, size_t pos);
00102 bool LocAbuseInLine(const std::string& str, size_t pos);
00103 size_t FetchNextEmail(const std::string& str,size_t pos, std::list<std::string>& emails);
00104 size_t FetchNextURL(const std::string& str,size_t pos,std::string& strUrl);
00105 bool LocEmailAfterRefWord(const std::string& whoisstr, const std::string& refWord, std::list<std::string>& emails);
00106 bool validIPv4address(const char* ip);
00107 std::string validIpUrlFormat(const char *ipUrl, bool& isIpFormat);
00109 
00112 std::string getPcreVersion();
00113 std::string UrlDigitsToIPDot(std::string Url);
00114 std::string removeEscapeUrlChars(const char* chUrl);
00115 
00116 
00118 
00123 __inline const char* getComputerName()
00124 {
00125         static char buf[MAX_COMPUTERNAME_LENGTH+1]={0};
00126         if(!buf[0])
00127         {
00128 #ifdef WIN32
00129                 DWORD dwDummy=MAX_COMPUTERNAME_LENGTH;
00130                 GetComputerName((LPSTR)buf,&dwDummy);
00131 #else
00132                 gethostname(buf,sizeof(buf));
00133 #endif
00134         }
00135         return buf;
00136 }
00137 
00139 
00142 class EmailExtractor
00143 {
00144 public:
00146 
00150         EmailExtractor(const std::string& what,size_t pos=0);
00152         virtual ~EmailExtractor();
00154 
00157         bool more()const;
00159 
00162         std::string next()const;
00163 private:
00165         std::string m_what;
00167         mutable size_t m_pos;
00169         mutable std::string m_next;
00171         void setNext()const;
00172 #ifndef NO_PCRE
00173 
00174         RegEx m_regex;
00175 #endif
00176 };
00177 #endif //NETLIB...
00178 

Generated on Thu Jun 16 00:13:14 2005 for Netlib for Abuse! by  doxygen 1.4.3