Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Utils.h

Go to the documentation of this file.
00001 #ifndef PRIVATE_UTILS_H
00002 #define PRIVATE_UTILS_H
00003 
00004 #include <abuse/Dnsbl.h>
00005 #include <abuse/RegKey.h>
00006 #include <abuse/SysError.h>
00007 #include <string>
00008 #include <list>
00009 #include "PropertiesNames.h"
00010 
00011 RegKey* initReg(const std::string& name)throw(SysError);
00012 std::string getOpenFileName(HWND hOwner,const std::string& initialfile="",const char* patterns=NULL, const std::string& title="");
00013 std::string getSaveFileName(HWND hOwner,const std::string& initialfile="",const char* patterns=NULL,const std::string& title="");
00014 std::string loadString(int ID)throw(SysError);
00015 const std::string& getAbuseExePath();
00016 const std::string& getAbuseDataPath();
00017 RECT getDlgItemRect(HWND hDlg,DWORD id)throw(SysError);
00018 RECT getDlgItemRect(HWND hDlg,HWND hCtrl)throw(SysError);
00019 bool isNtKernel();
00020 void EnableDefault(HWND hDlg,int ID);
00021 void DisableDefault(HWND hDlg,int ID);
00022 //@zello
00023 //Populate a combo with a description string of each result,
00024 //adding as a custom data the Result code
00025 void populateComboWithResults(HWND hCombo);
00026 
00027 __inline bool isWindowEnabled(HWND hWnd)
00028 {
00029         return (IsWindowEnabled(hWnd)?true:false);
00030 }
00031 #define isDlgItemEnabled(hDlg,id) isWindowEnabled(GetDlgItem(hDlg,id))
00032 #define enableDlgItem(hDlg,id,b) EnableWindow(GetDlgItem(hDlg,id),(BOOL)b)
00033 #define getDlgItemTextLength(hDlg,id) GetWindowTextLength(GetDlgItem(hDlg,id))
00034 __inline BOOL setDlgItemText(HWND hDlg,int id,const std::string& str)
00035 {
00036         return SetDlgItemText(hDlg,id,str.c_str());
00037 }
00038 std::string getWindowText(HWND hWnd);
00039 __inline std::string getDlgItemText(HWND hWnd,int id)
00040 {
00041         return getWindowText(GetDlgItem(hWnd,id));
00042 }
00043 __inline int MessageBox(HWND hWnd,std::string text,std::string caption,UINT uType)
00044 {
00045         return MessageBox(hWnd,text.c_str(),caption.c_str(),uType);
00046 }
00047 
00048 __inline std::string addreturn(const std::string& str)
00049 {
00050         size_t pos=0;
00051         std::string ret=str;
00052         while((pos=ret.find('\n',pos))!=std::string::npos)
00053         {
00054                 ret.insert(pos,"\r",1);
00055                 pos+=2;
00056         }
00057         return ret;
00058 }
00059 
00060 __inline std::string skipreturn(const std::string& str)
00061 {
00062         size_t pos=0;
00063         std::string ret=str;
00064         while((pos=ret.find('\r',pos))!=std::string::npos)
00065         {
00066                 ret.erase(pos/*+1*/,1);
00067                 pos+=2;
00068         }
00069         return ret;
00070 }
00071 
00072 __inline WNDPROC subclass(HWND hWnd,WNDPROC newWinProc)
00073 {
00074         return (WNDPROC)SetWindowLong(hWnd,GWL_WNDPROC,(LONG)newWinProc);
00075 }
00076 
00077 
00078 __inline std::string resultToPropName(Result r)
00079 {
00080         switch(r)
00081         {
00082         case SPAMSOURCE:
00083                 return SPAMKEY;
00084         case OPENPROXY:
00085                 return PROXYKEY;
00086         case OPENRELAY:
00087                 return RELAYKEY;
00088         case VIRUSSOURCE:
00089                 return VIRUSKEY;
00090         default:
00091                 return "";
00092         }
00093 }
00094 
00095 __inline std::string resultToPropSubjName(Result r)
00096 {
00097         switch(r)
00098         {
00099         case SPAMSOURCE:
00100                 return SPAMSUBJECT;
00101         case OPENPROXY:
00102                 return PROXYSUBJECT;
00103         case OPENRELAY:
00104                 return RELAYSUBJECT;
00105         case VIRUSSOURCE:
00106                 return VIRUSSUBJECT;
00107         default:
00108                 return "";
00109         }
00110 }
00111 
00112 std::string encode(const std::string& str);
00113 std::string decode(const std::string& str);
00114 
00122 std::list<UrlRange> listStringToListUrlRange(const std::list<std::string>&);
00123 std::list<std::string>   listUrlRangeToListString(const std::list<UrlRange>&);
00124 
00130 std::pair<std::string,std::string> splitString(const std::string& str,const char sep='-')throw(std::logic_error);
00131 
00133 
00137 extern "C" BOOL MakeSureDirectoryPathExists(PCSTR DirPath);
00138 #endif //PRIVATE_UTILS_H

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