[Home]

Summary:ASTERISK-04250: [patch] >Parses country code from a dial string (Useful for billing)
Reporter:Vikram Rangnekar (vr)Labels:
Date Opened:2005-05-21 01:30:09Date Closed:2011-06-07 14:04:52
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Applications/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) app_getcc.c
( 1) func_countrycode.c
Description:GetCC(varname=${EXTEN}): Seta a variable to the country code portion of the extension Calculates what portion of a digit string is the country code using
known country code length patterns used throughout the world. Can
analyze number without a database hit
The input 'pattern' to the routine MUST NOT contain the leading
International Access digits for the country you are in.  

(EXAMPLE:  Do not have the leading '011' if in the US, or '00/01' in other countries)

watch how the routine, when given something like 52583839337737 will find
and spit back 52 as the country code


****** ADDITIONAL INFORMATION ******

Pretty much everything (The algorithm implementation) was taken from
http://lists.digium.com/pipermail/asterisk-dev/2004-May/004151.html
Rob Gagnon's post. I just made it an asterisk module.

Example of the module's usage:

exten=>_3.,1,Answer()
exten=>_3.,2,GetCC(countrycode=${EXTEN:1})
exten=>_3.,3,SayDigits(${countrycode})
exten=>_3.,4,Hangup()
Comments:By: Olle Johansson (oej) 2005-05-21 02:58:52

Thank you, I think this is a great feature!

However, please read bug and coding guidelines.
* You need to mention that you have a disclaimer on file for new code to be added to CVS.
* Also, since this new feature does not affect the channel, it should be coded as a dial plan function instead of an application.
* The if lines should be two line, not one line according to code guidelines
* Error messages should not be LOG_DEBUG
* You should not have long sequences of code after an "if" then do an else with a oneline error. Negate the if and return the error, then continue the code.

The formatting issues is quick to fix. To convert it into a function is a bit more job, but still not too complicated. Looking forward to that code!

/Olle

By: Vikram Rangnekar (vr) 2005-05-21 06:46:56

all requested changes done :)

Will fax the disclaimer in today.

By: Michael Jerris (mikej) 2005-05-21 08:24:50

Is only the latest file needed?

By: Vikram Rangnekar (vr) 2005-05-21 14:25:27

app_getcc.c works with CVS STABLE

func_countrycode-LATEST.c works with CVS HEAD.

By: Kevin P. Fleming (kpfleming) 2005-05-21 14:41:17

Code review notes:

1) You are including excess header files (astdb.h, for one, there may be others).

2) There is no need to ast_strdrup() the string if you are not going to modify it.

3) You are not passing the length of the buffer into the findCCodeInPatt function, so it could conceivably overrun the buffer.

4) Please do not set the CC_RESULT variable, the function will return its result. Update the help text accordingly.

By: Vikram Rangnekar (vr) 2005-05-23 01:14:17

Please delete 'func_countrycode-LATEST.c' (Why am I not allowed to do that?)

To test out the countrycode dialplan function code.

exten=>_3.,1,Answer;
exten=>_3.,2,SayDigits(${COUNTRYCODE(${EXTEN:1})});
exten=>_3.,3,Hangup

By: drmac (drmac) 2005-05-23 09:51:57

I posted the CC algorthim on that email referenced above to the -users list a few months ago and I got several notices from others claiming that it didn't return the proper CC's in all cases. They gave specific examples but I don't have the reply's anymore. Just something to think about..

By: Vikram Rangnekar (vr) 2005-05-23 11:41:14

Maybe we should float that algo. on the list again to see if the algo. is completely wrong or just wrongly implemented. I found that algo on the list too and after trying it for phone numbers from many countries I found it to be working quite well so I made the patch. But maybe the numbering convention is changed or in few cases just not followed. I'd luv to see some telco documentation about this.

By: Vikram Rangnekar (vr) 2005-05-23 23:23:04

disclaimer on file.

By: Michael Jerris (mikej) 2005-06-23 15:04:50

suspended due to lack of response about the algorithm, if we can verify if that is correct, please re-open so we can get this commited.  Thanks!