Browse code

win32#3

aCaB authored on 2009/09/25 02:23:21
Showing 32 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Sep 24 19:22:24 CEST 2009 (acab)
2
+------------------------------------
3
+ * merge a set of win32 patches from Gianluigi Tiesi <sherpya*netfarm.it>
4
+
1 5
 Thu Sep 24 19:09:38 CEST 2009 (acab)
2 6
 ------------------------------------
3 7
  * drop OS/2 "support"
... ...
@@ -26,7 +26,9 @@
26 26
 #include <string.h>
27 27
 #include <stdlib.h>
28 28
 #include <unistd.h>
29
+#ifndef _WIN32
29 30
 #include <sys/time.h>
31
+#endif
30 32
 #include <time.h>
31 33
 #include <signal.h>
32 34
 
... ...
@@ -30,18 +30,20 @@
30 30
 #include <string.h>
31 31
 #include <sys/types.h>
32 32
 #include <sys/stat.h>
33
-#include <sys/socket.h>
34 33
 #ifdef HAVE_SYS_LIMITS_H
35 34
 #include <sys/limits.h>
36 35
 #endif
37 36
 #ifdef HAVE_SYS_SELECT_H
38 37
 #include <sys/select.h>
39 38
 #endif
39
+#ifndef _WIN32
40
+#include <sys/socket.h>
40 41
 #include <sys/un.h>
41 42
 #include <netinet/in.h>
42 43
 #include <arpa/inet.h>
43 44
 #include <netdb.h>
44 45
 #include <utime.h>
46
+#endif
45 47
 #include <errno.h>
46 48
 #include <dirent.h>
47 49
 #include <fcntl.h>
... ...
@@ -67,7 +69,9 @@
67 67
 struct sockaddr *mainsa = NULL;
68 68
 int mainsasz;
69 69
 unsigned long int maxstream;
70
+#ifndef _WIN32
70 71
 static struct sockaddr_un nixsock;
72
+#endif
71 73
 static struct sockaddr_in tcpsock;
72 74
 
73 75
 
... ...
@@ -25,7 +25,9 @@
25 25
 /* must be first because it may define _XOPEN_SOURCE */
26 26
 #include "shared/fdpassing.h"
27 27
 #include <stdio.h>
28
+#ifdef HAVE_UNISTD_H
28 29
 #include <unistd.h>
30
+#endif
29 31
 #include <string.h>
30 32
 #include <errno.h>
31 33
 #include <stdlib.h>
... ...
@@ -33,11 +35,13 @@
33 33
 #include <sys/stat.h>
34 34
 #include <fcntl.h>
35 35
 #include <sys/types.h>
36
-#include <sys/socket.h>
37 36
 #ifdef HAVE_SYS_SELECT_H
38 37
 #include <sys/select.h>
39 38
 #endif
39
+#ifndef _WIN32
40 40
 #include <arpa/inet.h>
41
+#include <sys/socket.h>
42
+#endif
41 43
 
42 44
 #include "libclamav/others.h"
43 45
 #include "shared/actions.h"
... ...
@@ -30,9 +30,7 @@
30 30
 #ifdef	HAVE_UNISTD_H
31 31
 #include <unistd.h>
32 32
 #endif
33
-#ifdef	C_WINDOWS
34
-#include <fcntl.h>
35
-#else
33
+#ifndef _WIN32
36 34
 #include <sys/time.h>
37 35
 #endif
38 36
 #include <time.h>
... ...
@@ -62,14 +60,14 @@ int main(int argc, char **argv)
62 62
 	int ds, dms, ret;
63 63
 	double mb, rmb;
64 64
 	struct timeval t1, t2;
65
-#ifndef C_WINDOWS
66 65
 	struct timezone tz;
66
+#ifndef _WIN32
67 67
 	sigset_t sigset;
68 68
 #endif
69 69
 	struct optstruct *opts;
70 70
 	const struct optstruct *opt;
71 71
 
72
-#if !defined(C_WINDOWS) && !defined(C_BEOS)
72
+#if !defined(_WIN32) && !defined(C_BEOS)
73 73
     sigemptyset(&sigset);
74 74
     sigaddset(&sigset, SIGXFSZ);
75 75
     sigprocmask(SIG_SETMASK, &sigset, NULL);
... ...
@@ -29,14 +29,10 @@
29 29
 #include <ctype.h>
30 30
 #include <sys/stat.h>
31 31
 #include <sys/types.h>
32
-#ifdef C_WINDOWS
33
-#include <sys/utime.h>
34
-#else
32
+#include <dirent.h>
33
+#ifndef _WIN32
35 34
 #include <sys/wait.h>
36 35
 #include <utime.h>
37
-#endif
38
-#ifndef C_WINDOWS
39
-#include <dirent.h>
40 36
 #include <sys/time.h>
41 37
 #include <sys/resource.h>
42 38
 #endif
... ...
@@ -323,7 +319,7 @@ int scanmanager(const struct optstruct *opts)
323 323
 	char *file, cwd[1024], *pua_cats = NULL;
324 324
 	const char *filename;
325 325
 	const struct optstruct *opt;
326
-#ifndef C_WINDOWS
326
+#ifndef _WIN32
327 327
 	struct rlimit rlim;
328 328
 #endif
329 329
 
... ...
@@ -457,7 +453,7 @@ int scanmanager(const struct optstruct *opts)
457 457
 	}
458 458
     }
459 459
 
460
-#ifndef C_WINDOWS
460
+#ifndef _WIN32
461 461
     if(getrlimit(RLIMIT_FSIZE, &rlim) == 0) {
462 462
 	if(rlim.rlim_cur < (rlim_t) cl_engine_get_num(engine, CL_ENGINE_MAX_FILESIZE, NULL))
463 463
 	    logg("^System limit for file size is lower than engine->maxfilesize\n");
... ...
@@ -36,7 +36,7 @@
36 36
 #endif
37 37
 #include <sys/types.h>
38 38
 #include <sys/stat.h>
39
-#ifndef C_WINDOWS
39
+#ifndef _WIN32
40 40
 #include <sys/wait.h>
41 41
 #include <sys/time.h>
42 42
 #endif
... ...
@@ -40,9 +40,6 @@ int active_children;
40 40
 void execute( const char *type, const char *text, const struct optstruct *opts )
41 41
 {
42 42
 	int ret;
43
-#ifndef C_WINDOWS
44
-	pid_t pid;
45
-#endif
46 43
 
47 44
     if(!optget(opts, "daemon")->enabled) {
48 45
 	if(sscanf(text, "EXIT_%d", &ret) == 1) {
... ...
@@ -65,7 +62,8 @@ void execute( const char *type, const char *text, const struct optstruct *opts )
65 65
 	} else
66 66
 		logg("^%s: already %d processes active.\n", type, active_children);
67 67
 #else
68
-	if ( active_children<MAX_CHILDREN )
68
+    if ( active_children<MAX_CHILDREN ) {
69
+	pid_t pid;
69 70
 	switch( pid=fork() ) {
70 71
 	case 0:
71 72
 		if ( -1==system(text) )
... ...
@@ -79,9 +77,8 @@ void execute( const char *type, const char *text, const struct optstruct *opts )
79 79
 	default:
80 80
 		active_children++;
81 81
 	}
82
-	else
83
-	{
82
+    } else {
84 83
 		logg("^%s: already %d processes active.\n", type, active_children);
85
-	}
84
+    }
86 85
 #endif
87 86
 }
... ...
@@ -30,7 +30,7 @@
30 30
 #include <signal.h>
31 31
 #include <time.h>
32 32
 #include <sys/types.h>
33
-#ifndef	C_WINDOWS
33
+#ifndef	_WIN32
34 34
 #include <sys/wait.h>
35 35
 #endif
36 36
 #include <sys/stat.h>
... ...
@@ -203,7 +203,7 @@ int main(int argc, char **argv)
203 203
 	struct sigaction sigact;
204 204
 	struct sigaction oldact;
205 205
 #endif
206
-#ifndef C_WINDOWS
206
+#ifdef HAVE_PWD_H
207 207
 	const char *dbowner;
208 208
 	struct passwd *user;
209 209
 #endif
... ...
@@ -256,7 +256,7 @@ int main(int argc, char **argv)
256 256
 #endif
257 257
     }
258 258
 
259
-#ifndef _WIN32
259
+#ifdef HAVE_PWD_H
260 260
     /* freshclam shouldn't work with root privileges */
261 261
     dbowner = optget(opts, "DatabaseOwner")->strarg;
262 262
 
... ...
@@ -419,7 +419,7 @@ int main(int argc, char **argv)
419 419
 
420 420
 	logg("#freshclam daemon %s (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n", get_version());
421 421
 
422
-#ifdef	C_WINDOWS
422
+#ifdef _WIN32
423 423
 	signal(SIGINT, daemon_sighandler);
424 424
 	terminate = 0;
425 425
 #else
... ...
@@ -43,16 +43,14 @@
43 43
 #include <strings.h>
44 44
 #endif
45 45
 #include <ctype.h>
46
-#ifndef C_WINDOWS
46
+#ifndef _WIN32
47 47
 #include <netinet/in.h>
48 48
 #include <netdb.h>
49 49
 #include <arpa/inet.h>
50
-#endif
51
-#include <sys/types.h>
52
-#ifndef C_WINDOWS
53 50
 #include <sys/socket.h>
54 51
 #include <sys/time.h>
55 52
 #endif
53
+#include <sys/types.h>
56 54
 #include <time.h>
57 55
 #include <fcntl.h>
58 56
 #include <sys/stat.h>
... ...
@@ -20,10 +20,6 @@
20 20
 #include "clamav-config.h"
21 21
 #endif
22 22
 
23
-#ifdef	C_WINDOWS
24
-#define	_USE_32BIT_TIME_T	/* FIXME: mirdat.atime assumes 32bit time_t */
25
-#endif
26
-
27 23
 #include <stdio.h>
28 24
 #include <string.h>
29 25
 #include <stdlib.h>
... ...
@@ -35,7 +31,7 @@
35 35
 #include <fcntl.h>
36 36
 #include <time.h>
37 37
 
38
-#ifndef C_WINDOWS
38
+#ifndef _WIN32
39 39
 #include <sys/socket.h>
40 40
 #include <netinet/in.h>
41 41
 #include <arpa/inet.h>
... ...
@@ -29,15 +29,13 @@
29 29
 #endif
30 30
 #include <string.h>
31 31
 #include <ctype.h>
32
-#ifndef	C_WINDOWS
32
+#ifndef	_WIN32
33 33
 #include <netinet/in.h>
34 34
 #include <netdb.h>
35
-#endif
36
-#include <sys/types.h>
37
-#ifndef	C_WINDOWS
38 35
 #include <sys/socket.h>
39 36
 #include <sys/time.h>
40 37
 #endif
38
+#include <sys/types.h>
41 39
 #include <time.h>
42 40
 #include <fcntl.h>
43 41
 #include <sys/stat.h>
... ...
@@ -46,16 +44,6 @@
46 46
 #include "shared/output.h"
47 47
 #include "libclamav/clamav.h"
48 48
 
49
-#if	(!defined(EALREADY)) && (defined(WSAEALREADY))
50
-#define EALREADY	WSAEALREADY
51
-#endif
52
-#if	(!defined(EINPROGRESS)) && (defined(WSAEINPROGRESS))
53
-#define EINPROGRESS	WSAEINPROGRESS
54
-#endif
55
-#if	(!defined(EISCONN)) && (defined(WSAEISCONN))
56
-#define EISCONN	WSAEISCONN
57
-#endif
58
-
59 49
 #ifdef SO_ERROR
60 50
 
61 51
 #ifndef timercmp
... ...
@@ -24,7 +24,7 @@
24 24
 #endif
25 25
 
26 26
 #include <sys/types.h>
27
-#ifndef	C_WINDOWS
27
+#ifndef	_WIN32
28 28
 #include <sys/socket.h>
29 29
 #endif
30 30
 
... ...
@@ -43,7 +43,7 @@
43 43
 int notify(const char *cfgfile)
44 44
 {
45 45
 	char buff[20];
46
-#ifndef	C_WINDOWS
46
+#ifndef	_WIN32
47 47
 	struct sockaddr_un server;
48 48
 #endif
49 49
 #ifdef HAVE_GETADDRINFO
... ...
@@ -66,7 +66,7 @@ int notify(const char *cfgfile)
66 66
 	return 1;
67 67
     }
68 68
 
69
-#ifndef	C_WINDOWS
69
+#ifndef	_WIN32
70 70
     if((opt = optget(opts, "LocalSocket"))->enabled) {
71 71
 	socktype = "UNIX";
72 72
 	server.sun_family = AF_UNIX;
... ...
@@ -100,14 +100,6 @@ static	char	const	rcsid[] = "$Id: binhex.c,v 1.23 2007/02/12 20:46:08 njh Exp $"
100 100
 #endif
101 101
 #endif
102 102
 
103
-#ifdef	HAVE_MMAP
104
-#if HAVE_SYS_MMAN_H
105
-#include <sys/mman.h>
106
-#else /* HAVE_SYS_MMAN_H */
107
-#undef HAVE_MMAP
108
-#endif
109
-#endif
110
-
111 103
 #include <stdio.h>
112 104
 #include <memory.h>
113 105
 #include <sys/stat.h>
... ...
@@ -33,18 +33,6 @@
33 33
 #endif
34 34
 #include <string.h>
35 35
 
36
-#if defined(HAVE_ATTRIB_PACKED) || defined(HAVE_PRAGMA_PACK) || defined(HAVE_PRAGMA_PACK_HPPA)
37
-#if HAVE_MMAP
38
-#if HAVE_SYS_MMAN_H
39
-#include <sys/mman.h>
40
-#else /* HAVE_SYS_MMAN_H */
41
-#undef HAVE_MMAP
42
-#endif /* HAVE_SYS_MMAN_H */
43
-#endif /* HAVE_MMAP */
44
-#else/* PACKED */
45
-#undef HAVE_MMAP
46
-#endif
47
-
48 36
 #include "others.h"
49 37
 #include "mspack.h"
50 38
 #include "cltypes.h"
... ...
@@ -40,14 +40,6 @@
40 40
 #include <stdio.h>
41 41
 #include <ctype.h>
42 42
 
43
-#if HAVE_MMAP
44
-#if HAVE_SYS_MMAN_H
45
-#include <sys/mman.h>
46
-#else /* HAVE_SYS_MMAN_H */
47
-#undef HAVE_MMAP
48
-#endif
49
-#endif
50
-
51 43
 #include "others.h"
52 44
 #include "htmlnorm.h"
53 45
 
... ...
@@ -32,11 +32,6 @@
32 32
 #ifdef	HAVE_UNISTD_H
33 33
 #include <unistd.h>
34 34
 #endif
35
-#if HAVE_MMAP
36
-#ifdef HAVE_SYS_MMAN_H
37
-#include <sys/mman.h>
38
-#endif
39
-#endif /* HAVE_MMAP */
40 35
 #if HAVE_STRING_H
41 36
 #include <string.h>
42 37
 #endif
... ...
@@ -301,20 +301,8 @@ static	pthread_mutex_t	tables_mutex = PTHREAD_MUTEX_INITIALIZER;
301 301
 #endif
302 302
 
303 303
 #ifdef	NEW_WORLD
304
-
305 304
 #include "matcher.h"
306
-
307 305
 #undef	PARTIAL_DIR
308
-
309
-#if HAVE_MMAP
310
-#if HAVE_SYS_MMAN_H
311
-#include <sys/mman.h>
312
-#else /* HAVE_SYS_MMAN_H */
313
-#undef HAVE_MMAP
314
-#endif
315
-#else	/*HAVE_MMAP*/
316
-#undef	NEW_WORLD
317
-#endif
318 306
 #endif
319 307
 
320 308
 #ifdef	NEW_WORLD
... ...
@@ -35,7 +35,6 @@
35 35
 #if HAVE_STRING_H
36 36
 #include <string.h>
37 37
 #endif
38
-#include <sys/mman.h>
39 38
 #include <stddef.h>
40 39
 
41 40
 #include "others.h"
... ...
@@ -31,12 +31,6 @@
31 31
 #include <unistd.h>
32 32
 #endif
33 33
 
34
-#if HAVE_MMAP
35
-#ifdef HAVE_SYS_MMAN_H
36
-#include <sys/mman.h>
37
-#endif
38
-#endif
39
-
40 34
 #include "others.h"
41 35
 #include "cltypes.h"
42 36
 #include "nsis_bzlib.h"
... ...
@@ -36,14 +36,6 @@
36 36
 #include <stdlib.h>
37 37
 #include "clamav.h"
38 38
 
39
-#if HAVE_MMAP
40
-#if HAVE_SYS_MMAN_H
41
-#include <sys/mman.h>
42
-#else /* HAVE_SYS_MMAN_H */
43
-#undef HAVE_MMAP
44
-#endif
45
-#endif
46
-
47 39
 #include "cltypes.h"
48 40
 #include "others.h"
49 41
 #include "ole2_extract.h"
... ...
@@ -42,16 +42,8 @@ static	char	const	rcsid[] = "$Id: pdf.c,v 1.61 2007/02/12 20:46:09 njh Exp $";
42 42
 #include <unistd.h>
43 43
 #endif
44 44
 
45
-#ifdef HAVE_SYS_MMAN_H
46
-#include <sys/mman.h>
47
-#endif
48
-
49 45
 #include <zlib.h>
50 46
 
51
-#ifdef	C_WINDOWS
52
-#include <io.h>
53
-#endif
54
-
55 47
 #include "clamav.h"
56 48
 #include "others.h"
57 49
 #include "mbox.h"
... ...
@@ -35,18 +35,7 @@
35 35
 #include <sys/param.h>
36 36
 #endif
37 37
 #include <fcntl.h>
38
-#ifndef	C_WINDOWS
39 38
 #include <dirent.h>
40
-#include <netinet/in.h>
41
-#endif
42
-
43
-#if HAVE_MMAP
44
-#if HAVE_SYS_MMAN_H
45
-#include <sys/mman.h>
46
-#else /* HAVE_SYS_MMAN_H */
47
-#undef HAVE_MMAP
48
-#endif
49
-#endif
50 39
 
51 40
 #define DCONF_ARCH  ctx->dconf->archive
52 41
 #define DCONF_DOC   ctx->dconf->doc
... ...
@@ -28,9 +28,6 @@
28 28
 #ifdef	HAVE_UNISTD_H
29 29
 #include <unistd.h>
30 30
 #endif
31
-#ifndef	C_WINDOWS
32
-#include <netinet/in.h>
33
-#endif
34 31
 #include <string.h>
35 32
 #include <ctype.h>
36 33
 #include "clamav.h"
... ...
@@ -34,13 +34,6 @@
34 34
 #include <string.h>
35 35
 #endif
36 36
 #include <stdlib.h>
37
-
38
-#if HAVE_MMAP
39
-#ifdef HAVE_SYS_MMAN_H
40
-#include <sys/mman.h>
41
-#endif
42
-#endif /* HAVE_MMAP */
43
-
44 37
 #include <stdio.h>
45 38
 
46 39
 #include <zlib.h>
... ...
@@ -34,3 +34,6 @@ typedef	unsigned	int	in_addr_t;
34 34
 #define PATHSEP "/"
35 35
 #endif
36 36
 
37
+#if defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H)
38
+#include <sys/mman.h>
39
+#endif
... ...
@@ -30,7 +30,6 @@
30 30
 #include <unistd.h>
31 31
 #endif
32 32
 #include <fcntl.h>
33
-#include <utime.h>
34 33
 #include <errno.h>
35 34
 #include <libgen.h>
36 35
 
... ...
@@ -31,7 +31,9 @@
31 31
 #include <time.h>
32 32
 #include <sys/types.h>
33 33
 #include <sys/stat.h>
34
+#ifndef _WIN32
34 35
 #include <sys/socket.h>
36
+#endif
35 37
 #include <dirent.h>
36 38
 #include <fcntl.h>
37 39
 #include <ctype.h>
... ...
@@ -20,8 +20,10 @@
20 20
 
21 21
 #ifndef __MISC_H
22 22
 #define __MISC_H
23
+#ifndef _WIN32
23 24
 #include <netdb.h>
24 25
 #include <netinet/in.h>
26
+#endif
25 27
 #include "optparser.h"
26 28
 /* Maximum filenames under various systems - njh */
27 29
 #ifndef	NAME_MAX	/* e.g. Linux */
... ...
@@ -34,7 +34,7 @@
34 34
 #include <time.h>
35 35
 #include <sys/stat.h>
36 36
 #include <errno.h>
37
-#ifndef C_WINDOWS
37
+#ifndef _WIN32
38 38
 #include <sys/time.h>
39 39
 #include <sys/socket.h>
40 40
 #endif
... ...
@@ -39,8 +39,8 @@
39 39
 #include <sys/un.h>
40 40
 #include <netinet/in.h>
41 41
 #include <arpa/inet.h>
42
-#endif
43 42
 #include <sys/wait.h>
43
+#endif
44 44
 #include <dirent.h>
45 45
 
46 46
 #ifdef HAVE_TERMIOS_H