Commit 7d343308 authored by jehan's avatar jehan

port to libanntlrc3.4

parent 7bb0ae0f
Dependencies:
libantlr3c-3.2
libantlr3c-3.4
antlr3-3.2
CUinit-2.x
......
......@@ -34,6 +34,10 @@ void belle_sip_parameters_clean(belle_sip_parameters_t* params);
const char* belle_sip_parameters_get_parameter(const belle_sip_parameters_t* obj,const char* name);
/*
* same as #belle_sip_parameters_get_parameter but name is case insensitive */
const char* belle_sip_parameters_get_case_parameter(const belle_sip_parameters_t* params,const char* name);
/**
* returns 0 if not found
*/
......
......@@ -802,10 +802,11 @@ belle_sip_header_extension_t* belle_sip_header_extension_parse (const char* valu
pANTLR3_COMMON_TOKEN_STREAM tokens;
pbelle_sip_messageParser parser;
belle_sip_messageParser_header_extension_return l_parsed_object;
input = antlr3NewAsciiStringCopyStream (
input = antlr3StringStreamNew (
(pANTLR3_UINT8)value,
ANTLR3_ENC_8BIT,
(ANTLR3_UINT32)strlen(value),
((void *)0));
(pANTLR3_UINT8)"header_extension");
lex = belle_sip_messageLexerNew (input);
tokens = antlr3CommonTokenStreamSourceNew (1025, lex->pLexer->rec->state->tokSource);
parser = belle_sip_messageParserNew (tokens);
......
......@@ -349,10 +349,11 @@ belle_sip_##object_type##_t* belle_sip_##object_type##_parse (const char* value)
pANTLR3_COMMON_TOKEN_STREAM tokens; \
pbelle_sip_messageParser parser; \
belle_sip_##object_type##_t* l_parsed_object; \
input = antlr3NewAsciiStringCopyStream (\
input = antlr3StringStreamNew(\
(pANTLR3_UINT8)value,\
ANTLR3_ENC_8BIT,\
(ANTLR3_UINT32)strlen(value),\
NULL);\
(pANTLR3_UINT8)#object_type);\
lex = belle_sip_messageLexerNew (input);\
tokens = antlr3CommonTokenStreamSourceNew (ANTLR3_SIZE_HINT, TOKENSOURCE(lex));\
parser = belle_sip_messageParserNew (tokens);\
......@@ -407,6 +408,7 @@ belle_sip_param_pair_t* belle_sip_param_pair_new(const char* name,const char* va
void belle_sip_param_pair_destroy(belle_sip_param_pair_t* pair) ;
int belle_sip_param_pair_comp_func(const belle_sip_param_pair_t *a, const char*b) ;
int belle_sip_param_pair_case_comp_func(const belle_sip_param_pair_t *a, const char*b) ;
belle_sip_param_pair_t* belle_sip_param_pair_ref(belle_sip_param_pair_t* obj);
......@@ -707,10 +709,11 @@ belle_sdp_##object_type##_t* belle_sdp_##object_type##_parse (const char* value)
pANTLR3_COMMON_TOKEN_STREAM tokens; \
pbelle_sdpParser parser; \
belle_sdp_##object_type##_t* l_parsed_object; \
input = antlr3NewAsciiStringCopyStream (\
input = antlr3StringStreamNew (\
(pANTLR3_UINT8)value,\
ANTLR3_ENC_8BIT,\
(ANTLR3_UINT32)strlen(value),\
NULL);\
(pANTLR3_UINT8)#object_type);\
lex = belle_sdpLexerNew (input);\
tokens = antlr3CommonTokenStreamSourceNew (ANTLR3_SIZE_HINT, TOKENSOURCE(lex));\
parser = belle_sdpParserNew (tokens);\
......
......@@ -58,8 +58,9 @@ BELLE_SIP_NEW_HEADER(parameters,header,"parameters")
const belle_sip_list_t * belle_sip_parameters_get_parameters(const belle_sip_parameters_t* obj) {
return obj->param_list;
}
const char* belle_sip_parameters_get_parameter(const belle_sip_parameters_t* params,const char* name) {
belle_sip_list_t * lResult = belle_sip_list_find_custom(params->param_list, (belle_sip_compare_func)belle_sip_param_pair_comp_func, name);
const char* belle_sip_parameters_get_parameter_base(const belle_sip_parameters_t* params,const char* name,belle_sip_compare_func func) {
belle_sip_list_t * lResult = belle_sip_list_find_custom(params->param_list, func, name);
if (lResult) {
return ((belle_sip_param_pair_t*)(lResult->data))->value;
}
......@@ -67,6 +68,13 @@ const char* belle_sip_parameters_get_parameter(const belle_sip_parameters_t* par
return NULL;
}
}
const char* belle_sip_parameters_get_parameter(const belle_sip_parameters_t* params,const char* name) {
return belle_sip_parameters_get_parameter_base(params,name,(belle_sip_compare_func)belle_sip_param_pair_comp_func);
}
const char* belle_sip_parameters_get_case_parameter(const belle_sip_parameters_t* params,const char* name) {
return belle_sip_parameters_get_parameter_base(params,name,(belle_sip_compare_func)belle_sip_param_pair_case_comp_func);
}
unsigned int belle_sip_parameters_is_parameter(const belle_sip_parameters_t* params,const char* name) {
return belle_sip_list_find_custom(params->param_list, (belle_sip_compare_func)belle_sip_param_pair_comp_func, name) != NULL;
}
......
......@@ -200,8 +200,8 @@ static int uri_strncasecmp(const char*a,const char*b,size_t n) {
#define IS_EQUAL_CASE(a,b) uri_strncasecmp(a,b,MIN(strlen(a),strlen(b)))!=0
#define PARAM_CASE_CMP(uri_a,uri_b,param) \
a_param=belle_sip_parameters_get_parameter((belle_sip_parameters_t*) uri_a,param); \
b_param=belle_sip_parameters_get_parameter((belle_sip_parameters_t*) uri_b,param);\
a_param=belle_sip_parameters_get_case_parameter((belle_sip_parameters_t*) uri_a,param); \
b_param=belle_sip_parameters_get_case_parameter((belle_sip_parameters_t*) uri_b,param);\
if (a_param && b_param) { \
if (IS_EQUAL_CASE(a_param,b_param)) return 0; \
} else if (a_param != b_param) {\
......
......@@ -522,6 +522,9 @@ void belle_sip_param_pair_destroy(belle_sip_param_pair_t* pair) {
int belle_sip_param_pair_comp_func(const belle_sip_param_pair_t *a, const char*b) {
return strcmp(a->name,b);
}
int belle_sip_param_pair_case_comp_func(const belle_sip_param_pair_t *a, const char*b) {
return strcasecmp(a->name,b);
}
char* _belle_sip_str_dup_and_unquote_string(const char* quoted_string) {
size_t value_size = strlen(quoted_string);
......
......@@ -79,10 +79,11 @@ belle_sip_message_t* belle_sip_message_parse_raw (const char* buff, size_t buff_
pANTLR3_COMMON_TOKEN_STREAM tokens;
pbelle_sip_messageParser parser;
belle_sip_message_t* l_parsed_object;
input = antlr3NewAsciiStringCopyStream (
input = antlr3StringStreamNew (
(pANTLR3_UINT8)buff,
ANTLR3_ENC_8BIT,
(ANTLR3_UINT32)buff_length,
((void *)0));
(pANTLR3_UINT8)"message");
lex = belle_sip_messageLexerNew (input);
tokens = antlr3CommonTokenStreamSourceNew (1025, lex->pLexer->rec->state->tokSource);
parser = belle_sip_messageParserNew (tokens);
......
......@@ -254,13 +254,13 @@ int belle_sip_message_test_suite () {
/* add the tests to the suite */
/* NOTE - ORDER IS IMPORTANT - MUST TEST fread() AFTER fprintf() */
if (NULL == CU_add_test(pSuite, "test of register message", testRegisterMessage)) {
if (NULL == CU_add_test(pSuite, "testRegisterMessage", testRegisterMessage)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "test of invite message", testInviteMessage)) {
if (NULL == CU_add_test(pSuite, "testInviteMessage", testInviteMessage)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "test of options message", testOptionMessage)) {
if (NULL == CU_add_test(pSuite, "testOptionMessage", testOptionMessage)) {
return CU_get_error();
}
......
......@@ -272,7 +272,7 @@ int belle_sip_uri_test_suite () {
/* add a suite to the registry */
pSuite = CU_add_suite("uri suite", init_suite_uri, clean_suite_uri);
pSuite = CU_add_suite("Uri", init_suite_uri, clean_suite_uri);
if (NULL == pSuite) {
return CU_get_error();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment