various whitespace changes to reduce indentation and to better conform to
authorRussell Bryant <russell@russellbryant.com>
Thu, 2 Nov 2006 14:15:12 +0000 (14:15 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 2 Nov 2006 14:15:12 +0000 (14:15 +0000)
formatting guidelines

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46886 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/callerid.c

index 036535d..e336020 100644 (file)
@@ -203,7 +203,7 @@ void callerid_get_dtmf(char *cidstring, char *number, int *flags)
                        *flags = CID_UNKNOWN_NUMBER;
        } else if (cidstring[0] == 'D' || cidstring[0] == 'A') {
                /* "Standard" callerid */
-               for (i = 1; i < strlen(cidstring); i++ ) {
+               for (i = 1; i < strlen(cidstring); i++) {
                        if (cidstring[i] == 'C' || cidstring[i] == '#')
                                break;
                        if (isdigit(cidstring[i]))
@@ -259,7 +259,7 @@ static unsigned short calc_crc(unsigned short crc, unsigned char data)
        org = data;
        dst = 0;
 
-       for (i=0; i < CHAR_BIT; i++) {
+       for (i = 0; i < CHAR_BIT; i++) {
                org <<= 1;
                dst >>= 1;
                if (org & 0x100) {
@@ -268,8 +268,8 @@ static unsigned short calc_crc(unsigned short crc, unsigned char data)
        }
        data = (unsigned char)dst;
        crc ^= (unsigned int)data << (16 - CHAR_BIT);
-       for ( j=0; j<CHAR_BIT; j++ ) {
-               if ( crc & 0x8000U )
+       for (j = 0; j < CHAR_BIT; j++) {
+               if (crc & 0x8000U)
                        crc = (crc << 1) ^ 0x1021U ;
                else
                        crc <<= 1 ;
@@ -282,7 +282,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i
        int mylen = len;
        int olen;
        int b = 'X';
-       int b2 ;
+       int b2;
        int res;
        int x;
        short *buf;
@@ -292,7 +292,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i
        memcpy(buf, cid->oldstuff, cid->oldlen);
        mylen += cid->oldlen/2;
 
-       for (x=0;x<len;x++) 
+       for (x = 0; x < len; x++) 
                buf[x+cid->oldlen/2] = AST_XLAW(ubuf[x]);
 
        while (mylen >= 160) {
@@ -313,208 +313,204 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i
                }
 
                if (res == 1) {
-
-                       b2 = b ;
-                       b  = b & 0x7f ;
+                       b2 = b;
+                       b  &= 0x7f;
 
                        /* crc checksum calculation */
-                       if ( cid->sawflag > 1 ) {
-                               cid->crc = calc_crc(cid->crc, (unsigned char)b2);
-                       }
+                       if (cid->sawflag > 1)
+                               cid->crc = calc_crc(cid->crc, (unsigned char) b2);
 
                        /* Ignore invalid bytes */
-                       if (b > 0xff) {
+                       if (b > 0xff)
                                continue;
-                       }
 
                        /* skip DLE if needed */
-                       if ( cid->sawflag > 0 ) {
-                               if ( cid->sawflag != 5 && cid->skipflag == 0 && b == 0x10 ) {
+                       if (cid->sawflag > 0) {
+                               if (cid->sawflag != 5 && cid->skipflag == 0 && b == 0x10) {
                                        cid->skipflag = 1 ;
                                        continue ;
                                }
                        }
-                       if ( cid->skipflag == 1 ) {
+                       if (cid->skipflag == 1)
                                cid->skipflag = 0 ;
-                       }
 
                        /* caller id retrieval */
                        switch(cid->sawflag) {
-                               case 0: /* DLE */
-                                       if (b == 0x10) {
-                                               cid->sawflag = 1;
-                                               cid->skipflag = 0;
-                                               cid->crc = 0;
-                                       }
-                                       break;
-                               case 1: /* SOH */
-                                       if (b == 0x01) {
-                                               cid->sawflag = 2;
-                                       }
-                                       break ;
-                               case 2: /* HEADER */
-                                       if (b == 0x07) {
-                                               cid->sawflag = 3;
-                                       }
-                                       break;
-                               case 3: /* STX */
-                                       if (b == 0x02) {
-                                               cid->sawflag = 4;
-                                       }
-                                       break;
-                               case 4: /* SERVICE TYPE */
-                                       if (b == 0x40) {
-                                               cid->sawflag = 5;
-                                       }
-                                       break;
-                               case 5: /* Frame Length */
-                                       cid->sawflag = 6;
-                                       break;  
-                               case 6: /* NUMBER TYPE */
-                                       cid->sawflag = 7;
-                                       cid->pos = 0;
-                                       cid->rawdata[cid->pos++] = b;
-                                       break;
-                               case 7: /* NUMBER LENGTH */
-                                       cid->sawflag = 8;
-                                       cid->len = b;
-                                       if ( (cid->len+2) >= sizeof( cid->rawdata ) ) {
-                                               ast_log(LOG_WARNING, "too long caller id string\n" ) ;
-                                               return -1;
-                                       }
-                                       cid->rawdata[cid->pos++] = b;
-                                       break;
-                               case 8: /* Retrieve message */
-                                       cid->rawdata[cid->pos++] = b;
-                                       cid->len--;
-                                       if (cid->len<=0) {
-                                               cid->rawdata[cid->pos] = '\0';
-                                               cid->sawflag = 9;
-                                       }
-                                       break;
-                               case 9: /* ETX */
-                                       cid->sawflag = 10;
-                                       break;
-                               case 10: /* CRC Checksum 1 */
-                                       cid->sawflag = 11;
-                                       break;
-                               case 11: /* CRC Checksum 2 */
-                                       cid->sawflag = 12;
-                                       if ( cid->crc != 0 ) {
-                                               ast_log(LOG_WARNING, "crc checksum error\n" ) ;
-                                               return -1;
-                                       } 
-                                       /* extract caller id data */
-                                       for (x=0; x<cid->pos; ) {
-                                               switch (cid->rawdata[x++]) {
-                                               case 0x02: /* caller id  number */
-                                                       cid->number[0] = '\0';
-                                                       cid->name[0] = '\0';
-                                                       cid->flags = 0;
-                                                       res = cid->rawdata[x++];
-                                                       ast_copy_string(cid->number, &cid->rawdata[x], res+1 );
-                                                       x += res;
-                                                       break;
-                                               case 0x21: /* additional information */
-                                                       /* length */
-                                                       x++; 
-                                                       /* number type */
-                                                       switch (cid->rawdata[x]) { 
-                                                       case 0x00: /* unknown */
-                                                       case 0x01: /* international number */
-                                                       case 0x02: /* domestic number */
-                                                       case 0x03: /* network */
-                                                       case 0x04: /* local call */
-                                                       case 0x06: /* short dial number */
-                                                       case 0x07: /* reserved */
-                                                       default:   /* reserved */
-                                                               if (option_debug > 1)
-                                                                       ast_log(LOG_DEBUG, "cid info:#1=%X\n", cid->rawdata[x]);
-                                                               break ;
-                                                       }
-                                                       x++; 
-                                                       /* numbering plan octed 4 */
-                                                       x++; 
-                                                       /* numbering plan octed 5 */
-                                                       switch (cid->rawdata[x]) { 
-                                                       case 0x00: /* unknown */
-                                                       case 0x01: /* recommendation E.164 ISDN */
-                                                       case 0x03: /* recommendation X.121 */
-                                                       case 0x04: /* telex dial plan */
-                                                       case 0x08: /* domestic dial plan */
-                                                       case 0x09: /* private dial plan */
-                                                       case 0x05: /* reserved */
-                                                       default:   /* reserved */
-                                                               if (option_debug > 1)
-                                                                       ast_log(LOG_DEBUG, "cid info:#2=%X\n", cid->rawdata[x]);
-                                                               break ;
-                                                       }
-                                                       x++; 
+                       case 0: /* DLE */
+                               if (b == 0x10) {
+                                       cid->sawflag = 1;
+                                       cid->skipflag = 0;
+                                       cid->crc = 0;
+                               }
+                               break;
+                       case 1: /* SOH */
+                               if (b == 0x01) {
+                                       cid->sawflag = 2;
+                               }
+                               break ;
+                       case 2: /* HEADER */
+                               if (b == 0x07) {
+                                       cid->sawflag = 3;
+                               }
+                               break;
+                       case 3: /* STX */
+                               if (b == 0x02) {
+                                       cid->sawflag = 4;
+                               }
+                               break;
+                       case 4: /* SERVICE TYPE */
+                               if (b == 0x40) {
+                                       cid->sawflag = 5;
+                               }
+                               break;
+                       case 5: /* Frame Length */
+                               cid->sawflag = 6;
+                               break;  
+                       case 6: /* NUMBER TYPE */
+                               cid->sawflag = 7;
+                               cid->pos = 0;
+                               cid->rawdata[cid->pos++] = b;
+                               break;
+                       case 7: /* NUMBER LENGTH */
+                               cid->sawflag = 8;
+                               cid->len = b;
+                               if ((cid->len+2) >= sizeof(cid->rawdata)) {
+                                       ast_log(LOG_WARNING, "too long caller id string\n") ;
+                                       return -1;
+                               }
+                               cid->rawdata[cid->pos++] = b;
+                               break;
+                       case 8: /* Retrieve message */
+                               cid->rawdata[cid->pos++] = b;
+                               cid->len--;
+                               if (cid->len<=0) {
+                                       cid->rawdata[cid->pos] = '\0';
+                                       cid->sawflag = 9;
+                               }
+                               break;
+                       case 9: /* ETX */
+                               cid->sawflag = 10;
+                               break;
+                       case 10: /* CRC Checksum 1 */
+                               cid->sawflag = 11;
+                               break;
+                       case 11: /* CRC Checksum 2 */
+                               cid->sawflag = 12;
+                               if (cid->crc != 0) {
+                                       ast_log(LOG_WARNING, "crc checksum error\n") ;
+                                       return -1;
+                               } 
+                               /* extract caller id data */
+                               for (x=0; x<cid->pos;) {
+                                       switch (cid->rawdata[x++]) {
+                                       case 0x02: /* caller id  number */
+                                               cid->number[0] = '\0';
+                                               cid->name[0] = '\0';
+                                               cid->flags = 0;
+                                               res = cid->rawdata[x++];
+                                               ast_copy_string(cid->number, &cid->rawdata[x], res+1);
+                                               x += res;
+                                               break;
+                                       case 0x21: /* additional information */
+                                               /* length */
+                                               x++; 
+                                               /* number type */
+                                                       switch (cid->rawdata[x]) { 
+                                               case 0x00: /* unknown */
+                                               case 0x01: /* international number */
+                                               case 0x02: /* domestic number */
+                                               case 0x03: /* network */
+                                               case 0x04: /* local call */
+                                               case 0x06: /* short dial number */
+                                               case 0x07: /* reserved */
+                                               default:   /* reserved */
+                                                       if (option_debug > 1)
+                                                               ast_log(LOG_DEBUG, "cid info:#1=%X\n", cid->rawdata[x]);
                                                        break ;
-                                               case 0x04: /* no callerid reason */
-                                                       /* length */
-                                                       x++; 
-                                                       /* no callerid reason code */
-                                                       switch (cid->rawdata[x]) {
-                                                       case 'P': /* caller id denied by user */
-                                                       case 'O': /* service not available */
-                                                       case 'C': /* pay phone */
-                                                       case 'S': /* service congested */
-                                                               cid->flags |= CID_UNKNOWN_NUMBER;
-                                                               if (option_debug > 1)
-                                                                       ast_log(LOG_DEBUG, "no cid reason:%c\n",cid->rawdata[x]);
-                                                               break ;
-                                                       }
-                                                       x++; 
+                                               }
+                                               x++; 
+                                               /* numbering plan octed 4 */
+                                               x++; 
+                                               /* numbering plan octed 5 */
+                                               switch (cid->rawdata[x]) { 
+                                               case 0x00: /* unknown */
+                                               case 0x01: /* recommendation E.164 ISDN */
+                                               case 0x03: /* recommendation X.121 */
+                                               case 0x04: /* telex dial plan */
+                                               case 0x08: /* domestic dial plan */
+                                               case 0x09: /* private dial plan */
+                                               case 0x05: /* reserved */
+                                               default:   /* reserved */
+                                                       if (option_debug > 1)
+                                                               ast_log(LOG_DEBUG, "cid info:#2=%X\n", cid->rawdata[x]);
                                                        break ;
-                                               case 0x09: /* dialed number */
-                                                       /* length */
-                                                       res = cid->rawdata[x++];
-                                                       /* dialed number */
-                                                       x += res;
+                                               }
+                                               x++; 
+                                               break ;
+                                       case 0x04: /* no callerid reason */
+                                               /* length */
+                                               x++; 
+                                               /* no callerid reason code */
+                                               switch (cid->rawdata[x]) {
+                                               case 'P': /* caller id denied by user */
+                                               case 'O': /* service not available */
+                                               case 'C': /* pay phone */
+                                               case 'S': /* service congested */
+                                                               cid->flags |= CID_UNKNOWN_NUMBER;
+                                                       if (option_debug > 1)
+                                                               ast_log(LOG_DEBUG, "no cid reason:%c\n",cid->rawdata[x]);
                                                        break ;
-                                               case 0x22: /* dialed number additional information */
-                                                       /* length */
-                                                       x++;
-                                                       /* number type */
-                                                       switch (cid->rawdata[x]) {
-                                                       case 0x00: /* unknown */
-                                                       case 0x01: /* international number */
-                                                       case 0x02: /* domestic number */
-                                                       case 0x03: /* network */
-                                                       case 0x04: /* local call */
-                                                       case 0x06: /* short dial number */
-                                                       case 0x07: /* reserved */
-                                                       default:   /* reserved */
-                                                               if (option_debug > 1)
-                                                                       ast_log(LOG_NOTICE, "did info:#1=%X\n", cid->rawdata[x]);
-                                                               break ;
-                                                       }
-                                                       x++;
-                                                       /* numbering plan octed 4 */
-                                                       x++;
-                                                       /* numbering plan octed 5 */
-                                                       switch (cid->rawdata[x]) {
-                                                       case 0x00: /* unknown */
-                                                       case 0x01: /* recommendation E.164 ISDN */
-                                                       case 0x03: /* recommendation X.121 */
-                                                       case 0x04: /* telex dial plan */
-                                                       case 0x08: /* domestic dial plan */
-                                                       case 0x09: /* private dial plan */
-                                                       case 0x05: /* reserved */
-                                                       default:   /* reserved */
-                                                               if (option_debug > 1)
-                                                                       ast_log(LOG_DEBUG, "did info:#2=%X\n", cid->rawdata[x]);
-                                                               break ;
-                                                       }
-                                                       x++;
+                                               }
+                                               x++; 
+                                               break ;
+                                       case 0x09: /* dialed number */
+                                               /* length */
+                                               res = cid->rawdata[x++];
+                                               /* dialed number */
+                                               x += res;
+                                               break ;
+                                       case 0x22: /* dialed number additional information */
+                                               /* length */
+                                               x++;
+                                               /* number type */
+                                               switch (cid->rawdata[x]) {
+                                               case 0x00: /* unknown */
+                                               case 0x01: /* international number */
+                                               case 0x02: /* domestic number */
+                                               case 0x03: /* network */
+                                               case 0x04: /* local call */
+                                               case 0x06: /* short dial number */
+                                               case 0x07: /* reserved */
+                                               default:   /* reserved */
+                                                       if (option_debug > 1)
+                                                               ast_log(LOG_NOTICE, "did info:#1=%X\n", cid->rawdata[x]);
                                                        break ;
                                                }
+                                               x++;
+                                               /* numbering plan octed 4 */
+                                               x++;
+                                                       /* numbering plan octed 5 */
+                                               switch (cid->rawdata[x]) {
+                                               case 0x00: /* unknown */
+                                               case 0x01: /* recommendation E.164 ISDN */
+                                               case 0x03: /* recommendation X.121 */
+                                               case 0x04: /* telex dial plan */
+                                               case 0x08: /* domestic dial plan */
+                                               case 0x09: /* private dial plan */
+                                               case 0x05: /* reserved */
+                                               default:   /* reserved */
+                                                       if (option_debug > 1)
+                                                               ast_log(LOG_DEBUG, "did info:#2=%X\n", cid->rawdata[x]);
+                                                       break ;
+                                               }
+                                               x++;
+                                               break ;
                                        }
-                                       return 1;
-                                       break;
-                               default:
-                                       ast_log(LOG_ERROR, "invalid value in sawflag %d\n", cid->sawflag);
+                               }
+                               return 1;
+                               break;
+                       default:
+                               ast_log(LOG_ERROR, "invalid value in sawflag %d\n", cid->sawflag);
                        }
                }
        }
@@ -542,7 +538,7 @@ int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int len, int
        memcpy(buf, cid->oldstuff, cid->oldlen);
        mylen += cid->oldlen/2;
 
-       for (x=0;x<len;x++) 
+       for (x = 0; x < len; x++) 
                buf[x+cid->oldlen/2] = AST_XLAW(ubuf[x]);
        while (mylen >= 160) {
                olen = mylen;
@@ -606,7 +602,7 @@ int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int len, int
                                if (cid->type == 0x80) {
                                        /* MDMF */
                                        /* Go through each element and process */
-                                       for (x=0;x< cid->pos;) {
+                                       for (x = 0; x < cid->pos;) {
                                                switch(cid->rawdata[x++]) {
                                                case 1:
                                                        /* Date */
@@ -642,7 +638,7 @@ int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int len, int
                                                case 22: /* Something French */
                                                        break;
                                                default:
-                                                       ast_log(LOG_NOTICE, "Unknown IE %d\n", cid->rawdata[x-1]);
+                                                       ast_log(LOG_NOTICE, "Unknown IE %d\n", cid->rawdata[x - 1]);
                                                }
                                                x += cid->rawdata[x];
                                                x++;
@@ -679,6 +675,7 @@ int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int len, int
                cid->oldlen = mylen * 2;
        } else
                cid->oldlen = 0;
+
        return 0;
 }
 
@@ -889,7 +886,7 @@ void ast_shrink_phone_number(char *n)
                                n[y++] = n[x];
                        break;
                default:
-                       if (!strchr("( )", n[x]))
+                       if (!strchr("()", n[x]))
                                n[y++] = n[x];
                }
        }