Commit 2eb76e39 authored by Ghislain MARY's avatar Ghislain MARY

Fix build for Windows 10.

parent 374a1ae8
......@@ -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);
......
......@@ -21,7 +21,6 @@
############################################################################
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()
......@@ -174,6 +173,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) {
......@@ -985,8 +985,8 @@ belle_sip_error_code belle_sip_header_content_length_marshal(belle_sip_header_co
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);
......
......@@ -956,7 +956,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);
}
}
......
......@@ -552,7 +552,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 +1096,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 +1136,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;
}
......
......@@ -72,7 +72,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);
......@@ -208,7 +208,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*/
......@@ -466,7 +466,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;
......@@ -514,7 +514,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;
......@@ -554,7 +554,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);*/
......@@ -1033,7 +1033,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;
......@@ -1041,7 +1041,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;
......@@ -1049,7 +1049,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);
}
}
......@@ -1076,7 +1076,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){
......@@ -1121,25 +1121,25 @@ 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 [%u] but no Content-Length, adding it.",msg,(unsigned int)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 [%u] and body size [%u] which are inconsistent, fixing it.",
msg, value, (unsigned int)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.",
msg,value);
msg,(unsigned int)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);
......
......@@ -4875,6 +4875,23 @@ int dns_resconf_loadpath(struct dns_resolv_conf *resconf, const char *path) {
return error;
} /* dns_resconf_loadpath() */
#ifdef USE_FIXED_NAMESERVERS
int dns_resconf_load_fixed_nameservers(struct dns_resolv_conf *resconf) {
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;
}
#endif /* USE_FIXED_NAMESERVERS */
#ifdef USE_STRUCT_RES_STATE_NAMESERVERS
int dns_resconf_load_struct_res_state_nameservers(struct dns_resolv_conf *resconf) {
int i;
......
......@@ -948,6 +948,10 @@ DNS_PUBLIC int dns_resconf_loadfile(struct dns_resolv_conf *, FILE *);
DNS_PUBLIC int dns_resconf_loadpath(struct dns_resolv_conf *, const char *);
#ifdef USE_FIXED_NAMESERVERS
int dns_resconf_load_fixed_nameservers(struct dns_resolv_conf *resconf);
#endif /* USE_FIXED_NAMESERVERS */
#ifdef USE_STRUCT_RES_STATE_NAMESERVERS
int dns_resconf_load_struct_res_state_nameservers(struct dns_resolv_conf *resconf);
#endif /* USE_STRUCT_RES_STATE_NAMESERVERS */
......
......@@ -364,10 +364,10 @@ static void split_request_url(belle_http_request_t *req){
}
static void fix_request(belle_http_request_t *req){
unsigned int size=belle_sip_message_get_body_size((belle_sip_message_t*)req);
size_t size=belle_sip_message_get_body_size((belle_sip_message_t*)req);
belle_sip_header_content_length_t *ctlen=belle_sip_message_get_header_by_type(req, belle_sip_header_content_length_t);
if (size>0 && !ctlen){
belle_sip_message_add_header((belle_sip_message_t*)req,(belle_sip_header_t*)belle_sip_header_content_length_create((int)size));
belle_sip_message_add_header((belle_sip_message_t*)req,(belle_sip_header_t*)belle_sip_header_content_length_create(size));
}
}
......
......@@ -82,10 +82,10 @@ void belle_sip_listening_point_remove_channel(belle_sip_listening_point_t *lp, b
void belle_sip_listening_point_clean_channels(belle_sip_listening_point_t *lp){
int existing_channels;
int existing_channels = belle_sip_listening_point_get_channel_count(lp);
belle_sip_list_t* iterator;
if ((existing_channels=belle_sip_list_size(lp->channels)) > 0) {
if (existing_channels > 0) {
belle_sip_message("Listening point destroying [%i] channels",existing_channels);
}
for (iterator=lp->channels;iterator!=NULL;iterator=iterator->next) {
......@@ -96,7 +96,7 @@ void belle_sip_listening_point_clean_channels(belle_sip_listening_point_t *lp){
}
int belle_sip_listening_point_get_channel_count(const belle_sip_listening_point_t *lp){
return belle_sip_list_size(lp->channels);
return (int)belle_sip_list_size(lp->channels);
}
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(belle_sip_listening_point_t);
......@@ -144,12 +144,12 @@ belle_sip_channel_t *belle_sip_listening_point_get_channel(belle_sip_listening_p
static int send_keep_alive(belle_sip_channel_t* obj) {
/*keep alive*/
const char* crlfcrlf = "\r\n\r\n";
int size=strlen(crlfcrlf);
size_t size=strlen(crlfcrlf);
int err=belle_sip_channel_send(obj,crlfcrlf,size);
if (err<=0 && !belle_sip_error_code_is_would_block(-err) && err!=-EINTR){
belle_sip_error("channel [%p]: could not send [%i] bytes of keep alive from [%s://%s:%i] to [%s:%i]" ,obj
,size
belle_sip_error("channel [%p]: could not send [%u] bytes of keep alive from [%s://%s:%i] to [%s:%i]" ,obj
,(unsigned int)size
,belle_sip_channel_get_transport_name(obj)
,obj->local_ip
,obj->local_port
......
......@@ -555,13 +555,13 @@ size_t belle_sip_message_get_body_size(const belle_sip_message_t *msg){
return belle_sip_body_handler_get_size(msg->body_handler);
}
void belle_sip_message_set_body(belle_sip_message_t *msg, const char* body, unsigned int size) {
void belle_sip_message_set_body(belle_sip_message_t *msg, const char* body, size_t size) {
belle_sip_body_handler_t *bh=NULL;
if (body && size) bh=(belle_sip_body_handler_t*)belle_sip_memory_body_handler_new_copy_from_buffer(body,size,NULL,NULL);
belle_sip_message_set_body_handler(msg,bh);
}
void belle_sip_message_assign_body(belle_sip_message_t *msg, char* body, unsigned int size) {
void belle_sip_message_assign_body(belle_sip_message_t *msg, char* body, size_t size) {
belle_sip_body_handler_t *bh=(belle_sip_body_handler_t*)belle_sip_memory_body_handler_new_from_buffer(body,size,NULL,NULL);
belle_sip_message_set_body_handler(msg,bh);
}
......
......@@ -128,7 +128,7 @@ const char *belle_sip_get_socket_error_string_from_code(int code){
static CHAR msgBuf[256];
#ifdef _UNICODE
static WCHAR wMsgBuf[256];
int ret;
size_t ret;
FormatMessageW(
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
......
......@@ -284,29 +284,29 @@ static void compute_hash_from_invariants(belle_sip_message_t *msg, char *branchi
belle_sip_md5_init(&ctx);
if (initial)
belle_sip_md5_append(&ctx,(uint8_t*)initial,strlen(initial));
belle_sip_md5_append(&ctx,(uint8_t*)initial,(int)strlen(initial));
if (requri){
size_t offset=0;
belle_sip_object_marshal((belle_sip_object_t*)requri,tmp,sizeof(tmp)-1,&offset);
belle_sip_md5_append(&ctx,(uint8_t*)tmp,strlen(tmp));
belle_sip_md5_append(&ctx,(uint8_t*)tmp,(int)strlen(tmp));
}
if (from_tag)
belle_sip_md5_append(&ctx,(uint8_t*)from_tag,strlen(from_tag));
belle_sip_md5_append(&ctx,(uint8_t*)from_tag,(int)strlen(from_tag));
if (to_tag)
belle_sip_md5_append(&ctx,(uint8_t*)to_tag,strlen(to_tag));
belle_sip_md5_append(&ctx,(uint8_t*)callid,strlen(callid));
belle_sip_md5_append(&ctx,(uint8_t*)to_tag,(int)strlen(to_tag));
belle_sip_md5_append(&ctx,(uint8_t*)callid,(int)strlen(callid));
belle_sip_md5_append(&ctx,(uint8_t*)&cseq,sizeof(cseq));
if (is_request){
if (prev_via){
size_t offset=0;
belle_sip_object_marshal((belle_sip_object_t*)prev_via,tmp,sizeof(tmp)-1,&offset);
belle_sip_md5_append(&ctx,(uint8_t*)tmp,offset);
belle_sip_md5_append(&ctx,(uint8_t*)tmp,(int)offset);
}
}else{
if (via){
size_t offset=0;
belle_sip_object_marshal((belle_sip_object_t*)via,tmp,sizeof(tmp)-1,&offset);
belle_sip_md5_append(&ctx,(uint8_t*)tmp,offset);
belle_sip_md5_append(&ctx,(uint8_t*)tmp,(int)offset);
}
}
belle_sip_md5_finish(&ctx,digest);
......@@ -336,15 +336,15 @@ static char *compute_rfc2543_branch(belle_sip_request_t *req, char *branchid, si
belle_sip_md5_init(&ctx);
belle_sip_md5_append(&ctx,(uint8_t*)from_str,strlen(from_str));
belle_sip_md5_append(&ctx,(uint8_t*)to_str,strlen(to_str));
belle_sip_md5_append(&ctx,(uint8_t*)callid,strlen(callid));
belle_sip_md5_append(&ctx,(uint8_t*)from_str,(int)strlen(from_str));
belle_sip_md5_append(&ctx,(uint8_t*)to_str,(int)strlen(to_str));
belle_sip_md5_append(&ctx,(uint8_t*)callid,(int)strlen(callid));
belle_sip_md5_append(&ctx,(uint8_t*)&cseq,sizeof(cseq));
belle_sip_free(from_str);
belle_sip_free(to_str);
if (v_branch)
belle_sip_md5_append(&ctx,(uint8_t*)v_branch,strlen(v_branch));
belle_sip_md5_append(&ctx,(uint8_t*)v_branch,(int)strlen(v_branch));
belle_sip_md5_finish(&ctx,digest);
belle_sip_octets_to_text(digest,sizeof(digest),branchid,branchid_size);
......
......@@ -40,8 +40,7 @@ static void stream_channel_uninit(belle_sip_stream_channel_t *obj){
int stream_channel_send(belle_sip_stream_channel_t *obj, const void *buf, size_t buflen){
belle_sip_socket_t sock = belle_sip_source_get_socket((belle_sip_source_t*)obj);
int err;
err=send(sock,buf,buflen,0);
int err=bctbx_send(sock,buf,buflen,0);
if (err==(belle_sip_socket_t)-1){
int errnum=get_socket_error();
if (!belle_sip_error_code_is_would_block(errnum)){
......@@ -54,8 +53,7 @@ int stream_channel_send(belle_sip_stream_channel_t *obj, const void *buf, size_t
int stream_channel_recv(belle_sip_stream_channel_t *obj, void *buf, size_t buflen){
belle_sip_socket_t sock = belle_sip_source_get_socket((belle_sip_source_t*)obj);
int err;
err=recv(sock,buf,buflen,0);
int err=bctbx_recv(sock,buf,buflen,0);
if (err==(belle_sip_socket_t)-1){
int errnum=get_socket_error();
if (!belle_sip_error_code_is_would_block(errnum)){
......@@ -135,7 +133,7 @@ int stream_channel_connect(belle_sip_stream_channel_t *obj, const struct addrinf
belle_sip_socket_enable_dual_stack(sock);
}
err = connect(sock,ai->ai_addr,ai->ai_addrlen);
err = bctbx_connect(sock,ai->ai_addr,(socklen_t)ai->ai_addrlen);
if (err != 0 && get_socket_error()!=BELLESIP_EINPROGRESS && get_socket_error()!=BELLESIP_EWOULDBLOCK) {
belle_sip_error("stream connect failed %s",belle_sip_get_socket_error_string());
close_socket(sock);
......
......@@ -99,7 +99,7 @@ static belle_sip_socket_t create_server_socket(const char *addr, int * port, int