Complete MSRP (RFC 4975) parsers.

This commit is contained in:
bossiel 2010-03-16 02:16:58 +00:00
parent b346c91c74
commit 675a0cc5ec
73 changed files with 15011 additions and 6 deletions

View File

@ -0,0 +1,92 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief Defines a MSRP header/line (<type>=<value>).
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef TINYMSRP_HEADER_H
#define TINYMSRP_HEADER_H
#include "tinymsrp_config.h"
#include "tsk_ragel_state.h"
#include "tsk_list.h"
TMSRP_BEGIN_DECLS
#define TMSRP_HEADER(self) ((tmsrp_header_t*)(self))
#define TMSRP_HEADER_VALUE_TOSTRING_F(self) ((tmsrp_header_value_tostring_f)(self))
typedef int (*tmsrp_header_value_tostring_f)(const struct tmsrp_header_s* header, tsk_buffer_t* output);
/**
* @enum tmsrp_header_type_e
*
* @brief List of all supported headers.
**/
typedef enum tmsrp_header_type_e
{
tmsrp_htype_Authentication_Info,
tmsrp_htype_Authorization,
tmsrp_htype_Byte_Range,
tmsrp_htype_Content_Type,
tmsrp_htype_Dummy,
tmsrp_htype_Expires,
tmsrp_htype_Failure_Report,
tmsrp_htype_From_Path,
tmsrp_htype_Max_Expires,
tmsrp_htype_Message_ID,
tmsrp_htype_Min_Expires,
tmsrp_htype_Status,
tmsrp_htype_Success_Report,
tmsrp_htype_To_Path,
tmsrp_htype_Use_Path,
tmsrp_htype_WWW_Authenticate
}
tmsrp_header_type_t;
/*================================
*/
typedef struct tmsrp_header_s
{
TSK_DECLARE_OBJECT;
tmsrp_header_type_t type;
tmsrp_header_value_tostring_f tostring;
}
tmsrp_header_t;
#define TMSRP_DECLARE_HEADER tmsrp_header_t header
typedef tsk_list_t tmsrp_headers_L_t; /**< List of @ref tmsrp_header_t elements. */
/*
================================*/
TINYMSRP_API const char* tmsrp_header_get_name(tmsrp_header_type_t type);
TINYMSRP_API const char* tmsrp_header_get_nameex(const tmsrp_header_t *self);
TINYMSRP_API int tmsrp_header_tostring(const tmsrp_header_t *self, tsk_buffer_t *output);
TMSRP_END_DECLS
#endif /* TINYMSRP_HEADER_H */

View File

@ -0,0 +1,103 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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_Authorization.h
* @brief MSRP header 'Authorization'.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_AUTHORIZATION_H_
#define _TMSRP_HEADER_AUTHORIZATION_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_AUTHORIZATION_CREATE
* Creates new msrp 'AUTHORIZATION' header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_AUTHORIZATION_CREATE() tsk_object_new(tmsrp_header_Authorization_def_t)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP header 'Authorization' as per RFC 3261 subclause .
///
/// @par ABNF = Authorization = "Authorization" HCOLON credentials
/// credentials = ("Digest" LWS digest-response) / other-response
/// digest-response = dig-resp *(COMMA dig-resp)
/// dig-resp = username / realm / nonce / digest-uri / dresponse / algorithm / cnonce / opaque / message-qop / nonce-count / auth-param / auts
/// username = "username" EQUAL username-value
/// username-value = quoted-string
/// digest-uri = "uri" EQUAL LDQUOT digest-uri-value RDQUOT
/// digest-uri-value = auth-request-uri ; equal to request-uri as specified by HTTP/1.1
/// message-qop = "qop" EQUAL qop-value
/// cnonce = "cnonce" EQUAL cnonce-value
/// cnonce-value = nonce-value
/// nonce-count = "nc" EQUAL nc-value
/// nc-value = 8LHEX
/// dresponse = "response" EQUAL request-digest
/// request-digest = LDQUOT 32LHEX RDQUOT
/// auth-request-uri = not-defined
///
/// auth-param = auth-param-name EQUAL ( token / quoted-string )
/// auth-param-name = token
///
/// other-response = auth-scheme LWS auth-param *(COMMA auth-param)
/// auth-scheme = token
/// auts = "auts" EQUAL auts-param
/// auts-param = LDQUOT auts-value RDQUOT
/// auts-value = <base64 encoding of AUTS>
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_Authorization_s
{
TMSRP_DECLARE_HEADER;
char* scheme;
char* username;
char* realm;
char* nonce;
char* uri;
char* response;
char* algorithm;
char* cnonce;
char* opaque;
char* qop;
char* nc;
tsk_params_L_t *params;
}
tmsrp_header_Authorization_t;
tmsrp_header_Authorization_t *tmsrp_header_Authorization_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_Authorization_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_AUTHORIZATION_H_ */

View File

@ -0,0 +1,76 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief MSRP 'Byte-Range' header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_BYTE_RANGE_H_
#define _TMSRP_HEADER_BYTE_RANGE_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_BYTE_RANGE_CREATE
* Creates new msrp Byte-Range header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_BYTE_RANGE_VA_ARGS(start, end, total) tmsrp_header_Byte_Range_def_t, (int64_t)start, (int64_t)end, (int64_t)total
#define TMSRP_HEADER_BYTE_RANGE_CREATE(start, end, total) tsk_object_new(TMSRP_HEADER_BYTE_RANGE_VA_ARGS(start, end, total))
#define TMSRP_HEADER_BYTE_RANGE_CREATE_NULL() TMSRP_HEADER_BYTE_RANGE_CREATE(1, -1, -1)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP 'Byte-Range' header.
///
/// @par ABNF : Byte-Range = "Byte-Range:" SP range-start "-" range-end "/" total
/// range-start = 1*DIGIT
/// range-end = 1*DIGIT / "*"
/// total = 1*DIGIT / "*"
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_Byte_Range_s
{
TMSRP_DECLARE_HEADER;
int64_t start;
int64_t end;
int64_t total;
}
tmsrp_header_Byte_Range_t;
typedef tsk_list_t tmsrp_headers_Byte_Range_L_t;
tmsrp_header_Byte_Range_t *tmsrp_header_Byte_Range_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_Byte_Range_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_BYTE_RANGE_H_ */

View File

@ -0,0 +1,80 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief MSRP header 'Content-Type'.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_CONTENT_TYPE_H_
#define _TMSRP_HEADER_CONTENT_TYPE_H_
#include "tinymsrp_config.h"
#include "tinymsrp/headers/tmsrp_header.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_CONTENT_TYPE_CREATE
* Creates new msrp 'Content-Type' header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_CONTENT_TYPE_VA_ARGS(type) tmsrp_header_Content_Type_def_t, (const char*)type
#define TMSRP_HEADER_CONTENT_TYPE_CREATE(type) tsk_object_new(TMSRP_HEADER_CONTENT_TYPE_VA_ARGS(type))
#define TMSRP_HEADER_CONTENT_TYPE_CREATE_NULL() TMSRP_HEADER_CONTENT_TYPE_CREATE(TMSRP_NULL)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP header 'Content-Type'.
/// @author Mamadou
/// @date 12/3/2009
///
/// @par ABNF= Content-Type = "Content-Type:" SP media-type
/// media-type = type "/" subtype *( ";" gen-param )
/// type = token
/// subtype = token
/// gen-param = pname [ "=" pval ]
/// pname = token
/// pval = token / quoted-string
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_Content_Type_s
{
TMSRP_DECLARE_HEADER;
char* value;
tsk_params_L_t *params;
}
tmsrp_header_Content_Type_t;
tmsrp_header_Content_Type_t *tmsrp_header_Content_Type_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_Content_Type_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_CONTENT_TYPE_H_ */

View File

@ -0,0 +1,72 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief MSRP dummy header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_DUMMY_H_
#define _TMSRP_HEADER_DUMMY_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_DUMMY_CREATE
* Creates new msrp Dummy header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_DUMMY_VA_ARGS(name, value) tmsrp_header_Dummy_def_t, (const char*)name, (const char*)value
#define TMSRP_HEADER_DUMMY_CREATE(name, value) tsk_object_new(TMSRP_HEADER_DUMMY_VA_ARGS(name, value))
#define TMSRP_HEADER_DUMMY_CREATE_NULL() TMSRP_HEADER_DUMMY_CREATE(TMSRP_NULL, TMSRP_NULL)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP Dummy header.
///
/// @par ABNF : hname ":" SP hval CRLF
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_Dummy_s
{
TMSRP_DECLARE_HEADER;
char *name;
char *value;
}
tmsrp_header_Dummy_t;
typedef tsk_list_t tmsrp_headers_Dummy_L_t;
tmsrp_header_Dummy_t *tmsrp_header_Dummy_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_Dummy_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_DUMMY_H_ */

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief MSRP 'Expires' header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_EXPIRES_H_
#define _TMSRP_HEADER_EXPIRES_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_EXPIRES_CREATE
* Creates new MSRP 'Expires' header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_EXPIRES_VA_ARGS(value) tmsrp_header_Expires_def_t, (int64_t)value
#define TMSRP_HEADER_EXPIRES_CREATE(value) tsk_object_new(TMSRP_HEADER_EXPIRES_VA_ARGS(value))
#define TMSRP_HEADER_EXPIRES_CREATE_NULL() TMSRP_HEADER_EXPIRES_CREATE(-1)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP 'Expires' header.
///
/// @par ABNF : Expires = "Expires:" SP 1*DIGIT
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_Expires_s
{
TMSRP_DECLARE_HEADER;
int64_t value;
}
tmsrp_header_Expires_t;
typedef tsk_list_t tmsrp_headers_Expires_L_t;
tmsrp_header_Expires_t *tmsrp_header_Expires_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_Expires_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_EXPIRES_H_ */

View File

@ -0,0 +1,80 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief MSRP 'Failure-Report' header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_FAILURE_REPORT_H_
#define _TMSRP_HEADER_FAILURE_REPORT_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_FAILURE_REPORT_CREATE
* Creates new msrp Failure-Report header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_FAILURE_REPORT_VA_ARGS(freport_type) tmsrp_header_Failure_Report_def_t, (tmsrp_freport_type_t)freport_type
#define TMSRP_HEADER_FAILURE_REPORT_CREATE(freport_type) tsk_object_new(TMSRP_HEADER_FAILURE_REPORT_VA_ARGS(freport_type))
#define TMSRP_HEADER_FAILURE_REPORT_CREATE_NULL() TMSRP_HEADER_FAILURE_REPORT_CREATE(freport_yes)
/** Failure report type;
*/
typedef enum tmsrp_freport_type_e
{
freport_yes,
freport_no,
freport_partial
}
tmsrp_freport_type_t;
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP 'Failure-Report' header.
///
/// @par ABNF : "Failure-Report:" ( "yes" / "no" / "partial" )
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_Failure_Report_s
{
TMSRP_DECLARE_HEADER;
tmsrp_freport_type_t type;
}
tmsrp_header_Failure_Report_t;
typedef tsk_list_t tmsrp_headers_Failure_Report_L_t;
tmsrp_header_Failure_Report_t *tmsrp_header_Failure_Report_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_Failure_Report_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_FAILURE_REPORT_H_ */

View File

@ -0,0 +1,74 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief MSRP 'From-Path' header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_FROM_PATH_H_
#define _TMSRP_HEADER_FROM_PATH_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
#include "tinyMSRP/parsers/tmsrp_parser_uri.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_FROM_PATH_CREATE
* Creates new msrp From-Path header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_FROM_PATH_VA_ARGS(uri) tmsrp_header_From_Path_def_t, (const tmsrp_uri_t*)uri
#define TMSRP_HEADER_FROM_PATH_CREATE(uri) tsk_object_new(TMSRP_HEADER_FROM_PATH_VA_ARGS(uri))
#define TMSRP_HEADER_FROM_PATH_CREATE_NULL() TMSRP_HEADER_FROM_PATH_CREATE(TMSRP_NULL)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP 'From-Path' header.
///
/// @par ABNF : "To-Path:" SP MSRP-URI *( SP MSRP-URI )
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_From_Path_s
{
TMSRP_DECLARE_HEADER;
tmsrp_uri_t *uri;
tmsrp_uris_L_t *otherURIs;
}
tmsrp_header_From_Path_t;
typedef tsk_list_t tmsrp_headers_From_Path_L_t;
tmsrp_header_From_Path_t *tmsrp_header_From_Path_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_From_Path_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_FROM_PATH_H_ */

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief MSRP 'Max-Expires' header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_MAX_EXPIRES_H_
#define _TMSRP_HEADER_MAX_EXPIRES_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_MAX_EXPIRES_CREATE
* Creates new msrp Max-Expires header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_MAX_EXPIRES_VA_ARGS(value) tmsrp_header_Max_Expires_def_t, (int64_t)value
#define TMSRP_HEADER_MAX_EXPIRES_CREATE(value) tsk_object_new(TMSRP_HEADER_MAX_EXPIRES_VA_ARGS(value))
#define TMSRP_HEADER_MAX_EXPIRES_CREATE_NULL() TMSRP_HEADER_MAX_EXPIRES_CREATE(-1)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP 'Max-Expires' header.
///
/// @par ABNF : Max-Expires = "Max-Expires:" SP 1*DIGIT
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_Max_Expires_s
{
TMSRP_DECLARE_HEADER;
int64_t value;
}
tmsrp_header_Max_Expires_t;
typedef tsk_list_t tmsrp_headers_Max_Expires_L_t;
tmsrp_header_Max_Expires_t *tmsrp_header_Max_Expires_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_Max_Expires_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_MAX_EXPIRES_H_ */

View File

@ -0,0 +1,73 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief MSRP 'Message-Id' header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_MESSAGE_ID_H_
#define _TMSRP_HEADER_MESSAGE_ID_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_MESSAGE_ID_CREATE
* Creates new msrp Message-Id header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_MESSAGE_ID_VA_ARGS(value) tmsrp_header_Message_ID_def_t, (const char*)value
#define TMSRP_HEADER_MESSAGE_ID_CREATE(value) tsk_object_new(TMSRP_HEADER_MESSAGE_ID_VA_ARGS(value))
#define TMSRP_HEADER_MESSAGE_ID_CREATE_NULL() TMSRP_HEADER_MESSAGE_ID_CREATE(TMSRP_NULL)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP 'Message-Id' header.
///
/// @par ABNF : Message-ID = "Message-ID:" SP ident
/// ident = ALPHANUM 3*31ident-char
/// ident-char = ALPHANUM / "." / "-" / "+" / "%" / "="
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_Message_ID_s
{
TMSRP_DECLARE_HEADER;
char *value;
}
tmsrp_header_Message_ID_t;
typedef tsk_list_t tmsrp_headers_Message_Id_L_t;
tmsrp_header_Message_ID_t *tmsrp_header_Message_ID_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_Message_ID_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_MESSAGE_ID_H_ */

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief MSRP 'Min-Expires' header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_MIN_EXPIRES_H_
#define _TMSRP_HEADER_MIN_EXPIRES_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_MIN_EXPIRES_CREATE
* Creates new msrp Min-Expires header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_MIN_EXPIRES_VA_ARGS(value) tmsrp_header_Min_Expires_def_t, (int64_t)value
#define TMSRP_HEADER_MIN_EXPIRES_CREATE(value) tsk_object_new(TMSRP_HEADER_MIN_EXPIRES_VA_ARGS(value))
#define TMSRP_HEADER_MIN_EXPIRES_CREATE_NULL() TMSRP_HEADER_MIN_EXPIRES_CREATE(-1)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP 'Min-Expires' header.
///
/// @par ABNF : Min-Expires = "Min-Expires:" SP 1*DIGIT
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_Min_Expires_s
{
TMSRP_DECLARE_HEADER;
int64_t value;
}
tmsrp_header_Min_Expires_t;
typedef tsk_list_t tmsrp_headers_Min_Expires_L_t;
tmsrp_header_Min_Expires_t *tmsrp_header_Min_Expires_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_Min_Expires_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_MIN_EXPIRES_H_ */

View File

@ -0,0 +1,75 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief MSRP 'Status' header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_STATUS_H_
#define _TMSRP_HEADER_STATUS_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_STATUS_CREATE
* Creates new msrp Status header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_STATUS_VA_ARGS(namespace, code, reason) tmsrp_header_Status_def_t, (short)namespace, (short)code, (const char*)reason
#define TMSRP_HEADER_STATUS_CREATE(namespace, code, reason) tsk_object_new(TMSRP_HEADER_STATUS_VA_ARGS(namespace, code, reason))
#define TMSRP_HEADER_STATUS_CREATE_NULL() TMSRP_HEADER_STATUS_CREATE(0, 200, TMSRP_NULL)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP 'Status' header.
///
/// @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
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_Status_s
{
TMSRP_DECLARE_HEADER;
short namespace;
short code;
char* reason;
}
tmsrp_header_Status_t;
typedef tsk_list_t tmsrp_headers_Status_L_t;
tmsrp_header_Status_t *tmsrp_header_Status_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_Status_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_STATUS_H_ */

View File

@ -0,0 +1,70 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief MSRP 'Success-Report' header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_SUCCESS_REPORT_H_
#define _TMSRP_HEADER_SUCCESS_REPORT_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_SUCCESS_REPORT_CREATE
* Creates new msrp Success-Report header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_SUCCESS_REPORT_VA_ARGS(isSuccess) tmsrp_header_Success_Report_def_t, (unsigned)isSuccess
#define TMSRP_HEADER_SUCCESS_REPORT_CREATE(isSuccess) tsk_object_new(TMSRP_HEADER_SUCCESS_REPORT_VA_ARGS(isSuccess))
#define TMSRP_HEADER_SUCCESS_REPORT_CREATE_NULL() TMSRP_HEADER_SUCCESS_REPORT_CREATE(0)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP 'Success-Report' header.
///
/// @par ABNF : "Success-Report:" ( "yes" / "no" )
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_Success_Report_s
{
TMSRP_DECLARE_HEADER;
unsigned yes:1;
}
tmsrp_header_Success_Report_t;
typedef tsk_list_t tmsrp_headers_Success_Report_L_t;
tmsrp_header_Success_Report_t *tmsrp_header_Success_Report_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_Success_Report_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_SUCCESS_REPORT_H_ */

View File

@ -0,0 +1,74 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief MSRP 'To-Path' header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_TO_PATH_H_
#define _TMSRP_HEADER_TO_PATH_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
#include "tinyMSRP/parsers/tmsrp_parser_uri.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_TO_PATH_CREATE
* Creates new msrp To-Path header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_TO_PATH_VA_ARGS(uri) tmsrp_header_To_Path_def_t, (const tmsrp_uri_t*)uri
#define TMSRP_HEADER_TO_PATH_CREATE(uri) tsk_object_new(TMSRP_HEADER_TO_PATH_VA_ARGS(uri))
#define TMSRP_HEADER_TO_PATH_CREATE_NULL() TMSRP_HEADER_TO_PATH_CREATE(TMSRP_NULL)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP 'To-Path' header.
///
/// @par ABNF : "To-Path:" SP MSRP-URI *( SP MSRP-URI )
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_To_Path_s
{
TMSRP_DECLARE_HEADER;
tmsrp_uri_t *uri;
tmsrp_uris_L_t *otherURIs;
}
tmsrp_header_To_Path_t;
typedef tsk_list_t tmsrp_headers_To_Path_L_t;
tmsrp_header_To_Path_t *tmsrp_header_To_Path_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_To_Path_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_TO_PATH_H_ */

View File

@ -0,0 +1,74 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.h
* @brief MSRP 'Use-Path' header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_USE_PATH_H_
#define _TMSRP_HEADER_USE_PATH_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
#include "tinyMSRP/parsers/tmsrp_parser_uri.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_USE_PATH_CREATE
* Creates new msrp Use-Path header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_USE_PATH_VA_ARGS(uri) tmsrp_header_Use_Path_def_t, (const tmsrp_uri_t*)uri
#define TMSRP_HEADER_USE_PATH_CREATE(uri) tsk_object_new(TMSRP_HEADER_USE_PATH_VA_ARGS(uri))
#define TMSRP_HEADER_USE_PATH_CREATE_NULL() TMSRP_HEADER_USE_PATH_CREATE(TMSRP_NULL)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP 'Use-Path' header.
///
/// @par ABNF : "Use-Path:" SP MSRP-URI *( SP MSRP-URI )
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_Use_Path_s
{
TMSRP_DECLARE_HEADER;
tmsrp_uri_t *uri;
tmsrp_uris_L_t *otherURIs;
}
tmsrp_header_Use_Path_t;
typedef tsk_list_t tmsrp_headers_Use_Path_L_t;
tmsrp_header_Use_Path_t *tmsrp_header_Use_Path_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_Use_Path_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_USE_PATH_H_ */

View File

@ -0,0 +1,87 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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_WWW_Authenticate.h
* @brief MSRP header 'WWW-Authenticate'.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef _TMSRP_HEADER_WWW_Authenticate_H_
#define _TMSRP_HEADER_WWW_Authenticate_H_
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_HEADER_WWW_AUTHENTICATE_CREATE
* Creates new msrp 'WWW-AUTHENTICATE' header. You must call @ref TSK_OBJECT_SAFE_FREE to free the header.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_HEADER_WWW_AUTHENTICATE_CREATE() tsk_object_new(tmsrp_header_WWW_Authenticate_def_t)
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @struct
///
/// @brief MSRP header 'WWW-Authenticate'.
///
/// @par ABNF = WWW-Authenticate = "WWW-Authenticate" HCOLON challenge
/// challenge = ("Digest" LWS digest-cln *(COMMA digest-cln)) / other-challenge
/// other-challenge = auth-scheme / auth-param *(COMMA auth-param)
/// digest-cln = realm / domain / nonce / opaque / stale / algorithm / qop-options / auth-param
/// realm = "realm" EQUAL realm-value
/// realm-value = quoted-string
/// domain = "domain" EQUAL LDQUOT URI *( 1*SP URI ) RDQUOT
/// URI = absoluteURI / abs-path
/// opaque = "opaque" EQUAL quoted-string
/// stale = "stale" EQUAL ( "true" / "false" )
/// qop-options = "qop" EQUAL LDQUOT qop-value *("," qop-value) RDQUOT
/// qop-value = "auth" / "auth-int" / token
///
////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct tmsrp_header_WWW_Authenticate_s
{
TMSRP_DECLARE_HEADER;
char* scheme;
char* realm;
char* domain;
char* nonce;
char* opaque;
unsigned stale:1;
char* algorithm;
char* qop;
tsk_params_L_t* params;
}
tmsrp_header_WWW_Authenticate_t;
tmsrp_header_WWW_Authenticate_t *tmsrp_header_WWW_Authenticate_parse(const char *data, size_t size);
TINYMSRP_GEXTERN const void *tmsrp_header_WWW_Authenticate_def_t;
TMSRP_END_DECLS
#endif /* _TMSRP_HEADER_WWW_Authenticate_H_ */

View File

@ -0,0 +1,44 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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_parser_message.h
* @brief MSRP message parser.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef TINYMSRP_PARSER_MESSAGE_H
#define TINYMSRP_PARSER_MESSAGE_H
#include "tinyMSRP_config.h"
#include "tinyMSRP/tmsrp_message.h"
#include "tsk_ragel_state.h"
TMSRP_BEGIN_DECLS
TINYMSRP_API tmsrp_message_t* tmsrp_message_parse(const void *input, size_t size);
TMSRP_END_DECLS
#endif /* TINYMSRP_PARSER_MESSAGE_H */

View File

@ -0,0 +1,45 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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_parser_uri.h
* @brief MSRP/MSRPS URI parser.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef TINYMSRP_PARSER_URI_H
#define TINYMSRP_PARSER_URI_H
#include "tinyMSRP_config.h"
#include "tinyMSRP/tmsrp_uri.h"
#include "tsk_ragel_state.h"
TMSRP_BEGIN_DECLS
TINYMSRP_API tmsrp_uri_t *tmsrp_uri_parse(const char *data, size_t size);
TMSRP_END_DECLS
#endif /* TINYMSRP_PARSER_URI_H */

View File

@ -0,0 +1,186 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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_message.h
* @brief MSRP message.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef TINYMSRP_MESSAGE_H
#define TINYMSRP_MESSAGE_H
#include "tinyMSRP_config.h"
#include "tinyMSRP/headers/tmsrp_header.h"
#include "tinyMSRP/headers/tmsrp_header_Byte-Range.h"
#include "tinymsrp/headers/tmsrp_header_Content-Type.h"
#include "tinyMSRP/headers/tmsrp_header_Failure-Report.h"
#include "tinyMSRP/headers/tmsrp_header_From-Path.h"
#include "tinyMSRP/headers/tmsrp_header_Message-Id.h"
#include "tinyMSRP/headers/tmsrp_header_Status.h"
#include "tinyMSRP/headers/tmsrp_header_Success-Report.h"
#include "tinyMSRP/headers/tmsrp_header_To-Path.h"
TMSRP_BEGIN_DECLS
#define TMSRP_MESSAGE_IS_REQUEST(self) ((self) ? (self)->type == tmsrp_request : 0)
#define TMSRP_MESSAGE_IS_RESPONSE(self) ((self) ? (self)->type == tmsrp_response : 0)
#define TMSRP_MESSAGE(self) ((tmsrp_message_t*)(self))
#define TMSRP_MESSAGE_AS_RESPONSE(self) ((tmsrp_response_t*)(self))
#define TMSRP_MESSAGE_AS_REQUEST(self) ((tmsrp_request_t*)(self))
/**@def TMSRP_MESSAGE_CREATE
* Creates new msrp messgae. Could be either a request or a response.
* You must call @ref TSK_OBJECT_SAFE_FREE to free the message.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_MESSAGE_CREATE(type, tid, method, status, comment)\
tsk_object_new(tmsrp_message_def_t, (tmsrp_message_type_t)type, (const char*)tid, (const char*)method, (short)status, (const char*)comment)
#define TMSRP_REQUEST_CREATE(tid, method)\
TMSRP_MESSAGE_CREATE(tmsrp_request, tid, method, 0, TMSRP_NULL)
#define TMSRP_RESPONSE_CREATE(tid, status, comment)\
TMSRP_MESSAGE_CREATE(tmsrp_response, tid, TMSRP_NULL, status, comment)
#define TMSRP_MESSAGE_CREATE_NULL()\
TMSRP_MESSAGE_CREATE(tmsrp_unknown, TMSRP_NULL, TMSRP_NULL, 0, TMSRP_NULL)
#define TMSRP_RESPONSE_CODE(self) (TMSRP_MESSAGE_IS_RESPONSE((self)) ? (self)->status_code : 0)
#define TMSRP_RESPONSE_PHRASE(self) ((self)->reason_phrase)
#define TMSRP_REQUEST_METHOD(self) ((self)->method)
#define TMSRP_REQUEST_URI(self) ((self)->uri)
#define TMSRP_MESSAGE_HAS_CONTENT(message) ((message) && (message)->Content && (message)->Content->data)
#define TMSRP_MESSAGE_CONTENT(message) (TMSRP_MESSAGE_HAS_CONTENT(message) ? (message)->Content->data : 0)
#define TMSRP_RESPONSE_IS(self, code) (TMSRP_RESPONSE_CODE((self)) == code)
#define TMSRP_RESPONSE_IS_NXX(self, N) (TMSRP_MESSAGE_IS_RESPONSE((self)) && N##00<= TMSRP_RESPONSE_CODE((self)) && TMSRP_RESPONSE_CODE((self)) <= N##99)
#define TMSRP_RESPONSE_IS_1XX(self) TMSRP_RESPONSE_IS_NXX(self, 1)
#define TMSRP_RESPONSE_IS_2XX(self) TMSRP_RESPONSE_IS_NXX(self, 2)
#define TMSRP_RESPONSE_IS_3XX(self) TMSRP_RESPONSE_IS_NXX(self, 3)
#define TMSRP_RESPONSE_IS_4XX(self) TMSRP_RESPONSE_IS_NXX(self, 4)
#define TMSRP_RESPONSE_IS_5XX(self) TMSRP_RESPONSE_IS_NXX(self, 5)
#define TMSRP_RESPONSE_IS_6XX(self) TMSRP_RESPONSE_IS_NXX(self, 6)
#define TMSRP_RESPONSE_IS_23456(self) (TMSRP_MESSAGE_IS_RESPONSE((self)) && 200<= TMSRP_RESPONSE_CODE((self)) && TMSRP_RESPONSE_CODE((self)) <= 699)
/** Defines the message type (Request or Response).
**/
typedef enum tmsrp_message_type_e
{
tmsrp_unknown,
tmsrp_request,
tmsrp_response
}
tmsrp_message_type_t;
typedef struct tmsrp_message_s
{
TSK_DECLARE_OBJECT;
tmsrp_message_type_t type;
char* tid;
union{
struct{
char* method;
} request;
struct{
short status;
char* comment;
} response;
} line;
// Very common headers
tmsrp_header_To_Path_t* To;
tmsrp_header_From_Path_t* From;
tmsrp_header_Message_ID_t* MessageID;
tmsrp_header_Byte_Range_t* ByteRange;
tmsrp_header_Failure_Report_t* FailureReport;
tmsrp_header_Success_Report_t* SuccessReport;
tmsrp_header_Status_t* Status;
//! List of @ref tmsrp_header_t elements.
tmsrp_headers_L_t* headers;
// Content
tmsrp_header_Content_Type_t* ContentType;
tsk_buffer_t *Content;
// End line
struct{
char* tid;
char cflag;
}end_line;
}
tmsrp_message_t;
typedef tmsrp_message_t tmsrp_request_t; /**< MSRP request message. */
typedef tmsrp_message_t tmsrp_response_t; /**< MSRP response message. */
TINYMSRP_API int tmsrp_message_add_header(tmsrp_message_t *self, const tmsrp_header_t *hdr);
TINYMSRP_API int tmsrp_message_add_headers(tmsrp_message_t *self, const tmsrp_headers_L_t *headers);
#if !defined(_MSC_VER) || defined(__GNUC__)
static void TMSRP_MESSAGE_ADD_HEADER(tmsrp_message_t *self, ...)
{
va_list ap;
tmsrp_header_t *header;
const tsk_object_def_t *objdef;
va_start(ap, self);
objdef = va_arg(ap, const tsk_object_def_t*);
header = tsk_object_new2(objdef, &ap);
va_end(ap);
tmsrp_message_add_header(self, header);
tsk_object_unref(header);
}
#else
#define TMSRP_MESSAGE_ADD_HEADER(self, objdef, ...) \
{ \
tmsrp_header_t *header = tsk_object_new(objdef, __VA_ARGS__); \
tmsrp_message_add_header(self, header); \
tsk_object_unref(header); \
}
#endif
TINYMSRP_API const tmsrp_header_t *tmsrp_message_get_headerAt(const tmsrp_message_t *self, tmsrp_header_type_t type, size_t index);
TINYMSRP_API const tmsrp_header_t *tmsrp_message_get_header(const tmsrp_message_t *self, tmsrp_header_type_t type);
TINYMSRP_API const tmsrp_header_t *tmsrp_message_get_headerByName(const tmsrp_message_t *self, char name);
TINYMSRP_API int tmsrp_message_add_content(tmsrp_message_t *self, const char* content_type, const void* content, size_t size);
TINYMSRP_API int tmsrp_message_tostring(const tmsrp_message_t *self, tsk_buffer_t *output);
TINYMSRP_GEXTERN const void *tmsrp_message_def_t;
TMSRP_END_DECLS
#endif /* TINYMSRP_MESSAGE_H */

View File

@ -0,0 +1,105 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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_uri.h
* @brief MSRP/MSRPS URI.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#ifndef TINYMSRP_URI_H
#define TINYMSRP_URI_H
#include "tinyMSRP_config.h"
#include "tsk_object.h"
#include "tsk_params.h"
#include "tsk_buffer.h"
TMSRP_BEGIN_DECLS
/**@def TMSRP_URI_CREATE
* Creates new msrp/msrps/tel uri. You must call @ref TSK_OBJECT_SAFE_FREE to free the uri.
* @param scheme "msrp" or "msrps".
* @param host Either domain anme or IPv4/IPv6 address.
* @param host_type @ref tmsrp_host_type_t.
* @param port The port.
* @param session_id The session identifier.
* @param transport The associated transport (e.g. @a "tcp").
* @retval @ref tmsrp_uri_t object.
* @sa TSK_OBJECT_SAFE_FREE.
*/
#define TMSRP_URI_CREATE(scheme, host, host_type, port, session_id, transport)\
tsk_object_new(tmsrp_uri_def_t, (const char*)scheme, (const char*)host, (tmsrp_host_type_t)host_type, (int32_t)port, (const char*)session_id, (const char*)transport)
#define TMSRP_URI_CREATE_NULL() TMSRP_URI_CREATE(TMSRP_NULL, TMSRP_NULL, host_unknown, -1, TMSRP_NULL, TMSRP_NULL)
#define TMSRP_URI_IS_SECURE(uri) ((uri) && (tsk_striequals(uri->scheme, "msrps") ? 1 : 0))
#define TMSRP_URI(self) ((tmsrp_uri_t*)(self))
/** The type of the authority host.
*/
typedef enum tmsrp_host_type_e
{
host_unknown,
host_hostname,
host_ipv4,
host_ipv6
}
tmsrp_host_type_t;
/**
* @struct tmsrp_uri_s
*
* @brief MSRP/MSRPS/TEL URI.
**/
typedef struct tmsrp_uri_s
{
TSK_DECLARE_OBJECT;
char *scheme;
struct{
char* userinfo;
tmsrp_host_type_t host_type; /**< IPv4 or IPv6 or domain name. */
char* host;
int32_t port;
}authority;
char* session_id;
char* transport;
tsk_params_L_t *params; /**< list of @ref tsk_param_t elements containing all parameters. */
}
tmsrp_uri_t;
typedef tsk_list_t tmsrp_uris_L_t;
TINYMSRP_API int tmsrp_uri_serialize(const tmsrp_uri_t *uri, tsk_buffer_t *output);
TINYMSRP_API char* tmsrp_uri_tostring(const tmsrp_uri_t *uri);
TINYMSRP_API tmsrp_uri_t *tmsrp_uri_clone(const tmsrp_uri_t *uri);
TINYMSRP_GEXTERN const void *tmsrp_uri_def_t;
TMSRP_END_DECLS
#endif /* TINYMSRP_URI_H */

View File

@ -81,6 +81,8 @@
#include <stdint.h>
#include <stddef.h>
/* FIXME */
#define TMSRP_NULL 0
#endif /* _TINYMSRP_H_ */

View File

60
trunk/tinyMSRP/ragel.sh Normal file
View File

@ -0,0 +1,60 @@
# Ragel generator
# For more information about Ragel: http://www.complang.org/ragel/
export OPTIONS="-C -L -T0"
#export OPTIONS="-C -L -G2"
# msrp Message parser
ragel.exe $OPTIONS -o ../src/parsers/tmsrp_parser_message.c tmsrp_parser_message.rl
# msrp URI
ragel.exe $OPTIONS -o ../src/parsers/tmsrp_parser_uri.c tmsrp_parser_uri.rl
# ==Authentication-Info.h
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_Authentication-Info.c tmsrp_parser_header_Authentication-Info.rl
# ==Authorization
# Ignored
# ==Byte-Range
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_Byte-Range.c tmsrp_parser_header_Byte-Range.rl
# ==Content-Type
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_Content-Type.c tmsrp_parser_header_Content-Type.rl
# ==Dummy
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_Dummy.c tmsrp_parser_header_Dummy.rl
# ==Expires
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_Expires.c tmsrp_parser_header_Expires.rl
# ==Failure-Report
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_Failure-Report.c tmsrp_parser_header_Failure-Report.rl
# ==From-Path
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_From-Path.c tmsrp_parser_header_From-Path.rl
# ==Max-Expires
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_Max-Expires.c tmsrp_parser_header_Max-Expires.rl
# ==Message-ID
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_Message-ID.c tmsrp_parser_header_Message-ID.rl
# ==Min-Expires
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_Min-Expires.c tmsrp_parser_header_Min-Expires.rl
# ==Status
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_Status.c tmsrp_parser_header_Status.rl
# ==Success-Report
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_Success-Report.c tmsrp_parser_header_Success-Report.rl
# ==To-Path
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_To-Path.c tmsrp_parser_header_To-Path.rl
# ==Use-Path
ragel.exe $OPTIONS -o ../src/headers/tmsrp_header_Use-Path.c tmsrp_parser_header_Use-Path.rl
# ==WWW-Authenticate
# Ignored

View File

@ -0,0 +1,117 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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;
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};
}%%

View File

@ -0,0 +1,185 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./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->end = -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?;
}%%
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_appendEx(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, 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 void* tmsrp_header_Byte_Range_create(void *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 void* tmsrp_header_Byte_Range_destroy(void *self)
{
tmsrp_header_Byte_Range_t *Byte_Range = self;
if(Byte_Range){
}
else{
TSK_DEBUG_ERROR("Null Byte-Range header.");
}
return self;
}
static int tmsrp_header_Byte_Range_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Byte_Range_def_s =
{
sizeof(tmsrp_header_Byte_Range_t),
tmsrp_header_Byte_Range_create,
tmsrp_header_Byte_Range_destroy,
tmsrp_header_Byte_Range_cmp
};
const void *tmsrp_header_Byte_Range_def_t = &tmsrp_header_Byte_Range_def_s;

View File

@ -0,0 +1,167 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./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?;
}%%
int tmsrp_header_Content_Type_tostring(const void* header, tsk_buffer_t* output)
{
if(header)
{
const tmsrp_header_Content_Type_t *Content_Type = 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, 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_OBJECT_SAFE_FREE(hdr_ctype);
}
return hdr_ctype;
}
//========================================================
// Content_Type header object definition
//
/**@ingroup tmsrp_header_Content_Type_group
*/
static void* tmsrp_header_Content_Type_create(void *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 void* tmsrp_header_Content_Type_destroy(void *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_create,
tmsrp_header_Content_Type_destroy,
0
};
const void *tmsrp_header_Content_Type_def_t = &tmsrp_header_Content_Type_def_s;

View File

@ -0,0 +1,156 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./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?;
}%%
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, 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 void* tmsrp_header_Dummy_create(void *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 void* tmsrp_header_Dummy_destroy(void *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 int tmsrp_header_Dummy_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Dummy_def_s =
{
sizeof(tmsrp_header_Dummy_t),
tmsrp_header_Dummy_create,
tmsrp_header_Dummy_destroy,
tmsrp_header_Dummy_cmp
};
const void *tmsrp_header_Dummy_def_t = &tmsrp_header_Dummy_def_s;

View File

@ -0,0 +1,149 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./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?;
}%%
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_appendEx(output, "%lld", Expires->value);
}
return 0;
}
return -1;
}
tmsrp_header_Expires_t *tmsrp_header_Expires_parse(const char *data, 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 void* tmsrp_header_Expires_create(void *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 void* tmsrp_header_Expires_destroy(void *self)
{
tmsrp_header_Expires_t *Expires = self;
if(Expires){
}
else{
TSK_DEBUG_ERROR("Null Expires header.");
}
return self;
}
static int tmsrp_header_Expires_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Expires_def_s =
{
sizeof(tmsrp_header_Expires_t),
tmsrp_header_Expires_create,
tmsrp_header_Expires_destroy,
tmsrp_header_Expires_cmp
};
const void *tmsrp_header_Expires_def_t = &tmsrp_header_Expires_def_s;

View File

@ -0,0 +1,149 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./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?;
}%%
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, 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 void* tmsrp_header_Failure_Report_create(void *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 void* tmsrp_header_Failure_Report_destroy(void *self)
{
tmsrp_header_Failure_Report_t *Failure_Report = self;
if(Failure_Report){
}
else{
TSK_DEBUG_ERROR("Null Failure-Report header.");
}
return self;
}
static int tmsrp_header_Failure_Report_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Failure_Report_def_s =
{
sizeof(tmsrp_header_Failure_Report_t),
tmsrp_header_Failure_Report_create,
tmsrp_header_Failure_Report_destroy,
tmsrp_header_Failure_Report_cmp
};
const void *tmsrp_header_Failure_Report_def_t = &tmsrp_header_Failure_Report_def_s;

View File

@ -0,0 +1,170 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./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, (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?;
}%%
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, 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;
}
//========================================================
// From_Path header object definition
//
static void* tmsrp_header_From_Path_create(void *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 void* tmsrp_header_From_Path_destroy(void *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 int tmsrp_header_From_Path_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_From_Path_def_s =
{
sizeof(tmsrp_header_From_Path_t),
tmsrp_header_From_Path_create,
tmsrp_header_From_Path_destroy,
tmsrp_header_From_Path_cmp
};
const void *tmsrp_header_From_Path_def_t = &tmsrp_header_From_Path_def_s;

View File

@ -0,0 +1,149 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./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?;
}%%
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_appendEx(output, "%lld", Max_Expires->value);
}
return 0;
}
return -1;
}
tmsrp_header_Max_Expires_t *tmsrp_header_Max_Expires_parse(const char *data, 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 void* tmsrp_header_Max_Expires_create(void *self, va_list * app)
{
tmsrp_header_Max_Expires_t *Max_Expires = self;
if(Max_Expires)
{
TMSRP_HEADER(Max_Expires)->type = tmsrp_htype_Message_ID;
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 void* tmsrp_header_Max_Expires_destroy(void *self)
{
tmsrp_header_Max_Expires_t *Max_Expires = self;
if(Max_Expires){
}
else{
TSK_DEBUG_ERROR("Null Max-Expires header.");
}
return self;
}
static int tmsrp_header_Max_Expires_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Max_Expires_def_s =
{
sizeof(tmsrp_header_Max_Expires_t),
tmsrp_header_Max_Expires_create,
tmsrp_header_Max_Expires_destroy,
tmsrp_header_Max_Expires_cmp
};
const void *tmsrp_header_Max_Expires_def_t = &tmsrp_header_Max_Expires_def_s;

View File

@ -0,0 +1,150 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./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?;
}%%
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, 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 void* tmsrp_header_Message_ID_create(void *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 void* tmsrp_header_Message_ID_destroy(void *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 int tmsrp_header_Message_ID_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Message_ID_def_s =
{
sizeof(tmsrp_header_Message_ID_t),
tmsrp_header_Message_ID_create,
tmsrp_header_Message_ID_destroy,
tmsrp_header_Message_ID_cmp
};
const void *tmsrp_header_Message_ID_def_t = &tmsrp_header_Message_ID_def_s;

View File

@ -0,0 +1,149 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./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?;
}%%
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_appendEx(output, "%lld", Min_Expires->value);
}
return 0;
}
return -1;
}
tmsrp_header_Min_Expires_t *tmsrp_header_Min_Expires_parse(const char *data, 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 void* tmsrp_header_Min_Expires_create(void *self, va_list * app)
{
tmsrp_header_Min_Expires_t *Min_Expires = self;
if(Min_Expires)
{
TMSRP_HEADER(Min_Expires)->type = tmsrp_htype_Message_ID;
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 void* tmsrp_header_Min_Expires_destroy(void *self)
{
tmsrp_header_Min_Expires_t *Min_Expires = self;
if(Min_Expires){
}
else{
TSK_DEBUG_ERROR("Null Min-Expires header.");
}
return self;
}
static int tmsrp_header_Min_Expires_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Min_Expires_def_s =
{
sizeof(tmsrp_header_Min_Expires_t),
tmsrp_header_Min_Expires_create,
tmsrp_header_Min_Expires_destroy,
tmsrp_header_Min_Expires_cmp
};
const void *tmsrp_header_Min_Expires_def_t = &tmsrp_header_Min_Expires_def_s;

View File

@ -0,0 +1,170 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./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?;
}%%
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_appendEx(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, 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 void* tmsrp_header_Status_create(void *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 void* tmsrp_header_Status_destroy(void *self)
{
tmsrp_header_Status_t *Status = self;
if(Status){
TSK_FREE(Status->reason);
}
else{
TSK_DEBUG_ERROR("Null Status header.");
}
return self;
}
static int tmsrp_header_Status_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Status_def_s =
{
sizeof(tmsrp_header_Status_t),
tmsrp_header_Status_create,
tmsrp_header_Status_destroy,
tmsrp_header_Status_cmp
};
const void *tmsrp_header_Status_def_t = &tmsrp_header_Status_def_s;

View File

@ -0,0 +1,145 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./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?;
}%%
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, 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 void* tmsrp_header_Success_Report_create(void *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, unsigned) ? 1 : 0;
}
else{
TSK_DEBUG_ERROR("Failed to create new Success-Report header.");
}
return self;
}
static void* tmsrp_header_Success_Report_destroy(void *self)
{
tmsrp_header_Success_Report_t *Success_Report = self;
if(Success_Report){
}
else{
TSK_DEBUG_ERROR("Null Success-Report header.");
}
return self;
}
static int tmsrp_header_Success_Report_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Success_Report_def_s =
{
sizeof(tmsrp_header_Success_Report_t),
tmsrp_header_Success_Report_create,
tmsrp_header_Success_Report_destroy,
tmsrp_header_Success_Report_cmp
};
const void *tmsrp_header_Success_Report_def_t = &tmsrp_header_Success_Report_def_s;

View File

@ -0,0 +1,170 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./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, (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?;
}%%
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, 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;
}
//========================================================
// To_Path header object definition
//
static void* tmsrp_header_To_Path_create(void *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 void* tmsrp_header_To_Path_destroy(void *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 int tmsrp_header_To_Path_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_To_Path_def_s =
{
sizeof(tmsrp_header_To_Path_t),
tmsrp_header_To_Path_create,
tmsrp_header_To_Path_destroy,
tmsrp_header_To_Path_cmp
};
const void *tmsrp_header_To_Path_def_t = &tmsrp_header_To_Path_def_s;

View File

@ -0,0 +1,170 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./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, (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?;
}%%
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, 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 void* tmsrp_header_Use_Path_create(void *self, va_list * app)
{
tmsrp_header_Use_Path_t *Use_Path = self;
if(Use_Path)
{
TMSRP_HEADER(Use_Path)->type = tmsrp_htype_Use_Path;
TMSRP_HEADER(Use_Path)->tostring = tmsrp_header_Use_Path_tostring;
Use_Path->uri = tsk_object_ref((void*)va_arg(*app, const tmsrp_uri_t*));
}
else{
TSK_DEBUG_ERROR("Failed to create new Use-Path header.");
}
return self;
}
static void* tmsrp_header_Use_Path_destroy(void *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 int tmsrp_header_Use_Path_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Use_Path_def_s =
{
sizeof(tmsrp_header_Use_Path_t),
tmsrp_header_Use_Path_create,
tmsrp_header_Use_Path_destroy,
tmsrp_header_Use_Path_cmp
};
const void *tmsrp_header_Use_Path_def_t = &tmsrp_header_Use_Path_def_s;

View File

@ -0,0 +1,286 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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_debug.h"
#include "tsk_memory.h"
#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 "./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);
}
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 parse_data{
int len = (int)(p - tag_start);
if(len>0 && !msrp_msg->Content){
msrp_msg->Content = TSK_BUFFER_CREATE(tag_start, (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 = '#';
}
###########################################
# 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 = CRLF<: data>tag %parse_data :>CRLF;
msrp_request = req_start headers>1 (content_stuff)?>0 end_line;
###########################################
# 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);
###########################################
# Entry Point
###########################################
main := msrp_req_or_resp;
}%%
/* Ragel data */
%% write data;
tmsrp_message_t* tmsrp_message_parse(const void *input, size_t size)
{
tmsrp_message_t* msrp_msg = TMSRP_NULL;
const char* tag_start = TMSRP_NULL;
tmsrp_header_t* header = TMSRP_NULL;
/* Ragel variables */
int cs = 0;
const char* p = input;
const char* pe = p + size;
const char* eof = TMSRP_NULL;
if(!input || !size){
TSK_DEBUG_ERROR("Null or empty buffer.");
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.");
TSK_OBJECT_SAFE_FREE(msrp_msg);
goto bail;
}
bail:
return msrp_msg;
}

View File

@ -0,0 +1,134 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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 "./tmsrp_machine_utils.rl";
action tag{
tag_start = p;
}
#/* Sets HOST type */
action is_ipv4 { uri->authority.host_type = host_ipv4; }
action is_ipv6 { uri->authority.host_type = host_ipv6; }
action is_hostname { uri->authority.host_type = 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 == host_ipv6){
tsk_strunquoteex(&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, 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;
}

View File

@ -0,0 +1,96 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.c
* @brief Defines a MSRP header (hname ":" SP hval CRLF).
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tinyMSRP/headers/tmsrp_header.h"
#include "tinyMSRP/headers/tmsrp_header_Dummy.h"
/** Gets the name of the MSRP 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.
**/
const char* tmsrp_header_get_name(tmsrp_header_type_t type)
{
switch(type)
{
case tmsrp_htype_Authentication_Info: return "Authentication-Info";
case tmsrp_htype_Authorization: return "Authorization";
case tmsrp_htype_Byte_Range: return "Byte-Range";
case tmsrp_htype_Content_Type: return "Content-Type";
case tmsrp_htype_Expires: return "Expires";
case tmsrp_htype_Failure_Report: return "Failure-Report";
case tmsrp_htype_From_Path: return "From-Path";
case tmsrp_htype_Max_Expires: return "Max-Expires";
case tmsrp_htype_Message_ID: return "Message-ID";
case tmsrp_htype_Min_Expires: return "Min-Expires";
case tmsrp_htype_Status: return "Status";
case tmsrp_htype_Success_Report: return "Success-Report";
case tmsrp_htype_To_Path: return "To-Path";
case tmsrp_htype_Use_Path: return "Use-Path";
case tmsrp_htype_WWW_Authenticate: return "WWW-Authenticate";
default: return "unknown-header";
}
}
const char* tmsrp_header_get_nameex(const tmsrp_header_t *self)
{
if(self){
if(self->type == tmsrp_htype_Dummy){
return ((tmsrp_header_Dummy_t*)(self))->name;
}
else{
return tmsrp_header_get_name(self->type);
}
}
return "unknown-header";
}
int tmsrp_header_tostring(const tmsrp_header_t *self, tsk_buffer_t *output)
{
int ret = -1;
if(!self || !output){
return -1;
}
/* Name */
tsk_buffer_appendEx(output, "%s: ", tmsrp_header_get_nameex(self));
/* Value */
if((ret = self->tostring(self, output))){
// Abort?
}
/* CRLF*/
ret = tsk_buffer_append(output, "\r\n", 2);
return ret;
}

View File

@ -0,0 +1,2 @@
/* #line 1 "tmsrp_parser_header_Authentication-Info.rl" */

View File

@ -0,0 +1,178 @@
/* #line 1 "tmsrp_parser_header_Authorization.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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_Authorization.c
* @brief MSRP Proxy-Authenticate header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tinyMSRP/headers/tmsrp_header_Authorization.h"
#include "tinyhttp/headers/thttp_header_Authorization.h"
#include "tsk_debug.h"
#include "tsk_memory.h"
#include "tsk_time.h"
#include <string.h>
int tmsrp_header_Authorization_tostring(const void* header, tsk_buffer_t* output)
{
if(header)
{
const tmsrp_header_Authorization_t *Authorization = header;
if(Authorization && Authorization->scheme)
{
return tsk_buffer_appendEx(output, "%s %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
Authorization->scheme,
Authorization->username ? "username=\"" : "",
Authorization->username ? Authorization->username : "",
Authorization->username ? "\"" : "",
Authorization->realm ? ",realm=\"" : "",
Authorization->realm ? Authorization->realm : "",
Authorization->realm ? "\"" : "",
Authorization->nonce ? ",nonce=\"" : "",
Authorization->nonce ? Authorization->nonce : "",
Authorization->nonce ? "\"" : "",
Authorization->uri ? ",uri=\"" : "",
Authorization->uri ? Authorization->uri : "",
Authorization->uri ? "\"" : "",
Authorization->response ? ",response=\"" : "",
Authorization->response ? Authorization->response : "",
Authorization->response ? "\"" : "",
Authorization->algorithm ? ",algorithm=" : "",
Authorization->algorithm ? Authorization->algorithm : "",
Authorization->cnonce ? ",cnonce=\"" : "",
Authorization->cnonce ? Authorization->cnonce : "",
Authorization->cnonce ? "\"" : "",
Authorization->opaque ? ",opaque=\"" : "",
Authorization->opaque ? Authorization->opaque : "",
Authorization->opaque ? "\"" : "",
Authorization->qop ? ",qop=" : "",
Authorization->qop ? Authorization->qop : "",
Authorization->nc ? ",nc=" : "",
Authorization->nc ? Authorization->nc : ""
);
}
}
return -1;
}
tmsrp_header_Authorization_t *tmsrp_header_Authorization_parse(const char *data, size_t size)
{
tmsrp_header_Authorization_t *hdr_msrp = 0;
thttp_header_Authorization_t* hdr_http;
if((hdr_http = thttp_header_Authorization_parse(data, size)))
{
hdr_msrp = TMSRP_HEADER_AUTHORIZATION_CREATE();
hdr_msrp->scheme = tsk_strdup(hdr_http->scheme);
hdr_msrp->username = tsk_strdup(hdr_http->username);
hdr_msrp->realm = tsk_strdup(hdr_http->realm);
hdr_msrp->nonce = tsk_strdup(hdr_http->nonce);
hdr_msrp->uri = tsk_strdup(hdr_http->uri);
hdr_msrp->response = tsk_strdup(hdr_http->response);
hdr_msrp->algorithm = tsk_strdup(hdr_http->algorithm);
hdr_msrp->cnonce = tsk_strdup(hdr_http->cnonce);
hdr_msrp->opaque = tsk_strdup(hdr_http->opaque);
hdr_msrp->qop = tsk_strdup(hdr_http->qop);
hdr_msrp->nc = tsk_strdup(hdr_http->nc);
hdr_msrp->params = tsk_object_ref(THTTP_HEADER(hdr_http)->params);
TSK_OBJECT_SAFE_FREE(hdr_http);
}
return hdr_msrp;
}
//========================================================
// Authorization header object definition
//
static void* tmsrp_header_Authorization_create(void *self, va_list * app)
{
tmsrp_header_Authorization_t *Authorization = self;
if(Authorization)
{
TMSRP_HEADER(Authorization)->type = tmsrp_htype_Authorization;
TMSRP_HEADER(Authorization)->tostring = tmsrp_header_Authorization_tostring;
}
else
{
TSK_DEBUG_ERROR("Failed to create new Authorization header.");
}
return self;
}
static void* tmsrp_header_Authorization_destroy(void *self)
{
tmsrp_header_Authorization_t *Authorization = self;
if(Authorization)
{
TSK_FREE(Authorization->scheme);
TSK_FREE(Authorization->username);
TSK_FREE(Authorization->realm);
TSK_FREE(Authorization->nonce);
TSK_FREE(Authorization->uri);
TSK_FREE(Authorization->response);
TSK_FREE(Authorization->algorithm);
TSK_FREE(Authorization->cnonce);
TSK_FREE(Authorization->opaque);
TSK_FREE(Authorization->qop);
TSK_FREE(Authorization->nc);
TSK_OBJECT_SAFE_FREE(Authorization->params);
}
else TSK_DEBUG_ERROR("Null Authorization header.");
return self;
}
static const tsk_object_def_t tmsrp_header_Authorization_def_s =
{
sizeof(tmsrp_header_Authorization_t),
tmsrp_header_Authorization_create,
tmsrp_header_Authorization_destroy,
0
};
const void *tmsrp_header_Authorization_def_t = &tmsrp_header_Authorization_def_s;

View File

@ -0,0 +1,380 @@
/* #line 1 "tmsrp_parser_header_Byte-Range.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 82 "tmsrp_parser_header_Byte-Range.rl" */
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_appendEx(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, 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;
/* #line 86 "../src/headers/tmsrp_header_Byte-Range.c" */
static const char _tmsrp_machine_parser_header_Byte_Range_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
3
};
static const char _tmsrp_machine_parser_header_Byte_Range_key_offsets[] = {
0, 0, 2, 4, 6, 8, 9, 11,
13, 15, 17, 19, 20, 21, 23, 26,
29, 30, 33, 34, 37, 38, 38
};
static const char _tmsrp_machine_parser_header_Byte_Range_trans_keys[] = {
66, 98, 89, 121, 84, 116, 69, 101,
45, 82, 114, 65, 97, 78, 110, 71,
103, 69, 101, 58, 32, 48, 57, 45,
48, 57, 42, 48, 57, 47, 42, 48,
57, 10, 47, 48, 57, 13, 13, 48,
57, 0
};
static const char _tmsrp_machine_parser_header_Byte_Range_single_lengths[] = {
0, 2, 2, 2, 2, 1, 2, 2,
2, 2, 2, 1, 1, 0, 1, 1,
1, 1, 1, 1, 1, 0, 1
};
static const char _tmsrp_machine_parser_header_Byte_Range_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 1, 1,
0, 1, 0, 1, 0, 0, 1
};
static const char _tmsrp_machine_parser_header_Byte_Range_index_offsets[] = {
0, 0, 3, 6, 9, 12, 14, 17,
20, 23, 26, 29, 31, 33, 35, 38,
41, 43, 46, 48, 51, 53, 54
};
static const char _tmsrp_machine_parser_header_Byte_Range_indicies[] = {
0, 0, 1, 2, 2, 1, 3, 3,
1, 4, 4, 1, 5, 1, 6, 6,
1, 7, 7, 1, 8, 8, 1, 9,
9, 1, 10, 10, 1, 11, 1, 12,
1, 13, 1, 14, 15, 1, 16, 17,
1, 18, 1, 19, 20, 1, 21, 1,
18, 22, 1, 23, 1, 1, 23, 24,
1, 0
};
static const char _tmsrp_machine_parser_header_Byte_Range_trans_targs[] = {
2, 0, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 14,
16, 19, 17, 20, 22, 21, 19, 18,
22
};
static const char _tmsrp_machine_parser_header_Byte_Range_trans_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 3, 0,
1, 1, 5, 1, 1, 0, 0, 7,
0
};
static const char _tmsrp_machine_parser_header_Byte_Range_eof_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 7, 0, 7
};
static const int tmsrp_machine_parser_header_Byte_Range_start = 1;
static const int tmsrp_machine_parser_header_Byte_Range_first_final = 20;
static const int tmsrp_machine_parser_header_Byte_Range_error = 0;
static const int tmsrp_machine_parser_header_Byte_Range_en_main = 1;
/* #line 122 "tmsrp_parser_header_Byte-Range.rl" */
/* #line 165 "../src/headers/tmsrp_header_Byte-Range.c" */
{
cs = tmsrp_machine_parser_header_Byte_Range_start;
}
/* #line 123 "tmsrp_parser_header_Byte-Range.rl" */
/* #line 172 "../src/headers/tmsrp_header_Byte-Range.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 = _tmsrp_machine_parser_header_Byte_Range_trans_keys + _tmsrp_machine_parser_header_Byte_Range_key_offsets[cs];
_trans = _tmsrp_machine_parser_header_Byte_Range_index_offsets[cs];
_klen = _tmsrp_machine_parser_header_Byte_Range_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 = _tmsrp_machine_parser_header_Byte_Range_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 = _tmsrp_machine_parser_header_Byte_Range_indicies[_trans];
cs = _tmsrp_machine_parser_header_Byte_Range_trans_targs[_trans];
if ( _tmsrp_machine_parser_header_Byte_Range_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_header_Byte_Range_actions + _tmsrp_machine_parser_header_Byte_Range_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 47 "tmsrp_parser_header_Byte-Range.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_Byte-Range.rl" */
{
TSK_PARSER_SET_INTEGER_EX(hdr_Byte_Range->start, int64_t, atoi64);
}
break;
case 2:
/* #line 55 "tmsrp_parser_header_Byte-Range.rl" */
{
if(tag_start && *tag_start == '*'){
hdr_Byte_Range->end = -1;
}
else{
TSK_PARSER_SET_INTEGER_EX(hdr_Byte_Range->end, int64_t, atoi64);
}
}
break;
case 3:
/* #line 64 "tmsrp_parser_header_Byte-Range.rl" */
{
if(tag_start && *tag_start == '*'){
hdr_Byte_Range->end = -1;
}
else{
TSK_PARSER_SET_INTEGER_EX(hdr_Byte_Range->total, int64_t, atoi64);
}
}
break;
/* #line 280 "../src/headers/tmsrp_header_Byte-Range.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_header_Byte_Range_actions + _tmsrp_machine_parser_header_Byte_Range_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 3:
/* #line 64 "tmsrp_parser_header_Byte-Range.rl" */
{
if(tag_start && *tag_start == '*'){
hdr_Byte_Range->end = -1;
}
else{
TSK_PARSER_SET_INTEGER_EX(hdr_Byte_Range->total, int64_t, atoi64);
}
}
break;
/* #line 307 "../src/headers/tmsrp_header_Byte-Range.c" */
}
}
}
_out: {}
}
/* #line 124 "tmsrp_parser_header_Byte-Range.rl" */
if( cs <
/* #line 318 "../src/headers/tmsrp_header_Byte-Range.c" */
20
/* #line 125 "tmsrp_parser_header_Byte-Range.rl" */
){
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 void* tmsrp_header_Byte_Range_create(void *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 void* tmsrp_header_Byte_Range_destroy(void *self)
{
tmsrp_header_Byte_Range_t *Byte_Range = self;
if(Byte_Range){
}
else{
TSK_DEBUG_ERROR("Null Byte-Range header.");
}
return self;
}
static int tmsrp_header_Byte_Range_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Byte_Range_def_s =
{
sizeof(tmsrp_header_Byte_Range_t),
tmsrp_header_Byte_Range_create,
tmsrp_header_Byte_Range_destroy,
tmsrp_header_Byte_Range_cmp
};
const void *tmsrp_header_Byte_Range_def_t = &tmsrp_header_Byte_Range_def_s;

View File

@ -0,0 +1,443 @@
/* #line 1 "tmsrp_parser_header_Content-Type.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 74 "tmsrp_parser_header_Content-Type.rl" */
int tmsrp_header_Content_Type_tostring(const void* header, tsk_buffer_t* output)
{
if(header)
{
const tmsrp_header_Content_Type_t *Content_Type = 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, 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;
/* #line 82 "../src/headers/tmsrp_header_Content-Type.c" */
static const char _tmsrp_machine_parser_header_Content_Type_actions[] = {
0, 1, 0, 1, 1, 1, 2
};
static const short _tmsrp_machine_parser_header_Content_Type_key_offsets[] = {
0, 0, 2, 4, 6, 8, 10, 12,
14, 15, 17, 19, 21, 23, 26, 43,
44, 46, 62, 78, 82, 83, 85, 88,
105, 106, 108, 124, 128, 129, 131, 134,
150, 151, 153, 168, 173, 174, 176, 180,
196, 197, 199, 214, 215, 221, 227, 233,
239, 257, 275, 292
};
static const char _tmsrp_machine_parser_header_Content_Type_trans_keys[] = {
67, 99, 79, 111, 78, 110, 84, 116,
69, 101, 78, 110, 84, 116, 45, 84,
116, 89, 121, 80, 112, 69, 101, 9,
32, 58, 9, 13, 32, 33, 37, 39,
126, 42, 43, 45, 46, 48, 57, 65,
90, 95, 122, 10, 9, 32, 9, 32,
33, 37, 39, 126, 42, 43, 45, 46,
48, 57, 65, 90, 95, 122, 9, 13,
32, 33, 37, 39, 47, 126, 42, 43,
45, 57, 65, 90, 95, 122, 9, 13,
32, 47, 10, 9, 32, 9, 32, 47,
9, 13, 32, 33, 37, 39, 126, 42,
43, 45, 46, 48, 57, 65, 90, 95,
122, 10, 9, 32, 9, 32, 33, 37,
39, 126, 42, 43, 45, 46, 48, 57,
65, 90, 95, 122, 9, 13, 32, 59,
10, 9, 32, 9, 32, 59, 9, 13,
32, 33, 37, 93, 95, 126, 36, 43,
45, 58, 65, 91, 97, 122, 10, 9,
32, 9, 32, 33, 37, 93, 95, 126,
36, 43, 45, 58, 65, 91, 97, 122,
9, 13, 32, 59, 61, 10, 9, 32,
9, 32, 59, 61, 9, 13, 32, 33,
37, 93, 95, 126, 36, 43, 45, 58,
65, 91, 97, 122, 10, 9, 32, 9,
32, 33, 37, 93, 95, 126, 36, 43,
45, 58, 65, 91, 97, 122, 10, 48,
57, 65, 70, 97, 102, 48, 57, 65,
70, 97, 102, 48, 57, 65, 70, 97,
102, 48, 57, 65, 70, 97, 102, 9,
13, 32, 33, 37, 39, 59, 126, 42,
43, 45, 46, 48, 57, 65, 90, 95,
122, 9, 13, 32, 33, 37, 59, 61,
93, 95, 126, 36, 43, 45, 58, 65,
91, 97, 122, 9, 13, 32, 33, 37,
59, 93, 95, 126, 36, 43, 45, 58,
65, 91, 97, 122, 0
};
static const char _tmsrp_machine_parser_header_Content_Type_single_lengths[] = {
0, 2, 2, 2, 2, 2, 2, 2,
1, 2, 2, 2, 2, 3, 7, 1,
2, 6, 8, 4, 1, 2, 3, 7,
1, 2, 6, 4, 1, 2, 3, 8,
1, 2, 7, 5, 1, 2, 4, 8,
1, 2, 7, 1, 0, 0, 0, 0,
8, 10, 9, 0
};
static const char _tmsrp_machine_parser_header_Content_Type_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 5, 0,
0, 5, 4, 0, 0, 0, 0, 5,
0, 0, 5, 0, 0, 0, 0, 4,
0, 0, 4, 0, 0, 0, 0, 4,
0, 0, 4, 0, 3, 3, 3, 3,
5, 4, 4, 0
};
static const short _tmsrp_machine_parser_header_Content_Type_index_offsets[] = {
0, 0, 3, 6, 9, 12, 15, 18,
21, 23, 26, 29, 32, 35, 39, 52,
54, 57, 69, 82, 87, 89, 92, 96,
109, 111, 114, 126, 131, 133, 136, 140,
153, 155, 158, 170, 176, 178, 181, 186,
199, 201, 204, 216, 218, 222, 226, 230,
234, 248, 263, 277
};
static const char _tmsrp_machine_parser_header_Content_Type_indicies[] = {
0, 0, 1, 2, 2, 1, 3, 3,
1, 4, 4, 1, 5, 5, 1, 6,
6, 1, 7, 7, 1, 8, 1, 9,
9, 1, 10, 10, 1, 11, 11, 1,
12, 12, 1, 12, 12, 13, 1, 13,
14, 13, 15, 15, 15, 15, 15, 15,
15, 15, 15, 1, 16, 1, 17, 17,
1, 17, 17, 15, 15, 15, 15, 15,
15, 15, 15, 15, 1, 18, 19, 18,
20, 20, 20, 21, 20, 20, 20, 20,
20, 1, 18, 19, 18, 21, 1, 22,
1, 23, 23, 1, 23, 23, 21, 1,
21, 24, 21, 25, 25, 25, 25, 25,
25, 25, 25, 25, 1, 26, 1, 27,
27, 1, 27, 27, 25, 25, 25, 25,
25, 25, 25, 25, 25, 1, 28, 29,
28, 30, 1, 31, 1, 32, 32, 1,
32, 32, 30, 1, 30, 33, 30, 34,
35, 34, 34, 34, 34, 34, 34, 34,
1, 36, 1, 37, 37, 1, 37, 37,
34, 35, 34, 34, 34, 34, 34, 34,
34, 1, 38, 39, 38, 30, 40, 1,
41, 1, 42, 42, 1, 42, 42, 30,
40, 1, 40, 43, 40, 44, 45, 44,
44, 44, 44, 44, 44, 44, 1, 46,
1, 47, 47, 1, 47, 47, 44, 45,
44, 44, 44, 44, 44, 44, 44, 1,
48, 1, 49, 49, 49, 1, 44, 44,
44, 1, 50, 50, 50, 1, 51, 51,
51, 1, 52, 53, 52, 25, 25, 25,
54, 25, 25, 25, 25, 25, 25, 1,
55, 56, 55, 51, 57, 58, 40, 51,
51, 51, 51, 51, 51, 51, 1, 59,
56, 59, 44, 45, 58, 44, 44, 44,
44, 44, 44, 44, 1, 1, 0
};
static const char _tmsrp_machine_parser_header_Content_Type_trans_targs[] = {
2, 0, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 18,
16, 17, 19, 20, 18, 23, 21, 22,
24, 48, 25, 26, 27, 28, 31, 29,
30, 32, 49, 46, 33, 34, 35, 36,
39, 37, 38, 40, 50, 44, 41, 42,
51, 45, 47, 49, 27, 43, 31, 35,
43, 46, 31, 27
};
static const char _tmsrp_machine_parser_header_Content_Type_trans_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 3, 3, 3, 5,
5, 0, 5, 5
};
static const char _tmsrp_machine_parser_header_Content_Type_eof_actions[] = {
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, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
3, 5, 5, 0
};
static const int tmsrp_machine_parser_header_Content_Type_start = 1;
static const int tmsrp_machine_parser_header_Content_Type_first_final = 48;
static const int tmsrp_machine_parser_header_Content_Type_error = 0;
static const int tmsrp_machine_parser_header_Content_Type_en_main = 1;
/* #line 107 "tmsrp_parser_header_Content-Type.rl" */
/* #line 246 "../src/headers/tmsrp_header_Content-Type.c" */
{
cs = tmsrp_machine_parser_header_Content_Type_start;
}
/* #line 108 "tmsrp_parser_header_Content-Type.rl" */
/* #line 253 "../src/headers/tmsrp_header_Content-Type.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 = _tmsrp_machine_parser_header_Content_Type_trans_keys + _tmsrp_machine_parser_header_Content_Type_key_offsets[cs];
_trans = _tmsrp_machine_parser_header_Content_Type_index_offsets[cs];
_klen = _tmsrp_machine_parser_header_Content_Type_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 = _tmsrp_machine_parser_header_Content_Type_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 = _tmsrp_machine_parser_header_Content_Type_indicies[_trans];
cs = _tmsrp_machine_parser_header_Content_Type_trans_targs[_trans];
if ( _tmsrp_machine_parser_header_Content_Type_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_header_Content_Type_actions + _tmsrp_machine_parser_header_Content_Type_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 50 "tmsrp_parser_header_Content-Type.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 54 "tmsrp_parser_header_Content-Type.rl" */
{
TSK_PARSER_SET_STRING(hdr_ctype->value);
}
break;
case 2:
/* #line 58 "tmsrp_parser_header_Content-Type.rl" */
{
TSK_PARSER_ADD_PARAM(hdr_ctype->params);
}
break;
/* #line 345 "../src/headers/tmsrp_header_Content-Type.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_header_Content_Type_actions + _tmsrp_machine_parser_header_Content_Type_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 1:
/* #line 54 "tmsrp_parser_header_Content-Type.rl" */
{
TSK_PARSER_SET_STRING(hdr_ctype->value);
}
break;
case 2:
/* #line 58 "tmsrp_parser_header_Content-Type.rl" */
{
TSK_PARSER_ADD_PARAM(hdr_ctype->params);
}
break;
/* #line 373 "../src/headers/tmsrp_header_Content-Type.c" */
}
}
}
_out: {}
}
/* #line 109 "tmsrp_parser_header_Content-Type.rl" */
if( cs <
/* #line 384 "../src/headers/tmsrp_header_Content-Type.c" */
48
/* #line 110 "tmsrp_parser_header_Content-Type.rl" */
)
{
TSK_OBJECT_SAFE_FREE(hdr_ctype);
}
return hdr_ctype;
}
//========================================================
// Content_Type header object definition
//
/**@ingroup tmsrp_header_Content_Type_group
*/
static void* tmsrp_header_Content_Type_create(void *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 void* tmsrp_header_Content_Type_destroy(void *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_create,
tmsrp_header_Content_Type_destroy,
0
};
const void *tmsrp_header_Content_Type_def_t = &tmsrp_header_Content_Type_def_s;

View File

@ -0,0 +1,350 @@
/* #line 1 "tmsrp_parser_header_Dummy.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 65 "tmsrp_parser_header_Dummy.rl" */
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, 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;
/* #line 73 "../src/headers/tmsrp_header_Dummy.c" */
static const char _tmsrp_machine_parser_header_Dummy_actions[] = {
0, 1, 0, 1, 1, 1, 2, 2,
0, 2
};
static const char _tmsrp_machine_parser_header_Dummy_key_offsets[] = {
0, 0, 14, 30, 32, 34, 36, 38,
40, 42, 43, 58, 72
};
static const char _tmsrp_machine_parser_header_Dummy_trans_keys[] = {
33, 37, 39, 126, 42, 43, 45, 46,
48, 57, 65, 90, 95, 122, 32, 33,
37, 39, 58, 126, 42, 43, 45, 46,
48, 57, 65, 90, 95, 122, 32, 58,
-128, -65, -128, -65, -128, -65, -128, -65,
-128, -65, 10, 9, 13, 32, -64, -33,
-32, -17, -16, -9, -8, -5, -4, -3,
33, 126, 9, 13, -64, -33, -32, -17,
-16, -9, -8, -5, -4, -3, 32, 126,
0
};
static const char _tmsrp_machine_parser_header_Dummy_single_lengths[] = {
0, 4, 6, 2, 0, 0, 0, 0,
0, 1, 3, 2, 0
};
static const char _tmsrp_machine_parser_header_Dummy_range_lengths[] = {
0, 5, 5, 0, 1, 1, 1, 1,
1, 0, 6, 6, 0
};
static const char _tmsrp_machine_parser_header_Dummy_index_offsets[] = {
0, 0, 10, 22, 25, 27, 29, 31,
33, 35, 37, 47, 56
};
static const char _tmsrp_machine_parser_header_Dummy_indicies[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 2, 3, 3, 3, 4, 3,
3, 3, 3, 3, 3, 1, 5, 6,
1, 7, 1, 8, 1, 9, 1, 10,
1, 11, 1, 12, 1, 18, 19, 6,
13, 14, 15, 16, 17, 18, 1, 7,
21, 8, 9, 10, 11, 20, 7, 1,
1, 0
};
static const char _tmsrp_machine_parser_header_Dummy_trans_targs[] = {
2, 0, 3, 2, 10, 3, 10, 11,
4, 5, 6, 7, 12, 4, 5, 6,
7, 8, 11, 9, 8, 9
};
static const char _tmsrp_machine_parser_header_Dummy_trans_actions[] = {
1, 0, 3, 0, 3, 0, 0, 0,
0, 0, 0, 0, 0, 1, 1, 1,
1, 1, 1, 7, 0, 5
};
static const char _tmsrp_machine_parser_header_Dummy_eof_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 7, 5, 0
};
static const int tmsrp_machine_parser_header_Dummy_start = 1;
static const int tmsrp_machine_parser_header_Dummy_first_final = 10;
static const int tmsrp_machine_parser_header_Dummy_error = 0;
static const int tmsrp_machine_parser_header_Dummy_en_main = 1;
/* #line 92 "tmsrp_parser_header_Dummy.rl" */
/* #line 149 "../src/headers/tmsrp_header_Dummy.c" */
{
cs = tmsrp_machine_parser_header_Dummy_start;
}
/* #line 93 "tmsrp_parser_header_Dummy.rl" */
/* #line 156 "../src/headers/tmsrp_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 = _tmsrp_machine_parser_header_Dummy_trans_keys + _tmsrp_machine_parser_header_Dummy_key_offsets[cs];
_trans = _tmsrp_machine_parser_header_Dummy_index_offsets[cs];
_klen = _tmsrp_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 = _tmsrp_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:
_trans = _tmsrp_machine_parser_header_Dummy_indicies[_trans];
cs = _tmsrp_machine_parser_header_Dummy_trans_targs[_trans];
if ( _tmsrp_machine_parser_header_Dummy_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_header_Dummy_actions + _tmsrp_machine_parser_header_Dummy_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 47 "tmsrp_parser_header_Dummy.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_Dummy.rl" */
{
TSK_PARSER_SET_STRING(hdr_Dummy->name);
}
break;
case 2:
/* #line 55 "tmsrp_parser_header_Dummy.rl" */
{
TSK_PARSER_SET_STRING(hdr_Dummy->value);
}
break;
/* #line 248 "../src/headers/tmsrp_header_Dummy.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_header_Dummy_actions + _tmsrp_machine_parser_header_Dummy_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 0:
/* #line 47 "tmsrp_parser_header_Dummy.rl" */
{
tag_start = p;
}
break;
case 2:
/* #line 55 "tmsrp_parser_header_Dummy.rl" */
{
TSK_PARSER_SET_STRING(hdr_Dummy->value);
}
break;
/* #line 276 "../src/headers/tmsrp_header_Dummy.c" */
}
}
}
_out: {}
}
/* #line 94 "tmsrp_parser_header_Dummy.rl" */
if( cs <
/* #line 287 "../src/headers/tmsrp_header_Dummy.c" */
10
/* #line 95 "tmsrp_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 void* tmsrp_header_Dummy_create(void *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 void* tmsrp_header_Dummy_destroy(void *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 int tmsrp_header_Dummy_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Dummy_def_s =
{
sizeof(tmsrp_header_Dummy_t),
tmsrp_header_Dummy_create,
tmsrp_header_Dummy_destroy,
tmsrp_header_Dummy_cmp
};
const void *tmsrp_header_Dummy_def_t = &tmsrp_header_Dummy_def_s;

View File

@ -0,0 +1,322 @@
/* #line 1 "tmsrp_parser_header_Expires.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 61 "tmsrp_parser_header_Expires.rl" */
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_appendEx(output, "%lld", Expires->value);
}
return 0;
}
return -1;
}
tmsrp_header_Expires_t *tmsrp_header_Expires_parse(const char *data, 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;
/* #line 73 "../src/headers/tmsrp_header_Expires.c" */
static const char _tmsrp_machine_parser_header_Expires_actions[] = {
0, 1, 0, 1, 1
};
static const char _tmsrp_machine_parser_header_Expires_key_offsets[] = {
0, 0, 2, 4, 6, 8, 10, 12,
14, 15, 16, 18, 19, 22
};
static const char _tmsrp_machine_parser_header_Expires_trans_keys[] = {
69, 101, 88, 120, 80, 112, 73, 105,
82, 114, 69, 101, 83, 115, 58, 32,
48, 57, 10, 13, 48, 57, 0
};
static const char _tmsrp_machine_parser_header_Expires_single_lengths[] = {
0, 2, 2, 2, 2, 2, 2, 2,
1, 1, 0, 1, 1, 0
};
static const char _tmsrp_machine_parser_header_Expires_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 1, 0
};
static const char _tmsrp_machine_parser_header_Expires_index_offsets[] = {
0, 0, 3, 6, 9, 12, 15, 18,
21, 23, 25, 27, 29, 32
};
static const char _tmsrp_machine_parser_header_Expires_indicies[] = {
0, 0, 1, 2, 2, 1, 3, 3,
1, 4, 4, 1, 5, 5, 1, 6,
6, 1, 7, 7, 1, 8, 1, 9,
1, 10, 1, 11, 1, 12, 13, 1,
1, 0
};
static const char _tmsrp_machine_parser_header_Expires_trans_targs[] = {
2, 0, 3, 4, 5, 6, 7, 8,
9, 10, 12, 13, 11, 12
};
static const char _tmsrp_machine_parser_header_Expires_trans_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 3, 0
};
static const char _tmsrp_machine_parser_header_Expires_eof_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 3, 0
};
static const int tmsrp_machine_parser_header_Expires_start = 1;
static const int tmsrp_machine_parser_header_Expires_first_final = 12;
static const int tmsrp_machine_parser_header_Expires_error = 0;
static const int tmsrp_machine_parser_header_Expires_en_main = 1;
/* #line 88 "tmsrp_parser_header_Expires.rl" */
/* #line 136 "../src/headers/tmsrp_header_Expires.c" */
{
cs = tmsrp_machine_parser_header_Expires_start;
}
/* #line 89 "tmsrp_parser_header_Expires.rl" */
/* #line 143 "../src/headers/tmsrp_header_Expires.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 = _tmsrp_machine_parser_header_Expires_trans_keys + _tmsrp_machine_parser_header_Expires_key_offsets[cs];
_trans = _tmsrp_machine_parser_header_Expires_index_offsets[cs];
_klen = _tmsrp_machine_parser_header_Expires_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 = _tmsrp_machine_parser_header_Expires_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 = _tmsrp_machine_parser_header_Expires_indicies[_trans];
cs = _tmsrp_machine_parser_header_Expires_trans_targs[_trans];
if ( _tmsrp_machine_parser_header_Expires_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_header_Expires_actions + _tmsrp_machine_parser_header_Expires_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 47 "tmsrp_parser_header_Expires.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_Expires.rl" */
{
TSK_PARSER_SET_INTEGER_EX(hdr_Expires->value, int64_t, atoi64)
}
break;
/* #line 229 "../src/headers/tmsrp_header_Expires.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_header_Expires_actions + _tmsrp_machine_parser_header_Expires_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 1:
/* #line 51 "tmsrp_parser_header_Expires.rl" */
{
TSK_PARSER_SET_INTEGER_EX(hdr_Expires->value, int64_t, atoi64)
}
break;
/* #line 251 "../src/headers/tmsrp_header_Expires.c" */
}
}
}
_out: {}
}
/* #line 90 "tmsrp_parser_header_Expires.rl" */
if( cs <
/* #line 262 "../src/headers/tmsrp_header_Expires.c" */
12
/* #line 91 "tmsrp_parser_header_Expires.rl" */
){
TSK_DEBUG_ERROR("Failed to parse 'Expires' header.");
TSK_OBJECT_SAFE_FREE(hdr_Expires);
}
return hdr_Expires;
}
//========================================================
// Expires header object definition
//
static void* tmsrp_header_Expires_create(void *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 void* tmsrp_header_Expires_destroy(void *self)
{
tmsrp_header_Expires_t *Expires = self;
if(Expires){
}
else{
TSK_DEBUG_ERROR("Null Expires header.");
}
return self;
}
static int tmsrp_header_Expires_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Expires_def_s =
{
sizeof(tmsrp_header_Expires_t),
tmsrp_header_Expires_create,
tmsrp_header_Expires_destroy,
tmsrp_header_Expires_cmp
};
const void *tmsrp_header_Expires_def_t = &tmsrp_header_Expires_def_s;

View File

@ -0,0 +1,364 @@
/* #line 1 "tmsrp_parser_header_Failure-Report.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 65 "tmsrp_parser_header_Failure-Report.rl" */
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, 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();
/* #line 69 "../src/headers/tmsrp_header_Failure-Report.c" */
static const char _tmsrp_machine_parser_header_Failure_Report_actions[] = {
0, 1, 0, 1, 1, 1, 2
};
static const char _tmsrp_machine_parser_header_Failure_Report_key_offsets[] = {
0, 0, 2, 4, 6, 8, 10, 12,
14, 15, 17, 19, 21, 23, 25, 27,
28, 29, 35, 37, 38, 40, 42, 44,
46, 48, 50, 52, 54, 55, 55, 56
};
static const char _tmsrp_machine_parser_header_Failure_Report_trans_keys[] = {
70, 102, 65, 97, 73, 105, 76, 108,
85, 117, 82, 114, 69, 101, 45, 82,
114, 69, 101, 80, 112, 79, 111, 82,
114, 84, 116, 58, 32, 78, 80, 89,
110, 112, 121, 79, 111, 10, 65, 97,
82, 114, 84, 116, 73, 105, 65, 97,
76, 108, 69, 101, 83, 115, 13, 13,
13, 0
};
static const char _tmsrp_machine_parser_header_Failure_Report_single_lengths[] = {
0, 2, 2, 2, 2, 2, 2, 2,
1, 2, 2, 2, 2, 2, 2, 1,
1, 6, 2, 1, 2, 2, 2, 2,
2, 2, 2, 2, 1, 0, 1, 1
};
static const char _tmsrp_machine_parser_header_Failure_Report_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
};
static const char _tmsrp_machine_parser_header_Failure_Report_index_offsets[] = {
0, 0, 3, 6, 9, 12, 15, 18,
21, 23, 26, 29, 32, 35, 38, 41,
43, 45, 52, 55, 57, 60, 63, 66,
69, 72, 75, 78, 81, 83, 84, 86
};
static const char _tmsrp_machine_parser_header_Failure_Report_indicies[] = {
0, 0, 1, 2, 2, 1, 3, 3,
1, 4, 4, 1, 5, 5, 1, 6,
6, 1, 7, 7, 1, 8, 1, 9,
9, 1, 10, 10, 1, 11, 11, 1,
12, 12, 1, 13, 13, 1, 14, 14,
1, 15, 1, 16, 1, 17, 18, 19,
17, 18, 19, 1, 20, 20, 1, 21,
1, 22, 22, 1, 23, 23, 1, 24,
24, 1, 25, 25, 1, 26, 26, 1,
27, 27, 1, 28, 28, 1, 29, 29,
1, 30, 1, 1, 31, 1, 32, 1,
0
};
static const char _tmsrp_machine_parser_header_Failure_Report_trans_targs[] = {
2, 0, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 20, 26, 28, 29, 21, 22,
23, 24, 25, 30, 27, 31, 19, 19,
19
};
static const char _tmsrp_machine_parser_header_Failure_Report_trans_actions[] = {
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, 3, 5,
1
};
static const char _tmsrp_machine_parser_header_Failure_Report_eof_actions[] = {
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, 3, 0, 5, 1
};
static const int tmsrp_machine_parser_header_Failure_Report_start = 1;
static const int tmsrp_machine_parser_header_Failure_Report_first_final = 28;
static const int tmsrp_machine_parser_header_Failure_Report_error = 0;
static const int tmsrp_machine_parser_header_Failure_Report_en_main = 1;
/* #line 88 "tmsrp_parser_header_Failure-Report.rl" */
/* #line 160 "../src/headers/tmsrp_header_Failure-Report.c" */
{
cs = tmsrp_machine_parser_header_Failure_Report_start;
}
/* #line 89 "tmsrp_parser_header_Failure-Report.rl" */
/* #line 167 "../src/headers/tmsrp_header_Failure-Report.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 = _tmsrp_machine_parser_header_Failure_Report_trans_keys + _tmsrp_machine_parser_header_Failure_Report_key_offsets[cs];
_trans = _tmsrp_machine_parser_header_Failure_Report_index_offsets[cs];
_klen = _tmsrp_machine_parser_header_Failure_Report_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 = _tmsrp_machine_parser_header_Failure_Report_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 = _tmsrp_machine_parser_header_Failure_Report_indicies[_trans];
cs = _tmsrp_machine_parser_header_Failure_Report_trans_targs[_trans];
if ( _tmsrp_machine_parser_header_Failure_Report_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_header_Failure_Report_actions + _tmsrp_machine_parser_header_Failure_Report_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 47 "tmsrp_parser_header_Failure-Report.rl" */
{
hdr_Failure_Report->type = freport_yes;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_Failure-Report.rl" */
{
hdr_Failure_Report->type = freport_no;
}
break;
case 2:
/* #line 55 "tmsrp_parser_header_Failure-Report.rl" */
{
hdr_Failure_Report->type = freport_partial;
}
break;
/* #line 259 "../src/headers/tmsrp_header_Failure-Report.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_header_Failure_Report_actions + _tmsrp_machine_parser_header_Failure_Report_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 0:
/* #line 47 "tmsrp_parser_header_Failure-Report.rl" */
{
hdr_Failure_Report->type = freport_yes;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_Failure-Report.rl" */
{
hdr_Failure_Report->type = freport_no;
}
break;
case 2:
/* #line 55 "tmsrp_parser_header_Failure-Report.rl" */
{
hdr_Failure_Report->type = freport_partial;
}
break;
/* #line 293 "../src/headers/tmsrp_header_Failure-Report.c" */
}
}
}
_out: {}
}
/* #line 90 "tmsrp_parser_header_Failure-Report.rl" */
if( cs <
/* #line 304 "../src/headers/tmsrp_header_Failure-Report.c" */
28
/* #line 91 "tmsrp_parser_header_Failure-Report.rl" */
){
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 void* tmsrp_header_Failure_Report_create(void *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 void* tmsrp_header_Failure_Report_destroy(void *self)
{
tmsrp_header_Failure_Report_t *Failure_Report = self;
if(Failure_Report){
}
else{
TSK_DEBUG_ERROR("Null Failure-Report header.");
}
return self;
}
static int tmsrp_header_Failure_Report_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Failure_Report_def_s =
{
sizeof(tmsrp_header_Failure_Report_t),
tmsrp_header_Failure_Report_create,
tmsrp_header_Failure_Report_destroy,
tmsrp_header_Failure_Report_cmp
};
const void *tmsrp_header_Failure_Report_def_t = &tmsrp_header_Failure_Report_def_s;

View File

@ -0,0 +1,363 @@
/* #line 1 "tmsrp_parser_header_From-Path.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 75 "tmsrp_parser_header_From-Path.rl" */
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, 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;
/* #line 78 "../src/headers/tmsrp_header_From-Path.c" */
static const char _tmsrp_machine_parser_header_From_Path_actions[] = {
0, 1, 0, 1, 1, 2, 0, 1
};
static const char _tmsrp_machine_parser_header_From_Path_key_offsets[] = {
0, 0, 2, 4, 6, 8, 9, 11,
13, 15, 17, 18, 19, 20, 22, 24
};
static const char _tmsrp_machine_parser_header_From_Path_trans_keys[] = {
70, 102, 82, 114, 79, 111, 77, 109,
45, 80, 112, 65, 97, 84, 116, 72,
104, 58, 32, 10, 13, 32, 13, 32,
0
};
static const char _tmsrp_machine_parser_header_From_Path_single_lengths[] = {
0, 2, 2, 2, 2, 1, 2, 2,
2, 2, 1, 1, 1, 2, 2, 0
};
static const char _tmsrp_machine_parser_header_From_Path_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
static const char _tmsrp_machine_parser_header_From_Path_index_offsets[] = {
0, 0, 3, 6, 9, 12, 14, 17,
20, 23, 26, 28, 30, 32, 35, 38
};
static const char _tmsrp_machine_parser_header_From_Path_indicies[] = {
0, 0, 1, 2, 2, 1, 3, 3,
1, 4, 4, 1, 5, 1, 6, 6,
1, 7, 7, 1, 8, 8, 1, 9,
9, 1, 10, 1, 11, 1, 12, 1,
14, 15, 13, 17, 18, 16, 1, 0
};
static const char _tmsrp_machine_parser_header_From_Path_trans_targs[] = {
2, 0, 3, 4, 5, 6, 7, 8,
9, 10, 11, 13, 15, 14, 12, 13,
14, 12, 13
};
static const char _tmsrp_machine_parser_header_From_Path_trans_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 5, 5,
0, 3, 3
};
static const char _tmsrp_machine_parser_header_From_Path_eof_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 5, 3, 0
};
static const int tmsrp_machine_parser_header_From_Path_start = 1;
static const int tmsrp_machine_parser_header_From_Path_first_final = 13;
static const int tmsrp_machine_parser_header_From_Path_error = 0;
static const int tmsrp_machine_parser_header_From_Path_en_main = 1;
/* #line 107 "tmsrp_parser_header_From-Path.rl" */
/* #line 145 "../src/headers/tmsrp_header_From-Path.c" */
{
cs = tmsrp_machine_parser_header_From_Path_start;
}
/* #line 108 "tmsrp_parser_header_From-Path.rl" */
/* #line 152 "../src/headers/tmsrp_header_From-Path.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 = _tmsrp_machine_parser_header_From_Path_trans_keys + _tmsrp_machine_parser_header_From_Path_key_offsets[cs];
_trans = _tmsrp_machine_parser_header_From_Path_index_offsets[cs];
_klen = _tmsrp_machine_parser_header_From_Path_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 = _tmsrp_machine_parser_header_From_Path_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 = _tmsrp_machine_parser_header_From_Path_indicies[_trans];
cs = _tmsrp_machine_parser_header_From_Path_trans_targs[_trans];
if ( _tmsrp_machine_parser_header_From_Path_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_header_From_Path_actions + _tmsrp_machine_parser_header_From_Path_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 47 "tmsrp_parser_header_From-Path.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_From-Path.rl" */
{
int len = (int)(p - tag_start);
tmsrp_uri_t* uri;
if((uri = tmsrp_uri_parse(tag_start, (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));
}
}
}
break;
/* #line 250 "../src/headers/tmsrp_header_From-Path.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_header_From_Path_actions + _tmsrp_machine_parser_header_From_Path_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 0:
/* #line 47 "tmsrp_parser_header_From-Path.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_From-Path.rl" */
{
int len = (int)(p - tag_start);
tmsrp_uri_t* uri;
if((uri = tmsrp_uri_parse(tag_start, (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));
}
}
}
break;
/* #line 290 "../src/headers/tmsrp_header_From-Path.c" */
}
}
}
_out: {}
}
/* #line 109 "tmsrp_parser_header_From-Path.rl" */
if( cs <
/* #line 301 "../src/headers/tmsrp_header_From-Path.c" */
13
/* #line 110 "tmsrp_parser_header_From-Path.rl" */
){
TSK_DEBUG_ERROR("Failed to parse 'From-Path' header.");
TSK_OBJECT_SAFE_FREE(header);
}
return header;
}
//========================================================
// From_Path header object definition
//
static void* tmsrp_header_From_Path_create(void *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 void* tmsrp_header_From_Path_destroy(void *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 int tmsrp_header_From_Path_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_From_Path_def_s =
{
sizeof(tmsrp_header_From_Path_t),
tmsrp_header_From_Path_create,
tmsrp_header_From_Path_destroy,
tmsrp_header_From_Path_cmp
};
const void *tmsrp_header_From_Path_def_t = &tmsrp_header_From_Path_def_s;

View File

@ -0,0 +1,331 @@
/* #line 1 "tmsrp_parser_header_Max-Expires.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 61 "tmsrp_parser_header_Max-Expires.rl" */
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_appendEx(output, "%lld", Max_Expires->value);
}
return 0;
}
return -1;
}
tmsrp_header_Max_Expires_t *tmsrp_header_Max_Expires_parse(const char *data, 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;
/* #line 73 "../src/headers/tmsrp_header_Max-Expires.c" */
static const char _tmsrp_machine_parser_header_Max_Expires_actions[] = {
0, 1, 0, 1, 1
};
static const char _tmsrp_machine_parser_header_Max_Expires_key_offsets[] = {
0, 0, 2, 4, 6, 7, 9, 11,
13, 15, 17, 19, 21, 22, 23, 25,
26, 29
};
static const char _tmsrp_machine_parser_header_Max_Expires_trans_keys[] = {
77, 109, 65, 97, 88, 120, 45, 69,
101, 88, 120, 80, 112, 73, 105, 82,
114, 69, 101, 83, 115, 58, 32, 48,
57, 10, 13, 48, 57, 0
};
static const char _tmsrp_machine_parser_header_Max_Expires_single_lengths[] = {
0, 2, 2, 2, 1, 2, 2, 2,
2, 2, 2, 2, 1, 1, 0, 1,
1, 0
};
static const char _tmsrp_machine_parser_header_Max_Expires_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0,
1, 0
};
static const char _tmsrp_machine_parser_header_Max_Expires_index_offsets[] = {
0, 0, 3, 6, 9, 11, 14, 17,
20, 23, 26, 29, 32, 34, 36, 38,
40, 43
};
static const char _tmsrp_machine_parser_header_Max_Expires_indicies[] = {
0, 0, 1, 2, 2, 1, 3, 3,
1, 4, 1, 5, 5, 1, 6, 6,
1, 7, 7, 1, 8, 8, 1, 9,
9, 1, 10, 10, 1, 11, 11, 1,
12, 1, 13, 1, 14, 1, 15, 1,
16, 17, 1, 1, 0
};
static const char _tmsrp_machine_parser_header_Max_Expires_trans_targs[] = {
2, 0, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 16, 17,
15, 16
};
static const char _tmsrp_machine_parser_header_Max_Expires_trans_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0,
3, 0
};
static const char _tmsrp_machine_parser_header_Max_Expires_eof_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
3, 0
};
static const int tmsrp_machine_parser_header_Max_Expires_start = 1;
static const int tmsrp_machine_parser_header_Max_Expires_first_final = 16;
static const int tmsrp_machine_parser_header_Max_Expires_error = 0;
static const int tmsrp_machine_parser_header_Max_Expires_en_main = 1;
/* #line 88 "tmsrp_parser_header_Max-Expires.rl" */
/* #line 145 "../src/headers/tmsrp_header_Max-Expires.c" */
{
cs = tmsrp_machine_parser_header_Max_Expires_start;
}
/* #line 89 "tmsrp_parser_header_Max-Expires.rl" */
/* #line 152 "../src/headers/tmsrp_header_Max-Expires.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 = _tmsrp_machine_parser_header_Max_Expires_trans_keys + _tmsrp_machine_parser_header_Max_Expires_key_offsets[cs];
_trans = _tmsrp_machine_parser_header_Max_Expires_index_offsets[cs];
_klen = _tmsrp_machine_parser_header_Max_Expires_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 = _tmsrp_machine_parser_header_Max_Expires_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 = _tmsrp_machine_parser_header_Max_Expires_indicies[_trans];
cs = _tmsrp_machine_parser_header_Max_Expires_trans_targs[_trans];
if ( _tmsrp_machine_parser_header_Max_Expires_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_header_Max_Expires_actions + _tmsrp_machine_parser_header_Max_Expires_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 47 "tmsrp_parser_header_Max-Expires.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_Max-Expires.rl" */
{
TSK_PARSER_SET_INTEGER_EX(hdr_Max_Expires->value, int64_t, atoi64)
}
break;
/* #line 238 "../src/headers/tmsrp_header_Max-Expires.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_header_Max_Expires_actions + _tmsrp_machine_parser_header_Max_Expires_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 1:
/* #line 51 "tmsrp_parser_header_Max-Expires.rl" */
{
TSK_PARSER_SET_INTEGER_EX(hdr_Max_Expires->value, int64_t, atoi64)
}
break;
/* #line 260 "../src/headers/tmsrp_header_Max-Expires.c" */
}
}
}
_out: {}
}
/* #line 90 "tmsrp_parser_header_Max-Expires.rl" */
if( cs <
/* #line 271 "../src/headers/tmsrp_header_Max-Expires.c" */
16
/* #line 91 "tmsrp_parser_header_Max-Expires.rl" */
){
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 void* tmsrp_header_Max_Expires_create(void *self, va_list * app)
{
tmsrp_header_Max_Expires_t *Max_Expires = self;
if(Max_Expires)
{
TMSRP_HEADER(Max_Expires)->type = tmsrp_htype_Message_ID;
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 void* tmsrp_header_Max_Expires_destroy(void *self)
{
tmsrp_header_Max_Expires_t *Max_Expires = self;
if(Max_Expires){
}
else{
TSK_DEBUG_ERROR("Null Max-Expires header.");
}
return self;
}
static int tmsrp_header_Max_Expires_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Max_Expires_def_s =
{
sizeof(tmsrp_header_Max_Expires_t),
tmsrp_header_Max_Expires_create,
tmsrp_header_Max_Expires_destroy,
tmsrp_header_Max_Expires_cmp
};
const void *tmsrp_header_Max_Expires_def_t = &tmsrp_header_Max_Expires_def_s;

View File

@ -0,0 +1,433 @@
/* #line 1 "tmsrp_parser_header_Message-ID.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 61 "tmsrp_parser_header_Message-ID.rl" */
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, 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;
/* #line 73 "../src/headers/tmsrp_header_Message-ID.c" */
static const char _tmsrp_machine_parser_header_Message_Id_actions[] = {
0, 1, 0, 1, 1
};
static const short _tmsrp_machine_parser_header_Message_Id_key_offsets[] = {
0, 0, 2, 4, 6, 8, 10, 12,
14, 15, 17, 19, 20, 21, 27, 38,
49, 60, 61, 73, 73, 85, 97, 109,
121, 133, 145, 157, 169, 181, 193, 205,
217, 229, 241, 253, 265, 277, 289, 301,
313, 325, 337, 349, 361, 373, 385, 397
};
static const char _tmsrp_machine_parser_header_Message_Id_trans_keys[] = {
77, 109, 69, 101, 83, 115, 83, 115,
65, 97, 71, 103, 69, 101, 45, 73,
105, 68, 100, 58, 32, 48, 57, 65,
90, 97, 122, 37, 43, 61, 45, 46,
48, 57, 65, 90, 97, 122, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 37, 43, 61, 45, 46, 48, 57,
65, 90, 97, 122, 10, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 37, 43,
61, 45, 46, 48, 57, 65, 90, 97,
122, 13, 37, 43, 61, 45, 46, 48,
57, 65, 90, 97, 122, 13, 0
};
static const char _tmsrp_machine_parser_header_Message_Id_single_lengths[] = {
0, 2, 2, 2, 2, 2, 2, 2,
1, 2, 2, 1, 1, 0, 3, 3,
3, 1, 4, 0, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 1
};
static const char _tmsrp_machine_parser_header_Message_Id_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 3, 4, 4,
4, 0, 4, 0, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 0
};
static const short _tmsrp_machine_parser_header_Message_Id_index_offsets[] = {
0, 0, 3, 6, 9, 12, 15, 18,
21, 23, 26, 29, 31, 33, 37, 45,
53, 61, 63, 72, 73, 82, 91, 100,
109, 118, 127, 136, 145, 154, 163, 172,
181, 190, 199, 208, 217, 226, 235, 244,
253, 262, 271, 280, 289, 298, 307, 316
};
static const char _tmsrp_machine_parser_header_Message_Id_indicies[] = {
0, 0, 1, 2, 2, 1, 3, 3,
1, 4, 4, 1, 5, 5, 1, 6,
6, 1, 7, 7, 1, 8, 1, 9,
9, 1, 10, 10, 1, 11, 1, 12,
1, 13, 13, 13, 1, 14, 14, 14,
14, 14, 14, 14, 1, 15, 15, 15,
15, 15, 15, 15, 1, 16, 16, 16,
16, 16, 16, 16, 1, 17, 1, 18,
19, 19, 19, 19, 19, 19, 19, 1,
1, 18, 20, 20, 20, 20, 20, 20,
20, 1, 18, 21, 21, 21, 21, 21,
21, 21, 1, 18, 22, 22, 22, 22,
22, 22, 22, 1, 18, 23, 23, 23,
23, 23, 23, 23, 1, 18, 24, 24,
24, 24, 24, 24, 24, 1, 18, 25,
25, 25, 25, 25, 25, 25, 1, 18,
26, 26, 26, 26, 26, 26, 26, 1,
18, 27, 27, 27, 27, 27, 27, 27,
1, 18, 28, 28, 28, 28, 28, 28,
28, 1, 18, 29, 29, 29, 29, 29,
29, 29, 1, 18, 30, 30, 30, 30,
30, 30, 30, 1, 18, 31, 31, 31,
31, 31, 31, 31, 1, 18, 32, 32,
32, 32, 32, 32, 32, 1, 18, 33,
33, 33, 33, 33, 33, 33, 1, 18,
34, 34, 34, 34, 34, 34, 34, 1,
18, 35, 35, 35, 35, 35, 35, 35,
1, 18, 36, 36, 36, 36, 36, 36,
36, 1, 18, 37, 37, 37, 37, 37,
37, 37, 1, 18, 38, 38, 38, 38,
38, 38, 38, 1, 18, 39, 39, 39,
39, 39, 39, 39, 1, 18, 40, 40,
40, 40, 40, 40, 40, 1, 18, 41,
41, 41, 41, 41, 41, 41, 1, 18,
42, 42, 42, 42, 42, 42, 42, 1,
18, 43, 43, 43, 43, 43, 43, 43,
1, 18, 44, 44, 44, 44, 44, 44,
44, 1, 18, 45, 45, 45, 45, 45,
45, 45, 1, 18, 46, 46, 46, 46,
46, 46, 46, 1, 18, 1, 0
};
static const char _tmsrp_machine_parser_header_Message_Id_trans_targs[] = {
2, 0, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
18, 19, 17, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47
};
static const char _tmsrp_machine_parser_header_Message_Id_trans_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 3, 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
};
static const char _tmsrp_machine_parser_header_Message_Id_eof_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 3, 0, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3
};
static const int tmsrp_machine_parser_header_Message_Id_start = 1;
static const int tmsrp_machine_parser_header_Message_Id_first_final = 18;
static const int tmsrp_machine_parser_header_Message_Id_error = 0;
static const int tmsrp_machine_parser_header_Message_Id_en_main = 1;
/* #line 88 "tmsrp_parser_header_Message-ID.rl" */
/* #line 246 "../src/headers/tmsrp_header_Message-ID.c" */
{
cs = tmsrp_machine_parser_header_Message_Id_start;
}
/* #line 89 "tmsrp_parser_header_Message-ID.rl" */
/* #line 253 "../src/headers/tmsrp_header_Message-ID.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 = _tmsrp_machine_parser_header_Message_Id_trans_keys + _tmsrp_machine_parser_header_Message_Id_key_offsets[cs];
_trans = _tmsrp_machine_parser_header_Message_Id_index_offsets[cs];
_klen = _tmsrp_machine_parser_header_Message_Id_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 = _tmsrp_machine_parser_header_Message_Id_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 = _tmsrp_machine_parser_header_Message_Id_indicies[_trans];
cs = _tmsrp_machine_parser_header_Message_Id_trans_targs[_trans];
if ( _tmsrp_machine_parser_header_Message_Id_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_header_Message_Id_actions + _tmsrp_machine_parser_header_Message_Id_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 47 "tmsrp_parser_header_Message-ID.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_Message-ID.rl" */
{
TSK_PARSER_SET_STRING(hdr_Message_Id->value);
}
break;
/* #line 339 "../src/headers/tmsrp_header_Message-ID.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_header_Message_Id_actions + _tmsrp_machine_parser_header_Message_Id_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 1:
/* #line 51 "tmsrp_parser_header_Message-ID.rl" */
{
TSK_PARSER_SET_STRING(hdr_Message_Id->value);
}
break;
/* #line 361 "../src/headers/tmsrp_header_Message-ID.c" */
}
}
}
_out: {}
}
/* #line 90 "tmsrp_parser_header_Message-ID.rl" */
if( cs <
/* #line 372 "../src/headers/tmsrp_header_Message-ID.c" */
18
/* #line 91 "tmsrp_parser_header_Message-ID.rl" */
){
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 void* tmsrp_header_Message_ID_create(void *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 void* tmsrp_header_Message_ID_destroy(void *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 int tmsrp_header_Message_ID_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Message_ID_def_s =
{
sizeof(tmsrp_header_Message_ID_t),
tmsrp_header_Message_ID_create,
tmsrp_header_Message_ID_destroy,
tmsrp_header_Message_ID_cmp
};
const void *tmsrp_header_Message_ID_def_t = &tmsrp_header_Message_ID_def_s;

View File

@ -0,0 +1,331 @@
/* #line 1 "tmsrp_parser_header_Min-Expires.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 61 "tmsrp_parser_header_Min-Expires.rl" */
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_appendEx(output, "%lld", Min_Expires->value);
}
return 0;
}
return -1;
}
tmsrp_header_Min_Expires_t *tmsrp_header_Min_Expires_parse(const char *data, 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;
/* #line 73 "../src/headers/tmsrp_header_Min-Expires.c" */
static const char _tmsrp_machine_parser_header_Min_Expires_actions[] = {
0, 1, 0, 1, 1
};
static const char _tmsrp_machine_parser_header_Min_Expires_key_offsets[] = {
0, 0, 2, 4, 6, 7, 9, 11,
13, 15, 17, 19, 21, 22, 23, 25,
26, 29
};
static const char _tmsrp_machine_parser_header_Min_Expires_trans_keys[] = {
77, 109, 73, 105, 78, 110, 45, 69,
101, 88, 120, 80, 112, 73, 105, 82,
114, 69, 101, 83, 115, 58, 32, 48,
57, 10, 13, 48, 57, 0
};
static const char _tmsrp_machine_parser_header_Min_Expires_single_lengths[] = {
0, 2, 2, 2, 1, 2, 2, 2,
2, 2, 2, 2, 1, 1, 0, 1,
1, 0
};
static const char _tmsrp_machine_parser_header_Min_Expires_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0,
1, 0
};
static const char _tmsrp_machine_parser_header_Min_Expires_index_offsets[] = {
0, 0, 3, 6, 9, 11, 14, 17,
20, 23, 26, 29, 32, 34, 36, 38,
40, 43
};
static const char _tmsrp_machine_parser_header_Min_Expires_indicies[] = {
0, 0, 1, 2, 2, 1, 3, 3,
1, 4, 1, 5, 5, 1, 6, 6,
1, 7, 7, 1, 8, 8, 1, 9,
9, 1, 10, 10, 1, 11, 11, 1,
12, 1, 13, 1, 14, 1, 15, 1,
16, 17, 1, 1, 0
};
static const char _tmsrp_machine_parser_header_Min_Expires_trans_targs[] = {
2, 0, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 16, 17,
15, 16
};
static const char _tmsrp_machine_parser_header_Min_Expires_trans_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0,
3, 0
};
static const char _tmsrp_machine_parser_header_Min_Expires_eof_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
3, 0
};
static const int tmsrp_machine_parser_header_Min_Expires_start = 1;
static const int tmsrp_machine_parser_header_Min_Expires_first_final = 16;
static const int tmsrp_machine_parser_header_Min_Expires_error = 0;
static const int tmsrp_machine_parser_header_Min_Expires_en_main = 1;
/* #line 88 "tmsrp_parser_header_Min-Expires.rl" */
/* #line 145 "../src/headers/tmsrp_header_Min-Expires.c" */
{
cs = tmsrp_machine_parser_header_Min_Expires_start;
}
/* #line 89 "tmsrp_parser_header_Min-Expires.rl" */
/* #line 152 "../src/headers/tmsrp_header_Min-Expires.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 = _tmsrp_machine_parser_header_Min_Expires_trans_keys + _tmsrp_machine_parser_header_Min_Expires_key_offsets[cs];
_trans = _tmsrp_machine_parser_header_Min_Expires_index_offsets[cs];
_klen = _tmsrp_machine_parser_header_Min_Expires_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 = _tmsrp_machine_parser_header_Min_Expires_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 = _tmsrp_machine_parser_header_Min_Expires_indicies[_trans];
cs = _tmsrp_machine_parser_header_Min_Expires_trans_targs[_trans];
if ( _tmsrp_machine_parser_header_Min_Expires_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_header_Min_Expires_actions + _tmsrp_machine_parser_header_Min_Expires_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 47 "tmsrp_parser_header_Min-Expires.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_Min-Expires.rl" */
{
TSK_PARSER_SET_INTEGER_EX(hdr_Min_Expires->value, int64_t, atoi64)
}
break;
/* #line 238 "../src/headers/tmsrp_header_Min-Expires.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_header_Min_Expires_actions + _tmsrp_machine_parser_header_Min_Expires_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 1:
/* #line 51 "tmsrp_parser_header_Min-Expires.rl" */
{
TSK_PARSER_SET_INTEGER_EX(hdr_Min_Expires->value, int64_t, atoi64)
}
break;
/* #line 260 "../src/headers/tmsrp_header_Min-Expires.c" */
}
}
}
_out: {}
}
/* #line 90 "tmsrp_parser_header_Min-Expires.rl" */
if( cs <
/* #line 271 "../src/headers/tmsrp_header_Min-Expires.c" */
16
/* #line 91 "tmsrp_parser_header_Min-Expires.rl" */
){
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 void* tmsrp_header_Min_Expires_create(void *self, va_list * app)
{
tmsrp_header_Min_Expires_t *Min_Expires = self;
if(Min_Expires)
{
TMSRP_HEADER(Min_Expires)->type = tmsrp_htype_Message_ID;
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 void* tmsrp_header_Min_Expires_destroy(void *self)
{
tmsrp_header_Min_Expires_t *Min_Expires = self;
if(Min_Expires){
}
else{
TSK_DEBUG_ERROR("Null Min-Expires header.");
}
return self;
}
static int tmsrp_header_Min_Expires_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Min_Expires_def_s =
{
sizeof(tmsrp_header_Min_Expires_t),
tmsrp_header_Min_Expires_create,
tmsrp_header_Min_Expires_destroy,
tmsrp_header_Min_Expires_cmp
};
const void *tmsrp_header_Min_Expires_def_t = &tmsrp_header_Min_Expires_def_s;

View File

@ -0,0 +1,384 @@
/* #line 1 "tmsrp_parser_header_Status.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 71 "tmsrp_parser_header_Status.rl" */
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_appendEx(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, 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;
/* #line 77 "../src/headers/tmsrp_header_Status.c" */
static const char _tmsrp_machine_parser_header_Status_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
3, 2, 0, 3
};
static const char _tmsrp_machine_parser_header_Status_key_offsets[] = {
0, 0, 2, 4, 6, 8, 10, 12,
13, 14, 16, 18, 20, 21, 23, 25,
27, 28, 30, 32, 34, 36, 38, 40,
40, 54
};
static const char _tmsrp_machine_parser_header_Status_trans_keys[] = {
83, 115, 84, 116, 65, 97, 84, 116,
85, 117, 83, 115, 58, 32, 48, 57,
48, 57, 48, 57, 32, 48, 57, 48,
57, 48, 57, 10, -128, -65, -128, -65,
-128, -65, -128, -65, -128, -65, 13, 32,
9, 13, -64, -33, -32, -17, -16, -9,
-8, -5, -4, -3, 32, 126, 9, 13,
-64, -33, -32, -17, -16, -9, -8, -5,
-4, -3, 32, 126, 0
};
static const char _tmsrp_machine_parser_header_Status_single_lengths[] = {
0, 2, 2, 2, 2, 2, 2, 1,
1, 0, 0, 0, 1, 0, 0, 0,
1, 0, 0, 0, 0, 0, 2, 0,
2, 2
};
static const char _tmsrp_machine_parser_header_Status_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 0, 1, 1, 1,
0, 1, 1, 1, 1, 1, 0, 0,
6, 6
};
static const char _tmsrp_machine_parser_header_Status_index_offsets[] = {
0, 0, 3, 6, 9, 12, 15, 18,
20, 22, 24, 26, 28, 30, 32, 34,
36, 38, 40, 42, 44, 46, 48, 51,
52, 61
};
static const char _tmsrp_machine_parser_header_Status_indicies[] = {
0, 0, 1, 2, 2, 1, 3, 3,
1, 4, 4, 1, 5, 5, 1, 6,
6, 1, 7, 1, 8, 1, 9, 1,
10, 1, 11, 1, 12, 1, 13, 1,
14, 1, 15, 1, 16, 1, 17, 1,
18, 1, 19, 1, 20, 1, 21, 1,
22, 23, 1, 1, 29, 30, 24, 25,
26, 27, 28, 29, 1, 17, 32, 18,
19, 20, 21, 31, 17, 1, 0
};
static const char _tmsrp_machine_parser_header_Status_trans_targs[] = {
2, 0, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 22,
23, 25, 17, 18, 19, 20, 16, 24,
17, 18, 19, 20, 21, 25, 16, 21,
16
};
static const char _tmsrp_machine_parser_header_Status_trans_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 3, 1, 0, 0,
0, 0, 0, 0, 0, 0, 5, 5,
1, 1, 1, 1, 1, 1, 9, 0,
7
};
static const char _tmsrp_machine_parser_header_Status_eof_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 5, 0,
9, 7
};
static const int tmsrp_machine_parser_header_Status_start = 1;
static const int tmsrp_machine_parser_header_Status_first_final = 22;
static const int tmsrp_machine_parser_header_Status_error = 0;
static const int tmsrp_machine_parser_header_Status_en_main = 1;
/* #line 102 "tmsrp_parser_header_Status.rl" */
/* #line 167 "../src/headers/tmsrp_header_Status.c" */
{
cs = tmsrp_machine_parser_header_Status_start;
}
/* #line 103 "tmsrp_parser_header_Status.rl" */
/* #line 174 "../src/headers/tmsrp_header_Status.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 = _tmsrp_machine_parser_header_Status_trans_keys + _tmsrp_machine_parser_header_Status_key_offsets[cs];
_trans = _tmsrp_machine_parser_header_Status_index_offsets[cs];
_klen = _tmsrp_machine_parser_header_Status_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 = _tmsrp_machine_parser_header_Status_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 = _tmsrp_machine_parser_header_Status_indicies[_trans];
cs = _tmsrp_machine_parser_header_Status_trans_targs[_trans];
if ( _tmsrp_machine_parser_header_Status_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_header_Status_actions + _tmsrp_machine_parser_header_Status_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 47 "tmsrp_parser_header_Status.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_Status.rl" */
{
TSK_PARSER_SET_INT(hdr_Status->namespace);
}
break;
case 2:
/* #line 55 "tmsrp_parser_header_Status.rl" */
{
TSK_PARSER_SET_INT(hdr_Status->code);
}
break;
case 3:
/* #line 59 "tmsrp_parser_header_Status.rl" */
{
TSK_PARSER_SET_STRING(hdr_Status->reason);
}
break;
/* #line 272 "../src/headers/tmsrp_header_Status.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_header_Status_actions + _tmsrp_machine_parser_header_Status_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 0:
/* #line 47 "tmsrp_parser_header_Status.rl" */
{
tag_start = p;
}
break;
case 2:
/* #line 55 "tmsrp_parser_header_Status.rl" */
{
TSK_PARSER_SET_INT(hdr_Status->code);
}
break;
case 3:
/* #line 59 "tmsrp_parser_header_Status.rl" */
{
TSK_PARSER_SET_STRING(hdr_Status->reason);
}
break;
/* #line 306 "../src/headers/tmsrp_header_Status.c" */
}
}
}
_out: {}
}
/* #line 104 "tmsrp_parser_header_Status.rl" */
if( cs <
/* #line 317 "../src/headers/tmsrp_header_Status.c" */
22
/* #line 105 "tmsrp_parser_header_Status.rl" */
){
TSK_DEBUG_ERROR("Failed to parse 'Status' header.");
TSK_OBJECT_SAFE_FREE(hdr_Status);
}
return hdr_Status;
}
//========================================================
// Status header object definition
//
static void* tmsrp_header_Status_create(void *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 void* tmsrp_header_Status_destroy(void *self)
{
tmsrp_header_Status_t *Status = self;
if(Status){
TSK_FREE(Status->reason);
}
else{
TSK_DEBUG_ERROR("Null Status header.");
}
return self;
}
static int tmsrp_header_Status_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Status_def_s =
{
sizeof(tmsrp_header_Status_t),
tmsrp_header_Status_create,
tmsrp_header_Status_destroy,
tmsrp_header_Status_cmp
};
const void *tmsrp_header_Status_def_t = &tmsrp_header_Status_def_s;

View File

@ -0,0 +1,345 @@
/* #line 1 "tmsrp_parser_header_Success-Report.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 61 "tmsrp_parser_header_Success-Report.rl" */
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, 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();
/* #line 69 "../src/headers/tmsrp_header_Success-Report.c" */
static const char _tmsrp_machine_parser_header_Success_Report_actions[] = {
0, 1, 0, 1, 1
};
static const char _tmsrp_machine_parser_header_Success_Report_key_offsets[] = {
0, 0, 2, 4, 6, 8, 10, 12,
14, 15, 17, 19, 21, 23, 25, 27,
28, 29, 33, 35, 36, 38, 40, 41,
41
};
static const char _tmsrp_machine_parser_header_Success_Report_trans_keys[] = {
83, 115, 85, 117, 67, 99, 67, 99,
69, 101, 83, 115, 83, 115, 45, 82,
114, 69, 101, 80, 112, 79, 111, 82,
114, 84, 116, 58, 32, 78, 89, 110,
121, 79, 111, 10, 69, 101, 83, 115,
13, 13, 0
};
static const char _tmsrp_machine_parser_header_Success_Report_single_lengths[] = {
0, 2, 2, 2, 2, 2, 2, 2,
1, 2, 2, 2, 2, 2, 2, 1,
1, 4, 2, 1, 2, 2, 1, 0,
1
};
static const char _tmsrp_machine_parser_header_Success_Report_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
};
static const char _tmsrp_machine_parser_header_Success_Report_index_offsets[] = {
0, 0, 3, 6, 9, 12, 15, 18,
21, 23, 26, 29, 32, 35, 38, 41,
43, 45, 50, 53, 55, 58, 61, 63,
64
};
static const char _tmsrp_machine_parser_header_Success_Report_indicies[] = {
0, 0, 1, 2, 2, 1, 3, 3,
1, 4, 4, 1, 5, 5, 1, 6,
6, 1, 7, 7, 1, 8, 1, 9,
9, 1, 10, 10, 1, 11, 11, 1,
12, 12, 1, 13, 13, 1, 14, 14,
1, 15, 1, 16, 1, 17, 18, 17,
18, 1, 19, 19, 1, 20, 1, 21,
21, 1, 22, 22, 1, 23, 1, 1,
24, 1, 0
};
static const char _tmsrp_machine_parser_header_Success_Report_trans_targs[] = {
2, 0, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 20, 22, 23, 21, 24, 19,
19
};
static const char _tmsrp_machine_parser_header_Success_Report_trans_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 3,
1
};
static const char _tmsrp_machine_parser_header_Success_Report_eof_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 3, 0,
1
};
static const int tmsrp_machine_parser_header_Success_Report_start = 1;
static const int tmsrp_machine_parser_header_Success_Report_first_final = 22;
static const int tmsrp_machine_parser_header_Success_Report_error = 0;
static const int tmsrp_machine_parser_header_Success_Report_en_main = 1;
/* #line 84 "tmsrp_parser_header_Success-Report.rl" */
/* #line 153 "../src/headers/tmsrp_header_Success-Report.c" */
{
cs = tmsrp_machine_parser_header_Success_Report_start;
}
/* #line 85 "tmsrp_parser_header_Success-Report.rl" */
/* #line 160 "../src/headers/tmsrp_header_Success-Report.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 = _tmsrp_machine_parser_header_Success_Report_trans_keys + _tmsrp_machine_parser_header_Success_Report_key_offsets[cs];
_trans = _tmsrp_machine_parser_header_Success_Report_index_offsets[cs];
_klen = _tmsrp_machine_parser_header_Success_Report_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 = _tmsrp_machine_parser_header_Success_Report_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 = _tmsrp_machine_parser_header_Success_Report_indicies[_trans];
cs = _tmsrp_machine_parser_header_Success_Report_trans_targs[_trans];
if ( _tmsrp_machine_parser_header_Success_Report_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_header_Success_Report_actions + _tmsrp_machine_parser_header_Success_Report_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 47 "tmsrp_parser_header_Success-Report.rl" */
{
hdr_Success_Report->yes = 1;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_Success-Report.rl" */
{
hdr_Success_Report->yes = 0;
}
break;
/* #line 246 "../src/headers/tmsrp_header_Success-Report.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_header_Success_Report_actions + _tmsrp_machine_parser_header_Success_Report_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 0:
/* #line 47 "tmsrp_parser_header_Success-Report.rl" */
{
hdr_Success_Report->yes = 1;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_Success-Report.rl" */
{
hdr_Success_Report->yes = 0;
}
break;
/* #line 274 "../src/headers/tmsrp_header_Success-Report.c" */
}
}
}
_out: {}
}
/* #line 86 "tmsrp_parser_header_Success-Report.rl" */
if( cs <
/* #line 285 "../src/headers/tmsrp_header_Success-Report.c" */
22
/* #line 87 "tmsrp_parser_header_Success-Report.rl" */
){
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 void* tmsrp_header_Success_Report_create(void *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, unsigned) ? 1 : 0;
}
else{
TSK_DEBUG_ERROR("Failed to create new Success-Report header.");
}
return self;
}
static void* tmsrp_header_Success_Report_destroy(void *self)
{
tmsrp_header_Success_Report_t *Success_Report = self;
if(Success_Report){
}
else{
TSK_DEBUG_ERROR("Null Success-Report header.");
}
return self;
}
static int tmsrp_header_Success_Report_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Success_Report_def_s =
{
sizeof(tmsrp_header_Success_Report_t),
tmsrp_header_Success_Report_create,
tmsrp_header_Success_Report_destroy,
tmsrp_header_Success_Report_cmp
};
const void *tmsrp_header_Success_Report_def_t = &tmsrp_header_Success_Report_def_s;

View File

@ -0,0 +1,357 @@
/* #line 1 "tmsrp_parser_header_To-Path.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 75 "tmsrp_parser_header_To-Path.rl" */
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, 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;
/* #line 78 "../src/headers/tmsrp_header_To-Path.c" */
static const char _tmsrp_machine_parser_header_To_Path_actions[] = {
0, 1, 0, 1, 1, 2, 0, 1
};
static const char _tmsrp_machine_parser_header_To_Path_key_offsets[] = {
0, 0, 2, 4, 5, 7, 9, 11,
13, 14, 15, 16, 18, 20
};
static const char _tmsrp_machine_parser_header_To_Path_trans_keys[] = {
84, 116, 79, 111, 45, 80, 112, 65,
97, 84, 116, 72, 104, 58, 32, 10,
13, 32, 13, 32, 0
};
static const char _tmsrp_machine_parser_header_To_Path_single_lengths[] = {
0, 2, 2, 1, 2, 2, 2, 2,
1, 1, 1, 2, 2, 0
};
static const char _tmsrp_machine_parser_header_To_Path_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};
static const char _tmsrp_machine_parser_header_To_Path_index_offsets[] = {
0, 0, 3, 6, 8, 11, 14, 17,
20, 22, 24, 26, 29, 32
};
static const char _tmsrp_machine_parser_header_To_Path_trans_targs[] = {
2, 2, 0, 3, 3, 0, 4, 0,
5, 5, 0, 6, 6, 0, 7, 7,
0, 8, 8, 0, 9, 0, 11, 0,
13, 0, 10, 11, 12, 10, 11, 12,
0, 0
};
static const char _tmsrp_machine_parser_header_To_Path_trans_actions[] = {
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, 5, 5, 1, 3, 3, 0,
0, 0
};
static const char _tmsrp_machine_parser_header_To_Path_eof_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 5, 3, 0
};
static const int tmsrp_machine_parser_header_To_Path_start = 1;
static const int tmsrp_machine_parser_header_To_Path_first_final = 11;
static const int tmsrp_machine_parser_header_To_Path_error = 0;
static const int tmsrp_machine_parser_header_To_Path_en_main = 1;
/* #line 107 "tmsrp_parser_header_To-Path.rl" */
/* #line 140 "../src/headers/tmsrp_header_To-Path.c" */
{
cs = tmsrp_machine_parser_header_To_Path_start;
}
/* #line 108 "tmsrp_parser_header_To-Path.rl" */
/* #line 147 "../src/headers/tmsrp_header_To-Path.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 = _tmsrp_machine_parser_header_To_Path_trans_keys + _tmsrp_machine_parser_header_To_Path_key_offsets[cs];
_trans = _tmsrp_machine_parser_header_To_Path_index_offsets[cs];
_klen = _tmsrp_machine_parser_header_To_Path_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 = _tmsrp_machine_parser_header_To_Path_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 = _tmsrp_machine_parser_header_To_Path_trans_targs[_trans];
if ( _tmsrp_machine_parser_header_To_Path_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_header_To_Path_actions + _tmsrp_machine_parser_header_To_Path_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 47 "tmsrp_parser_header_To-Path.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_To-Path.rl" */
{
int len = (int)(p - tag_start);
tmsrp_uri_t* uri;
if((uri = tmsrp_uri_parse(tag_start, (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));
}
}
}
break;
/* #line 244 "../src/headers/tmsrp_header_To-Path.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_header_To_Path_actions + _tmsrp_machine_parser_header_To_Path_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 0:
/* #line 47 "tmsrp_parser_header_To-Path.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_To-Path.rl" */
{
int len = (int)(p - tag_start);
tmsrp_uri_t* uri;
if((uri = tmsrp_uri_parse(tag_start, (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));
}
}
}
break;
/* #line 284 "../src/headers/tmsrp_header_To-Path.c" */
}
}
}
_out: {}
}
/* #line 109 "tmsrp_parser_header_To-Path.rl" */
if( cs <
/* #line 295 "../src/headers/tmsrp_header_To-Path.c" */
11
/* #line 110 "tmsrp_parser_header_To-Path.rl" */
){
TSK_DEBUG_ERROR("Failed to parse 'To-Path' header.");
TSK_OBJECT_SAFE_FREE(header);
}
return header;
}
//========================================================
// To_Path header object definition
//
static void* tmsrp_header_To_Path_create(void *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 void* tmsrp_header_To_Path_destroy(void *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 int tmsrp_header_To_Path_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_To_Path_def_s =
{
sizeof(tmsrp_header_To_Path_t),
tmsrp_header_To_Path_create,
tmsrp_header_To_Path_destroy,
tmsrp_header_To_Path_cmp
};
const void *tmsrp_header_To_Path_def_t = &tmsrp_header_To_Path_def_s;

View File

@ -0,0 +1,357 @@
/* #line 1 "tmsrp_parser_header_Use-Path.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 75 "tmsrp_parser_header_Use-Path.rl" */
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, 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;
/* #line 78 "../src/headers/tmsrp_header_Use-Path.c" */
static const char _tmsrp_machine_parser_header_Use_Path_actions[] = {
0, 1, 0, 1, 1, 2, 0, 1
};
static const char _tmsrp_machine_parser_header_Use_Path_key_offsets[] = {
0, 0, 2, 4, 6, 7, 9, 11,
13, 15, 16, 17, 18, 20, 22
};
static const char _tmsrp_machine_parser_header_Use_Path_trans_keys[] = {
85, 117, 83, 115, 69, 101, 45, 80,
112, 65, 97, 84, 116, 72, 104, 58,
32, 10, 13, 32, 13, 32, 0
};
static const char _tmsrp_machine_parser_header_Use_Path_single_lengths[] = {
0, 2, 2, 2, 1, 2, 2, 2,
2, 1, 1, 1, 2, 2, 0
};
static const char _tmsrp_machine_parser_header_Use_Path_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0
};
static const char _tmsrp_machine_parser_header_Use_Path_index_offsets[] = {
0, 0, 3, 6, 9, 11, 14, 17,
20, 23, 25, 27, 29, 32, 35
};
static const char _tmsrp_machine_parser_header_Use_Path_trans_targs[] = {
2, 2, 0, 3, 3, 0, 4, 4,
0, 5, 0, 6, 6, 0, 7, 7,
0, 8, 8, 0, 9, 9, 0, 10,
0, 12, 0, 14, 0, 11, 12, 13,
11, 12, 13, 0, 0
};
static const char _tmsrp_machine_parser_header_Use_Path_trans_actions[] = {
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, 5, 5, 1,
3, 3, 0, 0, 0
};
static const char _tmsrp_machine_parser_header_Use_Path_eof_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 5, 3, 0
};
static const int tmsrp_machine_parser_header_Use_Path_start = 1;
static const int tmsrp_machine_parser_header_Use_Path_first_final = 12;
static const int tmsrp_machine_parser_header_Use_Path_error = 0;
static const int tmsrp_machine_parser_header_Use_Path_en_main = 1;
/* #line 107 "tmsrp_parser_header_Use-Path.rl" */
/* #line 140 "../src/headers/tmsrp_header_Use-Path.c" */
{
cs = tmsrp_machine_parser_header_Use_Path_start;
}
/* #line 108 "tmsrp_parser_header_Use-Path.rl" */
/* #line 147 "../src/headers/tmsrp_header_Use-Path.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 = _tmsrp_machine_parser_header_Use_Path_trans_keys + _tmsrp_machine_parser_header_Use_Path_key_offsets[cs];
_trans = _tmsrp_machine_parser_header_Use_Path_index_offsets[cs];
_klen = _tmsrp_machine_parser_header_Use_Path_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 = _tmsrp_machine_parser_header_Use_Path_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 = _tmsrp_machine_parser_header_Use_Path_trans_targs[_trans];
if ( _tmsrp_machine_parser_header_Use_Path_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_header_Use_Path_actions + _tmsrp_machine_parser_header_Use_Path_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 47 "tmsrp_parser_header_Use-Path.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_Use-Path.rl" */
{
int len = (int)(p - tag_start);
tmsrp_uri_t* uri;
if((uri = tmsrp_uri_parse(tag_start, (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));
}
}
}
break;
/* #line 244 "../src/headers/tmsrp_header_Use-Path.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_header_Use_Path_actions + _tmsrp_machine_parser_header_Use_Path_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 0:
/* #line 47 "tmsrp_parser_header_Use-Path.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 51 "tmsrp_parser_header_Use-Path.rl" */
{
int len = (int)(p - tag_start);
tmsrp_uri_t* uri;
if((uri = tmsrp_uri_parse(tag_start, (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));
}
}
}
break;
/* #line 284 "../src/headers/tmsrp_header_Use-Path.c" */
}
}
}
_out: {}
}
/* #line 109 "tmsrp_parser_header_Use-Path.rl" */
if( cs <
/* #line 295 "../src/headers/tmsrp_header_Use-Path.c" */
12
/* #line 110 "tmsrp_parser_header_Use-Path.rl" */
){
TSK_DEBUG_ERROR("Failed to parse 'Use-Path' header.");
TSK_OBJECT_SAFE_FREE(header);
}
return header;
}
//========================================================
// Use_Path header object definition
//
static void* tmsrp_header_Use_Path_create(void *self, va_list * app)
{
tmsrp_header_Use_Path_t *Use_Path = self;
if(Use_Path)
{
TMSRP_HEADER(Use_Path)->type = tmsrp_htype_Use_Path;
TMSRP_HEADER(Use_Path)->tostring = tmsrp_header_Use_Path_tostring;
Use_Path->uri = tsk_object_ref((void*)va_arg(*app, const tmsrp_uri_t*));
}
else{
TSK_DEBUG_ERROR("Failed to create new Use-Path header.");
}
return self;
}
static void* tmsrp_header_Use_Path_destroy(void *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 int tmsrp_header_Use_Path_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_header_Use_Path_def_s =
{
sizeof(tmsrp_header_Use_Path_t),
tmsrp_header_Use_Path_create,
tmsrp_header_Use_Path_destroy,
tmsrp_header_Use_Path_cmp
};
const void *tmsrp_header_Use_Path_def_t = &tmsrp_header_Use_Path_def_s;

View File

@ -0,0 +1,157 @@
/* #line 1 "tmsrp_parser_header_WWW_Authenticate.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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_WWW_Authenticate.c
* @brief MSRP WWW-Authenticate header.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tinyMSRP/headers/tmsrp_header_WWW-Authenticate.h"
#include "tinyhttp/headers/thttp_header_WWW_Authenticate.h"
#include "tsk_debug.h"
#include "tsk_memory.h"
#include "tsk_time.h"
#include <string.h>
int tmsrp_header_WWW_Authenticate_tostring(const void* header, tsk_buffer_t* output)
{
if(header)
{
const tmsrp_header_WWW_Authenticate_t *WWW_Authenticate = header;
if(WWW_Authenticate && WWW_Authenticate->scheme)
{
return tsk_buffer_appendEx(output, "%s realm=\"%s\"%s%s%s%s%s%s%s%s%s%s%s%s,stale=%s%s%s",
WWW_Authenticate->scheme,
WWW_Authenticate->realm ? WWW_Authenticate->realm : "",
WWW_Authenticate->domain ? ",domain=\"" : "",
WWW_Authenticate->domain ? WWW_Authenticate->domain : "",
WWW_Authenticate->domain ? "\"" : "",
WWW_Authenticate->qop ? ",qop=\"" : "",
WWW_Authenticate->qop ? WWW_Authenticate->qop : "",
WWW_Authenticate->qop ? "\"" : "",
WWW_Authenticate->nonce ? ",nonce=\"" : "",
WWW_Authenticate->nonce ? WWW_Authenticate->nonce : "",
WWW_Authenticate->nonce ? "\"" : "",
WWW_Authenticate->opaque ? ",opaque=\"" : "",
WWW_Authenticate->opaque ? WWW_Authenticate->opaque : "",
WWW_Authenticate->opaque ? "\"" : "",
WWW_Authenticate->stale ? "TRUE" : "FALSE",
WWW_Authenticate->algorithm ? ",algorithm=" : "",
WWW_Authenticate->algorithm ? WWW_Authenticate->algorithm : ""
);
}
}
return -1;
}
tmsrp_header_WWW_Authenticate_t *tmsrp_header_WWW_Authenticate_parse(const char *data, size_t size)
{
tmsrp_header_WWW_Authenticate_t *msrp_hdr = 0;
thttp_header_WWW_Authenticate_t* http_hdr;
if((http_hdr = thttp_header_WWW_Authenticate_parse(data, size)))
{
msrp_hdr = TMSRP_HEADER_WWW_AUTHENTICATE_CREATE();
msrp_hdr->scheme = tsk_strdup(http_hdr->scheme);
msrp_hdr->realm = tsk_strdup(http_hdr->realm);
msrp_hdr->domain = tsk_strdup(http_hdr->domain);
msrp_hdr->nonce = tsk_strdup(http_hdr->nonce);
msrp_hdr->opaque = tsk_strdup(http_hdr->opaque);
msrp_hdr->algorithm = tsk_strdup(http_hdr->algorithm);
msrp_hdr->qop = tsk_strdup(http_hdr->qop);
msrp_hdr->stale = http_hdr->stale;
msrp_hdr->params = tsk_object_ref(THTTP_HEADER(http_hdr)->params);
TSK_OBJECT_SAFE_FREE(http_hdr);
}
return msrp_hdr;
}
//========================================================
// WWW_Authenticate header object definition
//
static void* tmsrp_header_WWW_Authenticate_create(void *self, va_list * app)
{
tmsrp_header_WWW_Authenticate_t *WWW_Authenticate = self;
if(WWW_Authenticate){
TMSRP_HEADER(WWW_Authenticate)->type = tmsrp_htype_WWW_Authenticate;
TMSRP_HEADER(WWW_Authenticate)->tostring = tmsrp_header_WWW_Authenticate_tostring;
}
else{
TSK_DEBUG_ERROR("Failed to create new WWW_Authenticate header.");
}
return self;
}
static void* tmsrp_header_WWW_Authenticate_destroy(void *self)
{
tmsrp_header_WWW_Authenticate_t *WWW_Authenticate = self;
if(WWW_Authenticate)
{
TSK_FREE(WWW_Authenticate->scheme);
TSK_FREE(WWW_Authenticate->realm);
TSK_FREE(WWW_Authenticate->domain);
TSK_FREE(WWW_Authenticate->nonce);
TSK_FREE(WWW_Authenticate->opaque);
TSK_FREE(WWW_Authenticate->algorithm);
TSK_FREE(WWW_Authenticate->qop);
TSK_OBJECT_SAFE_FREE(WWW_Authenticate->params);
}
else TSK_DEBUG_ERROR("Null WWW_Authenticate header.");
return self;
}
static const tsk_object_def_t tmsrp_header_WWW_Authenticate_def_s =
{
sizeof(tmsrp_header_WWW_Authenticate_t),
tmsrp_header_WWW_Authenticate_create,
tmsrp_header_WWW_Authenticate_destroy,
0
};
const void *tmsrp_header_WWW_Authenticate_def_t = &tmsrp_header_WWW_Authenticate_def_s;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,637 @@
/* #line 1 "tmsrp_parser_uri.rl" */
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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)yahoo.fr>
*
* @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.
*/
/* #line 112 "tmsrp_parser_uri.rl" */
tmsrp_uri_t *tmsrp_uri_parse(const char *data, 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;
/* #line 59 "../src/parsers/tmsrp_parser_uri.c" */
static const char _tmsrp_machine_parser_uri_actions[] = {
0, 1, 0, 1, 4, 1, 5, 1,
6, 1, 7, 1, 8, 1, 9, 1,
10, 2, 0, 1, 2, 0, 2, 2,
0, 3, 2, 0, 5, 2, 0, 9
};
static const short _tmsrp_machine_parser_uri_key_offsets[] = {
0, 0, 1, 2, 3, 4, 6, 7,
8, 25, 39, 45, 51, 58, 61, 63,
66, 68, 71, 73, 78, 90, 103, 117,
131, 136, 139, 141, 145, 148, 149, 152,
153, 156, 157, 168, 175, 184, 192, 199,
205, 212, 220, 228, 236, 238, 245, 254,
256, 259, 261, 264, 266, 269, 272, 273,
276, 277, 280, 281, 290, 299, 307, 315,
323, 331, 333, 339, 348, 357, 366, 368,
371, 374, 375, 376, 393, 409, 426, 442,
459, 475, 492, 509, 524, 540, 557, 577,
597, 614, 629, 646, 661, 678, 693, 712,
729, 746, 764, 781, 797, 798, 805, 812,
828, 843, 859, 875, 895, 917, 939, 959,
980
};
static const char _tmsrp_machine_parser_uri_trans_keys[] = {
109, 115, 114, 112, 58, 115, 47, 47,
33, 37, 61, 64, 91, 95, 126, 36,
46, 48, 57, 58, 59, 65, 90, 97,
122, 33, 37, 61, 64, 95, 126, 36,
46, 48, 59, 65, 90, 97, 122, 48,
57, 65, 70, 97, 102, 48, 57, 65,
70, 97, 102, 91, 48, 57, 65, 90,
97, 122, 46, 48, 57, 48, 57, 46,
48, 57, 48, 57, 46, 48, 57, 48,
57, 47, 58, 59, 48, 57, 33, 61,
95, 126, 39, 43, 45, 57, 65, 90,
97, 122, 33, 59, 61, 95, 126, 39,
43, 45, 57, 65, 90, 97, 122, 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, 47, 58, 59, 48, 57,
47, 58, 59, 48, 57, 47, 59, 48,
57, 46, 48, 57, 46, 46, 48, 57,
46, 46, 48, 57, 46, 45, 46, 47,
58, 59, 48, 57, 65, 90, 97, 122,
45, 48, 57, 65, 90, 97, 122, 47,
58, 59, 48, 57, 65, 90, 97, 122,
45, 46, 48, 57, 65, 90, 97, 122,
45, 48, 57, 65, 90, 97, 122, 48,
57, 65, 90, 97, 122, 58, 48, 57,
65, 70, 97, 102, 58, 93, 48, 57,
65, 70, 97, 102, 58, 93, 48, 57,
65, 70, 97, 102, 58, 93, 48, 57,
65, 70, 97, 102, 58, 93, 58, 48,
57, 65, 70, 97, 102, 46, 58, 93,
48, 57, 65, 70, 97, 102, 48, 57,
46, 48, 57, 48, 57, 46, 48, 57,
48, 57, 93, 48, 57, 93, 48, 57,
93, 46, 48, 57, 46, 46, 48, 57,
46, 46, 58, 93, 48, 57, 65, 70,
97, 102, 46, 58, 93, 48, 57, 65,
70, 97, 102, 58, 93, 48, 57, 65,
70, 97, 102, 58, 93, 48, 57, 65,
70, 97, 102, 58, 93, 48, 57, 65,
70, 97, 102, 58, 93, 48, 57, 65,
70, 97, 102, 58, 93, 48, 57, 65,
70, 97, 102, 46, 58, 93, 48, 57,
65, 70, 97, 102, 46, 58, 93, 48,
57, 65, 70, 97, 102, 46, 58, 93,
48, 57, 65, 70, 97, 102, 48, 57,
46, 48, 57, 46, 48, 57, 46, 58,
33, 37, 46, 61, 64, 95, 126, 36,
45, 48, 57, 58, 59, 65, 90, 97,
122, 33, 37, 61, 64, 95, 126, 36,
46, 48, 57, 58, 59, 65, 90, 97,
122, 33, 37, 46, 61, 64, 95, 126,
36, 45, 48, 57, 58, 59, 65, 90,
97, 122, 33, 37, 61, 64, 95, 126,
36, 46, 48, 57, 58, 59, 65, 90,
97, 122, 33, 37, 46, 61, 64, 95,
126, 36, 45, 48, 57, 58, 59, 65,
90, 97, 122, 33, 37, 61, 64, 95,
126, 36, 46, 48, 57, 58, 59, 65,
90, 97, 122, 33, 37, 47, 58, 59,
61, 64, 95, 126, 36, 46, 48, 57,
65, 90, 97, 122, 33, 37, 47, 58,
59, 61, 64, 95, 126, 36, 46, 48,
57, 65, 90, 97, 122, 33, 37, 47,
58, 59, 61, 64, 95, 126, 36, 57,
65, 90, 97, 122, 33, 37, 61, 64,
95, 126, 36, 46, 48, 57, 58, 59,
65, 90, 97, 122, 33, 37, 47, 58,
59, 61, 64, 95, 126, 36, 46, 48,
57, 65, 90, 97, 122, 33, 37, 39,
44, 61, 64, 96, 126, 36, 41, 42,
46, 48, 57, 58, 59, 65, 90, 95,
122, 33, 37, 39, 44, 61, 64, 96,
126, 36, 41, 42, 46, 48, 57, 58,
59, 65, 90, 95, 122, 33, 37, 46,
61, 64, 95, 126, 36, 45, 48, 57,
58, 59, 65, 90, 97, 122, 33, 37,
46, 61, 64, 95, 126, 36, 45, 48,
59, 65, 90, 97, 122, 33, 37, 46,
61, 64, 95, 126, 36, 45, 48, 57,
58, 59, 65, 90, 97, 122, 33, 37,
46, 61, 64, 95, 126, 36, 45, 48,
59, 65, 90, 97, 122, 33, 37, 46,
61, 64, 95, 126, 36, 45, 48, 57,
58, 59, 65, 90, 97, 122, 33, 37,
46, 61, 64, 95, 126, 36, 45, 48,
59, 65, 90, 97, 122, 33, 37, 45,
46, 47, 58, 59, 61, 64, 95, 126,
36, 44, 48, 57, 65, 90, 97, 122,
33, 37, 45, 61, 64, 95, 126, 36,
46, 48, 57, 58, 59, 65, 90, 97,
122, 33, 37, 47, 58, 59, 61, 64,
95, 126, 36, 46, 48, 57, 65, 90,
97, 122, 33, 37, 45, 46, 61, 64,
95, 126, 36, 44, 48, 57, 58, 59,
65, 90, 97, 122, 33, 37, 45, 61,
64, 95, 126, 36, 46, 48, 57, 58,
59, 65, 90, 97, 122, 33, 37, 61,
64, 95, 126, 36, 46, 48, 57, 58,
59, 65, 90, 97, 122, 58, 59, 48,
57, 65, 90, 97, 122, 59, 48, 57,
65, 90, 97, 122, 33, 37, 39, 59,
61, 126, 42, 43, 45, 46, 48, 57,
65, 90, 95, 122, 33, 37, 39, 59,
126, 42, 43, 45, 46, 48, 57, 65,
90, 95, 122, 33, 37, 58, 59, 61,
64, 95, 126, 36, 46, 48, 57, 65,
90, 97, 122, 33, 37, 58, 59, 61,
64, 95, 126, 36, 46, 48, 57, 65,
90, 97, 122, 33, 37, 39, 44, 58,
59, 61, 64, 96, 126, 36, 41, 42,
46, 48, 57, 65, 90, 95, 122, 33,
37, 39, 59, 61, 126, 42, 43, 45,
46, 48, 57, 65, 70, 71, 90, 95,
96, 97, 102, 103, 122, 33, 37, 39,
59, 61, 126, 42, 43, 45, 46, 48,
57, 65, 70, 71, 90, 95, 96, 97,
102, 103, 122, 33, 37, 39, 44, 58,
59, 61, 64, 96, 126, 36, 41, 42,
46, 48, 57, 65, 90, 95, 122, 33,
37, 39, 59, 126, 42, 43, 45, 46,
48, 57, 65, 70, 71, 90, 95, 96,
97, 102, 103, 122, 33, 37, 39, 59,
126, 42, 43, 45, 46, 48, 57, 65,
70, 71, 90, 95, 96, 97, 102, 103,
122, 0
};
static const char _tmsrp_machine_parser_uri_single_lengths[] = {
0, 1, 1, 1, 1, 2, 1, 1,
7, 6, 0, 0, 1, 1, 0, 1,
0, 1, 0, 3, 4, 5, 4, 4,
3, 3, 0, 2, 1, 1, 1, 1,
1, 1, 5, 1, 3, 2, 1, 0,
1, 2, 2, 2, 2, 1, 3, 0,
1, 0, 1, 0, 1, 1, 1, 1,
1, 1, 1, 3, 3, 2, 2, 2,
2, 2, 0, 3, 3, 3, 0, 1,
1, 1, 1, 7, 6, 7, 6, 7,
6, 9, 9, 9, 6, 9, 8, 8,
7, 7, 7, 7, 7, 7, 11, 7,
9, 8, 7, 6, 1, 1, 1, 6,
5, 8, 8, 10, 6, 6, 10, 5,
5
};
static const char _tmsrp_machine_parser_uri_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0,
5, 4, 3, 3, 3, 1, 1, 1,
1, 1, 1, 1, 4, 4, 5, 5,
1, 0, 1, 1, 1, 0, 1, 0,
1, 0, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 0, 3, 3, 1,
1, 1, 1, 1, 1, 1, 0, 1,
0, 1, 0, 3, 3, 3, 3, 3,
3, 0, 3, 3, 3, 3, 1, 1,
1, 0, 0, 5, 5, 5, 5, 5,
5, 4, 4, 3, 5, 4, 6, 6,
5, 4, 5, 4, 5, 4, 4, 5,
4, 5, 5, 5, 0, 3, 3, 5,
5, 4, 4, 5, 8, 8, 5, 8,
8
};
static const short _tmsrp_machine_parser_uri_index_offsets[] = {
0, 0, 2, 4, 6, 8, 11, 13,
15, 28, 39, 43, 47, 52, 55, 57,
60, 62, 65, 67, 72, 81, 91, 101,
111, 116, 120, 122, 126, 129, 131, 134,
136, 139, 141, 150, 155, 162, 168, 173,
177, 182, 188, 194, 200, 203, 208, 215,
217, 220, 222, 225, 227, 230, 233, 235,
238, 240, 243, 245, 252, 259, 265, 271,
277, 283, 286, 290, 297, 304, 311, 313,
316, 319, 321, 323, 336, 348, 361, 373,
386, 398, 412, 426, 439, 451, 465, 480,
495, 508, 520, 533, 545, 558, 570, 586,
599, 613, 627, 640, 652, 654, 659, 664,
676, 687, 700, 713, 729, 744, 759, 775,
789
};
static const unsigned char _tmsrp_machine_parser_uri_indicies[] = {
0, 1, 2, 1, 3, 1, 4, 1,
5, 6, 1, 7, 1, 8, 1, 9,
10, 9, 12, 14, 9, 9, 9, 11,
9, 13, 13, 1, 15, 16, 15, 17,
15, 15, 15, 15, 15, 15, 1, 18,
18, 18, 1, 15, 15, 15, 1, 14,
19, 20, 20, 1, 21, 22, 1, 23,
1, 24, 25, 1, 26, 1, 27, 28,
1, 29, 1, 30, 32, 33, 31, 1,
34, 34, 34, 34, 34, 34, 34, 34,
1, 35, 36, 35, 35, 35, 35, 35,
35, 35, 1, 37, 37, 37, 37, 37,
37, 37, 37, 37, 1, 38, 38, 38,
38, 38, 38, 38, 38, 38, 1, 30,
32, 33, 39, 1, 30, 32, 33, 1,
40, 1, 41, 43, 42, 1, 27, 44,
1, 27, 1, 24, 45, 1, 24, 1,
21, 46, 1, 21, 1, 47, 48, 30,
32, 33, 49, 49, 49, 1, 47, 49,
49, 49, 1, 30, 32, 33, 50, 49,
49, 1, 51, 52, 50, 50, 50, 1,
51, 50, 50, 50, 1, 50, 49, 49,
1, 54, 53, 53, 53, 1, 56, 39,
55, 55, 55, 1, 56, 39, 57, 57,
57, 1, 56, 39, 58, 58, 58, 1,
56, 39, 1, 60, 59, 53, 53, 1,
61, 56, 39, 62, 55, 55, 1, 63,
1, 64, 65, 1, 66, 1, 67, 68,
1, 69, 1, 39, 70, 1, 39, 71,
1, 39, 1, 67, 72, 1, 67, 1,
64, 73, 1, 64, 1, 61, 56, 39,
74, 57, 57, 1, 61, 56, 39, 58,
58, 58, 1, 76, 39, 75, 75, 75,
1, 78, 39, 77, 77, 77, 1, 78,
39, 79, 79, 79, 1, 78, 39, 80,
80, 80, 1, 78, 39, 1, 81, 75,
75, 1, 61, 78, 39, 82, 77, 77,
1, 61, 78, 39, 83, 79, 79, 1,
61, 78, 39, 80, 80, 80, 1, 84,
1, 61, 85, 1, 61, 86, 1, 61,
1, 60, 1, 15, 16, 87, 15, 17,
15, 15, 15, 88, 15, 15, 15, 1,
15, 16, 15, 17, 15, 15, 15, 89,
15, 15, 15, 1, 15, 16, 90, 15,
17, 15, 15, 15, 91, 15, 15, 15,
1, 15, 16, 15, 17, 15, 15, 15,
92, 15, 15, 15, 1, 15, 16, 93,
15, 17, 15, 15, 15, 94, 15, 15,
15, 1, 15, 16, 15, 17, 15, 15,
15, 95, 15, 15, 15, 1, 15, 16,
30, 97, 98, 15, 17, 15, 15, 15,
96, 15, 15, 1, 15, 16, 30, 97,
98, 15, 17, 15, 15, 15, 99, 15,
15, 1, 15, 16, 30, 97, 98, 15,
17, 15, 15, 15, 15, 15, 1, 15,
16, 15, 17, 15, 15, 15, 100, 15,
15, 15, 1, 15, 16, 41, 15, 102,
15, 17, 15, 15, 15, 101, 15, 15,
1, 103, 104, 103, 15, 15, 17, 37,
103, 15, 103, 103, 15, 103, 103, 1,
105, 106, 105, 15, 15, 17, 38, 105,
15, 105, 105, 15, 105, 105, 1, 15,
16, 93, 15, 17, 15, 15, 15, 107,
15, 15, 15, 1, 15, 16, 93, 15,
17, 15, 15, 15, 15, 15, 15, 1,
15, 16, 90, 15, 17, 15, 15, 15,
108, 15, 15, 15, 1, 15, 16, 90,
15, 17, 15, 15, 15, 15, 15, 15,
1, 15, 16, 87, 15, 17, 15, 15,
15, 109, 15, 15, 15, 1, 15, 16,
87, 15, 17, 15, 15, 15, 15, 15,
15, 1, 15, 16, 110, 111, 30, 97,
98, 15, 17, 15, 15, 15, 112, 112,
112, 1, 15, 16, 110, 15, 17, 15,
15, 15, 112, 15, 112, 112, 1, 15,
16, 30, 97, 98, 15, 17, 15, 15,
15, 113, 112, 112, 1, 15, 16, 114,
115, 15, 17, 15, 15, 15, 113, 15,
113, 113, 1, 15, 16, 114, 15, 17,
15, 15, 15, 113, 15, 113, 113, 1,
15, 16, 15, 17, 15, 15, 15, 113,
15, 112, 112, 1, 5, 1, 117, 116,
116, 116, 1, 119, 118, 118, 118, 1,
120, 120, 120, 121, 122, 120, 120, 120,
120, 120, 120, 1, 38, 38, 38, 121,
38, 38, 38, 38, 38, 38, 1, 15,
16, 15, 124, 15, 17, 15, 15, 15,
123, 123, 123, 1, 15, 16, 15, 126,
15, 17, 15, 15, 15, 125, 125, 125,
1, 127, 128, 127, 15, 15, 129, 130,
17, 120, 127, 15, 127, 127, 127, 127,
1, 120, 120, 120, 121, 122, 120, 120,
120, 131, 131, 120, 120, 131, 120, 1,
120, 120, 120, 121, 122, 120, 120, 120,
127, 127, 120, 120, 127, 120, 1, 105,
106, 105, 15, 15, 129, 15, 17, 38,
105, 15, 105, 105, 105, 105, 1, 38,
38, 38, 121, 38, 38, 38, 132, 132,
38, 38, 132, 38, 1, 38, 38, 38,
121, 38, 38, 38, 105, 105, 38, 38,
105, 38, 1, 0
};
static const char _tmsrp_machine_parser_uri_trans_targs[] = {
2, 0, 3, 4, 5, 6, 100, 7,
8, 9, 10, 75, 12, 94, 40, 9,
10, 12, 11, 13, 34, 14, 32, 15,
16, 30, 17, 18, 28, 19, 20, 24,
26, 101, 21, 21, 101, 103, 104, 25,
27, 20, 27, 101, 29, 31, 33, 35,
36, 34, 37, 38, 39, 41, 74, 42,
45, 43, 44, 46, 61, 47, 59, 48,
49, 57, 50, 51, 55, 52, 53, 54,
56, 58, 60, 62, 70, 63, 66, 64,
65, 67, 68, 69, 71, 72, 73, 76,
92, 77, 78, 90, 79, 80, 88, 81,
82, 84, 105, 83, 85, 85, 105, 107,
108, 110, 111, 89, 91, 93, 95, 96,
94, 97, 98, 99, 102, 22, 102, 22,
103, 22, 23, 106, 86, 106, 86, 107,
108, 86, 87, 109, 112
};
static const char _tmsrp_machine_parser_uri_trans_actions[] = {
1, 0, 0, 0, 0, 3, 0, 0,
0, 1, 1, 17, 26, 23, 20, 0,
0, 5, 0, 17, 23, 0, 0, 0,
0, 0, 0, 0, 0, 0, 7, 0,
7, 7, 1, 0, 11, 1, 0, 0,
1, 9, 0, 9, 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, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 7, 7, 0, 1, 0, 9, 1,
1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 29, 0, 13,
0, 15, 0, 1, 29, 0, 13, 0,
0, 15, 0, 0, 0
};
static const char _tmsrp_machine_parser_uri_eof_actions[] = {
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, 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, 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, 29, 13, 15,
15, 29, 13, 15, 15, 15, 15, 15,
15
};
static const int tmsrp_machine_parser_uri_start = 1;
static const int tmsrp_machine_parser_uri_first_final = 101;
static const int tmsrp_machine_parser_uri_error = 0;
static const int tmsrp_machine_parser_uri_en_main = 1;
/* #line 125 "tmsrp_parser_uri.rl" */
/* #line 440 "../src/parsers/tmsrp_parser_uri.c" */
{
cs = tmsrp_machine_parser_uri_start;
}
/* #line 126 "tmsrp_parser_uri.rl" */
/* #line 447 "../src/parsers/tmsrp_parser_uri.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 = _tmsrp_machine_parser_uri_trans_keys + _tmsrp_machine_parser_uri_key_offsets[cs];
_trans = _tmsrp_machine_parser_uri_index_offsets[cs];
_klen = _tmsrp_machine_parser_uri_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 = _tmsrp_machine_parser_uri_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 = _tmsrp_machine_parser_uri_indicies[_trans];
cs = _tmsrp_machine_parser_uri_trans_targs[_trans];
if ( _tmsrp_machine_parser_uri_trans_actions[_trans] == 0 )
goto _again;
_acts = _tmsrp_machine_parser_uri_actions + _tmsrp_machine_parser_uri_trans_actions[_trans];
_nacts = (unsigned int) *_acts++;
while ( _nacts-- > 0 )
{
switch ( *_acts++ )
{
case 0:
/* #line 47 "tmsrp_parser_uri.rl" */
{
tag_start = p;
}
break;
case 1:
/* #line 52 "tmsrp_parser_uri.rl" */
{ uri->authority.host_type = host_ipv4; }
break;
case 2:
/* #line 53 "tmsrp_parser_uri.rl" */
{ uri->authority.host_type = host_ipv6; }
break;
case 3:
/* #line 54 "tmsrp_parser_uri.rl" */
{ uri->authority.host_type = host_hostname; }
break;
case 4:
/* #line 56 "tmsrp_parser_uri.rl" */
{
TSK_PARSER_SET_STRING(uri->scheme);
}
break;
case 5:
/* #line 60 "tmsrp_parser_uri.rl" */
{
TSK_PARSER_SET_STRING(uri->authority.userinfo);
}
break;
case 6:
/* #line 64 "tmsrp_parser_uri.rl" */
{
TSK_PARSER_SET_STRING(uri->authority.host);
if(uri->authority.host_type == host_ipv6){
tsk_strunquoteex(&uri->authority.host, '[', ']');
}
}
break;
case 7:
/* #line 71 "tmsrp_parser_uri.rl" */
{
TSK_PARSER_SET_INT(uri->authority.port);
}
break;
case 8:
/* #line 75 "tmsrp_parser_uri.rl" */
{
TSK_PARSER_SET_STRING(uri->session_id);
}
break;
case 9:
/* #line 79 "tmsrp_parser_uri.rl" */
{
TSK_PARSER_SET_STRING(uri->transport);
}
break;
case 10:
/* #line 83 "tmsrp_parser_uri.rl" */
{
TSK_PARSER_ADD_PARAM(uri->params);
}
break;
/* #line 584 "../src/parsers/tmsrp_parser_uri.c" */
}
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
if ( p == eof )
{
const char *__acts = _tmsrp_machine_parser_uri_actions + _tmsrp_machine_parser_uri_eof_actions[cs];
unsigned int __nacts = (unsigned int) *__acts++;
while ( __nacts-- > 0 ) {
switch ( *__acts++ ) {
case 0:
/* #line 47 "tmsrp_parser_uri.rl" */
{
tag_start = p;
}
break;
case 9:
/* #line 79 "tmsrp_parser_uri.rl" */
{
TSK_PARSER_SET_STRING(uri->transport);
}
break;
case 10:
/* #line 83 "tmsrp_parser_uri.rl" */
{
TSK_PARSER_ADD_PARAM(uri->params);
}
break;
/* #line 618 "../src/parsers/tmsrp_parser_uri.c" */
}
}
}
_out: {}
}
/* #line 127 "tmsrp_parser_uri.rl" */
if( cs <
/* #line 629 "../src/parsers/tmsrp_parser_uri.c" */
101
/* #line 128 "tmsrp_parser_uri.rl" */
){
TSK_DEBUG_ERROR("Failed to parse MSRP/MSRPS header.");
TSK_OBJECT_SAFE_FREE(uri);
}
return uri;
}

View File

@ -0,0 +1,396 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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_message.c
* @brief MSRP message.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tinyMSRP/tmsrp_message.h"
#include "tsk_string.h"
#include "tsk_memory.h"
/*== Predicate function to find tmsrp_header_t object by type. */
static int pred_find_header_by_type(const tsk_list_item_t *item, const void *tmsrp_htype)
{
if(item && item->data)
{
tmsrp_header_t *header = item->data;
tmsrp_header_type_t htype = *((tmsrp_header_type_t*)tmsrp_htype);
return (header->type - htype);
}
return -1;
}
/*== Predicate function to find tmsrp_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)
{
tmsrp_header_t *header = item->data;
return tsk_stricmp(tmsrp_header_get_nameex(header), (const char*)name);
}
return -1;
}
int tmsrp_message_add_header(tmsrp_message_t *self, const tmsrp_header_t *hdr)
{
#define ADD_HEADER(type, field) \
case tmsrp_htype_##type: \
{ \
if(!self->field) \
{ \
self->field = (tmsrp_header_##type##_t*)header; \
return 0; \
} \
break; \
}
if(self && hdr)
{
tmsrp_header_t *header = tsk_object_ref((void*)hdr);
switch(header->type)
{
ADD_HEADER(To_Path, To);
ADD_HEADER(From_Path, From);
ADD_HEADER(Message_ID, MessageID);
ADD_HEADER(Byte_Range, ByteRange);
ADD_HEADER(Failure_Report, FailureReport);
ADD_HEADER(Success_Report, SuccessReport);
ADD_HEADER(Status, Status);
ADD_HEADER(Content_Type, ContentType);
default: break;
}
tsk_list_push_back_data(self->headers, (void**)&header);
return 0;
}
return -1;
}
int tmsrp_message_add_headers(tmsrp_message_t *self, const tmsrp_headers_L_t *headers)
{
tsk_list_item_t *item = 0;
if(self && headers)
{
tsk_list_foreach(item, headers){
tmsrp_message_add_header(self, item->data);
}
return 0;
}
return -1;
}
const tmsrp_header_t *tmsrp_message_get_headerAt(const tmsrp_message_t *self, tmsrp_header_type_t type, size_t index)
{
size_t pos = 0;
tsk_list_item_t *item;
const tmsrp_header_t* hdr = 0;
if(self)
{
switch(type)
{
case tmsrp_htype_To_Path:
if(index == 0){
hdr = (const tmsrp_header_t*)self->To;
goto bail;
}else pos++; break;
case tmsrp_htype_From_Path:
if(index == 0){
hdr = (const tmsrp_header_t*)self->From;
goto bail;
}else pos++; break;
case tmsrp_htype_Message_ID:
if(index == 0){
hdr = (const tmsrp_header_t*)self->MessageID;
goto bail; break;
}else pos++;
case tmsrp_htype_Byte_Range:
if(index == 0){
hdr = (const tmsrp_header_t*)self->ByteRange;
goto bail;
}else pos++; break;
case tmsrp_htype_Failure_Report:
if(index == 0){
hdr = (const tmsrp_header_t*)self->FailureReport;
goto bail;
}else pos++; break;
case tmsrp_htype_Success_Report:
if(index == 0){
hdr = (const tmsrp_header_t*)self->SuccessReport;
goto bail;
}else pos++; break;
case tmsrp_htype_Status:
if(index == 0){
hdr = (const tmsrp_header_t*)self->Status;
goto bail;
}else pos++; break;
case tmsrp_htype_Content_Type:
if(index == 0){
hdr = (const tmsrp_header_t*)self->ContentType;
goto bail;
}else pos++; break;
default:
break;
}
tsk_list_foreach(item, self->headers)
{
if(!pred_find_header_by_type(item, &type)){
if(pos++ >= index){
hdr = item->data;
break;
}
}
}
}
bail:
return hdr;
}
const tmsrp_header_t *tmsrp_message_get_header(const tmsrp_message_t *self, tmsrp_header_type_t type)
{
return tmsrp_message_get_headerAt(self, type, 0);
}
const tmsrp_header_t *tmsrp_message_get_headerByName(const tmsrp_message_t *self, char name)
{
if(self && self->headers){
const tsk_list_item_t* item;
if((item = tsk_list_find_item_by_pred(self->headers, pred_find_header_by_name, &name))){
return item->data;
}
}
return TMSRP_NULL;
}
int tmsrp_message_add_content(tmsrp_message_t *self, const char* content_type, const void* content, size_t size)
{
if(self)
{
if(content_type){
TSK_OBJECT_SAFE_FREE(self->ContentType);
}
TSK_OBJECT_SAFE_FREE(self->Content);
if(content_type){
TMSRP_MESSAGE_ADD_HEADER(self, TMSRP_HEADER_CONTENT_TYPE_VA_ARGS(content_type));
}
self->Content = TSK_BUFFER_CREATE(content, size);
return 0;
}
return -1;
}
int tmsrp_message_tostring(const tmsrp_message_t *self, tsk_buffer_t *output)
{
if(!self || !output){
return -1;
}
if(TMSRP_MESSAGE_IS_REQUEST(self)){
/* pMSRP SP transact-id SP method CRLF */
tsk_buffer_appendEx(output, "MSRP %s %s\r\n", self->tid, self->line.request.method);
}
else{
/* pMSRP SP transact-id SP status-code [SP comment] CRLF */
tsk_buffer_appendEx(output, "MSRP %s %3hi%s%s\r\n",
self->tid,
self->line.response.status,
self->line.response.comment ? " " : "",
self->line.response.comment ? self->line.response.comment : ""
);
}
/* To-Path */
if(self->To){
tmsrp_header_tostring(TMSRP_HEADER(self->To), output);
}
/* From-Path */
if(self->From){
tmsrp_header_tostring(TMSRP_HEADER(self->From), output);
}
/* Message-Id */
if(self->MessageID){
tmsrp_header_tostring(TMSRP_HEADER(self->MessageID), output);
}
/* Byte-Range */
if(self->ByteRange){
tmsrp_header_tostring(TMSRP_HEADER(self->ByteRange), output);
}
/* Failure-Report */
if(self->FailureReport){
tmsrp_header_tostring(TMSRP_HEADER(self->FailureReport), output);
}
/* Success-Report */
if(self->SuccessReport){
tmsrp_header_tostring(TMSRP_HEADER(self->SuccessReport), output);
}
/* Status */
if(self->Status){
tmsrp_header_tostring(TMSRP_HEADER(self->Status), output);
}
/* All other headers (Other-Mime-headers)*/
{
tsk_list_item_t *item;
tsk_list_foreach(item, self->headers){
tmsrp_header_t *hdr = item->data;
tmsrp_header_tostring(hdr, output);
}
}
/* Content-Type */
if(self->ContentType){
tmsrp_header_tostring(TMSRP_HEADER(self->ContentType), output);
}
/* CONTENT */
if(TMSRP_MESSAGE_HAS_CONTENT(self)){
tsk_buffer_append(output, "\r\n", 2);
tsk_buffer_append(output, TSK_BUFFER_TO_STRING(self->Content), TSK_BUFFER_SIZE(self->Content));
tsk_buffer_append(output, "\r\n", 2);
}
/* END LINE */
tsk_buffer_appendEx(output, "-------%s%c", self->end_line.tid, self->end_line.cflag);
return 0;
}
//=================================================================================================
// MSRP object definition
//
static void* tmsrp_message_create(void * self, va_list * app)
{
tmsrp_message_t *message = self;
if(message){
message->type = va_arg(*app, const tmsrp_message_type_t);
message->tid = tsk_strdup( va_arg(*app, const char*) );
message->line.request.method = tsk_strdup( va_arg(*app, const char*) );
#if defined(__GNUC__)
message->line.response.status = (short)va_arg(*app, int);
#else
message->line.response.status = va_arg(*app, short);
#endif
message->line.response.comment = tsk_strdup( va_arg(*app, const char*) );
message->headers = TSK_LIST_CREATE();
message->end_line.tid = tsk_strdup(message->tid);
message->end_line.cflag = '$';
}
return self;
}
static void* tmsrp_message_destroy(void * self)
{
tmsrp_message_t *message = self;
if(message){
TSK_FREE(message->tid);
// request
if(TMSRP_MESSAGE_IS_REQUEST(message)){
TSK_FREE(message->line.request.method);
}
// response
if(TMSRP_MESSAGE_IS_RESPONSE(message)){
TSK_FREE(message->line.response.comment);
}
// Very common headers
TSK_OBJECT_SAFE_FREE(message->To);
TSK_OBJECT_SAFE_FREE(message->From);
TSK_OBJECT_SAFE_FREE(message->MessageID);
TSK_OBJECT_SAFE_FREE(message->ByteRange);
TSK_OBJECT_SAFE_FREE(message->FailureReport);
TSK_OBJECT_SAFE_FREE(message->SuccessReport);
TSK_OBJECT_SAFE_FREE(message->Status);
// all other headers
TSK_OBJECT_SAFE_FREE(message->headers);
// content
TSK_OBJECT_SAFE_FREE(message->ContentType);
TSK_OBJECT_SAFE_FREE(message->Content);
// end-line
TSK_FREE(message->end_line.tid);
}
return self;
}
static int tmsrp_message_cmp(const void *obj1, const void *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_message_def_s =
{
sizeof(tmsrp_message_t),
tmsrp_message_create,
tmsrp_message_destroy,
tmsrp_message_cmp,
};
const void *tmsrp_message_def_t = &tmsrp_message_def_s;

View File

@ -0,0 +1,187 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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_uri.c
* @brief MSRP/MSRPS URI.
*
* @author Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
*/
#include "tinyMSRP/tmsrp_uri.h"
#include "tinyMSRP/parsers/tmsrp_parser_uri.h"
#include "tsk_debug.h"
#include "tsk_memory.h"
#include "tsk_string.h"
#include "tsk_params.h"
#include "tsk_url.h"
#include <string.h>
/**@defgroup tmsrp_uri_group MSRP/MSRPS/TEL URI
*/
int tmsrp_uri_serialize(const tmsrp_uri_t *uri, tsk_buffer_t *output)
{
tsk_istr_t port;
if(!uri || !output){
return -1;
}
if(uri->authority.port >= 0){
tsk_itoa(uri->authority.port, &port);
}
/* msrp://atlanta.example.com:7654/jshA7weztas;tcp
* msrp-scheme "://" authority ["/" session-id] ";" transport *( ";" URI-parameter)
* authority = [ userinfo "@" ] host [ ":" port ]
*/
tsk_buffer_appendEx(output, "%s://%s%s%s%s%s%s%s%s%s;%s",
// scheme
uri->scheme,
// authority
uri->authority.userinfo ? uri->authority.userinfo : "",
uri->authority.userinfo ? "@" : "",
uri->authority.host_type == host_ipv6 ? "[" : "",
uri->authority.host,
uri->authority.host_type == host_ipv6 ? "]" : "",
uri->authority.port >= 0 ? ":" : "",
uri->authority.port >= 0 ? port : "",
// session-id
uri->session_id ? "/" : "",
uri->session_id ? uri->session_id : "",
// transport
uri->transport
);
/* Params */
if(!TSK_LIST_IS_EMPTY(uri->params)){
tsk_buffer_append(output, ";", 1);
tsk_params_tostring(uri->params, ';', output);
}
return 0;
}
char* tmsrp_uri_tostring(const tmsrp_uri_t *uri)
{
tsk_buffer_t *output = TSK_BUFFER_CREATE_NULL();
char* ret = 0;
if(!tmsrp_uri_serialize(uri, output)){
ret = tsk_strndup((const char*)output->data, output->size);
}
else{
TSK_DEBUG_ERROR("Failed to serialize URI.");
}
TSK_OBJECT_SAFE_FREE(output);
return ret;
}
tmsrp_uri_t *tmsrp_uri_clone(const tmsrp_uri_t *uri)
{
tmsrp_uri_t *newuri = 0;
tsk_buffer_t *output = TSK_BUFFER_CREATE_NULL();
tmsrp_uri_serialize(uri, output);
newuri = tmsrp_uri_parse(output->data, output->size);
TSK_OBJECT_SAFE_FREE(output);
return newuri;
}
//========================================================
// MSRP/MSRPS/TEL URI object definition
//
/**@ingroup tmsrp_uri_group
*/
static void* tmsrp_uri_create(void *self, va_list * app)
{
tmsrp_uri_t *uri = self;
if(uri){
uri->scheme = tsk_strdup( va_arg(*app, const char*) );
// authority
uri->authority.host = tsk_strdup( va_arg(*app, const char*) );
uri->authority.host_type = va_arg(*app, tmsrp_host_type_t);
uri->authority.port = va_arg(*app, int32_t);
uri->session_id = tsk_strdup( va_arg(*app, const char*) );
uri->transport = tsk_strdup( va_arg(*app, const char*) );
uri->params = TSK_LIST_CREATE(); /* Empty list. */
}
else{
TSK_DEBUG_ERROR("Failed to create new MSRP/MSRPS.");
}
return self;
}
/**@ingroup tmsrp_uri_group
*/
static void* tmsrp_uri_destroy(void *self)
{
tmsrp_uri_t *uri = self;
if(uri)
{
TSK_FREE(uri->scheme);
// authority
TSK_FREE(uri->authority.userinfo);
TSK_FREE(uri->authority.host);
//
TSK_FREE(uri->session_id);
TSK_FREE(uri->transport);
TSK_OBJECT_SAFE_FREE(uri->params);
}
else TSK_DEBUG_ERROR("Null MSRP/MSRPS URI.");
return self;
}
static int tmsrp_uri_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return -1;
}
static const tsk_object_def_t tmsrp_uri_def_s =
{
sizeof(tmsrp_uri_t),
tmsrp_uri_create,
tmsrp_uri_destroy,
tmsrp_uri_cmp
};
const void *tmsrp_uri_def_t = &tmsrp_uri_def_s;

View File

@ -0,0 +1,26 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.
*
*/
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

View File

@ -0,0 +1,41 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.
*
*/
#ifndef TEST_TMSRP_STDAFX_H
#define TEST_TMSRP_STDAFX_H
#ifdef WIN32
#include "targetver.h"
#endif
#include <stdio.h>
#if (defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE)) && !defined(__SYMBIAN32__)
#include <tchar.h>
#endif
// TODO: reference additional headers your program requires here
#include <string.h>
#endif /* TEST_TMSRP_STDAFX_H */

View File

@ -0,0 +1,14 @@
#ifndef TMSRP_TEST_TARGETVER_H
#define TMSRP_TEST_TARGETVER_H
// The following macros define the minimum required platform. The minimum required platform
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
// your application. The macros work by enabling all features available on platform versions up to and
// including the version specified.
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#endif /* TMSRP_TEST_TARGETVER_H */

View File

@ -0,0 +1,61 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.
*
*/
#include "stdafx.h"
#include "tsk.h"
#include "tinyMSRP/parsers/tmsrp_parser_message.h"
#include "test_parser.h"
#include "test_uri.h"
#define RUN_TEST_LOOP 1
#define RUN_TEST_ALL 0
#define RUN_TEST_URI 0
#define RUN_TEST_PARSER 1
#ifdef _WIN32_WCE
int _tmain(int argc, _TCHAR* argv[])
#else
int main()
#endif
{
#if RUN_TEST_LOOP
for(;;)
#endif
{
/* Print copyright information */
printf("Doubango Project\nCopyright (C) 2009 - 2010 Mamadou Diop \n\n");
#if RUN_TEST_ALL || RUN_TEST_URI
test_uri();
#endif
#if RUN_TEST_ALL || RUN_TEST_PARSER
test_parser();
#endif
}
}

View File

@ -0,0 +1,219 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="test"
ProjectGUID="{C7732B19-4EF5-40EB-939B-4F1F5F2D3B18}"
RootNamespace="test"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(DOUBANGO_HOME)\thirdparties\win32\include&quot;;&quot;$(SolutionDir)\include&quot;;&quot;$(DOUBANGO_HOME)\tinySAK\src&quot;"
PreprocessorDefinitions="DEBUG_LEVEL=DEBUG_LEVEL_INFO;WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
WarnAsError="true"
DebugInformationFormat="4"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinyMSRP.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
WarnAsError="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="source"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\stdafx.c"
>
</File>
<File
RelativePath=".\test.c"
>
</File>
</Filter>
<Filter
Name="include"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\targetver.h"
>
</File>
</Filter>
<Filter
Name="tests"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\test_parser.h"
>
</File>
<File
RelativePath=".\test_uri.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.
*
*/
#ifndef _TEST_MSRPPARSER_H
#define _TEST_MSRPPARSER_H
#include "tinyMSRP/headers/tmsrp_header_Dummy.h"
#define MSRP_MSG_REQUEST \
"MSRP a786hjs2 SEND\r\n" \
"To-Path: msrp://biloxi.example.com:12763/kjhd37s2s20w2a;tcp\r\n" \
"From-Path: msrp://atlanta.example.com:7654/jshA7weztas;tcp\r\n" \
"Message-ID: 87652491\r\n" \
"Byte-Dummy: 1-25/25\r\n" \
"Byte-Range: 1-25/25\r\n" \
"Byte-Range: 1-25/*\r\n" \
"Byte-Range: 1-*/*\r\n" \
"Failure-Report: partial\r\n" \
"Success-Report: yes\r\n" \
"Content-Type: text/plain;charset=utf8\r\n" \
"\r\n" \
"-------fake-tid+ Hey Bob, are you there?\r\n" \
"-------a786hjs2$\r\n"
#define MSRP_MSG_RESPONSE \
"MSRP a786hjs2 200 OK\r\n" \
"To-Path: msrp://atlanta.example.com:7654/jshA7weztas;tcp\r\n" \
"From-Path: msrp://biloxi.example.com:12763/kjhd37s2s20w2a;tcp\r\n" \
"-------a786hjs2$\r\n"
#define MSRP_MSG_REPORT \
"MSRP dkei38sd REPORT\r\n" \
"To-Path: msrp://alicepc.example.com:7777/iau39soe2843z;tcp\r\n" \
"From-Path: msrp://bob.example.com:8888/9di4eae923wzd;tcp\r\n" \
"Message-ID: 12339sdqwer\r\n" \
"Byte-Range: 1-106/106\r\n" \
"Status: 000 200 OK\r\n" \
"-------dkei38sd$\r\n"
#define MSRP_MSG_TO_TEST MSRP_MSG_REQUEST
void test_parser()
{
tmsrp_message_t *message = 0;
/* deserialize the message */
if((message = tmsrp_message_parse(MSRP_MSG_TO_TEST, strlen(MSRP_MSG_TO_TEST)))){
tsk_buffer_t *buffer = TSK_BUFFER_CREATE_NULL();
/* serialize the message */
tmsrp_message_tostring(message, buffer);
TSK_DEBUG_INFO("\nMSRP Message=\n%s", TSK_BUFFER_TO_STRING(buffer));
TSK_OBJECT_SAFE_FREE(buffer);
}
else{
TSK_DEBUG_ERROR("Failed to parse MSRP message.");
}
TSK_OBJECT_SAFE_FREE(message);
}
#endif /* _TEST_MSRPPARSER_H */

View File

@ -0,0 +1,113 @@
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*
* 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.
*
*/
#ifndef _TEST_MSRPURI_H
#define _TEST_MSRPURI_H
#include "tinymsrp/parsers/tmsrp_parser_uri.h"
const char* uris[] =
{
"msrp://atlanta.example.com:7654/jshA7weztas;tcp;p1=1;p2=2",
"msrps://atlanta.example.com:7654/jshA7weztas;tcp",
// hostname, IPv4 and IPv6 (without userinfo and with port)
"msrp://biloxi.msrp.com:12763/kjhd37s2s20w2a;sctp",
"msrps://192.168.0.10:7654/jshA7weztas;tcp;p3=4",
"msrps://[::127]:7654/jshA7weztas;tcp;p=0",
// hostname, IPv4 and IPv6 (without userinfo and without port)
"msrp://biloxi.msrp.com/kjhd37s2s20w2a;sctp",
"msrps://192.168.0.10/jshA7weztas;tcp;p3=4",
"msrps://[::127]/jshA7weztas;tcp;p=0",
// hostname, IPv4 and IPv6 (with userinfo and with port)
"msrp://bob@biloxi.msrp.com:12763/kjhd37s2s20w2a;sctp",
"msrps://alice@192.168.0.10:7654/jshA7weztas;tcp;p3=4",
"msrps://carol@[::127]:7654/jshA7weztas;tcp;p=0",
// hostname, IPv4 and IPv6 (with userinfo and without port)
"msrp://bob@biloxi.msrp.com/kjhd37s2s20w2a;sctp",
"msrps://alice@192.168.0.10/jshA7weztas;tcp;p3=4",
"msrps://carol@[::127]/jshA7weztas;tcp;p=0",
// without session_id
"msrps://[::127]:7654;tcp;p=0",
};
void test_uri_tostring(const tmsrp_uri_t *uri)
{
char* ret = tmsrp_uri_tostring(uri);
TSK_DEBUG_INFO("uri_to_string=%s", ret);
TSK_FREE(ret);
}
void test_uri_parser()
{
int i;
tsk_list_item_t *item = 0;
for(i=0; i<sizeof(uris)/sizeof(const char*); i++)
{
tmsrp_uri_t *uri = tmsrp_uri_parse(uris[i], strlen(uris[i]));
printf("\n== Parsing {{ %s }} ==\n\n", uris[i]);
if(uri)
{
printf("scheme: %s\n", uri->scheme);
printf("userinfo: %s\n", uri->authority.userinfo);
printf("host: %s\n", uri->authority.host);
printf("port: %d\n", uri->authority.port);
printf("host-type: %s\n", uri->authority.host_type == host_ipv4 ? "IPv4" : (uri->authority.host_type == host_ipv6 ? "IPv6" : (uri->authority.host_type == host_hostname ? "HOSTNAME" : "UNKNOWN")) );
printf("session-id: %s\n", uri->session_id);
printf("transport: %s\n", uri->transport);
printf("---PARAMS---\n");
/* dump all parameters */
tsk_list_foreach(item, uri->params){
tsk_param_t* param = item->data;
printf("-->%s=%s\n", param->name, param->value);
}
printf("Is-secure: %s\n", TMSRP_URI_IS_SECURE(uri) ? "YES" : "NO");
test_uri_tostring(uri);
}
else{
printf("INVALID MSRP URI.\n");
}
printf("\n\n");
getchar();
TSK_OBJECT_SAFE_FREE(uri);
}
}
void test_uri()
{
test_uri_parser();
}
#endif /* _TEST_MSRPURI_H */

View File

@ -3,16 +3,64 @@ Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyMSRP", "tinyMSRP.vcproj", "{AA46AF16-9678-4054-8E48-98DC21ECEC82}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySAK", "..\tinySAK\tinySAK.vcproj", "{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test\test.vcproj", "{C7732B19-4EF5-40EB-939B-4F1F5F2D3B18}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyHTTP", "..\tinyHTTP\tinyHTTP.vcproj", "{B3E45009-C7C3-4090-837C-2D30C9058443}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyNET", "..\tinyNET\tinyNET.vcproj", "{7522A458-92F4-4259-B906-E84C2A65D9F1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
Release|Win32 = Release|Win32
Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AA46AF16-9678-4054-8E48-98DC21ECEC82}.Debug|Win32.ActiveCfg = Debug|Win32
{AA46AF16-9678-4054-8E48-98DC21ECEC82}.Debug|Win32.Build.0 = Debug|Win32
{AA46AF16-9678-4054-8E48-98DC21ECEC82}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32
{AA46AF16-9678-4054-8E48-98DC21ECEC82}.Release|Win32.ActiveCfg = Release|Win32
{AA46AF16-9678-4054-8E48-98DC21ECEC82}.Release|Win32.Build.0 = Release|Win32
{AA46AF16-9678-4054-8E48-98DC21ECEC82}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Win32.ActiveCfg = Debug|Win32
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Win32.Build.0 = Debug|Win32
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Win32.ActiveCfg = Release|Win32
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Win32.Build.0 = Release|Win32
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{C7732B19-4EF5-40EB-939B-4F1F5F2D3B18}.Debug|Win32.ActiveCfg = Debug|Win32
{C7732B19-4EF5-40EB-939B-4F1F5F2D3B18}.Debug|Win32.Build.0 = Debug|Win32
{C7732B19-4EF5-40EB-939B-4F1F5F2D3B18}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32
{C7732B19-4EF5-40EB-939B-4F1F5F2D3B18}.Release|Win32.ActiveCfg = Release|Win32
{C7732B19-4EF5-40EB-939B-4F1F5F2D3B18}.Release|Win32.Build.0 = Release|Win32
{C7732B19-4EF5-40EB-939B-4F1F5F2D3B18}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
{B3E45009-C7C3-4090-837C-2D30C9058443}.Debug|Win32.ActiveCfg = Debug|Win32
{B3E45009-C7C3-4090-837C-2D30C9058443}.Debug|Win32.Build.0 = Debug|Win32
{B3E45009-C7C3-4090-837C-2D30C9058443}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{B3E45009-C7C3-4090-837C-2D30C9058443}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{B3E45009-C7C3-4090-837C-2D30C9058443}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{B3E45009-C7C3-4090-837C-2D30C9058443}.Release|Win32.ActiveCfg = Release|Win32
{B3E45009-C7C3-4090-837C-2D30C9058443}.Release|Win32.Build.0 = Release|Win32
{B3E45009-C7C3-4090-837C-2D30C9058443}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{B3E45009-C7C3-4090-837C-2D30C9058443}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{B3E45009-C7C3-4090-837C-2D30C9058443}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{7522A458-92F4-4259-B906-E84C2A65D9F1}.Debug|Win32.ActiveCfg = Debug|Win32
{7522A458-92F4-4259-B906-E84C2A65D9F1}.Debug|Win32.Build.0 = Debug|Win32
{7522A458-92F4-4259-B906-E84C2A65D9F1}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{7522A458-92F4-4259-B906-E84C2A65D9F1}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{7522A458-92F4-4259-B906-E84C2A65D9F1}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Win32.ActiveCfg = Release|Win32
{7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Win32.Build.0 = Release|Win32
{7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{7522A458-92F4-4259-B906-E84C2A65D9F1}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -41,13 +41,16 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TINYMSRP_EXPORTS"
AdditionalIncludeDirectories="&quot;$(DOUBANGO_HOME)\thirdparties\win32\include&quot;;&quot;$(DOUBANGO_HOME)\tinySAK\src&quot;;&quot;$(DOUBANGO_HOME)\tinyMSRP\include&quot;;&quot;$(DOUBANGO_HOME)\tinyHTTP\include&quot;"
PreprocessorDefinitions="DEBUG_LEVEL=DEBUG_LEVEL_INFO;WIN32;_DEBUG;_WINDOWS;_USRDLL;TINYMSRP_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
WarnAsError="true"
DebugInformationFormat="4"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -60,6 +63,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinyHTTP.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
@ -119,7 +123,9 @@
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
WarnAsError="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -166,25 +172,117 @@
</References>
<Files>
<Filter
Name="include"
Name="include(*.h)"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\src\tinyMSRP_config.h"
RelativePath=".\include\tinyMSRP_config.h"
>
</File>
<File
RelativePath=".\src\tmsrp.h"
RelativePath=".\include\tmsrp.h"
>
</File>
<File
RelativePath=".\src\tmsrp_message.h"
RelativePath=".\include\tinyMSRP\tmsrp_message.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\tmsrp_uri.h"
>
</File>
<Filter
Name="headers"
>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_Authentication-Info.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_Authorization.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_Byte-Range.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_Content-Type.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_Dummy.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_Expires.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_Failure-Report.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_From-Path.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_Max-Expires.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_Message-ID.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_Min-Expires.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_Status.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_Success-Report.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_To-Path.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_Use-Path.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\headers\tmsrp_header_WWW-Authenticate.h"
>
</File>
</Filter>
<Filter
Name="parsers"
>
<File
RelativePath=".\include\tinyMSRP\parsers\tmsrp_parser_header.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\parsers\tmsrp_parser_message.h"
>
</File>
<File
RelativePath=".\include\tinyMSRP\parsers\tmsrp_parser_uri.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="source"
Name="source(*.c)"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
@ -196,6 +294,174 @@
RelativePath=".\src\tmsrp_message.c"
>
</File>
<File
RelativePath=".\src\tmsrp_uri.c"
>
</File>
<Filter
Name="headers"
>
<File
RelativePath=".\src\headers\tmsrp_header.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_Authentication-Info.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_Authorization.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_Byte-Range.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_Content-Type.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_Dummy.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_Expires.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_Failure-Report.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_From-Path.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_Max-Expires.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_Message-ID.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_Min-Expires.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_Status.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_Success-Report.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_To-Path.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_Use-Path.c"
>
</File>
<File
RelativePath=".\src\headers\tmsrp_header_WWW-Authenticate.c"
>
</File>
</Filter>
<Filter
Name="parsers"
>
<File
RelativePath=".\src\parsers\tmsrp_parser_message.c"
>
</File>
<File
RelativePath=".\src\parsers\tmsrp_parser_uri.c"
>
</File>
</Filter>
</Filter>
<Filter
Name="ragel(*.rl)"
>
<File
RelativePath=".\ragel\tmsrp_machine_utils.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_Authentication-Info.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_Authorization.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_Byte-Range.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_Content-Type.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_Dummy.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_Expires.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_Failure-Report.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_From-Path.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_Max-Expires.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_Message-ID.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_Min-Expires.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_Status.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_Success-Report.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_To-Path.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_header_Use-Path.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_message.rl"
>
</File>
<File
RelativePath=".\ragel\tmsrp_parser_uri.rl"
>
</File>
</Filter>
<Filter
Name="abnf(*.abnf)"
>
</Filter>
</Files>
<Globals>