A self-referential challenge

Leslie Mikesell les at chinet.chi.il.us
Mon Mar 27 13:42:16 AEST 1989


In article <6219 at bsu-cs.UUCP> dhesi at bsu-cs.UUCP (Rahul Dhesi) writes:
>consider the following problem.  The command

>     brik -G * > crc.lst

>generates a list of filenames and CRCs in crc.lst, which may be later checked
>with 

>     brik -C crc.lst

>This always reports a CRC error for "crc.lst" itself, since the CRC
>recorded for it was based on its contents before it was closed.  What I
>would like to do is find a way of having brik generate a CRC list that
>includes the corect CRC of the file containing that list. 

There are actually two problems here: finding the file where the
output is directed and making the CRC value correct.  Under unix
fstat() and stat() should let you check to see which file is your
output. If you remember what value you wrote for that file and
CRC all of your output you could just keep writing junk at the end
of the file until the CRC turned out to be correct.

Reminds me of a story I once heard about sales vs. service people:
  ...the salesmen tell the lies - the customer service people have
to make them come true.

Les Mikesell



More information about the Comp.lang.c mailing list