Browse code

Moving CONFDIR and DATADIR definitions out of the Win32 clamav-config.h, to eliminate conflict with directory-finding feature.

Micah Snyder authored on 2018/12/14 07:22:44
Showing 2 changed files
... ...
@@ -30,7 +30,7 @@
30 30
 #define CL_THREAD_SAFE 1
31 31
 
32 32
 /* where to look for the config file */
33
-#define CONFDIR "C:\\ClamAV"
33
+/* #undef CONFDIR */
34 34
 
35 35
 /* curses header location */
36 36
 /* #undef CURSES_INCLUDE */
... ...
@@ -81,7 +81,7 @@
81 81
 /* #undef C_SOLARIS */
82 82
 
83 83
 /* Path to virus database directory. */
84
-#define DATADIR "C:\\ClamAV\\db"
84
+/* #undef DATADIR */
85 85
 
86 86
 /* "default FD_SETSIZE value" */
87 87
 #define DEFAULT_FD_SETSIZE 1024
... ...
@@ -63,26 +63,36 @@ BOOL APIENTRY DllMain(HMODULE hm, DWORD why, LPVOID rsrv)
63 63
 
64 64
 /*
65 65
     The trick is:
66
-    1 - Reinclude clamav-config.h which is not guarded against multiple inclusions.
67
-	In platform.h we do undef them and re-export as extern pointers, however, since
68
-	platform.h is guarded, the undef won't trigger.
69
-	This gives back to us the original CONFDIR and DATADIR macroes.
66
+    1 - Define BACKUP_DATADIR and BACKUP_CONFDIR macros directly, rather than
67
+		defining them in clamav-config.h, because it is not guarded against multiple inclusions.
70 68
     2 - We define _static_ buffers to contain those strings.
71 69
     3 - We undef the macroes, which re-turns them back into extern pointers and we set them
72
-	to point to the above defined buffer.
73
-    4 - We now give the original macros the names of the above buffers and include optparser.c
74
-	This result in clam_options struct in optparser be defined with proper pointers.
70
+		to point to the above defined buffer.
71
+    4 - We now give the original macros the names of the above buffers and include optparser.c.
72
+		This result in clam_options struct in optparser be defined with proper pointers.
73
+
74
+	In platform.h, we export DATADIR and CONFDIR as extern pointers so they are available
75
+	directly to libclamav users.
75 76
 */
76 77
 
77
-#include "clamav-config.h"
78
-char _DATADIR[MAX_PATH]           = DATADIR;
79
-char _CONFDIR[MAX_PATH]           = CONFDIR;
80
-char _CONFDIR_CLAMD[MAX_PATH]     = CONFDIR "\\clamd.conf";
81
-char _CONFDIR_FRESHCLAM[MAX_PATH] = CONFDIR "\\freshclam.conf";
82
-char _CONFDIR_MILTER[MAX_PATH]    = CONFDIR "\\clamav-milter.conf";
78
+#ifndef BACKUP_DATADIR
79
+#define BACKUP_DATADIR "C:\\ClamAV\\db"
80
+#endif
81
+#ifndef BACKUP_CONFDIR
82
+#define BACKUP_CONFDIR "C:\\ClamAV"
83
+#endif
84
+char _DATADIR[MAX_PATH]           = BACKUP_DATADIR;
85
+char _CONFDIR[MAX_PATH]           = BACKUP_CONFDIR;
86
+char _CONFDIR_CLAMD[MAX_PATH]     = BACKUP_CONFDIR "\\clamd.conf";
87
+char _CONFDIR_FRESHCLAM[MAX_PATH] = BACKUP_CONFDIR "\\freshclam.conf";
88
+char _CONFDIR_MILTER[MAX_PATH]    = BACKUP_CONFDIR "\\clamav-milter.conf";
83 89
 
90
+#ifdef DATADIR
84 91
 #undef DATADIR
92
+#endif
93
+#ifdef DATADIR
85 94
 #undef CONFDIR
95
+#endif
86 96
 const char *DATADIR           = _DATADIR;
87 97
 const char *CONFDIR           = _CONFDIR;
88 98
 const char *CONFDIR_CLAMD     = _CONFDIR_CLAMD;