Blame


1 7b19e0f1 2017-11-05 stsp /*
2 7b19e0f1 2017-11-05 stsp * Copyright (c) 2017 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 d1cda826 2017-11-06 stsp };
36 d1cda826 2017-11-06 stsp
37 0ffeb3c2 2017-11-26 stsp struct got_tree_entry {
38 0ffeb3c2 2017-11-26 stsp SIMPLEQ_ENTRY(got_tree_entry) entry;
39 0ffeb3c2 2017-11-26 stsp mode_t mode;
40 0ffeb3c2 2017-11-26 stsp char *name;
41 0ffeb3c2 2017-11-26 stsp struct got_object_id id;
42 0ffeb3c2 2017-11-26 stsp };
43 0ffeb3c2 2017-11-26 stsp
44 d1cda826 2017-11-06 stsp struct got_tree_object {
45 0ffeb3c2 2017-11-26 stsp int nentries;
46 0ffeb3c2 2017-11-26 stsp SIMPLEQ_HEAD(, got_tree_entry) entries;
47 d1cda826 2017-11-06 stsp };
48 d1cda826 2017-11-06 stsp
49 d1cda826 2017-11-06 stsp struct got_parent_id {
50 d1cda826 2017-11-06 stsp SIMPLEQ_ENTRY(got_parent_id) entry;
51 d1cda826 2017-11-06 stsp struct got_object_id id;
52 d1cda826 2017-11-06 stsp };
53 d1cda826 2017-11-06 stsp
54 d1cda826 2017-11-06 stsp SIMPLEQ_HEAD(got_parent_id_list, got_parent_id);
55 d1cda826 2017-11-06 stsp
56 d1cda826 2017-11-06 stsp struct got_commit_object {
57 d1cda826 2017-11-06 stsp struct got_object_id tree_id;
58 d1cda826 2017-11-06 stsp unsigned int nparents;
59 d1cda826 2017-11-06 stsp SIMPLEQ_HEAD(, got_parent_id) parent_ids;
60 d1cda826 2017-11-06 stsp char *author;
61 d1cda826 2017-11-06 stsp char *committer;
62 d1cda826 2017-11-06 stsp char *logmsg;
63 d1cda826 2017-11-06 stsp };
64 d1cda826 2017-11-06 stsp
65 ab9a70b2 2017-11-06 stsp struct got_object {
66 ab9a70b2 2017-11-06 stsp int type;
67 ab9a70b2 2017-11-06 stsp #define GOT_OBJ_TYPE_COMMIT 1
68 ab9a70b2 2017-11-06 stsp #define GOT_OBJ_TYPE_TREE 2
69 ab9a70b2 2017-11-06 stsp #define GOT_OBJ_TYPE_BLOB 3
70 ab9a70b2 2017-11-06 stsp
71 d1cda826 2017-11-06 stsp size_t hdrlen;
72 ab9a70b2 2017-11-06 stsp size_t size;
73 ab9a70b2 2017-11-06 stsp struct got_object_id id;
74 ab9a70b2 2017-11-06 stsp };
75 ab9a70b2 2017-11-06 stsp
76 ab9a70b2 2017-11-06 stsp struct got_repository;
77 ab9a70b2 2017-11-06 stsp
78 d71d75ad 2017-11-05 stsp const char * got_object_id_str(struct got_object_id *, char *, size_t);
79 ab9a70b2 2017-11-06 stsp const struct got_error *got_object_open(struct got_object **,
80 ab9a70b2 2017-11-06 stsp struct got_repository *, struct got_object_id *);
81 ab9a70b2 2017-11-06 stsp void got_object_close(struct got_object *);
82 d1cda826 2017-11-06 stsp const struct got_error *got_object_commit_open(struct got_commit_object **,
83 d1cda826 2017-11-06 stsp struct got_repository *, struct got_object *);
84 d1cda826 2017-11-06 stsp void got_object_commit_close(struct got_commit_object *);
85 0ffeb3c2 2017-11-26 stsp const struct got_error *got_object_tree_open(struct got_tree_object **,
86 0ffeb3c2 2017-11-26 stsp struct got_repository *, struct got_object *);
87 0ffeb3c2 2017-11-26 stsp void got_object_tree_close(struct got_tree_object *);
88 68482ea3 2017-11-27 stsp const struct got_error *got_object_blob_open(struct got_blob_object **,
89 68482ea3 2017-11-27 stsp struct got_repository *, struct got_object *, size_t);
90 68482ea3 2017-11-27 stsp void got_object_blob_close(struct got_blob_object *);
91 68482ea3 2017-11-27 stsp const struct got_error *got_object_blob_read_block(struct got_blob_object *,
92 68482ea3 2017-11-27 stsp size_t *);