Commit 058bfd14 authored by Ghislain MARY's avatar Ghislain MARY

Port to Windows Phone 8.

parent 83522d29
......@@ -76,6 +76,7 @@ static unsigned int belle_sip_source_get_revents(belle_sip_source_t *s,belle_sip
#include <malloc.h>
typedef HANDLE belle_sip_pollfd_t;
static void belle_sip_source_to_poll(belle_sip_source_t *s, belle_sip_pollfd_t *pfd,int i){
......@@ -126,7 +127,7 @@ static int belle_sip_poll(belle_sip_pollfd_t *pfd, int count, int duration){
DWORD ret;
if (count == 0) {
Sleep(duration);
belle_sip_sleep(duration);
return 0;
}
......
......@@ -495,8 +495,11 @@ uint64_t belle_sip_time_ms(void){
}
#else
uint64_t belle_sip_time_ms(void){
#if WINAPI_FAMILY_APP
return GetTickCount64();
#else
return GetTickCount();
/* note use GetTickCount64 on windows phone 8*/
#endif
}
#endif
......
......@@ -72,8 +72,10 @@
#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#if !WINAPI_FAMILY_APP
#include <IPHlpApi.h>
#pragma comment(lib, "IPHLPAPI.lib")
#endif
#else
#include <sys/types.h> /* FD_SETSIZE socklen_t */
#include <sys/select.h> /* FD_ZERO FD_SET fd_set select(2) */
......@@ -4291,23 +4293,37 @@ int dns_resconf_loadpath(struct dns_resolv_conf *resconf, const char *path) {
#ifdef _WIN32
int dns_resconf_loadwin(struct dns_resolv_conf *resconf) {
#if WINAPI_FAMILY_APP
const char * const nameservers[] = {
"8.8.8.8",
"8.8.4.4"
};
int i;
int error = 0;
for (i = 0; !error && (i < lengthof(nameservers)); i++) {
error = dns_resconf_pton(&resconf->nameserver[i], nameservers[i]);
}
return error;
#else
FIXED_INFO *pFixedInfo;
ULONG ulOutBufLen;
DWORD dwRetVal;
IP_ADDR_STRING *pIPAddr;
unsigned int sa_count = 0;
int error;
int error = -1;
pFixedInfo = (FIXED_INFO *) malloc(sizeof(FIXED_INFO));
if (pFixedInfo == NULL) {
return -1;
return error;
}
ulOutBufLen = sizeof(FIXED_INFO);
if (GetNetworkParams(pFixedInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {
free(pFixedInfo);
pFixedInfo = (FIXED_INFO *) malloc(ulOutBufLen);
if (pFixedInfo == NULL) {
return -1;
return error;
}
}
......@@ -4322,6 +4338,7 @@ int dns_resconf_loadwin(struct dns_resolv_conf *resconf) {
}
return error;
#endif
} /* dns_resconf_loadwin() */
#endif
......@@ -9344,4 +9361,3 @@ int main(int argc, char **argv) {
#elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4
#pragma GCC diagnostic pop
#endif
......@@ -68,6 +68,15 @@ const char *belle_sip_get_socket_error_string_from_code(int code){
return (const char *)msgBuf;
}
#if WINAPI_FAMILY_APP
void belle_sip_sleep(unsigned int ms) {
HANDLE sleepEvent = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS);
if (!sleepEvent)
return;
WaitForSingleObjectEx(sleepEvent, ms, FALSE);
}
#endif
#else
int belle_sip_init_sockets(){
......
......@@ -83,6 +83,12 @@ static inline int get_socket_error(void){
const char *belle_sip_get_socket_error_string();
const char *belle_sip_get_socket_error_string_from_code(int code);
#if WINAPI_FAMILY_APP
BELLESIP_INTERNAL_EXPORT void belle_sip_sleep(unsigned int ms);
#else
#define belle_sip_sleep Sleep
#endif
#define usleep(us) Sleep((us)/1000)
static inline int inet_aton(const char *ip, struct in_addr *p){
*(long*)p=inet_addr(ip);
......
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