From a14fa22cf675d8193d90714548b17851accd0102 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 8 Jan 2015 11:51:07 +0100 Subject: [PATCH] Add linphone_proxy_config_is_phone_number in public API --- coreapi/linphonecore.h | 9 +++++++++ coreapi/proxy.c | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 225b05209..40b8724eb 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1040,6 +1040,15 @@ LINPHONE_PUBLIC void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg); LINPHONE_PUBLIC void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type); SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg); LINPHONE_PUBLIC SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg); + +/** + * Detect if the given input is a phone number or not. + * @param proxy #LinphoneProxyConfig argument, unused yet but may contain useful data. Can be NULL. + * @param username string to parse. + * @return TRUE if input is a phone number, FALSE otherwise. +**/ +LINPHONE_PUBLIC bool_t linphone_proxy_config_is_phone_number(LinphoneProxyConfig *proxy, const char *username); + /** * Normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222 * or +33888444222 depending on the #LinphoneProxyConfig argument. This function will always diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 1907ad3da..beed88ce3 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -879,7 +879,7 @@ static void lookup_dial_plan(const char *ccc, dial_plan_t *plan){ strcpy(plan->ccc,ccc); } -static bool_t is_a_phone_number(const char *username){ +bool_t linphone_proxy_config_is_phone_number(LinphoneProxyConfig *proxy, const char *username){ const char *p; for(p=username;*p!='\0';++p){ if (isdigit(*p) || @@ -928,7 +928,7 @@ static void replace_plus(const char *src, char *dest, size_t destlen, const char bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, char *result, size_t result_len){ - if (is_a_phone_number(username)){ + if (linphone_proxy_config_is_phone_number(proxy, username)){ char *flatten; flatten=flatten_number(username); ms_debug("Flattened number is '%s'",flatten);