]> granicus.if.org Git - python/commitdiff
It appears that inet_aton() doesn't really exist except in libresolv;
authorGuido van Rossum <guido@python.org>
Thu, 9 Sep 1999 15:42:59 +0000 (15:42 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 9 Sep 1999 15:42:59 +0000 (15:42 +0000)
the proper function to call is inet_addr().  Since we already had code
to do that (for MS-Windows), this simplifies things a lot!

Modules/socketmodule.c

index e64090e208babc00262f926b38c083d8827032d4..93a3b0996492d3b6cd5265e823e0348f9c78de1c 100644 (file)
@@ -1807,26 +1807,10 @@ binary format used in low-level network functions.";
 static PyObject*
 BUILD_FUNC_DEF_2(PySocket_inet_aton, PyObject *, self, PyObject *, args)
 {
-#ifndef MS_WINDOWS
-       char *ip_addr;
-       struct in_addr packed_addr;
-       int err;
-
-       if (!PyArg_Parse(args, "s", &ip_addr)) {
-               return NULL;
-       }
-       
-       err = inet_aton(ip_addr, &packed_addr);
-
-       if (err == 0) {         /* invalid address */
-               PyErr_SetString(PySocket_Error,
-                       "illegal IP address string passed to inet_aton");
-               return NULL;
-       }
+#ifndef INADDR_NONE
+#define INADDR_NONE (-1)
+#endif
 
-       return PyString_FromStringAndSize((char *) &packed_addr,
-                                         sizeof(packed_addr));
-#else /* MS_WINDOWS */
        /* Have to use inet_addr() instead */
        char *ip_addr;
        long packed_addr;
@@ -1845,7 +1829,6 @@ BUILD_FUNC_DEF_2(PySocket_inet_aton, PyObject *, self, PyObject *, args)
 
        return PyString_FromStringAndSize((char *) &packed_addr,
                                          sizeof(packed_addr));
-#endif /* MS_WINDOWS */
 }
 
 static char inet_ntoa_doc[] =