2003-06-24 Mikael Hallendal <micke@imendio.com>
* loudmouth/lm-connection.c:
* loudmouth/lm-sha.c:
* loudmouth/test-lm.c:
- Submitted patch that makes Loudmouth work and build on Win32.
Patch sent by Vince Negri, thanks a lot.
--- a/ChangeLog Sun Jun 15 12:00:57 2003 +0000
+++ b/ChangeLog Mon Jun 23 23:21:40 2003 +0000
@@ -1,3 +1,11 @@
+2003-06-24 Mikael Hallendal <micke@imendio.com>
+
+ * loudmouth/lm-connection.c:
+ * loudmouth/lm-sha.c:
+ * loudmouth/test-lm.c:
+ - Submitted patch that makes Loudmouth work and build on Win32.
+ Patch sent by Vince Negri, thanks a lot.
+
2003-06-15 Mikael Hallendal <micke@imendio.com>
* loudmouth/lm-message.c:
--- a/loudmouth/lm-connection.c Sun Jun 15 12:00:57 2003 +0000
+++ b/loudmouth/lm-connection.c Mon Jun 23 23:21:40 2003 +0000
@@ -21,12 +21,17 @@
#include <config.h>
-#include <netdb.h>
+#ifndef __WIN32__
+ #include <netdb.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+#else
+ #include <winsock2.h>
+#endif
+
#include <string.h>
#include <unistd.h>
-#include <sys/socket.h>
#include <sys/types.h>
-#include <netinet/in.h>
#include "lm-debug.h"
#include "lm-error.h"
--- a/loudmouth/lm-sha.c Sun Jun 15 12:00:57 2003 +0000
+++ b/loudmouth/lm-sha.c Mon Jun 23 23:21:40 2003 +0000
@@ -190,7 +190,11 @@
setEndian ();
#endif /* RUNTIME_ENDIAN */
+#ifdef __WIN32__
+ sc->totalLength = 0L;
+#else
sc->totalLength = 0LL;
+#endif
sc->hash[0] = 0x67452301L;
sc->hash[1] = 0xefcdab89L;
sc->hash[2] = 0x98badcfeL;
@@ -593,6 +597,10 @@
}
}
+#ifdef __WIN32__
+#define snprintf _snprintf
+#endif
+
const gchar *
lm_sha_hash (const gchar *str)
{
--- a/loudmouth/test-lm.c Sun Jun 15 12:00:57 2003 +0000
+++ b/loudmouth/test-lm.c Mon Jun 23 23:21:40 2003 +0000
@@ -24,6 +24,9 @@
#include <glib.h>
#include <string.h>
#include <loudmouth/loudmouth.h>
+#ifdef __WIN32__
+#include <winsock2.h>
+#endif
#include "lm-internals.h"
#define USAGE "Usage: test-lm <server> <username> <password>\n"
@@ -57,7 +60,7 @@
g_print ("Connected callback\n");
lm_connection_authenticate (connection,
info->name, info->passwd, "TestLM",
- FALSE, authentication_cb, NULL, NULL);
+ authentication_cb, NULL,FALSE, NULL);
g_print ("Sent auth message\n");
}
@@ -81,12 +84,43 @@
LmMessageHandler *handler;
gboolean result;
UserInfo *info;
+#ifdef __WIN32__
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ int err;
+#endif
if (argc < 4) {
g_print (USAGE);
return 1;
}
+/* Needed to build on Win32. */
+#ifdef __WIN32__
+ wVersionRequested = MAKEWORD( 2, 2 );
+
+ err = WSAStartup( wVersionRequested, &wsaData );
+ if ( err != 0 ) {
+ /* Tell the user that we could not find a usable */
+ /* WinSock DLL. */
+ return;
+ }
+
+ /* Confirm that the WinSock DLL supports 2.2.*/
+ /* Note that if the DLL supports versions greater */
+ /* than 2.2 in addition to 2.2, it will still return */
+ /* 2.2 in wVersion since that is the version we */
+ /* requested. */
+
+ if ( LOBYTE( wsaData.wVersion ) != 2 ||
+ HIBYTE( wsaData.wVersion ) != 2 ) {
+ /* Tell the user that we could not find a usable */
+ /* WinSock DLL. */
+ WSACleanup( );
+ return;
+ }
+#endif
+
connection = lm_connection_new (argv[1]);
handler = lm_message_handler_new (handle_messages, NULL, NULL);