#define americano 0 #define europeo 1 #define lmax 200 // 200 #define posin 18 #define estac 11+posin #define linea 21+posin #define durac 10 #define hor 4 #define fech 21+posin #define tranf 30+posin #define numero 20 #define ccost 0 #define proye 69+posin #define cuenta 0 #define pulsos 0 #define ruta 18+posin #define prinum 19 #define ring 0 #define antran 0 // anexo transferido #define fofech americano #define ladat 82+posin #define pry_num 180 // 100 #define clid_tena 24+posin #define clid_only 2+posin #define l_ruta 3 #define l_esta 6 #define l_proy 8 #define l_line 3 #define l_nume 23 #define l_cuen 15 typedef struct { char est[l_esta],lin[l_line],rut[l_ruta],pry[l_proy] ; } TPRY; typedef struct { char est[l_esta],lin[l_line],rut[l_ruta],cue[l_cuen] ; } TCUE; typedef struct { char est[l_esta],lin[l_line],rut[l_ruta],pry[l_proy],cue[l_cuen],num[l_nume],tip ; } TNUM; extern void gua_rut(char *buf); TPRY pry_cod[pry_num+3]; TCUE cue_cod[pry_num+3]; TNUM num_tra[pry_num+3]; char ruf[lmax+3],tuf[lmax+3], lgua[lmax+3], lineas[3][lmax+3]; int pry_max,num_max,cue_max,cont_buf=0; BOOL hubo_comienzo = FALSE; /* agregar proyecto */ void agr_pry(int est,int lin,int rut,int pry, char *buf,TPRY *pry_cod, int *pry_max) { int i,j ; pry = pry+12; if (*pry_max=pry_num) { for(j=0;j<(*pry_max-1);j++) { for (i=0;i=pry_num) { for(j=0;j<(*cue_max-1);j++) { for (i=0;i=pry_num) { for(j=0;j<(*num_max-1);j++) { for (i=0;i0) { for (i=0;i<9 && buf[pest+i]!=' ' && iclid_only+7) bonly = isdigit(cuf[clid_only]); if (strlen(cuf)>clid_tena+7) btena = isdigit(cuf[clid_tena]); if (bonly) { // i = 0; // for (i=clid_only;cuf[i]!='X'&& cuf[i]!='\r' && cuf[i]!='\n' && cuf[i]!='\0' && i5 && buf[posin+9]=='T' && buf[posin+17]=='T' && buf[ppri]=='A') { for (it=ppri+6; buf[it]!='\r' && buf[it]!='\n' && buf[it]!='\0' && it < largob; it++) { if isdigit(buf[it]) tel[k++] = buf[it] ; } } else tel[k++] = '*' ; } else { tel[k++] = '*' ; } } tel[k++] = ' ' ; if ((plin>0) && (buf[posin+17]=='T') && (ptip =='O')) { tel[k++] = buf[plin] ; tel[k++] = buf[plin+1] ; tel[k++] = buf[plin+2] ; } else if ((plin>0) && (buf[posin+17]=='T') && (ptip =='I')) { tel[k++] = buf[plin] ; tel[k++] = buf[plin+1] ; tel[k++] = buf[plin+2] ; } else if ((plin>0) && (buf[posin+17]!='T')) { tel[k++] = buf[plin] ; tel[k++] = buf[plin+1] ; tel[k++] = buf[plin+2] ; } else { tel[k++] = '*' ; tel[k++] = '*' ; tel[k++] = '*' ; } tel[k++] = ' ' ; if (buf[pdur+0]!=' ') tel[k++]=buf[pdur+0] ; else tel[k++]='0' ; if (buf[pdur+1]!=' ') tel[k++]=buf[pdur+1] ; else tel[k++]='0' ; tel[k++] = ':' ; if (buf[pdur+3]!=' ') tel[k++]=buf[pdur+3] ; else tel[k++]='0' ; if (buf[pdur+4]!=' ') tel[k++]=buf[pdur+4] ; else tel[k++]='0' ; tel[k++] = ':' ; if (buf[pdur+6]!=' ') tel[k++]=buf[pdur+6] ; else tel[k++]='0' ; if (buf[pdur+7]!=' ') tel[k++]=buf[pdur+7] ; else tel[k++]='0' ; tel[k++] = ' ' ; ka = k ; tel[k++] = buf[phor] ; tel[k++] = buf[phor+1] ; if (tel[ka]==' ') tel[ka]='0' ; tel[k++] = ':' ; tel[k++] = buf[phor+3] ; tel[k++] = buf[phor+4] ; tel[k++] = ' ' ; if (vfofech==americano) { tel[k++] = buf[pfec+0] ; tel[k++] = buf[pfec+1] ; tel[k++] = '/'; tel[k++] = buf[pfec+3] ; tel[k++] = buf[pfec+4] ; } else { tel[k++] = buf[pfec+3] ; tel[k++] = buf[pfec+4] ; tel[k++] = '/'; tel[k++] = buf[pfec+0] ; tel[k++] = buf[pfec+1] ; } tel[k++] = '/'; tel[k++] = buf[6] ; tel[k++] = buf[7] ; tel[k++] = ' ' ; tel[k++] = ptip ; tel[k++] = ' ' ; if (buf[ppri]=='A' || buf[ppri]=='E') it=pnum+1 ; else if (buf[ppri]=='C' && isdigit(buf[ppri+2])) it=pnum+1 ; else if (buf[ppri]=='C' && isalpha(buf[ppri+2])) it=pnum+3 ; else if (isdigit(buf[ppri]) && (pnum-ppri)==1 && isdigit(buf[pnum])) it=ppri; else it=pnum ; if (buf[posin]=='S') agr_num(pest,plin,prut,spry,scue,it,atip,buf,num_tra,num_max) ; ka=k ; if (((cuf[posin+30] =='X') || (cuf[posin+30] ==' ')) || (cuf[posin+1] =='&' ||cuf[posin+2] =='\r')) { for (; itclid_only+14) bonly = isdigit(cuf[clid_only]); if (strlen(cuf)>clid_tena+14) btena = isdigit(cuf[clid_tena]); if (buf[posin]=='E') { for(it=0;it0) && (buf[posin+17]=='T') && (ptip =='O' || ptip =='T')) { for (i=0;i<3 && buf[prut+i]!=':' && buf[prut+i]!='/';i++) ; if (buf[prut+i]==':' || buf[prut+i]=='/') return(0) ; tel[k++] = buf[prut] ; tel[k++] = buf[prut+1] ; tel[k++] = buf[prut+2] ; /* ruta */ } else if ((prut>0) && (buf[posin+17]=='T') && (ptip =='I')) { for (i=0;i<3 && buf[prut+i]!=':' && buf[prut+i]!='/';i++) ; if (buf[prut+i]==':' || buf[prut+i]=='/') return(0) ; tel[k++] = buf[prut] ; tel[k++] = buf[prut+1] ; tel[k++] = buf[prut+2] ; /* ruta */ } else if ((prut>0) && (buf[posin+17]!='T')) { for (i=0;i<3 && buf[prut+i]!=':' && buf[prut+i]!='/';i++) ; if (buf[prut+i]==':' || buf[prut+i]=='/') return(0) ; tel[k++] = buf[prut] ; tel[k++] = buf[prut+1] ; tel[k++] = buf[prut+2] ; /* ruta */ } else { tel[k++] = '*' ; tel[k++] = '*' ; tel[k++] = '*' ; } tel[k++] = ' ' ; if (isalnum(buf[ppri])) tel[k++] = buf[ppri] ; /* primer numero */ else tel[k++] = '*' ; tel[k++] = ' ' ; if (tuf[posin+4]==':') /* tiempo ring */ { for(j=0;j<5;j++) tel[k++]=tuf[posin+2+j]; } else { tel[k++] = '0'; tel[k++] = '0'; tel[k++] = ':'; tel[k++] = '0'; tel[k++] = '0'; } tel[k++] = ' ' ; if (buf[posin]!='E') tel[k++] = '*' ; // anexo transferido else { for (i=0;ilargo) *fech_N_s=largo-7; if ((*hor_N_s+7)>largo) *hor_N_s=largo-7; if ((buf[posin]!='A' && buf[posin]!='C') && (*dur_N_s+8)>largo) *dur_N_s=largo-5; if ((buf[posin]=='A' || buf[posin]=='C') && (*dur_N_s+1)>largo) *dur_N_s=largo+3; if ((*pri_N_s+2)>largo) *pri_N_s=6+largo; if ((*num_N_s+2)>largo) *num_N_s=6+largo; } void gua_buf(char *buf) { strcpy(lgua,buf); } /* retorna 1 -> OK */ int rec_buf(char *buf, int *numc) { strcpy(buf,lgua); *numc = strlen(buf); return (isalpha(buf[0])) ; } extern char rgua[]; void in_central() { lgua[0] = '\0'; rgua[0] = '\0'; ruf[0] = '\0'; abr_pry(pry_cod,&pry_max) ; abr_cue(cue_cod,&cue_max) ; abr_num(num_tra,&num_max) ; } void fi_central() { cer_pry(pry_cod,pry_max) ; cer_cue(cue_cod,cue_max) ; cer_num(num_tra,num_max) ; } 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 *cuf, *duf ; int i,li ; char lla_ent,lla_sal,lla_rut,lla_tra,aux ; int fech_N_s,hor_N_s,dur_N_s,num_N_s,pri_N_s ; BOOL primera_linea, otras_lineas, cambio_linea; cuf = ruf ; duf = tuf ; aux = 0; aux = strlen(buf); cuf = ruf ; duf = tuf ; _fmode = O_BINARY ; lla_sal =0 ; lla_ent=0 ; lla_rut=0 ; lla_tra=0 ; // detecta si es primera linea u otras lineas if (strlen(buf)>(posin+40)) primera_linea = isalpha(buf[posin]); else primera_linea = FALSE; aux = strlen(buf); if (strlen(buf)>(posin+1)) { if (buf[posin+1]=='&') otras_lineas = TRUE; } // incremento de contador de lineas if (primera_linea) { cont_buf = 0; cambio_linea = TRUE; } else if (hubo_comienzo && otras_lineas && cont_buf<2) { cont_buf++; cambio_linea = TRUE; } if (!hubo_comienzo) hubo_comienzo = primera_linea; if (cambio_linea && hubo_comienzo) strcpy(lineas[cont_buf],buf); if ( cont_buf==2 && hubo_comienzo) { cont_buf =0; hubo_comienzo = FALSE; strcpy(buf,lineas[0]); strcpy(cuf,lineas[1]); strcpy(duf,lineas[2]); posi_fe(&fech_N_s,&hor_N_s,&dur_N_s,&pri_N_s,&num_N_s,vhor,vdurac,vprinum,vnumero,buf) ; aux = 0; if (buf[posin]=='M') agr_pry(vestac,vlinea,vruta,pri_N_s,buf,pry_cod,&pry_max) ; if (buf[posin]=='C') agr_cue(vestac,vlinea,vruta,dur_N_s,buf,cue_cod,&cue_max) ; if (buf[posin]=='A') agr_pry(vestac,vlinea,vruta,dur_N_s,buf,pry_cod,&pry_max) ; lla_sal = (buf[posin]=='N' || buf[posin]=='E' || buf[posin]=='S') && ((buf[vestac-2]=='D' && buf[vestac-1]=='N') || (buf[vestac-2]=='A' && buf[vestac-1]=='T')) && ((buf[vruta-1]=='T' || buf[vruta-1]=='A') && isdigit(buf[vruta])) ; lla_ent = (buf[posin]=='N' || buf[posin]=='E' || buf[posin]=='S') && ((buf[vruta-1]=='D' && buf[vruta]=='N') || (buf[vruta-1]=='A' && buf[vruta]=='T')) && ((buf[vestac-2]=='T' || buf[vestac-2]=='A') && isdigit(buf[vestac-1])) ; lla_rut = (buf[posin]=='N' || buf[posin]=='E' || buf[posin]=='S') && ((buf[vestac-2]=='T' || buf[vestac-2]=='A') && isdigit(buf[vestac-1])) && ((buf[vruta-1]=='A' || buf[vruta-1]=='T') && isdigit(buf[vruta])) ; lla_tra = buf[posin]=='L' && ((buf[vestac-2]=='D' && buf[vestac-1]=='N') || (buf[vestac-2]=='A' && buf[vestac-1]=='T')) && ((buf[vruta-1]=='D' && buf[vruta]=='N') || (buf[vruta-1]=='A' && buf[vruta]=='T')) ; if (lla_sal && buf[fech_N_s+2]=='/' && buf[hor_N_s+2]==':' && buf[dur_N_s+2]==':' && buf[dur_N_s+5]==':') { if (!Tra_Cen(vestac,vlinea,vruta,dur_N_s,fech_N_s,hor_N_s,num_N_s,pri_N_s,'O',vfofech,buf,cuf,tel,pry_cod,&pry_max,num_tra,&num_max)) { for (i=0;i