Kaydet (Commit) a2e48552 authored tarafından Guido van Rossum's avatar Guido van Rossum

It appears that inet_aton() doesn't really exist except in libresolv;

the proper function to call is inet_addr().  Since we already had code
to do that (for MS-Windows), this simplifies things a lot!
üst a41c6913
...@@ -1807,26 +1807,10 @@ binary format used in low-level network functions."; ...@@ -1807,26 +1807,10 @@ binary format used in low-level network functions.";
static PyObject* static PyObject*
BUILD_FUNC_DEF_2(PySocket_inet_aton, PyObject *, self, PyObject *, args) BUILD_FUNC_DEF_2(PySocket_inet_aton, PyObject *, self, PyObject *, args)
{ {
#ifndef MS_WINDOWS #ifndef INADDR_NONE
char *ip_addr; #define INADDR_NONE (-1)
struct in_addr packed_addr; #endif
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;
}
return PyString_FromStringAndSize((char *) &packed_addr,
sizeof(packed_addr));
#else /* MS_WINDOWS */
/* Have to use inet_addr() instead */ /* Have to use inet_addr() instead */
char *ip_addr; char *ip_addr;
long packed_addr; long packed_addr;
...@@ -1845,7 +1829,6 @@ BUILD_FUNC_DEF_2(PySocket_inet_aton, PyObject *, self, PyObject *, args) ...@@ -1845,7 +1829,6 @@ BUILD_FUNC_DEF_2(PySocket_inet_aton, PyObject *, self, PyObject *, args)
return PyString_FromStringAndSize((char *) &packed_addr, return PyString_FromStringAndSize((char *) &packed_addr,
sizeof(packed_addr)); sizeof(packed_addr));
#endif /* MS_WINDOWS */
} }
static char inet_ntoa_doc[] = static char inet_ntoa_doc[] =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment