mirror of https://github.com/Cisco-Talos/clamav
parent
d98d511f32
commit
6bc7cf0bba
@ -0,0 +1,100 @@ |
||||
// clamadoc.cpp : implementation of the CClamavDoc class
|
||||
//
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
|
||||
#include "stdafx.h" |
||||
#include "resource.h" |
||||
#include "clamav.h" |
||||
|
||||
#include "clamadoc.h" |
||||
|
||||
#ifdef _DEBUG |
||||
#undef THIS_FILE |
||||
static char BASED_CODE THIS_FILE[] = __FILE__; |
||||
#endif |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavDoc
|
||||
|
||||
IMPLEMENT_DYNCREATE(CClamavDoc, CDocument) |
||||
|
||||
BEGIN_MESSAGE_MAP(CClamavDoc, CDocument) |
||||
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP() |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavDoc construction/destruction
|
||||
|
||||
CClamavDoc::CClamavDoc() |
||||
{ |
||||
// TODO: add one-time construction code here
|
||||
|
||||
} |
||||
|
||||
CClamavDoc::~CClamavDoc() |
||||
{ |
||||
} |
||||
|
||||
BOOL CClamavDoc::OnNewDocument() |
||||
{ |
||||
if (!CDocument::OnNewDocument()) |
||||
return FALSE; |
||||
|
||||
// TODO: add reinitialization code here
|
||||
// (SDI documents will reuse this document)
|
||||
|
||||
return TRUE; |
||||
} |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavDoc serialization
|
||||
|
||||
void CClamavDoc::Serialize(CArchive& ar) |
||||
{ |
||||
if (ar.IsStoring()) |
||||
{ |
||||
// TODO: add storing code here
|
||||
} |
||||
else |
||||
{ |
||||
// TODO: add loading code here
|
||||
} |
||||
} |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavDoc diagnostics
|
||||
|
||||
#ifdef _DEBUG |
||||
void CClamavDoc::AssertValid() const |
||||
{ |
||||
CDocument::AssertValid(); |
||||
} |
||||
|
||||
void CClamavDoc::Dump(CDumpContext& dc) const |
||||
{ |
||||
CDocument::Dump(dc); |
||||
} |
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavDoc commands
|
@ -0,0 +1,61 @@ |
||||
// clamadoc.h : interface of the CClamavDoc class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
class CClamavDoc : public CDocument |
||||
{ |
||||
protected: // create from serialization only
|
||||
CClamavDoc(); |
||||
DECLARE_DYNCREATE(CClamavDoc) |
||||
|
||||
// Attributes
|
||||
public: |
||||
|
||||
// Operations
|
||||
public: |
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CClamavDoc)
|
||||
public: |
||||
virtual BOOL OnNewDocument(); |
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public: |
||||
virtual ~CClamavDoc(); |
||||
virtual void Serialize(CArchive& ar); // overridden for document i/o
|
||||
#ifdef _DEBUG |
||||
virtual void AssertValid() const; |
||||
virtual void Dump(CDumpContext& dc) const; |
||||
#endif |
||||
|
||||
protected: |
||||
|
||||
// Generated message map functions
|
||||
protected: |
||||
//{{AFX_MSG(CClamavDoc)
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP() |
||||
}; |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
@ -0,0 +1,276 @@ |
||||
// clamav.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
#include "stdafx.h" |
||||
#include "resource.h" |
||||
|
||||
#include "clamav.h" |
||||
|
||||
#include "clamadoc.h" |
||||
#include "clamavw.h" |
||||
|
||||
#include <winsock.h> |
||||
|
||||
#ifdef _DEBUG |
||||
#undef THIS_FILE |
||||
static char BASED_CODE THIS_FILE[] = __FILE__; |
||||
#endif |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavApp
|
||||
|
||||
BEGIN_MESSAGE_MAP(CClamavApp, CWinApp) |
||||
//{{AFX_MSG_MAP(CClamavApp)
|
||||
ON_COMMAND(ID_APP_ABOUT, OnAppAbout) |
||||
ON_COMMAND(ID_FILE_NEW, OnFileNew) |
||||
ON_COMMAND(ID_FILE_OPEN, OnFileOpen) |
||||
ON_COMMAND(ID_SET_OPTIONS, OnSetOptions) |
||||
//}}AFX_MSG_MAP
|
||||
// Standard file based document commands
|
||||
// ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
|
||||
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) |
||||
// Standard print setup command
|
||||
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) |
||||
END_MESSAGE_MAP() |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavApp construction
|
||||
|
||||
CClamavApp::CClamavApp() |
||||
{ |
||||
// TODO: add construction code here,
|
||||
// Place all significant initialization in InitInstance
|
||||
} |
||||
|
||||
CClamavApp::~CClamavApp() |
||||
{ |
||||
} |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The one and only CClamavApp object
|
||||
|
||||
CClamavApp theApp; |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavApp initialization
|
||||
|
||||
BOOL CClamavApp::InitInstance() |
||||
{ |
||||
// Standard initialization
|
||||
// If you are not using these features and wish to reduce the size
|
||||
// of your final executable, you should remove from the following
|
||||
// the specific initialization routines you do not need.
|
||||
|
||||
Enable3dControls(); |
||||
|
||||
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
|
||||
|
||||
// Register the application's document templates. Document templates
|
||||
// serve as the connection between documents, frame windows and views.
|
||||
|
||||
CSingleDocTemplate* pDocTemplate; |
||||
pDocTemplate = new CSingleDocTemplate( |
||||
IDR_MAINFRAME, |
||||
RUNTIME_CLASS(CClamavDoc), |
||||
RUNTIME_CLASS(CMainFrame), // main SDI frame window
|
||||
RUNTIME_CLASS(CClamavView)); |
||||
AddDocTemplate(pDocTemplate); |
||||
|
||||
// Start up Winsock
|
||||
WSAData wsaData; |
||||
|
||||
if(WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) { |
||||
AfxMessageBox("WSAStartup() failed error code"); |
||||
return FALSE; |
||||
} |
||||
clamServer = NULL; |
||||
|
||||
if (m_lpCmdLine[0] != '\0') { |
||||
// TODO: add command line processing here
|
||||
// First argument is the server, second is the file to scan
|
||||
// TODO: more rigourous argument checking
|
||||
CString args = CString(m_lpCmdLine); |
||||
|
||||
int index = args.Find(' '); |
||||
if(index == -1) |
||||
exit(1); |
||||
|
||||
CString server = args.Left(index); |
||||
const CString fileName = args.Mid(index + 1); |
||||
unsigned short port; |
||||
|
||||
index = server.Find(':'); |
||||
if(index != -1) { |
||||
port = (unsigned short)atoi(server.Mid(index + 1)); |
||||
server = server.Left(index);
|
||||
} else |
||||
port = DEFAULT_PORT; |
||||
|
||||
TRY { |
||||
clamServer = new ClamServer(server, port); |
||||
} CATCH(CException, c) { |
||||
AfxMessageBox("Can't establish a connection to " + server); |
||||
c->Delete(); |
||||
exit(1); |
||||
} |
||||
END_CATCH |
||||
|
||||
CWinApp::OnFileNew(); |
||||
|
||||
// TODO: set quarantine directory
|
||||
|
||||
exit(clamServer->Scan(fileName, 0, (CMainFrame *)AfxGetMainWnd(), m_pMainWnd, TRUE, NULL) == TRUE); |
||||
} else { |
||||
// create a new (empty) document
|
||||
OnFileNew(); |
||||
} |
||||
|
||||
#ifdef _DEBUG |
||||
afxTraceEnabled = TRUE; |
||||
#endif |
||||
|
||||
options = new COptions(); |
||||
recursive = TRUE; |
||||
|
||||
return TRUE; |
||||
} |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAboutDlg dialog used for App About
|
||||
|
||||
class CAboutDlg : public CDialog |
||||
{ |
||||
public: |
||||
CAboutDlg(); |
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CAboutDlg)
|
||||
enum { IDD = IDD_ABOUTBOX }; |
||||
//}}AFX_DATA
|
||||
|
||||
// Implementation
|
||||
protected: |
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//{{AFX_MSG(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP() |
||||
}; |
||||
|
||||
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) |
||||
{ |
||||
//{{AFX_DATA_INIT(CAboutDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
} |
||||
|
||||
void CAboutDlg::DoDataExchange(CDataExchange* pDX) |
||||
{ |
||||
CDialog::DoDataExchange(pDX); |
||||
//{{AFX_DATA_MAP(CAboutDlg)
|
||||
//}}AFX_DATA_MAP
|
||||
} |
||||
|
||||
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) |
||||
//{{AFX_MSG_MAP(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP() |
||||
|
||||
// App command to run the dialog
|
||||
void CClamavApp::OnAppAbout() |
||||
{ |
||||
CAboutDlg aboutDlg; |
||||
aboutDlg.DoModal(); |
||||
} |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavApp commands
|
||||
|
||||
int CClamavApp::ExitInstance()
|
||||
{ |
||||
// TODO: Add your specialized code here and/or call the base class
|
||||
if(clamServer) { |
||||
delete clamServer; |
||||
clamServer = NULL; |
||||
} |
||||
if(options) { |
||||
delete options; |
||||
options = NULL; |
||||
} |
||||
WSACleanup(); |
||||
|
||||
return CWinApp::ExitInstance(); |
||||
} |
||||
|
||||
void CClamavApp::OnFileNew()
|
||||
{ |
||||
CWinApp::OnFileNew(); |
||||
|
||||
// TODO: Add your command handler code here
|
||||
|
||||
// Open connection to a different server
|
||||
if(clamServer) { |
||||
delete clamServer; |
||||
clamServer = NULL; |
||||
} |
||||
TRY { |
||||
clamServer = new ClamServer; |
||||
} CATCH(CException, c) { |
||||
clamServer = NULL; |
||||
c->Delete(); |
||||
} |
||||
END_CATCH |
||||
} |
||||
|
||||
void CClamavApp::OnFileOpen()
|
||||
{ |
||||
// TODO: Add your command handler code here
|
||||
|
||||
CString newName; |
||||
if (!DoPromptFileName(newName, AFX_IDS_OPENFILE, |
||||
/*OFN_HIDEREADONLY |*/ OFN_FILEMUSTEXIST, TRUE, NULL)) |
||||
return; // open cancelled
|
||||
|
||||
// OpenDocumentFile(newName);
|
||||
this->Scan(newName); |
||||
} |
||||
|
||||
// TODO: More than one scan happen at once but the progress bar gets confused
|
||||
// Need a new scanner class. Create a new instance everytime we scan something
|
||||
// Pass clamServer as a parameter
|
||||
// Scanner *s = new Scanner(clamServer, 0, (CMainFrame *)AfxGetMainWnd(), m_pMainWnd, recursive, options->m_quarantineDir);
|
||||
// if(s->clean())
|
||||
// AfxMessageBox("No virus found in " + filename);
|
||||
// delete s;
|
||||
|
||||
void CClamavApp::Scan(const CString& filename) |
||||
{ |
||||
if(clamServer == NULL) |
||||
AfxMessageBox("You must connect to a clamd server first"); |
||||
else if(clamServer->Scan(filename, 0, (CMainFrame *)AfxGetMainWnd(), m_pMainWnd, recursive, options->m_quarantineDir)) |
||||
AfxMessageBox("No virus found in " + filename); |
||||
} |
||||
|
||||
void CClamavApp::OnSetOptions()
|
||||
{ |
||||
// TODO: Add your command handler code here
|
||||
if(options->DoModal() == IDOK) |
||||
recursive = options->m_recursive; |
||||
} |
@ -0,0 +1,73 @@ |
||||
// clamav.h : main header file for the CLAMAV application
|
||||
//
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
#ifndef __AFXWIN_H__ |
||||
#error include 'stdafx.h' before including this file for PCH |
||||
#endif |
||||
|
||||
|
||||
#include "resource.h" // main symbols |
||||
|
||||
#include "mainfrm.h" |
||||
|
||||
#include "options.h" |
||||
#include "progress.h" |
||||
#include "clamserver.h" |
||||
|
||||
#define DEFAULT_PORT 3310 |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavApp:
|
||||
// See clamav.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class CClamavApp : public CWinApp |
||||
{ |
||||
public: |
||||
CClamavApp(); |
||||
~CClamavApp(); |
||||
void Scan(const CString& filename); |
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CClamavApp)
|
||||
public: |
||||
virtual BOOL InitInstance(); |
||||
virtual int ExitInstance(); |
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
|
||||
//{{AFX_MSG(CClamavApp)
|
||||
afx_msg void OnAppAbout(); |
||||
afx_msg void OnFileNew(); |
||||
afx_msg void OnFileOpen(); |
||||
afx_msg void OnSetOptions(); |
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP() |
||||
|
||||
private: |
||||
ClamServer *clamServer; |
||||
COptions *options; |
||||
BOOL recursive; // recursively scan folders?
|
||||
}; |
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
@ -0,0 +1,353 @@ |
||||
//Microsoft Visual C++ generated resource script. |
||||
// |
||||
#include "resource.h" |
||||
|
||||
/* |
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
#define APSTUDIO_READONLY_SYMBOLS |
||||
///////////////////////////////////////////////////////////////////////////// |
||||
// |
||||
// Generated from the TEXTINCLUDE 2 resource. |
||||
// |
||||
#include "afxres.h" |
||||
|
||||
///////////////////////////////////////////////////////////////////////////// |
||||
#undef APSTUDIO_READONLY_SYMBOLS |
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED |
||||
///////////////////////////////////////////////////////////////////////////// |
||||
// |
||||
// TEXTINCLUDE |
||||
// |
||||
|
||||
1 TEXTINCLUDE DISCARDABLE |
||||
BEGIN |
||||
"resource.h\0" |
||||
END |
||||
|
||||
2 TEXTINCLUDE DISCARDABLE |
||||
BEGIN |
||||
"#include ""afxres.h""\r\n" |
||||
"\0" |
||||
END |
||||
|
||||
3 TEXTINCLUDE DISCARDABLE |
||||
BEGIN |
||||
"#include ""res\\clamav.rc2"" // non-Microsoft Visual C++ edited resources\r\n" |
||||
"\r\n" |
||||
"#define _AFX_NO_SPLITTER_RESOURCES\r\n" |
||||
"#define _AFX_NO_OLE_RESOURCES\r\n" |
||||
"#define _AFX_NO_TRACKER_RESOURCES\r\n" |
||||
"#define _AFX_NO_PROPERTY_RESOURCES\r\n" |
||||
"#include ""afxres.rc"" \011// Standard components\r\n" |
||||
"#include ""afxprint.rc""\011// printing/print preview resources\r\n" |
||||
"\0" |
||||
END |
||||
|
||||
///////////////////////////////////////////////////////////////////////////// |
||||
#endif // APSTUDIO_INVOKED |
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////// |
||||
// |
||||
// Icon |
||||
// |
||||
|
||||
IDR_MAINFRAME ICON DISCARDABLE "res\\clamav.ico" |
||||
|
||||
///////////////////////////////////////////////////////////////////////////// |
||||
// |
||||
// Bitmap |
||||
// |
||||
|
||||
IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\toolbar.bmp" |
||||
|
||||
///////////////////////////////////////////////////////////////////////////// |
||||
// |
||||
// Menu |
||||
// |
||||
|
||||
IDR_MAINFRAME MENU PRELOAD DISCARDABLE |
||||
BEGIN |
||||
POPUP "&File" |
||||
BEGIN |
||||
MENUITEM "&New Server\tCtrl+N", ID_FILE_NEW |
||||
MENUITEM "&Scan File...\tCtrl+S", ID_FILE_OPEN |
||||
MENUITEM "&Options...\tCtrl+O", ID_SET_OPTIONS |
||||
MENUITEM SEPARATOR |
||||
MENUITEM "E&xit", ID_APP_EXIT |
||||
END |
||||
POPUP "&Help" |
||||
BEGIN |
||||
MENUITEM "&About Clamav...", ID_APP_ABOUT |
||||
END |
||||
END |
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////// |
||||
// |
||||
// Accelerator |
||||
// |
||||
|
||||
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE |
||||
BEGIN |
||||
"N", ID_FILE_NEW, VIRTKEY, CONTROL |
||||
"O", ID_FILE_OPEN, VIRTKEY, CONTROL |
||||
"S", ID_FILE_SAVE, VIRTKEY, CONTROL |
||||
"P", ID_FILE_PRINT, VIRTKEY, CONTROL |
||||
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL |
||||
"X", ID_EDIT_CUT, VIRTKEY, CONTROL |
||||
"C", ID_EDIT_COPY, VIRTKEY, CONTROL |
||||
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL |
||||
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT |
||||
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT |
||||
VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL |
||||
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT |
||||
VK_F6, ID_NEXT_PANE, VIRTKEY |
||||
VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT |
||||
VK_F1, ID_CONTEXT_HELP, VIRTKEY, SHIFT |
||||
VK_F1, ID_HELP, VIRTKEY |
||||
END |
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////// |
||||
// |
||||
// Dialog |
||||
// |
||||
|
||||
IDD_ABOUTBOX DIALOG DISCARDABLE 34, 22, 217, 55 |
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
||||
CAPTION "About clamav" |
||||
FONT 8, "MS Sans Serif" |
||||
BEGIN |
||||
ICON IDR_MAINFRAME,IDC_STATIC,11,17,18,20 |
||||
LTEXT "ClamAV Version 0.14",IDC_STATIC,40,10,76,8 |
||||
LTEXT "Copyright \251 2004 Nigel Horne",IDC_STATIC,40,25,102,8 |
||||
DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP |
||||
END |
||||
|
||||
IDD_SERVERNAME DIALOG DISCARDABLE 0, 0, 187, 67 |
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
||||
CAPTION "ClamAV Server" |
||||
FONT 8, "MS Sans Serif" |
||||
BEGIN |
||||
DEFPUSHBUTTON "OK",IDOK,131,6,50,14 |
||||
PUSHBUTTON "Cancel",IDCANCEL,131,23,50,14 |
||||
LTEXT "Server",IDC_STATIC,6,8,27,11 |
||||
EDITTEXT IDC_SERVERNAME,46,7,72,14,ES_AUTOHSCROLL |
||||
LTEXT "Port",IDC_STATIC,6,33,20,11 |
||||
EDITTEXT IDC_SERVERPORT,46,32,54,13,ES_AUTOHSCROLL |
||||
END |
||||
|
||||
IDD_PROGRESS DIALOG DISCARDABLE 0, 0, 287, 81 |
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
||||
CAPTION "Scanning" |
||||
FONT 8, "MS Sans Serif" |
||||
BEGIN |
||||
DEFPUSHBUTTON "Stop",IDSTOP,117,56,50,14 |
||||
CONTROL "Filename",IDC_FileName,"Static",SS_LEFTNOWORDWRAP | |
||||
WS_GROUP,9,7,270,13 |
||||
CTEXT "0%",IDC_Percent,116,28,52,18 |
||||
END |
||||
|
||||
IDD_OPTIONS DIALOG DISCARDABLE 0, 0, 277, 90 |
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
||||
CAPTION "Options" |
||||
FONT 8, "MS Sans Serif" |
||||
BEGIN |
||||
DEFPUSHBUTTON "OK",IDOK,214,42,50,14 |
||||
PUSHBUTTON "Cancel",IDCANCEL,213,64,50,14 |
||||
CONTROL "Recursively Scan Folders",IDC_RECURSIVE,"Button", |
||||
BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,6,9,93,10 |
||||
LTEXT "Quarantine Directory",IDC_STATIC,10,33,75,14 |
||||
EDITTEXT IDC_QUARANTINE,91,29,120,18,ES_AUTOHSCROLL |
||||
END |
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////// |
||||
// |
||||
// Version |
||||
// |
||||
|
||||
VS_VERSION_INFO VERSIONINFO |
||||
FILEVERSION 1,0,0,1 |
||||
PRODUCTVERSION 1,0,0,1 |
||||
FILEFLAGSMASK 0x3fL |
||||
#ifdef _DEBUG |
||||
FILEFLAGS 0x1L |
||||
#else |
||||
FILEFLAGS 0x0L |
||||
#endif |
||||
FILEOS 0x4L |
||||
FILETYPE 0x1L |
||||
FILESUBTYPE 0x0L |
||||
BEGIN |
||||
BLOCK "StringFileInfo" |
||||
BEGIN |
||||
BLOCK "080904b0" |
||||
BEGIN |
||||
VALUE "CompanyName", "NJH Music\0" |
||||
VALUE "FileDescription", "CLAMAV MFC Application\0" |
||||
VALUE "FileVersion", "1, 0, 0, 1\0" |
||||
VALUE "InternalName", "CLAMAV\0" |
||||
VALUE "LegalCopyright", "Copyright \251 2004 Nigel Horne\0" |
||||
VALUE "OriginalFilename", "CLAMAV.EXE\0" |
||||
VALUE "ProductName", "CLAMAV Application\0" |
||||
VALUE "ProductVersion", "1, 0, 0, 1\0" |
||||
END |
||||
END |
||||
BLOCK "VarFileInfo" |
||||
BEGIN |
||||
VALUE "Translation", 0x809, 1200 |
||||
END |
||||
END |
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////// |
||||
// |
||||
// String Table |
||||
// |
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE |
||||
BEGIN |
||||
IDR_MAINFRAME "clamav\n\nClamav\n\n\nClamav.Document\nClamav Document" |
||||
IDD_OPTIONS "Set Options\nOptions" |
||||
END |
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE |
||||
BEGIN |
||||
AFX_IDS_APP_TITLE "clamav" |
||||
AFX_IDS_IDLEMESSAGE "To scan a file/folder drag 'n' drop it onto the program" |
||||
AFX_IDS_HELPMODEMESSAGE "Select an object on which to get Help" |
||||
END |
||||
|
||||
STRINGTABLE DISCARDABLE |
||||
BEGIN |
||||
ID_INDICATOR_EXT "EXT" |
||||
ID_INDICATOR_CAPS "CAP" |
||||
ID_INDICATOR_NUM "NUM" |
||||
ID_INDICATOR_SCRL "SCRL" |
||||
ID_INDICATOR_OVR "OVR" |
||||
ID_INDICATOR_REC "REC" |
||||
END |
||||
|
||||
STRINGTABLE DISCARDABLE |
||||
BEGIN |
||||
ID_FILE_NEW "Connect to a different server\nNew" |
||||
ID_FILE_OPEN "Scan File\nScan" |
||||
ID_FILE_CLOSE "Close the active document\nClose" |
||||
ID_FILE_SAVE "Save the active document\nSave" |
||||
ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" |
||||
ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" |
||||
ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" |
||||
ID_FILE_PRINT "Print the active document\nPrint" |
||||
ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" |
||||
END |
||||
|
||||
STRINGTABLE DISCARDABLE |
||||
BEGIN |
||||
ID_APP_ABOUT "Display program information, version number and copyright\nAbout" |
||||
ID_APP_EXIT "Quit the application; prompts to save documents\nExit" |
||||
ID_HELP_INDEX "List Help topics\nHelp Index" |
||||
ID_HELP_USING "Display instructions about how to use help\nHelp" |
||||
ID_CONTEXT_HELP "Display help for clicked on buttons, menus and windows\nHelp" |
||||
ID_HELP "Display help for current task or command\nHelp" |
||||
END |
||||
|
||||
STRINGTABLE DISCARDABLE |
||||
BEGIN |
||||
ID_FILE_MRU_FILE1 "Open this document" |
||||
ID_FILE_MRU_FILE2 "Open this document" |
||||
ID_FILE_MRU_FILE3 "Open this document" |
||||
ID_FILE_MRU_FILE4 "Open this document" |
||||
END |
||||
|
||||
STRINGTABLE DISCARDABLE |
||||
BEGIN |
||||
ID_NEXT_PANE "Switch to the next window pane\nNext Pane" |
||||
ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" |
||||
END |
||||
|
||||
STRINGTABLE DISCARDABLE |
||||
BEGIN |
||||
ID_WINDOW_SPLIT "Split the active window into panes\nSplit" |
||||
END |
||||
|
||||
STRINGTABLE DISCARDABLE |
||||
BEGIN |
||||
ID_EDIT_CLEAR "Erase the selection\nErase" |
||||
ID_EDIT_CLEAR_ALL "Erase everything\nErase All" |
||||
ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" |
||||
ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" |
||||
ID_EDIT_FIND "Find the specified text\nFind" |
||||
ID_EDIT_PASTE "Insert Clipboard contents\nPaste" |
||||
ID_EDIT_REPEAT "Repeat the last action\nRepeat" |
||||
ID_EDIT_REPLACE "Replace specific text with different text\nReplace" |
||||
ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" |
||||
ID_EDIT_UNDO "Undo the last action\nUndo" |
||||
ID_EDIT_REDO "Redo the previously undone action\nRedo" |
||||
END |
||||
|
||||
STRINGTABLE DISCARDABLE |
||||
BEGIN |
||||
ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" |
||||
ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" |
||||
END |
||||
|
||||
STRINGTABLE DISCARDABLE |
||||
BEGIN |
||||
AFX_IDS_SCSIZE "Change the window size" |
||||
AFX_IDS_SCMOVE "Change the window position" |
||||
AFX_IDS_SCMINIMIZE "Reduce the window to an icon" |
||||
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" |
||||
AFX_IDS_SCNEXTWINDOW "Switch to the next document window" |
||||
AFX_IDS_SCPREVWINDOW "Switch to the previous document window" |
||||
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" |
||||
END |
||||
|
||||
STRINGTABLE DISCARDABLE |
||||
BEGIN |
||||
AFX_IDS_SCRESTORE "Restore the window to normal size" |
||||
AFX_IDS_SCTASKLIST "Activate Task List" |
||||
END |
||||
|
||||
STRINGTABLE DISCARDABLE |
||||
BEGIN |
||||
AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" |
||||
END |
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED |
||||
///////////////////////////////////////////////////////////////////////////// |
||||
// |
||||
// Generated from the TEXTINCLUDE 3 resource. |
||||
// |
||||
#include "res\clamav.rc2" // non-Microsoft Visual C++ edited resources |
||||
|
||||
#define _AFX_NO_SPLITTER_RESOURCES |
||||
#define _AFX_NO_OLE_RESOURCES |
||||
#define _AFX_NO_TRACKER_RESOURCES |
||||
#define _AFX_NO_PROPERTY_RESOURCES |
||||
#include "afxres.rc" // Standard components |
||||
#include "afxprint.rc" // printing/print preview resources |
||||
|
||||
///////////////////////////////////////////////////////////////////////////// |
||||
#endif // not APSTUDIO_INVOKED |
||||
|
@ -0,0 +1,110 @@ |
||||
// clamavw.cpp : implementation of the CClamavView class
|
||||
//
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
#include "stdafx.h" |
||||
#include "clamav.h" |
||||
|
||||
#include "clamadoc.h" |
||||
#include "clamavw.h" |
||||
|
||||
#ifdef _DEBUG |
||||
#undef THIS_FILE |
||||
static char BASED_CODE THIS_FILE[] = __FILE__; |
||||
#endif |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavView
|
||||
|
||||
IMPLEMENT_DYNCREATE(CClamavView, CView) |
||||
|
||||
BEGIN_MESSAGE_MAP(CClamavView, CView) |
||||
//{{AFX_MSG_MAP(CClamavView)
|
||||
//}}AFX_MSG_MAP
|
||||
// Standard printing commands
|
||||
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) |
||||
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) |
||||
END_MESSAGE_MAP() |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavView construction/destruction
|
||||
|
||||
CClamavView::CClamavView() |
||||
{ |
||||
// TODO: add construction code here
|
||||
|
||||
} |
||||
|
||||
CClamavView::~CClamavView() |
||||
{ |
||||
} |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavView drawing
|
||||
|
||||
void CClamavView::OnDraw(CDC* pDC) |
||||
{ |
||||
CClamavDoc* pDoc = GetDocument(); |
||||
ASSERT_VALID(pDoc); |
||||
|
||||
// TODO: add draw code for native data here
|
||||
} |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavView printing
|
||||
|
||||
BOOL CClamavView::OnPreparePrinting(CPrintInfo* pInfo) |
||||
{ |
||||
// default preparation
|
||||
return DoPreparePrinting(pInfo); |
||||
} |
||||
|
||||
void CClamavView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) |
||||
{ |
||||
// TODO: add extra initialization before printing
|
||||
} |
||||
|
||||
void CClamavView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) |
||||
{ |
||||
// TODO: add cleanup after printing
|
||||
} |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavView diagnostics
|
||||
|
||||
#ifdef _DEBUG |
||||
void CClamavView::AssertValid() const |
||||
{ |
||||
CView::AssertValid(); |
||||
} |
||||
|
||||
void CClamavView::Dump(CDumpContext& dc) const |
||||
{ |
||||
CView::Dump(dc); |
||||
} |
||||
|
||||
CClamavDoc* CClamavView::GetDocument() // non-debug version is inline
|
||||
{ |
||||
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CClamavDoc))); |
||||
return (CClamavDoc*)m_pDocument; |
||||
} |
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClamavView message handlers
|
@ -0,0 +1,68 @@ |
||||
// clamavw.h : interface of the CClamavView class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
class CClamavView : public CView |
||||
{ |
||||
protected: // create from serialization only
|
||||
CClamavView(); |
||||
DECLARE_DYNCREATE(CClamavView) |
||||
|
||||
// Attributes
|
||||
public: |
||||
CClamavDoc* GetDocument(); |
||||
|
||||
// Operations
|
||||
public: |
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CClamavView)
|
||||
public: |
||||
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||
protected: |
||||
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); |
||||
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); |
||||
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); |
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public: |
||||
virtual ~CClamavView(); |
||||
#ifdef _DEBUG |
||||
virtual void AssertValid() const; |
||||
virtual void Dump(CDumpContext& dc) const; |
||||
#endif |
||||
|
||||
protected: |
||||
|
||||
// Generated message map functions
|
||||
protected: |
||||
//{{AFX_MSG(CClamavView)
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP() |
||||
}; |
||||
|
||||
#ifndef _DEBUG // debug version in clamavw.cpp
|
||||
inline CClamavDoc* CClamavView::GetDocument() |
||||
{ return (CClamavDoc*)m_pDocument; } |
||||
#endif |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
@ -0,0 +1,444 @@ |
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
#include "stdafx.h" |
||||
|
||||
#include "resource.h" |
||||
#include "clamav.h" |
||||
|
||||
#include "mainfrm.h" |
||||
|
||||
#include "clamserver.h" |
||||
#include "servername.h" |
||||
|
||||
#include <io.h> |
||||
#include <winsock.h> |
||||
#include <sys/stat.h> |
||||
|
||||
ClamServer::ClamServer(void) |
||||
{ |
||||
if(!InitInstance()) |
||||
THROW(new CException()); // FIXME: never freed
|
||||
|
||||
progressBar = NULL; |
||||
stopping = FALSE; |
||||
} |
||||
|
||||
ClamServer::ClamServer(CString& serverName, unsigned short p) |
||||
{ |
||||
LPTSTR hostname = serverName.GetBuffer(64);
|
||||
serverIP = inet_addr(hostname); |
||||
|
||||
if(serverIP == -1L) |
||||
THROW(CException()); |
||||
|
||||
port = p; |
||||
|
||||
const int sock = CreateConnection(); |
||||
|
||||
if(sock < 0) |
||||
THROW(CException()); |
||||
|
||||
progressBar = NULL; |
||||
stopping = FALSE; |
||||
} |
||||
|
||||
ClamServer::~ClamServer() |
||||
{ |
||||
if(progressBar) { |
||||
delete progressBar; |
||||
progressBar = NULL; |
||||
} |
||||
} |
||||
|
||||
BOOL |
||||
ClamServer::InitInstance(void) |
||||
{ |
||||
ServerName serverName; |
||||
|
||||
if(serverName.DoModal() == IDCANCEL) |
||||
return FALSE; |
||||
|
||||
const char *hostname = serverName.m_serverName; |
||||
|
||||
serverIP = inet_addr(hostname); |
||||
|
||||
if(serverIP == -1L) { |
||||
AfxMessageBox("Unknown host"); |
||||
return FALSE; |
||||
} |
||||
|
||||
port = (unsigned short)serverName.m_port; |
||||
const int sock = CreateConnection(); |
||||
|
||||
if(sock < 0) |
||||
return TRUE; |
||||
|
||||
return CheckConnection(sock); |
||||
} |
||||
|
||||
const BOOL |
||||
ClamServer::CheckConnection(int sock) |
||||
{ |
||||
if(send(sock, "PING\n", 5, 0) < 5) { |
||||
closesocket(sock); |
||||
AfxMessageBox("Can't talk to clamdserver"); |
||||
return FALSE; |
||||
} |
||||
char ret[5]; |
||||
if(recv(sock, ret, sizeof(ret), 0) <= 4) { |
||||
closesocket(sock); |
||||
AfxMessageBox("Can't receive from clamdserver"); |
||||
return FALSE; |
||||
} |
||||
closesocket(sock); |
||||
if(strncmp(ret, "PONG\n", 5) != 0) { |
||||
AfxMessageBox("Is that server running clamd?"); |
||||
return FALSE; |
||||
} |
||||
|
||||
return TRUE;
|
||||
} |
||||
|
||||
int |
||||
ClamServer::CreateConnection(void) |
||||
{ |
||||
const int sock = socket(AF_INET, SOCK_STREAM, 0); |
||||
if(sock < 0) { |
||||
AfxMessageBox("Can't create socket"); |
||||
return FALSE; |
||||
} |
||||
|
||||
struct sockaddr_in server; |
||||
memset(&server, '\0', sizeof(struct sockaddr_in)); |
||||
server.sin_family = PF_INET; |
||||
server.sin_port = htons(port); |
||||
server.sin_addr.s_addr = serverIP; |
||||
|
||||
// TODO display a message about connecting to the server. Include cancel button
|
||||
if(connect(sock, (struct sockaddr *)&server, sizeof(struct sockaddr)) < 0) { |
||||
AfxMessageBox("Can't connect to clamdserver"); |
||||
return FALSE; |
||||
} |
||||
return sock; |
||||
} |
||||
|
||||
// TODO: on recursive pop up box with progress bar - to include cancel button
|
||||
BOOL |
||||
ClamServer::Scan(const CString& filename, int level, CMainFrame *mainFrame, CWnd *parent, BOOL recursive, const CString& qDir) |
||||
{ |
||||
if(level == 0) |
||||
stopping = FALSE; |
||||
else if(stopping) { |
||||
if(progressBar) { |
||||
delete progressBar; |
||||
progressBar = NULL; |
||||
} |
||||
// mainFrame->ChangeStatusText("");
|
||||
return TRUE; |
||||
} |
||||
|
||||
// Don't scan folders "." and ".."
|
||||
if(filename[filename.GetLength() - 1] == '.') |
||||
return TRUE; |
||||
|
||||
// I understand newer MFCs have 'PathIsDirectory'
|
||||
|
||||
struct stat statb; |
||||
|
||||
if(stat(filename, &statb) < 0) { |
||||
// It could be that we've been given a wild card match
|
||||
|
||||
WIN32_FIND_DATA findData; |
||||
|
||||
HANDLE hFind = FindFirstFile(filename, &findData); |
||||
|
||||
if(hFind == INVALID_HANDLE_VALUE) { |
||||
// No we haven't...
|
||||
AfxMessageBox(CString("Can't stat ") + filename); |
||||
return TRUE; |
||||
} |
||||
return this->ScanWildCard(filename, level, mainFrame, parent, recursive, qDir); |
||||
} |
||||
|
||||
if(progressBar && !stopping) { |
||||
if(progressBar->IsStopPressed())
|
||||
stopping = TRUE; |
||||
progressBar->SetFilename(filename); |
||||
} |
||||
|
||||
// mainFrame->ChangeStatusText(filename); // statusBar.ShowProgress
|
||||
// mainFrame->UpdateWindow();
|
||||
|
||||
if(statb.st_mode&S_IFDIR) { |
||||
// Don't recurse unless we've been asked to
|
||||
|
||||
if((!recursive) && (level > 0)) |
||||
return TRUE; |
||||
|
||||
if(progressBar == NULL) { |
||||
// FIXME: not all return paths remove this, possible memory leak
|
||||
progressBar = new CProgress(parent); |
||||
progressBar->Create(IDD_PROGRESS, parent); |
||||
} |
||||
|
||||
// Have been passed a folder.
|
||||
return this->ScanFolder(filename, level, mainFrame, parent, recursive, qDir); |
||||
|
||||
} |
||||
|
||||
if(progressBar && (level == 0)) { |
||||
delete progressBar; |
||||
progressBar = NULL; |
||||
} |
||||
|
||||
const int commandSocket = CreateConnection(); |
||||
|
||||
if(commandSocket < 0) |
||||
return TRUE; |
||||
|
||||
if(send(commandSocket, "STREAM\n", 7, 0) < 7) { |
||||
closesocket(commandSocket); |
||||
AfxMessageBox("Send failed to clamd"); |
||||
return TRUE; |
||||
} |
||||
|
||||
char buf[64]; |
||||
int nbytes = ClamdRecv(commandSocket, buf, sizeof(buf) - 1); |
||||
|
||||
if(nbytes < 0) { |
||||
closesocket(commandSocket); |
||||
AfxMessageBox("recv failed from clamd getting PORT"); |
||||
return TRUE; |
||||
} |
||||
buf[nbytes] = '\0'; |
||||
|
||||
unsigned short port; |
||||
|
||||
if(sscanf(buf, "PORT %hu\n", &port) != 1) { |
||||
closesocket(commandSocket); |
||||
AfxMessageBox("Didn't get PORT information from clamd"); |
||||
|
||||
return TRUE; |
||||
} |
||||
|
||||
const int dataSocket = socket(AF_INET, SOCK_STREAM, 0); |
||||
|
||||
if(dataSocket < 0) { |
||||
closesocket(commandSocket); |
||||
AfxMessageBox("Can't create dataSocket"); |
||||
return TRUE; |
||||
} |
||||
|
||||
shutdown(dataSocket, 0); |
||||
|
||||
struct sockaddr_in reply; |
||||
memset(&reply, '\0', sizeof(struct sockaddr_in)); |
||||
reply.sin_family = PF_INET; |
||||
reply.sin_port = htons(port); |
||||
reply.sin_addr.s_addr = serverIP; |
||||
|
||||
const int rc = connect(dataSocket, (struct sockaddr *)&reply, sizeof(struct sockaddr_in)); |
||||
if(rc < 0) { |
||||
closesocket(commandSocket); |
||||
closesocket(dataSocket); |
||||
AfxMessageBox("Failed to connect to port given by clamd"); |
||||
return TRUE; |
||||
} |
||||
|
||||
CFile file; |
||||
|
||||
if(!file.Open(filename, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) { |
||||
closesocket(commandSocket); |
||||
closesocket(dataSocket); |
||||
|
||||
AfxMessageBox(CString("Can't open ") + filename + " to scan: "); |
||||
return TRUE; |
||||
} |
||||
|
||||
if(progressBar) |
||||
progressBar->SetPercent(0); |
||||
|
||||
char buffer[1500]; // TODO: send in MTU byte chunks
|
||||
off_t bytesSent = (off_t)0; |
||||
|
||||
BOOL error = FALSE; |
||||
|
||||
while(((nbytes = file.Read(buffer, sizeof(buffer))) > 0) && !stopping) { |
||||
// Every block see if someone wants to do something
|
||||
MSG Msg; |
||||
|
||||
if(::PeekMessage(&Msg, NULL, WM_NULL, WM_USER - 1, PM_NOREMOVE)) { |
||||
::PeekMessage(&Msg, NULL, WM_NULL, WM_USER - 1, PM_REMOVE); |
||||
TranslateMessage(&Msg); |
||||
DispatchMessage(&Msg); |
||||
|
||||
if((progressBar && progressBar->IsStopPressed()) || |
||||
(Msg.message == WM_QUIT)) { |
||||
error = TRUE; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
char buf[81]; |
||||
if(ClamdRecv(commandSocket, buf, sizeof(buf) - 1, 0) > 0) { |
||||
AfxMessageBox(buf); |
||||
error = TRUE; |
||||
break; |
||||
} |
||||
|
||||
if(send(dataSocket, buffer, nbytes, 0) != nbytes) { |
||||
AfxMessageBox("Send error to clamd"); |
||||
error = TRUE; |
||||
break; |
||||
} |
||||
|
||||
if(progressBar) { |
||||
bytesSent += nbytes; |
||||
|
||||
progressBar->SetPercent((int)(bytesSent * 100 / statb.st_size));
|
||||
} |
||||
} |
||||
|
||||
closesocket(dataSocket); |
||||
|
||||
file.Close(); |
||||
|
||||
if(error) { |
||||
closesocket(commandSocket); |
||||
stopping = TRUE; |
||||
if(progressBar && (level == 0)) { |
||||
delete progressBar; |
||||
progressBar = NULL; |
||||
}
|
||||
return TRUE; |
||||
} |
||||
|
||||
nbytes = ClamdRecv(commandSocket, buffer, sizeof(buffer) - 1); |
||||
|
||||
closesocket(commandSocket); |
||||
|
||||
if(nbytes < 0) { |
||||
AfxMessageBox("recv error getting status"); |
||||
return TRUE; |
||||
} else if(nbytes == 0) |
||||
return TRUE; |
||||
|
||||
buffer[nbytes] = '\0'; |
||||
|
||||
if(strstr(buffer, "ERROR") != NULL) { |
||||
AfxMessageBox(filename + " " + buffer); |
||||
return TRUE; |
||||
} |
||||
|
||||
// TODO: if we're scanning down a directory tree
|
||||
// don't display a popup box - update a dialog box
|
||||
// which tells us how far we are
|
||||
|
||||
if(strstr(buffer, "FOUND") == NULL) |
||||
return TRUE; |
||||
AfxMessageBox(filename + " " + buffer); |
||||
|
||||
mainFrame->ChangeStatusText(filename + " " + buffer); // statusBar.ShowProgress
|
||||
|
||||
return FALSE; |
||||
} |
||||
|
||||
BOOL |
||||
ClamServer::ScanFolder(const CString& string, int level, CMainFrame *mainFrame, CWnd *parent, BOOL recursive, const CString& qDir) |
||||
{ |
||||
return ScanWildCard(string + "\\*.*", level, mainFrame, parent, recursive, qDir); |
||||
} |
||||
|
||||
BOOL |
||||
ClamServer::ScanWildCard(const CString& string, int level, CMainFrame *mainFrame, CWnd *parent, BOOL recursive, const CString& qDir) |
||||
{ |
||||
if(stopping) |
||||
return TRUE; |
||||
|
||||
WIN32_FIND_DATA findData; |
||||
|
||||
HANDLE hFind = FindFirstFile(string, &findData); |
||||
|
||||
if(hFind == INVALID_HANDLE_VALUE) |
||||
// No files in this folder
|
||||
return TRUE; |
||||
|
||||
// Get to the filename stub - i.e. the file without the trailing \*.*
|
||||
const int index = string.Find("\\*.*"); |
||||
|
||||
ASSERT(index >= 0); |
||||
|
||||
const CString stub = string.Left(index); |
||||
|
||||
BOOL rc = TRUE;
|
||||
|
||||
do |
||||
//if(findData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
|
||||
// Recurse into this folder/file only if recurse enabled
|
||||
// if(!this->Scan(filename + "\\" + findData.cFileName))
|
||||
// break out as soon as one virus is found
|
||||
// TODO: optionally report all found
|
||||
// return FALSE;
|
||||
if(!this->Scan(stub + "\\" + findData.cFileName, level + 1, mainFrame, parent, recursive, qDir)) |
||||
rc = FALSE; |
||||
|
||||
while(FindNextFile(hFind, &findData) && !stopping); |
||||
|
||||
if(progressBar && (level == 0)) { |
||||
delete progressBar; |
||||
progressBar = NULL; |
||||
} |
||||
|
||||
return rc; |
||||
} |
||||
|
||||
/*
|
||||
* Read from clamav - timeout if necessary |
||||
* timeout defaults to 30 seconds, -1 = wait forever, 0 = poll |
||||
* TODO: default time should be read from clamav.conf |
||||
*/ |
||||
int |
||||
ClamServer::ClamdRecv(int sock, char *buf, size_t len, int timeout /* = 30 */) |
||||
{ |
||||
fd_set rfds; |
||||
struct timeval tv; |
||||
|
||||
if(timeout == -1) |
||||
return recv(sock, buf, len, 0); |
||||
|
||||
FD_ZERO(&rfds); |
||||
FD_SET(sock, &rfds); |
||||
|
||||
tv.tv_sec = timeout; // TODO: from clamav.conf
|
||||
tv.tv_usec = 0; |
||||
|
||||
switch(select(sock + 1, &rfds, NULL, NULL, &tv)) { |
||||
case -1: |
||||
AfxMessageBox("select failed"); |
||||
return -1; |
||||
case 0: |
||||
if(timeout != 0) |
||||
AfxMessageBox("Timeout waiting for data from clamd"); |
||||
return 0; |
||||
} |
||||
|
||||
return recv(sock, buf, len, 0); |
||||
} |
||||
|
||||
// void __cdecl __interrupt __far intFhandler(void) {
|
||||
// }
|
@ -0,0 +1,51 @@ |
||||
// Maintains connection to the clamd server
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
#ifndef _CLAMSERVER_H |
||||
|
||||
#include "mainfrm.h" |
||||
|
||||
class ClamServer { |
||||
|
||||
public: |
||||
ClamServer(void); |
||||
ClamServer(CString& serverName, unsigned short port); |
||||
~ClamServer(); |
||||
BOOL Scan(const CString& filename, int level, CMainFrame *mainFrame, |
||||
CWnd *parent, BOOL recursive, const CString& qDir); |
||||
// returns TRUE if the file is clean
|
||||
|
||||
private: |
||||
BOOL InitInstance(void); |
||||
int CreateConnection(void); |
||||
const BOOL CheckConnection(int sock); |
||||
BOOL ClamServer::ScanFolder(const CString& string, int level, CMainFrame *mainFrame, |
||||
CWnd *parent, BOOL recursive, const CString& qDir); |
||||
BOOL ClamServer::ScanWildCard(const CString& string, int level, CMainFrame *mainFrame, |
||||
CWnd *parent, BOOL recursive, const CString& qDir); |
||||
int ClamServer::ClamdRecv(int sock, char *buf, size_t len, int timeout = 30); |
||||
|
||||
long serverIP; // IPv4 address of the clamdserver (only one for now)
|
||||
unsigned short port; // host order
|
||||
BOOL stopping; // true if the application has been asked to stop
|
||||
CProgress *progressBar; |
||||
}; |
||||
|
||||
#define _CLAMSERVER_H |
||||
#endif _CLAMSERVER_H |
@ -0,0 +1,175 @@ |
||||
// mainfrm.cpp : implementation of the CMainFrame class
|
||||
//
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
#include "stdafx.h" |
||||
#include "mainfrm.h" |
||||
#include "resource.h" |
||||
#include "clamav.h" |
||||
|
||||
#ifdef _DEBUG |
||||
#undef THIS_FILE |
||||
static char BASED_CODE THIS_FILE[] = __FILE__; |
||||
#endif |
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) |
||||
|
||||
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) |
||||
//{{AFX_MSG_MAP(CMainFrame)
|
||||
ON_WM_CREATE() |
||||
ON_WM_DROPFILES() |
||||
//}}AFX_MSG_MAP
|
||||
// Global help commands
|
||||
ON_COMMAND(ID_HELP_INDEX, CFrameWnd::OnHelpIndex) |
||||
ON_COMMAND(ID_HELP_USING, CFrameWnd::OnHelpUsing) |
||||
ON_COMMAND(ID_HELP, CFrameWnd::OnHelp) |
||||
ON_COMMAND(ID_CONTEXT_HELP, CFrameWnd::OnContextHelp) |
||||
ON_COMMAND(ID_DEFAULT_HELP, CFrameWnd::OnHelpIndex) |
||||
END_MESSAGE_MAP() |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// arrays of IDs used to initialize control bars
|
||||
|
||||
// toolbar buttons - IDs are command buttons
|
||||
static UINT BASED_CODE buttons[] = |
||||
{ |
||||
// same order as in the bitmap 'toolbar.bmp'
|
||||
ID_FILE_NEW, |
||||
ID_FILE_OPEN, |
||||
ID_FILE_SAVE, |
||||
ID_SEPARATOR, |
||||
ID_EDIT_CUT, |
||||
ID_EDIT_COPY, |
||||
ID_EDIT_PASTE, |
||||
ID_SEPARATOR, |
||||
ID_FILE_PRINT, |
||||
ID_APP_ABOUT, |
||||
ID_CONTEXT_HELP, |
||||
}; |
||||
|
||||
static UINT BASED_CODE indicators[] = |
||||
{ |
||||
ID_SEPARATOR, // status line indicator
|
||||
ID_INDICATOR_CAPS, |
||||
ID_INDICATOR_NUM, |
||||
ID_INDICATOR_SCRL, |
||||
}; |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame construction/destruction
|
||||
|
||||
CMainFrame::CMainFrame() |
||||
{ |
||||
// TODO: add member initialization code here
|
||||
|
||||
} |
||||
|
||||
CMainFrame::~CMainFrame() |
||||
{ |
||||
} |
||||
|
||||
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) |
||||
{ |
||||
if (CFrameWnd::OnCreate(lpCreateStruct) == -1) |
||||
return -1; |
||||
|
||||
|
||||
if (!m_wndToolBar.Create(this) || |
||||
!m_wndToolBar.LoadBitmap(IDR_MAINFRAME) || |
||||
!m_wndToolBar.SetButtons(buttons, |
||||
sizeof(buttons)/sizeof(UINT))) |
||||
{ |
||||
TRACE0("Failed to create toolbar\n"); |
||||
return -1; // fail to create
|
||||
} |
||||
|
||||
if (!m_wndStatusBar.Create(this) || |
||||
!m_wndStatusBar.SetIndicators(indicators, |
||||
sizeof(indicators)/sizeof(UINT))) |
||||
{ |
||||
TRACE0("Failed to create status bar\n"); |
||||
return -1; // fail to create
|
||||
} |
||||
|
||||
m_wndToolBar.DestroyWindow(); |
||||
#if 0 |
||||
// TODO: Delete these three lines if you don't want the toolbar to
|
||||
// be dockable
|
||||
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); |
||||
EnableDocking(CBRS_ALIGN_ANY); |
||||
DockControlBar(&m_wndToolBar); |
||||
|
||||
// TODO: Remove this if you don't want tool tips
|
||||
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | |
||||
CBRS_TOOLTIPS | CBRS_FLYBY); |
||||
#endif |
||||
DragAcceptFiles(TRUE); |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame diagnostics
|
||||
|
||||
#ifdef _DEBUG |
||||
void CMainFrame::AssertValid() const |
||||
{ |
||||
CFrameWnd::AssertValid(); |
||||
} |
||||
|
||||
void CMainFrame::Dump(CDumpContext& dc) const |
||||
{ |
||||
CFrameWnd::Dump(dc); |
||||
} |
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
void |
||||
CMainFrame::ChangeStatusText(const CString &text) |
||||
{ |
||||
m_wndStatusBar.SetWindowText(text); |
||||
} |
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame message handlers
|
||||
|
||||
void CMainFrame::OnDropFiles(HDROP hDropInfo)
|
||||
{ |
||||
// TODO: Add your message handler code here and/or call default
|
||||
|
||||
const int nFiles = ::DragQueryFile(hDropInfo, 0xFFFFFFFF, NULL, 0); |
||||
|
||||
for(int i = 0; i < nFiles; i++) { |
||||
TCHAR filename[_MAX_PATH]; |
||||
|
||||
::DragQueryFile(hDropInfo, i, filename, _MAX_PATH); |
||||
|
||||
extern CClamavApp theApp; |
||||
|
||||
theApp.Scan(filename); |
||||
} |
||||
|
||||
::DragFinish(hDropInfo); |
||||
} |
||||
|
@ -0,0 +1,67 @@ |
||||
// mainfrm.h : interface of the CMainFrame class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
#ifndef _MAINFRM_H |
||||
|
||||
class CMainFrame : public CFrameWnd |
||||
{ |
||||
protected: // create from serialization only
|
||||
CMainFrame(); |
||||
DECLARE_DYNCREATE(CMainFrame) |
||||
|
||||
// Attributes
|
||||
public: |
||||
|
||||
// Operations
|
||||
public: |
||||
void ChangeStatusText(const CString &text); |
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMainFrame)
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public: |
||||
virtual ~CMainFrame(); |
||||
#ifdef _DEBUG |
||||
virtual void AssertValid() const; |
||||
virtual void Dump(CDumpContext& dc) const; |
||||
#endif |
||||
|
||||
protected: // control bar embedded members
|
||||
CStatusBar m_wndStatusBar; |
||||
CToolBar m_wndToolBar; |
||||
|
||||
// Generated message map functions
|
||||
protected: |
||||
//{{AFX_MSG(CMainFrame)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); |
||||
afx_msg void OnDropFiles(HDROP hDropInfo); |
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP() |
||||
}; |
||||
|
||||
#define _MAINFRM_H |
||||
#endif _MAINFRM_H |
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
@ -0,0 +1,59 @@ |
||||
// options.cpp : implementation file
|
||||
//
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
#include "stdafx.h" |
||||
#include "clamav.h" |
||||
|
||||
#ifdef _DEBUG |
||||
#undef THIS_FILE |
||||
static char BASED_CODE THIS_FILE[] = __FILE__; |
||||
#endif |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptions dialog
|
||||
|
||||
|
||||
COptions::COptions(CWnd* pParent /*=NULL*/) |
||||
: CDialog(COptions::IDD, pParent) |
||||
{ |
||||
//{{AFX_DATA_INIT(COptions)
|
||||
m_recursive = TRUE; |
||||
m_quarantineDir = _T(""); |
||||
//}}AFX_DATA_INIT
|
||||
} |
||||
|
||||
void COptions::DoDataExchange(CDataExchange* pDX) |
||||
{ |
||||
CDialog::DoDataExchange(pDX); |
||||
//{{AFX_DATA_MAP(COptions)
|
||||
DDX_Check(pDX, IDC_RECURSIVE, m_recursive); |
||||
DDX_Text(pDX, IDC_QUARANTINE, m_quarantineDir); |
||||
//}}AFX_DATA_MAP
|
||||
} |
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(COptions, CDialog) |
||||
//{{AFX_MSG_MAP(COptions)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP() |
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptions message handlers
|
@ -0,0 +1,52 @@ |
||||
// options.h : header file
|
||||
//
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COptions dialog
|
||||
|
||||
class COptions : public CDialog |
||||
{ |
||||
// Construction
|
||||
public: |
||||
COptions(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(COptions)
|
||||
enum { IDD = IDD_OPTIONS }; |
||||
BOOL m_recursive; |
||||
CString m_quarantineDir; |
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(COptions)
|
||||
protected: |
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected: |
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(COptions)
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP() |
||||
}; |
@ -0,0 +1,117 @@ |
||||
// progress.cpp : implementation file
|
||||
//
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
#include "stdafx.h" |
||||
#include "clamav.h" |
||||
|
||||
#include "progress.h" |
||||
|
||||
#ifdef _DEBUG |
||||
#undef THIS_FILE |
||||
static char BASED_CODE THIS_FILE[] = __FILE__; |
||||
#endif |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CProgress dialog
|
||||
|
||||
|
||||
CProgress::CProgress(CWnd* pParent) |
||||
: CDialog(CProgress::IDD, pParent) |
||||
{ |
||||
//{{AFX_DATA_INIT(CProgress)
|
||||
m_filename = _T("bar"); |
||||
m_percent = _T(""); |
||||
//}}AFX_DATA_INIT
|
||||
stopPressed = FALSE; |
||||
} |
||||
|
||||
|
||||
void CProgress::DoDataExchange(CDataExchange* pDX) |
||||
{ |
||||
CDialog::DoDataExchange(pDX); |
||||
//{{AFX_DATA_MAP(CProgress)
|
||||
DDX_Text(pDX, IDC_FileName, m_filename); |
||||
DDX_Text(pDX, IDC_Percent, m_percent); |
||||
//}}AFX_DATA_MAP
|
||||
} |
||||
|
||||
void |
||||
CProgress::SetFilename(const CString& filename) |
||||
{ |
||||
if(stopPressed) |
||||
return; |
||||
|
||||
m_filename = _T(filename); |
||||
|
||||
CStatic *text = (CStatic *)GetDlgItem(IDC_FileName); |
||||
if(text) { |
||||
text->SetWindowText(filename); |
||||
// text->UpdateWindow();
|
||||
percent = -1; // force a display when it changes
|
||||
} else |
||||
AfxMessageBox("Can't find IDC_FileName"); |
||||
} |
||||
|
||||
void |
||||
CProgress::SetPercent(int p) |
||||
{ |
||||
if((p < 0) || (p > 100)) |
||||
return; |
||||
|
||||
if(p == percent) |
||||
return; |
||||
|
||||
char buf[5]; |
||||
sprintf(buf, "%d%%", p); |
||||
|
||||
CStatic *text = (CStatic *)GetDlgItem(IDC_Percent); |
||||
if(text) { |
||||
text->SetWindowText(buf); |
||||
// text->UpdateWindow();
|
||||
percent = p; |
||||
} else |
||||
AfxMessageBox("Can't find IDC_Percent"); |
||||
}
|
||||
|
||||
const BOOL |
||||
CProgress::IsStopPressed(void) |
||||
{ |
||||
return stopPressed; |
||||
} |
||||
|
||||
BEGIN_MESSAGE_MAP(CProgress, CDialog) |
||||
//{{AFX_MSG_MAP(CProgress)
|
||||
ON_BN_CLICKED(IDSTOP, OnStop) |
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP() |
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CProgress message handlers
|
||||
|
||||
void CProgress::OnStop()
|
||||
{ |
||||
// TODO: Add your control notification handler code here
|
||||
stopPressed = TRUE; |
||||
|
||||
CButton *stopButton = (CButton *)GetDlgItem(IDSTOP); |
||||
if(stopButton) |
||||
stopButton->EnableWindow(FALSE); |
||||
} |
@ -0,0 +1,66 @@ |
||||
// progress.h : header file
|
||||
//
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CProgress dialog
|
||||
|
||||
#ifndef _PROGRESS_H |
||||
|
||||
class CProgress : public CDialog |
||||
{ |
||||
// Construction
|
||||
public: |
||||
CProgress(CWnd* pParent = NULL); |
||||
|
||||
void SetFilename(const CString& filename); |
||||
const BOOL IsStopPressed(void); |
||||
void SetPercent(int percent); |
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CProgress)
|
||||
enum { IDD = IDD_PROGRESS }; |
||||
CString m_filename; |
||||
CString m_percent; |
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CProgress)
|
||||
protected: |
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected: |
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CProgress)
|
||||
afx_msg void OnStop(); |
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP() |
||||
|
||||
private: |
||||
BOOL stopPressed; |
||||
int percent; |
||||
}; |
||||
|
||||
#define _PROGRESS_H |
||||
#endif _PROGRESS_H |
@ -0,0 +1,64 @@ |
||||
// servername.cpp : implementation file
|
||||
//
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
#include "stdafx.h" |
||||
#include "clamav.h" |
||||
#include "servername.h" |
||||
|
||||
#ifdef _DEBUG |
||||
#undef THIS_FILE |
||||
static char BASED_CODE THIS_FILE[] = __FILE__; |
||||
#endif |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ServerName dialog
|
||||
|
||||
|
||||
ServerName::ServerName(CWnd* pParent /*=NULL*/) |
||||
: CDialog(ServerName::IDD, pParent) |
||||
{ |
||||
//{{AFX_DATA_INIT(ServerName)
|
||||
m_serverName = _T(""); |
||||
m_port = DEFAULT_PORT; |
||||
//}}AFX_DATA_INIT
|
||||
} |
||||
|
||||
|
||||
void ServerName::DoDataExchange(CDataExchange* pDX) |
||||
{ |
||||
CDialog::DoDataExchange(pDX); |
||||
//{{AFX_DATA_MAP(ServerName)
|
||||
DDX_Text(pDX, IDC_SERVERNAME, m_serverName); |
||||
DDV_MaxChars(pDX, m_serverName, 20); |
||||
DDX_Text(pDX, IDC_SERVERPORT, m_port); |
||||
DDV_MinMaxUInt(pDX, m_port, 1, 65535); |
||||
//}}AFX_DATA_MAP
|
||||
} |
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(ServerName, CDialog) |
||||
//{{AFX_MSG_MAP(ServerName)
|
||||
// NOTE: the ClassWizard will add message map macros here
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP() |
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ServerName message handlers
|
@ -0,0 +1,55 @@ |
||||
// servername.h : header file
|
||||
//
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 Nigel Horne <njh@bandsman.co.uk> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
*/ |
||||
#include "resource.h" // main symbols |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ServerName dialog
|
||||
|
||||
class ServerName : public CDialog |
||||
{ |
||||
// Construction
|
||||
public: |
||||
ServerName(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(ServerName)
|
||||
enum { IDD = IDD_SERVERNAME }; |
||||
CString m_serverName; |
||||
UINT m_port; |
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(ServerName)
|
||||
protected: |
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected: |
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(ServerName)
|
||||
// NOTE: the ClassWizard will add member functions here
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP() |
||||
}; |
Loading…
Reference in new issue