//////////////////////////////////////////////////////////////////////////// // // Author: Markus Diersbock // // Purpose: Parses weblog for pattern and outputs to file // if found. // // Created: 2001/10/27 // // Notes: Originally created for AAA to find intcampid's // // EXE: http://www.swingnote.com/getcode.php?name=prsweb.zip //////////////////////////////////////////////////////////////////////////// #include #include // Variables char infilename[256]; char outfilename[256]; char searchstring[51]; int verbose=0; // Functions bool checkline(const char *instring); int main(int args, char *argv[]) { char readline[1001]; FILE *infile; FILE *outfile; if (!(args > 3)) { printf("\n Usage: prsweb [/v]\n\n"); return -1; } strcpy(infilename, argv[1]); strcpy(outfilename, argv[2]); strcpy(searchstring, argv[3]); if (args==5) { if (strcmp(argv[4],"/v") > 0) verbose=1; } if ((infile = fopen(infilename,"r"))==NULL || (outfile = fopen(outfilename, "w"))==NULL) { printf("\nError opening file(s)!\n\n"); return -1; } // Get line and write if match while (!feof(infile)) { fgets(readline,sizeof(readline),infile); if ((checkline(readline))==true) { if (fputs(readline,outfile)==-1) { printf("Error writing to %s file!\n", outfilename); } } } if (fclose(infile)==-1 || fclose(outfile)==-1) { printf("\nError closing file(s)!\n\n"); return -1; } return 0; } bool checkline(const char *instring) { if (strstr(instring,searchstring) > 0) { if (verbose==1) printf("%s", instring); return true; } return false; }