]>
git.proxmox.com Git - libgit2.git/blob - include/git2/odb_backend.h
2 * Copyright (C) 2009-2012 the libgit2 contributors
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
7 #ifndef INCLUDE_git_odb_backend_h__
8 #define INCLUDE_git_odb_backend_h__
15 * @file git2/backend.h
16 * @brief Git custom backend functions
17 * @defgroup git_backend Git custom backend API
23 struct git_odb_stream
;
25 /** An instance for a custom backend */
26 struct git_odb_backend
{
30 void **, size_t *, git_otype
*,
31 struct git_odb_backend
*,
34 /* To find a unique object given a prefix
36 * The oid given must be so that the
37 * remaining (GIT_OID_HEXSZ - len)*4 bits
42 void **, size_t *, git_otype
*,
43 struct git_odb_backend
*,
48 size_t *, git_otype
*,
49 struct git_odb_backend
*,
54 struct git_odb_backend
*,
60 struct git_odb_stream
**,
61 struct git_odb_backend
*,
66 struct git_odb_stream
**,
67 struct git_odb_backend
*,
71 struct git_odb_backend
*,
75 struct git_odb_backend
*,
76 int (*cb
)(git_oid
*oid
, void *data
),
80 void (* free
)(struct git_odb_backend
*);
85 GIT_STREAM_RDONLY
= (1 << 1),
86 GIT_STREAM_WRONLY
= (1 << 2),
87 GIT_STREAM_RW
= (GIT_STREAM_RDONLY
| GIT_STREAM_WRONLY
),
90 /** A stream to read/write from a backend */
91 struct git_odb_stream
{
92 struct git_odb_backend
*backend
;
95 int (*read
)(struct git_odb_stream
*stream
, char *buffer
, size_t len
);
96 int (*write
)(struct git_odb_stream
*stream
, const char *buffer
, size_t len
);
97 int (*finalize_write
)(git_oid
*oid_p
, struct git_odb_stream
*stream
);
98 void (*free
)(struct git_odb_stream
*stream
);
101 GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend
**backend_out
, const char *objects_dir
);
102 GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend
**backend_out
, const char *objects_dir
, int compression_level
, int do_fsync
);