summaryrefslogtreecommitdiffstats
path: root/branches/1.0/tinySDP/src
diff options
context:
space:
mode:
Diffstat (limited to 'branches/1.0/tinySDP/src')
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header.c139
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_A.c400
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_B.c361
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_C.c368
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_Dummy.c354
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_E.c341
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_I.c342
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_K.c341
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_M.c811
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_O.c413
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_P.c340
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_R.c394
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_S.c338
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_T.c381
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_U.c342
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_V.c333
-rw-r--r--branches/1.0/tinySDP/src/headers/tsdp_header_Z.c485
-rw-r--r--branches/1.0/tinySDP/src/parsers/tsdp_parser_message.c477
-rw-r--r--branches/1.0/tinySDP/src/tsdp.c211
-rw-r--r--branches/1.0/tinySDP/src/tsdp_message.c409
20 files changed, 0 insertions, 7580 deletions
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header.c b/branches/1.0/tinySDP/src/headers/tsdp_header.c
deleted file mode 100644
index f3f1419..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-/**@file tsdp_header.c
- * @brief Defines a SDP header/line (<type>=<value>).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Sat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header.h"
-
-#include "tinysdp/headers/tsdp_header_Dummy.h"
-
-#include "tsk_string.h"
-
-int tsdp_header_rank_cmp(const tsdp_header_t* hdr1, const tsdp_header_t* hdr2)
-{
- if(hdr1 && hdr2){
- return (hdr1->rank - hdr2->rank);
- }
- else{
- return -1;
- }
-}
-
-tsdp_header_t* tsdp_header_clone(const tsdp_header_t* self)
-{
- if(self){
- return self->clone(self);
- }
- return tsk_null;
-}
-
-/** Gets the name of the SDP header with a type equal to @a type.
- * @param type The @a type of the header for which to retrieve the name.
- *
- * @return The name of the header.
-**/
-char tsdp_header_get_name(tsdp_header_type_t type)
-{
- switch(type)
- {
- case tsdp_htype_A: return 'a';
- case tsdp_htype_B: return 'b';
- case tsdp_htype_C: return 'c';
- case tsdp_htype_E: return 'e';
- case tsdp_htype_I: return 'i';
- case tsdp_htype_K: return 'k';
- case tsdp_htype_M: return 'm';
- case tsdp_htype_O: return 'o';
- case tsdp_htype_P: return 'p';
- case tsdp_htype_R: return 'r';
- case tsdp_htype_S: return 's';
- case tsdp_htype_T: return 't';
- case tsdp_htype_U: return 'u';
- case tsdp_htype_V: return 'v';
- case tsdp_htype_Z: return 'z';
-
- default: return '*';
- }
-}
-
-char tsdp_header_get_nameex(const tsdp_header_t *self)
-{
- if(self){
- if(self->type == tsdp_htype_Dummy){
- return ((tsdp_header_Dummy_t*)(self))->name;
- }
- else{
- return tsdp_header_get_name(self->type);
- }
- }
- return '*';
-}
-
-
-int tsdp_header_serialize(const tsdp_header_t *self, tsk_buffer_t *output)
-{
- static char name;
- int ret = -1;
- if(!self || !output){
- return -1;
- }
-
- /* Name */
- name = tsdp_header_get_nameex(self);
- tsk_buffer_append_2(output, "%c=", name);
-
- /* Value */
- if((ret = self->tostring(self, output))){
- // Abort?
- }
-
- /* CRLF*/
- if(output->size>2){
- if(*(TSK_BUFFER_TO_U8(output)+TSK_BUFFER_SIZE(output)-2) != '\r'
- && *(TSK_BUFFER_TO_U8(output)+TSK_BUFFER_SIZE(output)-1) != '\n'){
- ret = tsk_buffer_append(output, "\r\n", 2);
- }
- }
- else{
- ret = tsk_buffer_append(output, "\r\n", 2);
- }
-
- return ret;
-}
-
-char* tsdp_header_tostring(const tsdp_header_t *self)
-{
- tsk_buffer_t* output = tsk_buffer_create_null();
- char* str = tsk_null;
-
- if(!(tsdp_header_serialize(self, output))){
- str = tsk_strndup(TSK_BUFFER_DATA(output), TSK_BUFFER_SIZE(output));
- }
-
- TSK_OBJECT_SAFE_FREE(output);
- return str;
-}
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_A.c b/branches/1.0/tinySDP/src/headers/tsdp_header_A.c
deleted file mode 100644
index 6f64f80..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_A.c
+++ /dev/null
@@ -1,400 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_A.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-
-/**@file tsdp_header_A.c
- * @brief SDP "a=" header (Attributes).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Iat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_A.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 68 "./ragel/tsdp_parser_header_A.rl" */
-
-
-
-
-tsdp_header_A_t* tsdp_header_A_create(const char* field, const char* value)
-{
- return tsk_object_new(TSDP_HEADER_A_VA_ARGS(field, value));
-}
-
-tsdp_header_A_t* tsdp_header_A_create_null()
-{
- return tsdp_header_A_create(tsk_null, tsk_null);
-}
-
-
-int tsdp_header_A_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header){
- const tsdp_header_A_t *A = (const tsdp_header_A_t *)header;
-
- return tsk_buffer_append_2(output, "%s%s%s",
- A->field,
-
- A->value ? ":" : "",
- A->value ? A->value : ""
- );
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_A_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_A_t *A = (const tsdp_header_A_t *)header;
- return (tsdp_header_t*)tsdp_header_A_create(A->field, A->value);
- }
- return tsk_null;
-}
-
-tsdp_header_A_t *tsdp_header_A_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_A_t *hdr_A = tsdp_header_A_create_null();
-
- const char *tag_start;
-
-
-/* #line 98 "./src/headers/tsdp_header_A.c" */
-static const char _tsdp_machine_parser_header_A_actions[] = {
- 0, 1, 0, 1, 1, 1, 2, 2,
- 0, 2
-};
-
-static const char _tsdp_machine_parser_header_A_key_offsets[] = {
- 0, 0, 1, 3, 18, 19, 35, 35,
- 36
-};
-
-static const char _tsdp_machine_parser_header_A_trans_keys[] = {
- 97, 32, 61, 32, 33, 37, 39, 126,
- 42, 43, 45, 46, 48, 57, 65, 90,
- 95, 122, 10, 13, 33, 37, 39, 58,
- 126, 42, 43, 45, 46, 48, 57, 65,
- 90, 95, 122, 13, 13, 0
-};
-
-static const char _tsdp_machine_parser_header_A_single_lengths[] = {
- 0, 1, 2, 5, 1, 6, 0, 1,
- 1
-};
-
-static const char _tsdp_machine_parser_header_A_range_lengths[] = {
- 0, 0, 0, 5, 0, 5, 0, 0,
- 0
-};
-
-static const char _tsdp_machine_parser_header_A_index_offsets[] = {
- 0, 0, 2, 5, 16, 18, 30, 31,
- 33
-};
-
-static const char _tsdp_machine_parser_header_A_indicies[] = {
- 0, 1, 0, 2, 1, 2, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 1,
- 4, 1, 5, 6, 6, 6, 7, 6,
- 6, 6, 6, 6, 6, 1, 1, 9,
- 8, 11, 10, 0
-};
-
-static const char _tsdp_machine_parser_header_A_trans_targs[] = {
- 2, 0, 3, 5, 6, 4, 5, 7,
- 8, 4, 8, 4
-};
-
-static const char _tsdp_machine_parser_header_A_trans_actions[] = {
- 0, 0, 0, 1, 0, 3, 0, 3,
- 1, 7, 0, 5
-};
-
-static const char _tsdp_machine_parser_header_A_eof_actions[] = {
- 0, 0, 0, 0, 0, 3, 0, 7,
- 5
-};
-
-static const int tsdp_machine_parser_header_A_start = 1;
-static const int tsdp_machine_parser_header_A_first_final = 5;
-static const int tsdp_machine_parser_header_A_error = 0;
-
-static const int tsdp_machine_parser_header_A_en_main = 1;
-
-
-/* #line 119 "./ragel/tsdp_parser_header_A.rl" */
-
-/* #line 164 "./src/headers/tsdp_header_A.c" */
- {
- cs = tsdp_machine_parser_header_A_start;
- }
-
-/* #line 120 "./ragel/tsdp_parser_header_A.rl" */
-
-/* #line 171 "./src/headers/tsdp_header_A.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_A_trans_keys + _tsdp_machine_parser_header_A_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_A_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_A_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_A_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- _trans = _tsdp_machine_parser_header_A_indicies[_trans];
- cs = _tsdp_machine_parser_header_A_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_A_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_A_actions + _tsdp_machine_parser_header_A_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_A.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_A.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_A->field);
- }
- break;
- case 2:
-/* #line 56 "./ragel/tsdp_parser_header_A.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_A->value);
- }
- break;
-/* #line 263 "./src/headers/tsdp_header_A.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_A_actions + _tsdp_machine_parser_header_A_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_A.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_A.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_A->field);
- }
- break;
- case 2:
-/* #line 56 "./ragel/tsdp_parser_header_A.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_A->value);
- }
- break;
-/* #line 297 "./src/headers/tsdp_header_A.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 121 "./ragel/tsdp_parser_header_A.rl" */
-
- if( cs <
-/* #line 308 "./src/headers/tsdp_header_A.c" */
-5
-/* #line 122 "./ragel/tsdp_parser_header_A.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"a=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_A);
- }
-
- return hdr_A;
-}
-
-
-int tsdp_header_A_removeAll_by_field(tsdp_headers_A_L_t *attributes, const char* field)
-{
- tsk_list_item_t* item;
- const tsdp_header_A_t* A;
-
- if(!attributes || !field){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
-
-again:
- tsk_list_foreach(item, attributes){
- if(!(A = item->data)){
- continue;
- }
- if(tsk_striequals(field, A->field)){
- tsk_list_remove_item(attributes, item);
- goto again;
- }
- }
-
- return 0;
-}
-
-
-
-
-//========================================================
-// A header object definition
-//
-
-static tsk_object_t* tsdp_header_A_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_A_t *A = self;
- if(A)
- {
- TSDP_HEADER(A)->type = tsdp_htype_A;
- TSDP_HEADER(A)->tostring = tsdp_header_A_tostring;
- TSDP_HEADER(A)->clone = tsdp_header_A_clone;
- TSDP_HEADER(A)->rank = TSDP_HTYPE_A_RANK;
-
- A->field = tsk_strdup(va_arg(*app, const char*));
- A->value = tsk_strdup(va_arg(*app, const char*));
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new A header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_A_dtor(tsk_object_t *self)
-{
- tsdp_header_A_t *A = self;
- if(A){
- TSK_FREE(A->field);
- TSK_FREE(A->value);
- }
- else{
- TSK_DEBUG_ERROR("Null A header.");
- }
-
- return self;
-}
-static int tsdp_header_A_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_A_def_s =
-{
- sizeof(tsdp_header_A_t),
- tsdp_header_A_ctor,
- tsdp_header_A_dtor,
- tsdp_header_A_cmp
-};
-
-const tsk_object_def_t *tsdp_header_A_def_t = &tsdp_header_A_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_B.c b/branches/1.0/tinySDP/src/headers/tsdp_header_B.c
deleted file mode 100644
index c6d2020..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_B.c
+++ /dev/null
@@ -1,361 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_B.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-
-/**@file tsdp_header_B.c
- * @brief SDP "b=" header (Bandwidth).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Iat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_B.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 68 "./ragel/tsdp_parser_header_B.rl" */
-
-
-
-
-
-tsdp_header_B_t* tsdp_header_B_create(const char* bwtype, uint32_t bandwidth)
-{
- return tsk_object_new(TSDP_HEADER_B_VA_ARGS(bwtype, bandwidth));
-}
-
-tsdp_header_B_t* tsdp_header_B_create_null()
-{
- return tsdp_header_B_create(tsk_null, 0);
-}
-
-int tsdp_header_B_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header){
- const tsdp_header_B_t *B = (const tsdp_header_B_t *)header;
-
- return tsk_buffer_append_2(output, "%s:%u",
- B->bwtype,
- B->bandwidth
- );
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_B_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_B_t *B = (const tsdp_header_B_t *)header;
- return (tsdp_header_t*)tsdp_header_B_create(B->bwtype, B->bandwidth);
- }
- return tsk_null;
-}
-
-tsdp_header_B_t *tsdp_header_B_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_B_t *hdr_B = tsdp_header_B_create_null();
-
- const char *tag_start;
-
-
-/* #line 96 "./src/headers/tsdp_header_B.c" */
-static const char _tsdp_machine_parser_header_B_actions[] = {
- 0, 1, 0, 1, 1, 1, 2
-};
-
-static const char _tsdp_machine_parser_header_B_key_offsets[] = {
- 0, 0, 1, 3, 18, 33, 35, 36,
- 39
-};
-
-static const char _tsdp_machine_parser_header_B_trans_keys[] = {
- 98, 32, 61, 32, 33, 37, 39, 126,
- 42, 43, 45, 46, 48, 57, 65, 90,
- 95, 122, 33, 37, 39, 58, 126, 42,
- 43, 45, 46, 48, 57, 65, 90, 95,
- 122, 48, 57, 10, 13, 48, 57, 0
-};
-
-static const char _tsdp_machine_parser_header_B_single_lengths[] = {
- 0, 1, 2, 5, 5, 0, 1, 1,
- 0
-};
-
-static const char _tsdp_machine_parser_header_B_range_lengths[] = {
- 0, 0, 0, 5, 5, 1, 0, 1,
- 0
-};
-
-static const char _tsdp_machine_parser_header_B_index_offsets[] = {
- 0, 0, 2, 5, 16, 27, 29, 31,
- 34
-};
-
-static const char _tsdp_machine_parser_header_B_indicies[] = {
- 0, 1, 0, 2, 1, 2, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 1,
- 4, 4, 4, 5, 4, 4, 4, 4,
- 4, 4, 1, 6, 1, 7, 1, 8,
- 9, 1, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_B_trans_targs[] = {
- 2, 0, 3, 4, 4, 5, 7, 8,
- 6, 7
-};
-
-static const char _tsdp_machine_parser_header_B_trans_actions[] = {
- 0, 0, 0, 1, 0, 3, 1, 0,
- 5, 0
-};
-
-static const char _tsdp_machine_parser_header_B_eof_actions[] = {
- 0, 0, 0, 0, 0, 0, 0, 5,
- 0
-};
-
-static const int tsdp_machine_parser_header_B_start = 1;
-static const int tsdp_machine_parser_header_B_first_final = 7;
-static const int tsdp_machine_parser_header_B_error = 0;
-
-static const int tsdp_machine_parser_header_B_en_main = 1;
-
-
-/* #line 117 "./ragel/tsdp_parser_header_B.rl" */
-
-/* #line 161 "./src/headers/tsdp_header_B.c" */
- {
- cs = tsdp_machine_parser_header_B_start;
- }
-
-/* #line 118 "./ragel/tsdp_parser_header_B.rl" */
-
-/* #line 168 "./src/headers/tsdp_header_B.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_B_trans_keys + _tsdp_machine_parser_header_B_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_B_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_B_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_B_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- _trans = _tsdp_machine_parser_header_B_indicies[_trans];
- cs = _tsdp_machine_parser_header_B_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_B_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_B_actions + _tsdp_machine_parser_header_B_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_B.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_B.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_B->bwtype);
- }
- break;
- case 2:
-/* #line 56 "./ragel/tsdp_parser_header_B.rl" */
- {
- TSK_PARSER_SET_UINT(hdr_B->bandwidth);
- }
- break;
-/* #line 260 "./src/headers/tsdp_header_B.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_B_actions + _tsdp_machine_parser_header_B_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 2:
-/* #line 56 "./ragel/tsdp_parser_header_B.rl" */
- {
- TSK_PARSER_SET_UINT(hdr_B->bandwidth);
- }
- break;
-/* #line 282 "./src/headers/tsdp_header_B.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 119 "./ragel/tsdp_parser_header_B.rl" */
-
- if( cs <
-/* #line 293 "./src/headers/tsdp_header_B.c" */
-7
-/* #line 120 "./ragel/tsdp_parser_header_B.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"b=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_B);
- }
-
- return hdr_B;
-}
-
-
-
-
-
-
-
-//========================================================
-// B header object definition
-//
-
-static tsk_object_t* tsdp_header_B_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_B_t *B = self;
- if(B){
- TSDP_HEADER(B)->type = tsdp_htype_B;
- TSDP_HEADER(B)->tostring = tsdp_header_B_tostring;
- TSDP_HEADER(B)->clone = tsdp_header_B_clone;
- TSDP_HEADER(B)->rank = TSDP_HTYPE_B_RANK;
-
- B->bwtype = tsk_strdup(va_arg(*app, const char*));
- B->bandwidth = va_arg(*app, uint32_t);
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new B header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_B_dtor(tsk_object_t *self)
-{
- tsdp_header_B_t *B = self;
- if(B){
- TSK_FREE(B->bwtype);
- }
- else{
- TSK_DEBUG_ERROR("Null B header.");
- }
-
- return self;
-}
-static int tsdp_header_B_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_B_def_s =
-{
- sizeof(tsdp_header_B_t),
- tsdp_header_B_ctor,
- tsdp_header_B_dtor,
- tsdp_header_B_cmp
-};
-
-const tsk_object_def_t *tsdp_header_B_def_t = &tsdp_header_B_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_C.c b/branches/1.0/tinySDP/src/headers/tsdp_header_C.c
deleted file mode 100644
index c585395..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_C.c
+++ /dev/null
@@ -1,368 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_C.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-
-/**@file tsdp_header_C.c
- * @brief "c=" header (Connection Data).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Iat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_C.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 72 "./ragel/tsdp_parser_header_C.rl" */
-
-
-
-tsdp_header_C_t* tsdp_header_c_create(const char* nettype, const char* addrtype, const char* addr)
-{
- return tsk_object_new(TSDP_HEADER_C_VA_ARGS(nettype, addrtype, addr));
-}
-
-tsdp_header_C_t* tsdp_header_c_create_null()
-{
- return tsdp_header_c_create(tsk_null, tsk_null, tsk_null);
-}
-
-int tsdp_header_C_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header){
- const tsdp_header_C_t *C = (const tsdp_header_C_t *)header;
-
- return tsk_buffer_append_2(output, "%s %s %s",
- C->nettype,
- C->addrtype,
- C->addr
- );
-
- return 0;
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_C_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_C_t *C = (const tsdp_header_C_t *)header;
- return (tsdp_header_t*)tsdp_header_c_create(C->nettype, C->addrtype, C->addr);
- }
- return tsk_null;
-}
-
-tsdp_header_C_t *tsdp_header_C_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_C_t *hdr_C = tsdp_header_c_create_null();
-
- const char *tag_start;
-
-
-/* #line 97 "./src/headers/tsdp_header_C.c" */
-static const char _tsdp_machine_parser_header_C_actions[] = {
- 0, 1, 0, 1, 1, 1, 2, 1,
- 3, 2, 0, 2, 2, 0, 3
-};
-
-static const char _tsdp_machine_parser_header_C_key_offsets[] = {
- 0, 0, 1, 3, 4, 5, 6, 7,
- 8, 9, 10
-};
-
-static const char _tsdp_machine_parser_header_C_trans_keys[] = {
- 99, 32, 61, 32, 32, 32, 32, 10,
- 13, 13, 0
-};
-
-static const char _tsdp_machine_parser_header_C_single_lengths[] = {
- 0, 1, 2, 1, 1, 1, 1, 1,
- 1, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_C_range_lengths[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_C_index_offsets[] = {
- 0, 0, 2, 5, 7, 9, 11, 13,
- 15, 17, 19
-};
-
-static const char _tsdp_machine_parser_header_C_trans_targs[] = {
- 2, 0, 2, 3, 0, 3, 4, 5,
- 4, 8, 6, 8, 6, 10, 0, 7,
- 9, 7, 9, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_C_trans_actions[] = {
- 0, 0, 0, 0, 0, 0, 1, 3,
- 0, 9, 1, 5, 0, 0, 0, 12,
- 1, 7, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_C_eof_actions[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 12, 7, 0
-};
-
-static const int tsdp_machine_parser_header_C_start = 1;
-static const int tsdp_machine_parser_header_C_first_final = 8;
-static const int tsdp_machine_parser_header_C_error = 0;
-
-static const int tsdp_machine_parser_header_C_en_main = 1;
-
-
-/* #line 122 "./ragel/tsdp_parser_header_C.rl" */
-
-/* #line 154 "./src/headers/tsdp_header_C.c" */
- {
- cs = tsdp_machine_parser_header_C_start;
- }
-
-/* #line 123 "./ragel/tsdp_parser_header_C.rl" */
-
-/* #line 161 "./src/headers/tsdp_header_C.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_C_trans_keys + _tsdp_machine_parser_header_C_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_C_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_C_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_C_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- cs = _tsdp_machine_parser_header_C_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_C_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_C_actions + _tsdp_machine_parser_header_C_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_C.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_C.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_C->nettype);
- }
- break;
- case 2:
-/* #line 56 "./ragel/tsdp_parser_header_C.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_C->addrtype);
- }
- break;
- case 3:
-/* #line 60 "./ragel/tsdp_parser_header_C.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_C->addr);
- }
- break;
-/* #line 258 "./src/headers/tsdp_header_C.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_C_actions + _tsdp_machine_parser_header_C_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_C.rl" */
- {
- tag_start = p;
- }
- break;
- case 3:
-/* #line 60 "./ragel/tsdp_parser_header_C.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_C->addr);
- }
- break;
-/* #line 286 "./src/headers/tsdp_header_C.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 124 "./ragel/tsdp_parser_header_C.rl" */
-
- if( cs <
-/* #line 297 "./src/headers/tsdp_header_C.c" */
-8
-/* #line 125 "./ragel/tsdp_parser_header_C.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"c=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_C);
- }
-
- return hdr_C;
-}
-
-
-
-
-
-
-
-//========================================================
-// E header object definition
-//
-
-static tsk_object_t* tsdp_header_C_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_C_t *C = self;
- if(C){
- TSDP_HEADER(C)->type = tsdp_htype_C;
- TSDP_HEADER(C)->tostring = tsdp_header_C_tostring;
- TSDP_HEADER(C)->clone = tsdp_header_C_clone;
- TSDP_HEADER(C)->rank = TSDP_HTYPE_C_RANK;
-
- C->nettype = tsk_strdup(va_arg(*app, const char*));
- C->addrtype = tsk_strdup(va_arg(*app, const char*));
- C->addr = tsk_strdup(va_arg(*app, const char*));
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new C header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_C_dtor(tsk_object_t *self)
-{
- tsdp_header_C_t *C = self;
- if(C){
- TSK_FREE(C->nettype);
- TSK_FREE(C->addrtype);
- TSK_FREE(C->addr);
- }
- else{
- TSK_DEBUG_ERROR("Null PC header.");
- }
-
- return self;
-}
-static int tsdp_header_C_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_C_def_s =
-{
- sizeof(tsdp_header_C_t),
- tsdp_header_C_ctor,
- tsdp_header_C_dtor,
- tsdp_header_C_cmp
-};
-
-const tsk_object_def_t *tsdp_header_C_def_t = &tsdp_header_C_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_Dummy.c b/branches/1.0/tinySDP/src/headers/tsdp_header_Dummy.c
deleted file mode 100644
index 9e46e7b..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_Dummy.c
+++ /dev/null
@@ -1,354 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_Dummy.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-/**@file tsdp_header_Dummy.c
- * @brief SDP Dummy header.
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Sat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_Dummy.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 64 "./ragel/tsdp_parser_header_Dummy.rl" */
-
-
-
-
-tsdp_header_Dummy_t* tsdp_header_dummy_create(char name, const char* value)
-{
- return tsk_object_new(TSDP_HEADER_DUMMY_VA_ARGS(name, value));
-}
-
-tsdp_header_Dummy_t* tsdp_header_dummy_create_null()
-{
- return tsdp_header_dummy_create(0, tsk_null);
-}
-
-int tsdp_header_Dummy_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header)
- {
- const tsdp_header_Dummy_t *Dummy = (const tsdp_header_Dummy_t *)header;
- if(Dummy->value){
- return tsk_buffer_append(output, Dummy->value, tsk_strlen(Dummy->value));
- }
- return 0;
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_Dummy_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_Dummy_t *Dummy = (const tsdp_header_Dummy_t *)header;
- return (tsdp_header_t*)tsdp_header_dummy_create(Dummy->name, Dummy->value);
- }
- return tsk_null;
-}
-
-tsdp_header_Dummy_t *tsdp_header_Dummy_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_Dummy_t *hdr_Dummy = tsdp_header_dummy_create_null();
-
- const char *tag_start;
-
-
-/* #line 94 "./src/headers/tsdp_header_Dummy.c" */
-static const char _tsdp_machine_parser_header_Dummy_actions[] = {
- 0, 1, 0, 1, 1, 1, 2, 2,
- 0, 2
-};
-
-static const char _tsdp_machine_parser_header_Dummy_key_offsets[] = {
- 0, 0, 4, 6, 8, 9, 11, 12
-};
-
-static const char _tsdp_machine_parser_header_Dummy_trans_keys[] = {
- 65, 90, 97, 122, 32, 61, 32, 61,
- 10, 13, 32, 13, 0
-};
-
-static const char _tsdp_machine_parser_header_Dummy_single_lengths[] = {
- 0, 0, 2, 2, 1, 2, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_Dummy_range_lengths[] = {
- 0, 2, 0, 0, 0, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_Dummy_index_offsets[] = {
- 0, 0, 3, 6, 9, 11, 14, 16
-};
-
-static const char _tsdp_machine_parser_header_Dummy_trans_targs[] = {
- 2, 2, 0, 3, 5, 0, 3, 5,
- 0, 7, 0, 4, 5, 6, 4, 6,
- 0, 0
-};
-
-static const char _tsdp_machine_parser_header_Dummy_trans_actions[] = {
- 1, 1, 0, 3, 3, 0, 0, 0,
- 0, 0, 0, 7, 0, 1, 5, 0,
- 0, 0
-};
-
-static const char _tsdp_machine_parser_header_Dummy_eof_actions[] = {
- 0, 0, 0, 0, 0, 7, 5, 0
-};
-
-static const int tsdp_machine_parser_header_Dummy_start = 1;
-static const int tsdp_machine_parser_header_Dummy_first_final = 5;
-static const int tsdp_machine_parser_header_Dummy_error = 0;
-
-static const int tsdp_machine_parser_header_Dummy_en_main = 1;
-
-
-/* #line 112 "./ragel/tsdp_parser_header_Dummy.rl" */
-
-/* #line 146 "./src/headers/tsdp_header_Dummy.c" */
- {
- cs = tsdp_machine_parser_header_Dummy_start;
- }
-
-/* #line 113 "./ragel/tsdp_parser_header_Dummy.rl" */
-
-/* #line 153 "./src/headers/tsdp_header_Dummy.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_Dummy_trans_keys + _tsdp_machine_parser_header_Dummy_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_Dummy_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_Dummy_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_Dummy_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- cs = _tsdp_machine_parser_header_Dummy_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_Dummy_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_Dummy_actions + _tsdp_machine_parser_header_Dummy_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 47 "./ragel/tsdp_parser_header_Dummy.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 51 "./ragel/tsdp_parser_header_Dummy.rl" */
- {
- hdr_Dummy->name = *tag_start;
- }
- break;
- case 2:
-/* #line 55 "./ragel/tsdp_parser_header_Dummy.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_Dummy->value);
- }
- break;
-/* #line 244 "./src/headers/tsdp_header_Dummy.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_Dummy_actions + _tsdp_machine_parser_header_Dummy_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 0:
-/* #line 47 "./ragel/tsdp_parser_header_Dummy.rl" */
- {
- tag_start = p;
- }
- break;
- case 2:
-/* #line 55 "./ragel/tsdp_parser_header_Dummy.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_Dummy->value);
- }
- break;
-/* #line 272 "./src/headers/tsdp_header_Dummy.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 114 "./ragel/tsdp_parser_header_Dummy.rl" */
-
- if( cs <
-/* #line 283 "./src/headers/tsdp_header_Dummy.c" */
-5
-/* #line 115 "./ragel/tsdp_parser_header_Dummy.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse dummy header.");
- TSK_OBJECT_SAFE_FREE(hdr_Dummy);
- }
-
- return hdr_Dummy;
-}
-
-
-
-
-
-
-
-//========================================================
-// Dummy header object definition
-//
-
-static tsk_object_t* tsdp_header_Dummy_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_Dummy_t *Dummy = self;
- if(Dummy){
- TSDP_HEADER(Dummy)->type = tsdp_htype_Dummy;
- TSDP_HEADER(Dummy)->tostring = tsdp_header_Dummy_tostring;
- TSDP_HEADER(Dummy)->clone = tsdp_header_Dummy_clone;
- TSDP_HEADER(Dummy)->rank = TSDP_HTYPE_DUMMY_RANK;
-#if defined(__GNUC__)
- Dummy->name = va_arg(*app, const int);
-#else
- Dummy->name = va_arg(*app, const char);
-#endif
- Dummy->value = tsk_strdup(va_arg(*app, const char*));
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new Dummy header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_Dummy_dtor(tsk_object_t *self)
-{
- tsdp_header_Dummy_t *Dummy = self;
- if(Dummy){
- TSK_FREE(Dummy->value);
- }
- else{
- TSK_DEBUG_ERROR("Null Dummy header.");
- }
-
- return self;
-}
-static int tsdp_header_Dummy_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_Dummy_def_s =
-{
- sizeof(tsdp_header_Dummy_t),
- tsdp_header_Dummy_ctor,
- tsdp_header_Dummy_dtor,
- tsdp_header_Dummy_cmp
-};
-
-const tsk_object_def_t *tsdp_header_Dummy_def_t = &tsdp_header_Dummy_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_E.c b/branches/1.0/tinySDP/src/headers/tsdp_header_E.c
deleted file mode 100644
index a0ef6f5..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_E.c
+++ /dev/null
@@ -1,341 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_E.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-
-/**@file tsdp_header_E.c
- * @brief SDP "e=" header (Session Information).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Iat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_E.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 61 "./ragel/tsdp_parser_header_E.rl" */
-
-
-
-
-tsdp_header_E_t* tsdp_header_E_create(const char* value)
-{
- return tsk_object_new(TSDP_HEADER_E_VA_ARGS(value));
-}
-
-tsdp_header_E_t* tsdp_header_E_create_null()
-{
- return tsdp_header_E_create(tsk_null);
-}
-
-int tsdp_header_E_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header){
- const tsdp_header_E_t *E = (const tsdp_header_E_t *)header;
- if(E->value){
- tsk_buffer_append(output, E->value, tsk_strlen(E->value));
- }
- return 0;
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_E_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_E_t *E = (const tsdp_header_E_t *)header;
- return (tsdp_header_t*)tsdp_header_E_create(E->value);
- }
- return tsk_null;
-}
-
-tsdp_header_E_t *tsdp_header_E_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_E_t *hdr_E = tsdp_header_E_create_null();
-
- const char *tag_start;
-
-
-/* #line 94 "./src/headers/tsdp_header_E.c" */
-static const char _tsdp_machine_parser_header_E_actions[] = {
- 0, 1, 0, 1, 1, 2, 0, 1
-
-};
-
-static const char _tsdp_machine_parser_header_E_key_offsets[] = {
- 0, 0, 1, 3, 4, 6, 7
-};
-
-static const char _tsdp_machine_parser_header_E_trans_keys[] = {
- 101, 32, 61, 10, 13, 32, 13, 0
-};
-
-static const char _tsdp_machine_parser_header_E_single_lengths[] = {
- 0, 1, 2, 1, 2, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_E_range_lengths[] = {
- 0, 0, 0, 0, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_E_index_offsets[] = {
- 0, 0, 2, 5, 7, 10, 12
-};
-
-static const char _tsdp_machine_parser_header_E_trans_targs[] = {
- 2, 0, 2, 4, 0, 6, 0, 3,
- 4, 5, 3, 5, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_E_trans_actions[] = {
- 0, 0, 0, 0, 0, 0, 0, 5,
- 0, 1, 3, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_E_eof_actions[] = {
- 0, 0, 0, 0, 5, 3, 0
-};
-
-static const int tsdp_machine_parser_header_E_start = 1;
-static const int tsdp_machine_parser_header_E_first_final = 4;
-static const int tsdp_machine_parser_header_E_error = 0;
-
-static const int tsdp_machine_parser_header_E_en_main = 1;
-
-
-/* #line 108 "./ragel/tsdp_parser_header_E.rl" */
-
-/* #line 143 "./src/headers/tsdp_header_E.c" */
- {
- cs = tsdp_machine_parser_header_E_start;
- }
-
-/* #line 109 "./ragel/tsdp_parser_header_E.rl" */
-
-/* #line 150 "./src/headers/tsdp_header_E.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_E_trans_keys + _tsdp_machine_parser_header_E_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_E_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_E_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_E_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- cs = _tsdp_machine_parser_header_E_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_E_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_E_actions + _tsdp_machine_parser_header_E_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_E.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_E.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_E->value);
- }
- break;
-/* #line 235 "./src/headers/tsdp_header_E.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_E_actions + _tsdp_machine_parser_header_E_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_E.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_E.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_E->value);
- }
- break;
-/* #line 263 "./src/headers/tsdp_header_E.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 110 "./ragel/tsdp_parser_header_E.rl" */
-
- if( cs <
-/* #line 274 "./src/headers/tsdp_header_E.c" */
-4
-/* #line 111 "./ragel/tsdp_parser_header_E.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"e=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_E);
- }
-
- return hdr_E;
-}
-
-
-
-
-
-
-
-//========================================================
-// E header object definition
-//
-
-static tsk_object_t* tsdp_header_E_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_E_t *E = self;
- if(E){
- TSDP_HEADER(E)->type = tsdp_htype_E;
- TSDP_HEADER(E)->tostring = tsdp_header_E_tostring;
- TSDP_HEADER(E)->clone = tsdp_header_E_clone;
- TSDP_HEADER(E)->rank = TSDP_HTYPE_E_RANK;
-
- E->value = tsk_strdup(va_arg(*app, const char*));
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new E header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_E_dtor(tsk_object_t *self)
-{
- tsdp_header_E_t *E = self;
- if(E){
- TSK_FREE(E->value);
- }
- else{
- TSK_DEBUG_ERROR("Null E header.");
- }
-
- return self;
-}
-static int tsdp_header_E_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_E_def_s =
-{
- sizeof(tsdp_header_E_t),
- tsdp_header_E_ctor,
- tsdp_header_E_dtor,
- tsdp_header_E_cmp
-};
-
-const tsk_object_def_t *tsdp_header_E_def_t = &tsdp_header_E_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_I.c b/branches/1.0/tinySDP/src/headers/tsdp_header_I.c
deleted file mode 100644
index 0c2be11..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_I.c
+++ /dev/null
@@ -1,342 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_I.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-
-/**@file tsdp_header_I.c
- * @brief SDP "i=" header (Session Information).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Iat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_I.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 61 "./ragel/tsdp_parser_header_I.rl" */
-
-
-
-tsdp_header_I_t* tsdp_header_I_create(const char* value)
-{
- return tsk_object_new(TSDP_HEADER_I_VA_ARGS(value));
-}
-
-tsdp_header_I_t* tsdp_header_I_create_null()
-{
- return tsdp_header_I_create(tsk_null);
-}
-
-int tsdp_header_I_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header)
- {
- const tsdp_header_I_t *I = (const tsdp_header_I_t *)header;
- if(I->value){
- tsk_buffer_append(output, I->value, tsk_strlen(I->value));
- }
- return 0;
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_I_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_I_t *I = (const tsdp_header_I_t *)header;
- return (tsdp_header_t*)tsdp_header_I_create(I->value);
- }
- return tsk_null;
-}
-
-tsdp_header_I_t *tsdp_header_I_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_I_t *hdr_I = tsdp_header_I_create_null();
-
- const char *tag_start;
-
-
-/* #line 94 "./src/headers/tsdp_header_I.c" */
-static const char _tsdp_machine_parser_header_I_actions[] = {
- 0, 1, 0, 1, 1, 2, 0, 1
-
-};
-
-static const char _tsdp_machine_parser_header_I_key_offsets[] = {
- 0, 0, 1, 3, 4, 6, 7
-};
-
-static const char _tsdp_machine_parser_header_I_trans_keys[] = {
- 105, 32, 61, 10, 13, 32, 13, 0
-};
-
-static const char _tsdp_machine_parser_header_I_single_lengths[] = {
- 0, 1, 2, 1, 2, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_I_range_lengths[] = {
- 0, 0, 0, 0, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_I_index_offsets[] = {
- 0, 0, 2, 5, 7, 10, 12
-};
-
-static const char _tsdp_machine_parser_header_I_trans_targs[] = {
- 2, 0, 2, 4, 0, 6, 0, 3,
- 4, 5, 3, 5, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_I_trans_actions[] = {
- 0, 0, 0, 0, 0, 0, 0, 5,
- 0, 1, 3, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_I_eof_actions[] = {
- 0, 0, 0, 0, 5, 3, 0
-};
-
-static const int tsdp_machine_parser_header_I_start = 1;
-static const int tsdp_machine_parser_header_I_first_final = 4;
-static const int tsdp_machine_parser_header_I_error = 0;
-
-static const int tsdp_machine_parser_header_I_en_main = 1;
-
-
-/* #line 108 "./ragel/tsdp_parser_header_I.rl" */
-
-/* #line 143 "./src/headers/tsdp_header_I.c" */
- {
- cs = tsdp_machine_parser_header_I_start;
- }
-
-/* #line 109 "./ragel/tsdp_parser_header_I.rl" */
-
-/* #line 150 "./src/headers/tsdp_header_I.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_I_trans_keys + _tsdp_machine_parser_header_I_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_I_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_I_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_I_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- cs = _tsdp_machine_parser_header_I_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_I_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_I_actions + _tsdp_machine_parser_header_I_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_I.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_I.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_I->value);
- }
- break;
-/* #line 235 "./src/headers/tsdp_header_I.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_I_actions + _tsdp_machine_parser_header_I_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_I.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_I.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_I->value);
- }
- break;
-/* #line 263 "./src/headers/tsdp_header_I.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 110 "./ragel/tsdp_parser_header_I.rl" */
-
- if( cs <
-/* #line 274 "./src/headers/tsdp_header_I.c" */
-4
-/* #line 111 "./ragel/tsdp_parser_header_I.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"i=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_I);
- }
-
- return hdr_I;
-}
-
-
-
-
-
-
-
-//========================================================
-// I header object definition
-//
-
-static tsk_object_t* tsdp_header_I_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_I_t *I = self;
- if(I)
- {
- TSDP_HEADER(I)->type = tsdp_htype_I;
- TSDP_HEADER(I)->tostring = tsdp_header_I_tostring;
- TSDP_HEADER(I)->clone = tsdp_header_I_clone;
- TSDP_HEADER(I)->rank = TSDP_HTYPE_I_RANK;
-
- I->value = tsk_strdup(va_arg(*app, const char*));
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new I header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_I_dtor(tsk_object_t *self)
-{
- tsdp_header_I_t *I = self;
- if(I){
- TSK_FREE(I->value);
- }
- else{
- TSK_DEBUG_ERROR("Null I header.");
- }
-
- return self;
-}
-static int tsdp_header_I_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_I_def_s =
-{
- sizeof(tsdp_header_I_t),
- tsdp_header_I_ctor,
- tsdp_header_I_dtor,
- tsdp_header_I_cmp
-};
-
-const tsk_object_def_t *tsdp_header_I_def_t = &tsdp_header_I_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_K.c b/branches/1.0/tinySDP/src/headers/tsdp_header_K.c
deleted file mode 100644
index d1476c2..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_K.c
+++ /dev/null
@@ -1,341 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_K.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-
-/**@file tsdp_header_K.c
- * @brief SDP "k=" header (Encryption Key).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Iat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_K.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 61 "./ragel/tsdp_parser_header_K.rl" */
-
-
-
-
-tsdp_header_K_t* tsdp_header_K_create(const char* value)
-{
- return tsk_object_new(TSDP_HEADER_K_VA_ARGS(value));
-}
-
-tsdp_header_K_t* tsdp_header_K_create_null()
-{
- return tsdp_header_K_create(tsk_null);
-}
-
-int tsdp_header_K_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header){
- const tsdp_header_K_t *K = (const tsdp_header_K_t *)header;
- if(K->value){
- tsk_buffer_append(output, K->value, tsk_strlen(K->value));
- }
- return 0;
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_K_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_K_t *K = (const tsdp_header_K_t *)header;
- return (tsdp_header_t*)tsdp_header_K_create(K->value);
- }
- return tsk_null;
-}
-
-tsdp_header_K_t *tsdp_header_K_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_K_t *hdr_K = tsdp_header_K_create_null();
-
- const char *tag_start;
-
-
-/* #line 94 "./src/headers/tsdp_header_K.c" */
-static const char _tsdp_machine_parser_header_K_actions[] = {
- 0, 1, 0, 1, 1, 2, 0, 1
-
-};
-
-static const char _tsdp_machine_parser_header_K_key_offsets[] = {
- 0, 0, 1, 3, 4, 6, 7
-};
-
-static const char _tsdp_machine_parser_header_K_trans_keys[] = {
- 107, 32, 61, 10, 13, 32, 13, 0
-};
-
-static const char _tsdp_machine_parser_header_K_single_lengths[] = {
- 0, 1, 2, 1, 2, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_K_range_lengths[] = {
- 0, 0, 0, 0, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_K_index_offsets[] = {
- 0, 0, 2, 5, 7, 10, 12
-};
-
-static const char _tsdp_machine_parser_header_K_trans_targs[] = {
- 2, 0, 2, 4, 0, 6, 0, 3,
- 4, 5, 3, 5, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_K_trans_actions[] = {
- 0, 0, 0, 0, 0, 0, 0, 5,
- 0, 1, 3, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_K_eof_actions[] = {
- 0, 0, 0, 0, 5, 3, 0
-};
-
-static const int tsdp_machine_parser_header_K_start = 1;
-static const int tsdp_machine_parser_header_K_first_final = 4;
-static const int tsdp_machine_parser_header_K_error = 0;
-
-static const int tsdp_machine_parser_header_K_en_main = 1;
-
-
-/* #line 108 "./ragel/tsdp_parser_header_K.rl" */
-
-/* #line 143 "./src/headers/tsdp_header_K.c" */
- {
- cs = tsdp_machine_parser_header_K_start;
- }
-
-/* #line 109 "./ragel/tsdp_parser_header_K.rl" */
-
-/* #line 150 "./src/headers/tsdp_header_K.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_K_trans_keys + _tsdp_machine_parser_header_K_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_K_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_K_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_K_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- cs = _tsdp_machine_parser_header_K_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_K_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_K_actions + _tsdp_machine_parser_header_K_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_K.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_K.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_K->value);
- }
- break;
-/* #line 235 "./src/headers/tsdp_header_K.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_K_actions + _tsdp_machine_parser_header_K_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_K.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_K.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_K->value);
- }
- break;
-/* #line 263 "./src/headers/tsdp_header_K.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 110 "./ragel/tsdp_parser_header_K.rl" */
-
- if( cs <
-/* #line 274 "./src/headers/tsdp_header_K.c" */
-4
-/* #line 111 "./ragel/tsdp_parser_header_K.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"k=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_K);
- }
-
- return hdr_K;
-}
-
-
-
-
-
-
-
-//========================================================
-// K header object definition
-//
-
-static tsk_object_t* tsdp_header_K_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_K_t *K = self;
- if(K){
- TSDP_HEADER(K)->type = tsdp_htype_K;
- TSDP_HEADER(K)->tostring = tsdp_header_K_tostring;
- TSDP_HEADER(K)->clone = tsdp_header_K_clone;
- TSDP_HEADER(K)->rank = TSDP_HTYPE_P_RANK;
-
- K->value = tsk_strdup(va_arg(*app, const char*));
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new K header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_K_dtor(tsk_object_t *self)
-{
- tsdp_header_K_t *K = self;
- if(K){
- TSK_FREE(K->value);
- }
- else{
- TSK_DEBUG_ERROR("Null K header.");
- }
-
- return self;
-}
-static int tsdp_header_K_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_K_def_s =
-{
- sizeof(tsdp_header_K_t),
- tsdp_header_K_ctor,
- tsdp_header_K_dtor,
- tsdp_header_K_cmp
-};
-
-const tsk_object_def_t *tsdp_header_K_def_t = &tsdp_header_K_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_M.c b/branches/1.0/tinySDP/src/headers/tsdp_header_M.c
deleted file mode 100644
index 74ea1dd..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_M.c
+++ /dev/null
@@ -1,811 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_M.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-
-/**@file tsdp_header_M.c
- * @brief SDP "m=" header (Media Descriptions).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Iat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_M.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 83 "./ragel/tsdp_parser_header_M.rl" */
-
-
-
-
-tsdp_header_M_t* tsdp_header_M_create(const char* media, uint32_t port, const char* proto)
-{
- return tsk_object_new(TSDP_HEADER_M_VA_ARGS(media, port, proto));
-}
-
-tsdp_header_M_t* tsdp_header_M_create_null()
-{
- return tsdp_header_M_create(tsk_null, 0, tsk_null);
-}
-
-tsdp_fmt_t* tsdp_fmt_create(const char* fmt)
-{
- return tsk_object_new(TSDP_FMT_VA_ARGS(fmt));
-}
-
-
-int tsdp_header_M_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header){
- const tsdp_header_M_t *M = (const tsdp_header_M_t *)header;
- const tsk_list_item_t* item;
- tsk_istr_t nports;
-
- tsk_itoa(M->nports, &nports);
-
- /* IMPORTANT: Keep the order.
-
- m= (media name and transport address)
- i=* (media title)
- c=* (connection information -- optional if included at
- session level)
- b=* (zero or more bandwidth information lines)
- k=* (encryption key)
- a=* (zero or more media attribute lines)
- */
- tsk_buffer_append_2(output, "%s %u%s%s %s",
- M->media,
- M->port,
-
- M->nports ? "/" : "",
- M->nports ? nports : "",
-
- M->proto
- );
- // FMTs
- tsk_list_foreach(item, M->FMTs){
- tsk_buffer_append_2(output, " %s", TSDP_FMT_STR(item->data));
- }
- tsk_buffer_append(output, "\r\n", 2); // close the "m=" line.
- // i=* (media title)
- if(M->I){
- tsdp_header_serialize(TSDP_HEADER(M->I), output);
- }
- // c=* (connection information -- optional if included at session level)
- if(M->C){
- tsdp_header_serialize(TSDP_HEADER(M->C), output);
- }
- // b=* (zero or more bandwidth information lines)
- if(M->Bandwidths){
- tsk_list_foreach(item, M->Bandwidths){
- tsdp_header_serialize(TSDP_HEADER(item->data), output);
- }
- }
- // k=* (encryption key)
- if(M->K){
- tsdp_header_serialize(TSDP_HEADER(M->K), output);
- }
- // a=* (zero or more media attribute lines)
- if(M->Attributes){
- tsk_list_foreach(item, M->Attributes){
- tsdp_header_serialize(TSDP_HEADER(item->data), output);
- }
- }
- return 0;
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_M_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_M_t *M = (const tsdp_header_M_t *)header;
- tsdp_header_M_t* clone;
- const tsk_list_item_t* item;
-
- if((clone = tsdp_header_M_create(M->media, M->port, M->proto))){
- clone->nports = M->nports;
-
- // Formats
- tsk_list_foreach(item, M->FMTs){
- tsk_string_t* string = tsk_string_create(TSK_STRING_STR(item->data));
- tsk_list_push_back_data(clone->FMTs, (void**)&string);
- }
-
- // I
- clone->I = (tsdp_header_I_t*) (M->I ? TSDP_HEADER(M->I)->clone(TSDP_HEADER(M->I)) : tsk_null);
- // C
- clone->C = (tsdp_header_C_t*) (M->C ? TSDP_HEADER(M->C)->clone(TSDP_HEADER(M->C)) : tsk_null);
- // Bandwidths
- tsk_list_foreach(item, M->Bandwidths){
- tsdp_header_t* B;
- if(!clone->Bandwidths){
- clone->Bandwidths = tsk_list_create();
- }
- B = ((tsdp_header_t*)item->data)->clone((tsdp_header_t*)item->data);
- tsk_list_push_back_data(clone->Bandwidths, (void**)&B);
- }
- // K
- clone->K = (tsdp_header_K_t*) (M->K ? TSDP_HEADER(M->K)->clone(TSDP_HEADER(M->K)) : tsk_null);
- // Attributes
- tsk_list_foreach(item, M->Attributes){
- tsdp_header_t* A;
- if(!clone->Attributes){
- clone->Attributes = tsk_list_create();
- }
- A = ((tsdp_header_t*)item->data)->clone((tsdp_header_t*)item->data);
- tsk_list_push_back_data(clone->Attributes, (void**)&A);
- }
- }
-
- return TSDP_HEADER(clone);
- }
- return tsk_null;
-}
-
-tsdp_header_M_t *tsdp_header_M_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_M_t *hdr_M = tsdp_header_M_create_null();
-
- const char *tag_start;
-
-
-/* #line 188 "./src/headers/tsdp_header_M.c" */
-static const char _tsdp_machine_parser_header_M_actions[] = {
- 0, 1, 0, 1, 1, 1, 2, 1,
- 3, 1, 4
-};
-
-static const char _tsdp_machine_parser_header_M_key_offsets[] = {
- 0, 0, 1, 3, 18, 33, 35, 39,
- 53, 54, 68, 82, 84, 87, 102, 102
-};
-
-static const char _tsdp_machine_parser_header_M_trans_keys[] = {
- 109, 32, 61, 32, 33, 37, 39, 126,
- 42, 43, 45, 46, 48, 57, 65, 90,
- 95, 122, 32, 33, 37, 39, 126, 42,
- 43, 45, 46, 48, 57, 65, 90, 95,
- 122, 48, 57, 32, 47, 48, 57, 33,
- 37, 39, 126, 42, 43, 45, 46, 48,
- 57, 65, 90, 95, 122, 10, 33, 37,
- 39, 126, 42, 43, 45, 46, 48, 57,
- 65, 90, 95, 122, 33, 37, 39, 126,
- 42, 43, 45, 46, 48, 57, 65, 90,
- 95, 122, 48, 57, 32, 48, 57, 13,
- 32, 33, 37, 39, 47, 126, 42, 43,
- 45, 57, 65, 90, 95, 122, 13, 32,
- 33, 37, 39, 126, 42, 43, 45, 46,
- 48, 57, 65, 90, 95, 122, 0
-};
-
-static const char _tsdp_machine_parser_header_M_single_lengths[] = {
- 0, 1, 2, 5, 5, 0, 2, 4,
- 1, 4, 4, 0, 1, 7, 0, 6
-};
-
-static const char _tsdp_machine_parser_header_M_range_lengths[] = {
- 0, 0, 0, 5, 5, 1, 1, 5,
- 0, 5, 5, 1, 1, 4, 0, 5
-};
-
-static const char _tsdp_machine_parser_header_M_index_offsets[] = {
- 0, 0, 2, 5, 16, 27, 29, 33,
- 43, 45, 55, 65, 67, 70, 82, 83
-};
-
-static const char _tsdp_machine_parser_header_M_indicies[] = {
- 0, 1, 0, 2, 1, 2, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 1,
- 4, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 1, 6, 1, 7, 8, 9,
- 1, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 1, 11, 1, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 1, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 1, 14, 1, 7, 15, 1, 16, 17,
- 13, 13, 13, 18, 13, 13, 13, 13,
- 13, 1, 1, 19, 20, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_M_trans_targs[] = {
- 2, 0, 3, 4, 5, 4, 6, 7,
- 11, 6, 13, 14, 15, 13, 12, 12,
- 8, 9, 10, 8, 9, 15
-};
-
-static const char _tsdp_machine_parser_header_M_trans_actions[] = {
- 0, 0, 0, 1, 3, 0, 1, 5,
- 5, 0, 1, 0, 1, 0, 1, 0,
- 7, 7, 0, 9, 9, 0
-};
-
-static const char _tsdp_machine_parser_header_M_eof_actions[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 7, 0, 9
-};
-
-static const int tsdp_machine_parser_header_M_start = 1;
-static const int tsdp_machine_parser_header_M_first_final = 13;
-static const int tsdp_machine_parser_header_M_error = 0;
-
-static const int tsdp_machine_parser_header_M_en_main = 1;
-
-
-/* #line 224 "./ragel/tsdp_parser_header_M.rl" */
-
-/* #line 273 "./src/headers/tsdp_header_M.c" */
- {
- cs = tsdp_machine_parser_header_M_start;
- }
-
-/* #line 225 "./ragel/tsdp_parser_header_M.rl" */
-
-/* #line 280 "./src/headers/tsdp_header_M.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_M_trans_keys + _tsdp_machine_parser_header_M_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_M_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_M_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_M_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- _trans = _tsdp_machine_parser_header_M_indicies[_trans];
- cs = _tsdp_machine_parser_header_M_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_M_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_M_actions + _tsdp_machine_parser_header_M_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_M.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_M.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_M->media);
- }
- break;
- case 2:
-/* #line 56 "./ragel/tsdp_parser_header_M.rl" */
- {
- TSK_PARSER_SET_UINT(hdr_M->port);
- }
- break;
- case 3:
-/* #line 64 "./ragel/tsdp_parser_header_M.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_M->proto);
- }
- break;
- case 4:
-/* #line 68 "./ragel/tsdp_parser_header_M.rl" */
- {
- TSK_PARSER_ADD_STRING(hdr_M->FMTs);
- }
- break;
-/* #line 384 "./src/headers/tsdp_header_M.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_M_actions + _tsdp_machine_parser_header_M_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 3:
-/* #line 64 "./ragel/tsdp_parser_header_M.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_M->proto);
- }
- break;
- case 4:
-/* #line 68 "./ragel/tsdp_parser_header_M.rl" */
- {
- TSK_PARSER_ADD_STRING(hdr_M->FMTs);
- }
- break;
-/* #line 412 "./src/headers/tsdp_header_M.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 226 "./ragel/tsdp_parser_header_M.rl" */
-
- if( cs <
-/* #line 423 "./src/headers/tsdp_header_M.c" */
-13
-/* #line 227 "./ragel/tsdp_parser_header_M.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"m=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_M);
- }
-
- return hdr_M;
-}
-
-
-
-int tsdp_header_M_add(tsdp_header_M_t* self, const tsdp_header_t* header)
-{
- if(!self || !header){
- return -1;
- }
-
- switch(header->type){
- case tsdp_htype_I:
- {
- TSK_OBJECT_SAFE_FREE(self->I);
- self->I = tsk_object_ref((void*)header);
- break;
- }
- case tsdp_htype_C:
- {
- TSK_OBJECT_SAFE_FREE(self->C);
- self->C = tsk_object_ref((void*)header);
- break;
- }
- case tsdp_htype_B:
- {
- tsdp_header_t* B = tsk_object_ref((void*)header);
- if(!self->Bandwidths){
- self->Bandwidths = tsk_list_create();
- }
- tsk_list_push_back_data(self->Bandwidths, (void**)&B);
- break;
- }
- case tsdp_htype_K:
- {
- TSK_OBJECT_SAFE_FREE(self->K);
- self->K = tsk_object_ref((void*)header);
- break;
- }
- case tsdp_htype_A:
- {
- tsdp_header_t* A = tsk_object_ref((void*)header);
- if(!self->Attributes){
- self->Attributes = tsk_list_create();
- }
- tsk_list_push_back_data(self->Attributes, (void**)&A);
- break;
- }
- }
-
- return 0;
-}
-
-int tsdp_header_M_add_headers(tsdp_header_M_t* self, ...)
-{
- const tsk_object_def_t* objdef;
- tsdp_header_t *header;
- tsdp_fmt_t* fmt;
- va_list ap;
-
- if(!self){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
-
- va_start(ap, self);
- while((objdef = va_arg(ap, const tsk_object_def_t*))){
- if(objdef == tsdp_fmt_def_t){
- if((fmt = tsk_object_new_2(objdef, &ap))){
- tsk_list_push_back_data(self->FMTs, (void**)&fmt);
- }
- }
- else{
- if((header = tsk_object_new_2(objdef, &ap))){
- tsdp_header_M_add(self, header);
- TSK_OBJECT_SAFE_FREE(header);
- }
- }
- }
- va_end(ap);
-
- return 0;
-}
-
-int tsdp_header_M_add_headers_2(tsdp_header_M_t* self, const tsdp_headers_L_t* headers)
-{
- const tsk_list_item_t* item;
-
- if(!self || !headers){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
-
- tsk_list_foreach(item, headers){
- tsdp_header_M_add(self, item->data);
- }
-
- return 0;
-}
-
-int tsdp_header_M_add_fmt(tsdp_header_M_t* self, const char* fmt)
-{
- tsdp_fmt_t* _fmt;
- if(!self){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
-
- if((_fmt = tsdp_fmt_create(fmt))){
- tsk_list_push_back_data(self->FMTs, (void**)&_fmt);
- return 0;
- }
- else{
- TSK_DEBUG_ERROR("Failed to create fmt object");
- return -2;
- }
-}
-
-const tsdp_header_A_t* tsdp_header_M_findA_at(const tsdp_header_M_t* self, const char* field, tsk_size_t index)
-{
- const tsk_list_item_t *item;
- tsk_size_t pos = 0;
- const tsdp_header_A_t* A;
-
- if(!self){
- TSK_DEBUG_ERROR("Invalid parameter");
- return tsk_null;
- }
-
- tsk_list_foreach(item, self->Attributes){
- if(!(A = item->data)){
- continue;
- }
-
- if(tsk_strequals(TSDP_HEADER_A(item->data)->field, field)){
- if(pos++ >= index){
- return A;
- }
- }
- }
-
- return tsk_null;
-}
-
-const tsdp_header_A_t* tsdp_header_M_findA(const tsdp_header_M_t* self, const char* field)
-{
- return tsdp_header_M_findA_at(self, field, 0);
-}
-
-char* tsdp_header_M_get_rtpmap(const tsdp_header_M_t* self, const char* fmt)
-{
- char *rtpmap = tsk_null; /* e.g. AMR-WB/16000 */
- tsk_size_t i = 0, fmt_len, A_len;
- int indexof;
- const tsdp_header_A_t* A;
-
- fmt_len = tsk_strlen(fmt);
- if(!self || !fmt_len || fmt_len > 3/*'0-255' or '*'*/){
- TSK_DEBUG_ERROR("Invalid parameter");
- return tsk_null;
- }
-
- /* find "a=rtpmap" */
- while((A = tsdp_header_M_findA_at(self, "rtpmap", i++))){
- /* A->value would be: "98 AMR-WB/16000" */
- if((A_len = tsk_strlen(A->value)) < (fmt_len + 1/*space*/)){
- continue;
- }
- if((indexof = tsk_strindexOf(A->value, A_len, fmt)) == 0 && (A->value[fmt_len] == ' ')){
- rtpmap = tsk_strndup(&A->value[fmt_len+1], (A_len-(fmt_len+1)));
- break;
- }
- }
- return rtpmap;
-}
-
-char* tsdp_header_M_get_fmtp(const tsdp_header_M_t* self, const char* fmt)
-{
- char *fmtp = tsk_null; /* e.g. octet-align=1 */
- tsk_size_t i = 0, fmt_len, A_len;
- int indexof;
- const tsdp_header_A_t* A;
-
- fmt_len = tsk_strlen(fmt);
- if(!self || !fmt_len || fmt_len > 3/*'0-255' or '*'*/){
- TSK_DEBUG_ERROR("Invalid parameter");
- return tsk_null;
- }
-
- /* find "a=fmtp" */
- while((A = tsdp_header_M_findA_at(self, "fmtp", i++))){
- /* A->value would be: "98 octet-align=1" */
- if((A_len = tsk_strlen(A->value)) < (fmt_len + 1/*space*/)){
- continue;
- }
- if((indexof = tsk_strindexOf(A->value, A_len, fmt)) == 0 && (A->value[fmt_len] == ' ')){
- fmtp = tsk_strndup(&A->value[fmt_len+1], (A_len-(fmt_len+1)));
- break;
- }
- }
- return fmtp;
-}
-
-/* as per 3GPP TS 34.610 */
-int tsdp_header_M_hold(tsdp_header_M_t* self, tsk_bool_t local)
-{
- const tsdp_header_A_t* a;
- if(!self){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
-
- if((a = tsdp_header_M_findA(self, local ? "recvonly" : "sendonly"))){
- // an "inactive" SDP attribute if the stream was previously set to "recvonly" media stream
- tsk_strupdate(&(TSDP_HEADER_A(a)->field), local ? "inactive" : "recvonly");
- }
- else if((a = tsdp_header_M_findA(self, "sendrecv"))){
- // a "sendonly" SDP attribute if the stream was previously set to "sendrecv" media stream
- tsk_strupdate(&(TSDP_HEADER_A(a)->field), local ? "sendonly" : "recvonly");
- }
- else{
- // default value is sendrecv. hold on default --> sendonly
- if(!(a = tsdp_header_M_findA(self, local ? "sendonly" : "recvonly")) && !(a = tsdp_header_M_findA(self, "inactive"))){
- tsdp_header_A_t* newA;
- if((newA = tsdp_header_A_create(local ? "sendonly" : "recvonly", tsk_null))){
- tsdp_header_M_add(self, TSDP_HEADER_CONST(newA));
- TSK_OBJECT_SAFE_FREE(newA);
- }
- }
- }
- return 0;
-}
-
-tsk_bool_t tsdp_header_M_is_held(const tsdp_header_M_t* self, tsk_bool_t local)
-{
- if(!self){
- TSK_DEBUG_ERROR("Invalid parameter");
- return tsk_false;
- }
-
- /* both cases */
- if(tsdp_header_M_findA(self, "inactive")){
- return tsk_true;
- }
-
- if(local){
- return tsdp_header_M_findA(self, "recvonly") ? tsk_true : tsk_false;
- }
- else{
- return tsdp_header_M_findA(self, "sendonly") ? tsk_true : tsk_false;
- }
-}
-
-/* as per 3GPP TS 34.610 */
-int tsdp_header_M_resume(tsdp_header_M_t* self, tsk_bool_t local)
-{
- const tsdp_header_A_t* a;
- if(!self){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
-
- if((a = tsdp_header_M_findA(self, "inactive"))){
- // a "recvonly" SDP attribute if the stream was previously an inactive media stream
- tsk_strupdate(&(TSDP_HEADER_A(a)->field), local ? "recvonly" : "sendonly");
- }
- else if((a = tsdp_header_M_findA(self, local ? "sendonly" : "recvonly"))){
- // a "sendrecv" SDP attribute if the stream was previously a sendonly media stream, or the attribute may be omitted, since sendrecv is the default
- tsk_strupdate(&(TSDP_HEADER_A(a)->field), "sendrecv");
- }
- return 0;
-}
-
-
-//
-//int tsdp_header_M_set(tsdp_header_M_t* self, ...)
-//{
-// int ret = -1;
-// va_list params;
-// int type;
-//
-// va_start(params, self);
-//
-// if(!m){
-// goto bail;
-// }
-//
-// while((type=va_arg(params, int))){
-// switch(type){
-// case 0x01: /* FMT */
-// {
-// tsk_string_t* fmt = tsk_string_create(va_arg(values, const char *));
-// if(fmt){
-// tsk_list_push_back_data(sefl->FMTs, (void**)&fmt);
-// }
-// break;
-// }
-// case 0x02: /* A */
-// {
-// tsdp_header_A_t* A = tsdp_header_A_create(va_arg(values, const char *), va_arg(values, const char *));
-// if(A){
-// if(!M->Attributes){
-// M->Attributes = tsk_list_create();
-// }
-// tsk_list_push_back_data(M->Attributes, (void**)&A);
-// }
-// break;
-// }
-// }
-// }
-//
-//bail:
-// va_end(params);
-// return ret;
-//}
-
-
-
-//========================================================
-// M header object definition
-//
-
-static tsk_object_t* tsdp_header_M_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_M_t *M = self;
- if(M){
- TSDP_HEADER(M)->type = tsdp_htype_M;
- TSDP_HEADER(M)->tostring = tsdp_header_M_tostring;
- TSDP_HEADER(M)->clone = tsdp_header_M_clone;
- TSDP_HEADER(M)->rank = TSDP_HTYPE_M_RANK;
-
- M->FMTs = tsk_list_create(); // Because there is at least one fmt.
-
- M->media = tsk_strdup(va_arg(*app, const char*));
- M->port = va_arg(*app, uint32_t);
- M->proto = tsk_strdup(va_arg(*app, const char*));
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new M header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_M_dtor(tsk_object_t *self)
-{
- tsdp_header_M_t *M = self;
- if(M){
- TSK_FREE(M->media);
- TSK_FREE(M->proto);
- TSK_OBJECT_SAFE_FREE(M->FMTs);
-
- TSK_OBJECT_SAFE_FREE(M->I);
- TSK_OBJECT_SAFE_FREE(M->C);
- TSK_OBJECT_SAFE_FREE(M->Bandwidths);
- TSK_OBJECT_SAFE_FREE(M->K);
- TSK_OBJECT_SAFE_FREE(M->Attributes);
- }
- else{
- TSK_DEBUG_ERROR("Null M header.");
- }
-
- return self;
-}
-static int tsdp_header_M_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_M_def_s =
-{
- sizeof(tsdp_header_M_t),
- tsdp_header_M_ctor,
- tsdp_header_M_dtor,
- tsdp_header_M_cmp
-};
-
-const tsk_object_def_t *tsdp_header_M_def_t = &tsdp_header_M_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_O.c b/branches/1.0/tinySDP/src/headers/tsdp_header_O.c
deleted file mode 100644
index 5d3edb8..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_O.c
+++ /dev/null
@@ -1,413 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_O.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-/**@file tsdp_header_O.c
- * @brief SDP "o=" header (Origin).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Uat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_O.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 86 "./ragel/tsdp_parser_header_O.rl" */
-
-
-
-
-
-tsdp_header_O_t* tsdp_header_O_create(const char* username, uint32_t sess_id, uint32_t sess_version, const char* nettype, const char* addrtype, const char* addr)
-{
- return tsk_object_new(TSDP_HEADER_O_VA_ARGS(username, sess_id, sess_version, nettype, addrtype, addr));
-}
-
-tsdp_header_O_t* tsdp_header_O_create_null()
-{
- return tsdp_header_O_create(tsk_null, 0, 0, tsk_null, tsk_null, tsk_null);
-}
-
-tsdp_header_O_t* tsdp_header_O_create_default(const char* username, const char* nettype, const char* addrtype, const char* addr)
-{
- return tsdp_header_O_create(username, TSDP_HEADER_O_SESS_ID_DEFAULT, TSDP_HEADER_O_SESS_VERSION_DEFAULT, nettype, addrtype, addr);
-}
-
-
-int tsdp_header_O_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header){
- const tsdp_header_O_t *O = (const tsdp_header_O_t *)header;
-
- // o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com
- return tsk_buffer_append_2(output, "%s %u %u %s %s %s",
- O->username,
- O->sess_id,
- O->sess_version,
- O->nettype,
- O->addrtype,
- O->addr
- );
-
- return 0;
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_O_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_O_t *O = (const tsdp_header_O_t *)header;
- return (tsdp_header_t*)tsdp_header_O_create(O->username, O->sess_id, O->sess_version, O->nettype, O->addrtype, O->addr);
- }
- return tsk_null;
-}
-
-tsdp_header_O_t *tsdp_header_O_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_O_t *hdr_O = tsdp_header_O_create_null();
-
- const char *tag_start;
-
-
-/* #line 108 "./src/headers/tsdp_header_O.c" */
-static const char _tsdp_machine_parser_header_U_actions[] = {
- 0, 1, 0, 1, 1, 1, 2, 1,
- 3, 1, 4, 1, 5, 1, 6, 2,
- 0, 4, 2, 0, 5, 2, 0, 6
-
-};
-
-static const char _tsdp_machine_parser_header_U_key_offsets[] = {
- 0, 0, 1, 3, 4, 5, 7, 10,
- 12, 15, 16, 17, 18, 19, 20, 21,
- 22
-};
-
-static const char _tsdp_machine_parser_header_U_trans_keys[] = {
- 111, 32, 61, 32, 32, 48, 57, 32,
- 48, 57, 48, 57, 32, 48, 57, 32,
- 32, 32, 32, 10, 13, 13, 0
-};
-
-static const char _tsdp_machine_parser_header_U_single_lengths[] = {
- 0, 1, 2, 1, 1, 0, 1, 0,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 0
-};
-
-static const char _tsdp_machine_parser_header_U_range_lengths[] = {
- 0, 0, 0, 0, 0, 1, 1, 1,
- 1, 0, 0, 0, 0, 0, 0, 0,
- 0
-};
-
-static const char _tsdp_machine_parser_header_U_index_offsets[] = {
- 0, 0, 2, 5, 7, 9, 11, 14,
- 16, 19, 21, 23, 25, 27, 29, 31,
- 33
-};
-
-static const char _tsdp_machine_parser_header_U_trans_targs[] = {
- 2, 0, 2, 3, 0, 3, 4, 5,
- 4, 6, 0, 7, 6, 0, 8, 0,
- 9, 8, 0, 11, 10, 11, 10, 14,
- 12, 14, 12, 16, 0, 13, 15, 13,
- 15, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_U_trans_actions[] = {
- 0, 0, 0, 0, 0, 0, 1, 3,
- 0, 1, 0, 5, 0, 0, 1, 0,
- 7, 0, 0, 15, 1, 9, 0, 18,
- 1, 11, 0, 0, 0, 21, 1, 13,
- 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_U_eof_actions[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 21, 13,
- 0
-};
-
-static const int tsdp_machine_parser_header_U_start = 1;
-static const int tsdp_machine_parser_header_U_first_final = 14;
-static const int tsdp_machine_parser_header_U_error = 0;
-
-static const int tsdp_machine_parser_header_U_en_main = 1;
-
-
-/* #line 148 "./ragel/tsdp_parser_header_O.rl" */
-
-/* #line 177 "./src/headers/tsdp_header_O.c" */
- {
- cs = tsdp_machine_parser_header_U_start;
- }
-
-/* #line 149 "./ragel/tsdp_parser_header_O.rl" */
-
-/* #line 184 "./src/headers/tsdp_header_O.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_U_trans_keys + _tsdp_machine_parser_header_U_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_U_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_U_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_U_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- cs = _tsdp_machine_parser_header_U_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_U_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_U_actions + _tsdp_machine_parser_header_U_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 47 "./ragel/tsdp_parser_header_O.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 51 "./ragel/tsdp_parser_header_O.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_O->username);
- }
- break;
- case 2:
-/* #line 55 "./ragel/tsdp_parser_header_O.rl" */
- {
- TSK_PARSER_SET_UINT(hdr_O->sess_id);
- }
- break;
- case 3:
-/* #line 59 "./ragel/tsdp_parser_header_O.rl" */
- {
- TSK_PARSER_SET_UINT(hdr_O->sess_version);
- }
- break;
- case 4:
-/* #line 63 "./ragel/tsdp_parser_header_O.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_O->nettype);
- }
- break;
- case 5:
-/* #line 67 "./ragel/tsdp_parser_header_O.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_O->addrtype);
- }
- break;
- case 6:
-/* #line 71 "./ragel/tsdp_parser_header_O.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_O->addr);
- }
- break;
-/* #line 299 "./src/headers/tsdp_header_O.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_U_actions + _tsdp_machine_parser_header_U_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 0:
-/* #line 47 "./ragel/tsdp_parser_header_O.rl" */
- {
- tag_start = p;
- }
- break;
- case 6:
-/* #line 71 "./ragel/tsdp_parser_header_O.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_O->addr);
- }
- break;
-/* #line 327 "./src/headers/tsdp_header_O.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 150 "./ragel/tsdp_parser_header_O.rl" */
-
- if( cs <
-/* #line 338 "./src/headers/tsdp_header_O.c" */
-14
-/* #line 151 "./ragel/tsdp_parser_header_O.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"o=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_O);
- }
-
- return hdr_O;
-}
-
-
-
-
-
-
-
-//========================================================
-// O header object definition
-//
-
-static tsk_object_t* tsdp_header_O_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_O_t *O = self;
- if(O){
- TSDP_HEADER(O)->type = tsdp_htype_O;
- TSDP_HEADER(O)->tostring = tsdp_header_O_tostring;
- TSDP_HEADER(O)->clone = tsdp_header_O_clone;
- TSDP_HEADER(O)->rank = TSDP_HTYPE_O_RANK;
-
- O->username = tsk_strdup(va_arg(*app, const char*));
- O->sess_id = va_arg(*app, uint32_t);
- O->sess_version = va_arg(*app, uint32_t);
- O->nettype = tsk_strdup(va_arg(*app, const char*));
- O->addrtype = tsk_strdup(va_arg(*app, const char*));
- O->addr = tsk_strdup(va_arg(*app, const char*));
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new O header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_O_dtor(tsk_object_t *self)
-{
- tsdp_header_O_t *O = self;
- if(O){
- TSK_FREE(O->username);
- TSK_FREE(O->nettype);
- TSK_FREE(O->addrtype);
- TSK_FREE(O->addr);
- }
- else{
- TSK_DEBUG_ERROR("Null O header.");
- }
-
- return self;
-}
-static int tsdp_header_O_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_O_def_s =
-{
- sizeof(tsdp_header_O_t),
- tsdp_header_O_ctor,
- tsdp_header_O_dtor,
- tsdp_header_O_cmp
-};
-
-const tsk_object_def_t *tsdp_header_O_def_t = &tsdp_header_O_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_P.c b/branches/1.0/tinySDP/src/headers/tsdp_header_P.c
deleted file mode 100644
index 9d767e7..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_P.c
+++ /dev/null
@@ -1,340 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_P.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-
-/**@file tsdp_header_P.c
- * @brief SDP "p=" header (Phone Number).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Iat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_P.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 61 "./ragel/tsdp_parser_header_P.rl" */
-
-
-
-tsdp_header_P_t* tsdp_header_P_create(const char* value)
-{
- return tsk_object_new(TSDP_HEADER_P_VA_ARGS(value));
-}
-
-tsdp_header_P_t* tsdp_header_P_create_null()
-{
- return tsdp_header_P_create(tsk_null);
-}
-
-int tsdp_header_P_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header){
- const tsdp_header_P_t *P = (const tsdp_header_P_t *)header;
- if(P->value){
- tsk_buffer_append(output, P->value, tsk_strlen(P->value));
- }
- return 0;
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_P_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_P_t *P = (const tsdp_header_P_t *)header;
- return (tsdp_header_t*)tsdp_header_P_create(P->value);
- }
- return tsk_null;
-}
-
-tsdp_header_P_t *tsdp_header_P_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_P_t *hdr_P = tsdp_header_P_create_null();
-
- const char *tag_start;
-
-
-/* #line 93 "./src/headers/tsdp_header_P.c" */
-static const char _tsdp_machine_parser_header_P_actions[] = {
- 0, 1, 0, 1, 1, 2, 0, 1
-
-};
-
-static const char _tsdp_machine_parser_header_P_key_offsets[] = {
- 0, 0, 1, 3, 4, 6, 7
-};
-
-static const char _tsdp_machine_parser_header_P_trans_keys[] = {
- 112, 32, 61, 10, 13, 32, 13, 0
-};
-
-static const char _tsdp_machine_parser_header_P_single_lengths[] = {
- 0, 1, 2, 1, 2, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_P_range_lengths[] = {
- 0, 0, 0, 0, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_P_index_offsets[] = {
- 0, 0, 2, 5, 7, 10, 12
-};
-
-static const char _tsdp_machine_parser_header_P_trans_targs[] = {
- 2, 0, 2, 4, 0, 6, 0, 3,
- 4, 5, 3, 5, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_P_trans_actions[] = {
- 0, 0, 0, 0, 0, 0, 0, 5,
- 0, 1, 3, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_P_eof_actions[] = {
- 0, 0, 0, 0, 5, 3, 0
-};
-
-static const int tsdp_machine_parser_header_P_start = 1;
-static const int tsdp_machine_parser_header_P_first_final = 4;
-static const int tsdp_machine_parser_header_P_error = 0;
-
-static const int tsdp_machine_parser_header_P_en_main = 1;
-
-
-/* #line 107 "./ragel/tsdp_parser_header_P.rl" */
-
-/* #line 142 "./src/headers/tsdp_header_P.c" */
- {
- cs = tsdp_machine_parser_header_P_start;
- }
-
-/* #line 108 "./ragel/tsdp_parser_header_P.rl" */
-
-/* #line 149 "./src/headers/tsdp_header_P.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_P_trans_keys + _tsdp_machine_parser_header_P_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_P_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_P_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_P_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- cs = _tsdp_machine_parser_header_P_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_P_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_P_actions + _tsdp_machine_parser_header_P_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_P.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_P.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_P->value);
- }
- break;
-/* #line 234 "./src/headers/tsdp_header_P.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_P_actions + _tsdp_machine_parser_header_P_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_P.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_P.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_P->value);
- }
- break;
-/* #line 262 "./src/headers/tsdp_header_P.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 109 "./ragel/tsdp_parser_header_P.rl" */
-
- if( cs <
-/* #line 273 "./src/headers/tsdp_header_P.c" */
-4
-/* #line 110 "./ragel/tsdp_parser_header_P.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"p=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_P);
- }
-
- return hdr_P;
-}
-
-
-
-
-
-
-
-//========================================================
-// P header object definition
-//
-
-static tsk_object_t* tsdp_header_P_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_P_t *P = self;
- if(P){
- TSDP_HEADER(P)->type = tsdp_htype_P;
- TSDP_HEADER(P)->tostring = tsdp_header_P_tostring;
- TSDP_HEADER(P)->clone = tsdp_header_P_clone;
- TSDP_HEADER(P)->rank = TSDP_HTYPE_P_RANK;
-
- P->value = tsk_strdup(va_arg(*app, const char*));
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new P header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_P_dtor(tsk_object_t *self)
-{
- tsdp_header_P_t *P = self;
- if(P){
- TSK_FREE(P->value);
- }
- else{
- TSK_DEBUG_ERROR("Null P header.");
- }
-
- return self;
-}
-static int tsdp_header_P_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_P_def_s =
-{
- sizeof(tsdp_header_P_t),
- tsdp_header_P_ctor,
- tsdp_header_P_dtor,
- tsdp_header_P_cmp
-};
-
-const tsk_object_def_t *tsdp_header_P_def_t = &tsdp_header_P_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_R.c b/branches/1.0/tinySDP/src/headers/tsdp_header_R.c
deleted file mode 100644
index ca47660..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_R.c
+++ /dev/null
@@ -1,394 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_R.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-
-/**@file tsdp_header_R.c
- * @brief SDP "r=" header (Repeat Times).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Iat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_R.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 75 "./ragel/tsdp_parser_header_R.rl" */
-
-
-
-
-tsdp_header_R_t* tsdp_header_R_create()
-{
- return tsk_object_new(TSDP_HEADER_R_VA_ARGS());
-}
-
-tsdp_header_R_t* tsdp_header_R_create_null()
-{
- return tsdp_header_R_create();
-}
-
-int tsdp_header_R_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header){
- const tsdp_header_R_t *R = (const tsdp_header_R_t *)header;
- const tsk_list_item_t* item;
-
- // r=7d 1h 0 25h
- tsk_buffer_append_2(output, "%s %s",
- R->repeat_interval,
- R->typed_time
- );
- tsk_list_foreach(item, R->typed_times){
- tsk_string_t* string = item->data;
- tsk_buffer_append_2(output, " %s", TSK_STRING_STR(string));
- }
-
- return 0;
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_R_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_R_t *R = (const tsdp_header_R_t *)header;
- tsdp_header_R_t* clone;
- const tsk_list_item_t* item;
-
- if((clone = tsdp_header_R_create_null())){
- clone->repeat_interval = tsk_strdup(R->repeat_interval);
- clone->typed_time = tsk_strdup(R->typed_time);
-
- if(R->typed_times){
- clone->typed_times = tsk_list_create();
- }
-
- tsk_list_foreach(item, R->typed_times){
- tsk_string_t* string = tsk_string_create(TSK_STRING_STR(item->data));
- tsk_list_push_back_data(clone->typed_times, (void**)&string);
- }
- }
- return TSDP_HEADER(clone);
- }
- return tsk_null;
-}
-
-tsdp_header_R_t *tsdp_header_R_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_R_t *hdr_R = tsdp_header_R_create_null();
-
- const char *tag_start;
-
-
-/* #line 119 "./src/headers/tsdp_header_R.c" */
-static const char _tsdp_machine_parser_header_R_actions[] = {
- 0, 1, 0, 1, 1, 1, 2
-};
-
-static const char _tsdp_machine_parser_header_R_key_offsets[] = {
- 0, 0, 1, 3, 6, 13, 15, 22,
- 24, 25, 26, 27, 35, 35
-};
-
-static const char _tsdp_machine_parser_header_R_trans_keys[] = {
- 114, 32, 61, 32, 48, 57, 32, 100,
- 104, 109, 115, 48, 57, 48, 57, 32,
- 100, 104, 109, 115, 48, 57, 48, 57,
- 10, 32, 32, 13, 32, 100, 104, 109,
- 115, 48, 57, 13, 32, 0
-};
-
-static const char _tsdp_machine_parser_header_R_single_lengths[] = {
- 0, 1, 2, 1, 5, 0, 5, 0,
- 1, 1, 1, 6, 0, 2
-};
-
-static const char _tsdp_machine_parser_header_R_range_lengths[] = {
- 0, 0, 0, 1, 1, 1, 1, 1,
- 0, 0, 0, 1, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_R_index_offsets[] = {
- 0, 0, 2, 5, 8, 15, 17, 24,
- 26, 28, 30, 32, 40, 41
-};
-
-static const char _tsdp_machine_parser_header_R_indicies[] = {
- 0, 1, 0, 2, 1, 2, 3, 1,
- 4, 6, 6, 6, 6, 5, 1, 7,
- 1, 8, 10, 10, 10, 10, 9, 1,
- 11, 1, 12, 1, 8, 1, 4, 1,
- 13, 8, 15, 15, 15, 15, 14, 1,
- 1, 13, 8, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_R_trans_targs[] = {
- 2, 0, 3, 4, 5, 4, 10, 6,
- 7, 6, 9, 11, 12, 8, 11, 13
-};
-
-static const char _tsdp_machine_parser_header_R_trans_actions[] = {
- 0, 0, 0, 1, 3, 0, 0, 1,
- 5, 0, 0, 1, 0, 5, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_R_eof_actions[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 5, 0, 5
-};
-
-static const int tsdp_machine_parser_header_R_start = 1;
-static const int tsdp_machine_parser_header_R_first_final = 11;
-static const int tsdp_machine_parser_header_R_error = 0;
-
-static const int tsdp_machine_parser_header_R_en_main = 1;
-
-
-/* #line 147 "./ragel/tsdp_parser_header_R.rl" */
-
-/* #line 185 "./src/headers/tsdp_header_R.c" */
- {
- cs = tsdp_machine_parser_header_R_start;
- }
-
-/* #line 148 "./ragel/tsdp_parser_header_R.rl" */
-
-/* #line 192 "./src/headers/tsdp_header_R.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_R_trans_keys + _tsdp_machine_parser_header_R_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_R_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_R_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_R_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- _trans = _tsdp_machine_parser_header_R_indicies[_trans];
- cs = _tsdp_machine_parser_header_R_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_R_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_R_actions + _tsdp_machine_parser_header_R_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_R.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_R.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_R->repeat_interval);
- }
- break;
- case 2:
-/* #line 56 "./ragel/tsdp_parser_header_R.rl" */
- {
- if(!hdr_R->typed_time){
- TSK_PARSER_SET_STRING(hdr_R->typed_time);
- }
- else{
- TSK_PARSER_ADD_STRING(hdr_R->typed_times);
- }
- }
- break;
-/* #line 289 "./src/headers/tsdp_header_R.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_R_actions + _tsdp_machine_parser_header_R_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 2:
-/* #line 56 "./ragel/tsdp_parser_header_R.rl" */
- {
- if(!hdr_R->typed_time){
- TSK_PARSER_SET_STRING(hdr_R->typed_time);
- }
- else{
- TSK_PARSER_ADD_STRING(hdr_R->typed_times);
- }
- }
- break;
-/* #line 316 "./src/headers/tsdp_header_R.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 149 "./ragel/tsdp_parser_header_R.rl" */
-
- if( cs <
-/* #line 327 "./src/headers/tsdp_header_R.c" */
-11
-/* #line 150 "./ragel/tsdp_parser_header_R.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"r=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_R);
- }
-
- return hdr_R;
-}
-
-
-
-
-
-
-
-//========================================================
-// E header object definition
-//
-
-static tsk_object_t* tsdp_header_R_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_R_t *R = self;
- if(R){
- TSDP_HEADER(R)->type = tsdp_htype_R;
- TSDP_HEADER(R)->tostring = tsdp_header_R_tostring;
- TSDP_HEADER(R)->clone = tsdp_header_R_clone;
- TSDP_HEADER(R)->rank = TSDP_HTYPE_R_RANK;
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new E header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_R_dtor(tsk_object_t *self)
-{
- tsdp_header_R_t *R = self;
- if(R){
- TSK_FREE(R->repeat_interval);
- TSK_FREE(R->typed_time);
- TSK_OBJECT_SAFE_FREE(R->typed_times);
- }
- else{
- TSK_DEBUG_ERROR("Null R header.");
- }
-
- return self;
-}
-static int tsdp_header_R_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_R_def_s =
-{
- sizeof(tsdp_header_R_t),
- tsdp_header_R_ctor,
- tsdp_header_R_dtor,
- tsdp_header_R_cmp
-};
-
-const tsk_object_def_t *tsdp_header_R_def_t = &tsdp_header_R_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_S.c b/branches/1.0/tinySDP/src/headers/tsdp_header_S.c
deleted file mode 100644
index f053697..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_S.c
+++ /dev/null
@@ -1,338 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_S.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-/**@file tsdp_header_S.c
- * @brief SDP "s=" header (Session Name).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Sat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_S.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 60 "./ragel/tsdp_parser_header_S.rl" */
-
-
-
-tsdp_header_S_t* tsdp_header_S_create(const char* value)
-{
- return tsk_object_new(TSDP_HEADER_S_VA_ARGS(value));
-}
-tsdp_header_S_t* tsdp_header_S_create_null()
-{
- return tsdp_header_S_create(tsk_null);
-}
-
-int tsdp_header_S_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header)
- {
- const tsdp_header_S_t *S = (const tsdp_header_S_t *)header;
- if(S->value){
- tsk_buffer_append(output, S->value, tsk_strlen(S->value));
- }
- return 0;
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_S_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_S_t *S = (const tsdp_header_S_t *)header;
- return (tsdp_header_t*)tsdp_header_S_create(S->value);
- }
- return tsk_null;
-}
-
-tsdp_header_S_t *tsdp_header_S_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_S_t *hdr_S = tsdp_header_S_create_null();
-
- const char *tag_start;
-
-
-/* #line 92 "./src/headers/tsdp_header_S.c" */
-static const char _tsdp_machine_parser_header_S_actions[] = {
- 0, 1, 0, 1, 1, 2, 0, 1
-
-};
-
-static const char _tsdp_machine_parser_header_S_key_offsets[] = {
- 0, 0, 1, 3, 4, 6, 7
-};
-
-static const char _tsdp_machine_parser_header_S_trans_keys[] = {
- 115, 32, 61, 10, 13, 32, 13, 0
-};
-
-static const char _tsdp_machine_parser_header_S_single_lengths[] = {
- 0, 1, 2, 1, 2, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_S_range_lengths[] = {
- 0, 0, 0, 0, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_S_index_offsets[] = {
- 0, 0, 2, 5, 7, 10, 12
-};
-
-static const char _tsdp_machine_parser_header_S_trans_targs[] = {
- 2, 0, 2, 4, 0, 6, 0, 3,
- 4, 5, 3, 5, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_S_trans_actions[] = {
- 0, 0, 0, 0, 0, 0, 0, 5,
- 0, 1, 3, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_S_eof_actions[] = {
- 0, 0, 0, 0, 5, 3, 0
-};
-
-static const int tsdp_machine_parser_header_S_start = 1;
-static const int tsdp_machine_parser_header_S_first_final = 4;
-static const int tsdp_machine_parser_header_S_error = 0;
-
-static const int tsdp_machine_parser_header_S_en_main = 1;
-
-
-/* #line 106 "./ragel/tsdp_parser_header_S.rl" */
-
-/* #line 141 "./src/headers/tsdp_header_S.c" */
- {
- cs = tsdp_machine_parser_header_S_start;
- }
-
-/* #line 107 "./ragel/tsdp_parser_header_S.rl" */
-
-/* #line 148 "./src/headers/tsdp_header_S.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_S_trans_keys + _tsdp_machine_parser_header_S_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_S_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_S_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_S_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- cs = _tsdp_machine_parser_header_S_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_S_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_S_actions + _tsdp_machine_parser_header_S_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 47 "./ragel/tsdp_parser_header_S.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 51 "./ragel/tsdp_parser_header_S.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_S->value);
- }
- break;
-/* #line 233 "./src/headers/tsdp_header_S.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_S_actions + _tsdp_machine_parser_header_S_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 0:
-/* #line 47 "./ragel/tsdp_parser_header_S.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 51 "./ragel/tsdp_parser_header_S.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_S->value);
- }
- break;
-/* #line 261 "./src/headers/tsdp_header_S.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 108 "./ragel/tsdp_parser_header_S.rl" */
-
- if( cs <
-/* #line 272 "./src/headers/tsdp_header_S.c" */
-4
-/* #line 109 "./ragel/tsdp_parser_header_S.rl" */
- ){
- TSK_OBJECT_SAFE_FREE(hdr_S);
- }
-
- return hdr_S;
-}
-
-
-
-
-
-
-
-//========================================================
-// S header object definition
-//
-
-static tsk_object_t* tsdp_header_S_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_S_t *S = self;
- if(S){
- TSDP_HEADER(S)->type = tsdp_htype_S;
- TSDP_HEADER(S)->tostring = tsdp_header_S_tostring;
- TSDP_HEADER(S)->clone = tsdp_header_S_clone;
- TSDP_HEADER(S)->rank = TSDP_HTYPE_S_RANK;
-
- S->value = tsk_strdup(va_arg(*app, const char*));
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new S header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_S_dtor(tsk_object_t *self)
-{
- tsdp_header_S_t *S = self;
- if(S){
- TSK_FREE(S->value);
- }
- else{
- TSK_DEBUG_ERROR("Null S header.");
- }
-
- return self;
-}
-static int tsdp_header_S_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_S_def_s =
-{
- sizeof(tsdp_header_S_t),
- tsdp_header_S_ctor,
- tsdp_header_S_dtor,
- tsdp_header_S_cmp
-};
-
-const tsk_object_def_t *tsdp_header_S_def_t = &tsdp_header_S_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_T.c b/branches/1.0/tinySDP/src/headers/tsdp_header_T.c
deleted file mode 100644
index 0f1ec79..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_T.c
+++ /dev/null
@@ -1,381 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_T.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-/**@file tsdp_header_T.c
- * @brief SDP "t=" header (Timing).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Uat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_T.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 82 "./ragel/tsdp_parser_header_T.rl" */
-
-
-
-tsdp_header_T_t* tsdp_header_T_create(uint64_t start, uint64_t stop)
-{
- return tsk_object_new(TSDP_HEADER_T_VA_ARGS(start, stop));
-}
-
-tsdp_header_T_t* tsdp_header_T_create_null()
-{
- return tsdp_header_T_create(0, 0);
-}
-
-int tsdp_header_T_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header)
- {
- const tsdp_header_T_t *T = (const tsdp_header_T_t *)header;
- const tsk_list_item_t *item;
-
- //"t=3034423619 3042462419\r\n"
- //"r=7d 1h 0 25h\r\n"
- // IMPORTANT: Do not append the last CRLF (because we only print the header value).
- tsk_buffer_append_2(output, "%llu %llu",
- T->start,
- T->stop
- );
-
- tsk_list_foreach(item, T->repeat_fields)
- {
- if(TSK_LIST_IS_FIRST(T->repeat_fields, item)){
- tsk_buffer_append(output, "\r\n", 2);
- }
- tsk_buffer_append_2(output, "%c=", tsdp_header_get_nameex(TSDP_HEADER(item->data)));
- TSDP_HEADER(item->data)->tostring(TSDP_HEADER(item->data), output);
- //tsdp_header_tostring(TSDP_HEADER(item->data), output);
-
- if(!TSK_LIST_IS_LAST(T->repeat_fields, item)){
- tsk_buffer_append(output, "\r\n", 2);
- }
- }
-
- return 0;
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_T_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_T_t *T = (const tsdp_header_T_t *)header;
- tsdp_header_T_t* clone;
- const tsk_list_item_t *item;
-
- if((clone = tsdp_header_T_create(T->start, T->stop))){
-
- if(T->repeat_fields){
- clone->repeat_fields = tsk_list_create();
- }
-
- tsk_list_foreach(item, T->repeat_fields){
- const tsdp_header_t* curr = item->data;
- tsdp_header_t* hdr_clone = curr->clone(curr);
- tsk_list_push_back_data(clone->repeat_fields, (void**)&hdr_clone);
- }
- }
- return TSDP_HEADER(clone);
- }
- return tsk_null;
-}
-
-tsdp_header_T_t *tsdp_header_T_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_T_t *hdr_T = tsdp_header_T_create_null();
-
- const char *tag_start;
-
-
-/* #line 129 "./src/headers/tsdp_header_T.c" */
-static const char _tsdp_machine_parser_header_T_actions[] = {
- 0, 1, 0, 1, 1, 1, 2
-};
-
-static const char _tsdp_machine_parser_header_T_key_offsets[] = {
- 0, 0, 1, 3, 6, 9, 11, 12,
- 15
-};
-
-static const char _tsdp_machine_parser_header_T_trans_keys[] = {
- 116, 32, 61, 32, 48, 57, 32, 48,
- 57, 48, 57, 10, 13, 48, 57, 0
-};
-
-static const char _tsdp_machine_parser_header_T_single_lengths[] = {
- 0, 1, 2, 1, 1, 0, 1, 1,
- 0
-};
-
-static const char _tsdp_machine_parser_header_T_range_lengths[] = {
- 0, 0, 0, 1, 1, 1, 0, 1,
- 0
-};
-
-static const char _tsdp_machine_parser_header_T_index_offsets[] = {
- 0, 0, 2, 5, 8, 11, 13, 15,
- 18
-};
-
-static const char _tsdp_machine_parser_header_T_trans_targs[] = {
- 2, 0, 2, 3, 0, 3, 4, 0,
- 5, 4, 0, 7, 0, 8, 0, 6,
- 7, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_T_trans_actions[] = {
- 0, 0, 0, 0, 0, 0, 1, 0,
- 3, 0, 0, 1, 0, 0, 0, 5,
- 0, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_T_eof_actions[] = {
- 0, 0, 0, 0, 0, 0, 0, 5,
- 0
-};
-
-static const int tsdp_machine_parser_header_T_start = 1;
-static const int tsdp_machine_parser_header_T_first_final = 7;
-static const int tsdp_machine_parser_header_T_error = 0;
-
-static const int tsdp_machine_parser_header_T_en_main = 1;
-
-
-/* #line 165 "./ragel/tsdp_parser_header_T.rl" */
-
-/* #line 185 "./src/headers/tsdp_header_T.c" */
- {
- cs = tsdp_machine_parser_header_T_start;
- }
-
-/* #line 166 "./ragel/tsdp_parser_header_T.rl" */
-
-/* #line 192 "./src/headers/tsdp_header_T.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_T_trans_keys + _tsdp_machine_parser_header_T_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_T_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_T_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_T_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- cs = _tsdp_machine_parser_header_T_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_T_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_T_actions + _tsdp_machine_parser_header_T_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 47 "./ragel/tsdp_parser_header_T.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 55 "./ragel/tsdp_parser_header_T.rl" */
- {
- TSK_PARSER_SET_INTEGER_EX(hdr_T->start, uint64_t, atoi64);
- }
- break;
- case 2:
-/* #line 59 "./ragel/tsdp_parser_header_T.rl" */
- {
- TSK_PARSER_SET_INTEGER_EX(hdr_T->stop, uint64_t, atoi64);
- }
- break;
-/* #line 283 "./src/headers/tsdp_header_T.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_T_actions + _tsdp_machine_parser_header_T_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 2:
-/* #line 59 "./ragel/tsdp_parser_header_T.rl" */
- {
- TSK_PARSER_SET_INTEGER_EX(hdr_T->stop, uint64_t, atoi64);
- }
- break;
-/* #line 305 "./src/headers/tsdp_header_T.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 167 "./ragel/tsdp_parser_header_T.rl" */
-
- if( cs <
-/* #line 316 "./src/headers/tsdp_header_T.c" */
-7
-/* #line 168 "./ragel/tsdp_parser_header_T.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"t=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_T);
- }
-
- return hdr_T;
-}
-
-
-
-
-
-
-
-//========================================================
-// T header object definition
-//
-
-static tsk_object_t* tsdp_header_T_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_T_t *T = self;
- if(T){
- TSDP_HEADER(T)->type = tsdp_htype_T;
- TSDP_HEADER(T)->tostring = tsdp_header_T_tostring;
- TSDP_HEADER(T)->clone = tsdp_header_T_clone;
- TSDP_HEADER(T)->rank = TSDP_HTYPE_T_RANK;
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new U header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_T_dtor(tsk_object_t *self)
-{
- tsdp_header_T_t *T = self;
- if(T){
- TSK_OBJECT_SAFE_FREE(T->repeat_fields);
- }
- else{
- TSK_DEBUG_ERROR("Null U header.");
- }
-
- return self;
-}
-static int tsdp_header_T_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_T_def_s =
-{
- sizeof(tsdp_header_T_t),
- tsdp_header_T_ctor,
- tsdp_header_T_dtor,
- tsdp_header_T_cmp
-};
-
-const tsk_object_def_t *tsdp_header_T_def_t = &tsdp_header_T_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_U.c b/branches/1.0/tinySDP/src/headers/tsdp_header_U.c
deleted file mode 100644
index 4fd932f..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_U.c
+++ /dev/null
@@ -1,342 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_U.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-/**@file tsdp_header_U.c
- * @brief SDP "u=" header (URI).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Uat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_U.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 60 "./ragel/tsdp_parser_header_U.rl" */
-
-
-
-
-tsdp_header_U_t* tsdp_header_U_create(const char* value)
-{
- return tsk_object_new(TSDP_HEADER_U_VA_ARGS(value));
-}
-
-tsdp_header_U_t* tsdp_header_U_create_null()
-{
- return tsdp_header_U_create(tsk_null);
-}
-
-int tsdp_header_U_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header)
- {
- const tsdp_header_U_t *U = (const tsdp_header_U_t *)header;
- if(U->value){
- tsk_buffer_append(output, U->value, tsk_strlen(U->value));
- }
- return 0;
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_U_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_U_t *U = (const tsdp_header_U_t *)header;
- return (tsdp_header_t*)tsdp_header_U_create(U->value);
- }
- return tsk_null;
-}
-
-tsdp_header_U_t *tsdp_header_U_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_U_t *hdr_U = tsdp_header_U_create_null();
-
- const char *tag_start;
-
-
-/* #line 94 "./src/headers/tsdp_header_U.c" */
-static const char _tsdp_machine_parser_header_U_actions[] = {
- 0, 1, 0, 1, 1, 2, 0, 1
-
-};
-
-static const char _tsdp_machine_parser_header_U_key_offsets[] = {
- 0, 0, 1, 3, 4, 6, 7
-};
-
-static const char _tsdp_machine_parser_header_U_trans_keys[] = {
- 117, 32, 61, 10, 13, 32, 13, 0
-};
-
-static const char _tsdp_machine_parser_header_U_single_lengths[] = {
- 0, 1, 2, 1, 2, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_U_range_lengths[] = {
- 0, 0, 0, 0, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_U_index_offsets[] = {
- 0, 0, 2, 5, 7, 10, 12
-};
-
-static const char _tsdp_machine_parser_header_U_trans_targs[] = {
- 2, 0, 2, 4, 0, 6, 0, 3,
- 4, 5, 3, 5, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_U_trans_actions[] = {
- 0, 0, 0, 0, 0, 0, 0, 5,
- 0, 1, 3, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_U_eof_actions[] = {
- 0, 0, 0, 0, 5, 3, 0
-};
-
-static const int tsdp_machine_parser_header_U_start = 1;
-static const int tsdp_machine_parser_header_U_first_final = 4;
-static const int tsdp_machine_parser_header_U_error = 0;
-
-static const int tsdp_machine_parser_header_U_en_main = 1;
-
-
-/* #line 108 "./ragel/tsdp_parser_header_U.rl" */
-
-/* #line 143 "./src/headers/tsdp_header_U.c" */
- {
- cs = tsdp_machine_parser_header_U_start;
- }
-
-/* #line 109 "./ragel/tsdp_parser_header_U.rl" */
-
-/* #line 150 "./src/headers/tsdp_header_U.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_U_trans_keys + _tsdp_machine_parser_header_U_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_U_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_U_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_U_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- cs = _tsdp_machine_parser_header_U_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_U_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_U_actions + _tsdp_machine_parser_header_U_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 47 "./ragel/tsdp_parser_header_U.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 51 "./ragel/tsdp_parser_header_U.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_U->value);
- }
- break;
-/* #line 235 "./src/headers/tsdp_header_U.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_U_actions + _tsdp_machine_parser_header_U_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 0:
-/* #line 47 "./ragel/tsdp_parser_header_U.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 51 "./ragel/tsdp_parser_header_U.rl" */
- {
- TSK_PARSER_SET_STRING(hdr_U->value);
- }
- break;
-/* #line 263 "./src/headers/tsdp_header_U.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 110 "./ragel/tsdp_parser_header_U.rl" */
-
- if( cs <
-/* #line 274 "./src/headers/tsdp_header_U.c" */
-4
-/* #line 111 "./ragel/tsdp_parser_header_U.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"u=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_U);
- }
-
- return hdr_U;
-}
-
-
-
-
-
-
-
-//========================================================
-// U header object definition
-//
-
-static tsk_object_t* tsdp_header_U_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_U_t *U = self;
- if(U)
- {
- TSDP_HEADER(U)->type = tsdp_htype_U;
- TSDP_HEADER(U)->tostring = tsdp_header_U_tostring;
- TSDP_HEADER(U)->clone = tsdp_header_U_clone;
- TSDP_HEADER(U)->rank = TSDP_HTYPE_U_RANK;
-
- U->value = tsk_strdup(va_arg(*app, const char*));
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new U header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_U_dtor(tsk_object_t *self)
-{
- tsdp_header_U_t *U = self;
- if(U){
- TSK_FREE(U->value);
- }
- else{
- TSK_DEBUG_ERROR("Null U header.");
- }
-
- return self;
-}
-static int tsdp_header_U_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_U_def_s =
-{
- sizeof(tsdp_header_U_t),
- tsdp_header_U_ctor,
- tsdp_header_U_dtor,
- tsdp_header_U_cmp
-};
-
-const tsk_object_def_t *tsdp_header_U_def_t = &tsdp_header_U_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_V.c b/branches/1.0/tinySDP/src/headers/tsdp_header_V.c
deleted file mode 100644
index 231fd46..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_V.c
+++ /dev/null
@@ -1,333 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_V.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-/**@file tsdp_header_V.c
- * @brief SDP "v=" header (Protocol Version).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Sat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_V.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 60 "./ragel/tsdp_parser_header_V.rl" */
-
-
-
-tsdp_header_V_t* tsdp_header_V_create(int32_t version)
-{
- return tsk_object_new(TSDP_HEADER_V_VA_ARGS(version));
-}
-
-tsdp_header_V_t* tsdp_header_V_create_null()
-{
- return tsdp_header_V_create(TSDP_HEADER_V_DEFAULT);
-}
-
-int tsdp_header_V_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header)
- {
- const tsdp_header_V_t *V = (const tsdp_header_V_t *)header;
- if(V->version >=0){
- tsk_buffer_append_2(output, "%d", V->version);
- }
- return 0;
- }
-
- return -1;
-}
-
-tsdp_header_t* tsdp_header_V_clone(const tsdp_header_t* header)
-{
- if(header){
- const tsdp_header_V_t *V = (const tsdp_header_V_t *)header;
- return (tsdp_header_t*)tsdp_header_V_create(V->version);
- }
- return tsk_null;
-}
-
-tsdp_header_V_t *tsdp_header_V_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_V_t *hdr_V = tsdp_header_V_create_null();
-
- const char *tag_start;
-
-
-/* #line 93 "./src/headers/tsdp_header_V.c" */
-static const char _tsdp_machine_parser_header_V_actions[] = {
- 0, 1, 0, 1, 1
-};
-
-static const char _tsdp_machine_parser_header_V_key_offsets[] = {
- 0, 0, 1, 3, 6, 7, 10
-};
-
-static const char _tsdp_machine_parser_header_V_trans_keys[] = {
- 118, 32, 61, 32, 48, 57, 10, 13,
- 48, 57, 0
-};
-
-static const char _tsdp_machine_parser_header_V_single_lengths[] = {
- 0, 1, 2, 1, 1, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_V_range_lengths[] = {
- 0, 0, 0, 1, 0, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_V_index_offsets[] = {
- 0, 0, 2, 5, 8, 10, 13
-};
-
-static const char _tsdp_machine_parser_header_V_trans_targs[] = {
- 2, 0, 2, 3, 0, 3, 5, 0,
- 6, 0, 4, 5, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_V_trans_actions[] = {
- 0, 0, 0, 0, 0, 0, 1, 0,
- 0, 0, 3, 0, 0, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_V_eof_actions[] = {
- 0, 0, 0, 0, 0, 3, 0
-};
-
-static const int tsdp_machine_parser_header_V_start = 1;
-static const int tsdp_machine_parser_header_V_first_final = 5;
-static const int tsdp_machine_parser_header_V_error = 0;
-
-static const int tsdp_machine_parser_header_V_en_main = 1;
-
-
-/* #line 107 "./ragel/tsdp_parser_header_V.rl" */
-
-/* #line 142 "./src/headers/tsdp_header_V.c" */
- {
- cs = tsdp_machine_parser_header_V_start;
- }
-
-/* #line 108 "./ragel/tsdp_parser_header_V.rl" */
-
-/* #line 149 "./src/headers/tsdp_header_V.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_V_trans_keys + _tsdp_machine_parser_header_V_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_V_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_V_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_V_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- cs = _tsdp_machine_parser_header_V_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_V_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_V_actions + _tsdp_machine_parser_header_V_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 47 "./ragel/tsdp_parser_header_V.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 51 "./ragel/tsdp_parser_header_V.rl" */
- {
- TSK_PARSER_SET_INT(hdr_V->version);
- }
- break;
-/* #line 234 "./src/headers/tsdp_header_V.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_V_actions + _tsdp_machine_parser_header_V_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 1:
-/* #line 51 "./ragel/tsdp_parser_header_V.rl" */
- {
- TSK_PARSER_SET_INT(hdr_V->version);
- }
- break;
-/* #line 256 "./src/headers/tsdp_header_V.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 109 "./ragel/tsdp_parser_header_V.rl" */
-
- if( cs <
-/* #line 267 "./src/headers/tsdp_header_V.c" */
-5
-/* #line 110 "./ragel/tsdp_parser_header_V.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"v=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_V);
- }
-
- return hdr_V;
-}
-
-
-
-
-
-
-
-//========================================================
-// V header object definition
-//
-
-static tsk_object_t* tsdp_header_V_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_V_t *V = self;
- if(V){
- TSDP_HEADER(V)->type = tsdp_htype_V;
- TSDP_HEADER(V)->tostring = tsdp_header_V_tostring;
- TSDP_HEADER(V)->clone = tsdp_header_V_clone;
- TSDP_HEADER(V)->rank = TSDP_HTYPE_V_RANK;
-
- V->version = va_arg(*app, int32_t);
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new V header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_V_dtor(tsk_object_t *self)
-{
- tsdp_header_V_t *V = self;
- if(V){
- }
- else{
- TSK_DEBUG_ERROR("Null V header.");
- }
-
- return self;
-}
-static int tsdp_header_V_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_V_def_s =
-{
- sizeof(tsdp_header_V_t),
- tsdp_header_V_ctor,
- tsdp_header_V_dtor,
- tsdp_header_V_cmp
-};
-
-const tsk_object_def_t *tsdp_header_V_def_t = &tsdp_header_V_def_s;
diff --git a/branches/1.0/tinySDP/src/headers/tsdp_header_Z.c b/branches/1.0/tinySDP/src/headers/tsdp_header_Z.c
deleted file mode 100644
index 9ed89ac..0000000
--- a/branches/1.0/tinySDP/src/headers/tsdp_header_Z.c
+++ /dev/null
@@ -1,485 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_header_Z.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-
-/**@file tsdp_header_Z.c
- * @brief SDP "z=" header (Time Zones).
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Iat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/headers/tsdp_header_Z.h"
-
-#include "tsk_debug.h"
-#include "tsk_memory.h"
-#include "tsk_string.h"
-
-#include <string.h>
-
-/***********************************
-* Ragel state machine.
-*/
-
-/* #line 93 "./ragel/tsdp_parser_header_Z.rl" */
-
-
-
-tsdp_header_Z_t* tsdp_header_Z_create(uint64_t time, tsk_bool_t shifted_back, const char* typed_time)
-{
- return tsk_object_new(TSDP_HEADER_Z_VA_ARGS(time, shifted_back, typed_time));
-}
-
-tsdp_header_Z_t* tsdp_header_Z_create_null()
-{
- return tsdp_header_Z_create(0L, tsk_false, tsk_null);
-}
-
-
-tsdp_zone_t* tsdp_zone_create(uint64_t time, tsk_bool_t shifted_back, const char* typed_time)
-{
- return tsk_object_new(tsdp_zone_def_t, time, shifted_back, typed_time);
-}
-
-tsdp_zone_t* tsdp_zone_create_null()
-{
- return tsdp_zone_create(0L, tsk_false, tsk_null);
-}
-
-int tsdp_header_Z_tostring(const tsdp_header_t* header, tsk_buffer_t* output)
-{
- if(header){
- const tsdp_header_Z_t *Z = (const tsdp_header_Z_t *)header;
- const tsk_list_item_t *item;
- const tsdp_zone_t* zone;
-
- tsk_list_foreach(item, Z->zones){
- zone = item->data;
- // time SP ["-"] typed-time
- tsk_buffer_append_2(output, "%s%llu %s%s",
- TSK_LIST_IS_FIRST(Z->zones, item) ? "" : " ",
- zone->time,
- zone->shifted_back ? "-" : "",
- zone->typed_time
- );
- }
- }
-
- return -1;
-}
-
-tsdp_header_Z_t *tsdp_header_Z_parse(const char *data, tsk_size_t size)
-{
- int cs = 0;
- const char *p = data;
- const char *pe = p + size;
- const char *eof = pe;
- tsdp_header_Z_t *hdr_Z = tsdp_header_Z_create_null();
- tsdp_zone_t* zone = tsk_null;
-
- const char *tag_start;
-
-
-/* #line 105 "./src/headers/tsdp_header_Z.c" */
-static const char _tsdp_machine_parser_header_Z_actions[] = {
- 0, 1, 0, 1, 3, 1, 4, 2,
- 1, 0, 2, 4, 2, 2, 5, 0,
- 3, 4, 2, 1
-};
-
-static const char _tsdp_machine_parser_header_Z_key_offsets[] = {
- 0, 0, 1, 3, 5, 8, 11, 13,
- 14, 16, 19, 22, 24, 32, 32, 40,
- 42
-};
-
-static const char _tsdp_machine_parser_header_Z_trans_keys[] = {
- 122, 32, 61, 48, 57, 32, 48, 57,
- 45, 48, 57, 48, 57, 10, 48, 57,
- 32, 48, 57, 45, 48, 57, 48, 57,
- 13, 32, 100, 104, 109, 115, 48, 57,
- 13, 32, 100, 104, 109, 115, 48, 57,
- 13, 32, 13, 32, 0
-};
-
-static const char _tsdp_machine_parser_header_Z_single_lengths[] = {
- 0, 1, 2, 0, 1, 1, 0, 1,
- 0, 1, 1, 0, 6, 0, 6, 2,
- 2
-};
-
-static const char _tsdp_machine_parser_header_Z_range_lengths[] = {
- 0, 0, 0, 1, 1, 1, 1, 0,
- 1, 1, 1, 1, 1, 0, 1, 0,
- 0
-};
-
-static const char _tsdp_machine_parser_header_Z_index_offsets[] = {
- 0, 0, 2, 5, 7, 10, 13, 15,
- 17, 19, 22, 25, 27, 35, 36, 44,
- 47
-};
-
-static const char _tsdp_machine_parser_header_Z_indicies[] = {
- 0, 1, 0, 2, 1, 3, 1, 4,
- 5, 1, 6, 7, 1, 8, 1, 9,
- 1, 10, 1, 11, 12, 1, 13, 14,
- 1, 15, 1, 16, 17, 19, 19, 19,
- 19, 18, 1, 1, 20, 21, 23, 23,
- 23, 23, 22, 1, 20, 21, 1, 16,
- 17, 1, 0
-};
-
-static const char _tsdp_machine_parser_header_Z_trans_targs[] = {
- 2, 0, 3, 4, 5, 4, 6, 12,
- 12, 13, 9, 10, 9, 11, 14, 14,
- 7, 8, 12, 16, 7, 8, 14, 15
-};
-
-static const char _tsdp_machine_parser_header_Z_trans_actions[] = {
- 0, 0, 0, 7, 3, 0, 0, 1,
- 13, 0, 1, 3, 0, 0, 1, 13,
- 16, 16, 0, 0, 10, 5, 0, 0
-};
-
-static const char _tsdp_machine_parser_header_Z_eof_actions[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 16, 0, 10, 10,
- 16
-};
-
-static const int tsdp_machine_parser_header_Z_start = 1;
-static const int tsdp_machine_parser_header_Z_first_final = 12;
-static const int tsdp_machine_parser_header_Z_error = 0;
-
-static const int tsdp_machine_parser_header_Z_en_main = 1;
-
-
-/* #line 151 "./ragel/tsdp_parser_header_Z.rl" */
-
-/* #line 182 "./src/headers/tsdp_header_Z.c" */
- {
- cs = tsdp_machine_parser_header_Z_start;
- }
-
-/* #line 152 "./ragel/tsdp_parser_header_Z.rl" */
-
-/* #line 189 "./src/headers/tsdp_header_Z.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_parser_header_Z_trans_keys + _tsdp_machine_parser_header_Z_key_offsets[cs];
- _trans = _tsdp_machine_parser_header_Z_index_offsets[cs];
-
- _klen = _tsdp_machine_parser_header_Z_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_parser_header_Z_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- _trans = _tsdp_machine_parser_header_Z_indicies[_trans];
- cs = _tsdp_machine_parser_header_Z_trans_targs[_trans];
-
- if ( _tsdp_machine_parser_header_Z_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_parser_header_Z_actions + _tsdp_machine_parser_header_Z_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 48 "./ragel/tsdp_parser_header_Z.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_Z.rl" */
- {
- if(!zone){
- zone = tsdp_zone_create_null();
- }
- }
- break;
- case 2:
-/* #line 58 "./ragel/tsdp_parser_header_Z.rl" */
- {
- if(zone){
- tsk_list_push_back_data(hdr_Z->zones,(void**)&zone);
- }
- }
- break;
- case 3:
-/* #line 64 "./ragel/tsdp_parser_header_Z.rl" */
- {
- if(zone){
- TSK_PARSER_SET_INTEGER_EX(zone->time, uint64_t, atoi64);
- }
- }
- break;
- case 4:
-/* #line 70 "./ragel/tsdp_parser_header_Z.rl" */
- {
- if(zone){
- TSK_PARSER_SET_STRING(zone->typed_time);
- }
- }
- break;
- case 5:
-/* #line 76 "./ragel/tsdp_parser_header_Z.rl" */
- {
- if(zone){
- zone->shifted_back = tsk_true;
- }
- }
- break;
-/* #line 309 "./src/headers/tsdp_header_Z.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- if ( p == eof )
- {
- const char *__acts = _tsdp_machine_parser_header_Z_actions + _tsdp_machine_parser_header_Z_eof_actions[cs];
- unsigned int __nacts = (unsigned int) *__acts++;
- while ( __nacts-- > 0 ) {
- switch ( *__acts++ ) {
- case 1:
-/* #line 52 "./ragel/tsdp_parser_header_Z.rl" */
- {
- if(!zone){
- zone = tsdp_zone_create_null();
- }
- }
- break;
- case 2:
-/* #line 58 "./ragel/tsdp_parser_header_Z.rl" */
- {
- if(zone){
- tsk_list_push_back_data(hdr_Z->zones,(void**)&zone);
- }
- }
- break;
- case 4:
-/* #line 70 "./ragel/tsdp_parser_header_Z.rl" */
- {
- if(zone){
- TSK_PARSER_SET_STRING(zone->typed_time);
- }
- }
- break;
-/* #line 349 "./src/headers/tsdp_header_Z.c" */
- }
- }
- }
-
- _out: {}
- }
-
-/* #line 153 "./ragel/tsdp_parser_header_Z.rl" */
-
- if(zone){
- TSK_OBJECT_SAFE_FREE(zone);
- }
-
- if( cs <
-/* #line 364 "./src/headers/tsdp_header_Z.c" */
-12
-/* #line 158 "./ragel/tsdp_parser_header_Z.rl" */
- ){
- TSK_DEBUG_ERROR("Failed to parse \"z=\" header.");
- TSK_OBJECT_SAFE_FREE(hdr_Z);
- }
-
- return hdr_Z;
-}
-
-
-
-
-
-
-
-//========================================================
-// Z header object definition
-//
-
-static tsk_object_t* tsdp_header_Z_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_header_Z_t *Z = self;
- if(Z){
- TSDP_HEADER(Z)->type = tsdp_htype_Z;
- TSDP_HEADER(Z)->tostring = tsdp_header_Z_tostring;
- TSDP_HEADER(Z)->rank = TSDP_HTYPE_Z_RANK;
-
- if((Z->zones = tsk_list_create())){
- uint64_t time = va_arg(*app, uint64_t);
- unsigned shifted_back = va_arg(*app, unsigned);
- const char* typed_time = va_arg(*app, const char*);
-
- if(typed_time){
- tsdp_zone_t *zone;
- if((zone = tsdp_zone_create(time, shifted_back, typed_time))){
- tsk_list_push_back_data(Z->zones,(void**)&zone);
- }
- }
- }
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new Z header.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_header_Z_dtor(tsk_object_t *self)
-{
- tsdp_header_Z_t *Z = self;
- if(Z){
- TSK_OBJECT_SAFE_FREE(Z->zones);
- }
- else{
- TSK_DEBUG_ERROR("Null Z header.");
- }
-
- return self;
-}
-static int tsdp_header_Z_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
-{
- if(obj1 && obj2){
- return tsdp_header_rank_cmp(obj1, obj2);
- }
- else{
- return -1;
- }
-}
-
-static const tsk_object_def_t tsdp_header_Z_def_s =
-{
- sizeof(tsdp_header_Z_t),
- tsdp_header_Z_ctor,
- tsdp_header_Z_dtor,
- tsdp_header_Z_cmp
-};
-
-const tsk_object_def_t *tsdp_header_Z_def_t = &tsdp_header_Z_def_s;
-
-
-
-
-//========================================================
-// Zone object definition
-//
-
-static tsk_object_t* tsdp_zone_ctor(tsk_object_t *self, va_list * app)
-{
- tsdp_zone_t *zone = self;
- if(zone){
- zone->time = va_arg(*app, uint64_t);
- zone->shifted_back = va_arg(*app, tsk_bool_t);
- zone->typed_time = tsk_strdup( va_arg(*app, const char*) );
- }
- else{
- TSK_DEBUG_ERROR("Failed to create new zone object.");
- }
- return self;
-}
-
-static tsk_object_t* tsdp_zone_dtor(tsk_object_t *self)
-{
- tsdp_zone_t *zone = self;
- if(zone){
- TSK_FREE(zone->typed_time);
- }
- else{
- TSK_DEBUG_ERROR("Null zone object.");
- }
-
- return self;
-}
-
-static const tsk_object_def_t tsdp_zone_def_s =
-{
- sizeof(tsdp_zone_t),
- tsdp_zone_ctor,
- tsdp_zone_dtor,
- tsk_null
-};
-
-const tsk_object_def_t *tsdp_zone_def_t = &tsdp_zone_def_s;
diff --git a/branches/1.0/tinySDP/src/parsers/tsdp_parser_message.c b/branches/1.0/tinySDP/src/parsers/tsdp_parser_message.c
deleted file mode 100644
index b2ddb47..0000000
--- a/branches/1.0/tinySDP/src/parsers/tsdp_parser_message.c
+++ /dev/null
@@ -1,477 +0,0 @@
-
-/* #line 1 "./ragel/tsdp_parser_message.rl" */
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-/**@file tsdp_machine_message.rl
- * @brief Ragel file.
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Sat Nov 8 16:54:58 2009 mdiop
- */
-#include "tinysdp/parsers/tsdp_parser_message.h"
-
-#include "tinysdp/headers/tsdp_header_A.h"
-#include "tinysdp/headers/tsdp_header_B.h"
-#include "tinysdp/headers/tsdp_header_C.h"
-#include "tinysdp/headers/tsdp_header_Dummy.h"
-#include "tinysdp/headers/tsdp_header_E.h"
-#include "tinysdp/headers/tsdp_header_I.h"
-#include "tinysdp/headers/tsdp_header_K.h"
-#include "tinysdp/headers/tsdp_header_M.h"
-#include "tinysdp/headers/tsdp_header_O.h"
-#include "tinysdp/headers/tsdp_header_P.h"
-#include "tinysdp/headers/tsdp_header_R.h"
-#include "tinysdp/headers/tsdp_header_S.h"
-#include "tinysdp/headers/tsdp_header_T.h"
-#include "tinysdp/headers/tsdp_header_U.h"
-#include "tinysdp/headers/tsdp_header_V.h"
-#include "tinysdp/headers/tsdp_header_Z.h"
-
-#include "tsk_debug.h"
-
-
-/* #line 244 "./ragel/tsdp_parser_message.rl" */
-
-
-/* Ragel data */
-
-/* #line 59 "./src/parsers/tsdp_parser_message.c" */
-static const char _tsdp_machine_message_actions[] = {
- 0, 1, 0, 1, 1, 1, 2, 1,
- 3, 1, 4, 1, 5, 1, 6, 1,
- 7, 1, 8, 1, 9, 1, 10, 1,
- 11, 1, 12, 1, 13, 1, 14, 1,
- 15, 1, 16
-};
-
-static const char _tsdp_machine_message_key_offsets[] = {
- 0, 0, 2, 3, 4, 6, 7, 9,
- 10, 12, 13, 15, 16, 18, 19, 21,
- 22, 24, 25, 27, 28, 30, 31, 33,
- 34, 36, 37, 39, 40, 42, 43, 45,
- 46, 48, 49
-};
-
-static const char _tsdp_machine_message_trans_keys[] = {
- 32, 61, 13, 10, 32, 61, 13, 32,
- 61, 13, 32, 61, 13, 32, 61, 13,
- 32, 61, 13, 32, 61, 13, 32, 61,
- 13, 32, 61, 13, 32, 61, 13, 32,
- 61, 13, 32, 61, 13, 32, 61, 13,
- 32, 61, 13, 32, 61, 13, 32, 61,
- 13, 65, 66, 67, 69, 73, 75, 77,
- 79, 80, 82, 83, 84, 85, 86, 90,
- 97, 98, 99, 101, 105, 107, 109, 111,
- 112, 114, 115, 116, 117, 118, 122, 68,
- 89, 100, 121, 0
-};
-
-static const char _tsdp_machine_message_single_lengths[] = {
- 0, 2, 1, 1, 2, 1, 2, 1,
- 2, 1, 2, 1, 2, 1, 2, 1,
- 2, 1, 2, 1, 2, 1, 2, 1,
- 2, 1, 2, 1, 2, 1, 2, 1,
- 2, 1, 30
-};
-
-static const char _tsdp_machine_message_range_lengths[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 2
-};
-
-static const char _tsdp_machine_message_index_offsets[] = {
- 0, 0, 3, 5, 7, 10, 12, 15,
- 17, 20, 22, 25, 27, 30, 32, 35,
- 37, 40, 42, 45, 47, 50, 52, 55,
- 57, 60, 62, 65, 67, 70, 72, 75,
- 77, 80, 82
-};
-
-static const char _tsdp_machine_message_trans_targs[] = {
- 1, 2, 0, 3, 2, 34, 0, 4,
- 5, 0, 3, 5, 6, 7, 0, 3,
- 7, 8, 9, 0, 3, 9, 10, 11,
- 0, 3, 11, 12, 13, 0, 3, 13,
- 14, 15, 0, 3, 15, 16, 17, 0,
- 3, 17, 18, 19, 0, 3, 19, 20,
- 21, 0, 3, 21, 22, 23, 0, 3,
- 23, 24, 25, 0, 3, 25, 26, 27,
- 0, 3, 27, 28, 29, 0, 3, 29,
- 30, 31, 0, 3, 31, 32, 33, 0,
- 3, 33, 1, 4, 6, 10, 12, 14,
- 16, 18, 20, 22, 24, 26, 28, 30,
- 32, 1, 4, 6, 10, 12, 14, 16,
- 18, 20, 22, 24, 26, 28, 30, 32,
- 8, 8, 0, 0
-};
-
-static const char _tsdp_machine_message_trans_actions[] = {
- 0, 0, 0, 3, 0, 0, 0, 0,
- 0, 0, 5, 0, 0, 0, 0, 7,
- 0, 0, 0, 0, 9, 0, 0, 0,
- 0, 11, 0, 0, 0, 0, 13, 0,
- 0, 0, 0, 15, 0, 0, 0, 0,
- 17, 0, 0, 0, 0, 19, 0, 0,
- 0, 0, 21, 0, 0, 0, 0, 23,
- 0, 0, 0, 0, 25, 0, 0, 0,
- 0, 27, 0, 0, 0, 0, 29, 0,
- 0, 0, 0, 31, 0, 0, 0, 0,
- 33, 0, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 0, 0
-};
-
-static const int tsdp_machine_message_start = 34;
-static const int tsdp_machine_message_first_final = 34;
-static const int tsdp_machine_message_error = 0;
-
-static const int tsdp_machine_message_en_main = 34;
-
-
-/* #line 248 "./ragel/tsdp_parser_message.rl" */
-
-tsdp_message_t* tsdp_message_parse(const void *input, tsk_size_t size)
-{
- tsdp_message_t* sdp_msg = tsk_null;
- const char* tag_start = tsk_null;
- tsdp_header_t *header = tsk_null;
- tsdp_header_T_t *hdr_T = tsk_null;
- tsdp_header_M_t *hdr_M = tsk_null;
-
- /* Ragel variables */
- int cs = 0;
- const char* p = input;
- const char* pe = p + size;
- const char* eof = tsk_null;
-
- if(!input || !size){
- TSK_DEBUG_ERROR("Null or empty buffer.");
- goto bail;
- }
-
- if(!(sdp_msg = tsdp_message_create())){
- goto bail;
- }
-
- /* Ragel init */
-
-/* #line 184 "./src/parsers/tsdp_parser_message.c" */
- {
- cs = tsdp_machine_message_start;
- }
-
-/* #line 274 "./ragel/tsdp_parser_message.rl" */
-
- /* Ragel execute */
-
-/* #line 193 "./src/parsers/tsdp_parser_message.c" */
- {
- int _klen;
- unsigned int _trans;
- const char *_acts;
- unsigned int _nacts;
- const char *_keys;
-
- if ( p == pe )
- goto _test_eof;
- if ( cs == 0 )
- goto _out;
-_resume:
- _keys = _tsdp_machine_message_trans_keys + _tsdp_machine_message_key_offsets[cs];
- _trans = _tsdp_machine_message_index_offsets[cs];
-
- _klen = _tsdp_machine_message_single_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + _klen - 1;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + ((_upper-_lower) >> 1);
- if ( (*p) < *_mid )
- _upper = _mid - 1;
- else if ( (*p) > *_mid )
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- goto _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _tsdp_machine_message_range_lengths[cs];
- if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_mid;
- const char *_upper = _keys + (_klen<<1) - 2;
- while (1) {
- if ( _upper < _lower )
- break;
-
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
- if ( (*p) < _mid[0] )
- _upper = _mid - 2;
- else if ( (*p) > _mid[1] )
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys)>>1);
- goto _match;
- }
- }
- _trans += _klen;
- }
-
-_match:
- cs = _tsdp_machine_message_trans_targs[_trans];
-
- if ( _tsdp_machine_message_trans_actions[_trans] == 0 )
- goto _again;
-
- _acts = _tsdp_machine_message_actions + _tsdp_machine_message_trans_actions[_trans];
- _nacts = (unsigned int) *_acts++;
- while ( _nacts-- > 0 )
- {
- switch ( *_acts++ )
- {
- case 0:
-/* #line 58 "./ragel/tsdp_parser_message.rl" */
- {
- tag_start = p;
- }
- break;
- case 1:
-/* #line 65 "./ragel/tsdp_parser_message.rl" */
- {
- if(hdr_M){
- if(!hdr_M->Attributes){
- hdr_M->Attributes = tsk_list_create();
- }
- if((header = (tsdp_header_t*)tsdp_header_A_parse(tag_start, (p - tag_start)))){
- tsk_list_push_back_data(hdr_M->Attributes, (void**)&header);
- }
- }
- else if((header = (tsdp_header_t*)tsdp_header_A_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- break;
- case 2:
-/* #line 80 "./ragel/tsdp_parser_message.rl" */
- {
- if(hdr_M){
- if(!hdr_M->Bandwidths){
- hdr_M->Bandwidths = tsk_list_create();
- }
- if((header = (tsdp_header_t*)tsdp_header_B_parse(tag_start, (p - tag_start)))){
- tsk_list_push_back_data(hdr_M->Bandwidths, (void**)&header);
- }
- }
- else if((header = (tsdp_header_t*)tsdp_header_B_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- break;
- case 3:
-/* #line 95 "./ragel/tsdp_parser_message.rl" */
- {
- if(hdr_M && !hdr_M->C){
- hdr_M->C = tsdp_header_C_parse(tag_start, (p - tag_start));
- }
- else if((header = (tsdp_header_t*)tsdp_header_C_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- break;
- case 4:
-/* #line 105 "./ragel/tsdp_parser_message.rl" */
- {
- if((header = (tsdp_header_t*)tsdp_header_Dummy_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- break;
- case 5:
-/* #line 112 "./ragel/tsdp_parser_message.rl" */
- {
- if((header = (tsdp_header_t*)tsdp_header_E_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- break;
- case 6:
-/* #line 119 "./ragel/tsdp_parser_message.rl" */
- {
- if(hdr_M && !hdr_M->I){
- hdr_M->I = tsdp_header_I_parse(tag_start, (p - tag_start));
- }
- else if((header = (tsdp_header_t*)tsdp_header_I_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- break;
- case 7:
-/* #line 129 "./ragel/tsdp_parser_message.rl" */
- {
- if(hdr_M && !hdr_M->K){
- hdr_M->K = tsdp_header_K_parse(tag_start, (p - tag_start));
- }
- else if((header = (tsdp_header_t*)tsdp_header_K_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- break;
- case 8:
-/* #line 139 "./ragel/tsdp_parser_message.rl" */
- {
- if((hdr_M = tsdp_header_M_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, TSDP_HEADER(hdr_M));
- hdr_M = tsk_object_unref(hdr_M);
- }
- }
- break;
- case 9:
-/* #line 146 "./ragel/tsdp_parser_message.rl" */
- {
- if((header = (tsdp_header_t*)tsdp_header_O_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- break;
- case 10:
-/* #line 153 "./ragel/tsdp_parser_message.rl" */
- {
- if((header = (tsdp_header_t*)tsdp_header_P_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- break;
- case 11:
-/* #line 160 "./ragel/tsdp_parser_message.rl" */
- {
- if((header = (tsdp_header_t*)tsdp_header_R_parse(tag_start, (p - tag_start)))){
- if(hdr_T){
- if(!hdr_T->repeat_fields){
- hdr_T->repeat_fields = tsk_list_create();
- }
- tsk_list_push_back_data(hdr_T->repeat_fields, (void**)&header);
- }
- else{
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- }
- break;
- case 12:
-/* #line 175 "./ragel/tsdp_parser_message.rl" */
- {
- if((header = (tsdp_header_t*)tsdp_header_S_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- break;
- case 13:
-/* #line 182 "./ragel/tsdp_parser_message.rl" */
- {
- if((hdr_T = tsdp_header_T_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, TSDP_HEADER(hdr_T));
- hdr_T = tsk_object_unref(hdr_T);
- }
- }
- break;
- case 14:
-/* #line 189 "./ragel/tsdp_parser_message.rl" */
- {
- if((header = (tsdp_header_t*)tsdp_header_U_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- break;
- case 15:
-/* #line 196 "./ragel/tsdp_parser_message.rl" */
- {
- if((header = (tsdp_header_t*)tsdp_header_V_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- break;
- case 16:
-/* #line 203 "./ragel/tsdp_parser_message.rl" */
- {
- if((header = (tsdp_header_t*)tsdp_header_Z_parse(tag_start, (p - tag_start)))){
- tsdp_message_add_header(sdp_msg, header);
- tsk_object_unref(header);
- }
- }
- break;
-/* #line 449 "./src/parsers/tsdp_parser_message.c" */
- }
- }
-
-_again:
- if ( cs == 0 )
- goto _out;
- if ( ++p != pe )
- goto _resume;
- _test_eof: {}
- _out: {}
- }
-
-/* #line 277 "./ragel/tsdp_parser_message.rl" */
-
- /* Check result */
- if( cs <
-/* #line 466 "./src/parsers/tsdp_parser_message.c" */
-34
-/* #line 279 "./ragel/tsdp_parser_message.rl" */
- )
- {
- TSK_DEBUG_ERROR("Failed to parse SDP message.");
- TSK_OBJECT_SAFE_FREE(sdp_msg);
- goto bail;
- }
-
-bail:
- return sdp_msg;
-}
diff --git a/branches/1.0/tinySDP/src/tsdp.c b/branches/1.0/tinySDP/src/tsdp.c
deleted file mode 100644
index 5287b63..0000000
--- a/branches/1.0/tinySDP/src/tsdp.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-/**@file tsdp.c
- * @brief SDP (RFC 4566) implementations with both MMTel and PoC extensions.
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Sat Nov 8 16:54:58 2009 mdiop
- */
-#include "tsdp.h"
-
-#include "tinysdp/parsers/tsdp_parser_message.h"
-
-// Defined in tsdp_message.c
-extern int __pred_find_media_by_name(const tsk_list_item_t *item, const void *name);
-
-
-typedef struct tsdp_ctx_s
-{
- TSK_DECLARE_OBJECT;
-
- tsdp_message_t* local;
- tsdp_message_t* remote;
- tsdp_message_t* negotiated;
-}
-tsdp_ctx_t;
-
-const tsdp_message_t* tsdp_ctx_local_get_sdp(const tsdp_ctx_handle_t* self)
-{
- const tsdp_ctx_t* ctx = self;
-
- if(ctx){
- return ctx->local;
- }
- else return tsk_null;
-}
-
-int tsdp_ctx_local_create_sdp(tsdp_ctx_handle_t* self, const tsdp_message_t* local)
-{
- tsdp_ctx_t* ctx = self;
- tsdp_message_t* newsdp;
-
- if(!ctx || !local){
- return -1;
- }
-
- // set new local sdp
- if((newsdp = tsdp_message_clone(local))){
- TSK_OBJECT_SAFE_FREE(ctx->local);
- ctx->local = newsdp;
- return 0;
- }
- else return -2;
-}
-
-int tsdp_ctx_local_create_sdp_2(tsdp_ctx_handle_t* self, const char* sdp, tsk_size_t size)
-{
- tsdp_ctx_t* ctx = self;
- tsdp_message_t* newsdp;
-
- if(!ctx || !sdp || !size){
- return -1;
- }
-
- if((newsdp = tsdp_message_parse(sdp, size))){
- TSK_OBJECT_SAFE_FREE(ctx->local);
- ctx->local = newsdp;
- return 0;
- }
- else return -2;
-}
-
-int tsdp_ctx_local_add_headers(tsdp_ctx_handle_t* self, ...)
-{
- tsdp_ctx_t* ctx = self;
- const tsk_object_def_t* objdef;
- tsdp_header_t *header;
- va_list ap;
-
- if(!ctx || !ctx->local){
- return -1;
- }
-
- va_start(ap, self);
- while((objdef = va_arg(ap, const tsk_object_def_t*))){
- if((header = tsk_object_new_2(objdef, &ap))){
- tsdp_message_add_header(ctx->local, header);
- TSK_OBJECT_SAFE_FREE(header);
- }
- }
- va_end(ap);
-
- return 0;
-}
-
-int tsdp_ctx_local_add_media(tsdp_ctx_handle_t* self, const tsdp_header_M_t* media)
-{
- tsdp_ctx_t* ctx = self;
-
- if(!ctx || !media){
- return -1;
- }
-
- if(ctx->local){
- return tsdp_message_add_header(ctx->local, TSDP_HEADER(media));
- }
- else return -2;
-}
-
-int tsdp_ctx_local_add_media_2(tsdp_ctx_handle_t* self, const char* media, uint32_t port, const char* proto, ...)
-{
- tsdp_ctx_t* ctx = self;
- va_list ap;
-
- if(!ctx || !media || !proto){
- return -1;
- }
-
- if(ctx->local){
- int ret;
- va_start(ap, proto);
- ret = tsdp_message_add_media_2(ctx->local, media, port, proto, &ap);
- va_end(ap);
- return ret;
- }
- else return -2;
-}
-
-const tsdp_message_t* tsdp_ctx_remote_get_sdp(const tsdp_ctx_handle_t* self)
-{
- const tsdp_ctx_t* ctx = self;
-
- if(ctx){
- return ctx->remote;
- }
- else return tsk_null;
-}
-
-const tsdp_message_t* tsdp_ctx_negotiated_get_sdp(const tsdp_ctx_handle_t* self)
-{
- const tsdp_ctx_t* ctx = self;
-
- if(ctx){
- return ctx->negotiated;
- }
- else return tsk_null;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-//=================================================================================================
-// Sdp ctx object definition
-//
-static void* tsdp_ctx_create(void * self, va_list * app)
-{
- tsdp_ctx_t *ctx = self;
- if(ctx){
- }
- return self;
-}
-
-static void* tsdp_ctx_destroy(void * self)
-{
- tsdp_ctx_t *ctx = self;
- if(ctx){
- TSK_OBJECT_SAFE_FREE(ctx->local);
- TSK_OBJECT_SAFE_FREE(ctx->remote);
- TSK_OBJECT_SAFE_FREE(ctx->negotiated);
- }
- return self;
-}
-
-static const tsk_object_def_t tsdp_ctx_def_s =
-{
- sizeof(tsdp_ctx_t),
- tsdp_ctx_create,
- tsdp_ctx_destroy,
- tsk_null,
-};
-const tsk_object_def_t *tsdp_ctx_def_t = &tsdp_ctx_def_s;
diff --git a/branches/1.0/tinySDP/src/tsdp_message.c b/branches/1.0/tinySDP/src/tsdp_message.c
deleted file mode 100644
index 646bf11..0000000
--- a/branches/1.0/tinySDP/src/tsdp_message.c
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
-* Copyright (C) 2009-2010 Mamadou Diop.
-*
-* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
-* This file is part of Open Source Doubango Framework.
-*
-* DOUBANGO 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.
-*
-* DOUBANGO 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 DOUBANGO.
-*
-*/
-
-/**@file tsdp_message.c
- * @brief SDP message.
- *
- * @author Mamadou Diop <diopmamadou(at)doubango.org>
- *
- * @date Created: Sat Nov 8 16:54:58 2009 mdiop
- */
-
-#include "tinysdp/tsdp_message.h"
-
-#include "tinysdp/headers/tsdp_header_O.h"
-#include "tinysdp/headers/tsdp_header_S.h"
-#include "tinysdp/headers/tsdp_header_T.h"
-#include "tinysdp/headers/tsdp_header_V.h"
-
-#include "tsk_debug.h"
-
-#define TSDP_LINE_S_VALUE_DEFAULT "-" /* as per RFC 3264 subclause 5 */
-
-#define TSDP_LINE_O_USERNAME_DEFAULT "doubango"
-#define TSDP_LINE_O_SESSION_VER_DEFAULT 2301
-#define TSDP_LINE_O_SESSION_ID_DEFAULT 1983
-
-/*== Predicate function to find tsdp_header_t object by type. */
-static int __pred_find_header_by_type(const tsk_list_item_t *item, const void *tsdp_htype)
-{
- if(item && item->data){
- tsdp_header_t *header = item->data;
- tsdp_header_type_t htype = *((tsdp_header_type_t*)tsdp_htype);
- return (header->type - htype);
- }
- return -1;
-}
-
-/*== Predicate function to find tsdp_header_t object by name. */
-static int __pred_find_header_by_name(const tsk_list_item_t *item, const void *name)
-{
- if(item && item->data && name){
- tsdp_header_t *header = item->data;
- return tsdp_header_get_nameex(header) - *((const char*)name);
- }
- return -1;
-}
-
-/*== Predicate function to find media object by name. */
-static int __pred_find_media_by_name(const tsk_list_item_t *item, const void *name)
-{
- if(item && item->data && name){
- tsdp_header_t *header = item->data;
- if(header->type == tsdp_htype_M){
- return tsk_stricmp(((tsdp_header_M_t*)header)->media, (const char*)name);
- }
- }
- return -1;
-}
-
-tsdp_message_t* tsdp_message_create()
-{
- return tsk_object_new(tsdp_message_def_t);
-}
-
-/*== Add headers/fmt to the media line */
-int __add_headers(tsdp_header_M_t* m, va_list *ap)
-{
- const tsk_object_def_t* objdef;
- tsdp_header_t *header;
- tsdp_fmt_t* fmt;
-
- if(!m){
- return -1;
- }
-
- while((objdef = va_arg(*ap, const tsk_object_def_t*))){
- if(objdef == tsdp_fmt_def_t){
- if((fmt = tsk_object_new_2(objdef, ap))){
- tsk_list_push_back_data(m->FMTs, (void**)&fmt);
- }
- }
- else{
- if((header = tsk_object_new_2(objdef, ap))){
- tsdp_header_M_add(m, header);
- TSK_OBJECT_SAFE_FREE(header);
- }
- }
- }
- return 0;
-}
-
-int tsdp_message_add_header(tsdp_message_t *self, const tsdp_header_t *hdr)
-{
- if(self && hdr){
- tsdp_header_t *header = tsk_object_ref((void*)hdr);
- tsk_list_push_ascending_data(self->headers, (void**)&header); // Very important: Headers MUST appear in a fixed order (see ranks def).
-
- return 0;
- }
- return -1;
-}
-
-int tsdp_message_add_headers(tsdp_message_t *self, ...)
-{
- const tsk_object_def_t* objdef;
- tsdp_header_t *header;
- va_list ap;
-
- if(!self){
- return -1;
- }
-
- va_start(ap, self);
- while((objdef = va_arg(ap, const tsk_object_def_t*))){
- if((header = tsk_object_new_2(objdef, &ap))){
- tsdp_message_add_header(self, header);
- TSK_OBJECT_SAFE_FREE(header);
- }
- }
- va_end(ap);
-
- return 0;
-}
-
-const tsdp_header_t *tsdp_message_get_headerAt(const tsdp_message_t *self, tsdp_header_type_t type, tsk_size_t index)
-{
- tsk_size_t pos = 0;
- const tsk_list_item_t *item;
- const tsdp_header_t *hdr;
-
- if(!self || !self->headers){
- return tsk_null;
- }
-
- tsk_list_foreach(item, self->headers){
- hdr = item->data;
- if(hdr->type == type){
- if(pos++ >= index){
- return hdr;
- }
- }
- }
-
- return tsk_null;
-}
-
-const tsdp_header_t *tsdp_message_get_header(const tsdp_message_t *self, tsdp_header_type_t type)
-{
- return tsdp_message_get_headerAt(self, type, 0);
-}
-
-const tsdp_header_t *tsdp_message_get_headerByName(const tsdp_message_t *self, char name)
-{
- if(self){
- return tsk_list_find_object_by_pred(self->headers, __pred_find_header_by_name, &name);
- }
- else{
- TSK_DEBUG_ERROR("Invalid parameter");
- return tsk_null;
- }
-}
-
-int tsdp_message_serialize(const tsdp_message_t *self, tsk_buffer_t *output)
-{
- const tsk_list_item_t* item;
-
- if(!self || !output){
- return -1;
- }
-
- tsk_list_foreach(item, self->headers){
- if(tsdp_header_serialize(TSDP_HEADER(item->data), output)){
- // Abort?
- }
- }
-
- return 0;
-}
-
-char* tsdp_message_tostring(const tsdp_message_t *self)
-{
- tsk_buffer_t* output = tsk_buffer_create_null();
- char* ret = tsk_null;
-
- if(!tsdp_message_serialize(self, output)){
- ret = tsk_strndup(TSK_BUFFER_DATA(output), TSK_BUFFER_SIZE(output));
- }
-
- TSK_OBJECT_SAFE_FREE(output);
- return ret;
-}
-
-tsdp_message_t* tsdp_message_create_empty(const char* addr, tsk_bool_t ipv6, uint32_t version)
-{
- tsdp_message_t* ret = 0;
-
- if(!(ret = tsdp_message_create())){
- return tsk_null;
- }
-
- /* RFC 3264 - 5 Generating the Initial Offer
- The numeric value of the session id and version in the o line MUST be
- representable with a 64 bit signed integer. The initial value of the version MUST be less than
- (2**62)-1, to avoid rollovers.
- */
- TSDP_MESSAGE_ADD_HEADER(ret, TSDP_HEADER_V_VA_ARGS(0));
- TSDP_MESSAGE_ADD_HEADER(ret, TSDP_HEADER_O_VA_ARGS(
- TSDP_LINE_O_USERNAME_DEFAULT,
- TSDP_LINE_O_SESSION_ID_DEFAULT,
- version,
- "IN",
- ipv6 ? "IP6" : "IP4",
- addr));
-
- /* RFC 3264 - 5 Generating the Initial Offer
- The SDP "s=" line conveys the subject of the session, which is
- reasonably defined for multicast, but ill defined for unicast. For
- unicast sessions, it is RECOMMENDED that it consist of a single space
- character (0x20) or a dash (-).
-
- Unfortunately, SDP does not allow the "s=" line to be empty.
- */
- TSDP_MESSAGE_ADD_HEADER(ret, TSDP_HEADER_S_VA_ARGS(TSDP_LINE_S_VALUE_DEFAULT));
-
- /* RFC 3264 - 5 Generating the Initial Offer
- The SDP "t=" line conveys the time of the session. Generally,
- streams for unicast sessions are created and destroyed through
- external signaling means, such as SIP. In that case, the "t=" line
- SHOULD have a value of "0 0".
- */
- TSDP_MESSAGE_ADD_HEADER(ret, TSDP_HEADER_T_VA_ARGS(0, 0));
-
- return ret;
-}
-
-tsdp_message_t* tsdp_message_clone(const tsdp_message_t *self)
-{
- tsdp_message_t* clone = tsk_null;
- tsk_list_item_t* item;
- tsdp_header_t* header;
-
- if(!self){
- goto bail;
- }
-
- if((clone = tsdp_message_create())){
- tsk_list_foreach(item, self->headers){
- if((header = tsdp_header_clone(TSDP_HEADER(item->data)))){
- tsk_list_push_back_data(clone->headers, (void**)&header);
- }
- }
- }
-
-
-bail:
- return clone;
-}
-
-int tsdp_message_add_media(tsdp_message_t *self, const char* media, uint32_t port, const char* proto, ...)
-{
- va_list ap;
- int ret;
-
- va_start(ap, proto);
- ret = tsdp_message_add_media_2(self, media, port, proto, &ap);
- va_end(ap);
-
- return ret;
-}
-
-int tsdp_message_add_media_2(tsdp_message_t *self, const char* media, uint32_t port, const char* proto, va_list *ap)
-{
- int ret = -1;
- tsdp_header_M_t* m;
-
- if(!self){
- return -1;
- }
-
- if((m = tsdp_header_M_create(media, port, proto))){
- __add_headers(m, ap);
-
- ret = tsdp_message_add_header(self, TSDP_HEADER(m));
- TSK_OBJECT_SAFE_FREE(m);
- }
-
- return ret;
-}
-
-int tsdp_message_remove_media(tsdp_message_t *self, const char* media)
-{
- int ret = -1;
-
- if(!self){
- goto bail;
- }
-
- tsk_list_remove_item_by_pred(self->headers, __pred_find_media_by_name, media);
-
-bail:
- return ret;
-}
-
-
-
-/* ================= 3GPP TS 34.610 :: Communication HOLD (HOLD) using IP Multimedia (IM) Core ================*/
-int tsdp_message_hold(tsdp_message_t* self, const char* media)
-{
- tsdp_header_M_t* M;
- const tsk_list_item_t* item;
-
- if(!self){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
- // 3GPP TS 34.610-900 - 4.5.2.1 Actions at the invoking UE
- if((item = tsk_list_find_item_by_pred(self->headers, __pred_find_media_by_name, media))){
- M = TSDP_HEADER_M(item->data);
- tsdp_header_M_hold(M, tsk_true);
- }
-
- return 0;
-}
-
-int tsdp_message_resume(tsdp_message_t* self, const char* media)
-{
- tsdp_header_M_t* M;
- const tsk_list_item_t* item;
-
- if(!self){
- TSK_DEBUG_ERROR("Invalid parameter");
- return -1;
- }
- // 3GPP TS 34.610-900 - 4.5.2.1 Actions at the invoking UE
- if((item = tsk_list_find_item_by_pred(self->headers, __pred_find_media_by_name, media))){
- M = TSDP_HEADER_M(item->data);
- tsdp_header_M_resume(M, tsk_true);
- }
-
- return 0;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-//=================================================================================================
-// SDP object definition
-//
-static void* tsdp_message_ctor(void * self, va_list * app)
-{
- tsdp_message_t *message = self;
- if(message){
- message->headers = tsk_list_create();
- }
- return self;
-}
-
-static void* tsdp_message_dtor(void * self)
-{
- tsdp_message_t *message = self;
- if(message){
- TSK_OBJECT_SAFE_FREE(message->headers);
- }
- return self;
-}
-
-static const tsk_object_def_t tsdp_message_def_s =
-{
- sizeof(tsdp_message_t),
- tsdp_message_ctor,
- tsdp_message_dtor,
- tsk_null,
-};
-const tsk_object_def_t *tsdp_message_def_t = &tsdp_message_def_s;
OpenPOWER on IntegriCloud