Merge pull request #12 from jameinel/win32-project

Some updates to make the code compatible with VC 9 (2008)
diff --git a/.gitignore b/.gitignore
index a4cab25..6acd819 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,4 +21,6 @@
 test2
 test4
 testSubDir
-test_parse_int64
\ No newline at end of file
+test_parse_int64
+Debug
+Release
diff --git a/json_inttypes.h b/json_inttypes.h
index 1cbafc2..1f3e4d2 100644
--- a/json_inttypes.h
+++ b/json_inttypes.h
@@ -5,6 +5,9 @@
 #if defined(_MSC_VER) && _MSC_VER < 1600
 
 /* Anything less than Visual Studio C++ 10 is missing stdint.h and inttypes.h */
+typedef __int32 int32_t;
+#define INT32_MIN    ((int32_t)_I32_MIN)
+#define INT32_MAX    ((int32_t)_I32_MAX)
 typedef __int64 int64_t;
 #define PRId64 "I64d"
 #define SCNd64 "I64d"
diff --git a/json_object.c b/json_object.c
index bc09d65..65c1f6c 100644
--- a/json_object.c
+++ b/json_object.c
@@ -321,10 +321,13 @@
 
 int32_t json_object_get_int(struct json_object *jso)
 {
+  int64_t cint64;
+  enum json_type o_type;
+
   if(!jso) return 0;
 
-  enum json_type o_type = jso->o_type;
-  int64_t cint64 = jso->o.c_int64;
+  o_type = jso->o_type;
+  cint64 = jso->o.c_int64;
 
   if (o_type == json_type_string)
   {
diff --git a/json_util.c b/json_util.c
index dab3d8c..c6db882 100644
--- a/json_util.c
+++ b/json_util.c
@@ -130,13 +130,15 @@
 int json_parse_int64(const char *buf, int64_t *retval)
 {
 	int64_t num64;
+	const char *buf_skip_space;
+	int orig_has_neg;
 	if (sscanf(buf, "%" SCNd64, &num64) != 1)
 	{
 		MC_DEBUG("Failed to parse, sscanf != 1\n");
 		return 1;
 	}
-	const char *buf_skip_space = buf;
-	int orig_has_neg = 0;
+	buf_skip_space = buf;
+	orig_has_neg = 0;
 	// Skip leading spaces
 	while (isspace((int)*buf_skip_space) && *buf_skip_space)
 		buf_skip_space++;
@@ -156,6 +158,7 @@
 		char buf_cmp[100];
 		char *buf_cmp_start = buf_cmp;
 		int recheck_has_neg = 0;
+		int buf_cmp_len;
 		snprintf(buf_cmp_start, sizeof(buf_cmp), "%" PRId64, num64);
 		if (*buf_cmp_start == '-')
 		{
@@ -164,7 +167,7 @@
 		}
 		// No need to skip leading spaces or zeros here.
 
-		int buf_cmp_len = strlen(buf_cmp_start);
+		buf_cmp_len = strlen(buf_cmp_start);
 		/**
 		 * If the sign is different, or
 		 * some of the digits are different, or
diff --git a/printbuf.c b/printbuf.c
index 6ed1e94..e8902c8 100644
--- a/printbuf.c
+++ b/printbuf.c
@@ -65,7 +65,7 @@
   return size;
 }
 
-#if !HAVE_VSNPRINTF && defined(WIN32)
+#if !HAVE_VSNPRINTF && defined(_MSC_VER)
 # define vsnprintf _vsnprintf
 #elif !HAVE_VSNPRINTF /* !HAVE_VSNPRINTF */
 # error Need vsnprintf!