blob: 7e1339189dcdc6e271fad5df7ad427954642ae9e [file] [log] [blame]
Linus Torvaldsc38138c2005-06-26 20:27:56 -07001#ifndef CSUM_FILE_H
2#define CSUM_FILE_H
3
4/* A SHA1-protected file */
5struct sha1file {
6 int fd, error;
Linus Torvaldse1808842005-06-26 22:01:46 -07007 unsigned int offset, namelen;
Linus Torvaldsc38138c2005-06-26 20:27:56 -07008 SHA_CTX ctx;
Linus Torvaldse1808842005-06-26 22:01:46 -07009 char name[PATH_MAX];
Nicolas Pitre78d1e842007-04-09 01:06:31 -040010 int do_crc;
11 uint32_t crc32;
Linus Torvaldsc38138c2005-06-26 20:27:56 -070012 unsigned char buffer[8192];
13};
14
Linus Torvalds4397f012005-06-28 11:10:06 -070015extern struct sha1file *sha1fd(int fd, const char *name);
Timo Sirainen4ec99bf2005-08-09 18:30:22 +030016extern struct sha1file *sha1create(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
Linus Torvaldse1808842005-06-26 22:01:46 -070017extern int sha1close(struct sha1file *, unsigned char *, int);
Linus Torvaldsc38138c2005-06-26 20:27:56 -070018extern int sha1write(struct sha1file *, void *, unsigned int);
19extern int sha1write_compressed(struct sha1file *, void *, unsigned int);
Nicolas Pitre78d1e842007-04-09 01:06:31 -040020extern void crc32_begin(struct sha1file *);
21extern uint32_t crc32_end(struct sha1file *);
Linus Torvaldsc38138c2005-06-26 20:27:56 -070022
23#endif