All pastes #23988 Raw Edit

Something

public text v1 · immutable
#23988 ·published 2005-09-26 19:32 UTC
rendered paste body
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main (void)
{

 char dtmfbuf[300] = "*002044896227#";
/* char dtmfbuf[300] = "*002044896227#*6045551212#"; */
/* char dtmfbuf[300] = "*002044896227#*06045551212#"; */
/* char dtmfbuf[300] = "*1381537359#*002044896227#*3592943431012#"; */
/* char dtmfbuf[300] = "*1581537359#*002044896227#*3592943431012#"; */

    char IXC_PRESUB[10];
    char IXC_ANI[20] = "";
    char IXC_DNIS[20] = "";
    char IXC_INTL[10] = "0";
    char IXC_CIC[10] = "1537";
    char IXC_OZZ[10] = "";
    char IXC_COUNTRY[10] = "1";
    char IXC_OPERATOR[10] = "0";
    char IXC_CUTTHROUGH[10] = "0";
    char src[100], dest[100], intl[100];
    char ch, chstr[11];
    int ret;

    if (strlen(dtmfbuf)==14) {
        sscanf (dtmfbuf,"*%12s#",src);
        ret = 1;
    } else if (strlen (dtmfbuf) == 26) {
        sscanf (dtmfbuf,"*%12s#*%10s#",src, dest);
        ret = 2;
    } else if (strlen (dtmfbuf) == 27) {
        sscanf (dtmfbuf,"*%12s#*%11s#",src, dest);
        ret = 4;
    } else if (strlen (dtmfbuf) > 28) {
        char* index = strrchr (dtmfbuf,'#');
        sscanf (dtmfbuf, "*%10s#*%12s#", src, dest);
        memcpy (intl, dtmfbuf+27,index-dtmfbuf-27);
        ret = 3;
    }
    printf("(%s) (%s) (%s)\n",src,dest,intl);
    switch (ret) {
        case 1:
                sscanf (src,"%2s%10s",IXC_PRESUB,IXC_ANI);
                strcpy (IXC_CUTTHROUGH,"1");
                break;
        case 4:
                sscanf (src, "%2s%10s",IXC_PRESUB,IXC_ANI);
                sscanf (dest,"%c%10s",&ch,chstr);
                if(ch=='0')
                        strcpy (IXC_OPERATOR,"1");
                strcpy (IXC_DNIS,"1");
                strcat (IXC_DNIS,chstr);
                break;
        case 2:
                sscanf (src, "%2s%10s",IXC_PRESUB,IXC_ANI);
                strcpy (IXC_DNIS,"1");
                strcat (IXC_DNIS,dest);
                break;
        case 3:
                sscanf (dest,"%2s%10s", IXC_PRESUB, IXC_ANI);
                sscanf (src,"%3s%4s%3s",IXC_OZZ, IXC_CIC, IXC_COUNTRY);
                if (strcmp (IXC_OZZ,"138")==0)
                        strcpy (IXC_OPERATOR,"0");
                else if (strcmp(IXC_OZZ,"158")==0)
                        strcpy (IXC_OPERATOR,"1");
                strcpy (IXC_DNIS,"011");
                strcat (IXC_DNIS,intl);
                strcpy (IXC_INTL,"1");
    }
    printf("IXC_PRESUB[%s]\n",IXC_PRESUB);
    printf("IXC_ANI[%s]\n",IXC_ANI);
    printf("IXC_DNIS[%s]\n",IXC_DNIS);
    printf("IXC_INTL[%s]\n",IXC_INTL);
    printf("IXC_CIC[%s]\n",IXC_CIC);
    printf("IXC_OZZ[%s]\n",IXC_OZZ);
    printf("IXC_COUNTRY[%s]\n",IXC_COUNTRY);
    printf("IXC_OPERATOR[%s]\n",IXC_OPERATOR);
    printf("IXC_CUTTHROUGH[%s]\n",IXC_CUTTHROUGH);
    return 0;
}