]> git.ipfire.org Git - thirdparty/git.git/blobdiff - csum-file.h
csum-file: add hashwrite_be64()
[thirdparty/git.git] / csum-file.h
index a98b1eee53f40367ad06c7aa82da7af0ca6ed6bc..e54d53d1d0b3537b4fb4b0f22f9699cf38a2c3cf 100644 (file)
@@ -42,6 +42,15 @@ void hashflush(struct hashfile *f);
 void crc32_begin(struct hashfile *);
 uint32_t crc32_end(struct hashfile *);
 
+/*
+ * Returns the total number of bytes fed to the hashfile so far (including ones
+ * that have not been written out to the descriptor yet).
+ */
+static inline off_t hashfile_total(struct hashfile *f)
+{
+       return f->total + f->offset;
+}
+
 static inline void hashwrite_u8(struct hashfile *f, uint8_t data)
 {
        hashwrite(f, &data, sizeof(data));
@@ -53,4 +62,11 @@ static inline void hashwrite_be32(struct hashfile *f, uint32_t data)
        hashwrite(f, &data, sizeof(data));
 }
 
+static inline size_t hashwrite_be64(struct hashfile *f, uint64_t data)
+{
+       data = htonll(data);
+       hashwrite(f, &data, sizeof(data));
+       return sizeof(data);
+}
+
 #endif