9 #define CHUNK_TOC_ENTRY_SIZE (sizeof(uint32_t) + sizeof(uint64_t))
12 * Initialize a 'struct chunkfile' for writing _or_ reading a file
13 * with the chunk format.
15 * If writing a file, supply a non-NULL 'struct hashfile *' that will
18 * If reading a file, use a NULL 'struct hashfile *' and then call
19 * read_table_of_contents(). Supply the memory-mapped data to the
20 * pair_chunk() or read_chunk() methods, as appropriate.
22 * DO NOT MIX THESE MODES. Use different 'struct chunkfile' instances
23 * for reading and writing.
25 struct chunkfile
*init_chunkfile(struct hashfile
*f
);
26 void free_chunkfile(struct chunkfile
*cf
);
27 int get_num_chunks(struct chunkfile
*cf
);
28 typedef int (*chunk_write_fn
)(struct hashfile
*f
, void *data
);
29 void add_chunk(struct chunkfile
*cf
,
33 int write_chunkfile(struct chunkfile
*cf
, void *data
);
35 int read_table_of_contents(struct chunkfile
*cf
,
36 const unsigned char *mfile
,
40 unsigned expected_alignment
);
42 #define CHUNK_NOT_FOUND (-2)
45 * Find 'chunk_id' in the given chunkfile and assign the
46 * given pointer to the position in the mmap'd file where
47 * that chunk begins. Likewise the "size" parameter is filled
48 * with the size of the chunk.
50 * Returns CHUNK_NOT_FOUND if the chunk does not exist.
52 int pair_chunk(struct chunkfile
*cf
,
54 const unsigned char **p
,
57 typedef int (*chunk_read_fn
)(const unsigned char *chunk_start
,
58 size_t chunk_size
, void *data
);
60 * Find 'chunk_id' in the given chunkfile and call the
61 * given chunk_read_fn method with the information for
64 * Returns CHUNK_NOT_FOUND if the chunk does not exist.
66 int read_chunk(struct chunkfile
*cf
,
71 uint8_t oid_version(const struct git_hash_algo
*algop
);