}
return 0;
}
-
+static char *get_calleridname(char *input,char *output)
+{
+ char *end = strchr(input,'<');
+ char *tmp = strchr(input,'\"');
+ if (!end) return NULL;
+ /* move away from "<" */
+ end--;
+ /* we found "name" */
+ if (tmp && tmp < end) {
+ end = strchr(tmp+1,'\"');
+ if (!end) return NULL;
+ strncpy(output,tmp+1,(int)(end-tmp-1));
+ } else {
+ /* we didn't find "name" */
+ /* clear the empty characters in the begining*/
+ while(*input && (*input < 33))
+ input++;
+ /* clear the empty characters in the end */
+ while(*end && (*end < 33) && end > input)
+ end--;
+ strncpy(output,input,(int)(end-input));
+ }
+ return output;
+}
static int check_user(struct sip_pvt *p, struct sip_request *req, char *cmd, char *uri, int reliable)
{
struct sip_user *user;
char *of, from[256] = "", *c;
int res = 0;
char *t;
+ char calleridname[50];
/* Terminate URI */
t = uri;
while(*t && (*t > 32) && (*t != ';'))
*t = '\0';
of = get_header(req, "From");
strncpy(from, of, sizeof(from) - 1);
+ memset(calleridname,0,sizeof(calleridname));
+ get_calleridname(from,calleridname);
of = ditch_braces(from);
if (strncmp(of, "sip:", 4)) {
ast_log(LOG_NOTICE, "From address missing 'sip:', using it anyway\n");
*c = '\0';
if ((c = strchr(of, ':')))
*c = '\0';
- strncpy(p->callerid, of, sizeof(p->callerid) - 1);
+ if (*calleridname)
+ sprintf(p->callerid,"\"%s\" <%s>",calleridname,of);
+ else
+ strncpy(p->callerid, of, sizeof(p->callerid) - 1);
if (!strlen(of))
return 0;
ast_pthread_mutex_lock(&userl.lock);