dict.c revision 75bb83681e30d6a86109bbafdfe6b513c11124bc
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */
de1c645a79d42c37dffb7f52e9c643b6251fdcd0Aki Tuomistatic struct dict_iterate_context dict_iter_unsupported;
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomistatic struct dict *dict_driver_lookup(const char *name)
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi i_fatal("dict_driver_register(%s): Already registered",
b0c472c7a93dfc869e2124ca738d62f1d6794e43Timo Sirainen dict_driver_register(&dict_driver_memcached_ascii);
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi dict_driver_unregister(&dict_driver_memcached_ascii);
de1c645a79d42c37dffb7f52e9c643b6251fdcd0Aki Tuomistruct dict *dict_init(const char *uri, enum dict_data_type value_type,
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi const char *p, *name;
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi i_error("Dictionary URI is missing ':': %s", uri);
de1c645a79d42c37dffb7f52e9c643b6251fdcd0Aki Tuomi dict->v.init(dict, p+1, value_type, username, base_dir);
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi return dict->v.wait == NULL ? 1 : dict->v.wait(dict);
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomistatic bool dict_key_prefix_is_valid(const char *key)
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi return strncmp(key, DICT_PATH_SHARED, strlen(DICT_PATH_SHARED)) == 0 ||
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi strncmp(key, DICT_PATH_PRIVATE, strlen(DICT_PATH_PRIVATE)) == 0;
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomiint dict_lookup(struct dict *dict, pool_t pool, const char *key,
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi const char **value_r)
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomidict_iterate_init(struct dict *dict, const char *path,
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi return dict_iterate_init_multiple(dict, paths, flags);
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomidict_iterate_init_multiple(struct dict *dict, const char *const *paths,
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi unsigned int i;
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi /* not supported by backend */
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi i_error("%s: dict iteration not supported", dict->name);
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomibool dict_iterate(struct dict_iterate_context *ctx,
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomiint dict_iterate_deinit(struct dict_iterate_context **_ctx)
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomistruct dict_transaction_context *dict_transaction_begin(struct dict *dict)
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomiint dict_transaction_commit(struct dict_transaction_context **_ctx)
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi return ctx->dict->v.transaction_commit(ctx, FALSE, NULL, NULL);
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomivoid dict_transaction_commit_async(struct dict_transaction_context **_ctx,
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi ctx->dict->v.transaction_commit(ctx, TRUE, callback, context);
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomivoid dict_transaction_rollback(struct dict_transaction_context **_ctx)
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomivoid dict_set(struct dict_transaction_context *ctx,
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomivoid dict_unset(struct dict_transaction_context *ctx,
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi const char *key)
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomivoid dict_append(struct dict_transaction_context *ctx,
6b136bb200a5f803d0ef5af225ad891e862b6b75Timo Sirainenvoid dict_atomic_inc(struct dict_transaction_context *ctx,
return str;
return str;