#include #include #include #include main(int argc,char *argv[]){ char *a,*b,*c,*ind,ait[1024]; FILE *fpin,*fpout,*fi; int i,j,k,l1,m,n,ico1,ilin,iup; int c1,c2,c3,c4; a=(char *)malloc(strlen(argv[1]+2)); b=(char *)malloc(strlen(argv[2])+strlen(argv[1])+3); ind=(char *)malloc(strlen(argv[3])+1); strcpy(a,argv[1]); strtok(a,"eps"); strcat(a,"html"); strcpy(b,argv[2]); strcat(b,"/"); strcat(b,a); strcpy(ind,argv[3]); printf("in bar2\n"); printf("%s\n",a); printf("%s\n",b); fpin=fopen(argv[1],"r"); if (fpin==NULL) { printf("cant open input file\n"); fflush(NULL); return 1; } else { printf("opened %s successfully\n",argv[1]); fpout=fopen(b,"w"); if (fpout==NULL) { printf("cant open output\n"); fflush(NULL); return 1; } printf("opened %s successfully\n",b); fi=fopen(ind,"a"); if (fi==NULL) { printf("cant open index\n"); fflush(NULL); return 1; } printf("opened %s index successfully\n",ind); } c1=0; c2=0; do { c2=c1; c1=getc(fpin); if (c1==EOF){ printf("hit no fC in input\n"); fflush(NULL); return 1; } } while((c2!=102)||(c1!=67)); ilin=0; c1=0; c2=0; do { c2=c1; c1=getc(fpin); if (c1==EOF){ printf("hit EOF b4 EJ\n"); fflush(NULL); return 1; } if ((c1==40)&&(c2!=92)){ c3=0; c4=0; ilin++; ico1=0; do { c4=c3; c3=getc(fpin); if (c3==EOF) { printf("hit EOF b4 unescaped )\n"); fflush(NULL); return 1; } if ((c4==45)&&(c3!=41)) { ait[ico1]=c4; ico1++; /* putchar(c4); putc(c4,fpout); */ } if ((c4==72)&&(c3!=72)&&(c3!=32)&&(c3!=9)&&(c3!=41)){ ait[ico1]=c4; ico1++; /* putchar(c4); putc(c4,fpout); */ } else if((c4==72)&&((c3==32)||(c3==9))){ c3=72; } if ((c3!=92)&&(c3!=41)&&(c3!=45)&&(c3!=72)){ ait[ico1]=c3; ico1++; /* putchar(c3); putc(c3,fpout); */ } else if ((c3==41)&&(c4==92)){ ait[ico1]=c3; ico1++; /* putchar(c3); putc(c3,fpout); */ } else if ((c3==41)&&(c4!=45)){ ait[ico1]=32; ico1++; /* putchar(32); putc(32,fpout); */ } } while (((c4==92)||(c3!=41))&&(ico1<1024)); ait[ico1]=0; if(ilin==1) { fputs("",fpout); if (ait[ico1-1]==44){ ait[ico1-1]=32; } fputs("<H3 ALIGN=\"center\"><A HREF=\"http://philanet.com/news/classified/",fi); fputs(b,fi); fputs("\">",fi); fputs(ait,fi); fputs("</A></H3>",fi); fclose(fi); fputs(ait,fpout); fputs("",fpout); fputs("

",fpout); fputs(ait,fpout); fputs("

",fpout); fputs("

",fpout); } else { fputs(ait,fpout); printf(ait); } } } while((c2!='E')||(c1!='J')); printf("\n"); fclose(fpin); fputs("

\n

\n",fpout); fputs("

",fpout); fputs("Click to our \ homepage.
",fpout); fputs("",fpout); fclose(fpout); l1=unlink(argv[1]); printf("unlink returned %d\n",l1); free(a); free(b); fflush(NULL); printf("leaving bar2\n"); }