🌐 AI搜索 & 代理 主页
blob: bb543d52f108cf1e976ee644e337f5ccec983790 [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
Junio C Hamano6c526142011-11-18 00:26:5420/* Checkpoint */
21struct sha1file_checkpoint {
22 off_t offset;
23 git_SHA_CTX ctx;
24};
25
26extern void sha1file_checkpoint(struct sha1file *, struct sha1file_checkpoint *);
27extern int sha1file_truncate(struct sha1file *, struct sha1file_checkpoint *);
28
Linus Torvalds4c81b032008-05-30 15:42:1629/* sha1close flags */
30#define CSUM_CLOSE 1
31#define CSUM_FSYNC 2
32
Linus Torvalds4397f012005-06-28 18:10:0633extern struct sha1file *sha1fd(int fd, const char *name);
Junio C Hamanoe337a042011-02-03 01:29:0134extern struct sha1file *sha1fd_check(const char *name);
Nicolas Pitre2a128d62007-10-30 21:06:2135extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp);
Linus Torvalds4c81b032008-05-30 15:42:1636extern int sha1close(struct sha1file *, unsigned char *, unsigned int);
Junio C Hamanof06a5e62014-01-10 18:33:0937extern void sha1write(struct sha1file *, const void *, unsigned int);
Nicolas Pitre838cd342008-10-10 02:08:5138extern void sha1flush(struct sha1file *f);
Nicolas Pitre78d1e842007-04-09 05:06:3139extern void crc32_begin(struct sha1file *);
40extern uint32_t crc32_end(struct sha1file *);
Linus Torvaldsc38138c2005-06-27 03:27:5641
42#endif