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
a3ad258c
Commit
a3ad258c
authored
Nov 05, 2010
by
Simon Morlat
Browse files
start to implement source and mainloop.
parent
fd41c3e6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
193 additions
and
18 deletions
+193
-18
include/belle-sip/Makefile.am
include/belle-sip/Makefile.am
+5
-1
include/belle-sip/belle-sip.h
include/belle-sip/belle-sip.h
+25
-0
include/belle-sip/mainloop.h
include/belle-sip/mainloop.h
+41
-0
src/Makefile.am
src/Makefile.am
+2
-1
src/belle_sip_internal.h
src/belle_sip_internal.h
+15
-0
src/belle_sip_loop.c
src/belle_sip_loop.c
+72
-0
src/belle_sip_uri_impl.c
src/belle_sip_uri_impl.c
+2
-3
src/belle_sip_utils.c
src/belle_sip_utils.c
+31
-13
No files found.
include/belle-sip/Makefile.am
View file @
a3ad258c
bellesipdir
=
$(includedir)
/belle-sip
bellesip_HEADERS
=
uri.h list.h
bellesip_HEADERS
=
\
uri.h
\
list.h
\
mainloop.h
\
belle-sip.h
EXTRA_DIST
=
$(bellesip_HEADERS)
include/belle-sip/belle-sip.h
0 → 100644
View file @
a3ad258c
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
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
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BELLE_SIP_H
#define BELLE_SIP_H
#include "belle-sip/uri.h"
#include "belle-sip/list.h"
#include "belle-sip/mainloop.h"
#endif
include/belle-sip/mainloop.h
0 → 100644
View file @
a3ad258c
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
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
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BELLE_SIP_MAINLOOP_H
#define BELLE_SIP_MAINLOOP_H
#define BELLE_SIP_EVENT_READ 1
#define BELLE_SIP_EVENT_ERROR (1<<1)
typedef
struct
belle_sip_source
belle_sip_source_t
;
typedef
int
(
*
belle_sip_source_func_t
)(
void
*
user_data
,
int
events
);
belle_sip_source_t
*
belle_sip_timeout_source_new
(
belle_sip_source_func_t
func
,
void
*
data
,
unsigned
int
timeout_value_ms
);
typedef
struct
belle_sip_main_loop
belle_sip_main_loop_t
;
belle_sip_main_loop_t
*
belle_sip_main_loop_new
(
void
);
void
belle_sip_main_loop_add_source
(
belle_sip_main_loop_t
*
ml
,
belle_sip_source_t
*
source
);
void
belle_sip_main_loop_remove_source
(
belle_sip_main_loop_t
*
ml
,
belle_sip_source_t
*
source
);
void
belle_sip_main_loop_add_timeout
(
belle_sip_main_loop_t
*
ml
,
belle_sip_source_func_t
func
,
void
*
data
,
unsigned
int
timeout_value_ms
);
#endif
src/Makefile.am
View file @
a3ad258c
...
...
@@ -22,7 +22,8 @@ lib_LTLIBRARIES=libbellesip.la
libbellesip_la_SOURCES
=
belle_sip_uri_impl.c
\
belle_sip_utils.c belle_sip_utils.h
belle_sip_utils.c belle_sip_internal.h
\
belle_sip_loop.c
libbellesip_la_CFLAGS
=
$(STRICT_OPTIONS)
...
...
src/belle_sip_
utils
.h
→
src/belle_sip_
internal
.h
View file @
a3ad258c
#ifndef belle_utils_h
#define belle_utils_h
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include "belle-sip/list.h"
struct
_belle_sip_list
{
...
...
@@ -19,7 +25,16 @@ struct _belle_sip_list {
extern
"C"
{
#endif
void
*
belle_sip_malloc
(
size_t
size
);
void
*
belle_sip_malloc0
(
size_t
size
);
void
*
belle_sip_realloc
(
void
*
ptr
,
size_t
size
);
void
belle_sip_free
(
void
*
ptr
);
#define belle_sip_new(type) (type*)belle_sip_malloc(sizeof(type))
#define belle_sip_new0(type) (type*)belle_sip_malloc0(sizeof(type))
belle_sip_list_t
*
belle_sip_list_new
(
void
*
data
);
belle_sip_list_t
*
belle_sip_list_append_link
(
belle_sip_list_t
*
elem
,
belle_sip_list_t
*
new_elem
);
belle_sip_list_t
*
belle_sip_list_free
(
belle_sip_list_t
*
list
);
#define belle_sip_list_next(elem) ((elem)->next)
/***************/
...
...
src/belle_sip_loop.c
0 → 100644
View file @
a3ad258c
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
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
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "belle-sip/belle-sip.h"
#include "belle_sip_internal.h"
struct
belle_sip_source
{
belle_sip_list_t
node
;
int
fd
;
int
revents
;
int
timeout
;
void
*
data
;
belle_sip_source_func_t
notify
;
void
(
*
on_remove
)(
belle_sip_source_t
*
);
};
void
belle_sip_source_destroy
(
belle_sip_source_t
*
obj
){
belle_sip_free
(
obj
);
}
belle_sip_source_t
*
belle_sip_timeout_source_new
(
belle_sip_source_func_t
func
,
void
*
data
,
unsigned
int
timeout_value_ms
){
belle_sip_source_t
*
s
=
belle_sip_new0
(
belle_sip_source_t
);
s
->
fd
=-
1
;
s
->
timeout
=
timeout_value_ms
;
s
->
data
=
data
;
s
->
notify
=
func
;
return
s
;
}
struct
belle_sip_main_loop
{
belle_sip_source_t
*
sources
;
};
belle_sip_main_loop_t
*
belle_sip_main_loop_new
(
void
){
belle_sip_main_loop_t
*
m
=
belle_sip_new0
(
belle_sip_main_loop_t
);
return
m
;
}
void
belle_sip_main_loop_add_source
(
belle_sip_main_loop_t
*
ml
,
belle_sip_source_t
*
source
){
if
(
source
->
node
.
next
||
source
->
node
.
prev
){
belle_sip_fatal
(
"Source is already linked somewhere else."
);
return
;
}
ml
->
sources
=
(
belle_sip_source_t
*
)
belle_sip_list_append_link
((
belle_sip_list_t
*
)
ml
->
sources
,(
belle_sip_list_t
*
)
source
);
}
void
belle_sip_main_loop_remove_source
(
belle_sip_main_loop_t
*
ml
,
belle_sip_source_t
*
source
){
ml
->
sources
=
(
belle_sip_source_t
*
)
belle_sip_list_remove_link
((
belle_sip_list_t
*
)
ml
->
sources
,(
belle_sip_list_t
*
)
source
);
}
void
belle_sip_main_loop_add_timeout
(
belle_sip_main_loop_t
*
ml
,
belle_sip_source_func_t
func
,
void
*
data
,
unsigned
int
timeout_value_ms
){
belle_sip_source_t
*
s
=
belle_sip_timeout_source_new
(
func
,
data
,
timeout_value_ms
);
s
->
on_remove
=
belle_sip_source_destroy
;
belle_sip_main_loop_add_source
(
ml
,
s
);
}
src/belle_sip_uri_impl.c
View file @
a3ad258c
...
...
@@ -11,7 +11,7 @@
#include <stdarg.h>
#include "belle_sip_uriParser.h"
#include "belle_sip_uriLexer.h"
#include "belle_sip_
utils
.h"
#include "belle_sip_
internal
.h"
#define GET_SET_STRING(object_type,attribute) \
const char* object_type##_get_##attribute (object_type##_t* obj) {\
...
...
@@ -128,8 +128,7 @@ belle_sip_uri_t* belle_sip_uri_parse (const char* uri) {
}
belle_sip_uri_t
*
belle_sip_uri_new
()
{
belle_sip_uri_t
*
lUri
=
(
belle_sip_uri_t
*
)
malloc
(
sizeof
(
belle_sip_uri_t
));
memset
(
lUri
,
0
,
sizeof
(
belle_sip_uri_t
));
belle_sip_uri_t
*
lUri
=
belle_sip_new0
(
belle_sip_uri_t
);
lUri
->
ttl_param
=-
1
;
return
lUri
;
}
...
...
src/belle_sip_utils.c
View file @
a3ad258c
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include "belle_sip_utils.h"
#include "belle_sip_internal.h"
static
FILE
*
__log_file
=
0
;
...
...
@@ -142,15 +139,12 @@ static void __belle_sip_logv_out(belle_sip_log_level lev, const char *fmt, va_li
}
belle_sip_list_t
*
belle_sip_list_new
(
void
*
data
){
belle_sip_list_t
*
new_elem
=
(
belle_sip_list_t
*
)
malloc
(
sizeof
(
belle_sip_list_t
));
memset
(
new_elem
,
0
,
sizeof
(
belle_sip_list_t
));
new_elem
->
prev
=
new_elem
->
next
=
NULL
;
belle_sip_list_t
*
new_elem
=
belle_sip_new0
(
belle_sip_list_t
);
new_elem
->
data
=
data
;
return
new_elem
;
}
belle_sip_list_t
*
belle_sip_list_append
(
belle_sip_list_t
*
elem
,
void
*
data
){
belle_sip_list_t
*
new_elem
=
belle_sip_list_new
(
data
);
belle_sip_list_t
*
belle_sip_list_append_link
(
belle_sip_list_t
*
elem
,
belle_sip_list_t
*
new_elem
){
belle_sip_list_t
*
it
=
elem
;
if
(
elem
==
NULL
)
return
new_elem
;
while
(
it
->
next
!=
NULL
)
it
=
belle_sip_list_next
(
it
);
...
...
@@ -159,6 +153,11 @@ belle_sip_list_t* belle_sip_list_append(belle_sip_list_t* elem, void * data){
return
elem
;
}
belle_sip_list_t
*
belle_sip_list_append
(
belle_sip_list_t
*
elem
,
void
*
data
){
belle_sip_list_t
*
new_elem
=
belle_sip_list_new
(
data
);
return
belle_sip_list_append_link
(
elem
,
new_elem
);
}
belle_sip_list_t
*
belle_sip_list_prepend
(
belle_sip_list_t
*
elem
,
void
*
data
){
belle_sip_list_t
*
new_elem
=
belle_sip_list_new
(
data
);
if
(
elem
!=
NULL
)
{
...
...
@@ -185,9 +184,9 @@ belle_sip_list_t* belle_sip_list_free(belle_sip_list_t* list){
while
(
elem
->
next
!=
NULL
)
{
tmp
=
elem
;
elem
=
elem
->
next
;
free
(
tmp
);
belle_sip_
free
(
tmp
);
}
free
(
elem
);
belle_sip_
free
(
elem
);
return
NULL
;
}
...
...
@@ -381,5 +380,24 @@ char * belle_sip_concat (const char *str, ...) {
va_end
(
ap
);
}
return
result
;
return
result
;
}
void
*
belle_sip_malloc
(
size_t
size
){
return
malloc
(
size
);
}
void
*
belle_sip_malloc0
(
size_t
size
){
void
*
p
=
malloc
(
size
);
memset
(
p
,
0
,
size
);
return
p
;
}
void
*
belle_sip_realloc
(
void
*
ptr
,
size_t
size
){
return
realloc
(
ptr
,
size
);
}
void
belle_sip_free
(
void
*
ptr
){
free
(
ptr
);
}
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