1 /***************************************************************************
2 kdbcapability.c - Capability and attribute functions for backends
4 begin : Mon Dec 29 2003
5 copyright : (C) 2003 by Avi Alkalay
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the BSD License (revised). *
14 ***************************************************************************/
18 * @defgroup capability KDB Backends :: Capabilities of backends
19 * @brief The tactics to consider different possibilites of different backends.
21 * Since version 0.7 with the vast new possiblities of backends used
22 * together in a global namespace the fact that not every backend can
23 * fulfill any requirement as datastore and the intersection would
24 * lead to a useless limited storage, capabilities were introduced.
26 * Applications heavily using kdbGet() and kdbSet() together with metadata
27 * may be interested if what they show are default values or something you
30 * On the other hand backends may be interested to tell that they
31 * can't fullfill the requriements described in kdbGet_backend() and
34 * Many backends are very limited in how granular the metadata is. If
35 * many keys are stored in the same file, it is of course not possible
36 * that one key has e.g. another owner than another key in the same
39 * There might even be a limit in what names can be accepted by a
40 * backend, because of syntax in a configuration file. A formal description
41 * needed for that problem would be out of scope and not very useful.
42 * For that reason capabilites are limited to yes/no questions
43 * if something is provided or not.
45 * Capabilites are also very useful for testing driven or
46 * iterative development. Beginning with simple reading everything out
47 * transformed to keyset in kdbGet_backend() and generating a new
48 * file with the keyset of kdbSet_backend() you can iterative
49 * delete handicaps of your backend until you hit the full specification,
57 #if DEBUG && HAVE_STDIO_H
85 #include <kdbbackend.h>
89 KDBCap * cap = (KDBCap *)malloc(sizeof(KDBCap));
91 memset(cap,0,sizeof(KDBCap));
95 void capDel (KDBCap *cap)
101 /*Version of the library.
103 * @param cap the obsolete cap object
104 * @ingroup capability*/
105 const char * kdbcGetVersion (const KDBCap *cap)
111 /*Name of backend being or that will be used
113 * @param cap the obsolete cap object
114 * @ingroup capability*/
115 const char * kdbcGetName (const KDBCap *cap)
121 /*Any text describing the backend.
123 * @param cap the obsolete cap object
124 * @ingroup capability*/
125 const char * kdbcGetDescription (const KDBCap *cap)
127 return cap->description;
131 /*The author of the backend.
133 * Best is format "Full Name <email@libelektra.org>"
136 * Avi Alkalay <avi@unix.sh>
137 * Markus Raab <elektra@markus-raab.org>
138 * Yannick Lecaillez <yl@itioweb.com>
139 * Jens Andersen <jens.andersen@gmail.com>
140 * Patrick Sabin <patricksabin@gmx.at>
141 * Pier Luigi Fiorini <pierluigi.fiorini@mockup.org>
142 * Rèmi <remipouak@yahoo.fr>
143 * Studio-HB <contact@studio-hb.com>
146 * @param cap the obsolete cap object
147 * @ingroup capability*/
148 const char * kdbcGetAuthor (const KDBCap *cap)
154 /*The licence of the backend.
156 * - Must be "BSD" for bsd licence, this is the licence for elektra core.
157 * - Must be "GPL2" for gpl version 2.
158 * - Must be "GPL3" for gpl version 3.
159 * - Must be "LGPL" for lgpl.
161 * Because of BSD licence even commercial is allowed.
164 * @param cap the obsolete cap object
165 * @ingroup capability*/
166 const char * kdbcGetLicence (const KDBCap *cap){
171 /*You cant get specific keys.
173 * The specification of kdbGet_backend() says that you must
174 * get a key with its subkey and nothing more or less. Declaring
175 * onlyFullGet you are allowed to get all keys when you get
176 * a kdbGet_backend() request of your mountpoint, but you need
177 * to return 0 for any subkeys to avoid an infinite loop.
180 * @param cap the obsolete cap object
181 * @see kdbGet_backend()
182 * @ingroup capability
184 unsigned int kdbcGetonlyFullGet (const KDBCap *cap)
186 return cap->onlyFullGet;
190 /*All keys need to be in keyset when setting.
192 * Backends have not problem with setting single keys, when the
193 * gap between those keys is already filled out with previous
194 * calls of kdbSet(). The keys in between may not be in the
197 * Declaring onlyFullSet requires the caller to kdbGet() all
198 * keys of the backend and manipulating this full set. This
199 * allows the backend to regenerate the whole config, making
200 * implementation much easier.
203 * @param cap the obsolete cap object
204 * @see kdbSet_backend()
205 * @ingroup capability
207 unsigned int kdbcGetonlyFullSet (const KDBCap *cap)
209 return cap->onlyFullSet;
213 /*When getting keys they cant be stated.
215 * @see keyStat(), keyNeedStat()
216 * @see kdbGet_backend()
217 * @ingroup capability
219 unsigned int kdbcGetnoStat (const KDBCap *cap)
225 /*You can only remove all keys at once.
227 * @see kdbSet_backend()
228 * @ingroup capability
230 unsigned int kdbcGetonlyRemoveAll (const KDBCap *cap)
232 return cap->onlyRemoveAll;
236 /*When setting keys with new name below parentKey, they will be added.
238 * Otherwise (changing keys) all keys are required.
240 * @see kdbSet_backend()
241 * @ingroup capability
243 unsigned int kdbcGetonlyAddKeys (const KDBCap *cap)
245 return cap->onlyAddKeys;
249 /*The backend does not support a owner of keys.
252 * @see keySetOwner() and keyGetOwner()
253 * @ingroup capability
255 unsigned int kdbcGetnoOwner (const KDBCap *cap)
261 /*No value is supported in the backend.
263 * A backend might be useful only having comments, metadata or only
264 * names without any values as information for applications. Declare
265 * this if your backend is not capable of storing values.
268 * @see keySetString() and keyGetString()
269 * @see keyValue() (togehter with keyGetValueSize() if it is binary)
270 * @ingroup capability
272 unsigned int kdbcGetnoValue (const KDBCap *cap)
278 /*No comment is supported in the backend.
280 * @see keySetComment() and keyGetComment()
281 * @ingroup capability
283 unsigned int kdbcGetnoComment (const KDBCap *cap)
285 return cap->noComment;
289 /*No uid is supported in the backend.
292 * @ingroup capability
294 unsigned int kdbcGetnoUID (const KDBCap *cap)
300 /*No gid is supported in the backend.
303 * @ingroup capability
305 unsigned int kdbcGetnoGID (const KDBCap *cap)
311 /*No mode is supported in the backend.
313 * Means that keys will only have 664 or
314 * 775 as mode values.
317 * @ingroup capability
319 unsigned int kdbcGetnoMode (const KDBCap *cap)
325 /*Directories are not supported in the backend.
327 * Tells that mode won't have any executable
330 * Declaring kdbcGetnoDir() means
331 * that the backend is flat, no key will be true for keyIsDir()
332 * and so can't have any subkeys.
335 * @ingroup capability
337 unsigned int kdbcGetnoDir (const KDBCap *cap)
343 /*Access Time not supported.
346 * @ingroup capability
348 unsigned int kdbcGetnoATime (const KDBCap *cap)
354 /*Modification Time not supported.
357 * @ingroup capability
359 unsigned int kdbcGetnoMTime (const KDBCap *cap)
365 /*Meta Info and Subkeys Change Time not supported.
368 * @ingroup capability
370 unsigned int kdbcGetnoCTime (const KDBCap *cap)
376 /*The backend does not support removing keys.*/
377 unsigned int kdbcGetnoRemove (const KDBCap *cap)
379 return cap->noRemove;
384 /*Mount type not supported.*/
385 unsigned int kdbcGetnoMount (const KDBCap *cap)
391 /*Binary types not supported.
393 * @see keySetBinary()
394 * @ingroup capability
396 unsigned int kdbcGetnoBinary (const KDBCap *cap)
398 return cap->noBinary;
402 /*String types not supported.
404 * @see keySetString()
405 * @ingroup capability
407 unsigned int kdbcGetnoString (const KDBCap *cap)
409 return cap->noString;
413 /*Typing of keys is not supported.
415 * @see keySetRaw() and keySetType()
416 * @ingroup capability
418 unsigned int kdbcGetnoTypes (const KDBCap *cap)
424 /*Do not expect errno to be set correctly.
426 * @see kdbhSetError()
427 * @ingroup capability
429 unsigned int kdbcGetnoError (const KDBCap *cap)
435 /*Backend does not lock.
437 * @ingroup capability
439 unsigned int kdbcGetnoLock (const KDBCap *cap)
445 /*Backend uses global variables and is not threadsafe.
447 * @ingroup capability
449 unsigned int kdbcGetnoThread (const KDBCap *cap)
451 return cap->noThread;