Author: mikej Date: Sun Dec 21 17:13:20 2008 New Revision: 10899 Log: start of windows port Modified: freeswitch/trunk/libs/esl/src/esl.c freeswitch/trunk/libs/esl/src/esl_config.c freeswitch/trunk/libs/esl/src/include/esl.h Modified: freeswitch/trunk/libs/esl/src/esl.c ============================================================================== --- freeswitch/trunk/libs/esl/src/esl.c (original) +++ freeswitch/trunk/libs/esl/src/esl.c Sun Dec 21 17:13:20 2008 @@ -32,13 +32,16 @@ */ #include <esl.h> +#ifndef WIN32 +#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_errnop); + int *__h_errnump); #endif @@ -440,7 +443,7 @@ end: if (server_sock != ESL_SOCK_INVALID) { - close(server_sock); + closesocket(server_sock); server_sock = ESL_SOCK_INVALID; } @@ -474,14 +477,14 @@ memset(&handle->hostent, 0, sizeof(handle->hostent)); #ifdef HAVE_GETHOSTBYNAME_R_FIVE - rval = gethostbyname_r(host, &handle->hostent, handle->hostbuf, sizeof(handle->hostbuf), &handle->errno); + 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->errno); + rval = gethostbyname_r(host, &handle->hostent, handle->hostbuf, sizeof(handle->hostbuf), &result, &handle->errnum); #endif if (rval) { - strerror_r(handle->errno, handle->err, sizeof(handle->err)); + strerror_r(handle->errnum, handle->err, sizeof(handle->err)); goto fail; } @@ -546,7 +549,7 @@ } if (handle->sock != ESL_SOCK_INVALID) { - close(handle->sock); + closesocket(handle->sock); handle->sock = ESL_SOCK_INVALID; return ESL_SUCCESS; } @@ -604,7 +607,7 @@ char *hname, *hval; char *col; char *cl; - ssize_t len; + esl_ssize_t len; int zc = 0; esl_mutex_lock(handle->mutex); @@ -625,7 +628,7 @@ return ESL_FAIL; } } else if (rrval < 0) { - strerror_r(handle->errno, handle->err, sizeof(handle->err)); + strerror_r(handle->errnum, handle->err, sizeof(handle->err)); goto fail; } else { zc = 0; @@ -685,7 +688,7 @@ do { esl_ssize_t r; if ((r = recv(handle->sock, body + sofar, len - sofar, 0)) < 0) { - strerror_r(handle->errno, handle->err, sizeof(handle->err)); + strerror_r(handle->errnum, handle->err, sizeof(handle->err)); goto fail; } sofar += r; @@ -717,7 +720,7 @@ char *hname, *hval; char *col; char *cl; - ssize_t len; + esl_ssize_t len; char *c; esl_event_safe_destroy(&handle->last_ievent); @@ -775,7 +778,7 @@ do { esl_ssize_t r; if ((r = recv(handle->sock, body + sofar, len - sofar, 0)) < 0) { - strerror_r(handle->errno, handle->err, sizeof(handle->err)); + strerror_r(handle->errnum, handle->err, sizeof(handle->err)); goto fail; } sofar += r; Modified: freeswitch/trunk/libs/esl/src/esl_config.c ============================================================================== --- freeswitch/trunk/libs/esl/src/esl_config.c (original) +++ freeswitch/trunk/libs/esl/src/esl_config.c Sun Dec 21 17:13:20 2008 @@ -214,19 +214,24 @@ char cas_bits[5]; unsigned char bit = 0x8; char *double_colon = strchr(strvalue, ':'); + int x = 0; + if (!double_colon) { esl_log(ESL_LOG_ERROR, "No CAS bits specified: %s, :xxxx definition expected, where x is 1 or 0\n", double_colon); return -1; } + double_colon++; *outbits = 0; cas_bits[4] = 0; + if (sscanf(double_colon, "%c%c%c%c", &cas_bits[0], &cas_bits[1], &cas_bits[2], &cas_bits[3]) != 4) { esl_log(ESL_LOG_ERROR, "Invalid CAS bits specified: %s, :xxxx definition expected, where x is 1 or 0\n", double_colon); return -1; } + esl_log(ESL_LOG_DEBUG, "CAS bits specification found: %s\n", cas_bits); - int x = 0; + for (; cas_bits[x]; x++) { if ('1' == cas_bits[x]) { *outbits |= bit; Modified: freeswitch/trunk/libs/esl/src/include/esl.h ============================================================================== --- freeswitch/trunk/libs/esl/src/include/esl.h (original) +++ freeswitch/trunk/libs/esl/src/include/esl.h Sun Dec 21 17:13:20 2008 @@ -153,9 +153,11 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#ifndef WIN32 #include <sys/signal.h> #include <unistd.h> #include <ctype.h> +#endif #ifdef HAVE_STRINGS_H #include <strings.h> @@ -168,8 +170,9 @@ #define esl_strlen_zero_buf(s) (*(s) == '\0') #ifdef WIN32 +#include <winsock2.h> #include <windows.h> -typedef HANDLE esl_socket_t; +typedef SOCKET esl_socket_t; typedef unsigned __int64 uint64_t; typedef unsigned __int32 uint32_t; typedef unsigned __int16 uint16_t; @@ -180,6 +183,7 @@ typedef __int8 int8_t; typedef intptr_t esl_ssize_t; typedef int esl_filehandle_t; +#define ESL_SOCK_INVALID INVALID_SOCKET #else #include <stdint.h> #include <sys/types.h> @@ -211,7 +215,7 @@ char hostbuf[256]; esl_socket_t sock; char err[256]; - int errno; + int errnum; char header_buf[4196]; char last_reply[1024]; char last_sr_reply[1024];