more tdb
This commit is contained in:
parent
29b6e3edd7
commit
6632640d67
|
@ -13,76 +13,14 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#include "tdbDB.h"
|
||||
#include "tdb.h"
|
||||
#include "tdb_db.h"
|
||||
|
||||
TDB_EXTERN int tdbCreateDB(TDB** dbpp, tdb_db_t type) {
|
||||
TDB* dbp;
|
||||
int ret;
|
||||
|
||||
dbp = calloc(1, sizeof(*dbp));
|
||||
if (dbp == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
dbp->pageSize = TDB_DEFAULT_PGSIZE;
|
||||
dbp->type = type;
|
||||
|
||||
switch (type) {
|
||||
case TDB_BTREE_T:
|
||||
// ret = tdbInitBtreeDB(dbp);
|
||||
// if (ret < 0) goto _err;
|
||||
break;
|
||||
case TDB_HASH_T:
|
||||
// ret = tdbInitHashDB(dbp);
|
||||
// if (ret < 0) goto _err;
|
||||
break;
|
||||
case TDB_HEAP_T:
|
||||
// ret = tdbInitHeapDB(dbp);
|
||||
// if (ret < 0) goto _err;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
*dbpp = dbp;
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
if (dbp) {
|
||||
free(dbp);
|
||||
}
|
||||
*dbpp = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
TDB_EXTERN int tdbOpenDB(TDB* dbp, const char* fname, const char* dbname, uint32_t flags) {
|
||||
int ret = 0;
|
||||
|
||||
if ((dbp->fname = strdup(fname)) == NULL) {
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Create the backup file if the file not exists
|
||||
|
||||
// Open the file as a sub-db or a master-db
|
||||
if (dbname) {
|
||||
if ((dbp->dbname = strdup(dbname)) == NULL) {
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
// TODO: Open the DB as a SUB-DB in this file
|
||||
} else {
|
||||
// TODO: Open the DB as a MASTER-DB in this file
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
TDB_EXTERN int tdbCloseDB(TDB* dbp, uint32_t flags) {
|
||||
int tdbOpen(TDB **dbpp, const char *fname, const char *dbname, uint32_t flags) {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int tdbClose(TDB *dbp, uint32_t flags) {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
|
@ -16,32 +16,28 @@
|
|||
#ifndef _TD_TDB_DB_H_
|
||||
#define _TD_TDB_DB_H_
|
||||
|
||||
#include "tdb.h"
|
||||
#include "tdbBtree.h"
|
||||
#include "tdb_mpool.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int fd;
|
||||
} TDB_FH;
|
||||
typedef struct TDB TDB;
|
||||
|
||||
struct TDB {
|
||||
pgsize_t pageSize;
|
||||
tdb_db_t type;
|
||||
char * fname;
|
||||
char * dbname;
|
||||
char * fname;
|
||||
char * dbname;
|
||||
TDB_MPFILE *mpf;
|
||||
// union {
|
||||
// TDB_BTREE *btree;
|
||||
// TDB_HASH * hash;
|
||||
// TDB_HEAP * heap;
|
||||
// } dbam; // db access method
|
||||
|
||||
// TDB_FH * fhp; // The backup file handle
|
||||
// TDB_MPOOL *mph; // The memory pool handle
|
||||
};
|
||||
|
||||
int tdbOpen(TDB **dbpp, const char *fname, const char *dbname, uint32_t flags);
|
||||
int tdbClose(TDB *dbp, uint32_t flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue