aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_phone.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-06 07:01:37 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-06 07:01:37 +0000
commit7869a07656d61e478e5f859eaf0700aaf16e041c (patch)
treead17a2ce908daafa65d832bd01e4152df0933007 /channels/chan_phone.c
parent2b5f4ac80d2deae8a8999233d2d7161c28effa81 (diff)
Try to parse callerid properly on /dev/phone (bug #1788)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3154 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_phone.c')
-rwxr-xr-xchannels/chan_phone.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 54e31c24b..0f5ecfc20 100755
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -23,6 +23,7 @@
#include <asterisk/pbx.h>
#include <asterisk/options.h>
#include <asterisk/utils.h>
+#include <asterisk/callerid.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <errno.h>
@@ -156,7 +157,6 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout)
PHONE_CID cid;
time_t UtcTime;
struct tm tm;
- char *s;
/* display caller id if present */
if (ast->callerid) {
@@ -170,14 +170,23 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout)
sprintf(cid.min, "%02d", tm.tm_min);
}
/* the format of ast->callerid is always: "name" <number> */
- if(ast_strlen_zero(ast->callerid)){
+ if(!ast->callerid || ast_strlen_zero(ast->callerid)){
strcpy(cid.name,DEFAULT_CALLER_ID);
cid.number[0]='\0';
} else {
- s=strncpy(cid.name,ast->callerid+1,sizeof(cid.name));
- (void)strsep(&s,"\"");
- s=strncpy(cid.number,strrchr(ast->callerid,'<')+1,sizeof(cid.number));
- (void)strsep(&s,">");
+ char *n, *l;
+ char callerid[256] = "";
+ strncpy(callerid, ast->callerid, sizeof(callerid) - 1);
+ ast_callerid_parse(ast->callerid, &n, &l);
+ if (l) {
+ ast_shrink_phone_number(l);
+ if (!ast_isphonenumber(l))
+ l = NULL;
+ }
+ if (l)
+ strncpy(cid.number, l, sizeof(cid.number) - 1);
+ if (n)
+ strncpy(cid.name, n, sizeof(cid.name) - 1);
}
}