dict.c revision fd1a8db8fa61f9c38f063f62753d1bfef0261e19
76b43e4417bab52e913da39b5f5bc2a130d3f149Timo Sirainen/* Copyright (c) 2005-2008 Dovecot authors, see the included COPYING file */
419cf63077e755935ce105747d6ebc67b7d38a7fTimo Sirainenstatic ARRAY_DEFINE(dict_drivers, struct dict *);
419cf63077e755935ce105747d6ebc67b7d38a7fTimo Sirainenstatic struct dict *dict_driver_lookup(const char *name)
28c75d59f1d1a7caeb85635964f3881c0038eb23Timo Sirainen unsigned int i, count;
28c75d59f1d1a7caeb85635964f3881c0038eb23Timo Sirainen for (i = 0; i < count; i++) {
419cf63077e755935ce105747d6ebc67b7d38a7fTimo Sirainen if (dict_driver_lookup(driver->name) != NULL) {
419cf63077e755935ce105747d6ebc67b7d38a7fTimo Sirainen i_fatal("dict_driver_register(%s): Already registered",
419cf63077e755935ce105747d6ebc67b7d38a7fTimo Sirainenvoid dict_driver_unregister(struct dict *driver)
28c75d59f1d1a7caeb85635964f3881c0038eb23Timo Sirainen unsigned int i, count;
28c75d59f1d1a7caeb85635964f3881c0038eb23Timo Sirainen for (i = 0; i < count; i++) {
92d1458b00f4f236c4cec96a696253d3bbf8b05aTimo Sirainenstruct dict *dict_init(const char *uri, enum dict_data_type value_type,
9844b5359f5cab77e4c31a7ac9e4a60a0073929eTimo Sirainen const char *p, *name;
14cdb8cbe37616464c965aec90a8494b339db538Timo Sirainen i_error("Dictionary URI is missing ':': %s", uri);
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen dict->v.init(dict, p+1, value_type, username);
fd1a8db8fa61f9c38f063f62753d1bfef0261e19Timo Sirainenstatic bool dict_key_prefix_is_valid(const char *key)
fd1a8db8fa61f9c38f063f62753d1bfef0261e19Timo Sirainen return strncmp(key, DICT_PATH_SHARED, strlen(DICT_PATH_SHARED)) == 0 ||
fd1a8db8fa61f9c38f063f62753d1bfef0261e19Timo Sirainen strncmp(key, DICT_PATH_PRIVATE, strlen(DICT_PATH_PRIVATE)) == 0;
f8ead0942a9b7c8fcf91414ed1b534d5807ca555Timo Sirainenint dict_lookup(struct dict *dict, pool_t pool, const char *key,
f8ead0942a9b7c8fcf91414ed1b534d5807ca555Timo Sirainen const char **value_r)
f8ead0942a9b7c8fcf91414ed1b534d5807ca555Timo Sirainen return dict->v.lookup(dict, pool, key, value_r);
92d1458b00f4f236c4cec96a696253d3bbf8b05aTimo Sirainendict_iterate_init(struct dict *dict, const char *path,
92d1458b00f4f236c4cec96a696253d3bbf8b05aTimo Sirainen return dict->v.iterate_init(dict, path, flags);
28c75d59f1d1a7caeb85635964f3881c0038eb23Timo Sirainenint dict_iterate(struct dict_iterate_context *ctx,
28c75d59f1d1a7caeb85635964f3881c0038eb23Timo Sirainen return ctx->dict->v.iterate(ctx, key_r, value_r);
1dc6f277f5ac6a3dd5cd6aa75a7ef691de9acb7aTimo Sirainenvoid dict_iterate_deinit(struct dict_iterate_context **_ctx)
28c75d59f1d1a7caeb85635964f3881c0038eb23Timo Sirainenstruct dict_transaction_context *dict_transaction_begin(struct dict *dict)
1dc6f277f5ac6a3dd5cd6aa75a7ef691de9acb7aTimo Sirainenint dict_transaction_commit(struct dict_transaction_context **_ctx)
1dc6f277f5ac6a3dd5cd6aa75a7ef691de9acb7aTimo Sirainenvoid dict_transaction_rollback(struct dict_transaction_context **_ctx)
28c75d59f1d1a7caeb85635964f3881c0038eb23Timo Sirainenvoid dict_set(struct dict_transaction_context *ctx,
92d1458b00f4f236c4cec96a696253d3bbf8b05aTimo Sirainenvoid dict_unset(struct dict_transaction_context *ctx,
92d1458b00f4f236c4cec96a696253d3bbf8b05aTimo Sirainen const char *key)