diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-02-26 07:34:09 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-02-26 07:34:09 +0000 |
commit | f82ee2792834df8058f8adaae73b26803f789584 (patch) | |
tree | 84cf0173c7d7ad0e32cae89bb74d08e960a31882 /apps/app_setcallerid.c | |
parent | 94ab7ec60be4cc4005e5324a537726efb36e0f03 (diff) |
Add new callerpres parsing API (bug #3648)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5086 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_setcallerid.c')
-rwxr-xr-x | apps/app_setcallerid.c | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/apps/app_setcallerid.c b/apps/app_setcallerid.c index 100fb813c..78bd17c43 100755 --- a/apps/app_setcallerid.c +++ b/apps/app_setcallerid.c @@ -31,25 +31,9 @@ STANDARD_LOCAL_USER; LOCAL_USER_DECL; -static struct { - int val; - char *name; -} preses[] = { - { AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, "allowed_not_screened" }, - { AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, "allowed_passed_screen" }, - { AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN, "allowed_failed_screen" }, - { AST_PRES_ALLOWED_NETWORK_NUMBER, "allowed" }, - { AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED , "prohib_not_screened" }, - { AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN, "prohib_passed_screen" }, - { AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN, "prohib_failed_screen" }, - { AST_PRES_PROHIB_NETWORK_NUMBER, "prohib" }, - { AST_PRES_NUMBER_NOT_AVAILABLE, "unavailable" }, -}; - static char *descrip2 = -" SetCallerPres(presentation): Set Caller*ID presentation on\n" -"a call to a new value. Sets ANI as well if a flag is used.\n" -"Always returns 0. Valid presentations are:\n" +" SetCallerPres(presentation): Set Caller*ID presentation on a call.\n" +" Always returns 0. Valid presentations are:\n" "\n" " allowed_not_screened : Presentation Allowed, Not Screened\n" " allowed_passed_screen : Presentation Allowed, Passed Screen\n" @@ -65,33 +49,21 @@ static char *descrip2 = static int setcallerid_pres_exec(struct ast_channel *chan, void *data) { - int res = 0; - char tmp[256] = ""; struct localuser *u; - int x; - char *opts; int pres = -1; - if (data) - strncpy(tmp, (char *)data, sizeof(tmp) - 1); - opts = strchr(tmp, '|'); - if (opts) { - *opts = '\0'; - opts++; - } - for (x=0;x<sizeof(preses) / sizeof(preses[0]);x++) { - if (!strcasecmp(preses[x].name, tmp)) { - pres = preses[x].val; - break; - } - } + + pres = ast_parse_caller_presentation(data); + if (pres < 0) { - ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n", tmp); + ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n", + (char *) data); return 0; } + LOCAL_USER_ADD(u); chan->cid.cid_pres = pres; LOCAL_USER_REMOVE(u); - return res; + return 0; } |