git-svn: trunk@1752
Tomasz Kojm authored on 2005/11/12 10:29:51... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Sat Nov 12 02:25:03 CET 2005 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * libclamav/readdb.c: add cl_load(), successor of cl_loaddb and cl_loaddbdir |
|
4 |
+ |
|
1 | 5 |
Fri Nov 11 01:27:56 CET 2005 (tk) |
2 | 6 |
--------------------------------- |
3 | 7 |
* libclamav/matcher-ac.c: replace AC_MIN_LENGTH with cli_matcher->ac_depth |
... | ... |
@@ -928,7 +928,7 @@ static int cli_loadmd(FILE *fd, struct cl_engine **engine, unsigned int *signo, |
928 | 928 |
return 0; |
929 | 929 |
} |
930 | 930 |
|
931 |
-int cl_loaddb(const char *filename, struct cl_engine **engine, unsigned int *signo) |
|
931 |
+static int cli_load(const char *filename, struct cl_engine **engine, unsigned int *signo, unsigned int options) |
|
932 | 932 |
{ |
933 | 933 |
FILE *fd; |
934 | 934 |
int ret; |
... | ... |
@@ -979,7 +979,11 @@ int cl_loaddb(const char *filename, struct cl_engine **engine, unsigned int *sig |
979 | 979 |
return ret; |
980 | 980 |
} |
981 | 981 |
|
982 |
-int cl_loaddbdir(const char *dirname, struct cl_engine **engine, unsigned int *signo) |
|
982 |
+int cl_loaddb(const char *filename, struct cl_engine **engine, unsigned int *signo) { |
|
983 |
+ return cli_load(filename, engine, signo, 0); |
|
984 |
+} |
|
985 |
+ |
|
986 |
+static int cli_loaddbdir(const char *dirname, struct cl_engine **engine, unsigned int *signo, unsigned int options) |
|
983 | 987 |
{ |
984 | 988 |
DIR *dd; |
985 | 989 |
struct dirent *dent; |
... | ... |
@@ -1045,6 +1049,33 @@ int cl_loaddbdir(const char *dirname, struct cl_engine **engine, unsigned int *s |
1045 | 1045 |
return 0; |
1046 | 1046 |
} |
1047 | 1047 |
|
1048 |
+int cl_loaddbdir(const char *dirname, struct cl_engine **engine, unsigned int *signo) { |
|
1049 |
+ return cli_loaddbdir(dirname, engine, signo, 0); |
|
1050 |
+} |
|
1051 |
+ |
|
1052 |
+int cl_load(const char *path, struct cl_engine **engine, unsigned int *signo, unsigned int options) |
|
1053 |
+{ |
|
1054 |
+ struct stat sb; |
|
1055 |
+ |
|
1056 |
+ |
|
1057 |
+ if(stat(path, &sb) == -1) { |
|
1058 |
+ cli_errmsg("cl_loaddbdir(): Can't get status of %s\n", path); |
|
1059 |
+ return CL_EIO; |
|
1060 |
+ } |
|
1061 |
+ |
|
1062 |
+ switch(sb.st_mode & S_IFMT) { |
|
1063 |
+ case S_IFREG: |
|
1064 |
+ return cli_load(path, engine, signo, options); |
|
1065 |
+ |
|
1066 |
+ case S_IFDIR: |
|
1067 |
+ return cli_loaddbdir(path, engine, signo, options); |
|
1068 |
+ |
|
1069 |
+ default: |
|
1070 |
+ cli_errmsg("cl_load(): Not supported database file type\n"); |
|
1071 |
+ return CL_EOPEN; |
|
1072 |
+ } |
|
1073 |
+} |
|
1074 |
+ |
|
1048 | 1075 |
const char *cl_retdbdir(void) |
1049 | 1076 |
{ |
1050 | 1077 |
return DATADIR; |