Blame


1 7b19e0f1 2017-11-05 stsp /*
2 a1fd68d8 2018-01-12 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 7b19e0f1 2017-11-05 stsp *
4 7b19e0f1 2017-11-05 stsp * Permission to use, copy, modify, and distribute this software for any
5 7b19e0f1 2017-11-05 stsp * purpose with or without fee is hereby granted, provided that the above
6 7b19e0f1 2017-11-05 stsp * copyright notice and this permission notice appear in all copies.
7 7b19e0f1 2017-11-05 stsp *
8 7b19e0f1 2017-11-05 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 7b19e0f1 2017-11-05 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 7b19e0f1 2017-11-05 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 7b19e0f1 2017-11-05 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 7b19e0f1 2017-11-05 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 7b19e0f1 2017-11-05 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 7b19e0f1 2017-11-05 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 7b19e0f1 2017-11-05 stsp */
16 7b19e0f1 2017-11-05 stsp
17 68482ea3 2017-11-27 stsp struct got_zstream_buf {
18 68482ea3 2017-11-27 stsp z_stream z;
19 68482ea3 2017-11-27 stsp char *inbuf;
20 68482ea3 2017-11-27 stsp size_t inlen;
21 68482ea3 2017-11-27 stsp char *outbuf;
22 68482ea3 2017-11-27 stsp size_t outlen;
23 68482ea3 2017-11-27 stsp int flags;
24 68482ea3 2017-11-27 stsp #define GOT_ZSTREAM_F_HAVE_MORE 0x01
25 68482ea3 2017-11-27 stsp };
26 68482ea3 2017-11-27 stsp
27 11995603 2017-11-05 stsp struct got_object_id {
28 4027f31a 2017-11-04 stsp u_int8_t sha1[SHA1_DIGEST_LENGTH];
29 4027f31a 2017-11-04 stsp };
30 d71d75ad 2017-11-05 stsp
31 d1cda826 2017-11-06 stsp struct got_blob_object {
32 68482ea3 2017-11-27 stsp FILE *f;
33 68482ea3 2017-11-27 stsp struct got_zstream_buf zb;
34 7d283eee 2017-11-29 stsp size_t hdrlen;
35 eb651edf 2018-02-11 stsp size_t blocksize;
36 eb651edf 2018-02-11 stsp uint8_t *read_buf;
37 eb651edf 2018-02-11 stsp int flags;
38 eb651edf 2018-02-11 stsp #define GOT_BLOB_F_COMPRESSED 0x01
39 f78b0693 2017-11-29 stsp struct got_object_id id;
40 d1cda826 2017-11-06 stsp };
41 d1cda826 2017-11-06 stsp
42 0ffeb3c2 2017-11-26 stsp struct got_tree_entry {
43 0ffeb3c2 2017-11-26 stsp SIMPLEQ_ENTRY(got_tree_entry) entry;
44 0ffeb3c2 2017-11-26 stsp mode_t mode;
45 0ffeb3c2 2017-11-26 stsp char *name;
46 0ffeb3c2 2017-11-26 stsp struct got_object_id id;
47 0ffeb3c2 2017-11-26 stsp };
48 0ffeb3c2 2017-11-26 stsp
49 d1cda826 2017-11-06 stsp struct got_tree_object {
50 0ffeb3c2 2017-11-26 stsp int nentries;
51 0ffeb3c2 2017-11-26 stsp SIMPLEQ_HEAD(, got_tree_entry) entries;
52 d1cda826 2017-11-06 stsp };
53 d1cda826 2017-11-06 stsp
54 d1cda826 2017-11-06 stsp struct got_parent_id {
55 d1cda826 2017-11-06 stsp SIMPLEQ_ENTRY(got_parent_id) entry;
56 d1cda826 2017-11-06 stsp struct got_object_id id;
57 d1cda826 2017-11-06 stsp };
58 d1cda826 2017-11-06 stsp
59 d1cda826 2017-11-06 stsp SIMPLEQ_HEAD(got_parent_id_list, got_parent_id);
60 d1cda826 2017-11-06 stsp
61 d1cda826 2017-11-06 stsp struct got_commit_object {
62 d1cda826 2017-11-06 stsp struct got_object_id tree_id;
63 d1cda826 2017-11-06 stsp unsigned int nparents;
64 d1cda826 2017-11-06 stsp SIMPLEQ_HEAD(, got_parent_id) parent_ids;
65 d1cda826 2017-11-06 stsp char *author;
66 d1cda826 2017-11-06 stsp char *committer;
67 d1cda826 2017-11-06 stsp char *logmsg;
68 d1cda826 2017-11-06 stsp };
69 d1cda826 2017-11-06 stsp
70 eef6493a 2018-01-19 stsp struct got_object;
71 9b1d5162 2017-12-03 stsp #define GOT_OBJ_TYPE_COMMIT 1
72 9b1d5162 2017-12-03 stsp #define GOT_OBJ_TYPE_TREE 2
73 9b1d5162 2017-12-03 stsp #define GOT_OBJ_TYPE_BLOB 3
74 9b1d5162 2017-12-03 stsp #define GOT_OBJ_TYPE_TAG 4
75 f9a4270b 2017-12-03 stsp /* 5 is reserved */
76 9b1d5162 2017-12-03 stsp #define GOT_OBJ_TYPE_OFFSET_DELTA 6
77 9b1d5162 2017-12-03 stsp #define GOT_OBJ_TYPE_REF_DELTA 7
78 ab9a70b2 2017-11-06 stsp
79 ab9a70b2 2017-11-06 stsp struct got_repository;
80 ab9a70b2 2017-11-06 stsp
81 a1fd68d8 2018-01-12 stsp char *got_object_id_str(struct got_object_id *, char *, size_t);
82 a1fd68d8 2018-01-12 stsp int got_object_id_cmp(struct got_object_id *, struct got_object_id *);
83 b107e67f 2018-01-19 stsp int got_object_get_type(struct got_object *);
84 ab9a70b2 2017-11-06 stsp const struct got_error *got_object_open(struct got_object **,
85 ab9a70b2 2017-11-06 stsp struct got_repository *, struct got_object_id *);
86 ab9a70b2 2017-11-06 stsp void got_object_close(struct got_object *);
87 d1cda826 2017-11-06 stsp const struct got_error *got_object_commit_open(struct got_commit_object **,
88 d1cda826 2017-11-06 stsp struct got_repository *, struct got_object *);
89 d1cda826 2017-11-06 stsp void got_object_commit_close(struct got_commit_object *);
90 0ffeb3c2 2017-11-26 stsp const struct got_error *got_object_tree_open(struct got_tree_object **,
91 0ffeb3c2 2017-11-26 stsp struct got_repository *, struct got_object *);
92 0ffeb3c2 2017-11-26 stsp void got_object_tree_close(struct got_tree_object *);
93 68482ea3 2017-11-27 stsp const struct got_error *got_object_blob_open(struct got_blob_object **,
94 68482ea3 2017-11-27 stsp struct got_repository *, struct got_object *, size_t);
95 68482ea3 2017-11-27 stsp void got_object_blob_close(struct got_blob_object *);
96 eb651edf 2018-02-11 stsp const struct got_error *got_object_blob_read_block(size_t *,
97 eb651edf 2018-02-11 stsp struct got_blob_object *);