[Sumover-dev] [svn commit] r4551 - rat/trunk

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Thu Jan 7 16:16:09 GMT 2010


Author: piers
Date: Thu Jan  7 16:16:09 2010
New Revision: 4551

Modified:
   rat/trunk/win32.c

Log:
- Added implementation of strcasestr() which doesn't exist on Windows - it's only required by [Linux] PulseAudio stuff so unlikely to be used on Windows but I wrote it anyway.
- Tweaked Windows socket initialisation code so that version 2 is the default and it falls back to version 1 if needs be (though v1 is so ancient I doubt it'll ever make a difference).

Modified: rat/trunk/win32.c
==============================================================================
--- rat/trunk/win32.c	(original)
+++ rat/trunk/win32.c	Thu Jan  7 16:16:09 2010
@@ -138,6 +138,35 @@
 
 static char szTemp[256];
 
+#ifndef strcasestr
+#include <ctype.h>
+char *strcasestr(const char *haystack, const char *needle)
+{
+        int i=-1;
+        while (haystack[++i] != '\0') {
+                if (tolower(haystack[i]) == tolower(needle[0])) {
+                        int j=i, k=0, match=0;
+                        while (tolower(haystack[++j]) == tolower(needle[++k])) {
+                                match=1;
+                            // Catch case when they match at the end
+                                  printf("j:%d, k:%d\n",j,k);
+                                if (haystack[j] == '\0' && needle[k] == '\0') {
+                                  printf("Mj:%d, k:%d\n",j,k);
+                                        return &haystack[i];
+                                }
+                        }
+                        // Catch normal case
+                        if (match && needle[k] == '\0'){
+                                  printf("Norm j:%d, k:%d\n",j,k);
+                                return &haystack[i];
+                        }
+                }
+        }
+        return NULL;
+}
+#endif
+
+#if 0
 int
 printf(const char *fmt, ...)
 {
@@ -151,6 +180,7 @@
 
 	return retval;
 }
+#endif
 
 int
 fprintf(FILE *f, const char *fmt, ...)
@@ -215,10 +245,12 @@
     char *p;
     WSADATA WSAdata;
     int r;
-    if (WSAStartup(WS_VERSION_TWO, &WSAdata) != 0 &&
-        WSAStartup(WS_VERSION_ONE, &WSAdata) != 0) {
-    	MessageBox(NULL, "Windows Socket initialization failed. TCP/IP stack\nis not installed or is damaged.", "Network Error", MB_OK | MB_ICONERROR);
-        exit(-1);
+	if (WSAStartup(WS_VERSION_TWO, &WSAdata) != 0) {
+		if (WSAStartup(WS_VERSION_ONE, &WSAdata) != 0) {
+    		MessageBox(NULL, "Windows Socket initialization failed. TCP/IP stack\nis not installed or is damaged.", "Network Error", MB_OK | MB_ICONERROR);
+			exit(-1);
+		}
+   		MessageBox(NULL, "Windows Socket initialization only found version One of TCP/IP stack\n Functionality may be limited.", "Network Error", MB_OK | MB_ICONERROR);
     }
 
     debug_msg("WSAStartup OK: %sz\nStatus:%s\n", WSAdata.szDescription, WSAdata.szSystemStatus);



More information about the Sumover-dev mailing list