Win32 portability fixes


git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@85 59561ff5-6e30-0410-9f3c-9617f08c8826
diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c
index 5a3120d..9e8375e 100644
--- a/skeletons/GeneralizedTime.c
+++ b/skeletons/GeneralizedTime.c
@@ -9,6 +9,13 @@
 #include <assert.h>
 #endif	/* __NO_ASSERT_H__ */
 
+#ifdef	WIN32
+#define	localtime_r(tlocp, tmp)	(*tmp = localtime(&tlocp))
+#warning PLEASE STOP AND READ!
+#warning localtime_r is implemented via localtime(), which is not thread-safe. You must fix the code to insert appropriate locking if you want to use asn_GT2time() or asn_UT2time().
+#warning PLEASE STOP AND READ!
+#endif
+
 #ifndef	__NO_ASN_TABLE__
 
 /*
diff --git a/skeletons/OBJECT_IDENTIFIER.c b/skeletons/OBJECT_IDENTIFIER.c
index c910a8c..1e4fe59 100644
--- a/skeletons/OBJECT_IDENTIFIER.c
+++ b/skeletons/OBJECT_IDENTIFIER.c
@@ -359,11 +359,15 @@
 	unsigned LE = 1;
 	unsigned isLittleEndian = *(char *)&LE;
 #endif
-	uint8_t buffer[arcval_size];
 	uint8_t *tp, *tend;
 	unsigned int cache;
 	uint8_t *bp = arcbuf;
 	int bits;
+#ifdef	__GNUC__
+	uint8_t buffer[arcval_size];
+#else
+	uint8_t *buffer = alloca(arcval_size);
+#endif
 
 	if(isLittleEndian && !prepared_order) {
 		uint8_t *a = arcval + arcval_size - 1;
diff --git a/skeletons/asn_types.h b/skeletons/asn_types.h
index 6d42667..d2633f6 100644
--- a/skeletons/asn_types.h
+++ b/skeletons/asn_types.h
@@ -13,10 +13,29 @@
 #include <string.h>	/* For memcpy(3) */
 #include <sys/types.h>	/* For size_t */
 #include <stdarg.h>	/* For va_start */
-#include <inttypes.h>	/* C99 Standard specifies this file, for uintXX_t */
 #include <stddef.h>	/* for offsetof and ptrdiff_t */
+#if __STDC_VERSION__ < 199901L
+#include <inttypes.h>	/* C99 Standard specifies this file, for uintXX_t */
+#else
+typedef	unsigned char		uint8_t;
+typedef	unsigned short int	uint16_t;
+typedef	unsigned int		uint32_t;
+typedef	int			ssize_t;
+#endif
 
-#ifndef	offsetof
+#ifdef WIN32
+#define	 snprintf(str, size, format, args...)	\
+	_snprintf(str, size, format, ##args)
+#define	 vsnprintf(str, size, format, ap)	\
+	_vsnprintf(str, size, format, ap)
+#define	alloca(size)	_alloca(size)
+#endif
+
+#ifndef	__GNUC__
+#define	__attribute__(ignore)
+#endif
+
+#ifndef	offsetof	/* If not defined by <stddef.h> */
 #define	offsetof(s, m)	((ptrdiff_t)&(((s *)0)->m) - (ptrdiff_t)((s *)0))
 #endif	/* offsetof */