diff options
author | Guido van Rossum <guido@python.org> | 1999-03-24 17:20:40 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-03-24 17:20:40 (GMT) |
commit | 7b6c71f5a438647618d095b85728bf4d0c011353 (patch) | |
tree | 1f2042cc1a5004f569d97621dacea5a7221d0513 /Modules/socketmodule.c | |
parent | e256a0feed699a0bf9c22be0a0e0995632cfa4c4 (diff) | |
download | cpython-7b6c71f5a438647618d095b85728bf4d0c011353.zip cpython-7b6c71f5a438647618d095b85728bf4d0c011353.tar.gz cpython-7b6c71f5a438647618d095b85728bf4d0c011353.tar.bz2 |
Vladimir Marangozov implements the AIX 3-arg gethostbyname_r code.
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index c3524bd..8415d90 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -87,11 +87,6 @@ Socket methods: #include "Python.h" -#if defined(HAVE_GETHOSTBYNAME_R) && defined(HAVE_GETHOSTBYNAME_R_3_ARG) -/* XXX Somebody please submit code for the 3-arg version! */ -#undef HAVE_GETHOSTBYNAME_R -#endif - #if !defined(HAVE_GETHOSTBYNAME_R) && defined(WITH_THREAD) && !defined(MS_WINDOWS) #define USE_GETHOSTBYNAME_LOCK #endif @@ -342,10 +337,14 @@ BUILD_FUNC_DEF_2(setipaddr, char*,name, struct sockaddr_in *,addr_ret) char ch; #ifdef HAVE_GETHOSTBYNAME_R struct hostent hp_allocated; +#ifdef HAVE_GETHOSTBYNAME_R_3_ARG + struct hostent_data data; +#else char buf[1001]; int buf_len = (sizeof buf) - 1; int errnop; -#ifdef HAVE_GETHOSTBYNAME_R_6_ARG +#endif +#if defined(HAVE_GETHOSTBYNAME_R_3_ARG) || defined(HAVE_GETHOSTBYNAME_R_6_ARG) int result; #endif #endif /* HAVE_GETHOSTBYNAME_R */ @@ -369,10 +368,13 @@ BUILD_FUNC_DEF_2(setipaddr, char*,name, struct sockaddr_in *,addr_ret) } Py_BEGIN_ALLOW_THREADS #ifdef HAVE_GETHOSTBYNAME_R -#ifdef HAVE_GETHOSTBYNAME_R_6_ARG +#if defined(HAVE_GETHOSTBYNAME_R_6_ARG) result = gethostbyname_r(name, &hp_allocated, buf, buf_len, &hp, &errnop); -#else +#elif defined(HAVE_GETHOSTBYNAME_R_5_ARG) hp = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop); +#else /* HAVE_GETHOSTBYNAME_R_3_ARG */ + result = gethostbyname_r(name, &hp_allocated, &data); + hp = (result != 0) ? NULL : &hp_allocated; #endif #else /* not HAVE_GETHOSTBYNAME_R */ #ifdef USE_GETHOSTBYNAME_LOCK @@ -1427,10 +1429,14 @@ BUILD_FUNC_DEF_2(PySocket_gethostbyname_ex,PyObject *,self, PyObject *,args) PyObject *ret; #ifdef HAVE_GETHOSTBYNAME_R struct hostent hp_allocated; +#ifdef HAVE_GETHOSTBYNAME_R_3_ARG + struct hostent_data data; +#else char buf[16384]; int buf_len = (sizeof buf) - 1; int errnop; -#ifdef HAVE_GETHOSTBYNAME_R_6_ARG +#endif +#if defined(HAVE_GETHOSTBYNAME_R_3_ARG) || defined(HAVE_GETHOSTBYNAME_R_6_ARG) int result; #endif #endif /* HAVE_GETHOSTBYNAME_R */ @@ -1440,10 +1446,13 @@ BUILD_FUNC_DEF_2(PySocket_gethostbyname_ex,PyObject *,self, PyObject *,args) return NULL; Py_BEGIN_ALLOW_THREADS #ifdef HAVE_GETHOSTBYNAME_R -#ifdef HAVE_GETHOSTBYNAME_R_6_ARG +#if defined(HAVE_GETHOSTBYNAME_R_6_ARG) result = gethostbyname_r(name, &hp_allocated, buf, buf_len, &h, &errnop); -#else +#elif defined(HAVE_GETHOSTBYNAME_R_5_ARG) h = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop); +#else /* HAVE_GETHOSTBYNAME_R_3_ARG */ + result = gethostbyname_r(name, &hp_allocated, &data); + h = (result != 0) ? NULL : &hp_allocated; #endif #else /* not HAVE_GETHOSTBYNAME_R */ #ifdef USE_GETHOSTBYNAME_LOCK @@ -1478,10 +1487,14 @@ BUILD_FUNC_DEF_2(PySocket_gethostbyaddr,PyObject *,self, PyObject *, args) PyObject *ret; #ifdef HAVE_GETHOSTBYNAME_R struct hostent hp_allocated; +#ifdef HAVE_GETHOSTBYNAME_R_3_ARG + struct hostent_data data; +#else char buf[16384]; int buf_len = (sizeof buf) - 1; int errnop; -#ifdef HAVE_GETHOSTBYNAME_R_6_ARG +#endif +#if defined(HAVE_GETHOSTBYNAME_R_3_ARG) || defined(HAVE_GETHOSTBYNAME_R_6_ARG) int result; #endif #endif /* HAVE_GETHOSTBYNAME_R */ @@ -1492,16 +1505,21 @@ BUILD_FUNC_DEF_2(PySocket_gethostbyaddr,PyObject *,self, PyObject *, args) return NULL; Py_BEGIN_ALLOW_THREADS #ifdef HAVE_GETHOSTBYNAME_R -#ifdef HAVE_GETHOSTBYNAME_R_6_ARG +#if defined(HAVE_GETHOSTBYNAME_R_6_ARG) result = gethostbyaddr_r((char *)&addr.sin_addr, sizeof(addr.sin_addr), AF_INET, &hp_allocated, buf, buf_len, &h, &errnop); -#else +#elif defined(HAVE_GETHOSTBYNAME_R_5_ARG) h = gethostbyaddr_r((char *)&addr.sin_addr, sizeof(addr.sin_addr), AF_INET, &hp_allocated, buf, buf_len, &errnop); +#else /* HAVE_GETHOSTBYNAME_R_3_ARG */ + result = gethostbyaddr_r((char *)&addr.sin_addr, + sizeof(addr.sin_addr), + AF_INET, &hp_allocated, &data); + h = (result != 0) ? NULL : &hp_allocated; #endif #else /* not HAVE_GETHOSTBYNAME_R */ #ifdef USE_GETHOSTBYNAME_LOCK |