mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-12 23:40:04 +00:00
start of windows port
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10899 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
1bda469485
commit
65b9fe8e8b
@ -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 @@ esl_status_t esl_listen(const char *host, esl_port_t port, esl_listen_callback_t
|
||||
end:
|
||||
|
||||
if (server_sock != ESL_SOCK_INVALID) {
|
||||
close(server_sock);
|
||||
closesocket(server_sock);
|
||||
server_sock = ESL_SOCK_INVALID;
|
||||
}
|
||||
|
||||
@ -474,14 +477,14 @@ 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->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 @@ esl_status_t esl_disconnect(esl_handle_t *handle)
|
||||
}
|
||||
|
||||
if (handle->sock != ESL_SOCK_INVALID) {
|
||||
close(handle->sock);
|
||||
closesocket(handle->sock);
|
||||
handle->sock = ESL_SOCK_INVALID;
|
||||
return ESL_SUCCESS;
|
||||
}
|
||||
@ -604,7 +607,7 @@ esl_status_t esl_recv_event(esl_handle_t *handle, esl_event_t **save_event)
|
||||
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 @@ esl_status_t esl_recv_event(esl_handle_t *handle, esl_event_t **save_event)
|
||||
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 @@ esl_status_t esl_recv_event(esl_handle_t *handle, esl_event_t **save_event)
|
||||
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 @@ esl_status_t esl_recv_event(esl_handle_t *handle, esl_event_t **save_event)
|
||||
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 @@ esl_status_t esl_recv_event(esl_handle_t *handle, esl_event_t **save_event)
|
||||
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;
|
||||
|
@ -214,19 +214,24 @@ int esl_config_get_cas_bits(char *strvalue, unsigned char *outbits)
|
||||
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;
|
||||
|
@ -153,9 +153,11 @@ typedef struct esl_event esl_event_t;
|
||||
#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 @@ typedef struct esl_event esl_event_t;
|
||||
#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 __int16 int16_t;
|
||||
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 @@ typedef struct {
|
||||
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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user