Improve mp3 player quality (bug #1527)
[asterisk/asterisk.git] / callerid.c
index 984e449..3f3e2f7 100755 (executable)
@@ -110,8 +110,8 @@ struct callerid_state *callerid_new(void)
 {
        struct callerid_state *cid;
        cid = malloc(sizeof(struct callerid_state));
-       memset(cid, 0, sizeof(struct callerid_state));
        if (cid) {
+               memset(cid, 0, sizeof(struct callerid_state));
                cid->fskd.spb = 7;              /* 1200 baud */
                cid->fskd.hdlc = 0;             /* Async */
                cid->fskd.nbit = 8;             /* 8 bits */
@@ -436,6 +436,9 @@ int vmwi_generate(unsigned char *buf, int active, int mdmf, int codec)
                sum += msg[x];
        sum = (256 - (sum & 255));
        msg[len++] = sum;
+       /* Wait a half a second */
+       for (x=0;x<4000;x++)
+               PUT_BYTE(0x7f);
        /* Transmit 30 0x55's (looks like a square wave) for channel seizure */
        for (x=0;x<30;x++)
                PUT_CLID(0x55);
@@ -508,7 +511,7 @@ int ast_isphonenumber(char *n)
        if (!n || !strlen(n))
                return 0;
        for (x=0;n[x];x++)
-               if (!strchr("0123456789", n[x]))
+               if (!strchr("0123456789*#+", n[x]))
                        return 0;
        return 1;
 }
@@ -538,7 +541,7 @@ int ast_callerid_parse(char *instr, char **name, char **location)
                                instr[strlen(instr) - 1] = '\0';
                        /* And leading spaces */
                        while(**name && (**name < 33))
-                               name++;
+                               (*name)++;
                        return 0;
                }
        } else {
@@ -549,8 +552,11 @@ int ast_callerid_parse(char *instr, char **name, char **location)
                        *name = NULL;
                        *location = instr;
                } else {
-                       /* Assume it's just a name */
+                       /* Assume it's just a name.  Make sure it's not quoted though */
                        *name = instr;
+                       while(*(*name) && ((*(*name) < 33) || (*(*name) == '\"'))) (*name)++;
+                       ne = *name + strlen(*name) - 1;
+                       while((ne > *name) && ((*ne < 33) || (*ne == '\"'))) { *ne = '\0'; ne--; }
                        *location = NULL;
                }
                return 0;