🌐 AI搜索 & 代理 主页
blob: 6a7967c6bf604076c7d68ce139f65f34df3bc30e [file] [log] [blame]
Linus Torvaldsc38138c2005-06-27 03:27:561#ifndef CSUM_FILE_H
2#define CSUM_FILE_H
3
Nicolas Pitre2a128d62007-10-30 21:06:214struct progress;
5
Linus Torvaldsc38138c2005-06-27 03:27:566/* A SHA1-protected file */
7struct sha1file {
Nicolas Pitreec640ed2007-11-05 03:54:508 int fd;
Junio C Hamanoe337a042011-02-03 01:29:019 int check_fd;
Nicolas Pitreec640ed2007-11-05 03:54:5010 unsigned int offset;
Nicolas Pitre9126f002008-10-01 18:05:2011 git_SHA_CTX ctx;
Nicolas Pitre218558a2007-11-05 03:15:4112 off_t total;
Nicolas Pitre2a128d62007-10-30 21:06:2113 struct progress *tp;
Nicolas Pitreec640ed2007-11-05 03:54:5014 const char *name;
Nicolas Pitre78d1e842007-04-09 05:06:3115 int do_crc;
16 uint32_t crc32;
Linus Torvaldsc38138c2005-06-27 03:27:5617 unsigned char buffer[8192];
18};
19
Linus Torvalds4c81b032008-05-30 15:42:1620/* sha1close flags */
21#define CSUM_CLOSE 1
22#define CSUM_FSYNC 2
23
Linus Torvalds4397f012005-06-28 18:10:0624extern struct sha1file *sha1fd(int fd, const char *name);
Junio C Hamanoe337a042011-02-03 01:29:0125extern struct sha1file *sha1fd_check(const char *name);
Nicolas Pitre2a128d62007-10-30 21:06:2126extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp);
Linus Torvalds4c81b032008-05-30 15:42:1627extern int sha1close(struct sha1file *, unsigned char *, unsigned int);
Linus Torvaldsc38138c2005-06-27 03:27:5628extern int sha1write(struct sha1file *, void *, unsigned int);
Nicolas Pitre838cd342008-10-10 02:08:5129extern void sha1flush(struct sha1file *f);
Nicolas Pitre78d1e842007-04-09 05:06:3130extern void crc32_begin(struct sha1file *);
31extern uint32_t crc32_end(struct sha1file *);
Linus Torvaldsc38138c2005-06-27 03:27:5632
33#endif