#define americano 0 #define europeo 1 #define lmax 200 #define posin 18 #define ladat 132+posin #define estac 6+posin #define linea 11+posin #define durac 15+posin #define hor 30+posin//15+posin #define fech 21+posin//21+posin #define tranf 37+posin//30+posin #define numero 38+posin #define ccost 0 #define proye 0 #define cuenta 0 #define pulsos 0 #define ruta 0 #define prinum 0 #define ring 44+posin #define antran 0 // anexo transferido #define fofech europeo char reg[150][ladat]; char ani[150][50]; int aux=0,t=0,m=0,n=0,u=0,j,i,h,encuentra,encuentra_ani; extern char rgua[]; void in_central() { rgua[0]='\0'; } void fi_central() { } void busca_lin_ani(char *buf, int vlinea) { for(n=u;n>=0;n--) { if (buf[vlinea-6]==':' && ani[n][vlinea-9]==buf[vlinea-9] && ani[n][vlinea-8]==buf[vlinea-8]) //busqueda de ANI (reemplazo) {encuentra_ani=1; return;} //lineas+rutas iguales if (ani[n][vlinea-9]==buf[vlinea] && ani[n][vlinea-8]==buf[vlinea+1]) //busqueda de ANI {encuentra_ani=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_ani(char *buf, int vlinea) { busca_lin_ani(buf, vlinea); if (u==100) u=0; //cuando llega a los 100 registros guardados, reemplaza en el registro 0 if (!encuentra_ani) {n=u;u++;} for(j=0;j<=i;j++) ani[n][j]=buf[j]; } //compara la línea+fecha del registro actual (buf) con los registros anteriores (almacenados en el arreglo bidimencional) void busca_lin(char *buf, int vlinea) { for(m=t;m>=0;m--) { if (reg[m][vlinea]==buf[vlinea] && reg[m][vlinea+1]==buf[vlinea+1]) //busqueda de transferencia {encuentra=1; h=strlen(reg[m]); 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, int vlinea) { busca_lin(buf, vlinea); if (t==100) t=0; //cuando llega a los 100 registros guardados, reemplaza en el registro 0 if (!encuentra) {m=t;t++;} if (isdigit(buf[26])) {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,ka,cont; k=0;cont=0; encuentra=0; encuentra_ani=0; i=strlen(buf); //if (i>(vtranf-1) && buf[vfech+2]=='/' && buf[vhor+2]==':' && buf[vdurac+2]==':' && isalnum(buf[vtranf])) if (i>(vfech-3) && isdigit(buf[vestac+2])) { k = 0 ; if(buf[vestac-1]==':') {add_reg_ani (buf, vlinea); return;} //agrega ANI if(buf[vtranf ]!='O') busca_lin_ani(buf, vlinea); //busca ANI if (buf[vtranf]=='t' || buf[vtranf]=='T') busca_lin(buf, vlinea); //transferncias: busca por linea el anexo desde donde se transfirió else add_reg (buf, vlinea); // if (!isdigit(buf[vestac])) goto henry; if (i>(vtranf-1) && buf[vfech+2]=='/' && buf[vhor+2]==':' && buf[vdurac+2]==':' && isalnum(buf[vtranf])) { for (j=0;j<3;j++) tel[k++]=buf[vestac+j]; tel[k++]=' '; tel[k++]=buf[vlinea+0]; tel[k++]=buf[vlinea+1]; tel[k++]=' '; tel[k++]='0'; tel[k++]='0'; tel[k++]=':'; for(j=0;j<5;j++) tel[k++]=buf[vdurac+j]; tel[k++]=' '; ka = k ; for(j=0;j<5;j++) tel[k++]=buf[vhor+j]; tel[k++]=' '; if (fofech==americano) {tel[k++]=buf[vfech+3]; tel[k++]=buf[vfech+4]; tel[k++]='/'; tel[k++]=buf[vfech+0]; tel[k++]=buf[vfech+1]; tel[k++]='/'; tel[k++]=buf[vfech+6]; tel[k++]=buf[vfech+7];} else if ( fofech == europeo ) {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[vfech+6]; tel[k++]=buf[vfech+7];} tel[k++]=' '; if (buf[vtranf]=='t' && encuentra) tel[k++]=reg[m][vtranf]; //tipo else if (buf[vtranf]=='I' || buf[vtranf]=='H') tel[k++]='I'; else if (buf[vtranf]=='O') tel[k++]='O'; else if (buf[vtranf]=='T') tel[k++]='O'; else tel[k++]='*'; tel[k++] = ' ' ; if (encuentra_ani && buf[vnumero-1]!='T') { for (j=0;j<18 && ani[n][vestac+1+j]!=' ';j++) tel[k++]=ani[n][vestac+1+j]; } else if (isdigit(buf[vnumero]) && buf[vnumero-1]=='T') { for (j=0;j<18 && buf[vnumero+j]!=' ';j++) tel[k++]=buf[vnumero+j]; } else if (isdigit(buf[vnumero])) { for (j=0;j<18 && buf[vnumero+j]!=' ';j++) tel[k++]=buf[vnumero+j]; } else tel[k++]='*'; tel[k++]=' '; tel[k++]='*'; tel[k++]='*'; tel[k++]='*'; /* centro de costo */ tel[k++] = ' ' ; tel[k++] = '*' ; /* proyecto */ tel[k++] = ' ' ; tel[k++] = '*' ; tel[k++] = ' ' ; for (j=0;j<4;j++) tel[k++]='0' ; /* pulsos */ tel[k++] = ' ' ; tel[k++] = '*' ; tel[k++] = '*' ; tel[k++] = '*' ; /* ruta */ tel[k++] = ' ' ; tel[k++] = '*' ; /* primer numero */ tel[k++] = ' ' ; if (buf[vring-2]=='G') /* tiempo ring */ { for(j=0;j<5;j++) tel[k++]=buf[vring+j]; } else { tel[k++]='0'; tel[k++]='0'; tel[k++]=':'; tel[k++]='0'; tel[k++]='0'; } tel[k++] = ' ' ; if (buf[vtranf]=='t' || buf[vtranf]=='T' && encuentra) //anexo transferido { tel[k++]=reg[m][vestac]; tel[k++]=reg[m][vestac+1]; tel[k++]=reg[m][vestac+2]; } else tel[k++]='*'; tel[k++]=' '; if (buf[vtranf]=='t' || buf[vtranf]=='T') tel[k++]='T'; //servicio else tel[k++]='*'; // henry: tel[k++] = '\r'; tel[k++] = '\n'; tel[k++] = '\0'; } } }