git-svn: trunk@1753
Tomasz Kojm authored on 2005/11/13 11:08:28... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Sun Nov 13 03:05:52 CET 2005 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * libclamav: prepare for hardware acceleration |
|
4 |
+ |
|
1 | 5 |
Sat Nov 12 02:25:03 CET 2005 (tk) |
2 | 6 |
--------------------------------- |
3 | 7 |
* libclamav/readdb.c: add cl_load(), successor of cl_loaddb and cl_loaddbdir |
... | ... |
@@ -63,6 +63,9 @@ extern "C" |
63 | 63 |
#define CL_EIO -12 /* general I/O error */ |
64 | 64 |
#define CL_EFORMAT -13 /* bad format or broken file */ |
65 | 65 |
|
66 |
+/* db options */ |
|
67 |
+#define CL_DB_HWACCEL 1 |
|
68 |
+ |
|
66 | 69 |
/* scan options */ |
67 | 70 |
#define CL_SCAN_RAW 0 |
68 | 71 |
#define CL_SCAN_ARCHIVE 1 |
... | ... |
@@ -142,6 +145,7 @@ struct cli_matcher { |
142 | 142 |
|
143 | 143 |
struct cl_engine { |
144 | 144 |
unsigned int refcount; /* reference counter */ |
145 |
+ unsigned short hwaccel; |
|
145 | 146 |
|
146 | 147 |
/* Roots table */ |
147 | 148 |
struct cli_matcher **root; |
... | ... |
@@ -199,6 +203,7 @@ extern const char *cl_retver(void); |
199 | 199 |
/* database */ |
200 | 200 |
extern int cl_loaddb(const char *filename, struct cl_engine **engine, unsigned int *signo); |
201 | 201 |
extern int cl_loaddbdir(const char *dirname, struct cl_engine **engine, unsigned int *signo); |
202 |
+extern int cl_load(const char *path, struct cl_engine **engine, unsigned int *signo, unsigned int options); |
|
202 | 203 |
extern const char *cl_retdbdir(void); |
203 | 204 |
extern struct cl_engine *cl_dup(struct cl_engine *engine); |
204 | 205 |
|
... | ... |
@@ -286,7 +286,14 @@ int cli_addtypesigs(struct cl_engine *engine) |
286 | 286 |
cli_errmsg("cli_addtypesigs: Can't initialise AC pattern matcher\n"); |
287 | 287 |
return CL_EMEM; |
288 | 288 |
} |
289 |
- root->ac_depth = AC_DEFAULT_DEPTH; |
|
289 |
+ |
|
290 |
+ if(engine->hwaccel) { |
|
291 |
+ cli_dbgmsg("cli_addtypesigs: AC depth 10 (hwaccel mode)\n"); |
|
292 |
+ root->ac_depth = 10; |
|
293 |
+ } else { |
|
294 |
+ root->ac_depth = AC_DEFAULT_DEPTH; |
|
295 |
+ } |
|
296 |
+ |
|
290 | 297 |
root->ac_root = (struct cli_ac_node *) cli_calloc(1, sizeof(struct cli_ac_node)); |
291 | 298 |
if(!root->ac_root) { |
292 | 299 |
cli_errmsg("cli_addtypesigs: Can't initialise AC pattern matcher\n"); |
... | ... |
@@ -1056,6 +1056,7 @@ int cl_loaddbdir(const char *dirname, struct cl_engine **engine, unsigned int *s |
1056 | 1056 |
int cl_load(const char *path, struct cl_engine **engine, unsigned int *signo, unsigned int options) |
1057 | 1057 |
{ |
1058 | 1058 |
struct stat sb; |
1059 |
+ int ret; |
|
1059 | 1060 |
|
1060 | 1061 |
|
1061 | 1062 |
if(stat(path, &sb) == -1) { |
... | ... |
@@ -1063,7 +1064,19 @@ int cl_load(const char *path, struct cl_engine **engine, unsigned int *signo, un |
1063 | 1063 |
return CL_EIO; |
1064 | 1064 |
} |
1065 | 1065 |
|
1066 |
- switch(sb.st_mode & S_IFMT) { |
|
1066 |
+ if((ret = cli_initengine(engine))) { |
|
1067 |
+ cl_free(*engine); |
|
1068 |
+ return ret; |
|
1069 |
+ } |
|
1070 |
+ |
|
1071 |
+ if(options & CL_DB_HWACCEL) { |
|
1072 |
+ (*engine)->hwaccel = 1; |
|
1073 |
+ |
|
1074 |
+ /* load hw db */ |
|
1075 |
+ |
|
1076 |
+ return 0; |
|
1077 |
+ |
|
1078 |
+ } else switch(sb.st_mode & S_IFMT) { |
|
1067 | 1079 |
case S_IFREG: |
1068 | 1080 |
return cli_load(path, engine, signo, options); |
1069 | 1081 |
|