summaryrefslogtreecommitdiffstats
path: root/tinyMSRP/ragel
diff options
context:
space:
mode:
Diffstat (limited to 'tinyMSRP/ragel')
-rw-r--r--tinyMSRP/ragel/tmsrp_machine_utils.rl118
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_Authentication-Info.rl0
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_Authorization.rl0
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_Byte-Range.rl189
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_Content-Type.rl178
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_Dummy.rl161
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_Expires.rl154
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_Failure-Report.rl154
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_From-Path.rl197
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_Max-Expires.rl154
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_Message-ID.rl157
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_Min-Expires.rl154
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_Status.rl177
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_Success-Report.rl149
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_To-Path.rl196
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_header_Use-Path.rl180
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_message.rl354
-rw-r--r--tinyMSRP/ragel/tmsrp_parser_uri.rl134
18 files changed, 2806 insertions, 0 deletions
diff --git a/tinyMSRP/ragel/tmsrp_machine_utils.rl b/tinyMSRP/ragel/tmsrp_machine_utils.rl
new file mode 100644
index 0000000..91125b8
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_machine_utils.rl
@@ -0,0 +1,118 @@
+/*
+* Copyright (C) 2009 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 tsip_machine_utils.rl
+ * @brief Ragel file.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+%%{
+
+ machine tmsrp_machine_utils;
+
+ OCTET = "0x"[0-9A-Fa-f]+;
+ CHAR = 0x01..0x7f;
+ VCHAR = 0x21..0x7e;
+ ALPHA = 0x41..0x5a | 0x61..0x7a;
+ DIGIT = 0x30..0x39;
+ CTL = 0x00..0x1f | 0x7f;
+ HTAB = "\t";
+ LF = "\n";
+ CR = "\r";
+ SP = " ";
+ DQUOTE = "\"";
+ BIT = "0" | "1";
+ HEXDIG = DIGIT | "A"i | "B"i | "C"i | "D"i | "E"i | "F"i;
+ CRLF = CR LF;
+ WSP = SP | HTAB;
+ LWSP = ( WSP | ( CRLF WSP ) )*;
+ LWS = ( WSP* CRLF )? WSP+;
+ SWS = LWS?;
+ EQUAL = SWS "=" SWS;
+ LHEX = DIGIT | 0x61..0x66;
+ HCOLON = ( SP | HTAB )* ":" SWS;
+ separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\\" | DQUOTE | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HTAB;
+ STAR = SWS "*" SWS;
+ SLASH = SWS "/" SWS;
+ LPAREN = SWS "(" SWS;
+ RPAREN = SWS ")" SWS;
+ COMMA = SWS "," SWS;
+ SEMI = SWS ";" SWS;
+ COLON = SWS ":" SWS;
+ LAQUOT = SWS "<";
+ LDQUOT = SWS DQUOTE;
+ RAQUOT = ">" SWS;
+ RDQUOT = DQUOTE SWS;
+ UTF8_CONT = 0x80..0xbf;
+ ##### FIXME: UTF8_NONASCII up to 2bytes will fail on Android
+ UTF8_NONASCII = ( 0x80..0xff );
+ #UTF8_NONASCII = ( 0xc0..0xdf UTF8_CONT ) | ( 0xe0..0xef UTF8_CONT{2} ) | ( 0xf0..0xf7 UTF8_CONT{3} ) | ( 0xf8..0xfb UTF8_CONT{4} ) | ( 0xfc..0xfd UTF8_CONT{5} ); ctext = 0x21..0x27 | 0x2a..0x5b | 0x5d..0x7e | UTF8_NONASCII | LWS;
+ qvalue = ( "0" ( "." DIGIT{,3} )? ) | ( "1" ( "." "0"{,3} )? );
+ alphanum = ALPHA | DIGIT;
+ token = ( alphanum | "-" | "." | "!" | "%" | "*" | "_" | "+" | "`" | "'" | "~" )+;
+ ietf_token = token;
+ x_token = "x-"i token;
+ iana_token = token;
+ token_nodot = ( alphanum | "-" | "!" | "%" | "*" | "_" | "+" | "`" | "'" | "~" )+;
+ word = ( alphanum | "-" | "." | "!" | "%" | "*" | "_" | "+" | "`" | "'" | "~" | "(" | ")" | "<" | ">" | ":" | "\\" | DQUOTE | "/" | "[" | "]" | "?" | "{" | "}" )+;
+ domainlabel = alphanum | ( alphanum ( alphanum | "-" )* alphanum );
+ toplabel = ALPHA | ( ALPHA ( alphanum | "-" )* alphanum );
+ hostname = ( domainlabel "." )* toplabel "."?;
+ IPv4address = DIGIT{1,3} "." DIGIT{1,3} "." DIGIT{1,3} "." DIGIT{1,3};
+ hex4 = HEXDIG{1,4};
+ hexseq = hex4 ( ":" hex4 )*;
+ hexpart = hexseq | ( hexseq "::" hexseq? ) | ( "::" hexseq? );
+ IPv6address = hexpart ( ":" IPv4address )?;
+ IPv6reference = "[" IPv6address "]";
+ host = hostname | IPv4address | IPv6reference;
+ qdtext = LWS | "!" | 0x23..0x5b | 0x5d..0x7e | UTF8_NONASCII;
+ quoted_pair = "\\" ( 0x00..0x09 | 0x0b..0x0c | 0x0e..0x7f );
+ quoted_string = SWS DQUOTE ( qdtext | quoted_pair )* DQUOTE;
+ gen_value = token | host | quoted_string;
+ generic_param = token ( EQUAL gen_value )?;
+ accept_param = ( "q"i EQUAL qvalue ) | generic_param;
+ mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")";
+ unreserved = alphanum | mark;
+ escaped = "%" HEXDIG HEXDIG;
+ user_unreserved = "&" | "=" | "+" | "$" | "," | ";" | "?" | "/";
+ user = ( unreserved | escaped | user_unreserved )+;
+ visual_separator = "-" | "." | "(" | ")";
+ phonedigit = DIGIT | visual_separator?;
+ global_number_digits = "+" phonedigit* DIGIT phonedigit*;
+ param_unreserved = "[" | "]" | "/" | ":" | "&" | "+" | "$";
+ pct_encoded = "%" HEXDIG HEXDIG;
+ paramchar = param_unreserved | unreserved | pct_encoded;
+ pname = paramchar+;
+ pvalue = paramchar+;
+ parameter = ";" pname ( "=" pvalue )?;
+ port = DIGIT+;
+
+ gen_delims = ":" | "/" | "?" | "#" | "[" | "]" | "@";
+ sub_delims = "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "=";
+ utf8text = (HTAB | 0x20..0x7e | UTF8_NONASCII)*;
+ UPALPHA = 0x41..0x5A;
+ hname = ALPHA *token;
+ hval = utf8text;
+ ident_char = alphanum | "." | "-" | "+" | "%" | "=";
+ ident = alphanum ident_char{3,31};
+}%%
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_Authentication-Info.rl b/tinyMSRP/ragel/tmsrp_parser_header_Authentication-Info.rl
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_Authentication-Info.rl
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_Authorization.rl b/tinyMSRP/ragel/tmsrp_parser_header_Authorization.rl
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_Authorization.rl
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_Byte-Range.rl b/tinyMSRP/ragel/tmsrp_parser_header_Byte-Range.rl
new file mode 100644
index 0000000..679db9f
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_Byte-Range.rl
@@ -0,0 +1,189 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_Byte_Range.c
+ * @brief MSRP 'Byte-Range' header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/headers/tmsrp_header_Byte-Range.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_header_Byte_Range;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action tag{
+ tag_start = p;
+ }
+
+ action parse_start{
+ TSK_PARSER_SET_INTEGER_EX(hdr_Byte_Range->start, int64_t, atoi64);
+ }
+
+ action parse_end{
+ if(tag_start && *tag_start == '*'){
+ hdr_Byte_Range->end = -1;
+ }
+ else{
+ TSK_PARSER_SET_INTEGER_EX(hdr_Byte_Range->end, int64_t, atoi64);
+ }
+ }
+
+ action parse_total{
+ if(tag_start && *tag_start == '*'){
+ hdr_Byte_Range->total = -1;
+ }
+ else{
+ TSK_PARSER_SET_INTEGER_EX(hdr_Byte_Range->total, int64_t, atoi64);
+ }
+ }
+
+ #// Byte-Range = "Byte-Range:" SP range-start "-" range-end "/" total
+ #//range-start = 1*DIGIT
+ #//range-end = 1*DIGIT / "*"
+ #//total = 1*DIGIT / "*"
+ Byte_Range = "Byte-Range:"i SP DIGIT+>tag %parse_start "-" (DIGIT+ | "*")>tag %parse_end "/" (DIGIT+ | "*")>tag %parse_total;
+
+ # Entry point
+ main := Byte_Range :>CRLF?;
+
+}%%
+
+tmsrp_header_Byte_Range_t* tmsrp_header_Byte_Range_create(int64_t start, int64_t end, int64_t total)
+{
+ return tsk_object_new(TMSRP_HEADER_BYTE_RANGE_VA_ARGS(start, end, total));
+}
+
+tmsrp_header_Byte_Range_t* tmsrp_header_Byte_Range_create_null()
+{
+ return tmsrp_header_Byte_Range_create(1, -1, -1);
+}
+
+int tmsrp_header_Byte_Range_tostring(const tmsrp_header_t* header, tsk_buffer_t* output)
+{
+ if(header){
+ const tmsrp_header_Byte_Range_t *Byte_Range = (const tmsrp_header_Byte_Range_t *)header;
+ tsk_istr_t start, end, total;
+
+ if(Byte_Range->start>=0){
+ tsk_itoa(Byte_Range->start, &start);
+ }
+ if(Byte_Range->end>=0){
+ tsk_itoa(Byte_Range->end, &end);
+ }
+ if(Byte_Range->total>=0){
+ tsk_itoa(Byte_Range->total, &total);
+ }
+
+ return tsk_buffer_append_2(output, "%s-%s/%s",
+ Byte_Range->start>=0 ? start : "*",
+ Byte_Range->end>=0 ? end : "*",
+ Byte_Range->total>=0 ? total : "*"
+ );
+ }
+
+ return -1;
+}
+
+tmsrp_header_Byte_Range_t *tmsrp_header_Byte_Range_parse(const char *data, tsk_size_t size)
+{
+ int cs = 0;
+ const char *p = data;
+ const char *pe = p + size;
+ const char *eof = pe;
+ tmsrp_header_Byte_Range_t *hdr_Byte_Range = tmsrp_header_Byte_Range_create_null();
+
+ const char *tag_start;
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ TSK_DEBUG_ERROR("Failed to parse 'Byte-Range' header.");
+ TSK_OBJECT_SAFE_FREE(hdr_Byte_Range);
+ }
+
+ return hdr_Byte_Range;
+}
+
+
+
+
+
+
+
+//========================================================
+// Byte_Range header object definition
+//
+
+static tsk_object_t* tmsrp_header_Byte_Range_ctor(tsk_object_t *self, va_list * app)
+{
+ tmsrp_header_Byte_Range_t *Byte_Range = self;
+ if(Byte_Range){
+ TMSRP_HEADER(Byte_Range)->type = tmsrp_htype_Byte_Range;
+ TMSRP_HEADER(Byte_Range)->tostring = tmsrp_header_Byte_Range_tostring;
+
+ Byte_Range->start = va_arg(*app, int64_t);
+ Byte_Range->end = va_arg(*app, int64_t);
+ Byte_Range->total = va_arg(*app, int64_t);
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to create new Byte-Range header.");
+ }
+ return self;
+}
+
+static tsk_object_t* tmsrp_header_Byte_Range_dtor(tsk_object_t *self)
+{
+ tmsrp_header_Byte_Range_t *Byte_Range = self;
+ if(Byte_Range){
+ }
+ else{
+ TSK_DEBUG_ERROR("Null Byte-Range header.");
+ }
+
+ return self;
+}
+
+static const tsk_object_def_t tmsrp_header_Byte_Range_def_s =
+{
+ sizeof(tmsrp_header_Byte_Range_t),
+ tmsrp_header_Byte_Range_ctor,
+ tmsrp_header_Byte_Range_dtor,
+ tsk_null
+};
+
+const tsk_object_def_t *tmsrp_header_Byte_Range_def_t = &tmsrp_header_Byte_Range_def_s;
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_Content-Type.rl b/tinyMSRP/ragel/tmsrp_parser_header_Content-Type.rl
new file mode 100644
index 0000000..dbf2246
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_Content-Type.rl
@@ -0,0 +1,178 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_Content_Type.c
+ * @brief MSRP Content-Type header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/headers/tmsrp_header_Content-Type.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/**@defgroup tmsrp_header_Content_Type_group MSRP Content_Type header.
+*/
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_header_Content_Type;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action tag{
+ tag_start = p;
+ }
+
+ action parse_value{
+ TSK_PARSER_SET_STRING(hdr_ctype->value);
+ }
+
+ action parse_param{
+ TSK_PARSER_ADD_PARAM(hdr_ctype->params);
+ }
+
+ m_parameter = (pname (EQUAL pvalue)?)>tag %parse_param;
+
+ m_type = token;
+ m_subtype = token;
+
+ media_type = (m_type SLASH m_subtype)@1 >tag %parse_value ((SEMI m_parameter)*)@0;
+
+ Content_Type = ( "Content-Type"i ) HCOLON media_type;
+
+ # Entry point
+ main := Content_Type :>CRLF?;
+
+}%%
+
+
+tmsrp_header_Content_Type_t* tmsrp_header_Content_Type_create(const char* type)
+{
+ return tsk_object_new(TMSRP_HEADER_CONTENT_TYPE_VA_ARGS(type));
+}
+
+tmsrp_header_Content_Type_t* tmsrp_header_Content_Type_create_null()
+{
+ return tmsrp_header_Content_Type_create(tsk_null);
+}
+
+int tmsrp_header_Content_Type_tostring(const tmsrp_header_t* header, tsk_buffer_t* output)
+{
+ if(header){
+ const tmsrp_header_Content_Type_t *Content_Type = (const tmsrp_header_Content_Type_t *)header;
+ const tsk_list_item_t *item;
+
+ if(Content_Type->value){
+ tsk_buffer_append(output, Content_Type->value, strlen(Content_Type->value));
+ }
+ // Params
+ tsk_list_foreach(item, Content_Type->params){
+ tsk_buffer_append(output, ";", 1);
+ tsk_params_tostring(Content_Type->params, ';', output);
+ }
+ }
+
+ return -1;
+}
+
+tmsrp_header_Content_Type_t *tmsrp_header_Content_Type_parse(const char *data, tsk_size_t size)
+{
+ int cs = 0;
+ const char *p = data;
+ const char *pe = p + size;
+ const char *eof = pe;
+ tmsrp_header_Content_Type_t *hdr_ctype = tmsrp_header_Content_Type_create_null();
+
+ const char *tag_start;
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ TSK_DEBUG_ERROR("Failed to parse 'Content-Type' header.");
+ TSK_OBJECT_SAFE_FREE(hdr_ctype);
+ }
+
+ return hdr_ctype;
+}
+
+
+
+
+
+
+
+//========================================================
+// Content_Type header object definition
+//
+
+/**@ingroup tmsrp_header_Content_Type_group
+*/
+static tsk_object_t* tmsrp_header_Content_Type_ctor(tsk_object_t *self, va_list * app)
+{
+ tmsrp_header_Content_Type_t *Content_Type = self;
+ if(Content_Type){
+ TMSRP_HEADER(Content_Type)->type = tmsrp_htype_Content_Type;
+ TMSRP_HEADER(Content_Type)->tostring = tmsrp_header_Content_Type_tostring;
+
+ Content_Type->value = tsk_strdup( va_arg(*app, const char*) );
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to create new Content_Type header.");
+ }
+ return self;
+}
+
+/**@ingroup tmsrp_header_Content_Type_group
+*/
+static tsk_object_t* tmsrp_header_Content_Type_dtor(tsk_object_t *self)
+{
+ tmsrp_header_Content_Type_t *Content_Type = self;
+ if(Content_Type){
+ TSK_FREE(Content_Type->value);
+ TSK_OBJECT_SAFE_FREE(Content_Type->params);
+ }
+ else{
+ TSK_DEBUG_ERROR("Null Content-Type header.");
+ }
+
+ return self;
+}
+
+static const tsk_object_def_t tmsrp_header_Content_Type_def_s =
+{
+ sizeof(tmsrp_header_Content_Type_t),
+ tmsrp_header_Content_Type_ctor,
+ tmsrp_header_Content_Type_dtor,
+ tsk_null
+};
+const tsk_object_def_t *tmsrp_header_Content_Type_def_t = &tmsrp_header_Content_Type_def_s; \ No newline at end of file
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_Dummy.rl b/tinyMSRP/ragel/tmsrp_parser_header_Dummy.rl
new file mode 100644
index 0000000..6f1dbb0
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_Dummy.rl
@@ -0,0 +1,161 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_Dummy.c
+ * @brief MSRP Dummy header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/headers/tmsrp_header_Dummy.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_header_Dummy;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action tag{
+ tag_start = p;
+ }
+
+ action parse_hname{
+ TSK_PARSER_SET_STRING(hdr_Dummy->name);
+ }
+
+ action parse_hval{
+ TSK_PARSER_SET_STRING(hdr_Dummy->value);
+ }
+
+ #//hname ":" SP hval CRLF
+ Dummy = hname>tag %parse_hname :>SP* ":" SP*<: hval>tag %parse_hval;
+
+ # Entry point
+ main := Dummy :>CRLF?;
+
+}%%
+
+
+tmsrp_header_Dummy_t* tmsrp_header_Dummy_create(const char* name, const char* value)
+{
+ return tsk_object_new(TMSRP_HEADER_DUMMY_VA_ARGS(name, value));
+}
+
+tmsrp_header_Dummy_t* tmsrp_header_Dummy_create_null()
+{
+ return tmsrp_header_Dummy_create(tsk_null, tsk_null);
+}
+
+int tmsrp_header_Dummy_tostring(const tmsrp_header_t* header, tsk_buffer_t* output)
+{
+ if(header){
+ const tmsrp_header_Dummy_t *Dummy = (const tmsrp_header_Dummy_t *)header;
+ if(Dummy->value){
+ return tsk_buffer_append(output, Dummy->value, strlen(Dummy->value));
+ }
+ return 0;
+ }
+
+ return -1;
+}
+
+tmsrp_header_Dummy_t *tmsrp_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;
+ tmsrp_header_Dummy_t *hdr_Dummy = tmsrp_header_Dummy_create_null();
+
+ const char *tag_start;
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ 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* tmsrp_header_Dummy_ctor(tsk_object_t *self, va_list * app)
+{
+ tmsrp_header_Dummy_t *Dummy = self;
+ if(Dummy){
+ TMSRP_HEADER(Dummy)->type = tmsrp_htype_Dummy;
+ TMSRP_HEADER(Dummy)->tostring = tmsrp_header_Dummy_tostring;
+
+ Dummy->name = tsk_strdup(va_arg(*app, const char*));
+ 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* tmsrp_header_Dummy_dtor(tsk_object_t *self)
+{
+ tmsrp_header_Dummy_t *Dummy = self;
+ if(Dummy){
+ TSK_FREE(Dummy->name);
+ TSK_FREE(Dummy->value);
+ }
+ else{
+ TSK_DEBUG_ERROR("Null Dummy header.");
+ }
+
+ return self;
+}
+
+static const tsk_object_def_t tmsrp_header_Dummy_def_s =
+{
+ sizeof(tmsrp_header_Dummy_t),
+ tmsrp_header_Dummy_ctor,
+ tmsrp_header_Dummy_dtor,
+ tsk_null
+};
+
+const tsk_object_def_t *tmsrp_header_Dummy_def_t = &tmsrp_header_Dummy_def_s;
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_Expires.rl b/tinyMSRP/ragel/tmsrp_parser_header_Expires.rl
new file mode 100644
index 0000000..50dd9be
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_Expires.rl
@@ -0,0 +1,154 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_Expires.c
+ * @brief MSRP 'Expires' header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/headers/tmsrp_header_Expires.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_header_Expires;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action tag{
+ tag_start = p;
+ }
+
+ action parse_value{
+ TSK_PARSER_SET_INTEGER_EX(hdr_Expires->value, int64_t, atoi64)
+ }
+
+ #// "Expires:" SP 1*DIGIT
+ Expires = "Expires:"i SP DIGIT+>tag %parse_value;
+
+ # Entry point
+ main := Expires :>CRLF?;
+
+}%%
+
+
+tmsrp_header_Expires_t* tmsrp_header_Expires_create(int64_t value)
+{
+ return tsk_object_new(TMSRP_HEADER_EXPIRES_VA_ARGS(value));
+}
+
+tmsrp_header_Expires_t* tmsrp_header_Expires_create_null()
+{
+ return tmsrp_header_Expires_create(-1);
+}
+
+int tmsrp_header_Expires_tostring(const tmsrp_header_t* header, tsk_buffer_t* output)
+{
+ if(header){
+ const tmsrp_header_Expires_t *Expires = (const tmsrp_header_Expires_t *)header;
+ if(Expires->value>=0){
+ return tsk_buffer_append_2(output, "%lld", Expires->value);
+ }
+ return 0;
+ }
+
+ return -1;
+}
+
+tmsrp_header_Expires_t *tmsrp_header_Expires_parse(const char *data, tsk_size_t size)
+{
+ int cs = 0;
+ const char *p = data;
+ const char *pe = p + size;
+ const char *eof = pe;
+ tmsrp_header_Expires_t *hdr_Expires = tmsrp_header_Expires_create_null();
+
+ const char *tag_start;
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ TSK_DEBUG_ERROR("Failed to parse 'Expires' header.");
+ TSK_OBJECT_SAFE_FREE(hdr_Expires);
+ }
+
+ return hdr_Expires;
+}
+
+
+
+
+
+
+
+//========================================================
+// Expires header object definition
+//
+
+static tsk_object_t* tmsrp_header_Expires_ctor(tsk_object_t *self, va_list * app)
+{
+ tmsrp_header_Expires_t *Expires = self;
+ if(Expires){
+ TMSRP_HEADER(Expires)->type = tmsrp_htype_Message_ID;
+ TMSRP_HEADER(Expires)->tostring = tmsrp_header_Expires_tostring;
+
+ Expires->value = va_arg(*app, int64_t);
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to create new Expires header.");
+ }
+ return self;
+}
+
+static tsk_object_t* tmsrp_header_Expires_dtor(tsk_object_t *self)
+{
+ tmsrp_header_Expires_t *Expires = self;
+ if(Expires){
+ }
+ else{
+ TSK_DEBUG_ERROR("Null Expires header.");
+ }
+
+ return self;
+}
+
+static const tsk_object_def_t tmsrp_header_Expires_def_s =
+{
+ sizeof(tmsrp_header_Expires_t),
+ tmsrp_header_Expires_ctor,
+ tmsrp_header_Expires_dtor,
+ tsk_null
+};
+
+const tsk_object_def_t *tmsrp_header_Expires_def_t = &tmsrp_header_Expires_def_s;
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_Failure-Report.rl b/tinyMSRP/ragel/tmsrp_parser_header_Failure-Report.rl
new file mode 100644
index 0000000..72547a4
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_Failure-Report.rl
@@ -0,0 +1,154 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_Failure_Report.c
+ * @brief MSRP 'Failure-Report' header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/headers/tmsrp_header_Failure-Report.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_header_Failure_Report;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action is_yes{
+ hdr_Failure_Report->type = freport_yes;
+ }
+
+ action is_no{
+ hdr_Failure_Report->type = freport_no;
+ }
+
+ action ispartial{
+ hdr_Failure_Report->type = freport_partial;
+ }
+
+ #// "Failure-Report:" ( "yes" / "no" / "partial" )
+ Failure_Report = "Failure-Report:"i SP ("yes"i %is_yes | "no"i %is_no | "partial"i %ispartial);
+
+ # Entry point
+ main := Failure_Report :>CRLF?;
+
+}%%
+
+
+tmsrp_header_Failure_Report_t* tmsrp_header_Failure_Report_create(tmsrp_freport_type_t freport_type)
+{
+ return tsk_object_new(TMSRP_HEADER_FAILURE_REPORT_VA_ARGS(freport_type));
+}
+
+tmsrp_header_Failure_Report_t* tmsrp_header_Failure_Report_create_null()
+{
+ return tmsrp_header_Failure_Report_create(freport_yes);
+}
+
+int tmsrp_header_Failure_Report_tostring(const tmsrp_header_t* header, tsk_buffer_t* output)
+{
+ if(header){
+ const tmsrp_header_Failure_Report_t *Failure_Report = (const tmsrp_header_Failure_Report_t *)header;
+ const char* value = (Failure_Report->type == freport_yes) ? "yes" : (Failure_Report->type == freport_no ? "no" : "partial");
+ return tsk_buffer_append(output, value, strlen(value));
+ }
+
+ return -1;
+}
+
+tmsrp_header_Failure_Report_t *tmsrp_header_Failure_Report_parse(const char *data, tsk_size_t size)
+{
+ int cs = 0;
+ const char *p = data;
+ const char *pe = p + size;
+ const char *eof = pe;
+ tmsrp_header_Failure_Report_t *hdr_Failure_Report = tmsrp_header_Failure_Report_create_null();
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ TSK_DEBUG_ERROR("Failed to parse 'Failure-Report' header.");
+ TSK_OBJECT_SAFE_FREE(hdr_Failure_Report);
+ }
+
+ return hdr_Failure_Report;
+}
+
+
+
+
+
+
+
+//========================================================
+// Failure_Report header object definition
+//
+
+static tsk_object_t* tmsrp_header_Failure_Report_ctor(tsk_object_t *self, va_list * app)
+{
+ tmsrp_header_Failure_Report_t *Failure_Report = self;
+ if(Failure_Report){
+ TMSRP_HEADER(Failure_Report)->type = tmsrp_htype_Failure_Report;
+ TMSRP_HEADER(Failure_Report)->tostring = tmsrp_header_Failure_Report_tostring;
+
+ Failure_Report->type = va_arg(*app, tmsrp_freport_type_t);
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to create new Failure-Report header.");
+ }
+ return self;
+}
+
+static tsk_object_t* tmsrp_header_Failure_Report_dtor(tsk_object_t *self)
+{
+ tmsrp_header_Failure_Report_t *Failure_Report = self;
+ if(Failure_Report){
+ }
+ else{
+ TSK_DEBUG_ERROR("Null Failure-Report header.");
+ }
+
+ return self;
+}
+
+static const tsk_object_def_t tmsrp_header_Failure_Report_def_s =
+{
+ sizeof(tmsrp_header_Failure_Report_t),
+ tmsrp_header_Failure_Report_ctor,
+ tmsrp_header_Failure_Report_dtor,
+ tsk_null
+};
+
+const tsk_object_def_t *tmsrp_header_Failure_Report_def_t = &tmsrp_header_Failure_Report_def_s;
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_From-Path.rl b/tinyMSRP/ragel/tmsrp_parser_header_From-Path.rl
new file mode 100644
index 0000000..db9d18c
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_From-Path.rl
@@ -0,0 +1,197 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_From_Path.c
+ * @brief MSRP "From-Path" header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/headers/tmsrp_header_From-Path.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_header_From_Path;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action tag{
+ tag_start = p;
+ }
+
+ action parse_uri{
+ int len = (int)(p - tag_start);
+ tmsrp_uri_t* uri;
+ if((uri = tmsrp_uri_parse(tag_start, (tsk_size_t)len))){
+ if(!header->uri){
+ header->uri = uri;
+ }
+ else{
+ if(!header->otherURIs){
+ header->otherURIs = tsk_list_create();
+ }
+ tsk_list_push_back_data(header->otherURIs, ((void**) &uri));
+ }
+ }
+ }
+
+ MSRP_URI = (any -- SP)* >tag %parse_uri;
+
+ #//"From-Path:" SP MSRP-URI *( SP MSRP-URI )
+ From_Path = "From-Path:"i SP MSRP_URI (SP <:MSRP_URI)*;
+
+ # Entry point
+ main := From_Path :>CRLF?;
+
+}%%
+
+
+tmsrp_header_From_Path_t* tmsrp_header_From_Path_create(const tmsrp_uri_t* uri)
+{
+ return tsk_object_new(TMSRP_HEADER_FROM_PATH_VA_ARGS(uri));
+}
+
+tmsrp_header_From_Path_t* tmsrp_header_From_Path_create_null()
+{
+ return tmsrp_header_From_Path_create(tsk_null);
+}
+
+int tmsrp_header_From_Path_tostring(const tmsrp_header_t* header, tsk_buffer_t* output)
+{
+ if(header){
+ const tmsrp_header_From_Path_t *From_Path = (const tmsrp_header_From_Path_t *)header;
+ const tsk_list_item_t *item;
+
+ if(From_Path->uri){
+ tmsrp_uri_serialize(From_Path->uri, output);
+ }
+ tsk_list_foreach(item, From_Path->otherURIs){
+ tsk_buffer_append(output, " ", 1);
+ tmsrp_uri_serialize(TMSRP_URI(item->data), output);
+ }
+ }
+
+ return -1;
+}
+
+tmsrp_header_From_Path_t *tmsrp_header_From_Path_parse(const char *data, tsk_size_t size)
+{
+ int cs = 0;
+ const char *p = data;
+ const char *pe = p + size;
+ const char *eof = pe;
+ tmsrp_header_From_Path_t *header = tmsrp_header_From_Path_create_null();
+
+ const char *tag_start;
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ TSK_DEBUG_ERROR("Failed to parse 'From-Path' header.");
+ TSK_OBJECT_SAFE_FREE(header);
+ }
+
+ return header;
+}
+
+
+tmsrp_header_From_Path_t *tmsrp_header_From_Path_clone(const tmsrp_header_From_Path_t* From_Path)
+{
+ tmsrp_header_From_Path_t* clone = tsk_null;
+
+ if(!From_Path){
+ goto bail;
+ }
+
+ clone = tmsrp_header_From_Path_create_null();
+ clone->uri = tmsrp_uri_clone(From_Path->uri);
+ if(From_Path->otherURIs){
+ tsk_list_item_t *item;
+ clone->otherURIs = tsk_list_create();
+
+ tsk_list_foreach(item, From_Path->otherURIs){
+ tmsrp_uri_t *uri = tmsrp_uri_clone(TMSRP_URI(item->data));
+ tsk_list_push_back_data(clone->otherURIs, (void**)&uri);
+ }
+ }
+
+bail:
+ return clone;
+}
+
+
+
+
+//========================================================
+// From_Path header object definition
+//
+
+static tsk_object_t* tmsrp_header_From_Path_ctor(tsk_object_t *self, va_list * app)
+{
+ tmsrp_header_From_Path_t *From_Path = self;
+ if(From_Path){
+ TMSRP_HEADER(From_Path)->type = tmsrp_htype_From_Path;
+ TMSRP_HEADER(From_Path)->tostring = tmsrp_header_From_Path_tostring;
+
+ From_Path->uri = tsk_object_ref((void*)va_arg(*app, const tmsrp_uri_t*));
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to create new From-Path header.");
+ }
+ return self;
+}
+
+static tsk_object_t* tmsrp_header_From_Path_dtor(tsk_object_t *self)
+{
+ tmsrp_header_From_Path_t *From_Path = self;
+ if(From_Path){
+ TSK_OBJECT_SAFE_FREE(From_Path->uri);
+ TSK_OBJECT_SAFE_FREE(From_Path->otherURIs);
+ }
+ else{
+ TSK_DEBUG_ERROR("Null From-Path header.");
+ }
+
+ return self;
+}
+
+static const tsk_object_def_t tmsrp_header_From_Path_def_s =
+{
+ sizeof(tmsrp_header_From_Path_t),
+ tmsrp_header_From_Path_ctor,
+ tmsrp_header_From_Path_dtor,
+ tsk_null
+};
+
+const tsk_object_def_t *tmsrp_header_From_Path_def_t = &tmsrp_header_From_Path_def_s;
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_Max-Expires.rl b/tinyMSRP/ragel/tmsrp_parser_header_Max-Expires.rl
new file mode 100644
index 0000000..d043f8a
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_Max-Expires.rl
@@ -0,0 +1,154 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_Max_Expires.c
+ * @brief MSRP 'Max-Expires' header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/headers/tmsrp_header_Max-Expires.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_header_Max_Expires;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action tag{
+ tag_start = p;
+ }
+
+ action parse_value{
+ TSK_PARSER_SET_INTEGER_EX(hdr_Max_Expires->value, int64_t, atoi64)
+ }
+
+ #// "Max-Expires:" SP 1*DIGIT
+ Max_Expires = "Max-Expires:"i SP DIGIT+>tag %parse_value;
+
+ # Entry point
+ main := Max_Expires :>CRLF?;
+
+}%%
+
+
+tmsrp_header_Max_Expires_t* tmsrp_header_Max_Expires_create(int64_t value)
+{
+ return tsk_object_new(TMSRP_HEADER_MAX_EXPIRES_VA_ARGS(value));
+}
+
+tmsrp_header_Max_Expires_t* tmsrp_header_Max_Expires_create_null()
+{
+ return tmsrp_header_Max_Expires_create(-1);
+}
+
+int tmsrp_header_Max_Expires_tostring(const tmsrp_header_t* header, tsk_buffer_t* output)
+{
+ if(header){
+ const tmsrp_header_Max_Expires_t *Max_Expires = (const tmsrp_header_Max_Expires_t *)header;
+ if(Max_Expires->value>=0){
+ return tsk_buffer_append_2(output, "%lld", Max_Expires->value);
+ }
+ return 0;
+ }
+
+ return -1;
+}
+
+tmsrp_header_Max_Expires_t *tmsrp_header_Max_Expires_parse(const char *data, tsk_size_t size)
+{
+ int cs = 0;
+ const char *p = data;
+ const char *pe = p + size;
+ const char *eof = pe;
+ tmsrp_header_Max_Expires_t *hdr_Max_Expires = tmsrp_header_Max_Expires_create_null();
+
+ const char *tag_start;
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ TSK_DEBUG_ERROR("Failed to parse 'Max-Expires' header.");
+ TSK_OBJECT_SAFE_FREE(hdr_Max_Expires);
+ }
+
+ return hdr_Max_Expires;
+}
+
+
+
+
+
+
+
+//========================================================
+// Max-Expires header object definition
+//
+
+static tsk_object_t* tmsrp_header_Max_Expires_ctor(tsk_object_t *self, va_list * app)
+{
+ tmsrp_header_Max_Expires_t *Max_Expires = self;
+ if(Max_Expires){
+ TMSRP_HEADER(Max_Expires)->type = tmsrp_htype_Max_Expires;
+ TMSRP_HEADER(Max_Expires)->tostring = tmsrp_header_Max_Expires_tostring;
+
+ Max_Expires->value = va_arg(*app, int64_t);
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to create new Max-Expires header.");
+ }
+ return self;
+}
+
+static tsk_object_t* tmsrp_header_Max_Expires_dtor(tsk_object_t *self)
+{
+ tmsrp_header_Max_Expires_t *Max_Expires = self;
+ if(Max_Expires){
+ }
+ else{
+ TSK_DEBUG_ERROR("Null Max-Expires header.");
+ }
+
+ return self;
+}
+
+static const tsk_object_def_t tmsrp_header_Max_Expires_def_s =
+{
+ sizeof(tmsrp_header_Max_Expires_t),
+ tmsrp_header_Max_Expires_ctor,
+ tmsrp_header_Max_Expires_dtor,
+ tsk_null
+};
+
+const tsk_object_def_t *tmsrp_header_Max_Expires_def_t = &tmsrp_header_Max_Expires_def_s;
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_Message-ID.rl b/tinyMSRP/ragel/tmsrp_parser_header_Message-ID.rl
new file mode 100644
index 0000000..711cb63
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_Message-ID.rl
@@ -0,0 +1,157 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_Message_Id.c
+ * @brief MSRP 'Message-Id' header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/headers/tmsrp_header_Message-ID.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_header_Message_Id;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action tag{
+ tag_start = p;
+ }
+
+ action parse_id{
+ TSK_PARSER_SET_STRING(hdr_Message_Id->value);
+ }
+
+ #// "Message-ID:" SP ident
+ Message_Id = "Message-ID:"i SP ident>tag %parse_id;
+
+ # Entry point
+ main := Message_Id :>CRLF?;
+
+}%%
+
+
+tmsrp_header_Message_ID_t* tmsrp_header_Message_ID_create(const char* value)
+{
+ return tsk_object_new(TMSRP_HEADER_MESSAGE_ID_VA_ARGS(value));
+}
+
+tmsrp_header_Message_ID_t* tmsrp_header_Message_ID_create_null()
+{
+ return tmsrp_header_Message_ID_create(tsk_null);
+}
+
+
+int tmsrp_header_Message_ID_tostring(const tmsrp_header_t* header, tsk_buffer_t* output)
+{
+ if(header)
+ {
+ const tmsrp_header_Message_ID_t *Message_Id = (const tmsrp_header_Message_ID_t *)header;
+ if(Message_Id->value){
+ return tsk_buffer_append(output, Message_Id->value, strlen(Message_Id->value));
+ }
+ return 0;
+ }
+
+ return -1;
+}
+
+tmsrp_header_Message_ID_t *tmsrp_header_Message_ID_parse(const char *data, tsk_size_t size)
+{
+ int cs = 0;
+ const char *p = data;
+ const char *pe = p + size;
+ const char *eof = pe;
+ tmsrp_header_Message_ID_t *hdr_Message_Id = tmsrp_header_Message_ID_create_null();
+
+ const char *tag_start;
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ TSK_DEBUG_ERROR("Failed to parse 'Message-Id' header.");
+ TSK_OBJECT_SAFE_FREE(hdr_Message_Id);
+ }
+
+ return hdr_Message_Id;
+}
+
+
+
+
+
+
+
+//========================================================
+// Message_Id header object definition
+//
+
+static tsk_object_t* tmsrp_header_Message_ID_ctor(tsk_object_t *self, va_list * app)
+{
+ tmsrp_header_Message_ID_t *Message_Id = self;
+ if(Message_Id){
+ TMSRP_HEADER(Message_Id)->type = tmsrp_htype_Message_ID;
+ TMSRP_HEADER(Message_Id)->tostring = tmsrp_header_Message_ID_tostring;
+
+ Message_Id->value = tsk_strdup(va_arg(*app, const char*));
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to create new Message-Id header.");
+ }
+ return self;
+}
+
+static tsk_object_t* tmsrp_header_Message_ID_dtor(tsk_object_t *self)
+{
+ tmsrp_header_Message_ID_t *Message_Id = self;
+ if(Message_Id){
+ TSK_FREE(Message_Id->value);
+ }
+ else{
+ TSK_DEBUG_ERROR("Null Message-Id header.");
+ }
+
+ return self;
+}
+
+static const tsk_object_def_t tmsrp_header_Message_ID_def_s =
+{
+ sizeof(tmsrp_header_Message_ID_t),
+ tmsrp_header_Message_ID_ctor,
+ tmsrp_header_Message_ID_dtor,
+ tsk_null
+};
+
+const tsk_object_def_t *tmsrp_header_Message_ID_def_t = &tmsrp_header_Message_ID_def_s;
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_Min-Expires.rl b/tinyMSRP/ragel/tmsrp_parser_header_Min-Expires.rl
new file mode 100644
index 0000000..61aa3f4
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_Min-Expires.rl
@@ -0,0 +1,154 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_Min_Expires.c
+ * @brief MSRP 'Min-Expires' header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/headers/tmsrp_header_Min-Expires.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_header_Min_Expires;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action tag{
+ tag_start = p;
+ }
+
+ action parse_value{
+ TSK_PARSER_SET_INTEGER_EX(hdr_Min_Expires->value, int64_t, atoi64)
+ }
+
+ #// "Min-Expires:" SP 1*DIGIT
+ Min_Expires = "Min-Expires:"i SP DIGIT+>tag %parse_value;
+
+ # Entry point
+ main := Min_Expires :>CRLF?;
+
+}%%
+
+
+tmsrp_header_Min_Expires_t* tmsrp_header_Min_Expires_create(int64_t value)
+{
+ return tsk_object_new(TMSRP_HEADER_MIN_EXPIRES_VA_ARGS(value));
+}
+
+tmsrp_header_Min_Expires_t* tmsrp_header_Min_Expires_create_null()
+{
+ return tmsrp_header_Min_Expires_create(-1);
+}
+
+int tmsrp_header_Min_Expires_tostring(const tmsrp_header_t* header, tsk_buffer_t* output)
+{
+ if(header){
+ const tmsrp_header_Min_Expires_t *Min_Expires = (const tmsrp_header_Min_Expires_t *)header;
+ if(Min_Expires->value>=0){
+ return tsk_buffer_append_2(output, "%lld", Min_Expires->value);
+ }
+ return 0;
+ }
+
+ return -1;
+}
+
+tmsrp_header_Min_Expires_t *tmsrp_header_Min_Expires_parse(const char *data, tsk_size_t size)
+{
+ int cs = 0;
+ const char *p = data;
+ const char *pe = p + size;
+ const char *eof = pe;
+ tmsrp_header_Min_Expires_t *hdr_Min_Expires = tmsrp_header_Min_Expires_create_null();
+
+ const char *tag_start;
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ TSK_DEBUG_ERROR("Failed to parse 'Min-Expires' header.");
+ TSK_OBJECT_SAFE_FREE(hdr_Min_Expires);
+ }
+
+ return hdr_Min_Expires;
+}
+
+
+
+
+
+
+
+//========================================================
+// Min-Expires header object definition
+//
+
+static tsk_object_t* tmsrp_header_Min_Expires_ctor(tsk_object_t *self, va_list * app)
+{
+ tmsrp_header_Min_Expires_t *Min_Expires = self;
+ if(Min_Expires){
+ TMSRP_HEADER(Min_Expires)->type = tmsrp_htype_Min_Expires;
+ TMSRP_HEADER(Min_Expires)->tostring = tmsrp_header_Min_Expires_tostring;
+
+ Min_Expires->value = va_arg(*app, int64_t);
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to create new Min-Expires header.");
+ }
+ return self;
+}
+
+static tsk_object_t* tmsrp_header_Min_Expires_dtor(tsk_object_t *self)
+{
+ tmsrp_header_Min_Expires_t *Min_Expires = self;
+ if(Min_Expires){
+ }
+ else{
+ TSK_DEBUG_ERROR("Null Min-Expires header.");
+ }
+
+ return self;
+}
+
+static const tsk_object_def_t tmsrp_header_Min_Expires_def_s =
+{
+ sizeof(tmsrp_header_Min_Expires_t),
+ tmsrp_header_Min_Expires_ctor,
+ tmsrp_header_Min_Expires_dtor,
+ tsk_null
+};
+
+const tsk_object_def_t *tmsrp_header_Min_Expires_def_t = &tmsrp_header_Min_Expires_def_s;
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_Status.rl b/tinyMSRP/ragel/tmsrp_parser_header_Status.rl
new file mode 100644
index 0000000..4a57cba
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_Status.rl
@@ -0,0 +1,177 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_Status.c
+ * @brief MSRP 'Status' header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/headers/tmsrp_header_Status.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_header_Status;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action tag{
+ tag_start = p;
+ }
+
+ action parse_namespace{
+ TSK_PARSER_SET_INT(hdr_Status->_namespace);
+ }
+
+ action parse_code{
+ TSK_PARSER_SET_INT(hdr_Status->code);
+ }
+
+ action parse_reason{
+ TSK_PARSER_SET_STRING(hdr_Status->reason);
+ }
+
+ #/// @par ABNF : Status = "Status:" SP namespace SP status-code [SP text-reason]
+ #/// namespace = 3(DIGIT) ; "000" for all codes defined in RFC 4975
+ #/// text-reason = utf8text
+ Status = "Status:"i SP DIGIT{3}>tag %parse_namespace SP DIGIT{3}>tag %parse_code (SP utf8text>tag %parse_reason)?;
+
+ # Entry point
+ main := Status :>CRLF?;
+
+}%%
+
+
+
+tmsrp_header_Status_t* tmsrp_header_Status_create(short _namespace, short code, const char* reason)
+{
+ return tsk_object_new(TMSRP_HEADER_STATUS_VA_ARGS(_namespace, code, reason));
+}
+
+tmsrp_header_Status_t* tmsrp_header_Status_create_null()
+{
+ return tmsrp_header_Status_create(0, 200, tsk_null);
+}
+
+
+int tmsrp_header_Status_tostring(const tmsrp_header_t* header, tsk_buffer_t* output)
+{
+ if(header){
+ const tmsrp_header_Status_t *Status = (const tmsrp_header_Status_t *)header;
+
+ // Status: 000 200 OK
+ return tsk_buffer_append_2(output, "%.3hi %.3hi%s%s",
+ Status->_namespace,
+ Status->code,
+ Status->reason ? " " : "",
+ Status->reason ? Status->reason : ""
+ );
+ }
+
+ return -1;
+}
+
+tmsrp_header_Status_t *tmsrp_header_Status_parse(const char *data, tsk_size_t size)
+{
+ int cs = 0;
+ const char *p = data;
+ const char *pe = p + size;
+ const char *eof = pe;
+ tmsrp_header_Status_t *hdr_Status = tmsrp_header_Status_create_null();
+
+ const char *tag_start;
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ TSK_DEBUG_ERROR("Failed to parse 'Status' header.");
+ TSK_OBJECT_SAFE_FREE(hdr_Status);
+ }
+
+ return hdr_Status;
+}
+
+
+
+
+
+
+
+//========================================================
+// Status header object definition
+//
+
+static tsk_object_t* tmsrp_header_Status_ctor(tsk_object_t *self, va_list * app)
+{
+ tmsrp_header_Status_t *Status = self;
+ if(Status){
+ TMSRP_HEADER(Status)->type = tmsrp_htype_Status;
+ TMSRP_HEADER(Status)->tostring = tmsrp_header_Status_tostring;
+#if defined(__GNUC__)
+ Status->_namespace = (short)va_arg(*app, int);
+ Status->code = (short)va_arg(*app, int);
+#else
+ Status->_namespace = va_arg(*app, short);
+ Status->code = va_arg(*app, short);
+#endif
+ Status->reason = tsk_strdup( va_arg(*app, const char*) );
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to create new Status header.");
+ }
+ return self;
+}
+
+static tsk_object_t* tmsrp_header_Status_dtor(tsk_object_t *self)
+{
+ tmsrp_header_Status_t *Status = self;
+ if(Status){
+ TSK_FREE(Status->reason);
+ }
+ else{
+ TSK_DEBUG_ERROR("Null Status header.");
+ }
+
+ return self;
+}
+
+static const tsk_object_def_t tmsrp_header_Status_def_s =
+{
+ sizeof(tmsrp_header_Status_t),
+ tmsrp_header_Status_ctor,
+ tmsrp_header_Status_dtor,
+ tsk_null
+};
+
+const tsk_object_def_t *tmsrp_header_Status_def_t = &tmsrp_header_Status_def_s;
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_Success-Report.rl b/tinyMSRP/ragel/tmsrp_parser_header_Success-Report.rl
new file mode 100644
index 0000000..1c0fa72
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_Success-Report.rl
@@ -0,0 +1,149 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_Success_Report.c
+ * @brief MSRP 'Success-Report' header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/headers/tmsrp_header_Success-Report.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_header_Success_Report;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action is_yes{
+ hdr_Success_Report->yes = 1;
+ }
+
+ action is_no{
+ hdr_Success_Report->yes = 0;
+ }
+
+ #// "Success-Report:" ( "yes" / "no" )
+ Success_Report = "Success-Report:"i SP ("yes"i %is_yes | "no"i %is_no);
+
+ # Entry point
+ main := Success_Report :>CRLF?;
+
+}%%
+
+tmsrp_header_Success_Report_t* tmsrp_header_Success_Report_create(tsk_bool_t isSuccess)
+{
+ return tsk_object_new(TMSRP_HEADER_SUCCESS_REPORT_VA_ARGS(isSuccess));
+}
+
+tmsrp_header_Success_Report_t* tmsrp_header_Success_Report_create_null()
+{
+ return tmsrp_header_Success_Report_create(tsk_false);
+}
+
+int tmsrp_header_Success_Report_tostring(const tmsrp_header_t* header, tsk_buffer_t* output)
+{
+ if(header){
+ const tmsrp_header_Success_Report_t *Success_Report = (const tmsrp_header_Success_Report_t *)header;
+ const char* value = Success_Report->yes ? "yes" : "no";
+ return tsk_buffer_append(output, value, strlen(value));
+ }
+
+ return -1;
+}
+
+tmsrp_header_Success_Report_t *tmsrp_header_Success_Report_parse(const char *data, tsk_size_t size)
+{
+ int cs = 0;
+ const char *p = data;
+ const char *pe = p + size;
+ const char *eof = pe;
+ tmsrp_header_Success_Report_t *hdr_Success_Report = tmsrp_header_Success_Report_create_null();
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ TSK_DEBUG_ERROR("Failed to parse 'Success-Report' header.");
+ TSK_OBJECT_SAFE_FREE(hdr_Success_Report);
+ }
+
+ return hdr_Success_Report;
+}
+
+
+
+
+
+
+
+//========================================================
+// Success_Report header object definition
+//
+
+static tsk_object_t* tmsrp_header_Success_Report_ctor(tsk_object_t *self, va_list * app)
+{
+ tmsrp_header_Success_Report_t *Success_Report = self;
+ if(Success_Report){
+ TMSRP_HEADER(Success_Report)->type = tmsrp_htype_Success_Report;
+ TMSRP_HEADER(Success_Report)->tostring = tmsrp_header_Success_Report_tostring;
+
+ Success_Report->yes = va_arg(*app, tsk_bool_t) ? 1 : 0;
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to create new Success-Report header.");
+ }
+ return self;
+}
+
+static tsk_object_t* tmsrp_header_Success_Report_dtor(tsk_object_t *self)
+{
+ tmsrp_header_Success_Report_t *Success_Report = self;
+ if(Success_Report){
+ }
+ else{
+ TSK_DEBUG_ERROR("Null Success-Report header.");
+ }
+
+ return self;
+}
+
+static const tsk_object_def_t tmsrp_header_Success_Report_def_s =
+{
+ sizeof(tmsrp_header_Success_Report_t),
+ tmsrp_header_Success_Report_ctor,
+ tmsrp_header_Success_Report_dtor,
+ tsk_null
+};
+
+const tsk_object_def_t *tmsrp_header_Success_Report_def_t = &tmsrp_header_Success_Report_def_s;
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_To-Path.rl b/tinyMSRP/ragel/tmsrp_parser_header_To-Path.rl
new file mode 100644
index 0000000..0e6ecd1
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_To-Path.rl
@@ -0,0 +1,196 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_To_Path.c
+ * @brief MSRP "To-Path" header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/headers/tmsrp_header_To-Path.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_header_To_Path;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action tag{
+ tag_start = p;
+ }
+
+ action parse_uri{
+ int len = (int)(p - tag_start);
+ tmsrp_uri_t* uri;
+ if((uri = tmsrp_uri_parse(tag_start, (tsk_size_t)len))){
+ if(!header->uri){
+ header->uri = uri;
+ }
+ else{
+ if(!header->otherURIs){
+ header->otherURIs = tsk_list_create();
+ }
+ tsk_list_push_back_data(header->otherURIs, ((void**) &uri));
+ }
+ }
+ }
+
+ MSRP_URI = (any -- SP)* >tag %parse_uri;
+
+ #//"To-Path:" SP MSRP-URI *( SP MSRP-URI )
+ To_Path = "To-Path:"i SP MSRP_URI (SP <:MSRP_URI)*;
+
+ # Entry point
+ main := To_Path :>CRLF?;
+
+}%%
+
+tmsrp_header_To_Path_t* tmsrp_header_To_Path_create(const tmsrp_uri_t* uri)
+{
+ return tsk_object_new(TMSRP_HEADER_TO_PATH_VA_ARGS(uri));
+}
+
+tmsrp_header_To_Path_t* tmsrp_header_To_Path_create_null()
+{
+ return tmsrp_header_To_Path_create(tsk_null);
+}
+
+int tmsrp_header_To_Path_tostring(const tmsrp_header_t* header, tsk_buffer_t* output)
+{
+ if(header){
+ const tmsrp_header_To_Path_t *To_Path = (const tmsrp_header_To_Path_t *)header;
+ const tsk_list_item_t *item;
+
+ if(To_Path->uri){
+ tmsrp_uri_serialize(To_Path->uri, output);
+ }
+ tsk_list_foreach(item, To_Path->otherURIs){
+ tsk_buffer_append(output, " ", 1);
+ tmsrp_uri_serialize(TMSRP_URI(item->data), output);
+ }
+ }
+
+ return -1;
+}
+
+tmsrp_header_To_Path_t *tmsrp_header_To_Path_parse(const char *data, tsk_size_t size)
+{
+ int cs = 0;
+ const char *p = data;
+ const char *pe = p + size;
+ const char *eof = pe;
+ tmsrp_header_To_Path_t *header = tmsrp_header_To_Path_create_null();
+
+ const char *tag_start;
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ TSK_DEBUG_ERROR("Failed to parse 'To-Path' header.");
+ TSK_OBJECT_SAFE_FREE(header);
+ }
+
+ return header;
+}
+
+tmsrp_header_To_Path_t *tmsrp_header_To_Path_clone(const tmsrp_header_To_Path_t* To_Path)
+{
+ tmsrp_header_To_Path_t* clone = tsk_null;
+
+ if(!To_Path){
+ goto bail;
+ }
+
+ clone = tmsrp_header_To_Path_create_null();
+ clone->uri = tmsrp_uri_clone(To_Path->uri);
+ if(To_Path->otherURIs){
+ tsk_list_item_t *item;
+ clone->otherURIs = tsk_list_create();
+
+ tsk_list_foreach(item, To_Path->otherURIs){
+ tmsrp_uri_t *uri = tmsrp_uri_clone(TMSRP_URI(item->data));
+ tsk_list_push_back_data(clone->otherURIs, (void**)&uri);
+ }
+ }
+
+bail:
+ return clone;
+}
+
+
+
+
+
+//========================================================
+// To_Path header object definition
+//
+
+static tsk_object_t* tmsrp_header_To_Path_ctor(tsk_object_t *self, va_list * app)
+{
+ tmsrp_header_To_Path_t *To_Path = self;
+ if(To_Path){
+ TMSRP_HEADER(To_Path)->type = tmsrp_htype_To_Path;
+ TMSRP_HEADER(To_Path)->tostring = tmsrp_header_To_Path_tostring;
+
+ To_Path->uri = tsk_object_ref((void*)va_arg(*app, const tmsrp_uri_t*));
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to create new To-Path header.");
+ }
+ return self;
+}
+
+static tsk_object_t* tmsrp_header_To_Path_dtor(tsk_object_t *self)
+{
+ tmsrp_header_To_Path_t *To_Path = self;
+ if(To_Path){
+ TSK_OBJECT_SAFE_FREE(To_Path->uri);
+ TSK_OBJECT_SAFE_FREE(To_Path->otherURIs);
+ }
+ else{
+ TSK_DEBUG_ERROR("Null To-Path header.");
+ }
+
+ return self;
+}
+
+static const tsk_object_def_t tmsrp_header_To_Path_def_s =
+{
+ sizeof(tmsrp_header_To_Path_t),
+ tmsrp_header_To_Path_ctor,
+ tmsrp_header_To_Path_dtor,
+ tsk_null
+};
+
+const tsk_object_def_t *tmsrp_header_To_Path_def_t = &tmsrp_header_To_Path_def_s;
diff --git a/tinyMSRP/ragel/tmsrp_parser_header_Use-Path.rl b/tinyMSRP/ragel/tmsrp_parser_header_Use-Path.rl
new file mode 100644
index 0000000..a32cbd7
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_header_Use-Path.rl
@@ -0,0 +1,180 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_Use_Path.c
+ * @brief MSRP "Use-Path" header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/headers/tmsrp_header_Use-Path.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_header_Use_Path;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action tag{
+ tag_start = p;
+ }
+
+ action parse_uri{
+ int len = (int)(p - tag_start);
+ tmsrp_uri_t* uri;
+ if((uri = tmsrp_uri_parse(tag_start, (tsk_size_t)len))){
+ if(!header->uri){
+ header->uri = uri;
+ }
+ else{
+ if(!header->otherURIs){
+ header->otherURIs = tsk_list_create();
+ }
+ tsk_list_push_back_data(header->otherURIs, ((void**) &uri));
+ }
+ }
+ }
+
+ MSRP_URI = (any -- SP)* >tag %parse_uri;
+
+ #//"Use-Path:" SP MSRP-URI *( SP MSRP-URI )
+ Use_Path = "Use-Path:"i SP MSRP_URI (SP <:MSRP_URI)*;
+
+ # Entry point
+ main := Use_Path :>CRLF?;
+
+}%%
+
+
+
+tmsrp_header_Use_Path_t* tmsrp_header_Use_Path_create(const tmsrp_uri_t* uri)
+{
+ return tsk_object_new(TMSRP_HEADER_USE_PATH_VA_ARGS(uri));
+}
+
+tmsrp_header_Use_Path_t* tmsrp_header_Use_Path_create_null()
+{
+ return tmsrp_header_Use_Path_create(tsk_null);
+}
+
+int tmsrp_header_Use_Path_tostring(const tmsrp_header_t* header, tsk_buffer_t* output)
+{
+ if(header){
+ const tmsrp_header_Use_Path_t *Use_Path = (const tmsrp_header_Use_Path_t *)header;
+ const tsk_list_item_t *item;
+
+ if(Use_Path->uri){
+ tmsrp_uri_serialize(Use_Path->uri, output);
+ }
+ tsk_list_foreach(item, Use_Path->otherURIs){
+ tsk_buffer_append(output, " ", 1);
+ tmsrp_uri_serialize(TMSRP_URI(item->data), output);
+ }
+ }
+
+ return -1;
+}
+
+tmsrp_header_Use_Path_t *tmsrp_header_Use_Path_parse(const char *data, tsk_size_t size)
+{
+ int cs = 0;
+ const char *p = data;
+ const char *pe = p + size;
+ const char *eof = pe;
+ tmsrp_header_Use_Path_t *header = tmsrp_header_Use_Path_create_null();
+
+ const char *tag_start;
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ TSK_DEBUG_ERROR("Failed to parse 'Use-Path' header.");
+ TSK_OBJECT_SAFE_FREE(header);
+ }
+
+ return header;
+}
+
+
+
+
+
+
+
+//========================================================
+// Use_Path header object definition
+//
+
+static tsk_object_t* tmsrp_header_Use_Path_ctor(tsk_object_t *self, va_list * app)
+{
+ tmsrp_header_Use_Path_t *Use_Path = self;
+ if(Use_Path){
+ const tmsrp_uri_t* uri = va_arg(*app, const tmsrp_uri_t*);
+
+ TMSRP_HEADER(Use_Path)->type = tmsrp_htype_Use_Path;
+ TMSRP_HEADER(Use_Path)->tostring = tmsrp_header_Use_Path_tostring;
+
+ if(uri){
+ Use_Path->uri = tsk_object_ref((void*)uri);
+ }
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to create new Use-Path header.");
+ }
+ return self;
+}
+
+static tsk_object_t* tmsrp_header_Use_Path_dtor(tsk_object_t *self)
+{
+ tmsrp_header_Use_Path_t *Use_Path = self;
+ if(Use_Path){
+ TSK_OBJECT_SAFE_FREE(Use_Path->uri);
+ TSK_OBJECT_SAFE_FREE(Use_Path->otherURIs);
+ }
+ else{
+ TSK_DEBUG_ERROR("Null Use-Path header.");
+ }
+
+ return self;
+}
+
+static const tsk_object_def_t tmsrp_header_Use_Path_def_s =
+{
+ sizeof(tmsrp_header_Use_Path_t),
+ tmsrp_header_Use_Path_ctor,
+ tmsrp_header_Use_Path_dtor,
+ tsk_null
+};
+
+const tsk_object_def_t *tmsrp_header_Use_Path_def_t = &tmsrp_header_Use_Path_def_s;
diff --git a/tinyMSRP/ragel/tmsrp_parser_message.rl b/tinyMSRP/ragel/tmsrp_parser_message.rl
new file mode 100644
index 0000000..888a89a
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_message.rl
@@ -0,0 +1,354 @@
+/*
+* Copyright (C) 2009 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 tmsrp_machine_message.rl
+ * @brief Ragel file.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/parsers/tmsrp_parser_message.h"
+
+#include "tinymsrp/headers/tmsrp_header_Dummy.h"
+#include "tinymsrp/headers/tmsrp_header_Expires.h"
+#include "tinymsrp/headers/tmsrp_header_Max-Expires.h"
+#include "tinymsrp/headers/tmsrp_header_Min-Expires.h"
+#include "tinymsrp/headers/tmsrp_header_Use-Path.h"
+#include "tinymsrp/headers/tmsrp_header_WWW-Authenticate.h"
+
+#include "tsk_string.h"
+#include "tsk_memory.h"
+#include "tsk_debug.h"
+
+static tsk_bool_t parse_payload(tmsrp_message_t* msrp_msg, const char* tag_start, const char** p, const char* pe, tsk_bool_t* payload_parsed);
+static void set_payload(tmsrp_message_t* msrp_msg, const void* ptr, tsk_size_t len);
+
+#define TMSRP_MSG_PARSER_ADD_HEADER(name) \
+ if((header = (tmsrp_header_t*)tmsrp_header_##name##_parse(tag_start, (p - tag_start)))){ \
+ tmsrp_message_add_header(msrp_msg, header); \
+ header = tsk_object_unref(header); \
+ }
+%%{
+ machine tmsrp_machine_message;
+
+ ###########################################
+ # Includes
+ ###########################################
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action tag{
+ tag_start = p;
+ }
+
+ ###########################################
+ # Actions
+ ###########################################
+ action parse_Authentication_Info{
+ //FIXME: TMSRP_MSG_PARSER_ADD_HEADER(Authentication_Info);
+ TSK_DEBUG_WARN("Authentication_Info Not implemented");
+ }
+
+ action parse_Authorization{
+ //FIXME: TMSRP_MSG_PARSER_ADD_HEADER(Authorization);
+ TSK_DEBUG_WARN("Authorization Not implemented");
+ }
+
+ action parse_Byte_Range{
+ TMSRP_MSG_PARSER_ADD_HEADER(Byte_Range);
+ }
+
+ action parse_Content_Type{
+ TMSRP_MSG_PARSER_ADD_HEADER(Content_Type);
+ }
+
+ action parse_Expires{
+ TMSRP_MSG_PARSER_ADD_HEADER(Expires);
+ }
+
+ action parse_Failure_Report{
+ TMSRP_MSG_PARSER_ADD_HEADER(Failure_Report);
+ }
+
+ action parse_From_Path{
+ TMSRP_MSG_PARSER_ADD_HEADER(From_Path);
+ }
+
+ action parse_Max_Expires{
+ TMSRP_MSG_PARSER_ADD_HEADER(Max_Expires);
+ }
+
+ action parse_Message_ID{
+ TMSRP_MSG_PARSER_ADD_HEADER(Message_ID);
+ }
+
+ action parse_Min_Expires{
+ TMSRP_MSG_PARSER_ADD_HEADER(Min_Expires);
+ }
+
+ action parse_Status{
+ TMSRP_MSG_PARSER_ADD_HEADER(Status);
+ }
+
+ action parse_Success_Report{
+ TMSRP_MSG_PARSER_ADD_HEADER(Success_Report);
+ }
+
+ action parse_To_Path{
+ TMSRP_MSG_PARSER_ADD_HEADER(To_Path);
+ }
+
+ action parse_Use_Path{
+ TMSRP_MSG_PARSER_ADD_HEADER(Use_Path);
+ }
+
+ action parse_WWW_Authenticate{
+ TMSRP_MSG_PARSER_ADD_HEADER(WWW_Authenticate);
+ }
+
+ action parse_Dummy{
+ TMSRP_MSG_PARSER_ADD_HEADER(Dummy);
+ }
+
+ action parse_tid{
+ TSK_PARSER_SET_STRING(msrp_msg->tid);
+ }
+
+ action parse_method{
+ if(msrp_msg->type == tmsrp_unknown){
+ msrp_msg->type = tmsrp_request;
+ TSK_PARSER_SET_STRING(msrp_msg->line.request.method);
+ msrp_msg->line.request.type = tmsrp_request_get_type(msrp_msg->line.request.method);
+ }
+ else{
+ //cs = %%{ write first_final; }%%;
+ cs = tmsrp_machine_message_error;
+ TSK_DEBUG_ERROR("Message type already defined.");
+ }
+ }
+
+
+ action parse_status_code{
+ if(msrp_msg->type == tmsrp_unknown){
+ msrp_msg->type = tmsrp_response;
+ TSK_PARSER_SET_INT(msrp_msg->line.response.status);
+ }
+ else{
+ //cs = %%{ write first_final; }%%;
+ cs = tmsrp_machine_message_error;
+ TSK_DEBUG_ERROR("Message type already defined.");
+ }
+ }
+ action parse_comment{
+ TSK_PARSER_SET_STRING(msrp_msg->line.response.comment);
+ }
+
+
+ action try_parse_data{
+ parse_payload(msrp_msg, tag_start, &p, pe, &payload_parsed); // will update "p"
+ }
+
+ action parse_data{
+ // if the msrp message contain a valid content-type, then gob it otherwise continue until we reach the endline
+ int len;
+ if(parse_payload(msrp_msg, tag_start, &p, pe, &payload_parsed)){ // will update "p"
+ // (This space left deliberately blank)
+ }
+ else if((len = (int)(p - tag_start))>0){
+ set_payload(msrp_msg, tag_start, (tsk_size_t)len);
+ }
+ }
+
+ action parse_endtid{
+ TSK_PARSER_SET_STRING(msrp_msg->end_line.tid);
+ }
+
+ action parse_cflag{
+ if(tag_start){
+ msrp_msg->end_line.cflag = *tag_start;
+ }
+ else msrp_msg->end_line.cflag = '#';
+ }
+
+ action outside_endline{
+ *msg_size = (p - (const char*)input) + 1;
+ }
+
+ action into_endline{
+ into_endline = tsk_true;
+ }
+ action endtid_match{
+ ( into_endline || (((pe-p) >7/*seven hyphens*/) && (msrp_msg->tid) && tsk_strniequals(msrp_msg->tid, (p+7), tsk_strlen(msrp_msg->tid))) )
+ }
+
+
+ ###########################################
+ # Headers
+ ###########################################
+
+ Authentication_Info = "Authentication-Info:"i SP any* :>CRLF %parse_Authentication_Info;
+ Authorization = "Authorization:"i SP any* :>CRLF %parse_Authorization;
+ Byte_Range = "Byte-Range:"i SP any* :>CRLF %parse_Byte_Range;
+ Content_Type = "Content-Type:"i SP any* :>CRLF %parse_Content_Type;
+ Expires = "Expires:"i SP any* :>CRLF %parse_Expires;
+ Failure_Report = "Failure-Report:"i SP any* :>CRLF %parse_Failure_Report ;
+ From_Path = "From-Path:"i SP any* :>CRLF %parse_From_Path ;
+ Max_Expires = "Max-Expires:"i SP any* :>CRLF %parse_Max_Expires;
+ Message_ID = "Message-ID:"i SP any* :>CRLF %parse_Message_ID;
+ Min_Expires = "Min-Expires:"i SP any* :>CRLF %parse_Min_Expires;
+ Status = "Status:"i SP any* :>CRLF %parse_Status;
+ Success_Report = "Success-Report:"i SP any* :>CRLF %parse_Success_Report;
+ To_Path = "To-Path:"i SP any* :>CRLF %parse_To_Path;
+ Use_Path = "Use-Path:"i SP any* :>CRLF %parse_Use_Path;
+ WWW_Authenticate = "WWW-Authenticate:"i SP any* :>CRLF %parse_WWW_Authenticate;
+
+ Dummy = hname ":" SP hval :>CRLF %parse_Dummy;
+
+ header = (Authentication_Info | Authorization | Byte_Range | Content_Type | Expires | Failure_Report | From_Path | Max_Expires | Message_ID | Min_Expires | Status | Success_Report | To_Path | Use_Path | WWW_Authenticate)>tag @10 | (Dummy>tag) @0;
+
+ #headers = To_Path From_Path ( header )*;
+ headers = ( header )*;
+
+ ###########################################
+ # Utils
+ ###########################################
+ transact_id = ident;
+ method = UPALPHA*;
+ status_code = DIGIT{3};
+ comment = utf8text;
+
+ continuation_flag = "+" | "$" | "#";
+ end_line = "-------" transact_id>tag %parse_endtid continuation_flag>tag %parse_cflag CRLF;
+
+ Other_Mime_header = Dummy;
+
+ data = any*;
+
+ ###########################################
+ # Request
+ ###########################################
+ req_start = "MSRP" SP transact_id>tag %parse_tid SP method>tag %parse_method CRLF;
+ #content_stuff = (Other_Mime_header)* CRLF data>tag %parse_data :>CRLF;
+ content_stuff = data>tag >try_parse_data %parse_data;
+ msrp_request = req_start headers>10 (CRLF content_stuff CRLF)?>5 :>end_line when endtid_match >into_endline;
+
+ ###########################################
+ # Response
+ ###########################################
+ resp_start = "MSRP" SP transact_id>tag %parse_tid SP status_code>tag %parse_status_code (SP comment>tag %parse_comment)? CRLF;
+ msrp_response = resp_start headers end_line;
+
+ ###########################################
+ # Message
+ ###########################################
+ msrp_req_or_resp = (msrp_request | msrp_response)>1 @outside_endline any*>0;
+
+ ###########################################
+ # Entry Point
+ ###########################################
+ main := msrp_req_or_resp;
+}%%
+
+/* Ragel data */
+%% write data;
+
+tmsrp_message_t* tmsrp_message_parse(const void *input, tsk_size_t size)
+{
+ tsk_size_t msg_size;
+ return tmsrp_message_parse_2(input, size, &msg_size);
+}
+
+tmsrp_message_t* tmsrp_message_parse_2(const void *input, tsk_size_t size, tsk_size_t* msg_size)
+{
+ tmsrp_message_t* msrp_msg = tsk_null;
+ const char* tag_start = tsk_null;
+ tmsrp_header_t* header = tsk_null;
+ tsk_bool_t into_endline = tsk_false;
+ tsk_bool_t payload_parsed = tsk_false;
+
+ /* Ragel variables */
+ int cs = 0;
+ const char* p = input;
+ const char* pe = p + size;
+ const char* eof = tsk_null;
+
+ *msg_size = 0;
+
+ if(!input || !size){
+ //TSK_DEBUG_ERROR("Null or empty buffer."); // --> very common case(stream): do not bother us...
+ goto bail;
+ }
+
+ if(!(msrp_msg = tmsrp_message_create_null())){
+ goto bail;
+ }
+
+ /* Ragel init */
+ %% write init;
+
+ /* Ragel execute */
+ %% write exec;
+
+ /* Check result */
+ if( cs < %%{ write first_final; }%% ){
+ //TSK_DEBUG_ERROR("Failed to parse MSRP message."); --> very common case(stream): do not bother us...
+ TSK_OBJECT_SAFE_FREE(msrp_msg);
+ goto bail;
+ }
+
+bail:
+ return msrp_msg;
+}
+
+static tsk_bool_t parse_payload(tmsrp_message_t* msrp_msg, const char* tag_start, const char** p, const char* pe, tsk_bool_t* payload_parsed)
+{
+ int64_t payload_len, endline_len;
+ tsk_bool_t can_parse_payload;
+
+ if(*payload_parsed){
+ TSK_DEBUG_INFO("payload already parsed");
+ return tsk_true;
+ }
+
+ if(pe && p && *p && msrp_msg && (can_parse_payload = TMSRP_HEADER_BYTE_RANGE_IS_VALID(msrp_msg->ByteRange))){
+ payload_len = (msrp_msg->ByteRange->end - msrp_msg->ByteRange->start) + 1;
+ endline_len = 2/*CRLF*/ + 7/*hyphens*/ + tsk_strlen(msrp_msg->tid) + 2/*CRLF*/;
+ can_parse_payload = (pe - tag_start) > (payload_len + endline_len);
+ if(can_parse_payload){
+ set_payload(msrp_msg, tag_start, (tsk_size_t)payload_len);
+ *p = ((tag_start + payload_len) - 1);
+ *payload_parsed = tsk_true;
+ return tsk_true;
+ }
+ }
+ return tsk_false;
+}
+
+static void set_payload(tmsrp_message_t* msrp_msg, const void* ptr, tsk_size_t len)
+{
+ if(msrp_msg->Content){
+ tsk_buffer_cleanup(msrp_msg->Content);
+ tsk_buffer_append(msrp_msg->Content, ptr, len);
+ }
+ else{
+ msrp_msg->Content = tsk_buffer_create(ptr, len);
+ }
+} \ No newline at end of file
diff --git a/tinyMSRP/ragel/tmsrp_parser_uri.rl b/tinyMSRP/ragel/tmsrp_parser_uri.rl
new file mode 100644
index 0000000..32b011c
--- /dev/null
+++ b/tinyMSRP/ragel/tmsrp_parser_uri.rl
@@ -0,0 +1,134 @@
+/*
+* Copyright (C) 2009 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 tmsrp_header_Dummy.c
+ * @brief MSRP Dummy header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tinymsrp/parsers/tmsrp_parser_uri.h"
+
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+
+#include <string.h>
+
+/***********************************
+* Ragel state machine.
+*/
+%%{
+ machine tmsrp_machine_parser_uri;
+
+ # Includes
+ include tmsrp_machine_utils "./ragel/tmsrp_machine_utils.rl";
+
+ action tag{
+ tag_start = p;
+ }
+
+ #/* Sets HOST type */
+ action is_ipv4 { uri->authority.host_type = tmsrp_host_ipv4; }
+ action is_ipv6 { uri->authority.host_type = tmsrp_host_ipv6; }
+ action is_hostname { uri->authority.host_type = tmsrp_host_hostname; }
+
+ action parse_scheme{
+ TSK_PARSER_SET_STRING(uri->scheme);
+ }
+
+ action parse_userinfo{
+ TSK_PARSER_SET_STRING(uri->authority.userinfo);
+ }
+
+ action parse_host{
+ TSK_PARSER_SET_STRING(uri->authority.host);
+ if(uri->authority.host_type == tmsrp_host_ipv6){
+ tsk_strunquote_2(&uri->authority.host, '[', ']');
+ }
+ }
+
+ action parse_port{
+ TSK_PARSER_SET_INT(uri->authority.port);
+ }
+
+ action parse_session_id{
+ TSK_PARSER_SET_STRING(uri->session_id);
+ }
+
+ action parse_transport{
+ TSK_PARSER_SET_STRING(uri->transport);
+ }
+
+ action parse_param{
+ TSK_PARSER_ADD_PARAM(uri->params);
+ }
+
+
+
+ #//MSRP-URI = msrp-scheme "://" authority ["/" session-id] ";" transport *( ";" URI-parameter)
+ #//msrp-scheme = "msrp" / "msrps"
+ #//session-id = 1*( unreserved / "+" / "=" / "/" )
+ #//transport = "tcp" / 1*ALPHANUM
+ #//URI-parameter = token ["=" token]
+ #//authority = [ userinfo "@" ] host [ ":" port ]
+
+ msrp_scheme = ("msrp" | "msrps")>tag %parse_scheme;
+
+ userinfo = (unreserved | pct_encoded | sub_delims | ":")* >tag %parse_userinfo;
+ myhost = ((IPv6reference >is_ipv6)>2 | (IPv4address >is_ipv4)>1 | (hostname >is_hostname)>0)>tag %parse_host;
+ authority = (userinfo "@")? myhost (":" port>tag %parse_port)?;
+
+ session_id = (unreserved | "+" | "=" | "/")+ >tag %parse_session_id;
+
+ transport = ("tcp" | alphanum*)>tag %parse_transport;
+
+ URI_parameter = (token ("=" token)?)>tag %parse_param;
+
+ URI = msrp_scheme "://" authority ("/" session_id)? ";" transport ( ";" URI_parameter)*;
+
+ # Entry point
+ main := URI;
+}%%
+
+tmsrp_uri_t *tmsrp_uri_parse(const char *data, tsk_size_t size)
+{
+ int cs = 0;
+ const char *p = data;
+ const char *pe = p + size;
+ const char *eof = pe;
+ tmsrp_uri_t *uri = tmsrp_uri_create_null();
+
+ const char *tag_start;
+
+ %%write data;
+ %%write init;
+ %%write exec;
+
+ if( cs < %%{ write first_final; }%% ){
+ TSK_DEBUG_ERROR("Failed to parse MSRP/MSRPS header.");
+ TSK_OBJECT_SAFE_FREE(uri);
+ }
+
+ return uri;
+} \ No newline at end of file
OpenPOWER on IntegriCloud