#define americano 0 #define europeo 1 #define lmax 200 #define posin 18 #define ladat 82+posin #define estac 48+posin // llamadas entrantes #define linea 19+posin #define durac 6 +posin #define hor 0 +posin #define fech 0 #define tranf 14+posin #define numero 28+posin #define ccost 0 #define proye 60+posin #define cuenta 53+posin #define pulsos 0 #define ruta 0 #define prinum 0 #define ring 68+posin #define antran 0 // anexo transferido (pendiente) #define fofech europeo // formato de fecha #define larnum 18 extern void gua_rut(char *buf); char ruanex[(lmax+1)*2][7] ; /* Rutas Consideradas como Anexos */ extern char rgua[]; // Procesos Inicialiales (Inicializar Variables, Abrir // Archivos especiales, etc) void in_central() { rgua[0] = '\0'; } // Procesos de Finalización (Cerrar Archivos especiales, etc) void fi_central() { } void CalSeg(char cMin, char *cSeg) { int iSeg ; iSeg = ((int)cMin)*6 ; /* iSeg = ((int)cMin - 30)*6 ; */ itoa(iSeg,cSeg,10) ; if (iSeg<10) { cSeg[1] = cSeg[0] ; cSeg[0] = '0' ; cSeg[2] = '\0' ; } } void RegLla(char FAR *tel, char *buf, char cTipo, int pLinea, int pNumero, char *sAnexo, int vdurac, int vhor, int vfech, int vproye, int vcuenta, int vruta, int vring,int vfofech) { int i,k,ka,largo=strlen(buf) ; char cSeg[5] ; k = 0 ; for(i=0;i<4;) tel[k++] = sAnexo[i++] ; tel[k++] = ' ' ; tel[k++] = buf[pLinea] ; tel[k++] = buf[pLinea+1] ; tel[k++] = buf[pLinea+2] ; tel[k++] = ' ' ; tel[k++]='0' ; tel[k++]=buf[vdurac] ; tel[k++] = ':' ; tel[k++]=buf[vdurac+2] ; tel[k++]=buf[vdurac+3] ; tel[k++] = ':' ; CalSeg(buf[vdurac+5],cSeg) ; tel[k++] = cSeg[0] ; tel[k++] = cSeg[1] ; tel[k++] = ' ' ; tel[k++] = buf[vhor] ; tel[k++] = buf[vhor+1] ; tel[k++] = ':' ; tel[k++] = buf[vhor+3] ; tel[k++] = buf[vhor+4] ; tel[k++] = ' ' ; if (vfofech==americano) { 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] ; } else { 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[6] ; tel[k++] = buf[7] ; } tel[k++] = ' ' ; tel[k++] = cTipo ; tel[k++] = ' ' ; ka=k ; i=pNumero ; while( i<(pNumero+larnum) && i(vring+1)) { if (buf[vring]==' ' && buf[vring+1]==' ') { tel[k++] = '0' ; tel[k++] = '0' ; tel[k++] = ':' ; tel[k++] = '0' ; tel[k++] = '0' ; /* tiempo ring */ } else { tel[k++] = '0' ; tel[k++] = buf[vring] ; CalSeg(buf[vring+1],cSeg) ; tel[k++] = cSeg[0] ; tel[k++] = cSeg[1] ; } } else { tel[k++] = '0' ; tel[k++] = '0' ; tel[k++] = ':' ; tel[k++] = '0' ; tel[k++] = '0' ; /* tiempo ring */ } tel[k++] = ' ' ; tel[k++] = '*' ; /* anexo transf */ tel[k++] = '\r' ; tel[k++] = '\n' ; tel[k++] = '\0' ; } char fTipo(int vtranf, char *buf) { if (buf[vtranf]==' ' || buf[vtranf]=='O') return('O') ; if (buf[vtranf]=='I') return('I') ; return('X') ; } int fNumero(int vtranf, int vnumero, char *buf) { if (buf[vtranf]=='G') return(vnumero+4) ; if (buf[vtranf]!='I') return(vnumero) ; } int fLinea(int vtranf, int vlinea, int vestac, char *buf) { if (buf[vtranf]==' ') return(vlinea) ; if (buf[vtranf]=='I') return(vestac) ; } void pAnexo(char *sAnexo, int vtranf, int vnumero, int vestac, char *buf) { int i ; if(buf[vtranf]=='I') for(i=0;i<4;i++) sAnexo[i] = buf[vnumero+15+i] ; else for(i=0;i<4;i++) sAnexo[i] = buf[vestac+i] ; } // 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) { char cTipo, sAnexo[10]; int i; i = strlen(buf); if (i>30 && isdigit(buf[vhor]) && isdigit(buf[vdurac]) && isdigit(buf[vdurac+2]) && (cTipo=fTipo(vtranf, buf))!='X') { pAnexo(sAnexo,vtranf, vnumero, vestac, buf) ; if (cTipo!='R') RegLla(tel,buf, cTipo,fLinea(vtranf,vlinea,vestac,buf),fNumero(vtranf,vnumero,buf), sAnexo,vdurac,vhor,vfech,vproye,vcuenta,vruta,vring,vfofech) ; else { RegLla(tel,buf,'I',fLinea(vtranf,vlinea,vestac,buf),fNumero(vtranf,vnumero,buf),"****", vdurac,vhor,vfech,vproye,vcuenta,vruta,vring,vfofech) ; gua_rut(tel); RegLla(tel,buf,'O',fLinea(vtranf,vlinea,vestac,buf),fNumero(vtranf,vnumero,buf),"****", vdurac,vhor,vfech,vproye,vcuenta,vruta,vring,vfofech) ; } } }