/******************************************************************************
  cksum.h -- els checksum functions
  
  Author: Mark Baranowski
  Email:  requestXXX@els-software.org (remove XXX)
  Download: http://els-software.org

  Last significant change: October 6, 2003
  
  These functions are provided "as is" in the hopes that they might serve some
  higher purpose.  If you want these functions to serve some lower purpose,
  then that too is all right.  So as to keep these hopes alive you may
  freely distribute these functions so long as this header remains intact.
  You may also freely distribute modified versions of these functions so long
  as you indicate that such versions are modified and so long as you
  provide access to the unmodified original copy.
  
  Note: The most recent version of these functions may be obtained from
        http://els-software.org

  ****************************************************************************/

#ifndef ELS__CKSUM_H
#define ELS__CKSUM_H

typedef enum cksumType {
  CKSUM_UNSPECIFIED = 0,
  CKSUM_BSD,
  CKSUM_SYSV,
  CKSUM_POSIX,
  CKSUM_CRC32} cksumType;

extern char *cksumTypeToName(cksumType type);
extern Ulong cksumFile(char *filename, cksumType type);
extern Ulong cksumBsd(int fd);
extern Ulong cksumSysv(int fd);
extern Ulong cksumPosix(int fd);
extern Ulong cksumCrc32(int fd);

/* /usr/ucb/sum and /usr/bin/sum display 0 as the checksum if error occurs.
   /usr/bin/cksum displays (Ulong)-1 if error occurs.
   FIXME: what should crc32 display if error occurs? */
#define CKSUM_BSD_ERROR   0
#define CKSUM_SYSV_ERROR  0
#define CKSUM_POSIX_ERROR ((Ulong)-1)
#define CKSUM_CRC32_ERROR (0)

#endif /*ELS__CKSUM_H*/
