#define americano 0 #define europeo 1 #define lmax 200 // 200 #define posin 18 #define estac 9+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 57+posin #define cuenta 57+posin #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 100 // 100 #define clid_tena 24+posin #define clid_only 2+posin #define l_ruta 3 #define l_esta 7 #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 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], lgua[lmax+3]; int pry_max,num_max,cue_max; /* agregar proyecto */ void agr_pry(int est,int lin,int rut,int pry, char *buf,TPRY *pry_cod, int *pry_max) { int i,j ; i = 0; 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<7 && buf[pest+i]!=' ';i++) { if(!isalnum(buf[pest+i])) return(0) ; tel[k++] = buf[pest+i]; } } else { BOOL bonly=FALSE, btena=FALSE; if (strlen(cuf)>clid_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'; i++) if (i<=5) { for (it=clid_only;it<(clid_only+5) && isdigit(cuf[it]) ; it++) tel[k++] = cuf[it] ; } else { tel[k++] = '*' ; } } else if (btena) { j=0; while (cuf[clid_tena+j]!='X' && cuf[clid_tena+j]!='\r' && cuf[clid_tena+j]!='\n' && cuf[clid_tena+j]!='\0') j++; if (j<=5) { for (it=clid_tena;it<(clid_tena+5) && isdigit(cuf[it]) ; it++) tel[k++] = cuf[it] ; } else if (j>5 && buf[posin+9]=='T' && buf[posin+17]=='A' && buf[ppri]=='A') { for (it=ppri+6; buf[it]!='\r' && buf[it]!='\n' && buf[it]!='\0'; it++) { if isdigit(buf[it]) tel[k++] = buf[it] ; } } else tel[k++] = '*' ; } } tel[k++] = ' ' ; if (plin>0) { 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++] = ' ' ; /***************/ if (buf[posin+9]=='T' && buf[prut-1]=='A' && isdigit(buf[prut])) ptip ='T' ; else if (buf[posin+9]=='A' && buf[posin+17]=='T' && ptip=='I' )//&&isdigit(buf[prut]) ) ptip ='T' ; 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(plin,prut,spry,scue,it,atip,buf,num_tra,num_max) ; ka=k ; if (buf[it]=='A') it = it+2; if (buf[posin+9]=='T' && buf[posin+17]=='A') { for (it=posin+21; cuf[it]!='\r' && cuf[it]!='\n' && cuf[it]!='\0'&& cuf[it]!='X'; it++) { if (isdigit(cuf[it])) tel[k++] = cuf[it] ; } } else { for (; it<(pnum+23) && buf[it]!='\r' && buf[it]!='\n' && buf[it]!=' ' && buf[it]!='\0'; it++) if (isdigit(buf[it]) || buf[it]=='T' || buf[it]=='N') tel[k++] = buf[it] ; } if (ka==k) { BOOL bonly=FALSE, btena=FALSE; if (strlen(cuf)>clid_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) { 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++] = ' ' ; tel[k++] = '0' ; tel[k++] = '0' ; tel[k++] = ':' ; tel[k++] = '0' ; tel[k++] = '0' ; /* tiempo ring */ tel[k++] = ' ' ; tel[k++] = '*' ; // anexo transferido tel[k++] = '\r' ; tel[k++] = '\n' ; tel[k++] = '\0' ; return(1) ; } void posi_fe(int *fech_N_s,int *hor_N_s,int *dur_N_s,int *pri_N_s,int *num_N_s,int vhor,int vdur,int vpri,int vnum, char *buf) { int i,largo; largo = strlen(buf); largo--; if (largo<(posin+40)){ int pred=posin; if (largolargo) *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-8; if ((buf[posin]=='A' || buf[posin]=='C') && (*dur_N_s+1)>largo) *dur_N_s=largo; if ((*pri_N_s+2)>largo) *pri_N_s=largo; if ((*num_N_s+2)>largo) *num_N_s=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])) ; } int cif(int cond,int cov, int cof) { if (cond) return(cov) ; else return(cof) ; } 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 ; int i,li,j,k,largo ; char lla_ent,lla_sal,lla_rut,lla_tra ; int fech_N_s,hor_N_s,dur_N_s,num_N_s,pri_N_s ; char aux; BOOL alfabuf, alfacuf; aux = 0; cuf = ruf ; _fmode = O_BINARY ; lla_sal =0 ; lla_ent=0 ; lla_rut=0 ; lla_tra=0 ; rec_buf(cuf,&i); if (strlen(buf)>(posin+40)) alfabuf = isalpha(buf[posin]); else alfabuf = FALSE; if (strlen(cuf)>(posin+40)) alfacuf = isalpha(cuf[posin]); else alfacuf = FALSE; if (alfacuf && alfabuf) { char *tmp; BOOL talf; gua_buf(buf); largo = i; tmp=(char *)buf; buf=(char *)cuf; cuf=(char *)tmp; talf = alfabuf ; alfabuf = alfacuf ; alfacuf = talf; j=strlen(cuf); for(k=0;k<(j-1);k++) cuf[k]=' ' ; cuf[k]='\0' ; } else if (alfacuf && !alfabuf) { char *tmp; BOOL talf; largo = i; if ( strlen(buf) > (posin+5) ) { tmp=(char *)buf; buf=(char *)cuf; cuf=(char *)tmp; talf = alfabuf ; alfabuf = alfacuf ; alfacuf = talf; j=strlen(cuf); if (j<=clid_only) { for(k=0;k<(j-1);k++) { cuf[k]=' ' ; cuf[k]='\0' ; } } gua_buf("\r"); } } else { int j=strlen(buf); largo = 0; if ( j > (posin+5) ) gua_buf(buf); for(k=0;k<(j-1);k++) buf[k]=' ' ; buf[k]='\0' ; } if ( largo>(40+posin) && alfabuf ) { posi_fe(&fech_N_s,&hor_N_s,&dur_N_s,&pri_N_s,&num_N_s,vhor,vdurac,vprinum,vnumero,buf) ; 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) ; aux = 0; 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') && (isdigit(buf[vestac]) || (buf[vestac]=='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') && (isdigit(buf[vruta-1]) || (buf[vruta-1]=='A' && buf[vruta]=='T')) && ((buf[vestac]=='T' || buf[vestac]=='A') && isdigit(buf[vestac+3])) ; lla_rut = (buf[posin]=='N' || buf[posin]=='E' || buf[posin]=='S') && ((buf[vestac]=='T' || buf[vestac]=='A') && isdigit(buf[vestac+1])) && ((buf[vruta-1]=='A' || buf[vruta-1]=='T') && isdigit(buf[vruta])) ; lla_tra = buf[posin]=='L' && (isdigit(buf[vestac]) || (buf[vestac]=='A' && buf[vestac+1]=='T')) && (isdigit(buf[vruta-1]) || (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(cif(buf[vestac]=='A',vestac+2,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