[or-cvs] Make Tor build on win32 with VC6 without warnings.

Nick Mathewson nickm at seul.org
Wed Apr 28 20:13:23 UTC 2004


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv16693/src/common

Modified Files:
	crypto.c log.c util.c util.h 
Log Message:
Make Tor build on win32 with VC6 without warnings.

Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- crypto.c	28 Apr 2004 19:35:11 -0000	1.83
+++ crypto.c	28 Apr 2004 20:13:20 -0000	1.84
@@ -4,6 +4,14 @@
 
 #include "orconfig.h"
 
+#ifdef MS_WINDOWS
+#define WIN32_WINNT 0x400
+#define _WIN32_WINNT 0x400
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <wincrypt.h>
+#endif
+
 #include <string.h>
 
 #include <openssl/err.h>
@@ -40,13 +48,6 @@
 #include "aes.h"
 #include "util.h"
 
-#ifdef MS_WINDOWS
-#define WIN32_WINNT 0x400
-#define _WIN32_WINNT 0x400
-#define WIN32_LEAN_AND_MEAN
-#include <wincrypt.h>
-#endif
-
 #if OPENSSL_VERSION_NUMBER < 0x00905000l
 #error "We require openssl >= 0.9.5"
 #elif OPENSSL_VERSION_NUMBER < 0x00906000l

Index: log.c
===================================================================
RCS file: /home/or/cvsroot/src/common/log.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- log.c	6 Apr 2004 03:44:35 -0000	1.37
+++ log.c	28 Apr 2004 20:13:20 -0000	1.38
@@ -12,6 +12,7 @@
 
 #ifdef MS_WINDOWS
 #define vsnprintf _vsnprintf
+#define snprintf _snprintf
 #endif
 
 struct logfile_t;

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- util.c	28 Apr 2004 19:35:11 -0000	1.90
+++ util.c	28 Apr 2004 20:13:21 -0000	1.91
@@ -3,6 +3,23 @@
 /* $Id$ */
 
 #include "orconfig.h"
+
+#ifdef MS_WINDOWS
+#define WIN32_WINNT 0x400
+#define _WIN32_WINNT 0x400
+#define WIN32_LEAN_AND_MEAN
+#if _MSC_VER > 1300
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#elif defined(_MSC_VER)
+#include <winsock.h>
+#endif
+#include <io.h>
+#include <process.h>
+#include <direct.h>
+#include <windows.h>
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -27,6 +44,9 @@
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
 #ifdef HAVE_SYS_LIMITS_H
 #include <sys/limits.h>
 #endif
@@ -57,17 +77,8 @@
 #ifdef HAVE_GRP_H
 #include <grp.h>
 #endif
-
-#ifdef HAVE_WINSOCK_H
-#define WIN32_WINNT 0x400
-#define _WIN32_WINNT 0x400
-#define WIN32_LEAN_AND_MEAN
-#endif
-#if _MSC_VER > 1300
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#elif defined(_MSC_VER)
-#include <winsock.h>
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
 #endif
 
 /* used by inet_addr, not defined on solaris anywhere!? */
@@ -152,13 +163,13 @@
 }
 
 #ifndef UNALIGNED_INT_ACCESS_OK
-uint16_t get_uint16(char *cp)
+uint16_t get_uint16(const char *cp)
 {
   uint16_t v;
   memcpy(&v,cp,2);
   return v;
 }
-uint32_t get_uint32(char *cp)
+uint32_t get_uint32(const char *cp)
 {
   uint32_t v;
   memcpy(&v,cp,4);

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- util.h	28 Apr 2004 19:35:11 -0000	1.57
+++ util.h	28 Apr 2004 20:13:21 -0000	1.58
@@ -36,8 +36,14 @@
 #define strncasecmp strnicmp
 #define strcasecmp stricmp
 #define INLINE __inline
+#define _ARRAYSIZE(x) (((x)==0)?1:0)
+/* Windows compilers before VC7 don't have __FUNCTION__. */
+#if _MSC_VER < 1300
+#define __FUNCTION__ "???"
+#endif
 #else
 #define INLINE inline
+#define _ARRAYSIZE(x) (x)
 #endif
 
 #ifdef NDEBUG
@@ -76,8 +82,8 @@
 #define set_uint32(cp,v) do { *(uint32_t*)(cp) = (v); } while (0)
 #else
 #if 1
-uint16_t get_uint16(char *cp);
-uint32_t get_uint32(char *cp);
+uint16_t get_uint16(const char *cp);
+uint32_t get_uint32(const char *cp);
 void set_uint16(char *cp, uint16_t v);
 void set_uint32(char *cp, uint32_t v);
 #else



More information about the tor-commits mailing list