Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
501c5ce4
Commit
501c5ce4
authored
Nov 23, 2012
by
jehan
Browse files
add function to extract ccc from e164 number
parent
96dc7aac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
2 deletions
+42
-2
coreapi/linphonecore_utils.h
coreapi/linphonecore_utils.h
+8
-2
coreapi/proxy.c
coreapi/proxy.c
+26
-0
coreapi/test_numbers.c
coreapi/test_numbers.c
+8
-0
No files found.
coreapi/linphonecore_utils.h
View file @
501c5ce4
...
...
@@ -94,8 +94,14 @@ void linphone_core_remove_iterate_hook(LinphoneCore *lc, LinphoneCoreIterateHook
*@return call country code or -1 if not found
*/
int
linphone_dial_plan_lookup_ccc_from_iso
(
const
char
*
iso
);
/**
* @ingroup misc
*Function to get call country code from an e164 number, ex: +33952650121 will return 33
*@param e164 phone number
*@return call country code or -1 if not found
*/
int
linphone_dial_plan_lookup_ccc_from_e164
(
const
char
*
e164
);
#ifdef __cplusplus
}
#endif
...
...
coreapi/proxy.c
View file @
501c5ce4
...
...
@@ -607,6 +607,32 @@ static dial_plan_t const dial_plans[]={
};
static
dial_plan_t
most_common_dialplan
=
{
"generic"
,
""
,
""
,
10
,
"00"
};
int
linphone_dial_plan_lookup_ccc_from_e164
(
const
char
*
e164
)
{
dial_plan_t
*
dial_plan
;
dial_plan_t
*
elected_dial_plan
=
NULL
;
unsigned
int
found
;
unsigned
int
i
=
0
;
if
(
e164
[
1
]
==
'1'
)
{
/*USA case*/
return
1
;
}
do
{
found
=
0
;
i
++
;
for
(
dial_plan
=
(
dial_plan_t
*
)
dial_plans
;
dial_plan
->
country
!=
NULL
;
dial_plan
++
)
{
if
(
strncmp
(
dial_plan
->
ccc
,
&
e164
[
1
],
i
)
==
0
)
{
elected_dial_plan
=
dial_plan
;
found
++
;
}
}
}
while
(
found
>
1
||
found
==
0
);
if
(
found
==
1
)
{
return
atoi
(
elected_dial_plan
->
ccc
);
}
else
{
return
-
1
;
/*not found */
}
}
int
linphone_dial_plan_lookup_ccc_from_iso
(
const
char
*
iso
)
{
dial_plan_t
*
dial_plan
;
for
(
dial_plan
=
(
dial_plan_t
*
)
dial_plans
;
dial_plan
->
country
!=
NULL
;
dial_plan
++
)
{
...
...
coreapi/test_numbers.c
View file @
501c5ce4
...
...
@@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "linphonecore.h"
#include "linphonecore_utils.h"
int
main
(
int
argc
,
char
*
argv
[]){
LinphoneProxyConfig
*
cfg
;
...
...
@@ -35,6 +36,13 @@ int main(int argc , char *argv[]){
if
(
argc
>
3
&&
strcmp
(
argv
[
3
],
"--escape-plus"
)
==
0
)
linphone_proxy_config_set_dial_escape_plus
(
cfg
,
TRUE
);
linphone_proxy_config_normalize_number
(
cfg
,
argv
[
1
],
normalized_number
,
sizeof
(
normalized_number
));
printf
(
"Normalized number is %s
\n
"
,
normalized_number
);
/*check extracted ccc*/
if
(
linphone_dial_plan_lookup_ccc_from_e164
(
normalized_number
)
!=
atoi
(
linphone_proxy_config_get_dial_prefix
(
cfg
)))
{
printf
(
"Error ccc [%i] not correctly parsed
\n
"
,
linphone_dial_plan_lookup_ccc_from_e164
(
normalized_number
));
}
else
{
printf
(
"Extracted ccc is [%i]
\n
"
,
linphone_dial_plan_lookup_ccc_from_e164
(
normalized_number
));
}
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment