---

// quick&dirty offset seeker (c) 1994 by Rolf K. Wilms #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { if(argc != 3) { cout << "Usage: offset searchstring infile" << endl; exit(1); } ifstream in(open(argv[2], O_RDONLY|O_BINARY)); in.seekg(0); char *line, *p = NULL, buffer[4096]; unsigned int pos = 0, len; do { line = NULL; in.gets(&line, 0); len = strlen(line); if(line != NULL) { p = strstr(line, argv[1]); if(line != buffer) free(line); if(p != NULL) break; } pos += len+1; } while(in.good); in.close(); if(p != NULL) { cout << (pos + p - line); } else { cout << "no match"; exit(1); } exit(0); }

---

The views and opinions stated within this web page are those of the author or authors which wrote them and may not reflect the views and opinions of the ISP or account user which hosts the web page. The opinions may or may not be those of the Chairman of The Skeptic Tank.

Return to The Skeptic Tank's main Index page.

E-Mail Fredric L. Rice / The Skeptic Tank