Commit 2c236a7e authored by Simon Morlat's avatar Simon Morlat
Browse files

Merge branch 'master' into dev_http

Conflicts:
	include/belle-sip/belle-sip.h
	src/listeningpoint.c
parents 644c537c 9dd52e29
This diff is collapsed.
......@@ -86,6 +86,10 @@ ifeq ($(BUILD_RTP_MAP),1)
LOCAL_CFLAGS += -DBELLE_SDP_FORCE_RTP_MAP
endif
ifeq ($(BUILD_DONT_CHECK_HEADERS_IN_MESSAGE),1)
LOCAL_CFLAGS += -DBELLE_SIP_DONT_CHECK_HEADERS_IN_MESSAGE
endif
LOCAL_STATIC_LIBRARIES := \
antlr3
......
......@@ -204,7 +204,9 @@
<ClInclude Include="..\..\..\include\belle-sip\auth-helper.h" />
<ClInclude Include="..\..\..\include\belle-sip\belle-sdp.h" />
<ClInclude Include="..\..\..\include\belle-sip\belle-sip.h" />
<ClInclude Include="..\..\..\include\belle-sip\defs.h" />
<ClInclude Include="..\..\..\include\belle-sip\dialog.h" />
<ClInclude Include="..\..\..\include\belle-sip\dict.h" />
<ClInclude Include="..\..\..\include\belle-sip\headers.h" />
<ClInclude Include="..\..\..\include\belle-sip\list.h" />
<ClInclude Include="..\..\..\include\belle-sip\listener.h" />
......@@ -237,6 +239,7 @@
<ClCompile Include="..\..\..\src\belle_sdpLexer.c" />
<ClCompile Include="..\..\..\src\belle_sdpParser.c" />
<ClCompile Include="..\..\..\src\belle_sdp_impl.c" />
<ClCompile Include="..\..\..\src\belle_sip_dict.c" />
<ClCompile Include="..\..\..\src\belle_sip_headers_impl.c" />
<ClCompile Include="..\..\..\src\belle_sip_loop.c" />
<ClCompile Include="..\..\..\src\belle_sip_messageLexer.c" />
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -116,6 +116,7 @@ BELLE_SIP_DECLARE_TYPES_BEGIN(belle_sip,1)
BELLE_SIP_TYPE_ID(belle_sip_simple_resolver_context_t),
BELLE_SIP_TYPE_ID(belle_sip_combined_resolver_context_t),
BELLE_SIP_TYPE_ID(belle_sip_dict_t),
BELLE_SIP_TYPE_ID(belle_sip_dual_resolver_context_t),
BELLE_SIP_TYPE_ID(belle_http_provider_t),
BELLE_SIP_TYPE_ID(belle_http_request_t),
BELLE_SIP_TYPE_ID(belle_http_response_t),
......
......@@ -29,20 +29,26 @@
#ifdef _MSC_VER
#define BELLESIP_INLINE __inline
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
typedef unsigned char uint8_t;
#else
#include <inttypes.h>
#define BELLESIP_INLINE inline
#endif
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) || defined(__WIN32__)
#ifdef WIN32
#ifdef BELLESIP_EXPORTS
#define BELLESIP_EXPORT __declspec(dllexport)
#define BELLESIP_VAR_EXPORT __declspec(dllexport)
//#define BELLESIP_VAR_EXPORT __declspec(dllexport)
#else
#define BELLESIP_EXPORT
#define BELLESIP_VAR_EXPORT extern __declspec(dllimport)
//#define BELLESIP_VAR_EXPORT extern __declspec(dllimport)
#endif
#else
#define BELLESIP_VAR_EXPORT extern
//#define BELLESIP_VAR_EXPORT extern
#define BELLESIP_EXPORT extern
#endif
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -22,7 +22,6 @@
#ifndef WIN32
#include <sys/types.h>
#endif
#include <inttypes.h>
#include "object.h"
......@@ -127,7 +126,7 @@ BELLESIP_EXPORT void belle_sip_dict_merge( const belle_sip_dict_t* src, belle_si
* @return 1 if the key exists, 0 otherwise
* @todo create unit test
*/
BELLESIP_EXPORT int belle_sip_dict_haskey(belle_sip_dict_t* obj, const char* key);
BELLESIP_EXPORT int belle_sip_dict_haskey(const belle_sip_dict_t* obj, const char* key);
/**
* Apply a function for all keys stored in the dictionary
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -38,38 +38,48 @@ typedef unsigned int belle_sip_type_id_t;
#define BELLE_SIP_OBJECT_VPTR_NAME(object_type) object_type##_vptr
#define BELLE_SIP_OBJECT_GET_VPTR_FUNC(object_type) object_type##_vptr_get
#define BELLE_SIP_OBJECT_VPTR_TYPE(object_type) object_type##_vptr_t
#define BELLE_SIP_DECLARE_VPTR(object_type) \
typedef belle_sip_object_vptr_t BELLE_SIP_OBJECT_VPTR_TYPE(object_type);\
BELLESIP_VAR_EXPORT BELLE_SIP_OBJECT_VPTR_TYPE(object_type) BELLE_SIP_OBJECT_VPTR_NAME(object_type);
BELLESIP_EXPORT BELLE_SIP_OBJECT_VPTR_TYPE(object_type) * BELLE_SIP_OBJECT_GET_VPTR_FUNC(object_type)(void);
#define BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(object_type, parent_type) \
typedef struct object_type##_vptr_struct BELLE_SIP_OBJECT_VPTR_TYPE(object_type);\
extern BELLE_SIP_OBJECT_VPTR_TYPE(object_type) BELLE_SIP_OBJECT_VPTR_NAME(object_type);\
BELLESIP_EXPORT BELLE_SIP_OBJECT_VPTR_TYPE(object_type) * BELLE_SIP_OBJECT_GET_VPTR_FUNC(object_type)(void); \
struct object_type##_vptr_struct{\
BELLE_SIP_OBJECT_VPTR_TYPE(parent_type) base;
#define BELLE_SIP_DECLARE_CUSTOM_VPTR_END };
#define BELLE_SIP_INSTANCIATE_CUSTOM_VPTR(object_type) \
BELLE_SIP_OBJECT_VPTR_TYPE(object_type) BELLE_SIP_OBJECT_VPTR_NAME(object_type)
#define BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_BEGIN(object_type) \
extern BELLE_SIP_OBJECT_VPTR_TYPE(object_type) BELLE_SIP_OBJECT_VPTR_NAME(object_type);\
BELLE_SIP_OBJECT_VPTR_TYPE(object_type) * BELLE_SIP_OBJECT_GET_VPTR_FUNC(object_type)(void){\
return &BELLE_SIP_OBJECT_VPTR_NAME(object_type); \
}\
BELLE_SIP_OBJECT_VPTR_TYPE(object_type) BELLE_SIP_OBJECT_VPTR_NAME(object_type)={
#define BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_END };
#define BELLE_SIP_VPTR_INIT(object_type,parent_type,unowned) \
BELLE_SIP_TYPE_ID(object_type), \
#object_type,\
unowned,\
(belle_sip_object_vptr_t*)&BELLE_SIP_OBJECT_VPTR_NAME(parent_type), \
(belle_sip_object_get_vptr_t)BELLE_SIP_OBJECT_GET_VPTR_FUNC(parent_type), \
(belle_sip_interface_desc_t**)object_type##interfaces_table
#define BELLE_SIP_INSTANCIATE_VPTR(object_type,parent_type,destroy,clone,marshal,unowned) \
BELLE_SIP_OBJECT_VPTR_TYPE(object_type) BELLE_SIP_OBJECT_VPTR_NAME(object_type)={ \
static BELLE_SIP_OBJECT_VPTR_TYPE(object_type) BELLE_SIP_OBJECT_VPTR_NAME(object_type)={ \
BELLE_SIP_VPTR_INIT(object_type,parent_type,unowned), \
(belle_sip_object_destroy_t)destroy, \
(belle_sip_object_clone_t)clone, \
(belle_sip_object_marshal_t)marshal\
}; \
BELLE_SIP_OBJECT_VPTR_TYPE(object_type) * BELLE_SIP_OBJECT_GET_VPTR_FUNC(object_type)(void){\
return &BELLE_SIP_OBJECT_VPTR_NAME(object_type); \
}
/**
......@@ -117,12 +127,13 @@ typedef struct _belle_sip_object belle_sip_object_t;
typedef void (*belle_sip_object_destroy_t)(belle_sip_object_t*);
typedef void (*belle_sip_object_clone_t)(belle_sip_object_t* obj, const belle_sip_object_t *orig);
typedef int (*belle_sip_object_marshal_t)(belle_sip_object_t* obj, char* buff, size_t buff_size, size_t *offset);
typedef struct _belle_sip_object_vptr *(*belle_sip_object_get_vptr_t)(void);
struct _belle_sip_object_vptr{
belle_sip_type_id_t id;
const char *type_name;
int initially_unowned;
struct _belle_sip_object_vptr *parent;
belle_sip_object_get_vptr_t get_parent;
struct belle_sip_interface_desc **interfaces; /*NULL terminated table of */
belle_sip_object_destroy_t destroy;
belle_sip_object_clone_t clone;
......@@ -146,12 +157,10 @@ struct _belle_sip_object{
BELLE_SIP_BEGIN_DECLS
BELLESIP_VAR_EXPORT belle_sip_object_vptr_t belle_sip_object_t_vptr;
BELLESIP_EXPORT belle_sip_object_t * _belle_sip_object_new(size_t objsize, belle_sip_object_vptr_t *vptr);
#define belle_sip_object_new(_type) (_type*)_belle_sip_object_new(sizeof(_type),(belle_sip_object_vptr_t*)&BELLE_SIP_OBJECT_VPTR_NAME(_type))
#define belle_sip_object_new(_type) (_type*)_belle_sip_object_new(sizeof(_type),(belle_sip_object_vptr_t*)BELLE_SIP_OBJECT_GET_VPTR_FUNC(_type)())
/**
......@@ -170,7 +179,6 @@ int belle_sip_object_is_unowed(const belle_sip_object_t *obj);
**/
BELLESIP_EXPORT belle_sip_object_t * belle_sip_object_ref(void *obj);
/*#define BELLE_SIP_REF(object,type) (type*)belle_sip_object_ref(object);*/
/**
* Decrements the reference counter. When it drops to zero, the object is destroyed.
**/
......@@ -239,7 +247,7 @@ BELLESIP_EXPORT void* belle_sip_object_data_get( belle_sip_object_t *obj, const
/**
* Return 1 if the key exists in the data store, 0 otherwise
**/
BELLESIP_EXPORT int belle_sip_object_data_exists( belle_sip_object_t *obj, const char* name );
BELLESIP_EXPORT int belle_sip_object_data_exists( const belle_sip_object_t *obj, const char* name );
/**
* Destroys the named data associated by the name provided.
......
......@@ -49,6 +49,13 @@ BELLESIP_EXPORT unsigned int belle_sip_parameters_has_parameter(const belle_sip_
BELLESIP_EXPORT void belle_sip_parameters_set_parameter(belle_sip_parameters_t* obj,const char* name,const char* value);
/**
* Assign a full set of parameters to the belle_sip_parameters_t object.
* Parameters are given as string of key=value pairs separated with semicolons, where value is optional.
* @example belle_sip_parameters_set(parameters,"param1=value1;param2;param3=value3");
**/
BELLESIP_EXPORT void belle_sip_parameters_set(belle_sip_parameters_t *parameters, const char* params);
BELLESIP_EXPORT const belle_sip_list_t * belle_sip_parameters_get_parameter_names(const belle_sip_parameters_t* obj);
BELLESIP_EXPORT const belle_sip_list_t * belle_sip_parameters_get_parameters(const belle_sip_parameters_t* obj);
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -56,7 +56,15 @@ BELLESIP_EXPORT struct addrinfo * belle_sip_ip_address_to_addrinfo(int family, c
/**
* Asynchronously performs DNS SRV followed A or AAAA query. Automatically fallbacks to A or AAAA if SRV isn't found.
* Asynchronously performs DNS SRV followed A/AAAA query. Automatically fallbacks to A/AAAA if SRV isn't found.
* @param stack the belle_sip_stack_t, used to schedule asynchronous execution.
* @param transport the queried transport ("udp", "tcp", "tls")
* @param name the SIP domain name
* @param port a port that will be filled in the addrinfo list returned by the callback, for the case where no SRV records are found.
* @param family address family expected in the addrinfo result list. AF_INET or AF_INET6. If AF_INET6 is used but no IPv4 records are found, the IPv4 addresses
* will be returned as IPv6 with v4 mapping (AI_V4MAPPED).
* @param cb a callback function that will be called to notify the results.
* @param data a user pointer passed through the callback as first argument.
* @return a #belle_sip_resolver_context_t that can be used to cancel the resolution if needed. The context must have been ref'd with belle_sip_object_ref().
**/
BELLESIP_EXPORT belle_sip_resolver_context_t * belle_sip_stack_resolve(belle_sip_stack_t *stack, const char *transport, const char *name, int port, int family,
......@@ -64,6 +72,13 @@ belle_sip_resolver_callback_t cb, void *data);
/**
* Asynchronously performs DNS A or AAAA query.
* @param stack the belle_sip_stack_t, used to schedule asynchronous execution.
* @param name the SIP domain name
* @param port a port that will be filled in the addrinfo list returned by the callback, for the case where no SRV records are found.
* @param family address family expected in the addrinfo result list. AF_INET or AF_INET6. If AF_INET6 is used but no IPv4 records are found, the IPv4 addresses
* will be returned as IPv6 with v4 mapping (AI_V4MAPPED).
* @param cb a callback function that will be called to notify the results.
* @param data a user pointer passed through the callback as first argument.
* @return a #belle_sip_resolver_context_t that can be used to cancel the resolution if needed. The context must have been ref'd with belle_sip_object_ref().
**/
BELLESIP_EXPORT belle_sip_resolver_context_t * belle_sip_stack_resolve_a(belle_sip_stack_t *stack, const char *name, int port, int family, belle_sip_resolver_callback_t cb, void *data);
......@@ -84,14 +99,14 @@ BELLESIP_EXPORT void belle_sip_resolver_context_cancel(belle_sip_resolver_contex
* Lookups the source address from local interface that can be used to connect to a destination address.
* local_port is only used to be assigned into the result source address.
**/
void belle_sip_get_src_addr_for(const struct sockaddr *dest, socklen_t destlen, struct sockaddr *src, socklen_t *srclen, int local_port);
BELLESIP_EXPORT void belle_sip_get_src_addr_for(const struct sockaddr *dest, socklen_t destlen, struct sockaddr *src, socklen_t *srclen, int local_port);
/**
* This function will transform a V4 to V6 mapped address to a pure V4 and write it into result, or will just copy it otherwise.
* The memory for v6 and result may be the same, in which case processing is done in place or no copy is done.
* The pointer to result must have sufficient storage, typically a struct sockaddr_storage.
**/
void belle_sip_address_remove_v4_mapping(const struct sockaddr *v6, struct sockaddr *result, socklen_t *result_len);
BELLESIP_EXPORT void belle_sip_address_remove_v4_mapping(const struct sockaddr *v6, struct sockaddr *result, socklen_t *result_len);
BELLE_SIP_END_DECLS
......
......@@ -95,6 +95,20 @@ BELLESIP_EXPORT const char * belle_sip_stack_get_dns_user_hosts_file(const belle
**/
BELLESIP_EXPORT void belle_sip_stack_set_dns_user_hosts_file(belle_sip_stack_t *stack, const char *hosts_file);
/**
* Get the overriding DNS resolv.conf file.
* @return The path to the overriding DNS resolv.conf file.
**/
BELLESIP_EXPORT const char * belle_sip_stack_get_dns_resolv_conf_file(const belle_sip_stack_t *stack);
/**
* Can be used to load an overriding DNS resolv.conf file for tests.
* @param stack
* @param hosts_file The path to the overriding DNS resolv.conf file to load.
**/
BELLESIP_EXPORT void belle_sip_stack_set_dns_resolv_conf_file(belle_sip_stack_t *stack, const char *hosts_file);
/**
* Returns the time interval in seconds after which a connection must be closed when inactive.
**/
......
......@@ -49,6 +49,7 @@ BELLESIP_EXPORT void *belle_sip_transaction_get_application_data(const belle_sip
BELLESIP_EXPORT void belle_sip_transaction_set_application_data(belle_sip_transaction_t *t, void *data);
BELLESIP_EXPORT const char *belle_sip_transaction_get_branch_id(const belle_sip_transaction_t *t);
BELLESIP_EXPORT belle_sip_transaction_state_t belle_sip_transaction_get_state(const belle_sip_transaction_t *t);
BELLESIP_EXPORT const char *belle_sip_transaction_get_method(const belle_sip_transaction_t *t);
BELLESIP_EXPORT void belle_sip_transaction_terminate(belle_sip_transaction_t *t);
BELLESIP_EXPORT belle_sip_request_t *belle_sip_transaction_get_request(const belle_sip_transaction_t *t);
BELLESIP_EXPORT belle_sip_response_t *belle_sip_transaction_get_response(const belle_sip_transaction_t *t);
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......@@ -80,7 +80,11 @@ const char* belle_sip_dict_get_string(belle_sip_dict_t* obj, const char* key, co
void belle_sip_dict_set_int64(belle_sip_dict_t* obj, const char* key, int64_t value)
{
char tmp[30];
snprintf(tmp,sizeof(tmp),"%"PRId64"",value);
#if defined (_MSC_VER)
snprintf(tmp,sizeof(tmp),"%I64d",value);
#else
snprintf(tmp,sizeof(tmp),"%" PRId64"",value);
#endif
belle_sip_dict_set_string(obj,key,tmp);
}
......@@ -113,7 +117,7 @@ void belle_sip_dict_merge( const belle_sip_dict_t* src, belle_sip_dict_t* dst)
belle_sip_object_data_merge(BELLE_SIP_OBJECT(src), BELLE_SIP_OBJECT(dst), belle_sip_dict_string_clone);
}
int belle_sip_dict_haskey(belle_sip_dict_t* obj, const char* key)
int belle_sip_dict_haskey(const belle_sip_dict_t* obj, const char* key)
{
return belle_sip_object_data_exists(BELLE_SIP_OBJECT(obj), key);
}
......
......@@ -206,6 +206,9 @@ BELLE_SIP_DECLARE_CUSTOM_VPTR_END
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(belle_sip_combined_resolver_context_t,belle_sip_resolver_context_t)
BELLE_SIP_DECLARE_CUSTOM_VPTR_END
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(belle_sip_dual_resolver_context_t,belle_sip_resolver_context_t)
BELLE_SIP_DECLARE_CUSTOM_VPTR_END
typedef void (*belle_sip_source_remove_callback_t)(belle_sip_source_t *);
struct belle_sip_source{
......@@ -503,6 +506,7 @@ struct belle_sip_stack{
int resolver_send_error; /* used to simulate network error*/
int dscp;
char *dns_user_hosts_file; /* used to load additional hosts file for tests */
char *dns_resolv_conf; /*used to load custom resolv.conf, for tests*/
unsigned char dns_srv_enabled;
};
......
......@@ -27,7 +27,7 @@ static int has_type(belle_sip_object_t *obj, belle_sip_type_id_t id){
while(vptr!=NULL){
if (vptr->id==id) return TRUE;
vptr=vptr->parent;
vptr=vptr->get_parent();
}
return FALSE;
}
......@@ -144,17 +144,25 @@ static belle_sip_error_code _belle_object_marshal(belle_sip_object_t* obj, char*
return belle_sip_snprintf(buff,buff_size,offset,"{%s::%s %p}",obj->vptr->type_name,obj->name ? obj->name : "(no name)",obj);
}
static belle_sip_object_vptr_t *no_parent(void){
return NULL;
}
belle_sip_object_vptr_t belle_sip_object_t_vptr={
BELLE_SIP_TYPE_ID(belle_sip_object_t),
"belle_sip_object_t",
FALSE,
NULL, /*no parent, it's god*/
no_parent, /*no parent, it's god*/
NULL,
_belle_sip_object_uninit,
_belle_sip_object_clone,
_belle_object_marshal
};
belle_sip_object_vptr_t *belle_sip_object_t_vptr_get(void){
return &belle_sip_object_t_vptr;
}
void belle_sip_object_delete(void *ptr){
belle_sip_object_t *obj=BELLE_SIP_OBJECT(ptr);
belle_sip_object_vptr_t *vptr;
......@@ -163,7 +171,7 @@ void belle_sip_object_delete(void *ptr){
vptr=obj->vptr;
while(vptr!=NULL){
if (vptr->destroy) vptr->destroy(obj);
vptr=vptr->parent;
vptr=vptr->get_parent();
}
belle_sip_object_data_clear(obj);
belle_sip_free(obj);
......@@ -171,15 +179,15 @@ void belle_sip_object_delete(void *ptr){
static belle_sip_object_vptr_t *find_common_floor(belle_sip_object_vptr_t *vptr1, belle_sip_object_vptr_t *vptr2){
belle_sip_object_vptr_t *it1,*it2;
for (it1=vptr1;it1!=NULL;it1=it1->parent){
for (it1=vptr1;it1!=NULL;it1=it1->get_parent()){
if (it1==vptr2)
return vptr2;
}
for(it2=vptr2;it2!=NULL;it2=it2->parent){
for(it2=vptr2;it2!=NULL;it2=it2->get_parent()){
if (vptr1==it2)
return vptr1;
}
return find_common_floor(vptr1->parent,vptr2);
return find_common_floor(vptr1->get_parent(),vptr2);
}
/*copy the content of ref object to new object, for the part they have in common in their inheritence diagram*/
......@@ -194,7 +202,7 @@ void _belle_sip_object_copy(belle_sip_object_t *newobj, const belle_sip_object_t
belle_sip_fatal("Object of type %s cannot be cloned, it does not provide a clone() implementation.",vptr->type_name);
return;
}else vptr->clone(newobj,ref);
vptr=vptr->parent;
vptr=vptr->get_parent();
}
}
......@@ -285,7 +293,7 @@ int belle_sip_object_data_remove( belle_sip_object_t *obj, const char* name)
return !(list_entry!= NULL);
}
int belle_sip_object_data_exists( belle_sip_object_t *obj, const char* name )
int belle_sip_object_data_exists( const belle_sip_object_t *obj, const char* name )
{
return (belle_sip_list_find_custom(obj->data_store, belle_sip_object_data_find, name) != NULL);
}
......@@ -341,13 +349,14 @@ struct belle_sip_object_foreach_data {
void* userdata;
};
static void belle_sip_object_for_each_cb(void* data, void* userdata)
static void belle_sip_object_for_each_cb(void* data, void* pvdata)
{
struct belle_sip_object_foreach_data* fd = (struct belle_sip_object_foreach_data*)userdata;
struct belle_sip_object_data* it = (struct belle_sip_object_data*)data;
struct belle_sip_object_data* it = (struct belle_sip_object_data*)data;
struct belle_sip_object_foreach_data* fd = (struct belle_sip_object_foreach_data*)pvdata;
if( it && fd->apply_func )
fd->apply_func(it->name, it->data, userdata);
if( it && fd->apply_func ){
fd->apply_func(it->name, it->data, fd->userdata);
}
}
void belle_sip_object_data_foreach( const belle_sip_object_t* obj, void (*apply_func)(const char* key, void* data, void* userdata), void* userdata)
......@@ -370,7 +379,7 @@ void *belle_sip_object_cast(belle_sip_object_t *obj, belle_sip_type_id_t id, con
void *belle_sip_object_get_interface_methods(belle_sip_object_t *obj, belle_sip_interface_id_t ifid){
if (obj!=NULL){
belle_sip_object_vptr_t *vptr;
for (vptr=obj->vptr;vptr!=NULL;vptr=vptr->parent){
for (vptr=obj->vptr;vptr!=NULL;vptr=vptr->get_parent()){
belle_sip_interface_desc_t **ifaces=vptr->interfaces;
if (ifaces!=NULL){
for(;*ifaces!=0;++ifaces){
......@@ -448,7 +457,7 @@ belle_sip_error_code belle_sip_object_marshal(belle_sip_object_t* obj, char* buf
else
return vptr->marshal(obj,buff,buff_size,offset);
} else {
vptr=vptr->parent;
vptr=vptr->get_parent();
}
}
return BELLE_SIP_NOT_IMPLEMENTED; /*no implementation found*/
......@@ -504,7 +513,7 @@ char * _belle_sip_object_describe_type(belle_sip_object_vptr_t *vptr){
belle_sip_snprintf(ret,maxbufsize,&pos,"\t%s is created initially %s\n",vptr->type_name,
vptr->initially_unowned ? "unowned" : "owned");
belle_sip_snprintf(ret,maxbufsize,&pos,"\nInheritance diagram:\n");
for(it=vptr;it!=NULL;it=it->parent){
for(it=vptr;it!=NULL;it=it->get_parent()){
l=belle_sip_list_prepend(l,it);
}
for(elem=l;elem!=NULL;elem=elem->next){
......@@ -515,7 +524,7 @@ char * _belle_sip_object_describe_type(belle_sip_object_vptr_t *vptr){
}
belle_sip_list_free(l);
belle_sip_snprintf(ret,maxbufsize,&pos,"\nImplemented interfaces:\n");
for(it=vptr;it!=NULL;it=it->parent){
for(it=vptr;it!=NULL;it=it->get_parent()){
belle_sip_interface_desc_t **desc=it->interfaces;
if (desc!=NULL){
for(;*desc!=NULL;desc++){
......@@ -539,13 +548,14 @@ char *belle_sip_object_describe_type_from_name(const char *name){
char *vptr_name;
void *handle;
void *symbol;
belle_sip_object_get_vptr_t vptr_getter;
handle=dlopen(NULL,RTLD_LAZY);
if (handle==NULL){
belle_sip_error("belle_sip_object_describe_type_from_name: dlopen() failed: %s",dlerror());
return NULL;
}
vptr_name=belle_sip_strdup_printf("%s_vptr",name);
vptr_name=belle_sip_strdup_printf("%s_vptr_get",name);
symbol=dlsym(handle,vptr_name);
belle_sip_free(vptr_name);
dlclose(handle);
......@@ -553,7 +563,8 @@ char *belle_sip_object_describe_type_from_name(const char *name){
belle_sip_error("belle_sip_object_describe_type_from_name: could not find vptr for type %s",name);
return NULL;
}
return _belle_sip_object_describe_type((belle_sip_object_vptr_t*)symbol);
vptr_getter=(belle_sip_object_get_vptr_t)symbol;
return _belle_sip_object_describe_type(vptr_getter());
}
#else
......
......@@ -105,6 +105,37 @@ void belle_sip_parameters_set_parameter(belle_sip_parameters_t* params,const cha
params->paramnames_list=belle_sip_list_append(params->paramnames_list,lNewpair->name);
}
void belle_sip_parameters_set(belle_sip_parameters_t *parameters, const char* params){
belle_sip_parameters_clean(parameters);
if (params && *params!='\0'){
char *tmp=belle_sip_strdup(params);
char *end_of_param;
char *current=tmp;
char *equal;
char *next;
do{
end_of_param=strchr(current,';');
equal=strchr(current,'=');
if (!end_of_param) {
end_of_param=current+strlen(current);
next=end_of_param;
}else{
*end_of_param='\0';