[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b

aCaB acab at clamav.net
Sun Apr 4 01:07:41 UTC 2010


The following commit has been merged in the debian/unstable branch:
commit 13829b14c5d8699dc9bffd472e0282bce24d6271
Author: aCaB <acab at clamav.net>
Date:   Mon Oct 12 23:35:32 2009 +0200

    win32 dirent

diff --git a/win32/clamav-config.h b/win32/clamav-config.h
index 3fa510c..e6ffc00 100644
--- a/win32/clamav-config.h
+++ b/win32/clamav-config.h
@@ -216,7 +216,7 @@
 /* #undef HAVE_INTTYPES_H */
 
 /* in_addr_t is defined */
-#define HAVE_IN_ADDR_T 1
+/* #define HAVE_IN_ADDR_T */
 
 /* in_port_t is defined */
 #define HAVE_IN_PORT_T 1
@@ -346,7 +346,7 @@
 #define HAVE_STDLIB_H 1
 
 /* Define to 1 if you have the `strcasestr' function. */
-#define HAVE_STRCASESTR 1
+/* #define HAVE_STRCASESTR */
 
 /* Define to 1 if you have the `strerror_r' function. */
 #define HAVE_STRERROR_R 1
diff --git a/win32/compat/dirent.c b/win32/compat/dirent.c
index ad67a22..ebcb5c9 100644
--- a/win32/compat/dirent.c
+++ b/win32/compat/dirent.c
@@ -18,9 +18,77 @@
  *  MA 02110-1301, USA.
  */
 
+#include <errno.h>
+#include "others.h"
 #include "dirent.h"
+#include "shared/misc.h"
 
 DIR *opendir(const char *name) {
+	DIR *d;
+	DWORD attrs;
 
+	if(!(d = cli_malloc(sizeof(*d)))) {
+		errno = ENOMEM;
+		return NULL;
+	}
+	if(!(MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, d->entry, sizeof(d->entry) / sizeof(d->entry[0])))) {
+		free(d);
+		errno = (GetLastError() == ERROR_INSUFFICIENT_BUFFER) ? ENAMETOOLONG : ENOENT;
+		return NULL;
+	}
+	/* FIXME: this should be UNC'd */
+	if((attrs = GetFileAttributesW(d->entry)) == INVALID_FILE_ATTRIBUTES) {
+		free(d);
+		errno = ENOENT;
+		return NULL;
+	}
+	if(!(attrs & FILE_ATTRIBUTE_DIRECTORY)) {
+		free(d);
+		errno = ENOTDIR;
+		return NULL;
+	}
+	d->dh = INVALID_HANDLE_VALUE;
+	return d;
+}
 
+struct dirent *readdir(DIR *dirp) {
+	while(1) {
+		BOOL cant_convert;
+		if(dirp->dh == INVALID_HANDLE_VALUE) {
+			if((dirp->dh = FindFirstFileW(dirp->entry, &dirp->wfd)) == INVALID_HANDLE_VALUE) {
+				errno = ENOENT;
+				return NULL;
+			}
+		} else {
+			if(!(FindNextFileW(dirp->dh, &dirp->wfd))) {
+				errno = (GetLastError() == ERROR_NO_MORE_FILES) ? 0 : ENOENT;
+				return NULL;
+			}
+		}
+		if(!WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, dirp->wfd.cFileName, -1, dirp->ent.d_name, sizeof(dirp->ent.d_name), NULL, &cant_convert) ||
+			cant_convert || 
+			!WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, dirp->wfd.cAlternateFileName, -1, dirp->ent.d_name, sizeof(dirp->ent.d_name), NULL, &cant_convert) ||
+			cant_convert ||
+			!dirp->ent.d_name[0]) {
+			/* FIXME: WARN HERE ! */
+			continue;
+		}
+		dirp->ent.d_ino = dirp->wfd.ftCreationTime.dwLowDateTime ^ dirp->wfd.nFileSizeLow;
+		if(!dirp->ent.d_ino) dirp->ent.d_ino = 0x1337;
+		dirp->ent.d_type = (dirp->wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? DT_DIR : DT_REG;
+		break;
+	}
+	return &dirp->ent;
+}
+
+void rewinddir(DIR *dirp) {
+	if(dirp->dh != INVALID_HANDLE_VALUE)
+		FindClose(dirp->dh);
+	dirp->dh = INVALID_HANDLE_VALUE;
+}
+
+int closedir(DIR *dirp) {
+	rewinddir(dirp);
+	free(dirp);
+	return 0;
 }
\ No newline at end of file
diff --git a/win32/compat/dirent.h b/win32/compat/dirent.h
index 234c0f7..5fb4fcc 100644
--- a/win32/compat/dirent.h
+++ b/win32/compat/dirent.h
@@ -25,19 +25,21 @@
 #include "clamav-config.h"
 #endif
 
-#define _DIRENT_HAVE_D_TYPE
+//#define _DIRENT_HAVE_D_TYPE
+
+typedef unsigned long ino_t;
 
 typedef struct {
 	HANDLE dh;
 	WIN32_FIND_DATAW wfd;
-	char entry[MAX_PATH];
+	struct dirent {
+		ino_t d_ino;	/* inode number */
+		unsigned char d_type;	/* type of file */
+		char d_name[MAX_PATH];	/* filename */
+	} ent;
+	wchar_t entry[PATH_MAX];
 } DIR;
 
-struct dirent {
-	char d_ino;			/* inode number */
-	unsigned char d_type;	/* type of file */
-	char d_name[MAX_PATH];	/* filename */
-};
 
 enum {
 	DT_BLOCK,
diff --git a/win32/libclamav.vcproj b/win32/libclamav.vcproj
index 950c2b2..d254013 100644
--- a/win32/libclamav.vcproj
+++ b/win32/libclamav.vcproj
@@ -41,7 +41,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)..\libclamav&quot;;&quot;$(SolutionDir)\3rdparty\zlib&quot;;&quot;$(SolutionDir)\3rdparty\pthreads&quot;;&quot;$(SolutionDir)\3rdparty\bzip2&quot;;&quot;$(SolutionDir)..&quot;"
+				AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)..\libclamav&quot;;&quot;$(SolutionDir)\compat&quot;;&quot;$(SolutionDir)\3rdparty\zlib&quot;;&quot;$(SolutionDir)\3rdparty\pthreads&quot;;&quot;$(SolutionDir)\3rdparty\bzip2&quot;;&quot;$(SolutionDir)..\libltdl&quot;;&quot;$(SolutionDir)..&quot;"
 				PreprocessorDefinitions="WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -117,7 +117,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="2"
 				EnableIntrinsicFunctions="true"
-				AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)..\libclamav&quot;;&quot;$(SolutionDir)\3rdparty\zlib&quot;;&quot;$(SolutionDir)\3rdparty\pthreads&quot;;&quot;$(SolutionDir)\3rdparty\bzip2&quot;;&quot;$(SolutionDir)..&quot;"
+				AdditionalIncludeDirectories="&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)..\libclamav&quot;;&quot;$(SolutionDir)\compat&quot;;&quot;$(SolutionDir)\3rdparty\zlib&quot;;&quot;$(SolutionDir)\3rdparty\pthreads&quot;;&quot;$(SolutionDir)\3rdparty\bzip2&quot;;&quot;$(SolutionDir)..\libltdl&quot;;&quot;$(SolutionDir)..&quot;"
 				PreprocessorDefinitions="WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H"
 				RuntimeLibrary="2"
 				EnableFunctionLevelLinking="true"
@@ -181,6 +181,42 @@
 				>
 			</File>
 			<File
+				RelativePath="..\libclamav\7z\7zBuf.c"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\7zCrc.c"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\Archive\7z\7zDecode.c"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\Archive\7z\7zExtract.c"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\7zFile.c"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\Archive\7z\7zHeader.c"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\Archive\7z\7zIn.c"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\Archive\7z\7zItem.c"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\7zStream.c"
+				>
+			</File>
+			<File
 				RelativePath="..\libclamav\aspack.c"
 				>
 			</File>
@@ -189,6 +225,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\libclamav\7z\Bcj2.c"
+				>
+			</File>
+			<File
 				RelativePath="..\libclamav\bignum.c"
 				>
 			</File>
@@ -201,6 +241,18 @@
 				>
 			</File>
 			<File
+				RelativePath="..\libclamav\7z\Bra.c"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\Bra86.c"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\BraIA64.c"
+				>
+			</File>
+			<File
 				RelativePath="..\libclamav\bytecode.c"
 				>
 			</File>
@@ -237,6 +289,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\compat\dirent.c"
+				>
+			</File>
+			<File
 				RelativePath="..\libclamav\disasm.c"
 				>
 			</File>
@@ -301,6 +357,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\libclamav\7z\LzmaDec.c"
+				>
+			</File>
+			<File
 				RelativePath="..\libclamav\macho.c"
 				>
 			</File>
@@ -333,6 +393,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\shared\misc.c"
+				>
+			</File>
+			<File
 				RelativePath="..\libclamav\mpool.c"
 				>
 			</File>
@@ -507,6 +571,38 @@
 				>
 			</File>
 			<File
+				RelativePath="..\libclamav\7z\7zBuf.h"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\7zCrc.h"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\Archive\7z\7zDecode.h"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\Archive\7z\7zExtract.h"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\7zFile.h"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\Archive\7z\7zHeader.h"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\Archive\7z\7zIn.h"
+				>
+			</File>
+			<File
+				RelativePath="..\libclamav\7z\Archive\7z\7zItem.h"
+				>
+			</File>
+			<File
 				RelativePath="..\libclamav\aspack.h"
 				>
 			</File>
@@ -515,6 +611,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\libclamav\7z\Bcj2.h"
+				>
+			</File>
+			<File
 				RelativePath="..\libclamav\bignum.h"
 				>
 			</File>
@@ -531,6 +631,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\libclamav\7z\Bra.h"
+				>
+			</File>
+			<File
 				RelativePath="..\libclamav\bytecode.h"
 				>
 			</File>
@@ -567,6 +671,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\libclamav\7z\CpuArch.h"
+				>
+			</File>
+			<File
 				RelativePath="..\libclamav\cvd.h"
 				>
 			</File>
@@ -679,6 +787,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\libclamav\7z\LzmaDec.h"
+				>
+			</File>
+			<File
 				RelativePath="..\libclamav\macho.h"
 				>
 			</File>
@@ -711,6 +823,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\shared\misc.h"
+				>
+			</File>
+			<File
 				RelativePath="..\libclamav\mpool.h"
 				>
 			</File>
@@ -827,6 +943,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\libclamav\7z\Types.h"
+				>
+			</File>
+			<File
 				RelativePath="..\libclamav\unarj.h"
 				>
 			</File>
diff --git a/win32/platform.h b/win32/platform.h
index 6e61b8f..5cd1326 100644
--- a/win32/platform.h
+++ b/win32/platform.h
@@ -11,8 +11,12 @@
 typedef int ssize_t;
 #define strcasecmp lstrcmpi
 #define strncasecmp strnicmp
+
+/* FIXME: this one is b0rked */
 #define snprintf _snprintf
 
+#define PATH_MAX 32767
+
 #define S_IRUSR S_IREAD
 #define S_IWUSR S_IWRITE
 #define S_IRWXU (S_IRUSR|S_IWUSR)
@@ -23,6 +27,8 @@ typedef int ssize_t;
 #define R_OK 4
 #define X_OK R_OK
 
+#define SEARCH_LIBDIR "."
+
 #ifndef MIN
 #define MIN(a, b)	(((a) < (b)) ? (a) : (b))
 #endif

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list