/* Iulian Radu [v2.0@07.1999] */ int mkndx(char* file){ char tmp[257],xtmp[257],*ptmp; FILE *fcfg,*fndx; unsigned long ofs,xofs; /* open .cfg file */ if(cfgdir[0]) sprintf(tmp,"%s/%s",cfgdir,file); else strcpy(tmp,file); fcfg=fopen(tmp,"rt"); if(!fcfg){ fprintf(stderr,err[0],tmp); return 1;} /* check if file .cfg has length 0 */ if(fseek(fcfg,0,SEEK_END)){ fclose(fcfg); return 1;} if(!ftell(fcfg)){ fprintf(stderr,err[1],tmp); sprintf(xtmp,"rm -f %s",tmp); system(xtmp); return 1;} if(fseek(fcfg,0,SEEK_SET)) return 1; /* create de index file */ sprintf(tmp,"%s.ndx",extractfname(file)); fndx=fopen(tmp,"wb"); if(!fndx){ fclose(fcfg); return 1;} while(!feof(fcfg)){ xofs=ftell(fcfg); tmp[0]=0; fgets(tmp,256,fcfg); if((tmp[0]=='#') || (tmp[0]==0) || (tmp[0]=='\n')) continue; if(!strncmp(tmp,"Target[",7)) ofs=xofs; if(!strncmp(tmp,"Title[",6)){ ptmp=findnc(tmp,2,':'); trim(ptmp); fprintf(fndx,"%08ld %s\n",ofs,ptmp);} } fclose(fndx); fclose(fcfg); return 0; } void setPI(char* buf,unsigned long* pos,char** ifa){ sscanf(buf,"%08ld",pos); *ifa=buf+9; killnl(buf+9); } void gettarget(char* buf,char* target){ //word between [] int i; for(;buf[0]!='[';buf++); buf++; for(i=0;buf[0]!=']';buf++,i++) target[i]=buf[0]; target[i]=0; } char* findhost(char* buf){ int i; for(i=0;i

%s %s


\n",btxt[1],host); if(base[0]) fprintf(mkri[j][i],"
\n",base,target,base,target,txt[i]); else fprintf(mkri[j][i],"
\n",target,target,txt[i]); break;} } } convertname(host); /* change again the name, this time host var */ switch(conv){ case 1: //convip2name for(i=0;i<7;i++){ sprintf(tmp,"mv %s%s%s %s%s%s",mrtgoutpath,xtarget,xtxt[i],mrtgoutpath,host,xtxt[i]); system(tmp);} break; case 2: //convname2ip for(i=0;i<7;i++){ sprintf(tmp,"mv %s%s%s %s%s%s",mrtgoutpath,host,xtxt[i],mrtgoutpath,xtarget,xtxt[i]); system(tmp);} break; } }