Browse code

make cli_filetype non static

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@424 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2004/03/20 23:49:22
Showing 6 changed files
... ...
@@ -1,3 +1,7 @@
1
+Sat Mar 20 15:53:10 CET 2004 (tk)
2
+---------------------------------
3
+  * libclamav: make cli_filetype non static
4
+
1 5
 Sat Mar 20 13:33:49 GMT 2004 (njh)
2 6
 ----------------------------------
3 7
   * libclamav/message.c:	More bounces added
... ...
@@ -41,6 +41,7 @@ libclamav_la_SOURCES = \
41 41
 	str.h \
42 42
 	defaults.h \
43 43
 	scanners.c \
44
+	scanners.h \
44 45
 	unrarlib.c \
45 46
 	unrarlib.h \
46 47
 	zziplib/zzip-conf.h \
... ...
@@ -141,6 +141,7 @@ libclamav_la_SOURCES = \
141 141
 	str.h \
142 142
 	defaults.h \
143 143
 	scanners.c \
144
+	scanners.h \
144 145
 	unrarlib.c \
145 146
 	unrarlib.h \
146 147
 	zziplib/zzip-conf.h \
... ...
@@ -39,16 +39,17 @@
39 39
 #include <target.h>
40 40
 #include <sys/time.h>
41 41
 
42
+#ifdef CL_THREAD_SAFE
43
+#  include <pthread.h>
44
+pthread_mutex_t cl_gentemp_mutex = PTHREAD_MUTEX_INITIALIZER;
45
+#endif
46
+
42 47
 #include "clamav.h"
43 48
 #include "others.h"
44 49
 #include "md5.h"
45 50
 
46 51
 #define CL_FLEVEL 1 /* don't touch it */
47 52
 
48
-#ifdef CL_THREAD_SAFE
49
-#  include <pthread.h>
50
-pthread_mutex_t cl_gentemp_mutex = PTHREAD_MUTEX_INITIALIZER;
51
-#endif
52 53
 
53 54
 int cli_debug_flag = 0;
54 55
 
... ...
@@ -42,6 +42,7 @@ int cli_scanrar_inuse = 0;
42 42
 #include "unrarlib.h"
43 43
 #include "ole2_extract.h"
44 44
 #include "vba_extract.h"
45
+#include "scanners.h"
45 46
 
46 47
 #ifdef HAVE_ZLIB_H
47 48
 #include <zlib.h>
... ...
@@ -58,26 +59,16 @@ int cli_scanrar_inuse = 0;
58 58
 #define DISABLE_RAR	    (options & CL_DISABLERAR)
59 59
 #define DETECT_ENCRYPTED    (options & CL_ENCRYPTED)
60 60
 
61
-typedef enum {
62
-    CL_UNKNOWN_TYPE = 0,
63
-    CL_MAILFILE,
64
-    CL_GZFILE,
65
-    CL_ZIPFILE,
66
-    CL_BZFILE,
67
-    CL_RARFILE,
68
-    CL_OLE2FILE
69
-} cl_file_t;
70
-
71
-struct cl_magic_s {
61
+struct cli_magic_s {
72 62
     int offset;
73 63
     const char *magic;
74 64
     size_t length;
75 65
     const char *descr;
76
-    cl_file_t type;
66
+    cli_file_t type;
77 67
 };
78 68
 
79 69
 #define MAGIC_BUFFER_SIZE 26
80
-static const struct cl_magic_s cl_magic[] = {
70
+static const struct cli_magic_s cli_magic[] = {
81 71
     {0,  "Rar!",			4, "RAR",	    CL_RARFILE},
82 72
     {0,  "PK\003\004",			4, "ZIP",	    CL_ZIPFILE},
83 73
     {0,  "\037\213",			2, "GZip",	    CL_GZFILE},
... ...
@@ -97,15 +88,15 @@ static const struct cl_magic_s cl_magic[] = {
97 97
     {-1, NULL,              0, NULL,              CL_UNKNOWN_TYPE}
98 98
 };
99 99
 
100
-static cl_file_t cl_filetype(const char *buf, size_t buflen)
100
+cli_file_t cli_filetype(const char *buf, size_t buflen)
101 101
 {
102 102
 	int i;
103 103
 
104
-    for (i = 0; cl_magic[i].magic; i++) {
105
-	if (buflen >= cl_magic[i].offset+cl_magic[i].length) {
106
-	    if (memcmp(buf+cl_magic[i].offset, cl_magic[i].magic, cl_magic[i].length) == 0) {
107
-		cli_dbgmsg("Recognized %s file\n", cl_magic[i].descr);
108
-		return cl_magic[i].type;
104
+    for (i = 0; cli_magic[i].magic; i++) {
105
+	if (buflen >= cli_magic[i].offset+cli_magic[i].length) {
106
+	    if (memcmp(buf+cli_magic[i].offset, cli_magic[i].magic, cli_magic[i].length) == 0) {
107
+		cli_dbgmsg("Recognized %s file\n", cli_magic[i].descr);
108
+		return cli_magic[i].type;
109 109
 	    }
110 110
 	}
111 111
     }
... ...
@@ -783,7 +774,7 @@ static int cli_magic_scandesc(int desc, const char **virname, long int *scanned,
783 783
 	char magic[MAGIC_BUFFER_SIZE+1];
784 784
 	int ret = CL_CLEAN;
785 785
 	int bread = 0;
786
-	cl_file_t type;
786
+	cli_file_t type;
787 787
 
788 788
 
789 789
     if(!root) {
... ...
@@ -815,7 +806,7 @@ static int cli_magic_scandesc(int desc, const char **virname, long int *scanned,
815 815
 	    return ret;
816 816
 	}
817 817
 
818
-	type = cl_filetype(magic, bread);
818
+	type = cli_filetype(magic, bread);
819 819
 
820 820
 	switch(type) {
821 821
 	    case CL_RARFILE:
822 822
new file mode 100644
... ...
@@ -0,0 +1,35 @@
0
+/*
1
+ *  Copyright (C) 2002 - 2004 Tomasz Kojm <tkojm@clamav.net>
2
+ *  With enhancements from Thomas Lamy <Thomas.Lamy@in-online.net>
3
+ *
4
+ *  This program is free software; you can redistribute it and/or modify
5
+ *  it under the terms of the GNU General Public License as published by
6
+ *  the Free Software Foundation; either version 2 of the License, or
7
+ *  (at your option) any later version.
8
+ *
9
+ *  This program is distributed in the hope that it will be useful,
10
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
+ *  GNU General Public License for more details.
13
+ *
14
+ *  You should have received a copy of the GNU General Public License
15
+ *  along with this program; if not, write to the Free Software
16
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+#ifndef __SCANNERS_H
20
+#define __SCANNERS_H
21
+
22
+typedef enum {
23
+    CL_UNKNOWN_TYPE = 0,
24
+    CL_MAILFILE,
25
+    CL_GZFILE,
26
+    CL_ZIPFILE,
27
+    CL_BZFILE,
28
+    CL_RARFILE,
29
+    CL_OLE2FILE
30
+} cli_file_t;
31
+
32
+cli_file_t cli_filetype(const char *buf, size_t buflen);
33
+
34
+#endif