[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:52 UTC 2010


The following commit has been merged in the debian/unstable branch:
commit de61678c6e6f70ec96ec73aa2e0fd09c9c59b5c9
Author: aCaB <acab at clamav.net>
Date:   Tue Oct 13 00:54:49 2009 +0200

    win32: add snprintf

diff --git a/ChangeLog b/ChangeLog
index b70701b..735270e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Tue Oct 13 00:54:05 CEST 2009 (acab)
+------------------------------------
+ * win32/compat: add POSIX compatible snprintf
+
 Mon Oct 12 23:39:30 CEST 2009 (acab)
 ------------------------------------
  * win32: libclamav compiles
diff --git a/win32/compat/gettimeofday.c b/win32/compat/snprintf.c
similarity index 71%
copy from win32/compat/gettimeofday.c
copy to win32/compat/snprintf.c
index 78607cf..4d4d5f8 100644
--- a/win32/compat/gettimeofday.c
+++ b/win32/compat/snprintf.c
@@ -22,15 +22,20 @@
 #include "clamav-config.h"
 #endif
 
-#include <sys/types.h>
-#include <sys/timeb.h>
-#include "gettimeofday.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <errno.h>
+#include "snprintf.h"
 
-int gettimeofday(struct timeval *tv, struct timezone *tz) {
-	struct _timeb t;
-
-	_ftime_s(&t);
-	tv->tv_sec = t.time;
-	tv->tv_usec = t.millitm * 1000;
-	return 0;
+int snprintf(char *str, size_t size, const char *format, ...) {
+	va_list va;
+	int len;
+
+	va_start(va, format);
+	errno = 0;
+	len = vsnprintf(str, size, format, va);
+	if(len == -1 && errno == ERANGE) 
+		len = size;
+	va_end(va);
+	return len;
 }
\ No newline at end of file
diff --git a/win32/compat/gettimeofday.h b/win32/compat/snprintf.h
similarity index 84%
copy from win32/compat/gettimeofday.h
copy to win32/compat/snprintf.h
index 15c47d8..14de256 100644
--- a/win32/compat/gettimeofday.h
+++ b/win32/compat/snprintf.h
@@ -18,9 +18,9 @@
  *  MA 02110-1301, USA.
  */
 
-#ifndef __GETLOCALTIME_H
-#define __GETLOCALTIME_H
+#ifndef __SNPRINTF_H
+#define __SNPRINTF_H
 
-int gettimeofday(struct timeval *tv, struct timezone *tz);
+int snprintf(char *str, size_t size, const char *format, ...);
 
-#endif /* __GETLOCALTIME_H */
\ No newline at end of file
+#endif /* __SNPRINTF_H */
\ No newline at end of file
diff --git a/win32/libclamav.vcproj b/win32/libclamav.vcproj
index 4d0ec28..252879d 100644
--- a/win32/libclamav.vcproj
+++ b/win32/libclamav.vcproj
@@ -776,6 +776,10 @@
 					RelativePath=".\compat\ltdl.c"
 					>
 				</File>
+				<File
+					RelativePath=".\compat\snprintf.c"
+					>
+				</File>
 			</Filter>
 		</Filter>
 		<Filter
diff --git a/win32/platform.h b/win32/platform.h
index 9628d13..42079e6 100644
--- a/win32/platform.h
+++ b/win32/platform.h
@@ -8,15 +8,14 @@
 #include <io.h>
 #include <direct.h>
 
+#include "snprintf.h"
+
 typedef int ssize_t;
 #define strcasecmp lstrcmpi
 #define strncasecmp strnicmp
 #define mkdir(path, mode) mkdir(path)
 #define lstat stat
 
-/* FIXME: this one is b0rked */
-#define snprintf _snprintf
-
 #define PATH_MAX 32767
 
 #define S_IRUSR S_IREAD

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list