8 /* A SHA1-protected file */
19 unsigned char buffer
[8192];
23 struct hashfile_checkpoint
{
28 void hashfile_checkpoint(struct hashfile
*, struct hashfile_checkpoint
*);
29 int hashfile_truncate(struct hashfile
*, struct hashfile_checkpoint
*);
31 /* finalize_hashfile flags */
34 #define CSUM_HASH_IN_STREAM 4
36 struct hashfile
*hashfd(int fd
, const char *name
);
37 struct hashfile
*hashfd_check(const char *name
);
38 struct hashfile
*hashfd_throughput(int fd
, const char *name
, struct progress
*tp
);
39 int finalize_hashfile(struct hashfile
*, unsigned char *, unsigned int);
40 void hashwrite(struct hashfile
*, const void *, unsigned int);
41 void hashflush(struct hashfile
*f
);
42 void crc32_begin(struct hashfile
*);
43 uint32_t crc32_end(struct hashfile
*);
46 * Returns the total number of bytes fed to the hashfile so far (including ones
47 * that have not been written out to the descriptor yet).
49 static inline off_t
hashfile_total(struct hashfile
*f
)
51 return f
->total
+ f
->offset
;
54 static inline void hashwrite_u8(struct hashfile
*f
, uint8_t data
)
56 hashwrite(f
, &data
, sizeof(data
));
59 static inline void hashwrite_be32(struct hashfile
*f
, uint32_t data
)
62 hashwrite(f
, &data
, sizeof(data
));
65 static inline size_t hashwrite_be64(struct hashfile
*f
, uint64_t data
)
68 hashwrite(f
, &data
, sizeof(data
));