Andrew Duane wrote: > I've never seen any such thing, but I've done similar things a > lot. I'd say malloc/read the whole file in and use a decrementing > pointer to return the "previous" character.
Thanks, but I'll need a loop too, as malloc(filesize()) would be too big, as I omitted to say I'll be running it from find, reading all files on system, including DVD images @ 4.7G. Some of my machines dont have that much swap, let alone RAM :-) Aside: I was doing inefficient things here with getchar() (while searching forward, for a one off run, (CPU cycles were cheaper than brain cycles, so it was easier to hack a pre-existing prog that used getchar() ). I was doing a search for (trailing) nulls blocks, from BSD tar silently zeroing data from bad media, per http://lists.freebsd.org/pipermail/freebsd-hackers/2011-January/034254.html http://www.freebsd.org/cgi/query-pr.cgi?pr=154407 http://berklix.com/~jhs/src/bsd/fixes/FreeBSD/src/gen/usr.bin/tar/ But my search logs from find with http://berklix.com/~jhs/src/bsd/jhs/bin/public/8f were too big, so I'll reduce by searching backward & only indexing on trailing nulls. Dan Nelson wrote: > You might even be able to write functions that could be passed to funopen(). > Then you'd have a regular FILE* that you could call with regular stdio > functions. Getting the buffering right for good performance might get > tricky, though. Thanks, I didnt know funopen, I'll read it again tomorrow morning :-) Thanks to Devin Teske re src/usr.bin/tail/, sorry in my first post I forgot to say binary. Brian Reichert wrote: > Use lseek() to position yourself, iterate over the file, copying into a > small buffer, then iterate over your buffer in reverse? Yes, thanks, better for efficiency, being lazy I had first wondered if there was some fopen_starting_from_tail() & getchar_starting_from_tail() I could just call for aone off run :-) Thanks all. Cheers, Julian -- Julian Stacey, BSD Unix Linux C Sys Eng Consultants Munich http://berklix.com Mail plain text; Not quoted-printable, Not HTML, Not base 64. Reply below text sections not at top, to avoid breaking cumulative context. _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"