#define americano 0 #define europeo 1 #define lmax 200 #define posin 18 #define ladat 132+posin #define estac 9+posin #define linea 21+posin #define durac 49+posin #define hor 43+posin #define fech 37+posin #define tranf 0+posin #define numero 58+posin #define ccost 0 #define proye 49+posin #define cuenta 0 #define pulsos 0 #define ruta 18+posin #define prinum 0 #define ring 0 #define antran 0 // anexo transferido #define fofech americano char reg[60000][ladat], *cuf, *ruf, *buf2, lgua[lmax+3]; int aux=0,t=0,m=0,j,lb,i,h,cont,sal=0,registros=0; encuentra=0; //lb posicion de ruta+linea de buf extern void gua_rut(char *buf); extern char rgua[]; void in_central() { rgua[0]='\0'; } void gua_buf(char *buf) { strcpy(lgua,buf); } void fi_central() { } //compara la línea del registro actual (buf) con los registros anteriores (almacenados en el arreglo bidimencional) void busca_lin(char *buf) { for(m=t;m>=0;m--) { for(j=0 ; j<6 && ((reg[m][lb+j]==buf[lb+j]) || (reg[m][lb+8+j]==buf[lb+j])) ; j++) //compara lineas+rutas if (j==5) {encuentra=1; return;} //lineas+rutas iguales } } //almacena las llamadas con lineas distintas en un arreglo bidimencional (sobreescribe los registros de líneas iguales) void add_reg(char *buf) { busca_lin(buf); if (!encuentra) {m=t;t++;} // if (m<1) {m=t;t++;} for(j=0;j<=i;j++) reg[m][j]=buf[j]; } 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 k, j; int acep_prim, acep_seg, saliente, entrante, trans_ini, trans_fin, trans_in, trans_out, tandem; acep_prim=0; acep_seg=0; saliente=0; entrante=0; trans_ini=0; trans_fin=0; trans_in=0; trans_out=0; tandem=0; k=0; encuentra=0; i=strlen(buf); acep_prim = (i>(vdurac+2) && isalpha(buf[vtranf]) && buf[vfech+2]=='/' && buf[vhor+2]==':'); //primera línea válida acep_seg = (i>(vestac+7) && buf[vestac+26]=='X' && sal==0 && registros!=0 ); //segunda línea válida saliente = (acep_prim && isdigit(buf[vestac])); //llamada saliente entrante = (acep_prim && isdigit(buf[vruta-1])) || (acep_seg && buf[vestac+24]=='X' ); //llamada entrante trans_ini = (acep_prim && buf[vtranf]=='S'); //inicio de transferencia trans_fin = (acep_prim && buf[vtranf]=='E'); //fin de transferencia tandem = (!isdigit(buf[vestac]) && !isdigit(buf[ruta-1] && buf[vtranf]!='E'&& buf[vtranf]!='Q')); //llamadas troncal-troncal registros++; //TRANSFERENCIAS if (entrante) lb=vestac+1; //posicion de la línea buscada else lb=vruta; if (buf[vtranf]=='E' || buf[vtranf]=='N') busca_lin(buf); //transferncias: busca por linea el anexo desde donde se transfirió else if (buf[vtranf]=='S' || buf[vtranf]=='A') add_reg(buf); sal=0; trans_in = (trans_fin && encuentra && isdigit(reg[m][vestac+1])); //transferencia entrante trans_out = (trans_fin && encuentra && isalpha(reg[m][vestac+1])); //transferencia saliente if( acep_prim && entrante && (!trans_out || trans_in) || (tandem && acep_prim && buf[vestac+2]!='4') || ( isdigit(buf[vestac]) && buf[vruta+1]=='4' && buf[vruta+2]=='4' ) && (buf[vruta+1]=='4' && buf[vruta+2]=='4' ) ) { gua_buf(buf); cuf = lgua; return; } else if (acep_seg) { ruf=cuf; cuf=buf; buf=ruf; //cuf->buf y buf->cuf } pablo: aux=0; if ((acep_prim || acep_seg) && buf[vtranf]!='A' && i>vdurac+2 && buf[vruta+20]!='X'&& buf[vtranf]!='Q') { i=strlen(buf); k=0;cont=0; for (j=0;j<12 && buf[vnumero+2+j] && (vnumero+2+j)<=i; j++) { cont++;} if ( buf[vruta-1]=='T' && buf[vruta+1]=='4' && (buf[vruta+2]=='3' || buf[vruta+2]=='4') && isdigit(buf[vestac]) && cont==8) { for ( j=0;j<4;j++) tel[k++]=buf[vnumero+6+j]; } else if ( !isdigit(buf[vestac]) && !isdigit(buf[ruta-1])) { if (tandem==1){ tel[k++]='R'; tel[k++]=buf[vruta];tel[k++]=buf[vruta+1];tel[k++]=buf[vruta+2];} else {tel[k++]='R'; tel[k++]=buf[vestac+1];tel[k++]=buf[vestac+2];tel[k++]=buf[vestac+3];} } //anexo else if (saliente && isdigit(buf[vestac])) { for (j=0;j<6;j++) {if (isdigit(buf[vestac+j])) { tel[k++]=buf[vestac+j];} sal=1;} } else if (entrante && isdigit(buf[vruta-1])) { for (j=0;j<4;j++) if (isdigit(buf[vruta-1+j])) { tel[k++]=buf[vruta-1+j];} } else tel[k++]='*'; tel[k++]=' '; if ( isdigit(buf[vruta-1]) ) //línea { for (j=0;j<3;j++) tel[k++]=buf[vestac+4+j]; } else if ( isdigit(buf[vestac]) ) { for (j=0;j<3;j++) tel[k++]=buf[vlinea+j]; } else if ( entrante) { for (j=0;j<3;j++) tel[k++]=buf[vestac+4+j]; } else if (saliente) { for (j=0;j<3;j++) tel[k++]=buf[vestac+4+j]; } else tel[k++]='*'; tel[k++] = ' ' ; if (buf[vdurac+2]==':') { for(j=0;j<8;j++) tel[k++]=buf[vdurac+j] ; } else tel[k++]='*'; tel[k++] = ' ' ; if isdigit(buf[vhor]) { for(j=0;j<5;j++) tel[k++]=buf[vhor+j] ; } else tel[k++]='*'; tel[k++] = ' ' ; tel[k++] = buf[vfech+0] ; tel[k++] = buf[vfech+1] ; tel[k++] = '/'; tel[k++] = buf[vfech+3] ; tel[k++] = buf[vfech+4] ; tel[k++] = '/'; tel[k++] = buf[6]; tel[k++] = buf[7]; tel[k++] = ' ' ; //if (encuentra && isalpha(reg[m][vestac+1])) tel[k++]='O'; if ( buf[vruta-1]=='T' && buf[vruta+1]=='4' && (buf[vruta+2]=='3' || buf[vruta+2]=='4') && isdigit(buf[vestac]) && cont==8) tel[k++]='I'; else if (trans_out) tel[k++]='O'; else if (entrante) tel[k++]='I'; else if (buf[vtranf]=='L') tel[k++]='T'; else if (tandem==1) tel[k++]='I'; else if (tandem>1) tel[k++]='O'; else tel[k++]='O'; tel[k++] = ' ' ; if ( buf[vruta-1]=='T' && buf[vruta+1]=='4' && buf[vruta+2]=='3' && isdigit(buf[vestac]) && cont==8) tel[k++]='*'; else if ( buf[vruta-1]=='T' && buf[vruta+1]=='4' && buf[vruta+2]=='4' && isdigit(buf[vestac]) && cont==8) { for(j=0;cuf[vtranf+2+j]!='X';j++) tel[k++]=cuf[vtranf+2+j]; } else if (acep_seg && entrante && isdigit(cuf[vtranf+24])) { for(j=0;cuf[vtranf+24+j]!='X';j++) tel[k++]=cuf[vtranf+24+j]; } else if(buf[vtranf]=='E' && encuentra==1 && reg[m][vtranf]=='S') //NUMERO { h=strlen(reg[m]); //numero transferido for(j=0;(vnumero+j)0 && !isdigit(buf[vestac]) && !isdigit(buf[ruta-1])) tel[k++]='R'; else tel[k++] = '*' ; if(encuentra==1 && (buf[vtranf]=='N' || buf[vtranf]=='E')) {reg[m][vtranf]='U';reg[m][vestac+1]='U';reg[m][vruta]='U';} tel[k++] = '\r' ; tel[k++] = '\n' ; tel[k++] = '\0' ; if(tandem==1 && !isdigit(buf[vestac]) && !isdigit(buf[ruta-1])) { gua_rut(tel); for (j=0;j