Moved isE164() in common telephony functions.

git-svn-id: http://yate.null.ro/svn/yate/trunk@855 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2006-06-10 17:35:56 +00:00
parent a25466b295
commit beeecfe4ee
3 changed files with 41 additions and 27 deletions

View File

@ -27,6 +27,40 @@
using namespace TelEngine;
// Find if a string appears to be an E164 phone number
bool TelEngine::isE164(const char* str)
{
if (!str)
return false;
// an initial + character is ok, we skip it
if (*str == '+')
str++;
// at least one valid character is required
if (!*str)
return false;
for (;;) {
switch (*str++) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '*':
case '#':
break;
case '\0':
return true;
default:
return false;
}
}
}
static unsigned int s_callid = 0;
static Mutex s_callidMutex;

View File

@ -208,33 +208,6 @@ static const char* CallEndReasonText(int reason)
#undef MAKE_END_REASON
}
static bool isE164(const char* str)
{
if (!(str && *str))
return false;
for (;;) {
switch (*str++) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '*':
case '#':
continue;
case 0:
return true;
default:
return false;
}
}
}
static int cleaningCount()
{
Lock lock(s_mutex);

View File

@ -1921,6 +1921,13 @@ protected:
{ return m_id; }
};
/**
* Find if a string appears to be an E164 phone number
* @param str String to check
* @return True if str appears to be a valid E164 number
*/
YATE_API bool isE164(const char* str);
}; // namespace TelEngine
#endif /* __YATEPHONE_H */