blob: 9e13342eb357d6427a208fc6777ea170eb55acb8 [file] [log] [blame]
Linus Torvaldsc38138c2005-06-26 20:27:56 -07001#ifndef CSUM_FILE_H
2#define CSUM_FILE_H
3
Nicolas Pitre2a128d62007-10-30 17:06:21 -04004struct progress;
5
Linus Torvaldsc38138c2005-06-26 20:27:56 -07006/* A SHA1-protected file */
7struct sha1file {
Nicolas Pitreec640ed2007-11-04 22:54:50 -05008 int fd;
9 unsigned int offset;
Nicolas Pitre9126f002008-10-01 14:05:20 -040010 git_SHA_CTX ctx;
Nicolas Pitre218558a2007-11-04 22:15:41 -050011 off_t total;
Nicolas Pitre2a128d62007-10-30 17:06:21 -040012 struct progress *tp;
Nicolas Pitreec640ed2007-11-04 22:54:50 -050013 const char *name;
Nicolas Pitre78d1e842007-04-09 01:06:31 -040014 int do_crc;
15 uint32_t crc32;
Linus Torvaldsc38138c2005-06-26 20:27:56 -070016 unsigned char buffer[8192];
17};
18
Linus Torvalds4c81b032008-05-30 08:42:16 -070019/* sha1close flags */
20#define CSUM_CLOSE 1
21#define CSUM_FSYNC 2
22
Linus Torvalds4397f012005-06-28 11:10:06 -070023extern struct sha1file *sha1fd(int fd, const char *name);
Nicolas Pitre2a128d62007-10-30 17:06:21 -040024extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp);
Linus Torvalds4c81b032008-05-30 08:42:16 -070025extern int sha1close(struct sha1file *, unsigned char *, unsigned int);
Linus Torvaldsc38138c2005-06-26 20:27:56 -070026extern int sha1write(struct sha1file *, void *, unsigned int);
Nicolas Pitre78d1e842007-04-09 01:06:31 -040027extern void crc32_begin(struct sha1file *);
28extern uint32_t crc32_end(struct sha1file *);
Linus Torvaldsc38138c2005-06-26 20:27:56 -070029
30#endif