THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

54 lines
1.3 KiB

  1. #ifndef CSUM_FILE_H
  2. #define CSUM_FILE_H
  3. struct progress;
  4. /* A SHA1-protected file */
  5. struct sha1file {
  6. int fd;
  7. int check_fd;
  8. unsigned int offset;
  9. git_SHA_CTX ctx;
  10. off_t total;
  11. struct progress *tp;
  12. const char *name;
  13. int do_crc;
  14. uint32_t crc32;
  15. unsigned char buffer[8192];
  16. };
  17. /* Checkpoint */
  18. struct sha1file_checkpoint {
  19. off_t offset;
  20. git_SHA_CTX ctx;
  21. };
  22. extern void sha1file_checkpoint(struct sha1file *, struct sha1file_checkpoint *);
  23. extern int sha1file_truncate(struct sha1file *, struct sha1file_checkpoint *);
  24. /* sha1close flags */
  25. #define CSUM_CLOSE 1
  26. #define CSUM_FSYNC 2
  27. extern struct sha1file *sha1fd(int fd, const char *name);
  28. extern struct sha1file *sha1fd_check(const char *name);
  29. extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp);
  30. extern int sha1close(struct sha1file *, unsigned char *, unsigned int);
  31. extern void sha1write(struct sha1file *, const void *, unsigned int);
  32. extern void sha1flush(struct sha1file *f);
  33. extern void crc32_begin(struct sha1file *);
  34. extern uint32_t crc32_end(struct sha1file *);
  35. static inline void sha1write_u8(struct sha1file *f, uint8_t data)
  36. {
  37. sha1write(f, &data, sizeof(data));
  38. }
  39. static inline void sha1write_be32(struct sha1file *f, uint32_t data)
  40. {
  41. data = htonl(data);
  42. sha1write(f, &data, sizeof(data));
  43. }
  44. #endif