dict.h revision 39ea5717264668e2c7f9f7986eb821d21785f47f
#ifndef DICT_H
#define DICT_H
#define DICT_PATH_PRIVATE "priv/"
#define DICT_PATH_SHARED "shared/"
struct dict;
enum dict_iterate_flags {
DICT_ITERATE_FLAG_RECURSE = 0x01,
DICT_ITERATE_FLAG_SORT_BY_KEY = 0x02,
DICT_ITERATE_FLAG_SORT_BY_VALUE = 0x04,
DICT_ITERATE_FLAG_NO_VALUE = 0x08
};
enum dict_data_type {
};
struct dict_settings {
enum dict_data_type value_type;
const char *username;
const char *base_dir;
};
void dict_drivers_register_builtin(void);
void dict_drivers_unregister_builtin(void);
void dict_drivers_register_all(void);
void dict_drivers_unregister_all(void);
/* Open dictionary with given URI (type:data).
Returns 0 if ok, -1 if URI is invalid. */
const char **error_r);
/* Close dictionary. */
/* Wait for all pending asynchronous transaction commits to finish.
Returns 0 if ok, -1 if error. */
/* Lookup value for key. Set it to NULL if it's not found.
Returns 1 if found, 0 if not found and -1 if lookup failed. */
/* Iterate through all values in a path. flag indicates how iteration
is carried out */
struct dict_iterate_context *
enum dict_iterate_flags flags);
struct dict_iterate_context *
enum dict_iterate_flags flags);
/* Returns 0 = ok, -1 = iteration failed */
/* Start a new dictionary transaction. */
/* Commit the transaction. Returns 1 if ok, 0 if dict_atomic_inc() was used
on a nonexistent key, -1 if failed. */
/* Commit the transaction, but don't wait to see if it finishes successfully.
If callback isn't NULL, it's called eventually. If it's not called by the
time you want to deinitialize dict, call dict_flush() to wait for the
result. */
/* Rollback all changes made in transaction. */
/* Set key=value in dictionary. */
/* Unset a record in dictionary, identified by key*/
const char *key);
/* Append to an existing key in dictionary. Preferably an atomic operation. */
changed when transaction is being committed, so you can't know beforehand
what the value will become. The value is updated only if it already exists,
otherwise commit() will return 0. */
into path components in dict keys. */
const char *dict_escape_string(const char *str);
const char *dict_unescape_string(const char *str);
#endif