Commit c04f17a3 authored by jehan's avatar jehan

add generic uri parser as defined in rfc2396

parent 644c537c
......@@ -2,7 +2,7 @@ bellesipdir=$(includedir)/belle-sip
bellesip_HEADERS=\
object.h \
uri.h \
sip-uri.h \
list.h \
headers.h \
parameters.h \
......@@ -24,6 +24,7 @@ bellesip_HEADERS=\
dict.h \
http-provider.h \
http-message.h \
http-listener.h
http-listener.h \
generic-uri.h
EXTRA_DIST=$(bellesip_HEADERS)
......@@ -119,7 +119,8 @@ BELLE_SIP_DECLARE_TYPES_BEGIN(belle_sip,1)
BELLE_SIP_TYPE_ID(belle_http_provider_t),
BELLE_SIP_TYPE_ID(belle_http_request_t),
BELLE_SIP_TYPE_ID(belle_http_response_t),
BELLE_SIP_TYPE_ID(belle_http_channel_context_t)
BELLE_SIP_TYPE_ID(belle_http_channel_context_t),
BELLE_SIP_TYPE_ID(belle_generic_uri_t)
BELLE_SIP_DECLARE_TYPES_END
......@@ -163,7 +164,7 @@ typedef struct belle_http_url belle_http_url_t;
#include "belle-sip/list.h"
#include "belle-sip/listener.h"
#include "belle-sip/mainloop.h"
#include "belle-sip/uri.h"
#include "belle-sip/sip-uri.h"
#include "belle-sip/headers.h"
#include "belle-sip/parameters.h"
#include "belle-sip/message.h"
......@@ -175,6 +176,7 @@ typedef struct belle_http_url belle_http_url_t;
#include "belle-sip/listeningpoint.h"
#include "belle-sip/provider.h"
#include "belle-sip/auth-helper.h"
#include "belle-sip/generic-uri.h"
#include "belle-sip/http-listener.h"
#include "belle-sip/http-provider.h"
#include "belle-sip/http-message.h"
......
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2013 Belledonne Communications SARL, Grenoble, France
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BELLE_GENERIC_URI_H_
#define BELLE_GENERIC_URI_H_
#include "belle-sip/defs.h"
#include "belle-sip/list.h"
#include "belle-sip/utils.h"
typedef struct _belle_generic_uri belle_generic_uri_t;
BELLE_SIP_BEGIN_DECLS
/**
*
*/
BELLESIP_EXPORT belle_generic_uri_t* belle_generic_uri_new();
/**
*
*/
BELLESIP_EXPORT belle_generic_uri_t* belle_generic_uri_parse (const char* uri) ;
/*
* Returns the host part of this uri.
*
*/
BELLESIP_EXPORT const char* belle_generic_uri_get_host(const belle_generic_uri_t* uri) ;
/**
* Returns the value of the maddr parameter, or null if this is not set.
*
*/
BELLESIP_EXPORT int belle_generic_uri_get_port(const belle_generic_uri_t* uri) ;
/**
* Returns the port of the uri, if not specified in the uri returns the well known port according to the transport.
**/
BELLESIP_EXPORT int belle_generic_uri_get_listening_port(const belle_generic_uri_t *uri);
/**
* Returns the user part of this URI.
*
*/
BELLESIP_EXPORT const char* belle_generic_uri_get_user(const belle_generic_uri_t* uri) ;
/**
* Gets user password of uri, or null if it is not set.
*
*/
BELLESIP_EXPORT const char* belle_generic_uri_get_user_password(const belle_generic_uri_t* uri) ;
/**
*
* Returns uri scheme.
*
*/
BELLESIP_EXPORT const char* belle_generic_uri_get_scheme(const belle_generic_uri_t* uri) ;
/**
*
* Returns uri path.
*
*/
BELLESIP_EXPORT const char* belle_generic_uri_get_path(const belle_generic_uri_t* uri) ;
/**
*
* Returns uri query.
*
*/
BELLESIP_EXPORT const char* belle_generic_uri_get_query(const belle_generic_uri_t* uri) ;
/**
* Removes the port part of this uri.
*
*/
BELLESIP_EXPORT void belle_generic_uri_remove_port(belle_generic_uri_t* uri) ;
/**
* Set the host part of this uri to the newly supplied host parameter.
*
*/
BELLESIP_EXPORT void belle_generic_uri_set_host(belle_generic_uri_t* uri,const char*host) ;
/**
* Set the port part of this uri to the newly supplied port parameter.
*
*/
BELLESIP_EXPORT void belle_generic_uri_set_port(belle_generic_uri_t* uri, int port) ;
/**
* Sets the scheme of this URI .
*
*/
BELLESIP_EXPORT void belle_generic_uri_set_scheme(belle_generic_uri_t* uri,const char* scheme) ;
/**
* Sets the path of this URI .
*
*/
BELLESIP_EXPORT void belle_generic_uri_set_path(belle_generic_uri_t* uri,const char* scheme) ;
/**
* Sets the query of this URI .
*
*/
BELLESIP_EXPORT void belle_generic_uri_set_query(belle_generic_uri_t* uri,const char* scheme) ;
/**
* Sets the user of uri.
*
*/
BELLESIP_EXPORT void belle_generic_uri_set_user(belle_generic_uri_t* uri,const char*user) ;
/**
* Sets the user password associated with the user of uri.
*
*/
BELLESIP_EXPORT void belle_generic_uri_set_user_password(belle_generic_uri_t* uri,const char*userPassword) ;
/**
* This method returns the URI as a string.
*
*/
BELLESIP_EXPORT char* belle_generic_uri_to_string(belle_generic_uri_t* uri) ;
#define BELLE_GENERIC_URI(obj) BELLE_SIP_CAST(obj,belle_generic_uri_t)
BELLE_SIP_END_DECLS
#endif /* belle_generic_uri_H_ */
......@@ -20,7 +20,7 @@
#define HEADERS_H_
#include "belle-sip/defs.h"
#include "belle-sip/uri.h"
#include "belle-sip/sip-uri.h"
#include "belle-sip/utils.h"
#include <time.h>
......
/*
* SipUri.h
*
* Created on: 18 sept. 2010
* Author: jehanmonnier
*/
belle-sip - SIP (RFC3261) library.
Copyright (C) 2013 Belledonne Communications SARL, Grenoble, France
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BELLE_SIP_URI_H_
#define BELLE_SIP_URI_H_
......
grammar_files= \
$(srcdir)/belle_sip_message.g \
$(srcdir)/belle_sdp.g
generated_src= \
belle_sip_messageParser.c belle_sip_messageParser.h \
belle_sip_messageLexer.c belle_sip_messageLexer.h \
belle_sdpParser.c belle_sdpParser.h \
belle_sdpLexer.c belle_sdpLexer.h
belle_sdpLexer.c belle_sdpLexer.h \
belle_http_messageParser.c belle_http_messageParser.h \
belle_http_messageLexer.c belle_http_messageLexer.h
.NOTPARALLEL $(builddir)/belle_sip_messageLexer.c \
$(builddir)/belle_sip_messageParser.c\
$(builddir)/belle_sip_messageLexer.h \
$(builddir)/belle_sip_messageParser.h : $(srcdir)/belle_sip_message.g
$(ANTLR) -make -fo $(builddir) $<
.NOTPARALLEL $(builddir)/belle_sdpLexer.c \
$(builddir)/belle_sdpParser.c \
$(builddir)/belle_sdpLexer.h \
$(builddir)/belle_sdpParser.h : $(srcdir)/belle_sdp.g
$(ANTLR) -make -fo $(builddir) $<
.NOTPARALLEL $(builddir)/belle_http_messageLexer.c \
$(builddir)/belle_http_messageParser.c \
$(builddir)/belle_http_messageLexer.h \
$(builddir)/belle_http_messageParser.h: $(srcdir)/belle_http_message.g
$(ANTLR) -make -fo $(builddir) $<
$(builddir)/generated_src_stamp : $(grammar_files)
$(ANTLR) -make -fo $(builddir) $(grammar_files)
touch $(builddir)/generated_src_stamp
$(generated_src) : $(builddir)/generated_src_stamp
BUILT_SOURCES=$(generated_src)
......@@ -64,6 +77,7 @@ libbellesip_la_SOURCES= \
refresher.c \
dns.c dns.h \
belle_sip_dict.c \
generic-uri.c \
http-provider.c \
http-message.c
......
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2013 Belledonne Communications SARL, Grenoble, France
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
grammar belle_http_message;
options {
language = C;
}
@lexer::header {
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2013 Belledonne Communications SARL, Grenoble, France
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wunused"
}
@parser::header {
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wunused"
}
@includes {
#include "belle-sip/belle-sip.h"
#include "belle_sip_internal.h"
}
@rulecatch
{
if (HASEXCEPTION())
{
// This is ugly. We set the exception type to ANTLR3_RECOGNITION_EXCEPTION so we can always
// catch them.
//PREPORTERROR();
EXCEPTION->type = ANTLR3_RECOGNITION_EXCEPTION;
}
}
/*
absoluteURI = scheme ":" ( hier_part | opaque_part )
hier_part = ( net_path | abs_path ) [ "?" query ]
net_path = "//" authority [ abs_path ]
abs_path = "/" path_segments
*/
scheme: alpha ( alpha | DIGIT | '+' | '-' | '.' )*;
uri returns [belle_generic_uri_t* ret=NULL]
scope { belle_generic_uri_t* current; }
@init { $uri::current = $ret = belle_generic_uri_new(); }
: scheme {belle_generic_uri_set_scheme($uri::current,(const char*)$scheme.text->chars);} COLON hier_part[$uri::current] ;
catch [ANTLR3_MISMATCHED_TOKEN_EXCEPTION]
{
belle_sip_message("[\%s] reason [\%s]",(const char*)EXCEPTION->name,(const char*)EXCEPTION->message);
belle_sip_object_unref($uri::current);
$ret=NULL;
}
hier_part[belle_generic_uri_t* uri] returns [belle_generic_uri_t* ret=NULL]
: (
(SLASH SLASH)=>( SLASH SLASH authority[uri] (SLASH path_segments[uri])?)
|
(SLASH)=>SLASH path_segments[uri] )
('?' query
{
char* unescaped_query;
unescaped_query=belle_sip_to_unescaped_string((const char *)$query.text->chars);
belle_generic_uri_set_query(uri,(const char*)unescaped_query);
belle_sip_free(unescaped_query);
}) ?;
path_segments[belle_generic_uri_t* uri]
: (segment ( SLASH segment )*)
{
char* unescaped_path;
unescaped_path=belle_sip_to_unescaped_string((const char *)$path_segments.text->chars);
belle_generic_uri_set_path(uri,(const char*)unescaped_path);
belle_sip_free(unescaped_path);
};
segment: pchar* ( SEMI param )*;
param: pchar*;
pchar: unreserved | escaped | COLON | '@' | '&' | EQUAL | '+' | '$' | COMMA;
query: uric+;
uric: reserved | unreserved | escaped;
authority[belle_generic_uri_t* uri]
: (
(userinfo[NULL])=>(userinfo[uri] hostport[uri])
| hostport[uri] );
userinfo[belle_generic_uri_t* uri]
scope { belle_generic_uri_t* current; }
@init {$userinfo::current=uri;}
: user ( COLON password )? '@' ;
user : ( unreserved | escaped | user_unreserved )+ {
char* unescaped_username;
unescaped_username=belle_sip_to_unescaped_string((const char *)$text->chars);
belle_generic_uri_set_user($userinfo::current,unescaped_username);
belle_sip_free(unescaped_username);
};
user_unreserved : '&' | EQUAL | '+' | '$' | COMMA | SEMI | '?' | SLASH;
password : ( unreserved | escaped |'&' | EQUAL | '+' | '$' | COMMA )* {
char* unescaped_userpasswd;
unescaped_userpasswd=belle_sip_to_unescaped_string((const char *)$text->chars);
belle_generic_uri_set_user_password($userinfo::current,unescaped_userpasswd);
belle_sip_free(unescaped_userpasswd);
};
hostport[belle_generic_uri_t* uri]
scope { belle_generic_uri_t* current; }
@init {$hostport::current=uri;}
: host ( COLON port {belle_generic_uri_set_port($hostport::current,$port.ret);})? {belle_generic_uri_set_host($hostport::current,$host.ret);};
host returns [const char* ret]
scope { const char* current; }
@init {$host::current=$ret=NULL;}
: (hostname {$host::current=(const char *)$hostname.text->chars;}
| ipv4address {$host::current=(const char *)$ipv4address.text->chars;}
| ipv6reference ) {$ret=$host::current;};
hostname : ( domainlabel '.' )* toplabel '.'? ;
domainlabel : alphanum | (alphanum ( alphanum | '-' )* alphanum) ;
toplabel : alpha | (alpha ( '-'? alphanum)+) ;
ipv4address : three_digit '.' three_digit '.' three_digit '.' three_digit ;
ipv6reference : '[' ipv6address ']'{$host::current=(const char *)$ipv6address.text->chars;};
ipv6address : hexpart ( COLON ipv4address )? ;
hexpart : hexseq | hexseq '::' ( hexseq )? | '::' ( hexseq )?;
hexseq : hex4 ( COLON hex4)*;
hex4 : hexdigit+;/* hexdigit hexdigit hexdigit ;*/
port returns [int ret]: DIGIT+ { $ret=atoi((const char *)$text->chars); };
escaped : '%' hexdigit hexdigit;
ttl : three_digit;
three_digit: (DIGIT) => DIGIT
|
(DIGIT DIGIT) => (DIGIT DIGIT)
|
(DIGIT DIGIT DIGIT) =>(DIGIT DIGIT DIGIT) ;
token
: (alphanum | mark | '%' | PLUS | '`' )+;
reserved
: SEMI | SLASH | '?' | COLON | '@' | '&' | EQUAL | PLUS
| '$' | COMMA;
unreserved : alphanum |mark;
alphanum : alpha | DIGIT ;
hexdigit
: HEX_CHAR|DIGIT;
alpha : HEX_CHAR | COMMON_CHAR;
word
: (alphanum | mark | '%'
| PLUS | '`' |
LAQUOT | RAQUOT |
COLON | '\\' | DQUOTE | SLASH | '[' | ']' | '?' | '{' | '}' )+;
COMMON_CHAR
: 'g'..'z' | 'G'..'Z' ;
mark : '-' | '_' | '.' | '!' | '~' | STAR | '\'' | LPAREN | RPAREN ;
HEX_CHAR: 'a'..'f' |'A'..'F';
DIGIT : '0'..'9' ;
CRLF : '\r\n' { USER1 = (int)((char*)ctx->pLexer->input->currentLine - (char*)ctx->pLexer->input->data); /*GETCHARINDEX()*/;};
hcolon : ( LWS | HTAB )* COLON LWS? //SWS;
;//|( SP | HTAB )* COLON LWS+;
HTAB : ' ';
ldquot : LWS? DQUOTE ;
rdquot : DQUOTE LWS?;
DQUOTE : '"';
// open double quotation mark
//SWS : LWS? ;
LWS : (SP* CRLF)? SP+ ; //linear whitespace
PLUS: '+';
COLON
: ':'
;
semi: LWS? SEMI LWS?;
SEMI
: ';'
;
comma : LWS? COMMA LWS?;
COMMA
: ','
;
sp_laquot_sp
: LWS? LAQUOT LWS?;
sp_raquot_sp
: LWS? RAQUOT LWS?;
LAQUOT
: '<'
;
RAQUOT
: '>'
;
RPAREN
: ')'
;
LPAREN
: '('
;
equal:
LWS? EQUAL LWS?;
EQUAL
: '='
;
slash : LWS? SLASH LWS?;
SLASH
: '/'
;
STAR
: '*'
;
fragment
SP
: ' '
;
OCTET : . ;
......@@ -23,7 +23,7 @@ options {
output=AST;
}
@header {
@lexer::header {
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
......@@ -41,6 +41,32 @@ options {
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wunused"
}
@parser::header {
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wunused"
}
@includes {
#include "belle-sip/belle-sdp.h"
......
......@@ -195,6 +195,7 @@ BELLE_SIP_DECLARE_VPTR(belle_http_provider_t);
BELLE_SIP_DECLARE_VPTR(belle_http_channel_context_t);
BELLE_SIP_DECLARE_VPTR(belle_http_request_t);
BELLE_SIP_DECLARE_VPTR(belle_http_response_t);
BELLE_SIP_DECLARE_VPTR(belle_generic_uri_t);
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(belle_sip_resolver_context_t,belle_sip_source_t)
void (*cancel)(belle_sip_resolver_context_t *);
......@@ -377,17 +378,17 @@ antlr3NewAsciiStringCopyStream((pANTLR3_UINT8)value,(ANTLR3_UINT32)length,NULL)
#endif /*HAVE_ANTLR_STRING_STREAM_NEW*/
#define BELLE_SIP_PARSE(object_type) \
belle_sip_##object_type##_t* belle_sip_##object_type##_parse (const char* value) { \
#define BELLE_PARSE(parser_name, object_type_prefix, object_type) \
object_type_prefix##object_type##_t* object_type_prefix##object_type##_parse (const char* value) { \
pANTLR3_INPUT_STREAM input; \
pbelle_sip_messageLexer lex; \
p##parser_name##Lexer lex; \
pANTLR3_COMMON_TOKEN_STREAM tokens; \
pbelle_sip_messageParser parser; \
belle_sip_##object_type##_t* l_parsed_object; \
p##parser_name##Parser parser; \
object_type_prefix##object_type##_t* l_parsed_object; \
input = ANTLR_STREAM_NEW(object_type,value,strlen(value));\
lex = belle_sip_messageLexerNew (input);\
lex = parser_name##LexerNew (input);\
tokens = antlr3CommonTokenStreamSourceNew (ANTLR3_SIZE_HINT, TOKENSOURCE(lex));\
parser = belle_sip_messageParserNew (tokens);\
parser = parser_name##ParserNew (tokens);\
l_parsed_object = parser->object_type(parser);\
parser ->free(parser);\
tokens ->free(tokens);\
......@@ -396,21 +397,23 @@ belle_sip_##object_type##_t* belle_sip_##object_type##_parse (const char* value)
if (l_parsed_object == NULL) belle_sip_error(#object_type" parser error for [%s]",value);\
return l_parsed_object;\
}
#define BELLE_SIP_NEW(object_type,super_type) \
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(belle_sip_##object_type##_t); \
BELLE_SIP_INSTANCIATE_VPTR( belle_sip_##object_type##_t\
, belle_sip_##super_type##_t\
, belle_sip_##object_type##_destroy\
, belle_sip_##object_type##_clone\
, belle_sip_##object_type##_marshal, TRUE); \
belle_sip_##object_type##_t* belle_sip_##object_type##_new () { \
belle_sip_##object_type##_t* l_object = belle_sip_object_new(belle_sip_##object_type##_t);\
belle_sip_##super_type##_init((belle_sip_##super_type##_t*)l_object); \
belle_sip_##object_type##_init((belle_sip_##object_type##_t*) l_object); \
#define BELLE_SIP_PARSE(object_type) BELLE_PARSE(belle_sip_message,belle_sip_,object_type)
#define BELLE_NEW(object_type,super_type) \
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(object_type##_t); \
BELLE_SIP_INSTANCIATE_VPTR( object_type##_t\
, super_type##_t\
, object_type##_destroy\
, object_type##_clone\
, object_type##_marshal, TRUE); \
object_type##_t* object_type##_new () { \
object_type##_t* l_object = belle_sip_object_new(object_type##_t);\
super_type##_init((super_type##_t*)l_object); \
object_type##_init((object_type##_t*) l_object); \
return l_object;\
}
#define BELLE_SIP_NEW(object_type,super_type) BELLE_NEW (belle_sip_##object_type, belle_sip_##super_type)
#define BELLE_SIP_NEW_HEADER(object_type,super_type,name) BELLE_SIP_NEW_HEADER_INIT(object_type,super_type,name,header)
#define BELLE_SIP_NEW_HEADER_INIT(object_type,super_type,name,init_type) \
......@@ -917,6 +920,10 @@ BELLESIP_INTERNAL_EXPORT char* belle_sip_uri_to_escaped_parameter(const char* bu
BELLESIP_INTERNAL_EXPORT char* belle_sip_uri_to_escaped_header(const char* buff) ;
BELLESIP_INTERNAL_EXPORT char* belle_sip_to_unescaped_string(const char* buff) ;
/*(uri RFC 2396)*/
BELLESIP_INTERNAL_EXPORT char* belle_generic_uri_to_escaped_query(const char* buff);
BELLESIP_INTERNAL_EXPORT char* belle_generic_uri_to_escaped_path(const char* buff);
#define BELLE_SIP_SOCKET_TIMEOUT 30000
......
This diff is collapsed.
......@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "belle-sip/uri.h"
#include "belle-sip/sip-uri.h"
#include "belle-sip/parameters.h"
#include <stdlib.h>
#include <string.h>
......
......@@ -825,7 +825,7 @@ static void print_noescapes_map(char noescapes[BELLE_SIP_NO_ESCAPES_SIZE], const
}
*/
static const char *get_uri_username_noescapes() {
static const char *get_sip_uri_username_noescapes() {
static char noescapes[BELLE_SIP_NO_ESCAPES_SIZE] = {0};
if (noescapes[BELLE_SIP_NO_ESCAPES_SIZE-1] == 0) {
// concurrent initialization should not be an issue
......@@ -841,7 +841,7 @@ static const char *get_uri_username_noescapes() {
* password = *( unreserved / escaped /
"&" / "=" / "+" / "$" / "," )
* */
static const char *get_uri_userpasswd_noescapes() {
static const char *get_sip_uri_userpasswd_noescapes() {
static char noescapes[BELLE_SIP_NO_ESCAPES_SIZE] = {0};
if (noescapes[BELLE_SIP_NO_ESCAPES_SIZE-1] == 0) {
// unreserved
......@@ -855,7 +855,7 @@ static const char *get_uri_userpasswd_noescapes() {
return noescapes;
}
static const char *get_uri_parameter_noescapes() {
static const char *get_sip_uri_parameter_noescapes() {
static char noescapes[BELLE_SIP_NO_ESCAPES_SIZE] = {0};
if (noescapes[BELLE_SIP_NO_ESCAPES_SIZE-1] == 0) {
/*
......@@ -887,7 +887,7 @@ static const char *get_uri_parameter_noescapes() {
}
return noescapes;
}
static const char *get_uri_header_noescapes() {
static const char *get_sip_uri_header_noescapes() {
static char noescapes[BELLE_SIP_NO_ESCAPES_SIZE] = {0};
if (noescapes[BELLE_SIP_NO_ESCAPES_SIZE-1] == 0) {
/*
......@@ -936,14 +936,91 @@ static char* belle_sip_escape(const char* buff, const char *noescapes) {
}
char* belle_sip_uri_to_escaped_username(const char* buff) {
return belle_sip_escape(buff, get_uri_username_noescapes());
return belle_sip_escape(buff, get_sip_uri_username_noescapes());
}
char* belle_sip_uri_to_escaped_userpasswd(const char* buff) {
return belle_sip_escape(buff, get_uri_userpasswd_noescapes());
return belle_sip_escape(buff, get_sip_uri_userpasswd_noescapes());
}
char* belle_sip_uri_to_escaped_parameter(const char* buff) {
return belle_sip_escape(buff, get_uri_parameter_noescapes());
return belle_sip_escape(buff, get_sip_uri_parameter_noescapes());
}
char* belle_sip_uri_to_escaped_header(const char* buff) {
return belle_sip_escape(buff, get_uri_header_noescapes());