]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
support mac
authorAnthony Minessale <anthony.minessale@gmail.com>
Sun, 21 Dec 2008 23:31:57 +0000 (23:31 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Sun, 21 Dec 2008 23:31:57 +0000 (23:31 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10903 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/esl/src/esl.c
libs/esl/src/include/esl.h

index 44c5557b60ea9ce0e0fefb005a6a821164054b03..c8f2b7ead26e3e206279b2604554ca7f5d7b1ec2 100644 (file)
 #define closesocket(x) close(x)
 #endif
 
-#ifndef HAVE_GETHOSTBYNAME_R
-extern int gethostbyname_r (const char *__name,
-                            struct hostent *__result_buf,
-                            char *__buf, size_t __buflen,
-                            struct hostent **__result,
-                            int *__h_errnump);
-#endif
-
 
 
 /* Written by Marc Espie, public domain */
@@ -456,7 +448,7 @@ esl_status_t esl_connect(esl_handle_t *handle, const char *host, esl_port_t port
 
        struct hostent *result;
        char sendbuf[256];
-       int rval;
+       int rval = 0;
        const char *hval;
 
        if (!handle->mutex) {
@@ -476,19 +468,18 @@ esl_status_t esl_connect(esl_handle_t *handle, const char *host, esl_port_t port
 
     memset(&handle->hostent, 0, sizeof(handle->hostent));
 
-#ifdef HAVE_GETHOSTBYNAME_R_FIVE
-       rval = gethostbyname_r(host, &handle->hostent, handle->hostbuf, sizeof(handle->hostbuf), &handle->errnum);
-       result = handle->hostent;
-#else
-       rval = gethostbyname_r(host, &handle->hostent, handle->hostbuf, sizeof(handle->hostbuf), &result, &handle->errnum);
-#endif
+       if ((result = gethostbyname(host))) {
+               handle->hostent = *result;
+       } else {
+               rval = -1;
+       }
        
        if (rval) {
                strerror_r(handle->errnum, handle->err, sizeof(handle->err));
                goto fail;
        }
 
-       memcpy(&handle->sockaddr.sin_addr, result->h_addr, result->h_length);
+       memcpy(&handle->sockaddr.sin_addr, result->h_addr_list[0], result->h_length);
        
        rval = connect(handle->sock, (struct sockaddr *) &handle->sockaddr, sizeof(handle->sockaddr));
        
index 8d144cfefcf6dbc08eec0bb33c95708dcd9fe705..cf5fc084498a170734b72a49313748f51fa7d4c3 100644 (file)
 #define _ESL_H_
 
 
+#include <stdarg.h>
+int vasprintf(char **ret, const char *format, va_list ap);
+
+
 #define esl_copy_string(_x, _y, _z) strncpy(_x, _y, _z - 1)
 #define esl_set_string(_x, _y) esl_copy_string(_x, _y, sizeof(_x))