Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
belle-sip
Commits
d25b05a2
Commit
d25b05a2
authored
Jan 21, 2011
by
jehan
Browse files
one more step in message implementation
parent
5df364f6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
27 deletions
+51
-27
include/belle-sip/belle-sip.h
include/belle-sip/belle-sip.h
+8
-0
src/belle_sip_headers_impl.c
src/belle_sip_headers_impl.c
+10
-10
src/belle_sip_internal.h
src/belle_sip_internal.h
+9
-8
src/belle_sip_object.c
src/belle_sip_object.c
+8
-1
src/message.c
src/message.c
+16
-8
No files found.
include/belle-sip/belle-sip.h
View file @
d25b05a2
...
...
@@ -90,6 +90,14 @@ belle_sip_object_t * belle_sip_object_ref(void *obj);
* Decrements the reference counter. When it drops to zero, the object is destroyed.
**/
void
belle_sip_object_unref
(
void
*
obj
);
/**
* Set object name.
**/
void
belle_sip_object_set_name
(
belle_sip_object_t
*
obj
,
const
char
*
name
);
/**
* Get object name.
**/
const
char
*
belle_sip_object_get_name
(
belle_sip_object_t
*
obj
);
/**
* Destroy the object: this function is intended for unowed object, that is objects
...
...
src/belle_sip_headers_impl.c
View file @
d25b05a2
...
...
@@ -77,7 +77,7 @@ void belle_sip_header_contact_destroy(belle_sip_header_contact_t* contact) {
belle_sip_header_address_destroy
(
BELLE_SIP_HEADER_ADDRESS
(
contact
));
}
BELLE_SIP_NEW
(
header_contact
,
header_address
)
BELLE_SIP_NEW
_WITH_NAME
(
header_contact
,
header_address
,
"Contact"
)
BELLE_SIP_PARSE
(
header_contact
)
GET_SET_INT_PARAM_PRIVATE
(
belle_sip_header_contact
,
expires
,
int
,
_
)
...
...
@@ -116,7 +116,7 @@ static void belle_sip_header_from_destroy(belle_sip_header_from_t* from) {
belle_sip_header_address_destroy
(
BELLE_SIP_HEADER_ADDRESS
(
from
));
}
BELLE_SIP_NEW
(
header_from
,
header_address
)
BELLE_SIP_NEW
_WITH_NAME
(
header_from
,
header_address
,
"From"
)
BELLE_SIP_PARSE
(
header_from
)
GET_SET_STRING_PARAM
(
belle_sip_header_from
,
tag
);
...
...
@@ -132,7 +132,7 @@ static void belle_sip_header_to_destroy(belle_sip_header_to_t* to) {
belle_sip_header_address_destroy
(
BELLE_SIP_HEADER_ADDRESS
(
to
));
}
BELLE_SIP_NEW
(
header_to
,
header_address
)
BELLE_SIP_NEW
_WITH_NAME
(
header_to
,
header_address
,
"To"
)
BELLE_SIP_PARSE
(
header_to
)
GET_SET_STRING_PARAM
(
belle_sip_header_to
,
tag
);
...
...
@@ -154,7 +154,7 @@ static void belle_sip_header_via_destroy(belle_sip_header_via_t* via) {
if
(
via
->
protocol
)
belle_sip_free
((
void
*
)
via
->
protocol
);
}
BELLE_SIP_NEW
(
header_via
,
header_address
)
BELLE_SIP_NEW
_WITH_NAME
(
header_via
,
header_address
,
"Via"
)
BELLE_SIP_PARSE
(
header_via
)
GET_SET_STRING
(
belle_sip_header_via
,
protocol
);
GET_SET_STRING
(
belle_sip_header_via
,
transport
);
...
...
@@ -209,7 +209,7 @@ static void belle_sip_header_call_id_destroy(belle_sip_header_call_id_t* call_id
}
BELLE_SIP_NEW
(
header_call_id
,
object
)
BELLE_SIP_NEW
_WITH_NAME
(
header_call_id
,
object
,
"Call-ID"
)
BELLE_SIP_PARSE
(
header_call_id
)
GET_SET_STRING
(
belle_sip_header_call_id
,
call_id
);
/**************************
...
...
@@ -228,7 +228,7 @@ static void belle_sip_header_cseq_destroy(belle_sip_header_cseq_t* cseq) {
}
BELLE_SIP_NEW
(
header_cseq
,
object
)
BELLE_SIP_NEW
_WITH_NAME
(
header_cseq
,
object
,
"Cseq"
)
BELLE_SIP_PARSE
(
header_cseq
)
GET_SET_STRING
(
belle_sip_header_cseq
,
method
);
GET_SET_INT
(
belle_sip_header_cseq
,
seq_number
,
unsigned
int
)
...
...
@@ -248,7 +248,7 @@ static void belle_sip_header_content_type_destroy(belle_sip_header_content_type_
if
(
content_type
->
subtype
)
belle_sip_free
((
void
*
)
content_type
->
subtype
);
}
BELLE_SIP_NEW
(
header_content_type
,
parameters
)
BELLE_SIP_NEW
_WITH_NAME
(
header_content_type
,
parameters
,
"Content-Type"
)
BELLE_SIP_PARSE
(
header_content_type
)
GET_SET_STRING
(
belle_sip_header_content_type
,
type
);
GET_SET_STRING
(
belle_sip_header_content_type
,
subtype
);
...
...
@@ -264,7 +264,7 @@ static void belle_sip_header_route_destroy(belle_sip_header_route_t* route) {
belle_sip_header_address_destroy
(
BELLE_SIP_HEADER_ADDRESS
(
route
));
}
BELLE_SIP_NEW
(
header_route
,
header_address
)
BELLE_SIP_NEW
_WITH_NAME
(
header_route
,
header_address
,
"Route"
)
BELLE_SIP_PARSE
(
header_route
)
/**************************
* Record route header object inherent from header_address
...
...
@@ -278,7 +278,7 @@ static void belle_sip_header_record_route_destroy(belle_sip_header_record_route_
belle_sip_header_address_destroy
(
BELLE_SIP_HEADER_ADDRESS
(
record_route
));
}
BELLE_SIP_NEW
(
header_record_route
,
header_address
)
BELLE_SIP_NEW
_WITH_NAME
(
header_record_route
,
header_address
,
"Record-Route"
)
BELLE_SIP_PARSE
(
header_record_route
)
/**************************
* content length header object inherent from object
...
...
@@ -293,6 +293,6 @@ static void belle_sip_header_content_length_destroy(belle_sip_header_content_len
belle_sip_object_destroy
(
BELLE_SIP_OBJECT
(
content_length
));
}
BELLE_SIP_NEW
(
header_content_length
,
object
)
BELLE_SIP_NEW
_WITH_NAME
(
header_content_length
,
object
,
"Content-Length"
)
BELLE_SIP_PARSE
(
header_content_length
)
GET_SET_INT
(
belle_sip_header_content_length
,
content_length
,
unsigned
int
)
src/belle_sip_internal.h
View file @
d25b05a2
...
...
@@ -36,6 +36,7 @@ struct _belle_sip_object{
int
ref
;
void
*
vptr
;
belle_sip_object_destroy_t
destroy
;
const
char
*
name
;
};
belle_sip_object_t
*
_belle_sip_object_new
(
size_t
objsize
,
belle_sip_type_id_t
id
,
void
*
vptr
,
belle_sip_object_destroy_t
destroy_func
,
int
initially_unowed
);
...
...
@@ -315,15 +316,15 @@ belle_sip_##object_type##_t* belle_sip_##object_type##_parse (const char* value)
return l_parsed_object;\
}
#define BELLE_SIP_NEW(object_type,super_type) \
belle_sip_##object_type##_t* belle_sip_##object_type##_new () { \
belle_sip_##object_type##_t* l_object = belle_sip_object_new(belle_sip_##object_type##_t, (belle_sip_object_destroy_t)belle_sip_##object_type##_destroy);\
belle_sip_##super_type##_init((belle_sip_##super_type##_t*)l_object); \
return l_object;\
}
#define BELLE_SIP_NEW(object_type,super_type) BELLE_SIP_NEW_WITH_NAME(object_type,super_type,NULL)
#define BELLE_SIP_NEW_WITH_NAME(object_type,super_type,name) \
belle_sip_##object_type##_t* belle_sip_##object_type##_new () { \
belle_sip_##object_type##_t* l_object = belle_sip_object_new(belle_sip_##object_type##_t, (belle_sip_object_destroy_t)belle_sip_##object_type##_destroy);\
belle_sip_##super_type##_init((belle_sip_##super_type##_t*)l_object); \
belle_sip_object_set_name(BELLE_SIP_OBJECT(l_object),name);\
return l_object;\
}
typedef
struct
belle_sip_param_pair_t
{
int
ref
;
char
*
name
;
...
...
src/belle_sip_object.c
View file @
d25b05a2
...
...
@@ -85,4 +85,11 @@ void *belle_sip_object_cast(belle_sip_object_t *obj, belle_sip_type_id_t id, con
void
belle_sip_object_init
(
belle_sip_object_t
*
obj
)
{
belle_sip_object_init_type
(
obj
,
belle_sip_object_t
);
}
void
belle_sip_object_set_name
(
belle_sip_object_t
*
object
,
const
char
*
name
)
{
if
(
name
==
NULL
)
return
;
if
(
object
->
name
)
belle_sip_free
((
void
*
)
object
->
name
);
object
->
name
=
belle_sip_strdup
(
name
);
}
const
char
*
belle_sip_object_get_name
(
belle_sip_object_t
*
object
)
{
return
object
->
name
;
}
src/message.c
View file @
d25b05a2
...
...
@@ -18,27 +18,35 @@
#include "belle_sip_messageParser.h"
#include "belle_sip_messageLexer.h"
#include "belle_sip_internal.h"
typedef
struct
_header_container
{
typedef
struct
_header
s
_container
{
const
char
*
name
;
belle_sip_list_t
*
header_list
;
}
header_container_t
;
/*
static header_container_t* belle_sip_message_header_container_new(const char* name) {
header_container_t* header_container = belle_sip_new0(header_container_t);
header_container->name= belle_sip_strdup(name);
}
header
s
_container_t
;
static
header
s
_container_t
*
belle_sip_message_header
s
_container_new
(
const
char
*
name
)
{
header
s
_container_t
*
header
s
_container
=
belle_sip_new0
(
header
s
_container_t
);
header
s
_container
->
name
=
belle_sip_strdup
(
name
);
}
*/
struct
_belle_sip_message
{
belle_sip_object_t
base
;
belle_sip_list_t
*
header_list
;
belle_sip_list_t
*
headernames_list
;
};
static
int
belle_sip_headers_container_comp_func
(
const
headers_container_t
*
a
,
const
char
*
b
)
{
return
strcmp
(
a
->
name
,
b
);
}
static
void
belle_sip_message_init
(
belle_sip_message_t
*
message
){
belle_sip_object_init_type
(
message
,
belle_sip_message_t
);
}
headers_container_t
*
belle_sip_headers_container_get
(
belle_sip_message_t
*
message
,
const
char
*
header_name
)
{
belle_sip_list_t
*
result
=
belle_sip_list_find_custom
(
message
->
header_list
,
(
belle_sip_compare_func
)
belle_sip_headers_container_comp_func
,
header_name
);
return
result
?
(
headers_container_t
*
)(
result
->
data
)
:
NULL
;
}
void
belle_sip_message_add_header
(
belle_sip_message_t
*
message
,
belle_sip_header_t
*
header
)
{
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment