dict-db.c revision 3954326e793bdef1e94e0ad781ed6cc7e48beebb
/* Copyright (c) 2006-2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "dict-private.h"
#ifdef BUILD_DB
#include <stdlib.h>
#include <db.h>
struct db_dict {
enum dict_data_type value_type;
};
struct db_dict_iterate_context {
struct dict_iterate_context ctx;
char *path;
unsigned int path_len;
enum dict_iterate_flags flags;
};
struct db_dict_transaction_context {
struct dict_transaction_context ctx;
};
{
return 0;
}
{
}
const char *username)
{
const char *dir;
int ret;
else
dir = ".";
DB_INIT_MPOOL | DB_INIT_TXN, 0);
if (ret != 0) {
return -1;
}
if (ret != 0) {
return -1;
}
/* create both primary and secondary databases */
if (ret != 0) {
return -1;
}
if (ret != 0) {
return -1;
}
return -1;
}
return -1;
/* by default keys are compared as strings. if we store uint32_t,
we need a customized compare function */
return -1;
}
return -1;
}
associate_key, DB_CREATE)) != 0) {
return -1;
}
return 0;
}
static struct dict *
enum dict_data_type value_type,
{
i_error("Berkeley DB version mismatch: "
"Compiled against %d.%d.%d headers, "
"run-time linked against %d.%d.%d library",
return NULL;
}
/* prepare the environment */
if (ret != 0) {
pool_unref(&pool);
return NULL;
}
return NULL;
}
}
{
}
{
if (ret == DB_NOTFOUND)
return 0;
else if (ret != 0)
return -1;
switch (dict->value_type) {
case DICT_DATA_TYPE_UINT32:
/* data may not be aligned, so use memcpy() */
break;
case DICT_DATA_TYPE_STRING:
break;
}
return 1;
}
{
int ret;
if (ret == DB_NOTFOUND)
return 0;
else if (ret != 0)
return -1;
switch (dict->value_type) {
case DICT_DATA_TYPE_UINT32:
/* data may not be aligned, so use memcpy() */
break;
case DICT_DATA_TYPE_STRING:
break;
}
return 1;
}
{
int ret;
DB_NEXT)) == 0) {
/* make sure the path matches */
break;
break;
}
} else {
DB_NEXT);
/* there are no more matches */
return 0;
}
}
}
{
int ret;
/* iterating through secondary database returns values sorted */
} else {
return 0;
}
}
}
static struct dict_iterate_context *
enum dict_iterate_flags flags)
{
struct db_dict_iterate_context *ctx;
}
{
struct db_dict_iterate_context *ctx =
(struct db_dict_iterate_context *)_ctx;
}
{
struct db_dict_iterate_context *ctx =
(struct db_dict_iterate_context *)_ctx;
}
static struct dict_transaction_context *
{
struct db_dict_transaction_context *ctx;
}
static int
bool async ATTR_UNUSED,
void *context)
{
struct db_dict_transaction_context *ctx =
(struct db_dict_transaction_context *)_ctx;
int ret;
return ret;
}
{
struct db_dict_transaction_context *ctx =
(struct db_dict_transaction_context *)_ctx;
}
{
struct db_dict_transaction_context *ctx =
(struct db_dict_transaction_context *)_ctx;
} else {
}
}
const char *key)
{
struct db_dict_transaction_context *ctx =
(struct db_dict_transaction_context *)_ctx;
}
static void
{
/* FIXME */
}
struct dict dict_driver_db = {
{
NULL,
}
};
#endif