]> git.pld-linux.org Git - packages/python-pyclamav.git/blame - python-pyclamav-new-api.patch
- release 12
[packages/python-pyclamav.git] / python-pyclamav-new-api.patch
CommitLineData
84b4eace
MB
1
2--- python-clamav-0.4.1.orig/pyclamav.c
3+++ python-clamav-0.4.1/pyclamav.c
4@@ -33,25 +33,6 @@
5
6 /* ********************************************************* */
7
8-/* To be able to compile with
9- releases 0.75 of libclamav
10-
11- Where cl_free was cl_freetrie
12- and cl_build was cl_buildtrie
13- CL_SCAN_STDOPT did not exist
14-*/
15-#ifndef CL_SCAN_STDOPT
16-#define CL_SCAN_STDOPT CL_RAW | CL_ARCHIVE | CL_MAIL | CL_DISABLERAR | CL_OLE2 | CL_ENCRYPTED
17-void cl_free(struct cl_node *rootnode) {
18- cl_freetrie(rootnode);
19- return;
20-}
21-
22-int cl_build(struct cl_node *rootnode) {
23- return cl_buildtrie(rootnode);
24-}
25-#endif
26-
27 /* For python prior to 2.3 */
28 #ifndef PyMODINIT_FUNC
29 #define PyMODINIT_FUNC void
30@@ -68,11 +49,9 @@
31 unsigned int signumber = 0;
32
33 /* Structures for clamav */
34-struct cl_node *root = NULL;
35-struct cl_limits limits;
36+struct cl_engine *engine = NULL;
37 struct cl_stat dbstat;
38
39-
40 /*
41 * If the virus database has been changed, then
42 * free the current tree and reload the new one
43@@ -85,22 +64,22 @@
44 /* If yes : reload DB */
45 if (cl_statchkdir(&dbstat) == 1)
46 {
47- /* free the tree */
48- cl_free(root);
49+ /* free the engine */
50+ cl_engine_free(engine);
51 signumber=0;
52- root=NULL;
53+ engine=NULL;
54
55 /* Load DB */
56- if((ret = cl_load(cl_retdbdir(), &root, &signumber, CL_DB_STDOPT))) {
57+ if((ret = cl_load(cl_retdbdir(), engine, &signumber, CL_DB_STDOPT)) != CL_SUCCESS) {
58 /* Raise exception with error message */
59 PyErr_SetString(PyclamavError, cl_strerror(ret));
60 return -2;
61 }
62
63- /* build the final tree */
64- if((ret = cl_build(root))) {
65- /* free the partial tree */
66- cl_free(root);
67+ /* prepare the engine */
68+ if((ret = cl_engine_compile(engine))) {
69+ /* free the engine */
70+ cl_engine_free(engine);
71 /* Raise exception with error message */
72 PyErr_SetString(PyclamavError, cl_strerror(ret));
73 return -2;
74@@ -231,7 +210,7 @@
75 return NULL;
76 }
77
78- ret = cl_scanfile(file_to_scan, &virname, &size, root, &limits, CL_SCAN_STDOPT);
79+ ret = cl_scanfile(file_to_scan, &virname, &size, engine, CL_SCAN_STDOPT);
80
81 /* Test return code */
82 switch (ret) {
83@@ -278,17 +257,21 @@
84 /* Set documentation string for the module */
85 PyDict_SetItemString(dict, "__doc__", PyString_FromString("pyclamav :\n\n This is a python binding to the C libclamav library\n (from the Clamav project - http://www.clamav.net).\n It can be used to easily allow a Python script to scan\n a file or a buffer against known viruses.\n\nAuthor : Alexandre Norman [norman@xael.org]\n\nFunctions :\n - scanfile(string filename) : Scan a file for virus.\n - get_numsig() : Return the number of known signatures.\n - get_version() : Return the version of Clamav.\n - version() : Return the version of pyclamav.\n"));
86
87+ /* initialize libclamav */
88+ cl_init(CL_INIT_DEFAULT);
89+ engine = cl_engine_new();
90
91- if((ret = cl_load(cl_retdbdir(), &root, &signumber, CL_DB_STDOPT))) {
92+ if((ret = cl_load(cl_retdbdir(), engine, &signumber, CL_DB_STDOPT))) {
93 /* Raise exception with error message */
94 PyErr_SetString(PyclamavError, cl_strerror(ret));
95+ cl_engine_free(engine);
96 return;
97 }
98
99- /* build the final tree */
100- if((ret = cl_build(root))) {
101- /* free the partial tree */
102- cl_free(root);
103+ /* prepare the engine */
104+ if((ret = cl_engine_compile(engine)) != CL_SUCCESS) {
105+ /* free up the engine resources */
106+ cl_engine_free(engine);
107 /* Raise exception with error message */
108 PyErr_SetString(PyclamavError, cl_strerror(ret));
109 return;
110@@ -299,15 +282,6 @@
111 memset(&dbstat, 0, sizeof(struct cl_stat));
112 cl_statinidir(cl_retdbdir(), &dbstat);
113
114-
115-
116- /* set up archive limits */
117- memset(&limits, 0, sizeof(struct cl_limits));
118- limits.maxfiles = 1000; /* max files */
119- limits.maxfilesize = 10 * 1048576; /* maximal archived file size == 10 Mb */
120- limits.maxreclevel = 5; /* maximal recursion level */
121- limits.archivememlim = 0; /* disable memory limit for bzip2 scanner */
122-
123 return ;
124 }
125
126
This page took 0.045657 seconds and 4 git commands to generate.