diff --git a/clamav-devel/ChangeLog b/clamav-devel/ChangeLog index 92330220d..61474990b 100644 --- a/clamav-devel/ChangeLog +++ b/clamav-devel/ChangeLog @@ -1,3 +1,7 @@ +Wed Sep 27 12:48:06 CEST 2006 (tk) +---------------------------------- + * shared/misc.c: apply w32 patch from NJH + Wed Sep 27 12:20:38 CEST 2006 (tk) ---------------------------------- * freshclam/dns.c: apply w32 support patch from Mark Pizzolato diff --git a/clamav-devel/shared/misc.c b/clamav-devel/shared/misc.c index 63172a712..2faf131fe 100644 --- a/clamav-devel/shared/misc.c +++ b/clamav-devel/shared/misc.c @@ -23,22 +23,30 @@ #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include #include #include +#ifndef C_WINDOWS #include +#endif #include #include #include -#include "clamav.h" -#include "cfgparser.h" -#include "memory.h" -#include "output.h" +#include "shared/cfgparser.h" +#include "shared/memory.h" +#include "shared/output.h" -#include "../libclamav/cvd.h" +#include "libclamav/clamav.h" +#include "libclamav/cvd.h" + +#ifndef O_BINARY +#define O_BINARY 0 +#endif char *freshdbdir(void) @@ -136,10 +144,10 @@ int filecopy(const char *src, const char *dest) struct stat sb; - if((s = open(src, O_RDONLY)) == -1) + if((s = open(src, O_RDONLY|O_BINARY)) == -1) return -1; - if((d = open(dest, O_CREAT|O_WRONLY|O_TRUNC)) == -1) { + if((d = open(dest, O_CREAT|O_WRONLY|O_TRUNC|O_BINARY)) == -1) { close(s); return -1; } @@ -177,13 +185,17 @@ int rmdirs(const char *dirname) } while((dent = readdir(dd))) { -#if (!defined(C_CYGWIN)) && (!defined(C_INTERIX)) +#if (!defined(C_CYGWIN)) && (!defined(C_INTERIX)) && (!defined(C_WINDOWS)) if(dent->d_ino) #endif { if(strcmp(dent->d_name, ".") && strcmp(dent->d_name, "..")) { fname = mcalloc(strlen(dirname) + strlen(dent->d_name) + 2, sizeof(char)); +#ifdef C_WINDOWS + sprintf(fname, "%s\\%s", dirname, dent->d_name); +#else sprintf(fname, "%s/%s", dirname, dent->d_name); +#endif /* stat the file */ if(lstat(fname, &statbuf) != -1) { @@ -237,7 +249,7 @@ int dircopy(const char *src, const char *dest) } while((dent = readdir(dd))) { -#if (!defined(C_CYGWIN)) && (!defined(C_INTERIX)) +#if (!defined(C_CYGWIN)) && (!defined(C_INTERIX)) && (!defined(C_WINDOWS)) if(dent->d_ino) #endif { @@ -276,7 +288,7 @@ int cvd_unpack(const char *cvd, const char *destdir) int fd; - if((fd = open(cvd, O_RDONLY)) == -1) + if((fd = open(cvd, O_RDONLY|O_BINARY)) == -1) return -1; if(lseek(fd, 512, SEEK_SET) == -1) { @@ -292,11 +304,12 @@ int cvd_unpack(const char *cvd, const char *destdir) void daemonize(void) { - int i; - -#ifdef C_OS2 +#if defined(C_OS2) || defined(C_WINDOWS) + fputs("Background mode is not supported on your operating system\n", stderr); return; #else + int i; + if((i = open("/dev/null", O_WRONLY)) == -1) { for(i = 0; i <= 2; i++)