#define lmax 500 #define ladat 500+posin #define americano 0 /// arreglo especial /// VERSION 334 // 1 de septiembre 2004 #define europeo 1 #define posin 18 #define estac 143 +posin // callingPartyNumber #define linea 188 +posin #define durac 305+posin //duracion #define hor 15 +posin //dateTimeOrigination #define fech 15 +posin //dateTimeOrigination #define tranf 0 + posin #define numero 53+posin //callingPartyNumber #define ccost 0 #define proye 378+posin //authCodeDescription #define cuenta 0 #define pulsos 0 #define ruta 0 #define prinum 15 +posin //origNodeId #define ring 184+posin //dateTimeConnect #define antran 0 //anexo transferido (pendiente) #define fofech europeo extern char rgua[]; void in_central() { rgua[0]='\0'; } /* void gua_buf(char *buf) { strcpy(lgua,buf); }*/ void fi_central() { } int j,i,t, k,m,largo1,largo2,encuentra,h; char reg[300][ladat]; m= 0; void busca_lin(char *buf, int vtranf) { //lr, posición de ruta+línea en registro for(m=t;m>=0;m--) { largo1=0;largo2=0; for (j=0;j<10;j++) { if (reg[m][vtranf+179]==buf[vtranf+79]) largo1++;} for (j=0;j<10;j++) { if (reg[m][vtranf+34]==buf[vtranf+79]) largo2++;} if ( largo1>7 || largo2>7 ) {encuentra=1; h=strlen(reg[m]); return;} // encontro conferencia o transferencia } } void add_reg(char *buf, int vtranf) { if (m>=300) m=0; { m=m++; // llamadas conferencias for(j=0;j<=i;j++) reg[m][j]=buf[j]; t=m; } } //tranforma segundos dede 01/01/1970 a fecha y hora Aqct setenta_to_time(char *cdr, char *tel, int vfech) { char tiempo_ori[10], *tiempo_str; long tiempo_seg; for(j=0;j<10;j++) tiempo_ori[j] = cdr[vfech+j]; // tiempo_seg = atoi(tiempo_ori)+10800; //+3horas tiempo_seg = atoi(tiempo_ori); //+3horas tiempo_str = ctime(&tiempo_seg); //Wed Jan 02 02:03:55 1980 tel[k++]=tiempo_str[11]; tel[k++]=tiempo_str[12]; tel[k++]=tiempo_str[13]; tel[k++]=tiempo_str[14]; tel[k++]=tiempo_str[15]; tel[k++]=' '; if (tiempo_str[4]=='J' && tiempo_str[5]=='a') {tel[k++]='0'; tel[k++]='1';} else if (tiempo_str[4]=='F') {tel[k++]='0'; tel[k++]='2';} else if (tiempo_str[4]=='M' && tiempo_str[5]=='a' && tiempo_str[6]=='r') {tel[k++]='0'; tel[k++]='3';} else if (tiempo_str[4]=='A' && tiempo_str[5]=='p') {tel[k++]='0'; tel[k++]='4';} else if (tiempo_str[4]=='M' && tiempo_str[5]=='a' && tiempo_str[6]=='y') {tel[k++]='0'; tel[k++]='5';} else if (tiempo_str[4]=='J' && tiempo_str[5]=='u' && tiempo_str[6]=='n') {tel[k++]='0'; tel[k++]='6';} else if (tiempo_str[4]=='J' && tiempo_str[5]=='u' && tiempo_str[6]=='l') {tel[k++]='0'; tel[k++]='7';} else if (tiempo_str[4]=='A' && tiempo_str[5]=='u') {tel[k++]='0'; tel[k++]='8';} else if (tiempo_str[4]=='S') {tel[k++]='0'; tel[k++]='9';} else if (tiempo_str[4]=='O') {tel[k++]='1'; tel[k++]='0';} else if (tiempo_str[4]=='N') {tel[k++]='1'; tel[k++]='1';} else if (tiempo_str[4]=='D') {tel[k++]='1'; tel[k++]='2';} tel[k++]='/'; tel[k++]=tiempo_str[8]; tel[k++]=tiempo_str[9]; tel[k++]='/'; tel[k++]=tiempo_str[22]; tel[k++]=tiempo_str[23]; } // Driver Propiamente tal. Las posiciones de los campos se // ingresan como parámetros, lo que permite modificar desde // Aplicación de Tarificación la posición de estos en el // Registro de Llamados. void DatCentral(char *buf, char *tel, int vestac, int vlinea,int vdurac,int vhor, int vfech, int vtranf, int vnumero, int vccost,int vproye, int vcuenta, int vpulsos, int vruta, int vprinum, int vring, int vantran, int vfofech) { int cont, num, dn,tr,hunt; int dur_val, minu, segu, hora, ringueo, dn_en_dn, dn_en_num , dn_en_dnx, dn_en_numx; int causa_ori, causa_des; char aux, seg[5], tipo_llamada,servicio; i=strlen(buf); aux=0; cont=0; ringueo=0; num=0, dn=0; dn_en_dn=0; dn_en_num=0,tr=0,hunt=0,dn_en_dnx=0; dn_en_numx=0; causa_ori=0; causa_des=0; if (isdigit(buf[vprinum]) ) { k = 0 ; for (j=0;j<17 ;j++){if(isdigit(buf[vestac+j])) num++ ;} //cuenta dígitos en el campo anexo for (j=0;j<17;j++){if(isdigit(buf[vnumero+j])) dn++;} //cuenta dígitos en el campo número dn_en_dn =( dn <5 ); dn_en_num =( num<5 ); if ( dn<5 && num<5) { dn_en_dn=1;} servicio = '*'; // causa_ori=(isdigit(buf[vlinea-4]) || buf[vlinea-3]>'0'); //el que originó la llamada la terminó // causa_des=(isdigit(buf[vring-16]) || buf[vring-15] >'0'); //el que recibió la llamada la terminó if ( buf[vtranf+149]=='b' ) { servicio='C'; tipo_llamada='O';} else if ( isdigit(buf[ vtranf+47]) && buf[vtranf+137]==' ') { tipo_llamada='I'; dn_en_dn=0; dn_en_num=1;} else if ( buf[vtranf +47]==' ' && isdigit(buf[vtranf+137])) { tipo_llamada='O'; dn_en_dn=1; dn_en_num=0;} //else if ( buf[posin +47]==' ' && buf[posin +137]==' ' ) { tipo_llamada='T'; dn_en_dn=1; dn_en_num=1;} else if (dn<5 && num<5) tipo_llamada='T'; else if (dn_en_dn && dn_en_num) tipo_llamada='T'; else if (dn_en_dn) tipo_llamada='O'; else if (dn_en_num) tipo_llamada='I'; else if (causa_des) tipo_llamada='I'; else if (causa_ori) tipo_llamada='O'; else tipo_llamada='O'; if (buf[vtranf+149]=='b') servicio= 'C'; else if ( buf[vtranf+375]=='1' && buf[vtranf+376]=='0') servicio= 'T'; else servicio= '*'; if (buf[vtranf+71]=='1' && buf[vtranf+72]=='2' && buf[vtranf+73]=='6') { buf[vtranf+385]= tipo_llamada; // registro de quien transfirio llamada add_reg(buf,vtranf); } if ( servicio =='C' || servicio=='T') busca_lin(buf,vtranf); // busca llamada quien transfirio if ( servicio =='T' && encuentra ) { if (reg[m][vtranf+385]=='I' ) tipo_llamada = 'I'; else tipo_llamada = 'O'; } if ( servicio == 'C' && encuentra ) { if (reg[m][vtranf+385]== 'I') { for(j=0;j<17;j++) { if (isdigit(reg[m][vestac+j])) { tel[k++]=reg[m][vestac+j];cont++;} } } if (reg[m][vtranf+385]== 'O') { for(j=0;j<17;j++) { if (isdigit(reg[m][vnumero+j])) { tel[k++]=reg[m][vnumero+j];cont++;} } } } else if (dn_en_dn) for(j=0;j<17;j++) { if (isdigit(buf[vnumero+j])) { tel[k++]=buf[vnumero+j];cont++;} } else if (dn_en_num) for(j=0;j<17;j++) { if (isdigit(buf[vestac+j])) { tel[k++]=buf[vestac+j];cont++;} } else tel[k++]='*'; if (cont==0) tel[k++] = '*'; tel[k++] = ' ' ; cont=0; if (dn_en_num) //linea for(j=0;j<9;j++) { if (isdigit(buf[vtranf+323+j])) { tel[k++]=buf[vtranf+323+j];cont++;} } else if (dn_en_dn) for(j=0;j<9;j++) { if (isdigit(buf[vtranf+344+j])) { tel[k++]=buf[vtranf+344+j];cont++;} } else tel[k++] = '*'; if (cont==0) tel[k++] = '*'; tel[k++] = ' ' ; for(j=0;j<5;j++) seg[j]=buf[306+vtranf+j]; dur_val=(atoi(seg)); segu=(dur_val)%60; //segundos minu=((dur_val)%3600)/60; //minutos hora=(dur_val)/3600; //hora tel[k++]=(hora/10)+'0'; tel[k++]=(hora%10)+'0'; tel[k++]=':'; tel[k++]=(minu/10)+'0'; tel[k++]=(minu%10)+'0'; tel[k++]=':'; tel[k++]=(segu/10)+'0'; tel[k++]=(segu%10)+'0'; tel[k++] = ' ' ; setenta_to_time(buf, tel, vfech); //tranforma segundos dede 01/01/1970 a fecha y hora Aqct tel[k++] = ' '; tel[k++] = tipo_llamada; tel[k++] = ' '; cont=0; if ( servicio == 'C' && encuentra ) { if (reg[m][vtranf+385]== 'I') { for(j=0;j<17;j++) { if (isdigit(reg[m][vnumero+j])) { tel[k++]=reg[m][vnumero+j];cont++;} } } if (reg[m][vtranf+385]== 'O') { for(j=0;j<17;j++) { if (isdigit(reg[m][vestac+j])) { tel[k++]=reg[m][vestac+j];cont++;} } } } else if (dn_en_dn) for(j=0;j<17;j++) { if (isdigit(buf[vestac+j])) { tel[k++]=buf[vestac+j];cont++;} } else if (dn_en_num) for(j=0;j<17;j++) { if (isdigit(buf[vnumero+j])) { tel[k++]=buf[vnumero+j];cont++;} } else tel[k++]='*'; if (cont==0 ) { tel[k++]='*';} tel[k++] = ' ' ; tel[k++] = '*';tel[k++] = '*';tel[k++] = '*'; //centro costo tel[k++] = ' ' ; cont=0; if (buf[vproye]!=' ') for(j=0;j<8;j++) { if (isalnum(buf[vproye+j]) ) {tel[k++]= buf[vproye+j];cont++;} } else tel[k++]='*'; if (cont==0) tel[k++]='*'; tel[k++] = ' ' ; tel[k++] = '*' ; // Código de Cuenta tel[k++] = ' ' ; for (j=0 ; j<5 ; j++) tel[k++]='0'; tel[k++] = ' ' ; cont = 0; if (dn_en_num) //linea for(j=0;j<3;j++) { if (isdigit(buf[vtranf+320+j])) { tel[k++]=buf[vtranf+320+j];cont++;} } else if (dn_en_dn) for(j=0;j<3;j++) { if (isdigit(buf[vtranf+340+j])) { tel[k++]=buf[vtranf+340+j];cont++;} } else { tel[k++] = '*';tel[k++] = '*'; } if (cont==0) tel[k++]='*'; tel[k++] = ' ' ; tel[k++] = buf[vprinum]; /* central */ tel[k++] = ' ' ; tel[k++]='0'; tel[k++]='0'; tel[k++]=':'; tel[k++]='0'; tel[k++]='0'; // t ring tel[k++] = ' ' ; if ( (servicio == 'C' || servicio=='T') && encuentra ) { if ( tipo_llamada =='I') { for(j=0;j<17;j++) { if (isdigit(reg[m][vestac+j])) { tel[k++]=reg[m][vestac+j];cont++;} } } if ( tipo_llamada == 'O') { for(j=0;j<17;j++) { if (isdigit(reg[m][vnumero+j])) { tel[k++]=reg[m][vnumero+j];cont++;} } } } else tel[k++] = '*' ; // anexo transferido tel[k++] = ' ' ; if (dur_val==0 && tipo_llamada=='I' ) servicio= 'A'; else if (dur_val==0 && tipo_llamada=='O' ) servicio= 'N'; tel[k++] = servicio; tel[k++] = '\r' ; tel[k++] = '\n' ; tel[k++] = '\0' ; } }