提交 cb9ca05b 编写于 作者: H Hongze Cheng

more tdb

上级 93d68cce
......@@ -15,12 +15,59 @@
#include "tdb_db.h"
static int tdbOpenImpl(TDB *dbp);
int tdbOpen(TDB **dbpp, const char *fname, const char *dbname, uint32_t flags) {
// TODO
TDB * dbp;
TDB_MPFILE *mpf;
uint8_t fileid[TDB_FILE_ID_LEN];
if ((dbp = (TDB *)calloc(1, sizeof(*dbp))) == NULL) {
return -1;
}
if ((dbp->fname = strdup(fname)) == NULL) {
free(dbp);
return -1;
}
if ((dbname) && ((dbp->dbname = strdup(dbname)) == NULL)) {
free(dbp->fname);
free(dbp);
return -1;
}
// if (tdbGnrtFileID(fname, fileid) < 0) {
// // todo
// return -1;
// }
// TODO: mpf = tdbGetMPFileByID(fileid);
if (mpf == NULL) {
// todoerr: maybe we need to create one
return -1;
}
if (tdbOpenImpl(dbp) < 0) {
// todoerr
return -1;
}
*dbpp = dbp;
return 0;
}
int tdbClose(TDB *dbp, uint32_t flags) {
// TODO
return 0;
}
static int tdbOpenImpl(TDB *dbp) {
if (dbp->dbname == NULL) {
// todo: open the DB as a master DB
} else {
// todo: open the DB as a sub-db
}
// TODO
return 0;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册