Skyld AV  0.6
On access virus scanning for Linux
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
VirusScan.h
Go to the documentation of this file.
1 /*
2  * File: virusscan.h
3  *
4  * Copyright 2012 Heinrich Schuchardt <xypron.glpk@gmx.de>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
23 #ifndef VIRUSSCAN_H
24 #define VIRUSSCAN_H
25 
26 #include <clamav.h>
27 #include <pthread.h>
28 #include "Environment.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
38 class VirusScan {
39 public:
40 
44  enum Status {
48  SCANOK = 0,
52  SCANERROR = -1,
57  };
58 
59  enum RunStatus {
63  };
64 
66  int scan(const int fd);
67  ~VirusScan();
68 private:
76  struct cl_stat dbstat;
80  struct cl_engine *engine;
84  pthread_mutex_t mutexEngine;
88  pthread_mutex_t mutexUpdate;
96  pthread_t updateThread;
101 
102  struct cl_engine *createEngine();
103  int createThread();
104  void dbstat_clear();
105  int dbstat_check();
106  void dbstat_free();
107  void destroyEngine(cl_engine *);
108  struct cl_engine *getEngine();
109  void releaseEngine();
110  void log_virus_found(const int fd, const char *virname);
111  static void *updater(void *);
112 };
113 #ifdef __cplusplus
114 }
115 #endif
116 
117 #endif /* VIRUSSCAN_H */
~VirusScan()
Deletes the virus scanner.
Definition: VirusScan.cc:337
int engineRefCount
Reference count of virus scan enginge.
Definition: VirusScan.h:100
void dbstat_free()
Frees database status.
Definition: VirusScan.cc:204
pthread_t updateThread
Thrad for updating.
Definition: VirusScan.h:96
void log_virus_found(const int fd, const char *virname)
Writes log entry.
Definition: VirusScan.cc:214
Status
Status of virus scanning.
Definition: VirusScan.h:44
struct cl_engine * getEngine()
Gets reference to virus scan engine.
Definition: VirusScan.cc:147
struct cl_engine * createEngine()
Creates a new virus scan engine.
Definition: VirusScan.cc:71
static void * updater(void *)
Thread to update engine.
Definition: VirusScan.cc:274
struct cl_stat dbstat
Struture indicating if database has changed.
Definition: VirusScan.h:76
pthread_mutex_t mutexEngine
Mutex for accessing the engine.
Definition: VirusScan.h:84
Environment * env
environment
Definition: VirusScan.h:72
void destroyEngine(cl_engine *)
Definition: VirusScan.cc:131
enum RunStatus status
Definition: VirusScan.h:92
int scan(const int fd)
Scans file for virus.
Definition: VirusScan.cc:243
pthread_mutex_t mutexUpdate
Mutex for accessing the engine.
Definition: VirusScan.h:88
void dbstat_clear()
Clears database status.
Definition: VirusScan.cc:196
A virus was found.
Definition: VirusScan.h:56
int dbstat_check()
Checks if database has changed. 0 = unchanged, 1 = changed.
Definition: VirusScan.cc:183
void releaseEngine()
Definition: VirusScan.cc:232
An error occured.
Definition: VirusScan.h:52
Envronment.
struct cl_engine * engine
Reference to virus scan engine.
Definition: VirusScan.h:80
VirusScan(Environment *)
Initializes virus scan engine.
Definition: VirusScan.cc:37
The environment holds variables that are shared by instances of multiple classes. ...
Definition: Environment.h:38
Scans files for viruses.
Definition: VirusScan.h:38
int createThread()
Creates a new thread for managing the scan engine.
Definition: VirusScan.cc:168