Commit 37ccabae authored by jehan's avatar jehan
Browse files

add cunit test

renable belle_sip
parent 132430e2
......@@ -30,9 +30,12 @@
<tool id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.debug.1932492077" name="MacOS X C++ Linker" superClass="cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.debug">
<option id="macosx.cpp.link.option.paths.194605718" name="Library search path (-L)" superClass="macosx.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="/Users/jehanmonnier/opt/lib"/>
<listOptionValue builtIn="false" value="/opt/local/lib"/>
</option>
<option id="macosx.cpp.link.option.libs.704032711" name="Libraries (-l)" superClass="macosx.cpp.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="antlr3c"/>
<listOptionValue builtIn="false" value="cunit"/>
<listOptionValue builtIn="false" value="ncurses"/>
</option>
<inputType id="cdt.managedbuild.tool.macosx.cpp.linker.input.1803560595" superClass="cdt.managedbuild.tool.macosx.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
......@@ -57,18 +60,26 @@
<option id="gnu.c.compiler.macosx.exe.debug.option.debugging.level.989062315" name="Debug Level" superClass="gnu.c.compiler.macosx.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.1528555998" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/Users/jehanmonnier/opt/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/belle-sip/include}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1688341083" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
</toolChain>
</folderInfo>
<fileInfo id="cdt.managedbuild.config.gnu.macosx.exe.debug.341835025.1534608110" name="parser-antlr.c" rcbsApplicability="disable" resourcePath="src/parser-antlr.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201.1123722163">
<tool id="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201.1123722163" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201">
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.10332711" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
<fileInfo id="cdt.managedbuild.config.gnu.macosx.exe.debug.341835025.789517118" name="parser-antlr.c" rcbsApplicability="disable" resourcePath="tester/belle_sip_uri_tester.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201.75619886">
<tool id="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201.75619886" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201">
<option id="gnu.c.compiler.option.include.paths.246079056" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/Users/jehanmonnier/opt/include"/>
<listOptionValue builtIn="false" value="/opt/local/include"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/belle-sip/include}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.170614653" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
</fileInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="tester"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="include"/>
</sourceEntries>
</configuration>
</storageModule>
......@@ -162,6 +173,89 @@
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.macosx.exe.debug.341835025;cdt.managedbuild.config.gnu.macosx.exe.debug.341835025.789517118;cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201.75619886;cdt.managedbuild.tool.gnu.c.compiler.input.170614653">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="makefileGenerator">
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.macosx.exe.debug.341835025;cdt.managedbuild.config.gnu.macosx.exe.debug.341835025.;cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.debug.908444505;cdt.managedbuild.tool.gnu.cpp.compiler.input.797856581">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
......@@ -622,6 +716,8 @@
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="include"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="tester"/>
</sourceEntries>
</configuration>
</storageModule>
......@@ -715,6 +811,89 @@
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.macosx.exe.debug.341835025;cdt.managedbuild.config.gnu.macosx.exe.debug.341835025.789517118;cdt.managedbuild.tool.gnu.c.compiler.macosx.exe.debug.315151201.75619886;cdt.managedbuild.tool.gnu.c.compiler.input.170614653">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="makefileGenerator">
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.macosx.exe.debug.341835025;cdt.managedbuild.config.gnu.macosx.exe.debug.341835025.;cdt.managedbuild.tool.gnu.cpp.compiler.macosx.exe.debug.908444505;cdt.managedbuild.tool.gnu.cpp.compiler.input.797856581">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
......
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>parser-antlr</name>
<name>belle-sip</name>
<comment></comment>
<projects>
</projects>
......
......@@ -5,155 +5,155 @@
* Author: jehanmonnier
*/
#ifndef SIPURI_H_
#define SIPURI_H_
#ifndef BELLE_SIP_URI_H_
#define BELLE_SIP_URI_H_
typedef struct _sip_uri sip_uri;
typedef struct _belle_sip_uri belle_sip_uri;
sip_uri* sip_uri_new();
belle_sip_uri* belle_sip_uri_new();
void sip_uri_delete(sip_uri* uri);
sip_uri* sip_uri_parse (const char* uri) ;
void belle_sip_uri_delete(belle_sip_uri* uri);
belle_sip_uri* belle_sip_uri_parse (const char* uri) ;
/**
* Returns the value of the named header, or null if it is not set.
*
*/
const char* sip_uri_get_header(sip_uri* uri,const char* name);
const char* belle_sip_uri_get_header(belle_sip_uri* uri,const char* name);
/**
* Returns an Iterator over the const char*names of all headers present in this SipURI.
*
*/
/*list<const char*>::iterator sip_uri_get_header_names(SipUri* uri) ;*/
/*list<const char*>::iterator belle_sip_uri_get_header_names(SipUri* uri) ;*/
/**
* Returns the host part of this SipURI.
*
*/
const char* sip_uri_get_host(sip_uri* uri) ;
const char* belle_sip_uri_get_host(belle_sip_uri* uri) ;
/**
* Returns the value of the maddr parameter, or null if this is not set.
*
*/
const char* sip_uri_get_maddr_param(sip_uri* uri) ;
const char* belle_sip_uri_get_maddr_param(belle_sip_uri* uri) ;
/**
* Returns the value of the method parameter, or null if this is not set.
*
*/
const char* sip_uri_get_method_param(sip_uri* uri) ;
const char* belle_sip_uri_get_method_param(belle_sip_uri* uri) ;
/**
* Returns the port part of this SipURI.
*
*/
unsigned short sip_uri_get_port(sip_uri* uri) ;
unsigned int belle_sip_uri_get_port(belle_sip_uri* uri) ;
/**
* Returns the value of the "transport" parameter, or null if this is not set.
*
*/
const char* sip_uri_get_transport_param(sip_uri* uri) ;
const char* belle_sip_uri_get_transport_param(belle_sip_uri* uri) ;
/**
* Returns the value of the "ttl" parameter, or -1 if this is not set.
*
*/
int sip_uri_get_ttl_param(sip_uri* uri) ;
int belle_sip_uri_get_ttl_param(belle_sip_uri* uri) ;
/**
* Returns the user part of this SipURI.
*
*/
const char* sip_uri_get_user(sip_uri* uri) ;
const char* belle_sip_uri_get_user(belle_sip_uri* uri) ;
/**
* Returns the value of the userParam, or null if this is not set.
*
*/
const char* sip_uri_get_user_param(sip_uri* uri) ;
const char* belle_sip_uri_get_user_param(belle_sip_uri* uri) ;
/**
* Gets user password of SipURI, or null if it is not set.
*
*/
const char* sip_uri_get_user_password(sip_uri* uri) ;
const char* belle_sip_uri_get_user_password(belle_sip_uri* uri) ;
/**
* Returns whether the the lr parameter is set.
*
*/
unsigned int sip_uri_has_lr_param(sip_uri* uri) ;
unsigned int belle_sip_uri_has_lr_param(belle_sip_uri* uri) ;
/**
*
* Returns true if this SipURI is secure i.e. if this SipURI represents a sips URI.
*
*/
unsigned int sip_uri_is_secure(sip_uri* uri) ;
unsigned int belle_sip_uri_is_secure(belle_sip_uri* uri) ;
/**
* Removes the port part of this SipURI.
*
*/
void sip_uri_remove_port(sip_uri* uri) ;
void belle_sip_uri_remove_port(belle_sip_uri* uri) ;
/**
* Sets the value of the specified header fields to be included in a request constructed from the URI.
*
*/
void sip_uri_set_header(sip_uri* uri,const char*name, const char*value) ;
void belle_sip_uri_set_header(belle_sip_uri* uri,const char*name, const char*value) ;
/**
* Set the host part of this SipURI to the newly supplied host parameter.
*
*/
void sip_uri_set_host(sip_uri* uri,const char*host) ;
void belle_sip_uri_set_host(belle_sip_uri* uri,const char*host) ;
/**
* Sets the value of the lr parameter of this SipURI.
*
*/
void sip_uri_set_lr_param(sip_uri* uri) ;
void belle_sip_uri_set_lr_param(belle_sip_uri* uri) ;
/**
* Sets the value of the maddr parameter of this SipURI.
*
*/
void sip_uri_set_maddr_param(sip_uri* uri,const char*mAddr) ;
void belle_sip_uri_set_maddr_param(belle_sip_uri* uri,const char*mAddr) ;
/**
* Sets the value of the method parameter.
*
*/
void sip_uri_set_method_param(sip_uri* uri,const char*method) ;
void belle_sip_uri_set_method_param(belle_sip_uri* uri,const char*method) ;
/**
* Set the port part of this SipURI to the newly supplied port parameter.
*
*/
void sip_uri_set_port(sip_uri* uri,unsigned short port) ;
void belle_sip_uri_set_port(belle_sip_uri* uri,unsigned int port) ;
/**
* Sets the scheme of this URI to sip or sips depending on whether the argument is true or false.
*
*/
void sip_uri_set_secure(sip_uri* uri,unsigned secure) ;
void belle_sip_uri_set_secure(belle_sip_uri* uri,unsigned secure) ;
/**
* Sets the value of the "transport" parameter.
*
*/
void sip_uri_set_transport_param(sip_uri* uri,const char*transport) ;
void belle_sip_uri_set_transport_param(belle_sip_uri* uri,const char*transport) ;
/**
* Sets the value of the ttl parameter.
*
*/
void sip_uri_set_ttl_param(sip_uri* uri,int ttl) ;
void belle_sip_uri_set_ttl_param(belle_sip_uri* uri,int ttl) ;
/**
* Sets the user of SipURI.
*
*/
void sip_uri_set_user(sip_uri* uri,const char*user) ;
void belle_sip_uri_set_user(belle_sip_uri* uri,const char*user) ;
/**
* Sets the value of the user parameter.
*
*/
void sip_uri_set_user_param(sip_uri* uri,const char*userParam) ;
void belle_sip_uri_set_user_param(belle_sip_uri* uri,const char*userParam) ;
/**
* Sets the user password associated with the user of SipURI.
*
*/
void sip_uri_set_user_password(sip_uri* uri,const char*userPassword) ;
void belle_sip_uri_set_user_password(belle_sip_uri* uri,const char*userPassword) ;
/**
* This method returns the URI as a string.
*
*/
char* sip_uri_to_string(sip_uri* uri) ;
char* belle_sip_uri_to_string(belle_sip_uri* uri) ;
#endif /*SIPURI_H_*/
#endif /*BELLE_SIP_URI_H_*/
grammar sipuri;
grammar belle_sip_uri;
options { language = C;}
@header { #include "sip_uri.h"}
@header { #include "belle_sip_uri.h"}
an_sip_uri returns [sip_uri* ret]
scope { sip_uri* current; }
@init { $an_sip_uri::current = sip_uri_new(); }
an_sip_uri returns [belle_sip_uri* ret]
scope { belle_sip_uri* current; }
@init { $an_sip_uri::current = belle_sip_uri_new(); }
: 'sip:' userinfo? hostport uri_parameters {$ret = $an_sip_uri::current;};
userinfo : user ( ':' password )? '@' ;
user : ( unreserved | user_unreserved )+ {sip_uri_set_user($an_sip_uri::current,(const char *)$text->chars);};
user : ( unreserved | user_unreserved )+ {belle_sip_uri_set_user($an_sip_uri::current,(const char *)$text->chars);};
user_unreserved : '&' | '=' | '+' | '$' | ',' | ';' | '?' | '/';
password : ( unreserved |'&' | '=' | '+' | '$' | ',' )*;
hostport : host ( ':' port )?;
host : hostname {sip_uri_set_host($an_sip_uri::current,(const char *)$text->chars);};
host : hostname {belle_sip_uri_set_host($an_sip_uri::current,(const char *)$text->chars);};
hostname : ( domainlabel '.' )* toplabel '.'? ;
domainlabel : alphanum | alphanum ( alphanum | '-' )* alphanum ;
toplabel : ALPHA | ALPHA ( alphanum | '-' )* alphanum;
port : DIGIT+ ;
port : DIGIT+ {belle_sip_uri_set_port($an_sip_uri::current,atoi((const char *)$text->chars));};
uri_parameters
......@@ -28,7 +28,7 @@ uri_parameter
transport_param
: 'transport=' transport_value;
transport_value: ('udp' | 'tcp' | 'sctp' | 'tls'| other_transport)
{sip_uri_set_transport_param($an_sip_uri::current,(const char *)$text->chars);};
{belle_sip_uri_set_transport_param($an_sip_uri::current,(const char *)$text->chars);};
other_transport
: token ;
user_param
......
......@@ -5,12 +5,12 @@
* Author: jehanmonnier
*/
#include "sip_uri.h"
#include "belle_sip_uri.h"
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "sipuriParser.h"
#include "sipuriLexer.h"
#include <stdarg.h>
#include "belle_sip_uriParser.h"
#include "belle_sip_uriLexer.h"
#define GET_SET_STRING(object_type,attribute) \
const char* object_type##_get_##attribute (object_type* obj) {\
......@@ -22,42 +22,43 @@
strcpy((char*)(obj->attribute),value);\
}
#define SIP_URI_GET_SET_STRING(attribute) GET_SET_STRING(sip_uri,attribute)
#define SIP_URI_GET_SET_STRING(attribute) GET_SET_STRING(belle_sip_uri,attribute)
#define GET_SET_UINT(object_type,attribute) \
unsigned int* object_type##_get_##attribute (object_type* obj) {\
unsigned int object_type##_get_##attribute (object_type* obj) {\
return obj->attribute;\
}\
void object_type##_set_##attribute (object_type* obj,unsigned int value) {\
obj->attribute=value;\
}
#define SIP_URI_GET_SET_UINT(attribute) GET_SET_UINT(sip_uri,attribute)
#define SIP_URI_GET_SET_UINT(attribute) GET_SET_UINT(belle_sip_uri,attribute)
struct _sip_uri {
struct _belle_sip_uri {
const char* user;
const char* host;
const char* transport_param;
unsigned int port;
};
sip_uri* sip_uri_parse (const char* uri) {
belle_sip_uri* belle_sip_uri_parse (const char* uri) {
pANTLR3_INPUT_STREAM input;
psipuriLexer lex;
pbelle_sip_uriLexer lex;
pANTLR3_COMMON_TOKEN_STREAM tokens;
psipuriParser parser;
pbelle_sip_uriParser parser;
input = antlr3NewAsciiStringCopyStream (
(pANTLR3_UINT8)uri,
(ANTLR3_UINT32)strlen(uri),
NULL);
lex = sipuriLexerNew (input);
lex = belle_sip_uriLexerNew (input);
tokens = antlr3CommonTokenStreamSourceNew (ANTLR3_SIZE_HINT, TOKENSOURCE(lex));
parser = sipuriParserNew (tokens);
parser = belle_sip_uriParserNew (tokens);
sip_uri* l_parsed_uri = parser->an_sip_uri(parser);
belle_sip_uri* l_parsed_uri = parser->an_sip_uri(parser);
// Must manually clean up
//
......@@ -67,12 +68,12 @@ sip_uri* sip_uri_parse (const char* uri) {
input ->close(input);
return l_parsed_uri;
}
sip_uri* sip_uri_new () {
sip_uri* lUri = (sip_uri*)malloc(sizeof(sip_uri));
memset(lUri,0,sizeof(sip_uri));
belle_sip_uri* belle_sip_uri_new () {
belle_sip_uri* lUri = (belle_sip_uri*)malloc(sizeof(belle_sip_uri));
memset(lUri,0,sizeof(belle_sip_uri));
return lUri;
}
void sip_uri_delete(sip_uri* uri) {
void belle_sip_uri_delete(belle_sip_uri* uri) {
free(uri);
}
......@@ -123,7 +124,7 @@ static char * concat (const char *str, ...) {
return result;
}
char* sip_uri_to_string(sip_uri* uri) {
char* belle_sip_uri_to_string(belle_sip_uri* uri) {
return concat( "sip:"
,(uri->user?uri->user:"")
,(uri->user?"@":"")
......@@ -136,4 +137,4 @@ char* sip_uri_to_string(sip_uri* uri) {
SIP_URI_GET_SET_STRING(user)
SIP_URI_GET_SET_STRING(host)
SIP_URI_GET_SET_STRING(transport_param)
SIP_URI_GET_SET_UINT(port)
//============================================================================
// Name : parser-antlr.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include "sip_uri.h"
#include <stdio.h>
int main (int argc, char *argv[]) {
sip_uri* L_uri = sip_uri_parse("sip:toto@titi.com:5060;transport=tcp");
printf(sip_uri_to_string(L_uri));
return 0;
}
//============================================================================
// Name : parser-antlr.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include "belle_sip_uri.h"
#include <stdio.h>
#include "CUnit/Basic.h"
int init_suite1(void) {
return 0;
}
int clean_suite1(void) {
return 0;
}
void testSIMPLEURI(void) {
belle_sip_uri* L_uri = belle_sip_uri_parse("sip:titi.com");
CU_ASSERT_PTR_NULL(belle_sip_uri_get_user(L_uri));
CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_host(L_uri), "titi.com");
CU_ASSERT_PTR_NULL(belle_sip_uri_get_transport_param(L_uri));
}
void testCOMPLEXURI(void) {
belle_sip_uri* L_uri = belle_sip_uri_parse("sip:toto@titi.com:5060;transport=tcp");
CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_user(L_uri), "toto");
CU_ASSERT_EQUAL(belle_sip_uri_get_port(L_uri), 5060);
CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_host(L_uri), "titi.com");
CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_transport_param(L_uri), "tcp");
}