Blob


1 /*
2 * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
17 struct got_object_id;
19 struct got_blob_object;
21 struct got_tree_entry {
22 SIMPLEQ_ENTRY(got_tree_entry) entry;
23 mode_t mode;
24 char *name;
25 struct got_object_id *id;
26 };
28 struct got_tree_object {
29 int nentries;
30 SIMPLEQ_HEAD(, got_tree_entry) entries;
31 };
33 struct got_parent_id {
34 SIMPLEQ_ENTRY(got_parent_id) entry;
35 struct got_object_id *id;
36 };
38 SIMPLEQ_HEAD(got_parent_id_list, got_parent_id);
40 struct got_commit_object {
41 struct got_object_id *tree_id;
42 unsigned int nparents;
43 SIMPLEQ_HEAD(, got_parent_id) parent_ids;
44 char *author;
45 char *committer;
46 char *logmsg;
47 };
49 struct got_object;
50 #define GOT_OBJ_TYPE_COMMIT 1
51 #define GOT_OBJ_TYPE_TREE 2
52 #define GOT_OBJ_TYPE_BLOB 3
53 #define GOT_OBJ_TYPE_TAG 4
54 /* 5 is reserved */
55 #define GOT_OBJ_TYPE_OFFSET_DELTA 6
56 #define GOT_OBJ_TYPE_REF_DELTA 7
58 struct got_repository;
60 char *got_object_id_str(struct got_object_id *, char *, size_t);
61 int got_object_id_cmp(struct got_object_id *, struct got_object_id *);
62 int got_object_get_type(struct got_object *);
63 const struct got_error *got_object_open(struct got_object **,
64 struct got_repository *, struct got_object_id *);
65 const struct got_error *got_object_open_by_id_str(struct got_object **,
66 struct got_repository *, const char *);
67 void got_object_close(struct got_object *);
68 const struct got_error *got_object_commit_open(struct got_commit_object **,
69 struct got_repository *, struct got_object *);
70 void got_object_commit_close(struct got_commit_object *);
71 const struct got_error *got_object_tree_open(struct got_tree_object **,
72 struct got_repository *, struct got_object *);
73 void got_object_tree_close(struct got_tree_object *);
74 const struct got_error *got_object_blob_open(struct got_blob_object **,
75 struct got_repository *, struct got_object *, size_t);
76 void got_object_blob_close(struct got_blob_object *);
77 char *got_object_blob_id_str(struct got_blob_object*, char *, size_t);
78 size_t got_object_blob_get_hdrlen(struct got_blob_object *);
79 const uint8_t *got_object_blob_get_read_buf(struct got_blob_object *);
80 const struct got_error *got_object_blob_read_block(size_t *,
81 struct got_blob_object *);