aboutsummaryrefslogtreecommitdiffstats
path: root/callerid.c
diff options
context:
space:
mode:
authoroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-30 04:16:38 +0000
committeroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-30 04:16:38 +0000
commita9a990c34439999f57a0993ddf1b81c8501bae91 (patch)
treeac13fdc97eba41953e221550011bf44b2e0cf4fe /callerid.c
parentc10fca18f2a1aab415df2cd4af54f5ed64b49970 (diff)
Issue #6450 - Don't remove characters from SIP uri's when not needed
Patch by jcomellas, heavily modified by oej git-svn-id: http://svn.digium.com/svn/asterisk/trunk@16425 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'callerid.c')
-rw-r--r--callerid.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/callerid.c b/callerid.c
index 68b42f8d4..58891d0fa 100644
--- a/callerid.c
+++ b/callerid.c
@@ -905,21 +905,42 @@ void ast_shrink_phone_number(char *n)
n[y] = '\0';
}
-/*! \brief checks if string consists only of digits and * \# and +
- \return 1 if string is valid AST phone number
- \return 0 if not
+/*! \brief Checks if phone number consists of valid characters
+ \param exten String that needs to be checked
+ \param valid Valid characters in string
+ \return 1 if valid string, 0 if string contains invalid characters
*/
-int ast_isphonenumber(char *n)
+static int ast_is_valid_string(const char *exten, const char *valid)
{
int x;
- if (ast_strlen_zero(n))
+
+ if (ast_strlen_zero(exten))
return 0;
- for (x=0;n[x];x++)
- if (!strchr("0123456789*#+", n[x]))
+ for (x=0; exten[x]; x++)
+ if (!strchr(valid, exten[x]))
return 0;
return 1;
}
+/*! \brief checks if string consists only of digits and * \# and +
+ \return 1 if string is valid AST phone number
+ \return 0 if not
+*/
+int ast_isphonenumber(const char *n)
+{
+ return ast_is_valid_string(n, "0123456789*#+");
+}
+
+/*! \brief checks if string consists only of digits and ( ) - * \# and +
+ Pre-qualifies the string for ast_shrink_phone_number()
+ \return 1 if string is valid AST shrinkable phone number
+ \return 0 if not
+*/
+int ast_is_shrinkable_phonenumber(const char *exten)
+{
+ return ast_is_valid_string(exten, "0123456789*#+()-.");
+}
+
/*! \brief parse string for caller id information
\return always returns 0, as the code always returns something.
XXX note that 'name' is not parsed consistently e.g. we have