Commit e532cd49 authored by jehan's avatar jehan
Browse files

Merge branch 'master' of git.linphone.org:belle-sip

parents a8c40518 086bb16b
......@@ -48,8 +48,8 @@
#endif
#define BELLE_SIP_POINTER_TO_INT(p) ((int)(long)(p))
#define BELLE_SIP_INT_TO_POINTER(i) ((void*)(long)(i))
#define BELLE_SIP_POINTER_TO_INT(p) ((int)(intptr_t)(p))
#define BELLE_SIP_INT_TO_POINTER(i) ((void*)(intptr_t)(i))
#endif
......@@ -410,9 +410,9 @@ typedef struct _belle_sip_header_content_length belle_sip_header_content_length_
BELLESIP_EXPORT belle_sip_header_content_length_t* belle_sip_header_content_length_new(void);
BELLESIP_EXPORT belle_sip_header_content_length_t* belle_sip_header_content_length_parse (const char* content_length) ;
BELLESIP_EXPORT belle_sip_header_content_length_t* belle_sip_header_content_length_create (int content_length) ;
BELLESIP_EXPORT unsigned int belle_sip_header_content_length_get_content_length(const belle_sip_header_content_length_t* content_length);
BELLESIP_EXPORT void belle_sip_header_content_length_set_content_length(belle_sip_header_content_length_t* content_length,unsigned int length);
BELLESIP_EXPORT belle_sip_header_content_length_t* belle_sip_header_content_length_create (size_t content_length) ;
BELLESIP_EXPORT size_t belle_sip_header_content_length_get_content_length(const belle_sip_header_content_length_t* content_length);
BELLESIP_EXPORT void belle_sip_header_content_length_set_content_length(belle_sip_header_content_length_t* content_length,size_t length);
#define BELLE_SIP_HEADER_CONTENT_LENGTH(t) BELLE_SIP_CAST(t,belle_sip_header_content_length_t)
#define BELLE_SIP_CONTENT_LENGTH "Content-Length"
......
......@@ -133,9 +133,9 @@ BELLESIP_EXPORT const char* belle_sip_message_get_body(belle_sip_message_t *msg)
BELLESIP_EXPORT size_t belle_sip_message_get_body_size(const belle_sip_message_t *msg);
BELLESIP_EXPORT void belle_sip_message_set_body(belle_sip_message_t *msg,const char* body,unsigned int size);
BELLESIP_EXPORT void belle_sip_message_set_body(belle_sip_message_t *msg,const char* body,size_t size);
BELLESIP_EXPORT void belle_sip_message_assign_body(belle_sip_message_t *msg, char* body, unsigned int size);
BELLESIP_EXPORT void belle_sip_message_assign_body(belle_sip_message_t *msg, char* body, size_t size);
BELLESIP_EXPORT int belle_sip_response_get_status_code(const belle_sip_response_t *response);
BELLESIP_EXPORT void belle_sip_response_set_status_code(belle_sip_response_t *response,int status);
......
......@@ -61,6 +61,10 @@ BELLESIP_EXPORT unsigned char belle_sip_stack_dns_srv_enabled(const belle_sip_st
BELLESIP_EXPORT void belle_sip_stack_enable_dns_srv(belle_sip_stack_t *stack, unsigned char enable);
BELLESIP_EXPORT unsigned char belle_sip_stack_dns_search_enabled(const belle_sip_stack_t *stack);
BELLESIP_EXPORT void belle_sip_stack_enable_dns_search(belle_sip_stack_t *stack, unsigned char enable);
/**
* Override system's DNS servers used for DNS resolving by app-supplied list of dns servers.
* @param stack the stack
......
......@@ -21,12 +21,17 @@
############################################################################
function(require_c99 target)
message("CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
if(CMAKE_C_COMPILER_ID STREQUAL "QCC")
target_compile_options(${target} PRIVATE "-std=gnu99")
else()
set_property(TARGET ${target} PROPERTY C_STANDARD 99)
set_property(TARGET ${target} PROPERTY C_STANDARD_REQUIRED TRUE)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(${target} PRIVATE "-std=gnu99")
endif()
else()
set_property(TARGET ${target} PROPERTY C_STANDARD 99)
set_property(TARGET ${target} PROPERTY C_STANDARD_REQUIRED TRUE)
endif()
endif()
endfunction()
......@@ -174,6 +179,12 @@ if(MSVC)
set(DNS_C_COMPILE_FLAGS "${DNS_C_COMPILE_FLAGS} /wd4305") # Disable "'initializing': truncation from 'unsigned int' to 'UCHAR'" warnings
set(DNS_C_COMPILE_FLAGS "${DNS_C_COMPILE_FLAGS} /wd4018") # Disable "signed/unsigned mismatch" warnings
set_source_files_properties(dns.c PROPERTIES COMPILE_FLAGS "${DNS_C_COMPILE_FLAGS}")
get_source_file_property(SDP_PARSER_COMPILE_FLAGS grammars/belle_sdpParser.c COMPILE_FLAGS)
set(SDP_PARSER_COMPILE_FLAGS "${SDP_PARSER_COMPILE_FLAGS} /wd4267") # Disable "possible loss of data" warnings
set_source_files_properties(grammars/belle_sdpParser.c PROPERTIES COMPILE_FLAGS "${SDP_PARSER_COMPILE_FLAGS}")
get_source_file_property(SIP_MESSAGE_PARSER_COMPILE_FLAGS grammars/belle_sip_messageParser.c COMPILE_FLAGS)
set(SIP_MESSAGE_PARSER_COMPILE_FLAGS "${SIP_MESSAGE_PARSER_COMPILE_FLAGS} /wd4267") # Disable "possible loss of data" warnings
set_source_files_properties(grammars/belle_sip_messageParser.c PROPERTIES COMPILE_FLAGS "${SIP_MESSAGE_PARSER_COMPILE_FLAGS}")
endif()
string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}")
......
......@@ -74,11 +74,11 @@ int belle_sip_auth_helper_compute_ha1(const char* userid,const char* realm,const
}
belle_sip_md5_init(&state);
belle_sip_md5_append(&state,(const md5_byte_t *)userid,strlen(userid));
belle_sip_md5_append(&state,(const md5_byte_t *)userid,(int)strlen(userid));
belle_sip_md5_append(&state,(const md5_byte_t *)":",1);
belle_sip_md5_append(&state,(const md5_byte_t *)realm,strlen(realm));
belle_sip_md5_append(&state,(const md5_byte_t *)realm,(int)strlen(realm));
belle_sip_md5_append(&state,(const md5_byte_t *)":",1);
belle_sip_md5_append(&state,(const md5_byte_t *)password,strlen(password));
belle_sip_md5_append(&state,(const md5_byte_t *)password,(int)strlen(password));
belle_sip_md5_finish(&state,out);
for (di = 0; di < 16; ++di)
sprintf(ha1 + di * 2, "%02x", out[di]);
......@@ -93,14 +93,15 @@ int belle_sip_auth_helper_compute_ha2(const char* method,const char* uri, char h
ha2[32]='\0';
/*HA2=MD5(method:uri)*/
belle_sip_md5_init(&state);
belle_sip_md5_append(&state,(const md5_byte_t *)method,strlen(method));
belle_sip_md5_append(&state,(const md5_byte_t *)method,(int)strlen(method));
belle_sip_md5_append(&state,(const md5_byte_t *)":",1);
belle_sip_md5_append(&state,(const md5_byte_t *)uri,strlen(uri));
belle_sip_md5_append(&state,(const md5_byte_t *)uri,(int)strlen(uri));
belle_sip_md5_finish(&state,out);
for (di = 0; di < 16; ++di)
sprintf(ha2 + di * 2, "%02x", out[di]);
sprintf(ha2 + di * 2, "%02x", out[di]);
return 0;
}
int belle_sip_auth_helper_compute_response(const char* ha1,const char* nonce, const char* ha2, char response[33]) {
md5_byte_t out[16];
md5_state_t state;
......@@ -108,20 +109,19 @@ int belle_sip_auth_helper_compute_response(const char* ha1,const char* nonce, co
response[32]='\0';
belle_sip_md5_init(&state);
belle_sip_md5_append(&state,(const md5_byte_t *)ha1,strlen(ha1));
belle_sip_md5_append(&state,(const md5_byte_t *)ha1,(int)strlen(ha1));
belle_sip_md5_append(&state,(const md5_byte_t *)":",1);
belle_sip_md5_append(&state
,(const md5_byte_t *)nonce
,strlen(nonce));
belle_sip_md5_append(&state,(const md5_byte_t *)nonce,(int)strlen(nonce));
belle_sip_md5_append(&state,(const md5_byte_t *)":",1);
belle_sip_md5_append(&state,(const md5_byte_t *)ha2,strlen(ha2));
belle_sip_md5_append(&state,(const md5_byte_t *)ha2,(int)strlen(ha2));
belle_sip_md5_finish(&state,out);
/*copy values*/
for (di = 0; di < 16; ++di)
sprintf(response + di * 2, "%02x", out[di]);
sprintf(response + di * 2, "%02x", out[di]);
return 0;
}
int belle_sip_auth_helper_compute_response_qop_auth(const char* ha1
, const char* nonce
, unsigned int nonce_count
......@@ -139,30 +139,21 @@ int belle_sip_auth_helper_compute_response_qop_auth(const char* ha1
/*response=MD5(HA1:nonce:nonce_count:cnonce:qop:HA2)*/
belle_sip_md5_init(&state);
belle_sip_md5_append(&state,(const md5_byte_t *)ha1,strlen(ha1));
belle_sip_md5_append(&state,(const md5_byte_t *)ha1,(int)strlen(ha1));
belle_sip_md5_append(&state,(const md5_byte_t *)":",1);
belle_sip_md5_append(&state
,(const md5_byte_t *)nonce
,strlen(nonce));
belle_sip_md5_append(&state,(const md5_byte_t *)nonce,(int)strlen(nonce));
belle_sip_md5_append(&state,(const md5_byte_t *)":",1);
belle_sip_md5_append(&state
,(const md5_byte_t *)nounce_count_as_string
,strlen(nounce_count_as_string));
belle_sip_md5_append(&state,(const md5_byte_t *)nounce_count_as_string,(int)strlen(nounce_count_as_string));
belle_sip_md5_append(&state,(const md5_byte_t *)":",1);
belle_sip_md5_append(&state
,(const md5_byte_t *)cnonce
,strlen(cnonce));
belle_sip_md5_append(&state,(const md5_byte_t *)cnonce,(int)strlen(cnonce));
belle_sip_md5_append(&state,(const md5_byte_t *)":",1);
belle_sip_md5_append(&state
,(const md5_byte_t *)qop
,strlen(qop));
belle_sip_md5_append(&state,(const md5_byte_t *)qop,(int)strlen(qop));
belle_sip_md5_append(&state,(const md5_byte_t *)":",1);
belle_sip_md5_append(&state,(const md5_byte_t *)ha2,strlen(ha2));
belle_sip_md5_append(&state,(const md5_byte_t *)ha2,(int)strlen(ha2));
belle_sip_md5_finish(&state,out);
/*copy values*/
for (di = 0; di < 16; ++di)
sprintf(response + di * 2, "%02x", out[di]);
sprintf(response + di * 2, "%02x", out[di]);
return 0;
}
......@@ -170,7 +161,6 @@ int belle_sip_auth_helper_compute_response_qop_auth(const char* ha1
int belle_sip_auth_helper_fill_authorization(belle_sip_header_authorization_t* authorization
,const char* method
,const char* ha1) {
int auth_mode=0;
char* uri;
char ha2[16*2 + 1];
......
......@@ -632,7 +632,7 @@ int belle_sip_header_user_agent_get_products_as_string(const belle_sip_header_us
}
if (result>0) value[result-1]='\0'; /*remove last space */
return result-1;
return (int)result-1;
}
/**************************
......@@ -964,7 +964,7 @@ BELLE_SIP_PARSE(header_service_route)
*/
struct _belle_sip_header_content_length {
belle_sip_header_t header;
unsigned int content_length;
size_t content_length;
};
static void belle_sip_header_content_length_destroy(belle_sip_header_content_length_t* content_length) {
......@@ -978,15 +978,15 @@ static void belle_sip_header_content_length_clone(belle_sip_header_content_lengt
belle_sip_error_code belle_sip_header_content_length_marshal(belle_sip_header_content_length_t* content_length, char* buff, size_t buff_size, size_t *offset) {
belle_sip_error_code error=belle_sip_header_marshal(BELLE_SIP_HEADER(content_length), buff, buff_size, offset);
if (error!=BELLE_SIP_OK) return error;
error=belle_sip_snprintf(buff,buff_size,offset,"%i",content_length->content_length);
error=belle_sip_snprintf(buff,buff_size,offset,FORMAT_SIZE_T,content_length->content_length);
if (error!=BELLE_SIP_OK) return error;
return error;
}
BELLE_SIP_NEW_HEADER(header_content_length,header,BELLE_SIP_CONTENT_LENGTH)
BELLE_SIP_PARSE(header_content_length)
GET_SET_INT(belle_sip_header_content_length,content_length,unsigned int)
belle_sip_header_content_length_t* belle_sip_header_content_length_create (int content_length) {
GET_SET_INT(belle_sip_header_content_length,content_length,size_t)
belle_sip_header_content_length_t* belle_sip_header_content_length_create (size_t content_length) {
belle_sip_header_content_length_t* obj;
obj = belle_sip_header_content_length_new();
belle_sip_header_content_length_set_content_length(obj,content_length);
......
......@@ -528,7 +528,7 @@ struct belle_sip_stack{
char *http_proxy_passwd; /*for future use*/
unsigned char dns_srv_enabled;
unsigned char dns_search_enabled;
};
belle_sip_hop_t* belle_sip_hop_new(const char* transport, const char *cname, const char* host,int port);
......@@ -959,7 +959,7 @@ belle_sip_refresher_t* belle_sip_refresher_new(belle_sip_client_transaction_t* t
/*
* returns a char, even if entry is escaped*/
int belle_sip_get_char (const char*a,int n,char*out);
size_t belle_sip_get_char (const char*a,size_t n,char*out);
/*return an escaped string*/
BELLESIP_INTERNAL_EXPORT char* belle_sip_uri_to_escaped_username(const char* buff) ;
BELLESIP_INTERNAL_EXPORT char* belle_sip_uri_to_escaped_userpasswd(const char* buff) ;
......
......@@ -69,7 +69,7 @@ void belle_sip_object_enable_leak_detector(int enable){
}
int belle_sip_object_get_object_count(void){
return belle_sip_list_size(all_objects);
return (int)belle_sip_list_size(all_objects);
}
void belle_sip_object_flush_active_objects(void){
......@@ -555,10 +555,10 @@ char* belle_sip_object_to_string(void* _obj) {
belle_sip_error_code error = belle_sip_object_marshal(obj,buff,sizeof(buff)-1,&offset);
if (error==BELLE_SIP_BUFFER_OVERFLOW){
belle_sip_message("belle_sip_object_to_string(): temporary buffer is too short while doing to_string() for %s, retrying", obj->vptr->type_name);
return belle_sip_object_to_alloc_string(obj,get_hint_size(2*offset));
return belle_sip_object_to_alloc_string(obj,get_hint_size(2*(int)offset));
}
buff[offset]='\0';
obj->vptr->tostring_bufsize_hint=get_hint_size(2*offset);
obj->vptr->tostring_bufsize_hint=get_hint_size(2*(int)offset);
return belle_sip_strdup(buff);
}
}
......
......@@ -447,6 +447,7 @@ static int resolver_process_data(belle_sip_simple_resolver_context_t *ctx, unsig
int error;
unsigned char simulated_timeout=0;
int timeout=belle_sip_stack_get_dns_timeout(ctx->base.stack);
unsigned char search_enabled = belle_sip_stack_dns_search_enabled(ctx->base.stack);
/*Setting timeout to 0 can be used to simulate DNS timeout*/
if ((revents!=0) && timeout==0){
......@@ -459,6 +460,7 @@ static int resolver_process_data(belle_sip_simple_resolver_context_t *ctx, unsig
notify_results(ctx);
return BELLE_SIP_STOP;
}
dns_res_enable_search(ctx->R, search_enabled);
/*belle_sip_message("resolver_process_data(): revents=%i",revents);*/
error = dns_res_check(ctx->R);
if (!error) {
......@@ -552,7 +554,7 @@ static void * _resolver_getaddrinfo_thread(void *ptr) {
belle_sip_error("getaddrinfo DNS resolution of %s failed: %s", ctx->name, gai_strerror(err));
} else if (!ctx->getaddrinfo_cancelled) {
do {
append_dns_result(ctx, &ctx->getaddrinfo_ai_list, res->ai_addr, res->ai_addrlen);
append_dns_result(ctx, &ctx->getaddrinfo_ai_list, res->ai_addr, (socklen_t)res->ai_addrlen);
res = res->ai_next;
} while (res != NULL);
}
......@@ -1096,7 +1098,7 @@ It works on all platform except for windows using ipv6 sockets. TODO: find a wor
*/
void belle_sip_get_src_addr_for(const struct sockaddr *dest, socklen_t destlen, struct sockaddr *src, socklen_t *srclen, int local_port){
int af_type=dest->sa_family;
int sock=socket(af_type,SOCK_DGRAM,IPPROTO_UDP);
int sock=(int)socket(af_type,SOCK_DGRAM,IPPROTO_UDP);
belle_sip_message("belle_sip_get_src_addr_for(): af_inet6=%i",af_type==AF_INET6);
if (sock==(belle_sip_socket_t)-1){
......@@ -1136,7 +1138,7 @@ fail:
struct addrinfo *res = bctbx_ip_address_to_addrinfo(af_type, SOCK_STREAM, af_type == AF_INET ? "127.0.0.1" : "::1", local_port);
if (res != NULL) {
memcpy(src,res->ai_addr,MIN((size_t)*srclen,res->ai_addrlen));
*srclen=res->ai_addrlen;
*srclen=(socklen_t)res->ai_addrlen;
bctbx_freeaddrinfo(res);
} else {
if (af_type == AF_INET) belle_sip_fatal("belle_sip_get_src_addr_for(): belle_sip_ip_address_to_addrinfo() failed");
......
......@@ -296,7 +296,7 @@ static int bits_reader_read(bits_reader_t *reader, int count, unsigned int *ret)
unsigned int tmp;
size_t byte_index=reader->bit_index/8;
size_t bit_index=reader->bit_index % 8;
int shift=32-bit_index-count;
int shift=32-(int)bit_index-count;
if (count>=24){
belle_sip_error("This bit reader cannot read more than 24 bits at once.");
......@@ -355,7 +355,7 @@ void belle_sip_util_copy_headers(belle_sip_message_t *orig, belle_sip_message_t
}
}
int belle_sip_get_char (const char*a,int n,char*out) {
size_t belle_sip_get_char (const char*a,size_t n,char*out) {
if (*a=='%' && n>2) {
unsigned int tmp;
sscanf(a+1,"%02x",&tmp);
......@@ -369,8 +369,8 @@ int belle_sip_get_char (const char*a,int n,char*out) {
char* belle_sip_to_unescaped_string(const char* buff) {
char *output_buff=belle_sip_malloc(strlen(buff)+1);
unsigned int i;
unsigned int out_buff_index=0;
size_t i;
size_t out_buff_index=0;
for(i=0; buff[i]!='\0'; out_buff_index++) {
i+=belle_sip_get_char(buff+i,3,output_buff+out_buff_index);
......
......@@ -251,11 +251,11 @@ void belle_sip_memory_body_handler_apply_encoding(belle_sip_memory_body_handler_
strm.opaque = Z_NULL;
ret = deflateInit(&strm, Z_DEFAULT_COMPRESSION);
if (ret != Z_OK) return;
strm.avail_in = initial_size;
strm.avail_in = (uInt)initial_size;
strm.next_in = obj->buffer;
do {
if (avail_out < BELLE_SIP_MEMORY_BODY_HANDLER_ZLIB_INITIAL_SIZE) {
unsigned int cursize = outbuf_ptr - outbuf;
unsigned int cursize = (unsigned int)(outbuf_ptr - outbuf);
outbuf_size *= 2;
outbuf = belle_sip_realloc(outbuf, outbuf_size);
outbuf_ptr = outbuf + cursize;
......@@ -264,7 +264,7 @@ void belle_sip_memory_body_handler_apply_encoding(belle_sip_memory_body_handler_
strm.next_out = outbuf_ptr;
deflate(&strm, Z_FINISH);
outbuf_ptr += avail_out - strm.avail_out;
avail_out = outbuf_size - (outbuf_ptr - outbuf);
avail_out = outbuf_size - (unsigned int)(outbuf_ptr - outbuf);
} while (strm.avail_out == 0);
deflateEnd(&strm);
final_size = outbuf_ptr - outbuf;
......@@ -301,11 +301,11 @@ int belle_sip_memory_body_handler_unapply_encoding(belle_sip_memory_body_handler
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
if (ret != Z_OK) return -1;
strm.avail_in = initial_size;
strm.avail_in = (uInt)initial_size;
strm.next_in = obj->buffer;
do {
if (avail_out < BELLE_SIP_MEMORY_BODY_HANDLER_ZLIB_INITIAL_SIZE) {
unsigned int cursize = outbuf_ptr - outbuf;
unsigned int cursize = (unsigned int)(outbuf_ptr - outbuf);
outbuf_size *= 2;
outbuf = belle_sip_realloc(outbuf, outbuf_size);
outbuf_ptr = outbuf + cursize;
......@@ -323,7 +323,7 @@ int belle_sip_memory_body_handler_unapply_encoding(belle_sip_memory_body_handler
return -1;
}
outbuf_ptr += avail_out - strm.avail_out;
avail_out = outbuf_size - (outbuf_ptr - outbuf);
avail_out = outbuf_size - (unsigned int)(outbuf_ptr - outbuf);
} while (ret != Z_STREAM_END);
inflateEnd(&strm);
final_size = outbuf_ptr - outbuf;
......@@ -451,7 +451,7 @@ static void belle_sip_file_body_handler_clone(belle_sip_file_body_handler_t *obj
static void belle_sip_file_body_handler_recv_chunk(belle_sip_body_handler_t *base, belle_sip_message_t *msg, size_t offset, const uint8_t *buf, size_t size) {
FILE *f;
int ret;
size_t ret;
belle_sip_file_body_handler_t *obj = (belle_sip_file_body_handler_t *)base;
if (obj->filepath == NULL) return;
f = fopen(obj->filepath, "ab");
......@@ -466,23 +466,24 @@ static void belle_sip_file_body_handler_recv_chunk(belle_sip_body_handler_t *bas
static int belle_sip_file_body_handler_send_chunk(belle_sip_body_handler_t *base, belle_sip_message_t *msg, size_t offset, uint8_t *buf, size_t *size) {
FILE *f;
int ret;
int int_ret;
size_t size_t_ret;
belle_sip_file_body_handler_t *obj = (belle_sip_file_body_handler_t *)base;
size_t to_send = MIN(*size, obj->base.expected_size - offset);
if (obj->filepath == NULL) return BELLE_SIP_STOP;
f = fopen(obj->filepath, "rb");
if (f == NULL) return BELLE_SIP_STOP;
ret = fseek(f, offset, SEEK_SET);
if (ret < 0) {
int_ret = fseek(f, (long)offset, SEEK_SET);
if (int_ret < 0) {
fclose(f);
return BELLE_SIP_STOP;
}
ret = fread(buf, 1, to_send, f);
if (ret < 0) {
size_t_ret = fread(buf, 1, to_send, f);
if (size_t_ret < 0) {
fclose(f);
return BELLE_SIP_STOP;
}
*size = ret;
*size = size_t_ret;
fclose(f);
return (((obj->base.expected_size - offset) == *size) || (*size == 0)) ? BELLE_SIP_STOP : BELLE_SIP_CONTINUE;
}
......
......@@ -84,7 +84,7 @@ static belle_sip_list_t * for_each_weak_unref_free(belle_sip_list_t *l, belle_si
static void belle_sip_channel_input_stream_rewind(belle_sip_channel_input_stream_t* input_stream){
int remaining;
remaining=input_stream->write_ptr-input_stream->read_ptr;
remaining=(int)(input_stream->write_ptr-input_stream->read_ptr);
if (remaining>0){
/* copy remaning bytes at top of buffer*/
memmove(input_stream->buff,input_stream->read_ptr,remaining);
......@@ -222,7 +222,7 @@ static int get_message_start_pos(char *buff, size_t bufflen) {
char method[17]={0};
char saved_char1;
char sip_version[10]={0};
int saved_char1_index;
size_t saved_char1_index;
for(i=0; i<(int)bufflen-12;i++) { /*9=strlen( SIP/2.0\r\n)*/
switch (buff[i]) { /*to avoid this character to be ignored by scanf*/
......@@ -480,7 +480,7 @@ static int acquire_chuncked_body(belle_sip_channel_t *obj){
return BELLE_SIP_STOP;
}
}
readsize=MIN(st->write_ptr-st->read_ptr,st->chunk_size-st->chunk_read_size);
readsize=MIN((int)(st->write_ptr-st->read_ptr),st->chunk_size-st->chunk_read_size);
if (readsize>0){
feed_body(obj,readsize);
st->chunk_read_size+=readsize;
......@@ -529,7 +529,7 @@ void belle_sip_channel_parse_stream(belle_sip_channel_t *obj, int end_of_stream)
size_t read_size=0;
int num;
while ((num=(obj->input_stream.write_ptr-obj->input_stream.read_ptr))>0){
while ((num=(int)(obj->input_stream.write_ptr-obj->input_stream.read_ptr))>0){
if (obj->input_stream.state == WAITING_MESSAGE_START) {
int i;
......@@ -569,7 +569,7 @@ void belle_sip_channel_parse_stream(belle_sip_channel_t *obj, int end_of_stream)
char tmp;
/*end of message found*/
end_of_message+=4;/*add \r\n\r\n*/
bytes_to_parse=end_of_message-obj->input_stream.read_ptr;
bytes_to_parse=(int)(end_of_message-obj->input_stream.read_ptr);
tmp=*end_of_message;
*end_of_message='\0';/*this is in order for the following log to print the message only to its end.*/
/*belle_sip_message("channel [%p] read message of [%i] bytes:\n%.40s...",obj, bytes_to_parse, obj->input_stream.read_ptr);*/
......@@ -1065,7 +1065,7 @@ static size_t find_non_printable(const char *buffer, size_t size){
static char *make_logbuf(belle_sip_channel_t *obj, belle_sip_log_level level, const char *buffer, size_t size){
char *logbuf;
char truncate_msg[128]={0};
int limit=7000; /*big message when many ice candidates*/
size_t limit=7000; /*big message when many ice candidates*/
if (!belle_sip_log_level_enabled(level)){
return NULL;
......@@ -1073,7 +1073,7 @@ static char *make_logbuf(belle_sip_channel_t *obj, belle_sip_log_level level, co
if (obj->stop_logging_buffer == 1) {
return NULL;
}
limit=find_non_printable(buffer,MIN((int)size,limit));
limit=find_non_printable(buffer,MIN(size,limit));
if (limit != size) {
belle_sip_message("channel [%p]: found binary data in buffer, will stop logging it now.", obj);
obj->stop_logging_buffer = 1;
......@@ -1081,7 +1081,7 @@ static char *make_logbuf(belle_sip_channel_t *obj, belle_sip_log_level level, co
snprintf(truncate_msg,sizeof(truncate_msg)-1,"... (binary data)");
} else {
size=limit;
snprintf(truncate_msg,sizeof(truncate_msg)-1,"... (first %i bytes shown)",limit);
snprintf(truncate_msg,sizeof(truncate_msg)-1,"... (first %u bytes shown)",(unsigned int)limit);
}
}
......@@ -1108,7 +1108,7 @@ static int send_buffer(belle_sip_channel_t *obj, const char *buffer, size_t size
/*for testing purpose only */
ret=obj->stack->send_error;
} else {
ret=size; /*to silently discard message*/
ret=(int)size; /*to silently discard message*/
}
if (ret<0){
......@@ -1153,24 +1153,24 @@ static int send_buffer(belle_sip_channel_t *obj, const char *buffer, size_t size
static void check_content_length(belle_sip_message_t *msg, size_t body_len){
belle_sip_header_content_length_t *ctlen=belle_sip_message_get_header_by_type(msg,belle_sip_header_content_length_t);
unsigned int value=ctlen ? belle_sip_header_content_length_get_content_length(ctlen) : 0;
size_t value=ctlen ? belle_sip_header_content_length_get_content_length(ctlen) : 0;
if (body_len){
if (ctlen==NULL){
belle_sip_message("message [%p] has body of size [%i] but no Content-Length, adding it.",msg,(int)body_len);
belle_sip_message("message [%p] has body of size ["FORMAT_SIZE_T"] but no Content-Length, adding it.",msg,body_len);
belle_sip_message_add_header(msg,
(belle_sip_header_t*)belle_sip_header_content_length_create((int)body_len)
(belle_sip_header_t*)belle_sip_header_content_length_create(body_len)
);
}else{
if (value!=(unsigned int)body_len){
belle_sip_warning("message [%p] has Content-Length [%u] and body size [%i] which are inconsistent, fixing it.",
msg, value, (int)body_len);
belle_sip_header_content_length_set_content_length(ctlen,(int)body_len);
if (value!=body_len){
belle_sip_warning("message [%p] has Content-Length ["FORMAT_SIZE_T"] and body size ["FORMAT_SIZE_T"] which are inconsistent, fixing it.",
msg, value, body_len);
belle_sip_header_content_length_set_content_length(ctlen,body_len);
}
}
}else{
/*no body, or undetermined size body*/
if (ctlen && value!=0){
belle_sip_error("message [%p] has Content-Length [%u], but without body or body with undetermined size. Fix your app.",
belle_sip_error("message [%p] has Content-Length ["FORMAT_SIZE_T"], but without body or body with undetermined size. Fix your app.",
msg,value);
}
}
......
......@@ -817,7 +817,7 @@ belle_sip_request_t *belle_sip_dialog_create_queued_request_from(belle_sip_dialo
}
void belle_sip_dialog_delete(belle_sip_dialog_t *obj){
int dropped_transactions;
size_t dropped_transactions;
if (obj->expiration_timer){
belle_sip_main_loop_remove_source(obj->provider->stack->ml, obj->expiration_timer);
......@@ -828,7 +828,7 @@ void belle_sip_dialog_delete(belle_sip_dialog_t *obj){
belle_sip_dialog_stop_200Ok_retrans(obj); /*if any*/
set_state(obj,BELLE_SIP_DIALOG_TERMINATED);
dropped_transactions=belle_sip_list_size(obj->queued_ct);
if (dropped_transactions>0) belle_sip_warning("dialog [%p]: leaves %i queued transaction aborted.",obj,dropped_transactions);
if (dropped_transactions>0) belle_sip_warning("dialog [%p]: leaves %u queued transaction aborted.",obj,(unsigned int)dropped_transactions);
belle_sip_list_for_each(obj->queued_ct,(void(*)(void*))belle_sip_transaction_terminate);
obj->queued_ct=belle_sip_list_free_with_data(obj->queued_ct,belle_sip_object_unref);
belle_sip_provider_remove_dialog(obj->provider,obj);
......
......@@ -74,8 +74,23 @@
#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#ifndef USE_FIXED_NAMESERVERS
#include <IPHlpApi.h>
#pragma comment(lib, "IPHLPAPI.lib")
#endif
#if defined(__MINGW32__) || !defined(WINAPI_FAMILY_PARTITION) || !defined(WINAPI_PARTITION_DESKTOP)
#define BELLE_SIP_WINDOWS_DESKTOP 1
#elif defined(WINAPI_FAMILY_PARTITION)
#if defined(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#define BELLE_SIP_WINDOWS_DESKTOP 1
#elif defined(WINAPI_PARTITION_PHONE_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
#define BELLE_SIP_WINDOWS_PHONE 1
#elif defined(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
#define BELLE_SIP_WINDOWS_UNIVERSAL 1
#endif
#endif
#else
#include <sys/types.h> /* FD_SETSIZE socklen_t */
#include <sys/select.h> /* FD_ZERO FD_SET fd_set select(2) */
......@@ -4141,7 +4156,8 @@ struct dns_hosts *dns_hosts_mortal(struct dns_hosts *hosts) {
return hosts;
} /* dns_hosts_mortal() */
int dns_hosts_add_localhost(struct dns_hosts *hosts) {
#if defined(BELLE_SIP_WINDOWS_PHONE) || defined(BELLE_SIP_WINDOWS_UNIVERSAL)
static int dns_hosts_add_localhost(struct dns_hosts *hosts) {
struct dns_hosts_entry ent;
memset(&ent, '\0', sizeof(ent));
ent.af = AF_INET;
......@@ -4155,6 +4171,7 @@ int dns_hosts_add_localhost(struct dns_hosts *hosts) {
dns_hosts_insert(hosts, ent.af, &ent.addr, ent.host, 1);
return 0;
}
#endif
struct dns_hosts *dns_hosts_local(int *error_) {
struct dns_hosts *hosts;
......@@ -4164,7 +4181,7 @@ struct dns_hosts *dns_hosts_local(int *error_) {