First set of changes for windows
[cascardo/gnio.git] / gnio / ginet4address.c
index a7473f8..7ab6361 100644 (file)
@@ -1,6 +1,6 @@
 /* GNIO - GLib Network Layer of GIO
  * 
- * Copyright (C) 2008 Christian Kellner 
+ * Copyright (C) 2008 Christian Kellner, Samuel Cormier-Iijima
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  * Boston, MA 02111-1307, USA.
  *
- * Author: Christian Kellner <gicmo@gnome.org>
+ * Authors: Christian Kellner <gicmo@gnome.org>
+ *          Samuel Cormier-Iijima <sciyoshi@gmail.com>
  */
 
 #include <config.h>
 #include <glib.h>
 
-#include <netinet/in.h>
-#include <arpa/inet.h>
+#ifndef G_OS_WIN32
+# include <netinet/in.h>
+# include <arpa/inet.h>
+#else
+# include <winsock2.h>
+# define IN_LOOPBACKNET 127
+#endif
 
 #include "ginet4address.h"
 
@@ -178,11 +184,20 @@ g_inet4_address_from_string (const gchar *string)
 {
   struct in_addr addr;
 
+#ifndef G_OS_WIN32
   if (!inet_aton (string, &addr))
     {
       g_warning ("Could not parse IP address %s", string);
       return NULL;
     }
+#else
+  addr.s_addr = inet_addr (string);
+  if (addr.s_addr == INADDR_NONE)
+    {
+      g_warning ("Could not parse IP address %s", string);
+      return NULL;
+    }
+#endif
 
   return g_inet4_address_from_bytes ((guint8 *) &(addr.s_addr));
 }