crc.h

/** @file crc.h
 *  @date April 24, 2009
 */

#ifndef CRC_H_
#define CRC_H_

/** Calculate a CRC for a file stream.  The function seeks to the start of
 *  the stream and then calculates the CRC until the end of the stream.
 *
 *  @param file The file pointer.
 *  @param result The CRC output.
 *
 *  @return EXIT_SUCCESS or EXIT_FAILURE.
 */
extern int crc_file(FILE * file, u_long * result);

/** Returns an initialized CRC value.  This should be called before calling
 *  crc_update and finally crc_reslut.
 *
 *  @return The initialized CRC value.
 */
extern u_long crc_init(void);

/** Return a final value for a CRC.  The function should be called after
 *  calling crc_init and crc_update some number of times.
 *
 *  @param value The last value returned from crc_update.
 *
 *  @return The final CRC value.
 */
extern u_long crc_result(u_long value);

/** Returns an updated CRC value.  The value is updated based on the values in
 *  the buffer.  This function should be called after crc_init.
 *
 *  @param current The current or initial CRC.
 *  @param buffer The buffer of dat.
 *  @param size The size of the buffer.
 *
 *  @return The updated CRC value.
 */
extern u_long crc_update(u_long current, const void * buffer, size_t size);

#endif /* CRC_H_ */
Valid HTML 4.01 Valid CSS