git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@473 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2004/04/05 23:22:251 | 1 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,100 @@ |
0 |
+// clamadoc.cpp : implementation of the CClamavDoc class |
|
1 |
+// |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
5 |
+ * |
|
6 |
+ * This program is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * This program is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
+ * GNU General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU General Public License |
|
17 |
+ * along with this program; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+#include "stdafx.h" |
|
22 |
+#include "resource.h" |
|
23 |
+#include "clamav.h" |
|
24 |
+ |
|
25 |
+#include "clamadoc.h" |
|
26 |
+ |
|
27 |
+#ifdef _DEBUG |
|
28 |
+#undef THIS_FILE |
|
29 |
+static char BASED_CODE THIS_FILE[] = __FILE__; |
|
30 |
+#endif |
|
31 |
+ |
|
32 |
+///////////////////////////////////////////////////////////////////////////// |
|
33 |
+// CClamavDoc |
|
34 |
+ |
|
35 |
+IMPLEMENT_DYNCREATE(CClamavDoc, CDocument) |
|
36 |
+ |
|
37 |
+BEGIN_MESSAGE_MAP(CClamavDoc, CDocument) |
|
38 |
+ |
|
39 |
+ // NOTE - the ClassWizard will add and remove mapping macros here. |
|
40 |
+ // DO NOT EDIT what you see in these blocks of generated code! |
|
41 |
+ //}}AFX_MSG_MAP |
|
42 |
+END_MESSAGE_MAP() |
|
43 |
+ |
|
44 |
+///////////////////////////////////////////////////////////////////////////// |
|
45 |
+// CClamavDoc construction/destruction |
|
46 |
+ |
|
47 |
+CClamavDoc::CClamavDoc() |
|
48 |
+{ |
|
49 |
+ // TODO: add one-time construction code here |
|
50 |
+ |
|
51 |
+} |
|
52 |
+ |
|
53 |
+CClamavDoc::~CClamavDoc() |
|
54 |
+{ |
|
55 |
+} |
|
56 |
+ |
|
57 |
+BOOL CClamavDoc::OnNewDocument() |
|
58 |
+{ |
|
59 |
+ if (!CDocument::OnNewDocument()) |
|
60 |
+ return FALSE; |
|
61 |
+ |
|
62 |
+ // TODO: add reinitialization code here |
|
63 |
+ // (SDI documents will reuse this document) |
|
64 |
+ |
|
65 |
+ return TRUE; |
|
66 |
+} |
|
67 |
+ |
|
68 |
+///////////////////////////////////////////////////////////////////////////// |
|
69 |
+// CClamavDoc serialization |
|
70 |
+ |
|
71 |
+void CClamavDoc::Serialize(CArchive& ar) |
|
72 |
+{ |
|
73 |
+ if (ar.IsStoring()) |
|
74 |
+ { |
|
75 |
+ // TODO: add storing code here |
|
76 |
+ } |
|
77 |
+ else |
|
78 |
+ { |
|
79 |
+ // TODO: add loading code here |
|
80 |
+ } |
|
81 |
+} |
|
82 |
+ |
|
83 |
+///////////////////////////////////////////////////////////////////////////// |
|
84 |
+// CClamavDoc diagnostics |
|
85 |
+ |
|
86 |
+#ifdef _DEBUG |
|
87 |
+void CClamavDoc::AssertValid() const |
|
88 |
+{ |
|
89 |
+ CDocument::AssertValid(); |
|
90 |
+} |
|
91 |
+ |
|
92 |
+void CClamavDoc::Dump(CDumpContext& dc) const |
|
93 |
+{ |
|
94 |
+ CDocument::Dump(dc); |
|
95 |
+} |
|
96 |
+#endif //_DEBUG |
|
97 |
+ |
|
98 |
+///////////////////////////////////////////////////////////////////////////// |
|
99 |
+// CClamavDoc commands |
0 | 100 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,61 @@ |
0 |
+// clamadoc.h : interface of the CClamavDoc class |
|
1 |
+// |
|
2 |
+///////////////////////////////////////////////////////////////////////////// |
|
3 |
+ |
|
4 |
+/* |
|
5 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
6 |
+ * |
|
7 |
+ * This program is free software; you can redistribute it and/or modify |
|
8 |
+ * it under the terms of the GNU General Public License as published by |
|
9 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
10 |
+ * (at your option) any later version. |
|
11 |
+ * |
|
12 |
+ * This program is distributed in the hope that it will be useful, |
|
13 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
+ * GNU General Public License for more details. |
|
16 |
+ * |
|
17 |
+ * You should have received a copy of the GNU General Public License |
|
18 |
+ * along with this program; if not, write to the Free Software |
|
19 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
20 |
+ */ |
|
21 |
+class CClamavDoc : public CDocument |
|
22 |
+{ |
|
23 |
+protected: // create from serialization only |
|
24 |
+ CClamavDoc(); |
|
25 |
+ DECLARE_DYNCREATE(CClamavDoc) |
|
26 |
+ |
|
27 |
+// Attributes |
|
28 |
+public: |
|
29 |
+ |
|
30 |
+// Operations |
|
31 |
+public: |
|
32 |
+ |
|
33 |
+// Overrides |
|
34 |
+ // ClassWizard generated virtual function overrides |
|
35 |
+ //{{AFX_VIRTUAL(CClamavDoc) |
|
36 |
+ public: |
|
37 |
+ virtual BOOL OnNewDocument(); |
|
38 |
+ //}}AFX_VIRTUAL |
|
39 |
+ |
|
40 |
+// Implementation |
|
41 |
+public: |
|
42 |
+ virtual ~CClamavDoc(); |
|
43 |
+ virtual void Serialize(CArchive& ar); // overridden for document i/o |
|
44 |
+#ifdef _DEBUG |
|
45 |
+ virtual void AssertValid() const; |
|
46 |
+ virtual void Dump(CDumpContext& dc) const; |
|
47 |
+#endif |
|
48 |
+ |
|
49 |
+protected: |
|
50 |
+ |
|
51 |
+// Generated message map functions |
|
52 |
+protected: |
|
53 |
+ //{{AFX_MSG(CClamavDoc) |
|
54 |
+ // NOTE - the ClassWizard will add and remove member functions here. |
|
55 |
+ // DO NOT EDIT what you see in these blocks of generated code ! |
|
56 |
+ //}}AFX_MSG |
|
57 |
+ DECLARE_MESSAGE_MAP() |
|
58 |
+}; |
|
59 |
+ |
|
60 |
+///////////////////////////////////////////////////////////////////////////// |
0 | 61 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,276 @@ |
0 |
+// clamav.cpp : Defines the class behaviors for the application. |
|
1 |
+// |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
5 |
+ * |
|
6 |
+ * This program is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * This program is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
+ * GNU General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU General Public License |
|
17 |
+ * along with this program; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
19 |
+ */ |
|
20 |
+#include "stdafx.h" |
|
21 |
+#include "resource.h" |
|
22 |
+ |
|
23 |
+#include "clamav.h" |
|
24 |
+ |
|
25 |
+#include "clamadoc.h" |
|
26 |
+#include "clamavw.h" |
|
27 |
+ |
|
28 |
+#include <winsock.h> |
|
29 |
+ |
|
30 |
+#ifdef _DEBUG |
|
31 |
+#undef THIS_FILE |
|
32 |
+static char BASED_CODE THIS_FILE[] = __FILE__; |
|
33 |
+#endif |
|
34 |
+ |
|
35 |
+///////////////////////////////////////////////////////////////////////////// |
|
36 |
+// CClamavApp |
|
37 |
+ |
|
38 |
+BEGIN_MESSAGE_MAP(CClamavApp, CWinApp) |
|
39 |
+ //{{AFX_MSG_MAP(CClamavApp) |
|
40 |
+ ON_COMMAND(ID_APP_ABOUT, OnAppAbout) |
|
41 |
+ ON_COMMAND(ID_FILE_NEW, OnFileNew) |
|
42 |
+ ON_COMMAND(ID_FILE_OPEN, OnFileOpen) |
|
43 |
+ ON_COMMAND(ID_SET_OPTIONS, OnSetOptions) |
|
44 |
+ //}}AFX_MSG_MAP |
|
45 |
+ // Standard file based document commands |
|
46 |
+ // ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) |
|
47 |
+ ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) |
|
48 |
+ // Standard print setup command |
|
49 |
+ ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) |
|
50 |
+END_MESSAGE_MAP() |
|
51 |
+ |
|
52 |
+///////////////////////////////////////////////////////////////////////////// |
|
53 |
+// CClamavApp construction |
|
54 |
+ |
|
55 |
+CClamavApp::CClamavApp() |
|
56 |
+{ |
|
57 |
+ // TODO: add construction code here, |
|
58 |
+ // Place all significant initialization in InitInstance |
|
59 |
+} |
|
60 |
+ |
|
61 |
+CClamavApp::~CClamavApp() |
|
62 |
+{ |
|
63 |
+} |
|
64 |
+ |
|
65 |
+///////////////////////////////////////////////////////////////////////////// |
|
66 |
+// The one and only CClamavApp object |
|
67 |
+ |
|
68 |
+CClamavApp theApp; |
|
69 |
+ |
|
70 |
+///////////////////////////////////////////////////////////////////////////// |
|
71 |
+// CClamavApp initialization |
|
72 |
+ |
|
73 |
+BOOL CClamavApp::InitInstance() |
|
74 |
+{ |
|
75 |
+ // Standard initialization |
|
76 |
+ // If you are not using these features and wish to reduce the size |
|
77 |
+ // of your final executable, you should remove from the following |
|
78 |
+ // the specific initialization routines you do not need. |
|
79 |
+ |
|
80 |
+ Enable3dControls(); |
|
81 |
+ |
|
82 |
+ LoadStdProfileSettings(); // Load standard INI file options (including MRU) |
|
83 |
+ |
|
84 |
+ // Register the application's document templates. Document templates |
|
85 |
+ // serve as the connection between documents, frame windows and views. |
|
86 |
+ |
|
87 |
+ CSingleDocTemplate* pDocTemplate; |
|
88 |
+ pDocTemplate = new CSingleDocTemplate( |
|
89 |
+ IDR_MAINFRAME, |
|
90 |
+ RUNTIME_CLASS(CClamavDoc), |
|
91 |
+ RUNTIME_CLASS(CMainFrame), // main SDI frame window |
|
92 |
+ RUNTIME_CLASS(CClamavView)); |
|
93 |
+ AddDocTemplate(pDocTemplate); |
|
94 |
+ |
|
95 |
+ // Start up Winsock |
|
96 |
+ WSAData wsaData; |
|
97 |
+ |
|
98 |
+ if(WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) { |
|
99 |
+ AfxMessageBox("WSAStartup() failed error code"); |
|
100 |
+ return FALSE; |
|
101 |
+ } |
|
102 |
+ clamServer = NULL; |
|
103 |
+ |
|
104 |
+ if (m_lpCmdLine[0] != '\0') { |
|
105 |
+ // TODO: add command line processing here |
|
106 |
+ // First argument is the server, second is the file to scan |
|
107 |
+ // TODO: more rigourous argument checking |
|
108 |
+ CString args = CString(m_lpCmdLine); |
|
109 |
+ |
|
110 |
+ int index = args.Find(' '); |
|
111 |
+ if(index == -1) |
|
112 |
+ exit(1); |
|
113 |
+ |
|
114 |
+ CString server = args.Left(index); |
|
115 |
+ const CString fileName = args.Mid(index + 1); |
|
116 |
+ unsigned short port; |
|
117 |
+ |
|
118 |
+ index = server.Find(':'); |
|
119 |
+ if(index != -1) { |
|
120 |
+ port = (unsigned short)atoi(server.Mid(index + 1)); |
|
121 |
+ server = server.Left(index); |
|
122 |
+ } else |
|
123 |
+ port = DEFAULT_PORT; |
|
124 |
+ |
|
125 |
+ TRY { |
|
126 |
+ clamServer = new ClamServer(server, port); |
|
127 |
+ } CATCH(CException, c) { |
|
128 |
+ AfxMessageBox("Can't establish a connection to " + server); |
|
129 |
+ c->Delete(); |
|
130 |
+ exit(1); |
|
131 |
+ } |
|
132 |
+ END_CATCH |
|
133 |
+ |
|
134 |
+ CWinApp::OnFileNew(); |
|
135 |
+ |
|
136 |
+ // TODO: set quarantine directory |
|
137 |
+ |
|
138 |
+ exit(clamServer->Scan(fileName, 0, (CMainFrame *)AfxGetMainWnd(), m_pMainWnd, TRUE, NULL) == TRUE); |
|
139 |
+ } else { |
|
140 |
+ // create a new (empty) document |
|
141 |
+ OnFileNew(); |
|
142 |
+ } |
|
143 |
+ |
|
144 |
+#ifdef _DEBUG |
|
145 |
+ afxTraceEnabled = TRUE; |
|
146 |
+#endif |
|
147 |
+ |
|
148 |
+ options = new COptions(); |
|
149 |
+ recursive = TRUE; |
|
150 |
+ |
|
151 |
+ return TRUE; |
|
152 |
+} |
|
153 |
+ |
|
154 |
+///////////////////////////////////////////////////////////////////////////// |
|
155 |
+// CAboutDlg dialog used for App About |
|
156 |
+ |
|
157 |
+class CAboutDlg : public CDialog |
|
158 |
+{ |
|
159 |
+public: |
|
160 |
+ CAboutDlg(); |
|
161 |
+ |
|
162 |
+// Dialog Data |
|
163 |
+ //{{AFX_DATA(CAboutDlg) |
|
164 |
+ enum { IDD = IDD_ABOUTBOX }; |
|
165 |
+ //}}AFX_DATA |
|
166 |
+ |
|
167 |
+// Implementation |
|
168 |
+protected: |
|
169 |
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support |
|
170 |
+ //{{AFX_MSG(CAboutDlg) |
|
171 |
+ // No message handlers |
|
172 |
+ //}}AFX_MSG |
|
173 |
+ DECLARE_MESSAGE_MAP() |
|
174 |
+}; |
|
175 |
+ |
|
176 |
+CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) |
|
177 |
+{ |
|
178 |
+ //{{AFX_DATA_INIT(CAboutDlg) |
|
179 |
+ //}}AFX_DATA_INIT |
|
180 |
+} |
|
181 |
+ |
|
182 |
+void CAboutDlg::DoDataExchange(CDataExchange* pDX) |
|
183 |
+{ |
|
184 |
+ CDialog::DoDataExchange(pDX); |
|
185 |
+ //{{AFX_DATA_MAP(CAboutDlg) |
|
186 |
+ //}}AFX_DATA_MAP |
|
187 |
+} |
|
188 |
+ |
|
189 |
+BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) |
|
190 |
+ //{{AFX_MSG_MAP(CAboutDlg) |
|
191 |
+ // No message handlers |
|
192 |
+ //}}AFX_MSG_MAP |
|
193 |
+END_MESSAGE_MAP() |
|
194 |
+ |
|
195 |
+// App command to run the dialog |
|
196 |
+void CClamavApp::OnAppAbout() |
|
197 |
+{ |
|
198 |
+ CAboutDlg aboutDlg; |
|
199 |
+ aboutDlg.DoModal(); |
|
200 |
+} |
|
201 |
+ |
|
202 |
+///////////////////////////////////////////////////////////////////////////// |
|
203 |
+// CClamavApp commands |
|
204 |
+ |
|
205 |
+int CClamavApp::ExitInstance() |
|
206 |
+{ |
|
207 |
+ // TODO: Add your specialized code here and/or call the base class |
|
208 |
+ if(clamServer) { |
|
209 |
+ delete clamServer; |
|
210 |
+ clamServer = NULL; |
|
211 |
+ } |
|
212 |
+ if(options) { |
|
213 |
+ delete options; |
|
214 |
+ options = NULL; |
|
215 |
+ } |
|
216 |
+ WSACleanup(); |
|
217 |
+ |
|
218 |
+ return CWinApp::ExitInstance(); |
|
219 |
+} |
|
220 |
+ |
|
221 |
+void CClamavApp::OnFileNew() |
|
222 |
+{ |
|
223 |
+ CWinApp::OnFileNew(); |
|
224 |
+ |
|
225 |
+ // TODO: Add your command handler code here |
|
226 |
+ |
|
227 |
+ // Open connection to a different server |
|
228 |
+ if(clamServer) { |
|
229 |
+ delete clamServer; |
|
230 |
+ clamServer = NULL; |
|
231 |
+ } |
|
232 |
+ TRY { |
|
233 |
+ clamServer = new ClamServer; |
|
234 |
+ } CATCH(CException, c) { |
|
235 |
+ clamServer = NULL; |
|
236 |
+ c->Delete(); |
|
237 |
+ } |
|
238 |
+ END_CATCH |
|
239 |
+} |
|
240 |
+ |
|
241 |
+void CClamavApp::OnFileOpen() |
|
242 |
+{ |
|
243 |
+ // TODO: Add your command handler code here |
|
244 |
+ |
|
245 |
+ CString newName; |
|
246 |
+ if (!DoPromptFileName(newName, AFX_IDS_OPENFILE, |
|
247 |
+ /*OFN_HIDEREADONLY |*/ OFN_FILEMUSTEXIST, TRUE, NULL)) |
|
248 |
+ return; // open cancelled |
|
249 |
+ |
|
250 |
+ // OpenDocumentFile(newName); |
|
251 |
+ this->Scan(newName); |
|
252 |
+} |
|
253 |
+ |
|
254 |
+// TODO: More than one scan happen at once but the progress bar gets confused |
|
255 |
+// Need a new scanner class. Create a new instance everytime we scan something |
|
256 |
+// Pass clamServer as a parameter |
|
257 |
+// Scanner *s = new Scanner(clamServer, 0, (CMainFrame *)AfxGetMainWnd(), m_pMainWnd, recursive, options->m_quarantineDir); |
|
258 |
+// if(s->clean()) |
|
259 |
+// AfxMessageBox("No virus found in " + filename); |
|
260 |
+// delete s; |
|
261 |
+ |
|
262 |
+void CClamavApp::Scan(const CString& filename) |
|
263 |
+{ |
|
264 |
+ if(clamServer == NULL) |
|
265 |
+ AfxMessageBox("You must connect to a clamd server first"); |
|
266 |
+ else if(clamServer->Scan(filename, 0, (CMainFrame *)AfxGetMainWnd(), m_pMainWnd, recursive, options->m_quarantineDir)) |
|
267 |
+ AfxMessageBox("No virus found in " + filename); |
|
268 |
+} |
|
269 |
+ |
|
270 |
+void CClamavApp::OnSetOptions() |
|
271 |
+{ |
|
272 |
+ // TODO: Add your command handler code here |
|
273 |
+ if(options->DoModal() == IDOK) |
|
274 |
+ recursive = options->m_recursive; |
|
275 |
+} |
0 | 276 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,73 @@ |
0 |
+// clamav.h : main header file for the CLAMAV application |
|
1 |
+// |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
5 |
+ * |
|
6 |
+ * This program is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * This program is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
+ * GNU General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU General Public License |
|
17 |
+ * along with this program; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
19 |
+ */ |
|
20 |
+#ifndef __AFXWIN_H__ |
|
21 |
+ #error include 'stdafx.h' before including this file for PCH |
|
22 |
+#endif |
|
23 |
+ |
|
24 |
+ |
|
25 |
+#include "resource.h" // main symbols |
|
26 |
+ |
|
27 |
+#include "mainfrm.h" |
|
28 |
+ |
|
29 |
+#include "options.h" |
|
30 |
+#include "progress.h" |
|
31 |
+#include "clamserver.h" |
|
32 |
+ |
|
33 |
+#define DEFAULT_PORT 3310 |
|
34 |
+ |
|
35 |
+///////////////////////////////////////////////////////////////////////////// |
|
36 |
+// CClamavApp: |
|
37 |
+// See clamav.cpp for the implementation of this class |
|
38 |
+// |
|
39 |
+ |
|
40 |
+class CClamavApp : public CWinApp |
|
41 |
+{ |
|
42 |
+public: |
|
43 |
+ CClamavApp(); |
|
44 |
+ ~CClamavApp(); |
|
45 |
+ void Scan(const CString& filename); |
|
46 |
+ |
|
47 |
+// Overrides |
|
48 |
+ // ClassWizard generated virtual function overrides |
|
49 |
+ //{{AFX_VIRTUAL(CClamavApp) |
|
50 |
+ public: |
|
51 |
+ virtual BOOL InitInstance(); |
|
52 |
+ virtual int ExitInstance(); |
|
53 |
+ //}}AFX_VIRTUAL |
|
54 |
+ |
|
55 |
+// Implementation |
|
56 |
+ |
|
57 |
+ //{{AFX_MSG(CClamavApp) |
|
58 |
+ afx_msg void OnAppAbout(); |
|
59 |
+ afx_msg void OnFileNew(); |
|
60 |
+ afx_msg void OnFileOpen(); |
|
61 |
+ afx_msg void OnSetOptions(); |
|
62 |
+ //}}AFX_MSG |
|
63 |
+ DECLARE_MESSAGE_MAP() |
|
64 |
+ |
|
65 |
+private: |
|
66 |
+ ClamServer *clamServer; |
|
67 |
+ COptions *options; |
|
68 |
+ BOOL recursive; // recursively scan folders? |
|
69 |
+}; |
|
70 |
+ |
|
71 |
+ |
|
72 |
+///////////////////////////////////////////////////////////////////////////// |
0 | 73 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,353 @@ |
0 |
+//Microsoft Visual C++ generated resource script. |
|
1 |
+// |
|
2 |
+#include "resource.h" |
|
3 |
+ |
|
4 |
+/* |
|
5 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
6 |
+ * |
|
7 |
+ * This program is free software; you can redistribute it and/or modify |
|
8 |
+ * it under the terms of the GNU General Public License as published by |
|
9 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
10 |
+ * (at your option) any later version. |
|
11 |
+ * |
|
12 |
+ * This program is distributed in the hope that it will be useful, |
|
13 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
+ * GNU General Public License for more details. |
|
16 |
+ * |
|
17 |
+ * You should have received a copy of the GNU General Public License |
|
18 |
+ * along with this program; if not, write to the Free Software |
|
19 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
20 |
+ */ |
|
21 |
+#define APSTUDIO_READONLY_SYMBOLS |
|
22 |
+///////////////////////////////////////////////////////////////////////////// |
|
23 |
+// |
|
24 |
+// Generated from the TEXTINCLUDE 2 resource. |
|
25 |
+// |
|
26 |
+#include "afxres.h" |
|
27 |
+ |
|
28 |
+///////////////////////////////////////////////////////////////////////////// |
|
29 |
+#undef APSTUDIO_READONLY_SYMBOLS |
|
30 |
+ |
|
31 |
+ |
|
32 |
+#ifdef APSTUDIO_INVOKED |
|
33 |
+///////////////////////////////////////////////////////////////////////////// |
|
34 |
+// |
|
35 |
+// TEXTINCLUDE |
|
36 |
+// |
|
37 |
+ |
|
38 |
+1 TEXTINCLUDE DISCARDABLE |
|
39 |
+BEGIN |
|
40 |
+ "resource.h\0" |
|
41 |
+END |
|
42 |
+ |
|
43 |
+2 TEXTINCLUDE DISCARDABLE |
|
44 |
+BEGIN |
|
45 |
+ "#include ""afxres.h""\r\n" |
|
46 |
+ "\0" |
|
47 |
+END |
|
48 |
+ |
|
49 |
+3 TEXTINCLUDE DISCARDABLE |
|
50 |
+BEGIN |
|
51 |
+ "#include ""res\\clamav.rc2"" // non-Microsoft Visual C++ edited resources\r\n" |
|
52 |
+ "\r\n" |
|
53 |
+ "#define _AFX_NO_SPLITTER_RESOURCES\r\n" |
|
54 |
+ "#define _AFX_NO_OLE_RESOURCES\r\n" |
|
55 |
+ "#define _AFX_NO_TRACKER_RESOURCES\r\n" |
|
56 |
+ "#define _AFX_NO_PROPERTY_RESOURCES\r\n" |
|
57 |
+ "#include ""afxres.rc"" \011// Standard components\r\n" |
|
58 |
+ "#include ""afxprint.rc""\011// printing/print preview resources\r\n" |
|
59 |
+ "\0" |
|
60 |
+END |
|
61 |
+ |
|
62 |
+///////////////////////////////////////////////////////////////////////////// |
|
63 |
+#endif // APSTUDIO_INVOKED |
|
64 |
+ |
|
65 |
+ |
|
66 |
+///////////////////////////////////////////////////////////////////////////// |
|
67 |
+// |
|
68 |
+// Icon |
|
69 |
+// |
|
70 |
+ |
|
71 |
+IDR_MAINFRAME ICON DISCARDABLE "res\\clamav.ico" |
|
72 |
+ |
|
73 |
+///////////////////////////////////////////////////////////////////////////// |
|
74 |
+// |
|
75 |
+// Bitmap |
|
76 |
+// |
|
77 |
+ |
|
78 |
+IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\toolbar.bmp" |
|
79 |
+ |
|
80 |
+///////////////////////////////////////////////////////////////////////////// |
|
81 |
+// |
|
82 |
+// Menu |
|
83 |
+// |
|
84 |
+ |
|
85 |
+IDR_MAINFRAME MENU PRELOAD DISCARDABLE |
|
86 |
+BEGIN |
|
87 |
+ POPUP "&File" |
|
88 |
+ BEGIN |
|
89 |
+ MENUITEM "&New Server\tCtrl+N", ID_FILE_NEW |
|
90 |
+ MENUITEM "&Scan File...\tCtrl+S", ID_FILE_OPEN |
|
91 |
+ MENUITEM "&Options...\tCtrl+O", ID_SET_OPTIONS |
|
92 |
+ MENUITEM SEPARATOR |
|
93 |
+ MENUITEM "E&xit", ID_APP_EXIT |
|
94 |
+ END |
|
95 |
+ POPUP "&Help" |
|
96 |
+ BEGIN |
|
97 |
+ MENUITEM "&About Clamav...", ID_APP_ABOUT |
|
98 |
+ END |
|
99 |
+END |
|
100 |
+ |
|
101 |
+ |
|
102 |
+///////////////////////////////////////////////////////////////////////////// |
|
103 |
+// |
|
104 |
+// Accelerator |
|
105 |
+// |
|
106 |
+ |
|
107 |
+IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE |
|
108 |
+BEGIN |
|
109 |
+ "N", ID_FILE_NEW, VIRTKEY, CONTROL |
|
110 |
+ "O", ID_FILE_OPEN, VIRTKEY, CONTROL |
|
111 |
+ "S", ID_FILE_SAVE, VIRTKEY, CONTROL |
|
112 |
+ "P", ID_FILE_PRINT, VIRTKEY, CONTROL |
|
113 |
+ "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL |
|
114 |
+ "X", ID_EDIT_CUT, VIRTKEY, CONTROL |
|
115 |
+ "C", ID_EDIT_COPY, VIRTKEY, CONTROL |
|
116 |
+ "V", ID_EDIT_PASTE, VIRTKEY, CONTROL |
|
117 |
+ VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT |
|
118 |
+ VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT |
|
119 |
+ VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL |
|
120 |
+ VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT |
|
121 |
+ VK_F6, ID_NEXT_PANE, VIRTKEY |
|
122 |
+ VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT |
|
123 |
+ VK_F1, ID_CONTEXT_HELP, VIRTKEY, SHIFT |
|
124 |
+ VK_F1, ID_HELP, VIRTKEY |
|
125 |
+END |
|
126 |
+ |
|
127 |
+ |
|
128 |
+///////////////////////////////////////////////////////////////////////////// |
|
129 |
+// |
|
130 |
+// Dialog |
|
131 |
+// |
|
132 |
+ |
|
133 |
+IDD_ABOUTBOX DIALOG DISCARDABLE 34, 22, 217, 55 |
|
134 |
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
|
135 |
+CAPTION "About clamav" |
|
136 |
+FONT 8, "MS Sans Serif" |
|
137 |
+BEGIN |
|
138 |
+ ICON IDR_MAINFRAME,IDC_STATIC,11,17,18,20 |
|
139 |
+ LTEXT "ClamAV Version 0.14",IDC_STATIC,40,10,76,8 |
|
140 |
+ LTEXT "Copyright \251 2004 Nigel Horne",IDC_STATIC,40,25,102,8 |
|
141 |
+ DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP |
|
142 |
+END |
|
143 |
+ |
|
144 |
+IDD_SERVERNAME DIALOG DISCARDABLE 0, 0, 187, 67 |
|
145 |
+STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
|
146 |
+CAPTION "ClamAV Server" |
|
147 |
+FONT 8, "MS Sans Serif" |
|
148 |
+BEGIN |
|
149 |
+ DEFPUSHBUTTON "OK",IDOK,131,6,50,14 |
|
150 |
+ PUSHBUTTON "Cancel",IDCANCEL,131,23,50,14 |
|
151 |
+ LTEXT "Server",IDC_STATIC,6,8,27,11 |
|
152 |
+ EDITTEXT IDC_SERVERNAME,46,7,72,14,ES_AUTOHSCROLL |
|
153 |
+ LTEXT "Port",IDC_STATIC,6,33,20,11 |
|
154 |
+ EDITTEXT IDC_SERVERPORT,46,32,54,13,ES_AUTOHSCROLL |
|
155 |
+END |
|
156 |
+ |
|
157 |
+IDD_PROGRESS DIALOG DISCARDABLE 0, 0, 287, 81 |
|
158 |
+STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
|
159 |
+CAPTION "Scanning" |
|
160 |
+FONT 8, "MS Sans Serif" |
|
161 |
+BEGIN |
|
162 |
+ DEFPUSHBUTTON "Stop",IDSTOP,117,56,50,14 |
|
163 |
+ CONTROL "Filename",IDC_FileName,"Static",SS_LEFTNOWORDWRAP | |
|
164 |
+ WS_GROUP,9,7,270,13 |
|
165 |
+ CTEXT "0%",IDC_Percent,116,28,52,18 |
|
166 |
+END |
|
167 |
+ |
|
168 |
+IDD_OPTIONS DIALOG DISCARDABLE 0, 0, 277, 90 |
|
169 |
+STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
|
170 |
+CAPTION "Options" |
|
171 |
+FONT 8, "MS Sans Serif" |
|
172 |
+BEGIN |
|
173 |
+ DEFPUSHBUTTON "OK",IDOK,214,42,50,14 |
|
174 |
+ PUSHBUTTON "Cancel",IDCANCEL,213,64,50,14 |
|
175 |
+ CONTROL "Recursively Scan Folders",IDC_RECURSIVE,"Button", |
|
176 |
+ BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,6,9,93,10 |
|
177 |
+ LTEXT "Quarantine Directory",IDC_STATIC,10,33,75,14 |
|
178 |
+ EDITTEXT IDC_QUARANTINE,91,29,120,18,ES_AUTOHSCROLL |
|
179 |
+END |
|
180 |
+ |
|
181 |
+ |
|
182 |
+///////////////////////////////////////////////////////////////////////////// |
|
183 |
+// |
|
184 |
+// Version |
|
185 |
+// |
|
186 |
+ |
|
187 |
+VS_VERSION_INFO VERSIONINFO |
|
188 |
+ FILEVERSION 1,0,0,1 |
|
189 |
+ PRODUCTVERSION 1,0,0,1 |
|
190 |
+ FILEFLAGSMASK 0x3fL |
|
191 |
+#ifdef _DEBUG |
|
192 |
+ FILEFLAGS 0x1L |
|
193 |
+#else |
|
194 |
+ FILEFLAGS 0x0L |
|
195 |
+#endif |
|
196 |
+ FILEOS 0x4L |
|
197 |
+ FILETYPE 0x1L |
|
198 |
+ FILESUBTYPE 0x0L |
|
199 |
+BEGIN |
|
200 |
+ BLOCK "StringFileInfo" |
|
201 |
+ BEGIN |
|
202 |
+ BLOCK "080904b0" |
|
203 |
+ BEGIN |
|
204 |
+ VALUE "CompanyName", "NJH Music\0" |
|
205 |
+ VALUE "FileDescription", "CLAMAV MFC Application\0" |
|
206 |
+ VALUE "FileVersion", "1, 0, 0, 1\0" |
|
207 |
+ VALUE "InternalName", "CLAMAV\0" |
|
208 |
+ VALUE "LegalCopyright", "Copyright \251 2004 Nigel Horne\0" |
|
209 |
+ VALUE "OriginalFilename", "CLAMAV.EXE\0" |
|
210 |
+ VALUE "ProductName", "CLAMAV Application\0" |
|
211 |
+ VALUE "ProductVersion", "1, 0, 0, 1\0" |
|
212 |
+ END |
|
213 |
+ END |
|
214 |
+ BLOCK "VarFileInfo" |
|
215 |
+ BEGIN |
|
216 |
+ VALUE "Translation", 0x809, 1200 |
|
217 |
+ END |
|
218 |
+END |
|
219 |
+ |
|
220 |
+ |
|
221 |
+ |
|
222 |
+///////////////////////////////////////////////////////////////////////////// |
|
223 |
+// |
|
224 |
+// String Table |
|
225 |
+// |
|
226 |
+ |
|
227 |
+STRINGTABLE PRELOAD DISCARDABLE |
|
228 |
+BEGIN |
|
229 |
+ IDR_MAINFRAME "clamav\n\nClamav\n\n\nClamav.Document\nClamav Document" |
|
230 |
+ IDD_OPTIONS "Set Options\nOptions" |
|
231 |
+END |
|
232 |
+ |
|
233 |
+STRINGTABLE PRELOAD DISCARDABLE |
|
234 |
+BEGIN |
|
235 |
+ AFX_IDS_APP_TITLE "clamav" |
|
236 |
+ AFX_IDS_IDLEMESSAGE "To scan a file/folder drag 'n' drop it onto the program" |
|
237 |
+ AFX_IDS_HELPMODEMESSAGE "Select an object on which to get Help" |
|
238 |
+END |
|
239 |
+ |
|
240 |
+STRINGTABLE DISCARDABLE |
|
241 |
+BEGIN |
|
242 |
+ ID_INDICATOR_EXT "EXT" |
|
243 |
+ ID_INDICATOR_CAPS "CAP" |
|
244 |
+ ID_INDICATOR_NUM "NUM" |
|
245 |
+ ID_INDICATOR_SCRL "SCRL" |
|
246 |
+ ID_INDICATOR_OVR "OVR" |
|
247 |
+ ID_INDICATOR_REC "REC" |
|
248 |
+END |
|
249 |
+ |
|
250 |
+STRINGTABLE DISCARDABLE |
|
251 |
+BEGIN |
|
252 |
+ ID_FILE_NEW "Connect to a different server\nNew" |
|
253 |
+ ID_FILE_OPEN "Scan File\nScan" |
|
254 |
+ ID_FILE_CLOSE "Close the active document\nClose" |
|
255 |
+ ID_FILE_SAVE "Save the active document\nSave" |
|
256 |
+ ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" |
|
257 |
+ ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" |
|
258 |
+ ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" |
|
259 |
+ ID_FILE_PRINT "Print the active document\nPrint" |
|
260 |
+ ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" |
|
261 |
+END |
|
262 |
+ |
|
263 |
+STRINGTABLE DISCARDABLE |
|
264 |
+BEGIN |
|
265 |
+ ID_APP_ABOUT "Display program information, version number and copyright\nAbout" |
|
266 |
+ ID_APP_EXIT "Quit the application; prompts to save documents\nExit" |
|
267 |
+ ID_HELP_INDEX "List Help topics\nHelp Index" |
|
268 |
+ ID_HELP_USING "Display instructions about how to use help\nHelp" |
|
269 |
+ ID_CONTEXT_HELP "Display help for clicked on buttons, menus and windows\nHelp" |
|
270 |
+ ID_HELP "Display help for current task or command\nHelp" |
|
271 |
+END |
|
272 |
+ |
|
273 |
+STRINGTABLE DISCARDABLE |
|
274 |
+BEGIN |
|
275 |
+ ID_FILE_MRU_FILE1 "Open this document" |
|
276 |
+ ID_FILE_MRU_FILE2 "Open this document" |
|
277 |
+ ID_FILE_MRU_FILE3 "Open this document" |
|
278 |
+ ID_FILE_MRU_FILE4 "Open this document" |
|
279 |
+END |
|
280 |
+ |
|
281 |
+STRINGTABLE DISCARDABLE |
|
282 |
+BEGIN |
|
283 |
+ ID_NEXT_PANE "Switch to the next window pane\nNext Pane" |
|
284 |
+ ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" |
|
285 |
+END |
|
286 |
+ |
|
287 |
+STRINGTABLE DISCARDABLE |
|
288 |
+BEGIN |
|
289 |
+ ID_WINDOW_SPLIT "Split the active window into panes\nSplit" |
|
290 |
+END |
|
291 |
+ |
|
292 |
+STRINGTABLE DISCARDABLE |
|
293 |
+BEGIN |
|
294 |
+ ID_EDIT_CLEAR "Erase the selection\nErase" |
|
295 |
+ ID_EDIT_CLEAR_ALL "Erase everything\nErase All" |
|
296 |
+ ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" |
|
297 |
+ ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" |
|
298 |
+ ID_EDIT_FIND "Find the specified text\nFind" |
|
299 |
+ ID_EDIT_PASTE "Insert Clipboard contents\nPaste" |
|
300 |
+ ID_EDIT_REPEAT "Repeat the last action\nRepeat" |
|
301 |
+ ID_EDIT_REPLACE "Replace specific text with different text\nReplace" |
|
302 |
+ ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" |
|
303 |
+ ID_EDIT_UNDO "Undo the last action\nUndo" |
|
304 |
+ ID_EDIT_REDO "Redo the previously undone action\nRedo" |
|
305 |
+END |
|
306 |
+ |
|
307 |
+STRINGTABLE DISCARDABLE |
|
308 |
+BEGIN |
|
309 |
+ ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" |
|
310 |
+ ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" |
|
311 |
+END |
|
312 |
+ |
|
313 |
+STRINGTABLE DISCARDABLE |
|
314 |
+BEGIN |
|
315 |
+ AFX_IDS_SCSIZE "Change the window size" |
|
316 |
+ AFX_IDS_SCMOVE "Change the window position" |
|
317 |
+ AFX_IDS_SCMINIMIZE "Reduce the window to an icon" |
|
318 |
+ AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" |
|
319 |
+ AFX_IDS_SCNEXTWINDOW "Switch to the next document window" |
|
320 |
+ AFX_IDS_SCPREVWINDOW "Switch to the previous document window" |
|
321 |
+ AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" |
|
322 |
+END |
|
323 |
+ |
|
324 |
+STRINGTABLE DISCARDABLE |
|
325 |
+BEGIN |
|
326 |
+ AFX_IDS_SCRESTORE "Restore the window to normal size" |
|
327 |
+ AFX_IDS_SCTASKLIST "Activate Task List" |
|
328 |
+END |
|
329 |
+ |
|
330 |
+STRINGTABLE DISCARDABLE |
|
331 |
+BEGIN |
|
332 |
+ AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" |
|
333 |
+END |
|
334 |
+ |
|
335 |
+ |
|
336 |
+#ifndef APSTUDIO_INVOKED |
|
337 |
+///////////////////////////////////////////////////////////////////////////// |
|
338 |
+// |
|
339 |
+// Generated from the TEXTINCLUDE 3 resource. |
|
340 |
+// |
|
341 |
+#include "res\clamav.rc2" // non-Microsoft Visual C++ edited resources |
|
342 |
+ |
|
343 |
+#define _AFX_NO_SPLITTER_RESOURCES |
|
344 |
+#define _AFX_NO_OLE_RESOURCES |
|
345 |
+#define _AFX_NO_TRACKER_RESOURCES |
|
346 |
+#define _AFX_NO_PROPERTY_RESOURCES |
|
347 |
+#include "afxres.rc" // Standard components |
|
348 |
+#include "afxprint.rc" // printing/print preview resources |
|
349 |
+ |
|
350 |
+///////////////////////////////////////////////////////////////////////////// |
|
351 |
+#endif // not APSTUDIO_INVOKED |
|
352 |
+ |
0 | 353 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,110 @@ |
0 |
+// clamavw.cpp : implementation of the CClamavView class |
|
1 |
+// |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
5 |
+ * |
|
6 |
+ * This program is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * This program is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
+ * GNU General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU General Public License |
|
17 |
+ * along with this program; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
19 |
+ */ |
|
20 |
+#include "stdafx.h" |
|
21 |
+#include "clamav.h" |
|
22 |
+ |
|
23 |
+#include "clamadoc.h" |
|
24 |
+#include "clamavw.h" |
|
25 |
+ |
|
26 |
+#ifdef _DEBUG |
|
27 |
+#undef THIS_FILE |
|
28 |
+static char BASED_CODE THIS_FILE[] = __FILE__; |
|
29 |
+#endif |
|
30 |
+ |
|
31 |
+///////////////////////////////////////////////////////////////////////////// |
|
32 |
+// CClamavView |
|
33 |
+ |
|
34 |
+IMPLEMENT_DYNCREATE(CClamavView, CView) |
|
35 |
+ |
|
36 |
+BEGIN_MESSAGE_MAP(CClamavView, CView) |
|
37 |
+ //{{AFX_MSG_MAP(CClamavView) |
|
38 |
+ //}}AFX_MSG_MAP |
|
39 |
+ // Standard printing commands |
|
40 |
+ ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) |
|
41 |
+ ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) |
|
42 |
+END_MESSAGE_MAP() |
|
43 |
+ |
|
44 |
+///////////////////////////////////////////////////////////////////////////// |
|
45 |
+// CClamavView construction/destruction |
|
46 |
+ |
|
47 |
+CClamavView::CClamavView() |
|
48 |
+{ |
|
49 |
+ // TODO: add construction code here |
|
50 |
+ |
|
51 |
+} |
|
52 |
+ |
|
53 |
+CClamavView::~CClamavView() |
|
54 |
+{ |
|
55 |
+} |
|
56 |
+ |
|
57 |
+///////////////////////////////////////////////////////////////////////////// |
|
58 |
+// CClamavView drawing |
|
59 |
+ |
|
60 |
+void CClamavView::OnDraw(CDC* pDC) |
|
61 |
+{ |
|
62 |
+ CClamavDoc* pDoc = GetDocument(); |
|
63 |
+ ASSERT_VALID(pDoc); |
|
64 |
+ |
|
65 |
+ // TODO: add draw code for native data here |
|
66 |
+} |
|
67 |
+ |
|
68 |
+///////////////////////////////////////////////////////////////////////////// |
|
69 |
+// CClamavView printing |
|
70 |
+ |
|
71 |
+BOOL CClamavView::OnPreparePrinting(CPrintInfo* pInfo) |
|
72 |
+{ |
|
73 |
+ // default preparation |
|
74 |
+ return DoPreparePrinting(pInfo); |
|
75 |
+} |
|
76 |
+ |
|
77 |
+void CClamavView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) |
|
78 |
+{ |
|
79 |
+ // TODO: add extra initialization before printing |
|
80 |
+} |
|
81 |
+ |
|
82 |
+void CClamavView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) |
|
83 |
+{ |
|
84 |
+ // TODO: add cleanup after printing |
|
85 |
+} |
|
86 |
+ |
|
87 |
+///////////////////////////////////////////////////////////////////////////// |
|
88 |
+// CClamavView diagnostics |
|
89 |
+ |
|
90 |
+#ifdef _DEBUG |
|
91 |
+void CClamavView::AssertValid() const |
|
92 |
+{ |
|
93 |
+ CView::AssertValid(); |
|
94 |
+} |
|
95 |
+ |
|
96 |
+void CClamavView::Dump(CDumpContext& dc) const |
|
97 |
+{ |
|
98 |
+ CView::Dump(dc); |
|
99 |
+} |
|
100 |
+ |
|
101 |
+CClamavDoc* CClamavView::GetDocument() // non-debug version is inline |
|
102 |
+{ |
|
103 |
+ ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CClamavDoc))); |
|
104 |
+ return (CClamavDoc*)m_pDocument; |
|
105 |
+} |
|
106 |
+#endif //_DEBUG |
|
107 |
+ |
|
108 |
+///////////////////////////////////////////////////////////////////////////// |
|
109 |
+// CClamavView message handlers |
0 | 110 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,68 @@ |
0 |
+// clamavw.h : interface of the CClamavView class |
|
1 |
+// |
|
2 |
+///////////////////////////////////////////////////////////////////////////// |
|
3 |
+ |
|
4 |
+/* |
|
5 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
6 |
+ * |
|
7 |
+ * This program is free software; you can redistribute it and/or modify |
|
8 |
+ * it under the terms of the GNU General Public License as published by |
|
9 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
10 |
+ * (at your option) any later version. |
|
11 |
+ * |
|
12 |
+ * This program is distributed in the hope that it will be useful, |
|
13 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
+ * GNU General Public License for more details. |
|
16 |
+ * |
|
17 |
+ * You should have received a copy of the GNU General Public License |
|
18 |
+ * along with this program; if not, write to the Free Software |
|
19 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
20 |
+ */ |
|
21 |
+class CClamavView : public CView |
|
22 |
+{ |
|
23 |
+protected: // create from serialization only |
|
24 |
+ CClamavView(); |
|
25 |
+ DECLARE_DYNCREATE(CClamavView) |
|
26 |
+ |
|
27 |
+// Attributes |
|
28 |
+public: |
|
29 |
+ CClamavDoc* GetDocument(); |
|
30 |
+ |
|
31 |
+// Operations |
|
32 |
+public: |
|
33 |
+ |
|
34 |
+// Overrides |
|
35 |
+ // ClassWizard generated virtual function overrides |
|
36 |
+ //{{AFX_VIRTUAL(CClamavView) |
|
37 |
+ public: |
|
38 |
+ virtual void OnDraw(CDC* pDC); // overridden to draw this view |
|
39 |
+ protected: |
|
40 |
+ virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); |
|
41 |
+ virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); |
|
42 |
+ virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); |
|
43 |
+ //}}AFX_VIRTUAL |
|
44 |
+ |
|
45 |
+// Implementation |
|
46 |
+public: |
|
47 |
+ virtual ~CClamavView(); |
|
48 |
+#ifdef _DEBUG |
|
49 |
+ virtual void AssertValid() const; |
|
50 |
+ virtual void Dump(CDumpContext& dc) const; |
|
51 |
+#endif |
|
52 |
+ |
|
53 |
+protected: |
|
54 |
+ |
|
55 |
+// Generated message map functions |
|
56 |
+protected: |
|
57 |
+ //{{AFX_MSG(CClamavView) |
|
58 |
+ //}}AFX_MSG |
|
59 |
+ DECLARE_MESSAGE_MAP() |
|
60 |
+}; |
|
61 |
+ |
|
62 |
+#ifndef _DEBUG // debug version in clamavw.cpp |
|
63 |
+inline CClamavDoc* CClamavView::GetDocument() |
|
64 |
+ { return (CClamavDoc*)m_pDocument; } |
|
65 |
+#endif |
|
66 |
+ |
|
67 |
+///////////////////////////////////////////////////////////////////////////// |
0 | 68 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,444 @@ |
0 |
+/* |
|
1 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
2 |
+ * |
|
3 |
+ * This program is free software; you can redistribute it and/or modify |
|
4 |
+ * it under the terms of the GNU General Public License as published by |
|
5 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
6 |
+ * (at your option) any later version. |
|
7 |
+ * |
|
8 |
+ * This program is distributed in the hope that it will be useful, |
|
9 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 |
+ * GNU General Public License for more details. |
|
12 |
+ * |
|
13 |
+ * You should have received a copy of the GNU General Public License |
|
14 |
+ * along with this program; if not, write to the Free Software |
|
15 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
16 |
+ */ |
|
17 |
+#include "stdafx.h" |
|
18 |
+ |
|
19 |
+#include "resource.h" |
|
20 |
+#include "clamav.h" |
|
21 |
+ |
|
22 |
+#include "mainfrm.h" |
|
23 |
+ |
|
24 |
+#include "clamserver.h" |
|
25 |
+#include "servername.h" |
|
26 |
+ |
|
27 |
+#include <io.h> |
|
28 |
+#include <winsock.h> |
|
29 |
+#include <sys/stat.h> |
|
30 |
+ |
|
31 |
+ClamServer::ClamServer(void) |
|
32 |
+{ |
|
33 |
+ if(!InitInstance()) |
|
34 |
+ THROW(new CException()); // FIXME: never freed |
|
35 |
+ |
|
36 |
+ progressBar = NULL; |
|
37 |
+ stopping = FALSE; |
|
38 |
+} |
|
39 |
+ |
|
40 |
+ClamServer::ClamServer(CString& serverName, unsigned short p) |
|
41 |
+{ |
|
42 |
+ LPTSTR hostname = serverName.GetBuffer(64); |
|
43 |
+ serverIP = inet_addr(hostname); |
|
44 |
+ |
|
45 |
+ if(serverIP == -1L) |
|
46 |
+ THROW(CException()); |
|
47 |
+ |
|
48 |
+ port = p; |
|
49 |
+ |
|
50 |
+ const int sock = CreateConnection(); |
|
51 |
+ |
|
52 |
+ if(sock < 0) |
|
53 |
+ THROW(CException()); |
|
54 |
+ |
|
55 |
+ progressBar = NULL; |
|
56 |
+ stopping = FALSE; |
|
57 |
+} |
|
58 |
+ |
|
59 |
+ClamServer::~ClamServer() |
|
60 |
+{ |
|
61 |
+ if(progressBar) { |
|
62 |
+ delete progressBar; |
|
63 |
+ progressBar = NULL; |
|
64 |
+ } |
|
65 |
+} |
|
66 |
+ |
|
67 |
+BOOL |
|
68 |
+ClamServer::InitInstance(void) |
|
69 |
+{ |
|
70 |
+ ServerName serverName; |
|
71 |
+ |
|
72 |
+ if(serverName.DoModal() == IDCANCEL) |
|
73 |
+ return FALSE; |
|
74 |
+ |
|
75 |
+ const char *hostname = serverName.m_serverName; |
|
76 |
+ |
|
77 |
+ serverIP = inet_addr(hostname); |
|
78 |
+ |
|
79 |
+ if(serverIP == -1L) { |
|
80 |
+ AfxMessageBox("Unknown host"); |
|
81 |
+ return FALSE; |
|
82 |
+ } |
|
83 |
+ |
|
84 |
+ port = (unsigned short)serverName.m_port; |
|
85 |
+ const int sock = CreateConnection(); |
|
86 |
+ |
|
87 |
+ if(sock < 0) |
|
88 |
+ return TRUE; |
|
89 |
+ |
|
90 |
+ return CheckConnection(sock); |
|
91 |
+} |
|
92 |
+ |
|
93 |
+const BOOL |
|
94 |
+ClamServer::CheckConnection(int sock) |
|
95 |
+{ |
|
96 |
+ if(send(sock, "PING\n", 5, 0) < 5) { |
|
97 |
+ closesocket(sock); |
|
98 |
+ AfxMessageBox("Can't talk to clamdserver"); |
|
99 |
+ return FALSE; |
|
100 |
+ } |
|
101 |
+ char ret[5]; |
|
102 |
+ if(recv(sock, ret, sizeof(ret), 0) <= 4) { |
|
103 |
+ closesocket(sock); |
|
104 |
+ AfxMessageBox("Can't receive from clamdserver"); |
|
105 |
+ return FALSE; |
|
106 |
+ } |
|
107 |
+ closesocket(sock); |
|
108 |
+ if(strncmp(ret, "PONG\n", 5) != 0) { |
|
109 |
+ AfxMessageBox("Is that server running clamd?"); |
|
110 |
+ return FALSE; |
|
111 |
+ } |
|
112 |
+ |
|
113 |
+ return TRUE; |
|
114 |
+} |
|
115 |
+ |
|
116 |
+int |
|
117 |
+ClamServer::CreateConnection(void) |
|
118 |
+{ |
|
119 |
+ const int sock = socket(AF_INET, SOCK_STREAM, 0); |
|
120 |
+ if(sock < 0) { |
|
121 |
+ AfxMessageBox("Can't create socket"); |
|
122 |
+ return FALSE; |
|
123 |
+ } |
|
124 |
+ |
|
125 |
+ struct sockaddr_in server; |
|
126 |
+ memset(&server, '\0', sizeof(struct sockaddr_in)); |
|
127 |
+ server.sin_family = PF_INET; |
|
128 |
+ server.sin_port = htons(port); |
|
129 |
+ server.sin_addr.s_addr = serverIP; |
|
130 |
+ |
|
131 |
+ // TODO display a message about connecting to the server. Include cancel button |
|
132 |
+ if(connect(sock, (struct sockaddr *)&server, sizeof(struct sockaddr)) < 0) { |
|
133 |
+ AfxMessageBox("Can't connect to clamdserver"); |
|
134 |
+ return FALSE; |
|
135 |
+ } |
|
136 |
+ return sock; |
|
137 |
+} |
|
138 |
+ |
|
139 |
+// TODO: on recursive pop up box with progress bar - to include cancel button |
|
140 |
+BOOL |
|
141 |
+ClamServer::Scan(const CString& filename, int level, CMainFrame *mainFrame, CWnd *parent, BOOL recursive, const CString& qDir) |
|
142 |
+{ |
|
143 |
+ if(level == 0) |
|
144 |
+ stopping = FALSE; |
|
145 |
+ else if(stopping) { |
|
146 |
+ if(progressBar) { |
|
147 |
+ delete progressBar; |
|
148 |
+ progressBar = NULL; |
|
149 |
+ } |
|
150 |
+ // mainFrame->ChangeStatusText(""); |
|
151 |
+ return TRUE; |
|
152 |
+ } |
|
153 |
+ |
|
154 |
+ // Don't scan folders "." and ".." |
|
155 |
+ if(filename[filename.GetLength() - 1] == '.') |
|
156 |
+ return TRUE; |
|
157 |
+ |
|
158 |
+ // I understand newer MFCs have 'PathIsDirectory' |
|
159 |
+ |
|
160 |
+ struct stat statb; |
|
161 |
+ |
|
162 |
+ if(stat(filename, &statb) < 0) { |
|
163 |
+ // It could be that we've been given a wild card match |
|
164 |
+ |
|
165 |
+ WIN32_FIND_DATA findData; |
|
166 |
+ |
|
167 |
+ HANDLE hFind = FindFirstFile(filename, &findData); |
|
168 |
+ |
|
169 |
+ if(hFind == INVALID_HANDLE_VALUE) { |
|
170 |
+ // No we haven't... |
|
171 |
+ AfxMessageBox(CString("Can't stat ") + filename); |
|
172 |
+ return TRUE; |
|
173 |
+ } |
|
174 |
+ return this->ScanWildCard(filename, level, mainFrame, parent, recursive, qDir); |
|
175 |
+ } |
|
176 |
+ |
|
177 |
+ if(progressBar && !stopping) { |
|
178 |
+ if(progressBar->IsStopPressed()) |
|
179 |
+ stopping = TRUE; |
|
180 |
+ progressBar->SetFilename(filename); |
|
181 |
+ } |
|
182 |
+ |
|
183 |
+ // mainFrame->ChangeStatusText(filename); // statusBar.ShowProgress |
|
184 |
+ // mainFrame->UpdateWindow(); |
|
185 |
+ |
|
186 |
+ if(statb.st_mode&S_IFDIR) { |
|
187 |
+ // Don't recurse unless we've been asked to |
|
188 |
+ |
|
189 |
+ if((!recursive) && (level > 0)) |
|
190 |
+ return TRUE; |
|
191 |
+ |
|
192 |
+ if(progressBar == NULL) { |
|
193 |
+ // FIXME: not all return paths remove this, possible memory leak |
|
194 |
+ progressBar = new CProgress(parent); |
|
195 |
+ progressBar->Create(IDD_PROGRESS, parent); |
|
196 |
+ } |
|
197 |
+ |
|
198 |
+ // Have been passed a folder. |
|
199 |
+ return this->ScanFolder(filename, level, mainFrame, parent, recursive, qDir); |
|
200 |
+ |
|
201 |
+ } |
|
202 |
+ |
|
203 |
+ if(progressBar && (level == 0)) { |
|
204 |
+ delete progressBar; |
|
205 |
+ progressBar = NULL; |
|
206 |
+ } |
|
207 |
+ |
|
208 |
+ const int commandSocket = CreateConnection(); |
|
209 |
+ |
|
210 |
+ if(commandSocket < 0) |
|
211 |
+ return TRUE; |
|
212 |
+ |
|
213 |
+ if(send(commandSocket, "STREAM\n", 7, 0) < 7) { |
|
214 |
+ closesocket(commandSocket); |
|
215 |
+ AfxMessageBox("Send failed to clamd"); |
|
216 |
+ return TRUE; |
|
217 |
+ } |
|
218 |
+ |
|
219 |
+ char buf[64]; |
|
220 |
+ int nbytes = ClamdRecv(commandSocket, buf, sizeof(buf) - 1); |
|
221 |
+ |
|
222 |
+ if(nbytes < 0) { |
|
223 |
+ closesocket(commandSocket); |
|
224 |
+ AfxMessageBox("recv failed from clamd getting PORT"); |
|
225 |
+ return TRUE; |
|
226 |
+ } |
|
227 |
+ buf[nbytes] = '\0'; |
|
228 |
+ |
|
229 |
+ unsigned short port; |
|
230 |
+ |
|
231 |
+ if(sscanf(buf, "PORT %hu\n", &port) != 1) { |
|
232 |
+ closesocket(commandSocket); |
|
233 |
+ AfxMessageBox("Didn't get PORT information from clamd"); |
|
234 |
+ |
|
235 |
+ return TRUE; |
|
236 |
+ } |
|
237 |
+ |
|
238 |
+ const int dataSocket = socket(AF_INET, SOCK_STREAM, 0); |
|
239 |
+ |
|
240 |
+ if(dataSocket < 0) { |
|
241 |
+ closesocket(commandSocket); |
|
242 |
+ AfxMessageBox("Can't create dataSocket"); |
|
243 |
+ return TRUE; |
|
244 |
+ } |
|
245 |
+ |
|
246 |
+ shutdown(dataSocket, 0); |
|
247 |
+ |
|
248 |
+ struct sockaddr_in reply; |
|
249 |
+ memset(&reply, '\0', sizeof(struct sockaddr_in)); |
|
250 |
+ reply.sin_family = PF_INET; |
|
251 |
+ reply.sin_port = htons(port); |
|
252 |
+ reply.sin_addr.s_addr = serverIP; |
|
253 |
+ |
|
254 |
+ const int rc = connect(dataSocket, (struct sockaddr *)&reply, sizeof(struct sockaddr_in)); |
|
255 |
+ if(rc < 0) { |
|
256 |
+ closesocket(commandSocket); |
|
257 |
+ closesocket(dataSocket); |
|
258 |
+ AfxMessageBox("Failed to connect to port given by clamd"); |
|
259 |
+ return TRUE; |
|
260 |
+ } |
|
261 |
+ |
|
262 |
+ CFile file; |
|
263 |
+ |
|
264 |
+ if(!file.Open(filename, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) { |
|
265 |
+ closesocket(commandSocket); |
|
266 |
+ closesocket(dataSocket); |
|
267 |
+ |
|
268 |
+ AfxMessageBox(CString("Can't open ") + filename + " to scan: "); |
|
269 |
+ return TRUE; |
|
270 |
+ } |
|
271 |
+ |
|
272 |
+ if(progressBar) |
|
273 |
+ progressBar->SetPercent(0); |
|
274 |
+ |
|
275 |
+ char buffer[1500]; // TODO: send in MTU byte chunks |
|
276 |
+ off_t bytesSent = (off_t)0; |
|
277 |
+ |
|
278 |
+ BOOL error = FALSE; |
|
279 |
+ |
|
280 |
+ while(((nbytes = file.Read(buffer, sizeof(buffer))) > 0) && !stopping) { |
|
281 |
+ // Every block see if someone wants to do something |
|
282 |
+ MSG Msg; |
|
283 |
+ |
|
284 |
+ if(::PeekMessage(&Msg, NULL, WM_NULL, WM_USER - 1, PM_NOREMOVE)) { |
|
285 |
+ ::PeekMessage(&Msg, NULL, WM_NULL, WM_USER - 1, PM_REMOVE); |
|
286 |
+ TranslateMessage(&Msg); |
|
287 |
+ DispatchMessage(&Msg); |
|
288 |
+ |
|
289 |
+ if((progressBar && progressBar->IsStopPressed()) || |
|
290 |
+ (Msg.message == WM_QUIT)) { |
|
291 |
+ error = TRUE; |
|
292 |
+ break; |
|
293 |
+ } |
|
294 |
+ } |
|
295 |
+ |
|
296 |
+ char buf[81]; |
|
297 |
+ if(ClamdRecv(commandSocket, buf, sizeof(buf) - 1, 0) > 0) { |
|
298 |
+ AfxMessageBox(buf); |
|
299 |
+ error = TRUE; |
|
300 |
+ break; |
|
301 |
+ } |
|
302 |
+ |
|
303 |
+ if(send(dataSocket, buffer, nbytes, 0) != nbytes) { |
|
304 |
+ AfxMessageBox("Send error to clamd"); |
|
305 |
+ error = TRUE; |
|
306 |
+ break; |
|
307 |
+ } |
|
308 |
+ |
|
309 |
+ if(progressBar) { |
|
310 |
+ bytesSent += nbytes; |
|
311 |
+ |
|
312 |
+ progressBar->SetPercent((int)(bytesSent * 100 / statb.st_size)); |
|
313 |
+ } |
|
314 |
+ } |
|
315 |
+ |
|
316 |
+ closesocket(dataSocket); |
|
317 |
+ |
|
318 |
+ file.Close(); |
|
319 |
+ |
|
320 |
+ if(error) { |
|
321 |
+ closesocket(commandSocket); |
|
322 |
+ stopping = TRUE; |
|
323 |
+ if(progressBar && (level == 0)) { |
|
324 |
+ delete progressBar; |
|
325 |
+ progressBar = NULL; |
|
326 |
+ } |
|
327 |
+ return TRUE; |
|
328 |
+ } |
|
329 |
+ |
|
330 |
+ nbytes = ClamdRecv(commandSocket, buffer, sizeof(buffer) - 1); |
|
331 |
+ |
|
332 |
+ closesocket(commandSocket); |
|
333 |
+ |
|
334 |
+ if(nbytes < 0) { |
|
335 |
+ AfxMessageBox("recv error getting status"); |
|
336 |
+ return TRUE; |
|
337 |
+ } else if(nbytes == 0) |
|
338 |
+ return TRUE; |
|
339 |
+ |
|
340 |
+ buffer[nbytes] = '\0'; |
|
341 |
+ |
|
342 |
+ if(strstr(buffer, "ERROR") != NULL) { |
|
343 |
+ AfxMessageBox(filename + " " + buffer); |
|
344 |
+ return TRUE; |
|
345 |
+ } |
|
346 |
+ |
|
347 |
+ // TODO: if we're scanning down a directory tree |
|
348 |
+ // don't display a popup box - update a dialog box |
|
349 |
+ // which tells us how far we are |
|
350 |
+ |
|
351 |
+ if(strstr(buffer, "FOUND") == NULL) |
|
352 |
+ return TRUE; |
|
353 |
+ AfxMessageBox(filename + " " + buffer); |
|
354 |
+ |
|
355 |
+ mainFrame->ChangeStatusText(filename + " " + buffer); // statusBar.ShowProgress |
|
356 |
+ |
|
357 |
+ return FALSE; |
|
358 |
+} |
|
359 |
+ |
|
360 |
+BOOL |
|
361 |
+ClamServer::ScanFolder(const CString& string, int level, CMainFrame *mainFrame, CWnd *parent, BOOL recursive, const CString& qDir) |
|
362 |
+{ |
|
363 |
+ return ScanWildCard(string + "\\*.*", level, mainFrame, parent, recursive, qDir); |
|
364 |
+} |
|
365 |
+ |
|
366 |
+BOOL |
|
367 |
+ClamServer::ScanWildCard(const CString& string, int level, CMainFrame *mainFrame, CWnd *parent, BOOL recursive, const CString& qDir) |
|
368 |
+{ |
|
369 |
+ if(stopping) |
|
370 |
+ return TRUE; |
|
371 |
+ |
|
372 |
+ WIN32_FIND_DATA findData; |
|
373 |
+ |
|
374 |
+ HANDLE hFind = FindFirstFile(string, &findData); |
|
375 |
+ |
|
376 |
+ if(hFind == INVALID_HANDLE_VALUE) |
|
377 |
+ // No files in this folder |
|
378 |
+ return TRUE; |
|
379 |
+ |
|
380 |
+ // Get to the filename stub - i.e. the file without the trailing \*.* |
|
381 |
+ const int index = string.Find("\\*.*"); |
|
382 |
+ |
|
383 |
+ ASSERT(index >= 0); |
|
384 |
+ |
|
385 |
+ const CString stub = string.Left(index); |
|
386 |
+ |
|
387 |
+ BOOL rc = TRUE; |
|
388 |
+ |
|
389 |
+ do |
|
390 |
+ //if(findData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) |
|
391 |
+ // Recurse into this folder/file only if recurse enabled |
|
392 |
+ // if(!this->Scan(filename + "\\" + findData.cFileName)) |
|
393 |
+ // break out as soon as one virus is found |
|
394 |
+ // TODO: optionally report all found |
|
395 |
+ // return FALSE; |
|
396 |
+ if(!this->Scan(stub + "\\" + findData.cFileName, level + 1, mainFrame, parent, recursive, qDir)) |
|
397 |
+ rc = FALSE; |
|
398 |
+ |
|
399 |
+ while(FindNextFile(hFind, &findData) && !stopping); |
|
400 |
+ |
|
401 |
+ if(progressBar && (level == 0)) { |
|
402 |
+ delete progressBar; |
|
403 |
+ progressBar = NULL; |
|
404 |
+ } |
|
405 |
+ |
|
406 |
+ return rc; |
|
407 |
+} |
|
408 |
+ |
|
409 |
+/* |
|
410 |
+ * Read from clamav - timeout if necessary |
|
411 |
+ * timeout defaults to 30 seconds, -1 = wait forever, 0 = poll |
|
412 |
+ * TODO: default time should be read from clamav.conf |
|
413 |
+ */ |
|
414 |
+int |
|
415 |
+ClamServer::ClamdRecv(int sock, char *buf, size_t len, int timeout /* = 30 */) |
|
416 |
+{ |
|
417 |
+ fd_set rfds; |
|
418 |
+ struct timeval tv; |
|
419 |
+ |
|
420 |
+ if(timeout == -1) |
|
421 |
+ return recv(sock, buf, len, 0); |
|
422 |
+ |
|
423 |
+ FD_ZERO(&rfds); |
|
424 |
+ FD_SET(sock, &rfds); |
|
425 |
+ |
|
426 |
+ tv.tv_sec = timeout; // TODO: from clamav.conf |
|
427 |
+ tv.tv_usec = 0; |
|
428 |
+ |
|
429 |
+ switch(select(sock + 1, &rfds, NULL, NULL, &tv)) { |
|
430 |
+ case -1: |
|
431 |
+ AfxMessageBox("select failed"); |
|
432 |
+ return -1; |
|
433 |
+ case 0: |
|
434 |
+ if(timeout != 0) |
|
435 |
+ AfxMessageBox("Timeout waiting for data from clamd"); |
|
436 |
+ return 0; |
|
437 |
+ } |
|
438 |
+ |
|
439 |
+ return recv(sock, buf, len, 0); |
|
440 |
+} |
|
441 |
+ |
|
442 |
+// void __cdecl __interrupt __far intFhandler(void) { |
|
443 |
+// } |
0 | 444 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,51 @@ |
0 |
+// Maintains connection to the clamd server |
|
1 |
+ |
|
2 |
+/* |
|
3 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
4 |
+ * |
|
5 |
+ * This program is free software; you can redistribute it and/or modify |
|
6 |
+ * it under the terms of the GNU General Public License as published by |
|
7 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
8 |
+ * (at your option) any later version. |
|
9 |
+ * |
|
10 |
+ * This program is distributed in the hope that it will be useful, |
|
11 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
+ * GNU General Public License for more details. |
|
14 |
+ * |
|
15 |
+ * You should have received a copy of the GNU General Public License |
|
16 |
+ * along with this program; if not, write to the Free Software |
|
17 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
18 |
+ */ |
|
19 |
+#ifndef _CLAMSERVER_H |
|
20 |
+ |
|
21 |
+#include "mainfrm.h" |
|
22 |
+ |
|
23 |
+class ClamServer { |
|
24 |
+ |
|
25 |
+public: |
|
26 |
+ ClamServer(void); |
|
27 |
+ ClamServer(CString& serverName, unsigned short port); |
|
28 |
+ ~ClamServer(); |
|
29 |
+ BOOL Scan(const CString& filename, int level, CMainFrame *mainFrame, |
|
30 |
+ CWnd *parent, BOOL recursive, const CString& qDir); |
|
31 |
+ // returns TRUE if the file is clean |
|
32 |
+ |
|
33 |
+private: |
|
34 |
+ BOOL InitInstance(void); |
|
35 |
+ int CreateConnection(void); |
|
36 |
+ const BOOL CheckConnection(int sock); |
|
37 |
+ BOOL ClamServer::ScanFolder(const CString& string, int level, CMainFrame *mainFrame, |
|
38 |
+ CWnd *parent, BOOL recursive, const CString& qDir); |
|
39 |
+ BOOL ClamServer::ScanWildCard(const CString& string, int level, CMainFrame *mainFrame, |
|
40 |
+ CWnd *parent, BOOL recursive, const CString& qDir); |
|
41 |
+ int ClamServer::ClamdRecv(int sock, char *buf, size_t len, int timeout = 30); |
|
42 |
+ |
|
43 |
+ long serverIP; // IPv4 address of the clamdserver (only one for now) |
|
44 |
+ unsigned short port; // host order |
|
45 |
+ BOOL stopping; // true if the application has been asked to stop |
|
46 |
+ CProgress *progressBar; |
|
47 |
+}; |
|
48 |
+ |
|
49 |
+#define _CLAMSERVER_H |
|
50 |
+#endif _CLAMSERVER_H |
0 | 51 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,175 @@ |
0 |
+// mainfrm.cpp : implementation of the CMainFrame class |
|
1 |
+// |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
5 |
+ * |
|
6 |
+ * This program is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * This program is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
+ * GNU General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU General Public License |
|
17 |
+ * along with this program; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
19 |
+ */ |
|
20 |
+#include "stdafx.h" |
|
21 |
+#include "mainfrm.h" |
|
22 |
+#include "resource.h" |
|
23 |
+#include "clamav.h" |
|
24 |
+ |
|
25 |
+#ifdef _DEBUG |
|
26 |
+#undef THIS_FILE |
|
27 |
+static char BASED_CODE THIS_FILE[] = __FILE__; |
|
28 |
+#endif |
|
29 |
+ |
|
30 |
+ |
|
31 |
+///////////////////////////////////////////////////////////////////////////// |
|
32 |
+// CMainFrame |
|
33 |
+ |
|
34 |
+IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) |
|
35 |
+ |
|
36 |
+BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) |
|
37 |
+ //{{AFX_MSG_MAP(CMainFrame) |
|
38 |
+ ON_WM_CREATE() |
|
39 |
+ ON_WM_DROPFILES() |
|
40 |
+ //}}AFX_MSG_MAP |
|
41 |
+ // Global help commands |
|
42 |
+ ON_COMMAND(ID_HELP_INDEX, CFrameWnd::OnHelpIndex) |
|
43 |
+ ON_COMMAND(ID_HELP_USING, CFrameWnd::OnHelpUsing) |
|
44 |
+ ON_COMMAND(ID_HELP, CFrameWnd::OnHelp) |
|
45 |
+ ON_COMMAND(ID_CONTEXT_HELP, CFrameWnd::OnContextHelp) |
|
46 |
+ ON_COMMAND(ID_DEFAULT_HELP, CFrameWnd::OnHelpIndex) |
|
47 |
+END_MESSAGE_MAP() |
|
48 |
+ |
|
49 |
+///////////////////////////////////////////////////////////////////////////// |
|
50 |
+// arrays of IDs used to initialize control bars |
|
51 |
+ |
|
52 |
+// toolbar buttons - IDs are command buttons |
|
53 |
+static UINT BASED_CODE buttons[] = |
|
54 |
+{ |
|
55 |
+ // same order as in the bitmap 'toolbar.bmp' |
|
56 |
+ ID_FILE_NEW, |
|
57 |
+ ID_FILE_OPEN, |
|
58 |
+ ID_FILE_SAVE, |
|
59 |
+ ID_SEPARATOR, |
|
60 |
+ ID_EDIT_CUT, |
|
61 |
+ ID_EDIT_COPY, |
|
62 |
+ ID_EDIT_PASTE, |
|
63 |
+ ID_SEPARATOR, |
|
64 |
+ ID_FILE_PRINT, |
|
65 |
+ ID_APP_ABOUT, |
|
66 |
+ ID_CONTEXT_HELP, |
|
67 |
+}; |
|
68 |
+ |
|
69 |
+static UINT BASED_CODE indicators[] = |
|
70 |
+{ |
|
71 |
+ ID_SEPARATOR, // status line indicator |
|
72 |
+ ID_INDICATOR_CAPS, |
|
73 |
+ ID_INDICATOR_NUM, |
|
74 |
+ ID_INDICATOR_SCRL, |
|
75 |
+}; |
|
76 |
+ |
|
77 |
+///////////////////////////////////////////////////////////////////////////// |
|
78 |
+// CMainFrame construction/destruction |
|
79 |
+ |
|
80 |
+CMainFrame::CMainFrame() |
|
81 |
+{ |
|
82 |
+ // TODO: add member initialization code here |
|
83 |
+ |
|
84 |
+} |
|
85 |
+ |
|
86 |
+CMainFrame::~CMainFrame() |
|
87 |
+{ |
|
88 |
+} |
|
89 |
+ |
|
90 |
+int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) |
|
91 |
+{ |
|
92 |
+ if (CFrameWnd::OnCreate(lpCreateStruct) == -1) |
|
93 |
+ return -1; |
|
94 |
+ |
|
95 |
+ |
|
96 |
+ if (!m_wndToolBar.Create(this) || |
|
97 |
+ !m_wndToolBar.LoadBitmap(IDR_MAINFRAME) || |
|
98 |
+ !m_wndToolBar.SetButtons(buttons, |
|
99 |
+ sizeof(buttons)/sizeof(UINT))) |
|
100 |
+ { |
|
101 |
+ TRACE0("Failed to create toolbar\n"); |
|
102 |
+ return -1; // fail to create |
|
103 |
+ } |
|
104 |
+ |
|
105 |
+ if (!m_wndStatusBar.Create(this) || |
|
106 |
+ !m_wndStatusBar.SetIndicators(indicators, |
|
107 |
+ sizeof(indicators)/sizeof(UINT))) |
|
108 |
+ { |
|
109 |
+ TRACE0("Failed to create status bar\n"); |
|
110 |
+ return -1; // fail to create |
|
111 |
+ } |
|
112 |
+ |
|
113 |
+ m_wndToolBar.DestroyWindow(); |
|
114 |
+#if 0 |
|
115 |
+ // TODO: Delete these three lines if you don't want the toolbar to |
|
116 |
+ // be dockable |
|
117 |
+ m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); |
|
118 |
+ EnableDocking(CBRS_ALIGN_ANY); |
|
119 |
+ DockControlBar(&m_wndToolBar); |
|
120 |
+ |
|
121 |
+ // TODO: Remove this if you don't want tool tips |
|
122 |
+ m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | |
|
123 |
+ CBRS_TOOLTIPS | CBRS_FLYBY); |
|
124 |
+#endif |
|
125 |
+ DragAcceptFiles(TRUE); |
|
126 |
+ |
|
127 |
+ return 0; |
|
128 |
+} |
|
129 |
+ |
|
130 |
+///////////////////////////////////////////////////////////////////////////// |
|
131 |
+// CMainFrame diagnostics |
|
132 |
+ |
|
133 |
+#ifdef _DEBUG |
|
134 |
+void CMainFrame::AssertValid() const |
|
135 |
+{ |
|
136 |
+ CFrameWnd::AssertValid(); |
|
137 |
+} |
|
138 |
+ |
|
139 |
+void CMainFrame::Dump(CDumpContext& dc) const |
|
140 |
+{ |
|
141 |
+ CFrameWnd::Dump(dc); |
|
142 |
+} |
|
143 |
+ |
|
144 |
+#endif //_DEBUG |
|
145 |
+ |
|
146 |
+void |
|
147 |
+CMainFrame::ChangeStatusText(const CString &text) |
|
148 |
+{ |
|
149 |
+ m_wndStatusBar.SetWindowText(text); |
|
150 |
+} |
|
151 |
+ |
|
152 |
+ |
|
153 |
+///////////////////////////////////////////////////////////////////////////// |
|
154 |
+// CMainFrame message handlers |
|
155 |
+ |
|
156 |
+void CMainFrame::OnDropFiles(HDROP hDropInfo) |
|
157 |
+{ |
|
158 |
+ // TODO: Add your message handler code here and/or call default |
|
159 |
+ |
|
160 |
+ const int nFiles = ::DragQueryFile(hDropInfo, 0xFFFFFFFF, NULL, 0); |
|
161 |
+ |
|
162 |
+ for(int i = 0; i < nFiles; i++) { |
|
163 |
+ TCHAR filename[_MAX_PATH]; |
|
164 |
+ |
|
165 |
+ ::DragQueryFile(hDropInfo, i, filename, _MAX_PATH); |
|
166 |
+ |
|
167 |
+ extern CClamavApp theApp; |
|
168 |
+ |
|
169 |
+ theApp.Scan(filename); |
|
170 |
+ } |
|
171 |
+ |
|
172 |
+ ::DragFinish(hDropInfo); |
|
173 |
+} |
|
174 |
+ |
0 | 175 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,67 @@ |
0 |
+// mainfrm.h : interface of the CMainFrame class |
|
1 |
+// |
|
2 |
+///////////////////////////////////////////////////////////////////////////// |
|
3 |
+ |
|
4 |
+/* |
|
5 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
6 |
+ * |
|
7 |
+ * This program is free software; you can redistribute it and/or modify |
|
8 |
+ * it under the terms of the GNU General Public License as published by |
|
9 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
10 |
+ * (at your option) any later version. |
|
11 |
+ * |
|
12 |
+ * This program is distributed in the hope that it will be useful, |
|
13 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
+ * GNU General Public License for more details. |
|
16 |
+ * |
|
17 |
+ * You should have received a copy of the GNU General Public License |
|
18 |
+ * along with this program; if not, write to the Free Software |
|
19 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
20 |
+ */ |
|
21 |
+#ifndef _MAINFRM_H |
|
22 |
+ |
|
23 |
+class CMainFrame : public CFrameWnd |
|
24 |
+{ |
|
25 |
+protected: // create from serialization only |
|
26 |
+ CMainFrame(); |
|
27 |
+ DECLARE_DYNCREATE(CMainFrame) |
|
28 |
+ |
|
29 |
+// Attributes |
|
30 |
+public: |
|
31 |
+ |
|
32 |
+// Operations |
|
33 |
+public: |
|
34 |
+ void ChangeStatusText(const CString &text); |
|
35 |
+ |
|
36 |
+// Overrides |
|
37 |
+ // ClassWizard generated virtual function overrides |
|
38 |
+ //{{AFX_VIRTUAL(CMainFrame) |
|
39 |
+ //}}AFX_VIRTUAL |
|
40 |
+ |
|
41 |
+// Implementation |
|
42 |
+public: |
|
43 |
+ virtual ~CMainFrame(); |
|
44 |
+#ifdef _DEBUG |
|
45 |
+ virtual void AssertValid() const; |
|
46 |
+ virtual void Dump(CDumpContext& dc) const; |
|
47 |
+#endif |
|
48 |
+ |
|
49 |
+protected: // control bar embedded members |
|
50 |
+ CStatusBar m_wndStatusBar; |
|
51 |
+ CToolBar m_wndToolBar; |
|
52 |
+ |
|
53 |
+// Generated message map functions |
|
54 |
+protected: |
|
55 |
+ //{{AFX_MSG(CMainFrame) |
|
56 |
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); |
|
57 |
+ afx_msg void OnDropFiles(HDROP hDropInfo); |
|
58 |
+ //}}AFX_MSG |
|
59 |
+ DECLARE_MESSAGE_MAP() |
|
60 |
+}; |
|
61 |
+ |
|
62 |
+#define _MAINFRM_H |
|
63 |
+#endif _MAINFRM_H |
|
64 |
+ |
|
65 |
+ |
|
66 |
+///////////////////////////////////////////////////////////////////////////// |
0 | 67 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,59 @@ |
0 |
+// options.cpp : implementation file |
|
1 |
+// |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
5 |
+ * |
|
6 |
+ * This program is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * This program is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
+ * GNU General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU General Public License |
|
17 |
+ * along with this program; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
19 |
+ */ |
|
20 |
+#include "stdafx.h" |
|
21 |
+#include "clamav.h" |
|
22 |
+ |
|
23 |
+#ifdef _DEBUG |
|
24 |
+#undef THIS_FILE |
|
25 |
+static char BASED_CODE THIS_FILE[] = __FILE__; |
|
26 |
+#endif |
|
27 |
+ |
|
28 |
+///////////////////////////////////////////////////////////////////////////// |
|
29 |
+// COptions dialog |
|
30 |
+ |
|
31 |
+ |
|
32 |
+COptions::COptions(CWnd* pParent /*=NULL*/) |
|
33 |
+ : CDialog(COptions::IDD, pParent) |
|
34 |
+{ |
|
35 |
+ //{{AFX_DATA_INIT(COptions) |
|
36 |
+ m_recursive = TRUE; |
|
37 |
+ m_quarantineDir = _T(""); |
|
38 |
+ //}}AFX_DATA_INIT |
|
39 |
+} |
|
40 |
+ |
|
41 |
+void COptions::DoDataExchange(CDataExchange* pDX) |
|
42 |
+{ |
|
43 |
+ CDialog::DoDataExchange(pDX); |
|
44 |
+ //{{AFX_DATA_MAP(COptions) |
|
45 |
+ DDX_Check(pDX, IDC_RECURSIVE, m_recursive); |
|
46 |
+ DDX_Text(pDX, IDC_QUARANTINE, m_quarantineDir); |
|
47 |
+ //}}AFX_DATA_MAP |
|
48 |
+} |
|
49 |
+ |
|
50 |
+ |
|
51 |
+BEGIN_MESSAGE_MAP(COptions, CDialog) |
|
52 |
+ //{{AFX_MSG_MAP(COptions) |
|
53 |
+ //}}AFX_MSG_MAP |
|
54 |
+END_MESSAGE_MAP() |
|
55 |
+ |
|
56 |
+ |
|
57 |
+///////////////////////////////////////////////////////////////////////////// |
|
58 |
+// COptions message handlers |
0 | 59 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,52 @@ |
0 |
+// options.h : header file |
|
1 |
+// |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
5 |
+ * |
|
6 |
+ * This program is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * This program is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
+ * GNU General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU General Public License |
|
17 |
+ * along with this program; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
19 |
+ */ |
|
20 |
+///////////////////////////////////////////////////////////////////////////// |
|
21 |
+// COptions dialog |
|
22 |
+ |
|
23 |
+class COptions : public CDialog |
|
24 |
+{ |
|
25 |
+// Construction |
|
26 |
+public: |
|
27 |
+ COptions(CWnd* pParent = NULL); // standard constructor |
|
28 |
+ |
|
29 |
+// Dialog Data |
|
30 |
+ //{{AFX_DATA(COptions) |
|
31 |
+ enum { IDD = IDD_OPTIONS }; |
|
32 |
+ BOOL m_recursive; |
|
33 |
+ CString m_quarantineDir; |
|
34 |
+ //}}AFX_DATA |
|
35 |
+ |
|
36 |
+ |
|
37 |
+// Overrides |
|
38 |
+ // ClassWizard generated virtual function overrides |
|
39 |
+ //{{AFX_VIRTUAL(COptions) |
|
40 |
+ protected: |
|
41 |
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support |
|
42 |
+ //}}AFX_VIRTUAL |
|
43 |
+ |
|
44 |
+// Implementation |
|
45 |
+protected: |
|
46 |
+ |
|
47 |
+ // Generated message map functions |
|
48 |
+ //{{AFX_MSG(COptions) |
|
49 |
+ //}}AFX_MSG |
|
50 |
+ DECLARE_MESSAGE_MAP() |
|
51 |
+}; |
0 | 52 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,117 @@ |
0 |
+// progress.cpp : implementation file |
|
1 |
+// |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
5 |
+ * |
|
6 |
+ * This program is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * This program is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
+ * GNU General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU General Public License |
|
17 |
+ * along with this program; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
19 |
+ */ |
|
20 |
+#include "stdafx.h" |
|
21 |
+#include "clamav.h" |
|
22 |
+ |
|
23 |
+#include "progress.h" |
|
24 |
+ |
|
25 |
+#ifdef _DEBUG |
|
26 |
+#undef THIS_FILE |
|
27 |
+static char BASED_CODE THIS_FILE[] = __FILE__; |
|
28 |
+#endif |
|
29 |
+ |
|
30 |
+///////////////////////////////////////////////////////////////////////////// |
|
31 |
+// CProgress dialog |
|
32 |
+ |
|
33 |
+ |
|
34 |
+CProgress::CProgress(CWnd* pParent) |
|
35 |
+ : CDialog(CProgress::IDD, pParent) |
|
36 |
+{ |
|
37 |
+ //{{AFX_DATA_INIT(CProgress) |
|
38 |
+ m_filename = _T("bar"); |
|
39 |
+ m_percent = _T(""); |
|
40 |
+ //}}AFX_DATA_INIT |
|
41 |
+ stopPressed = FALSE; |
|
42 |
+} |
|
43 |
+ |
|
44 |
+ |
|
45 |
+void CProgress::DoDataExchange(CDataExchange* pDX) |
|
46 |
+{ |
|
47 |
+ CDialog::DoDataExchange(pDX); |
|
48 |
+ //{{AFX_DATA_MAP(CProgress) |
|
49 |
+ DDX_Text(pDX, IDC_FileName, m_filename); |
|
50 |
+ DDX_Text(pDX, IDC_Percent, m_percent); |
|
51 |
+ //}}AFX_DATA_MAP |
|
52 |
+} |
|
53 |
+ |
|
54 |
+void |
|
55 |
+CProgress::SetFilename(const CString& filename) |
|
56 |
+{ |
|
57 |
+ if(stopPressed) |
|
58 |
+ return; |
|
59 |
+ |
|
60 |
+ m_filename = _T(filename); |
|
61 |
+ |
|
62 |
+ CStatic *text = (CStatic *)GetDlgItem(IDC_FileName); |
|
63 |
+ if(text) { |
|
64 |
+ text->SetWindowText(filename); |
|
65 |
+ // text->UpdateWindow(); |
|
66 |
+ percent = -1; // force a display when it changes |
|
67 |
+ } else |
|
68 |
+ AfxMessageBox("Can't find IDC_FileName"); |
|
69 |
+} |
|
70 |
+ |
|
71 |
+void |
|
72 |
+CProgress::SetPercent(int p) |
|
73 |
+{ |
|
74 |
+ if((p < 0) || (p > 100)) |
|
75 |
+ return; |
|
76 |
+ |
|
77 |
+ if(p == percent) |
|
78 |
+ return; |
|
79 |
+ |
|
80 |
+ char buf[5]; |
|
81 |
+ sprintf(buf, "%d%%", p); |
|
82 |
+ |
|
83 |
+ CStatic *text = (CStatic *)GetDlgItem(IDC_Percent); |
|
84 |
+ if(text) { |
|
85 |
+ text->SetWindowText(buf); |
|
86 |
+ // text->UpdateWindow(); |
|
87 |
+ percent = p; |
|
88 |
+ } else |
|
89 |
+ AfxMessageBox("Can't find IDC_Percent"); |
|
90 |
+} |
|
91 |
+ |
|
92 |
+const BOOL |
|
93 |
+CProgress::IsStopPressed(void) |
|
94 |
+{ |
|
95 |
+ return stopPressed; |
|
96 |
+} |
|
97 |
+ |
|
98 |
+BEGIN_MESSAGE_MAP(CProgress, CDialog) |
|
99 |
+ //{{AFX_MSG_MAP(CProgress) |
|
100 |
+ ON_BN_CLICKED(IDSTOP, OnStop) |
|
101 |
+ //}}AFX_MSG_MAP |
|
102 |
+END_MESSAGE_MAP() |
|
103 |
+ |
|
104 |
+ |
|
105 |
+///////////////////////////////////////////////////////////////////////////// |
|
106 |
+// CProgress message handlers |
|
107 |
+ |
|
108 |
+void CProgress::OnStop() |
|
109 |
+{ |
|
110 |
+ // TODO: Add your control notification handler code here |
|
111 |
+ stopPressed = TRUE; |
|
112 |
+ |
|
113 |
+ CButton *stopButton = (CButton *)GetDlgItem(IDSTOP); |
|
114 |
+ if(stopButton) |
|
115 |
+ stopButton->EnableWindow(FALSE); |
|
116 |
+} |
0 | 117 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,66 @@ |
0 |
+// progress.h : header file |
|
1 |
+// |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
5 |
+ * |
|
6 |
+ * This program is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * This program is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
+ * GNU General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU General Public License |
|
17 |
+ * along with this program; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
19 |
+ */ |
|
20 |
+///////////////////////////////////////////////////////////////////////////// |
|
21 |
+// CProgress dialog |
|
22 |
+ |
|
23 |
+#ifndef _PROGRESS_H |
|
24 |
+ |
|
25 |
+class CProgress : public CDialog |
|
26 |
+{ |
|
27 |
+// Construction |
|
28 |
+public: |
|
29 |
+ CProgress(CWnd* pParent = NULL); |
|
30 |
+ |
|
31 |
+ void SetFilename(const CString& filename); |
|
32 |
+ const BOOL IsStopPressed(void); |
|
33 |
+ void SetPercent(int percent); |
|
34 |
+ |
|
35 |
+// Dialog Data |
|
36 |
+ //{{AFX_DATA(CProgress) |
|
37 |
+ enum { IDD = IDD_PROGRESS }; |
|
38 |
+ CString m_filename; |
|
39 |
+ CString m_percent; |
|
40 |
+ //}}AFX_DATA |
|
41 |
+ |
|
42 |
+ |
|
43 |
+// Overrides |
|
44 |
+ // ClassWizard generated virtual function overrides |
|
45 |
+ //{{AFX_VIRTUAL(CProgress) |
|
46 |
+ protected: |
|
47 |
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support |
|
48 |
+ //}}AFX_VIRTUAL |
|
49 |
+ |
|
50 |
+// Implementation |
|
51 |
+protected: |
|
52 |
+ |
|
53 |
+ // Generated message map functions |
|
54 |
+ //{{AFX_MSG(CProgress) |
|
55 |
+ afx_msg void OnStop(); |
|
56 |
+ //}}AFX_MSG |
|
57 |
+ DECLARE_MESSAGE_MAP() |
|
58 |
+ |
|
59 |
+private: |
|
60 |
+ BOOL stopPressed; |
|
61 |
+ int percent; |
|
62 |
+}; |
|
63 |
+ |
|
64 |
+#define _PROGRESS_H |
|
65 |
+#endif _PROGRESS_H |
0 | 66 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,64 @@ |
0 |
+// servername.cpp : implementation file |
|
1 |
+// |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
5 |
+ * |
|
6 |
+ * This program is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * This program is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
+ * GNU General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU General Public License |
|
17 |
+ * along with this program; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
19 |
+ */ |
|
20 |
+#include "stdafx.h" |
|
21 |
+#include "clamav.h" |
|
22 |
+#include "servername.h" |
|
23 |
+ |
|
24 |
+#ifdef _DEBUG |
|
25 |
+#undef THIS_FILE |
|
26 |
+static char BASED_CODE THIS_FILE[] = __FILE__; |
|
27 |
+#endif |
|
28 |
+ |
|
29 |
+///////////////////////////////////////////////////////////////////////////// |
|
30 |
+// ServerName dialog |
|
31 |
+ |
|
32 |
+ |
|
33 |
+ServerName::ServerName(CWnd* pParent /*=NULL*/) |
|
34 |
+ : CDialog(ServerName::IDD, pParent) |
|
35 |
+{ |
|
36 |
+ //{{AFX_DATA_INIT(ServerName) |
|
37 |
+ m_serverName = _T(""); |
|
38 |
+ m_port = DEFAULT_PORT; |
|
39 |
+ //}}AFX_DATA_INIT |
|
40 |
+} |
|
41 |
+ |
|
42 |
+ |
|
43 |
+void ServerName::DoDataExchange(CDataExchange* pDX) |
|
44 |
+{ |
|
45 |
+ CDialog::DoDataExchange(pDX); |
|
46 |
+ //{{AFX_DATA_MAP(ServerName) |
|
47 |
+ DDX_Text(pDX, IDC_SERVERNAME, m_serverName); |
|
48 |
+ DDV_MaxChars(pDX, m_serverName, 20); |
|
49 |
+ DDX_Text(pDX, IDC_SERVERPORT, m_port); |
|
50 |
+ DDV_MinMaxUInt(pDX, m_port, 1, 65535); |
|
51 |
+ //}}AFX_DATA_MAP |
|
52 |
+} |
|
53 |
+ |
|
54 |
+ |
|
55 |
+BEGIN_MESSAGE_MAP(ServerName, CDialog) |
|
56 |
+ //{{AFX_MSG_MAP(ServerName) |
|
57 |
+ // NOTE: the ClassWizard will add message map macros here |
|
58 |
+ //}}AFX_MSG_MAP |
|
59 |
+END_MESSAGE_MAP() |
|
60 |
+ |
|
61 |
+ |
|
62 |
+///////////////////////////////////////////////////////////////////////////// |
|
63 |
+// ServerName message handlers |
0 | 64 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,55 @@ |
0 |
+// servername.h : header file |
|
1 |
+// |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
|
5 |
+ * |
|
6 |
+ * This program is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * This program is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
+ * GNU General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU General Public License |
|
17 |
+ * along with this program; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
19 |
+ */ |
|
20 |
+#include "resource.h" // main symbols |
|
21 |
+ |
|
22 |
+///////////////////////////////////////////////////////////////////////////// |
|
23 |
+// ServerName dialog |
|
24 |
+ |
|
25 |
+class ServerName : public CDialog |
|
26 |
+{ |
|
27 |
+// Construction |
|
28 |
+public: |
|
29 |
+ ServerName(CWnd* pParent = NULL); // standard constructor |
|
30 |
+ |
|
31 |
+// Dialog Data |
|
32 |
+ //{{AFX_DATA(ServerName) |
|
33 |
+ enum { IDD = IDD_SERVERNAME }; |
|
34 |
+ CString m_serverName; |
|
35 |
+ UINT m_port; |
|
36 |
+ //}}AFX_DATA |
|
37 |
+ |
|
38 |
+ |
|
39 |
+// Overrides |
|
40 |
+ // ClassWizard generated virtual function overrides |
|
41 |
+ //{{AFX_VIRTUAL(ServerName) |
|
42 |
+ protected: |
|
43 |
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support |
|
44 |
+ //}}AFX_VIRTUAL |
|
45 |
+ |
|
46 |
+// Implementation |
|
47 |
+protected: |
|
48 |
+ |
|
49 |
+ // Generated message map functions |
|
50 |
+ //{{AFX_MSG(ServerName) |
|
51 |
+ // NOTE: the ClassWizard will add member functions here |
|
52 |
+ //}}AFX_MSG |
|
53 |
+ DECLARE_MESSAGE_MAP() |
|
54 |
+}; |