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