Newer
Older
return callerid_generate(buf, number, name, 0, callwaiting, codec);
Russell Bryant
committed
int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, int codec)
return __ast_callerid_generate(buf, name, number, 0, codec);
Russell Bryant
committed
int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, int codec)
{
return __ast_callerid_generate(buf, name, number, 1, codec);
}
char *ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *num, const char *unknown)
if (name && num)
snprintf(buf, bufsiz, "\"%s\" <%s>", name, num);
else if (name)
ast_copy_string(buf, unknown, bufsiz);
int ast_callerid_split(const char *buf, char *name, int namelen, char *num, int numlen)
char *tmp;
char *l = NULL, *n = NULL;
tmp = ast_strdupa(buf);
ast_callerid_parse(tmp, &n, &l);
if (n)
if (l) {
ast_shrink_phone_number(l);
/*! \brief Translation table for Caller ID Presentation settings */
static struct {
int val;
char *name;
char *description;
} pres_types[] = {
{ AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, "allowed_not_screened", "Presentation Allowed, Not Screened"},
{ AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, "allowed_passed_screen", "Presentation Allowed, Passed Screen"},
{ AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN, "allowed_failed_screen", "Presentation Allowed, Failed Screen"},
{ AST_PRES_ALLOWED_NETWORK_NUMBER, "allowed", "Presentation Allowed, Network Number"},
{ AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED, "prohib_not_screened", "Presentation Prohibited, Not Screened"},
{ AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN, "prohib_passed_screen", "Presentation Prohibited, Passed Screen"},
{ AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN, "prohib_failed_screen", "Presentation Prohibited, Failed Screen"},
{ AST_PRES_PROHIB_NETWORK_NUMBER, "prohib", "Presentation Prohibited, Network Number"},
{ AST_PRES_NUMBER_NOT_AVAILABLE, "unavailable", "Number Unavailable"},
};
/*! \brief Convert caller ID text code to value
used in config file parsing
\param data text string
\return value AST_PRES_ from callerid.h
*/
int ast_parse_caller_presentation(const char *data)
{
int i;
for (i = 0; i < ((sizeof(pres_types) / sizeof(pres_types[0]))); i++) {
if (!strcasecmp(pres_types[i].name, data))
return pres_types[i].val;
}
return -1;
}
/*! \brief Convert caller ID pres value to explanatory string
\param data value (see callerid.h AST_PRES_ )
\return string for human presentation
*/
const char *ast_describe_caller_presentation(int data)
{
int i;
for (i = 0; i < ((sizeof(pres_types) / sizeof(pres_types[0]))); i++) {
if (pres_types[i].val == data)
return pres_types[i].description;
}
return "unknown";
}