Data Structures | |
struct | _KDBInfo |
Object returned by kdbGetInfo() containing some informations about the Elektra library and backend being used. More... | |
Typedefs | |
typedef _KDBInfo | KDBInfo |
Object returned by kdbGetInfo() containing some informations about the Elektra library and backend being used. | |
Enumerations | |
enum | KDBErr { KDB_RET_OK = 0, KDB_RET_NULLKEY = EINVAL, KDB_RET_UNINITIALIZED = EINVAL, KDB_RET_NOTFOUND = ENOENT, KDB_RET_INVALIDKEY = ESRCH, KDB_RET_NOKEY = ENXIO, KDB_RET_NODATA = ENODEV, KDB_RET_NODESC = ENOTDIR, KDB_RET_NODOMAIN = EDOM, KDB_RET_NOGROUP = ECHILD, KDB_RET_NOTIME = ENOTTY, KDB_RET_NOCRED = EACCES, KDB_RET_TRUNC = ERANGE, KDB_RET_NOMEM = ENOMEM, KDB_RET_TYPEMISMATCH = EBADF, KDB_RET_NOSYS = ENOSYS, KDB_RET_EBACKEND = EIO } |
Some return codes generated by the Elektra library. More... | |
enum | KDBOptions { KDB_O_RECURSIVE = 1, KDB_O_DIR = 1<<1, KDB_O_DIRONLY = 1<<2 , KDB_O_STATONLY = 1<<4, KDB_O_INACTIVE = 1<<5, KDB_O_SORT = 1<<6, KDB_O_NFOLLOWLINK = 1<<7, KDB_O_CONDENSED = 1<<8, KDB_O_NUMBERS = 1<<9, KDB_O_XMLHEADERS = 1<<10, KDB_O_FULLNAME = 1<<11, KDB_O_FULLUGID = 1<<12, KDB_O_HIER = 1<<13, KDB_O_NOCASE = 1<<15, KDB_O_NOSPANPARENT = 1<<16 } |
Options to change the default behavior of some methods. More... | |
Functions | |
int | kdbOpen () |
Opens the session with the Key database, using a backend defined by environment var $KDB_BACKEND. | |
int | kdbOpenDefault () |
Opens the session with the Key database. | |
int | kdbOpenBackend (char *backendName) |
Opens the session with the Key database, dynamically loading a specific beckend for libelektra.so. | |
int | kdbClose () |
Closes the session with the Key database. | |
int | kdbGetValue (const char *keyname, char *returned, size_t maxSize) |
A high-level method to get a key value, by key name. | |
int | kdbSetValue (const char *keyname, const char *value) |
A high-level method to set a value to a key, by key name. | |
int | kdbGetValueByParent (const char *parentName, const char *baseName, char *returned, size_t maxSize) |
Fills the returned buffer with the value of a key, which name is the concatenation of parentName and baseName . | |
int | kdbSetValueByParent (const char *parentName, const char *baseName, const char *value) |
Sets the provided value to the key whose name is the concatenation of parentName and baseName . | |
int | kdbGetKeyByParent (const char *parentName, const char *baseName, Key *returned) |
Given a parent key name plus a basename, returns the key. | |
int | kdbGetKeyByParentKey (const Key *parent, const char *baseName, Key *returned) |
Similar to previous, provided for convenience. | |
ssize_t | kdbGetKeyChildKeys (const Key *parentKey, KeySet *returned, unsigned long options) |
Retrieve a number of keys at once. | |
ssize_t | kdbGetChildKeys (const char *parentName, KeySet *returned, unsigned long options) |
This method is similar and calls kdbGetKeyChildKeys(). | |
ssize_t | kdbGetRootKeys (KeySet *returned) |
Returns a KeySet with all root keys currently recognized and present on the system. | |
int | kdbStatKey (Key *key) |
Taps the key only for its meta-info from the backend storage. | |
int | kdbGetKey (Key *key) |
Fully retrieves the passed key from the backend storage. | |
int | kdbSetKeys (KeySet *ks) |
Commits the ks KeySet to the backend storage, starting from ks's current position until its end. | |
int | kdbSetKey (Key *key) |
Sets key in the backend storage. | |
int | kdbRename (Key *key, const char *newName) |
Rename a key in the backend storage. | |
int | kdbRemoveKey (const Key *key) |
Remove a key from the backend storage. | |
int | kdbRemove (const char *keyName) |
Remove a key by its name from the backend storage. | |
int | kdbLink (const char *oldPath, const char *newKeyName) |
Create a link key on the backend storage that points to other key. | |
uint32_t | kdbMonitorKeys (KeySet *interests, uint32_t diffMask, unsigned long iterations, unsigned sleep) |
Monitor a KeySet for some key change. | |
uint32_t | kdbMonitorKey (Key *interest, uint32_t diffMask, unsigned long iterations, unsigned sleep) |
Monitor a key change. | |
KDBInfo * | kdbGetInfo (void) |
Returns a structure of information about the internals of the library and the backend used. | |
void | kdbFreeInfo (KDBInfo *info) |
Frees the object returned by kdbGetInfo(). | |
int | kdbInfoToString (KDBInfo *info, char *string, size_t maxSize) |
Convenience method to provide a human readable text for what kdbGetInfo() returns. |
To use them:
#include <kdb.h>
This is the class that accesses the storage backend. When writing a new backend , these are the methods you'll have to reimplement: kdbOpen(), kdbClose(), kdbGetKey(), kdbSetKey(), kdbStatKey(), kdbGetKeyChildKeys(), kdbRemove(), kdbRename().
And methods that are suggested to reimplement (but not needed) if you want them to get the benefits of your new backend: kdbSetKeys(), kdbMonitorKey(), kdbMonitorKeys().
The other methods are higher level. They use the above methods to do their job, and generally don't have to be reimplemented for a different backend.
Language binding writers should follow the same rules:
|
Object returned by kdbGetInfo() containing some informations about the Elektra library and backend being used. You should not allocate or deallocate memory for each of these members. This is a library responsability.
Referenced by commandInfo(), kdbFreeInfo(), kdbGetInfo(), and kdbInfoToString(). |
|
Some return codes generated by the Elektra library.
These are Elektra specific errors only, that the library sets in
The idea is to keep compatibility to POSIX
A very robust program should check
|
|
Options to change the default behavior of some methods. These options should be ORed.
|
|
Opens the session with the Key database, using a backend defined by environment var $KDB_BACKEND. If the environment is not set the default backend will be opened. You must always call this method before retrieving or commiting any keys to the database. In the end of the program, after using the key database, you must not forget to kdbClose(). You can use the atexit () handler for it. This is the best way to have affairs with the key database, unless the program is concerned about security and authentication (e.g. su, login, telnetd, etc), in which kdbOpenDefault() should be used. kdbOpen() is used by the kdb command. Currently you can have only one backend (and key database session) initialized at a certain time. To simply manipulate Key or KeySet objects without having to retrieve them from the storage, you don't need to open the key database before with any of the kdbOpen*() methods.
Definition at line 160 of file libkdb.c. References kdbOpenBackend(). Referenced by commandExport(), and main(). |
|
Opens the session with the Key database. Different from kdbOpen(), kdbOpenDefault() will completely ignore the $KDB_BACKEND environment and open the default backend. So kdbOpenDefault() must be used by programs concerned about security (e.g. su, login, sshd, etc). The default backend use to be a symlink to the real backend, and is found in /lib/libelektra-default.so
Definition at line 188 of file libkdb.c. References kdbOpenBackend(). |
|
Opens the session with the Key database, dynamically loading a specific beckend for libelektra.so. After dynamic loading, the backend will be initialized with its implementation of kdbOpen().
Definition at line 244 of file libkdb.c. Referenced by kdbOpen(), and kdbOpenDefault(). |
|
Closes the session with the Key database. You should call this method when you finished your affairs with the key database. You can manipulate Key and KeySet objects after kdbClose(). This is the counterpart of kdbOpen().
Definition at line 311 of file libkdb.c. Referenced by commandExport(). |
|
A high-level method to get a key value, by key name. This method is valid only for string keys. You should use other methods to get non-string keys.
Definition at line 550 of file libkdb.c. References kdbGetKey(), KEY_SWITCH_END, keyDel(), keyGetString(), and keyNew(). Referenced by kdbGetValueByParent(). |
|
A high-level method to set a value to a key, by key name. It will obviously check if key exists first, and keep its metadata. So you'll not loose the precious key comment. This will set a text key. So if the key was previously a binary, etc key, it will be retyped as text.
Definition at line 578 of file libkdb.c. References kdbGetKey(), kdbSetKey(), KEY_SWITCH_END, keyDel(), keyNew(), and keySetString(). Referenced by kdbSetValueByParent(). |
|
Fills the
Definition at line 619 of file libkdb.c. References kdbGetValue(), and strblen(). |
|
Sets the provided
Definition at line 642 of file libkdb.c. References kdbSetValue(), and strblen(). |
|
Given a parent key name plus a basename, returns the key. So here you'll provide something like
Definition at line 669 of file libkdb.c. References kdbGetKey(), keySetName(), and strblen(). |
|
Similar to previous, provided for convenience.
Definition at line 687 of file libkdb.c. References kdbGetKey(), keyGetFullName(), keyGetFullNameSize(), keySetName(), and strblen(). |
|
Retrieve a number of keys at once. This is one of the most practical methods of the library. And because of storing the keys in the efficient afterward, its very recommended to use it. The existing KeySet (you must initializise it with ) will have all retrieved keys appended afterwards. In default behaviour it will fully retrieve all keys in the specified directory, but not folder and inactive keys. The output is in a backend specific order. Option can be any of the following:
Definition at line 793 of file libkdb.c. Referenced by commandList(), and kdbGetChildKeys(). |
|
This method is similar and calls kdbGetKeyChildKeys(). It is provided for convenience. Definition at line 810 of file libkdb.c. References kdbGetKeyChildKeys(), KEY_SWITCH_END, keyDel(), and keyNew(). Referenced by commandEdit(), and commandList(). |
|
Returns a KeySet with all root keys currently recognized and present on the system.
Currently, the
Definition at line 835 of file libkdb.c. References _Key::flags, KEY_SWITCH_END, KEY_SWITCH_NEEDSYNC, keyDel(), keyNew(), ksInsert(), and _KeySet::size. Referenced by commandList(). |
|
Taps the key only for its meta-info from the backend storage. The bahavior may change from backend to backend. In the filesystem backend, it will make only a stat(2) on the key.
A key of type KEY_TYPE_LINK will have its target address loaded in the Info like comments and key data type are not retrieved.
Definition at line 873 of file libkdb.c. Referenced by commandList(). |
|
Fully retrieves the passed
Definition at line 897 of file libkdb.c. Referenced by commandEdit(), commandGet(), commandList(), commandSet(), kdbGetKeyByParent(), kdbGetKeyByParentKey(), kdbGetValue(), kdbMonitorKey_default(), kdbSetValue(), and keyNew(). |
|
Commits the
This is why it is suggested that you call ksRewind() on
If some error occurs, kdbSetKeys() stops and returns whatever kdbSetKey() returned. The KeySet internal cursor is left on the key that generated the error (so you may check it latter with ksCurrent()). The internal kdbSetKey() also sets
Definition at line 931 of file libkdb.c. References kdbSetKeys_default(). Referenced by commandEdit(), and commandImport(). |
|
Sets
Definition at line 987 of file libkdb.c. Referenced by commandSet(), kdbLink(), kdbSetKeys_default(), and kdbSetValue(). |
|
Rename a key in the backend storage.
Definition at line 1012 of file libkdb.c. Referenced by commandMove(). |
|
Remove a key from the backend storage.
The This method is not recursive.
Definition at line 1040 of file libkdb.c. Referenced by kdbRemove(). |
|
Remove a key by its name from the backend storage. This is a convenience to kdbRemoveKey().
Definition at line 1065 of file libkdb.c. References kdbRemoveKey(), KEY_SWITCH_END, keyDel(), keyNew(), and keySetName(). Referenced by commandEdit(), and commandRemove(). |
|
Create a link key on the backend storage that points to other key.
Definition at line 1097 of file libkdb.c. References kdbSetKey(), KEY_SWITCH_END, keyDel(), keyNew(), and keySetLink(). Referenced by commandLink(). |
|
Monitor a KeySet for some key change.
This method will scan the You may check the return code to see if some key changed, and get the updated key using ksCurrent().
Definition at line 1171 of file libkdb.c. References kdbMonitorKeys_default(). |
|
Monitor a key change. This method will block execution until one of the folowing happens:
If
If
If you don't have access rights to
If something from
Definition at line 1269 of file libkdb.c. References kdbMonitorKey_default(). Referenced by commandMonitor(), and kdbMonitorKeys_default(). |
|
Returns a structure of information about the internals of the library and the backend used. Currently, the returned object has the following members:
After use, the returned object must be freed with a call to kdbFreeInfo().
Definition at line 1513 of file libkdb.c. References _KDBInfo::backendIsOpen, _KDBInfo::backendName, KDBInfo, and _KDBInfo::version. Referenced by commandInfo(). |
|
Frees the object returned by kdbGetInfo(). This method is provided so the programmer doesn't need to learn about the storage internals of the KDBInfo structure.
Definition at line 1548 of file libkdb.c. References KDBInfo. |
|
Convenience method to provide a human readable text for what kdbGetInfo() returns.
It is your responsability to allocate and free the
Definition at line 1581 of file libkdb.c. References _KDBInfo::backendIsOpen, _KDBInfo::backendName, KDBInfo, and _KDBInfo::version. Referenced by commandInfo(). |