#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 37+posin #define hor 31+posin #define fech 25+posin #define tranf 0+posin #define numero 24+posin #define ccost 0 #define proye 37+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[300][ladat], *cuf, *ruf, lgua[lmax+3]; int aux,t,m,j,lb,lr,i,h,cont, encuentra, pos_anexo; //lb posicion de ruta+linea de buf int primera_OK, segunda_OK; aux=0; t=0; m=0; lb=0; i=0; h=0; cont=0; encuentra=0; primera_OK=0; segunda_OK=0; pos_anexo=0; //pos_anexo= posición de anexo 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 && isdigit(reg[m][pos_anexo+1+j]); j++){} if (j==6) lr=pos_anexo+1; //linea+ruta en origen else lr=pos_anexo+9; //línea+ruta en destino for(j=0; j<6 && reg[m][lr+j]==buf[lb+j]; j++) {} //compara lineas+rutas if (j==6) {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 vtranf, int vproye ) { char clave[6]; int largo_reg; busca_lin(buf); largo_reg = i; if (!encuentra) { m=t;t++; for(j=0;j<=i;j++) reg[m][j]=buf[j]; } else if (encuentra && reg[m][vtranf]=='A' ) { largo_reg = strlen(reg[m]); for(j=0;j<=6;j++) clave[j] = ' '; for(j=0;vproye+j<=largo_reg;j++) clave[j] = reg[m][vproye+j]; for(j=0;j<=i;j++) reg[m][j] = buf[j]; for(j=0;vproye+j<=largo_reg;j++) if (isdigit(clave[j])) reg[m][vproye+j]=clave[j]; } else { for(j=0;j<=i;j++) reg[m][j]=buf[j];} } void borrar_reg (char *buf) { int d; for(j=m;j<=t;j++) for(d=0;d<=ladat-1;d++) reg[j][d]=reg[j+1][d]; t--; } 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; int tandem; int opera_ori, opera_des, anexo_ori, anexo_des, tronc_ori, tronc_des; int trans_in, trans_out; opera_ori=0; opera_des=0; anexo_ori=0; anexo_des=0; tronc_ori=0; tronc_des=0; trans_in=0; trans_out=0; tandem=0; i=strlen(buf); pos_anexo=vestac; //posición anexo /*if (i>(vdurac+2) && isalpha(buf[vtranf]) && buf[vfech+2]=='/' && buf[vhor+2]==':') //primera línea válida { gua_buf(buf); cuf = lgua; primera_OK=1; return; } else if (i>(vestac+2) && isdigit(buf[vestac+3]) && isdigit(buf[ruta+2])) //segunda línea válida { ruf=cuf; cuf=buf; buf=ruf; //cuf->buf y buf->cuf segunda_OK=1; }*/ if (/*primera_OK /*&& segunda_OK && */ isalnum(buf[vtranf]) && buf[vtranf]!='Q' && buf[vtranf]!='R') { i=strlen(buf); primera_OK=0; segunda_OK=0; opera_ori = (buf[vestac] =='A' && buf[vestac+1]=='T'); //operadora en origen opera_des = (buf[vruta-1]=='A' && buf[vruta] =='T'); //operadora en destino anexo_ori = (isdigit(buf[vestac] ) && isdigit(buf[vestac+1])); //anexo en origen anexo_des = (isdigit(buf[vruta-1]) && isdigit(buf[vruta])); //anexo en destino tronc_ori = (isalpha(buf[vestac] ) && isdigit(buf[vestac+1])); //troncal en origen tronc_des = (isalpha(buf[vruta-1]) && isdigit(buf[vruta])); //troncal en destino tandem = (buf[vtranf]!='E' && tronc_ori && tronc_des); //llamadas troncal-troncal salto: aux=0; k=0; encuentra=0; //TRANSFERENCIAS if (tronc_ori) lb=vestac+1; //posicion de la línea buscada else lb=vruta; if (buf[vtranf]=='E' || buf[vtranf]=='N') busca_lin(buf); //transferencias: busca por linea el anexo desde donde se transfirió else if (buf[vtranf]=='S' || buf[vtranf]=='A') add_reg (buf,vtranf,vproye); if(buf[vtranf]=='A') return; trans_in = (encuentra && isalpha(reg[m][vestac]) && isdigit(reg[m][vestac+1])); //transferencia entrante trans_out = (encuentra && isalpha(reg[m][vruta-1]) && isdigit(reg[m][vruta])); //transferencia saliente if (tandem>0) tel[k++]='*'; //anexo else if (anexo_ori) { for (j=0;j<4;j++) if (isdigit(buf[vestac+j])) tel[k++]=buf[vestac+j]; } else if (opera_ori) { for (j=0;j<4;j++) if (isdigit(buf[vestac+2+j])) tel[k++]=buf[vestac+2+j]; } else if (anexo_des) { for (j=0;j<4;j++) if (isdigit(buf[vruta-1+j])) tel[k++]=buf[vruta-1+j]; } else if (opera_des) { for (j=0;j<4;j++) if (isdigit(buf[vruta+1+j])) tel[k++]=buf[vruta+1+j]; } else tel[k++]='*'; tel[k++]=' '; if (tronc_ori) //línea { for (j=0;j<3;j++) tel[k++]=buf[vestac+4+j]; } else if (tronc_des) { for (j=0;j<3;j++) tel[k++]=buf[vlinea+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 (trans_in && buf[vtranf]=='E') tel[k++]='I'; else if (trans_out && buf[vtranf]=='E') tel[k++]='O'; else if (anexo_ori) tel[k++]='O'; else if (anexo_des) tel[k++]='I'; else if (buf[vtranf]=='L') tel[k++]='T'; else tel[k++]='O'; tel[k++]=' '; /*if (tronc_ori && isdigit(cuf[vnumero+2]) && cuf[vnumero+14]=='X') //ANI { for(j=0;cuf[vnumero+j]!='X';j++) tel[k++]=cuf[vnumero+j]; } else*/ if(buf[vtranf]=='E' && encuentra && h>(vdurac+9)) //&& reg[m][vtranf]=='S') //numero transferido { for(j=0;(vdurac+9+j)