summaryrefslogtreecommitdiff
path: root/src/odb.h
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2010-12-03 18:01:30 +0200
committerVicent Marti <tanoku@gmail.com>2010-12-06 01:14:15 +0200
commit7d7cd8857a451ff50b126e452bcbdc0fb397db35 (patch)
treec9ddb750041ef6d22e8fef955df71dd6e7f2973f /src/odb.h
parent86bfec39b55c00ef499e635fdbdca7946c55fcde (diff)
downloadlibgit2-7d7cd8857a451ff50b126e452bcbdc0fb397db35.tar.gz
Decouple storage from ODB logic
Comes with two default backends: loose object and packfiles. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/odb.h')
-rw-r--r--src/odb.h61
1 files changed, 44 insertions, 17 deletions
diff --git a/src/odb.h b/src/odb.h
index a45b803b8..2726cbb46 100644
--- a/src/odb.h
+++ b/src/odb.h
@@ -1,22 +1,49 @@
#ifndef INCLUDE_odb_h__
#define INCLUDE_odb_h__
-/** First 4 bytes of a pack-*.idx file header.
- *
- * Note this header exists only in idx v2 and later. The idx v1
- * file format does not have a magic sequence at the front, and
- * must be detected by the first four bytes *not* being this value
- * and the first 8 bytes matching the following expression:
- *
- * uint32_t *fanout = ... the file data at offset 0 ...
- * ntohl(fanout[0]) < ntohl(fanout[1])
- *
- * The value chosen here for PACK_TOC is such that the above
- * cannot be true for an idx v1 file.
- */
-#define PACK_TOC 0xff744f63 /* -1tOc */
-
-/** First 4 bytes of a pack-*.pack file header. */
-#define PACK_SIG 0x5041434b /* PACK */
+#include <git/odb.h>
+#include <git/oid.h>
+
+#include "vector.h"
+
+struct git_odb {
+ void *_internal;
+ git_vector backends;
+};
+
+struct git_odb_backend {
+ git_odb *odb;
+
+ int priority;
+
+ int (* read)(
+ git_rawobj *,
+ struct git_odb_backend *,
+ const git_oid *);
+
+ int (* read_header)(
+ git_rawobj *,
+ struct git_odb_backend *,
+ const git_oid *);
+
+ int (* write)(
+ git_oid *id,
+ struct git_odb_backend *,
+ git_rawobj *obj);
+
+ int (* exists)(
+ struct git_odb_backend *,
+ const git_oid *);
+
+ void (* free)(struct git_odb_backend *);
+
+};
+
+int git_odb__hash_obj(git_oid *id, char *hdr, size_t n, int *len, git_rawobj *obj);
+int git_odb__inflate_buffer(void *in, size_t inlen, void *out, size_t outlen);
+
+
+int git_odb_backend_loose(git_odb_backend **backend_out, const char *objects_dir);
+int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir);
#endif