Linus Torvalds | c38138c | 2005-06-26 20:27:56 -0700 | [diff] [blame] | 1 | #ifndef CSUM_FILE_H |
| 2 | #define CSUM_FILE_H |
| 3 | |
Nicolas Pitre | 2a128d6 | 2007-10-30 17:06:21 -0400 | [diff] [blame] | 4 | struct progress; |
| 5 | |
Linus Torvalds | c38138c | 2005-06-26 20:27:56 -0700 | [diff] [blame] | 6 | /* A SHA1-protected file */ |
| 7 | struct sha1file { |
Nicolas Pitre | ec640ed | 2007-11-04 22:54:50 -0500 | [diff] [blame] | 8 | int fd; |
| 9 | unsigned int offset; |
Nicolas Pitre | 9126f00 | 2008-10-01 14:05:20 -0400 | [diff] [blame] | 10 | git_SHA_CTX ctx; |
Nicolas Pitre | 218558a | 2007-11-04 22:15:41 -0500 | [diff] [blame] | 11 | off_t total; |
Nicolas Pitre | 2a128d6 | 2007-10-30 17:06:21 -0400 | [diff] [blame] | 12 | struct progress *tp; |
Nicolas Pitre | ec640ed | 2007-11-04 22:54:50 -0500 | [diff] [blame] | 13 | const char *name; |
Nicolas Pitre | 78d1e84 | 2007-04-09 01:06:31 -0400 | [diff] [blame] | 14 | int do_crc; |
| 15 | uint32_t crc32; |
Linus Torvalds | c38138c | 2005-06-26 20:27:56 -0700 | [diff] [blame] | 16 | unsigned char buffer[8192]; |
| 17 | }; |
| 18 | |
Linus Torvalds | 4c81b03 | 2008-05-30 08:42:16 -0700 | [diff] [blame] | 19 | /* sha1close flags */ |
| 20 | #define CSUM_CLOSE 1 |
| 21 | #define CSUM_FSYNC 2 |
| 22 | |
Linus Torvalds | 4397f01 | 2005-06-28 11:10:06 -0700 | [diff] [blame] | 23 | extern struct sha1file *sha1fd(int fd, const char *name); |
Nicolas Pitre | 2a128d6 | 2007-10-30 17:06:21 -0400 | [diff] [blame] | 24 | extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp); |
Linus Torvalds | 4c81b03 | 2008-05-30 08:42:16 -0700 | [diff] [blame] | 25 | extern int sha1close(struct sha1file *, unsigned char *, unsigned int); |
Linus Torvalds | c38138c | 2005-06-26 20:27:56 -0700 | [diff] [blame] | 26 | extern int sha1write(struct sha1file *, void *, unsigned int); |
Nicolas Pitre | 78d1e84 | 2007-04-09 01:06:31 -0400 | [diff] [blame] | 27 | extern void crc32_begin(struct sha1file *); |
| 28 | extern uint32_t crc32_end(struct sha1file *); |
Linus Torvalds | c38138c | 2005-06-26 20:27:56 -0700 | [diff] [blame] | 29 | |
| 30 | #endif |