#include #include #include #include FILE *fpi,*fpo,*fopen(); unsigned char *cp,last[2512],s[2512],s2[2512]; unsigned char *cp1,s3[2512],s4[2512]; unsigned char strtmp[2512]; unsigned char *ptr; char OutFile[1000]; char Day[10],Mon[10],Year[10]; char sysline[1000]; int i,j,k; int lc=0; #define TRUE 1 #define FALSE 0 void Bomb(char *msg) { printf("Error: %s\n",msg); exit(1); } main(argc,argv) int argc; unsigned char **argv; { int argk,c,state,ip; int posn; register char **p; argk = argc; if (argk < 2) { printf("usage: %s fn-in\n",argv[0]); exit(1); } p=argv; p++; --argk; printf("Opening %s\n",*p); fpi= fopen(*p,"r"); if (fpi==NULL) Bomb("Cannot open input file"); OutFile[0] = 0; fpo= fopen("tmp","w"); while (!feof(fpi)) { fgets(s,2511,fpi); if(feof(fpi))break; s[strlen(s)-1] = 0; lc++; if (strlen(s) == 0) continue; strcpy(s2,s); if (s[0] == '=') { if (strstr(s,"Date") == NULL) { printf("Bad Date at %d\n",lc); exit(1); } ptr = strtok(s2," "); ptr = strtok(NULL," "); ptr = strtok(NULL," "); ptr = strtok(NULL," "); strcpy(Day,ptr); ptr = strtok(NULL," "); strcpy(Mon,ptr); ptr = strtok(NULL," "); strcpy(Year,ptr); sprintf(strtmp,"subs%s-%s-%s.html",Year,Mon,Day); if (strlen(OutFile) == 0) strcpy(OutFile,strtmp); if (strcmp(OutFile,strtmp) == 0) { fprintf(fpo,"%s\n",s); continue; } fclose(fpo); sprintf(sysline,"cp htmlhdr %s",OutFile); system (sysline); sprintf(sysline,"echo \"

New Entries/Amendments for %s


\" >> %s",OutFile+4,OutFile);
		system (sysline);
		sprintf(sysline,"cat tmp >> %s",OutFile);
		system (sysline);
		sprintf(sysline,"cat htmlftr >> %s",OutFile);
		system (sysline);
  		fpo= fopen("tmp","w");
		strcpy(OutFile,strtmp);
	}
	fprintf (fpo,"%s\n",s);
  }
  fclose(fpi);
		fclose(fpo);
		sprintf(sysline,"cp htmlhdr %s",OutFile);
		system (sysline);
		sprintf(sysline,"echo \"

New Entries/Amendments for %s


\" >> %s",OutFile+4,OutFile);
		system (sysline);
		sprintf(sysline,"cat tmp >> %s",OutFile);
		system (sysline);
		sprintf(sysline,"cat htmlftr >> %s",OutFile);
		system (sysline);
}