environment.h: move declarations for environment.c functions from cache.h
[alt-git.git] / reftable / reader.h
blobe869165f234bf05f0ab9f20a4e2288666baab7b0
1 /*
2 Copyright 2020 Google LLC
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file or at
6 https://developers.google.com/open-source/licenses/bsd
7 */
9 #ifndef READER_H
10 #define READER_H
12 #include "block.h"
13 #include "record.h"
14 #include "reftable-iterator.h"
15 #include "reftable-reader.h"
17 uint64_t block_source_size(struct reftable_block_source *source);
19 int block_source_read_block(struct reftable_block_source *source,
20 struct reftable_block *dest, uint64_t off,
21 uint32_t size);
22 void block_source_close(struct reftable_block_source *source);
24 /* metadata for a block type */
25 struct reftable_reader_offsets {
26 int is_present;
27 uint64_t offset;
28 uint64_t index_offset;
31 /* The state for reading a reftable file. */
32 struct reftable_reader {
33 /* for convience, associate a name with the instance. */
34 char *name;
35 struct reftable_block_source source;
37 /* Size of the file, excluding the footer. */
38 uint64_t size;
40 /* 'sha1' for SHA1, 's256' for SHA-256 */
41 uint32_t hash_id;
43 uint32_t block_size;
44 uint64_t min_update_index;
45 uint64_t max_update_index;
46 /* Length of the OID keys in the 'o' section */
47 int object_id_len;
48 int version;
50 struct reftable_reader_offsets ref_offsets;
51 struct reftable_reader_offsets obj_offsets;
52 struct reftable_reader_offsets log_offsets;
55 int init_reader(struct reftable_reader *r, struct reftable_block_source *source,
56 const char *name);
57 void reader_close(struct reftable_reader *r);
58 const char *reader_name(struct reftable_reader *r);
60 /* initialize a block reader to read from `r` */
61 int reader_init_block_reader(struct reftable_reader *r, struct block_reader *br,
62 uint64_t next_off, uint8_t want_typ);
64 #endif