KDB Backends :: KDB access functions

Methods to access the backend handle. More...


Functions

void * kdbhSetBackendData (KDB *handle, void *data)
void * kdbhGetBackendData (const KDB *handle)
KDBCap * kdbhSetCapability (KDB *handle, KDBCap *cap)
KDBCap * kdbhGetCapability (const KDB *handle)
Trie * kdbhGetTrie (const KDB *handle)
void kdbhSetTrie (KDB *handle, Trie *trie)
const Key * kdbhGetMountpoint (KDB *handle)
void kdbhSetMountpoint (KDB *handle, const Key *mountpoint)
KeySet * kdbhGetConfig (KDB *handle)


Detailed Description

Methods to access the backend handle.

To use them:

 #include <kdb.h>

These functions provide access to the information stored in Backend Handles.


Function Documentation

void* kdbhGetBackendData ( const KDB *  handle  ) 

Get the previously set backend-specific data from the handle.

This is useful when your backend have a backend-global context or environment.

This method will probably be called everytime one of your kdb*() implementations is called. And if you change something inside the data, you don't have to kdbhSetBackendData() again, bacause you are manipulating your data, and not a copy of it.

Example:
struct MyBackendData {
 int context1;
 int context2;
};

int kdbOpen_mybackend(KDB *handle) {
        struct MyBackendData *context;

        context=malloc(sizeof(struct MyBackendData));
 
        // a random initialization...
        context->context1=1;
        context->context2=2;

        kdbhSetBackendData(*handle,context);

        return 0;
}

int kdbGetKey_maybackend(KDB handle) {
        struct MyBackendData *context;

        context=kdbhGetBackendData(handle);

        // No do something with the context
        . . .

        return 0;
}
On the kdbClose() implementation of your backend, you must remember to free all resources associated to your data.

Example of kdbClose() implementation that correctly cleans the context:
int kdbClose_mybackend(KDB &handle) {
        struct MyBackendData *context;

        context=kdbhGetBackendData(handle);
        free(context);

        return 0;
}
Returns:
a pointer to the data previously set be kdbhSetBackendData()
Parameters:
handle contains internal information of opened key database

KDBCap* kdbhGetCapability ( const KDB *  handle  ) 

Gets capability for handle.

Parameters:
handle contains internal information of opened key database
Returns:
The backend name set in handle.

KeySet* kdbhGetConfig ( KDB *  handle  ) 

Returns configuration for handle.

Every backend may have its own configuration using a Keyset.

Parameters:
handle contains internal information of opened key database
Returns:
the keyset containing configuration for a backend

const Key* kdbhGetMountpoint ( KDB *  handle  ) 

Gets mountpoint for handle.

Every mounted backend has a specific mountpoint where it is mounted. You may need to know where you were mounted inside a backend to calculate relative pathes.

The keyName() is where the backend is mounted, keyString() gives the name of which backend is mounted.

Parameters:
handle contains internal information of opened key database
See also:
kdbhSetMountpoint()
Returns:
The Key containing the mountpoint.

Trie* kdbhGetTrie ( const KDB *  handle  ) 

Gets trie for handle.

The trie is a datastructure containing the mounted backends.

Parameters:
handle contains internal information of opened key database
See also:
kdbhSetTrie()
Returns:
The backend name set in handle.

void* kdbhSetBackendData ( KDB *  handle,
void *  data 
)

Set some backend-specific data in the handle.

This is useful when your backend have a backend-global context or environment.

Parameters:
handle contains internal information of opened key database
data a pointer to general data specific to a backend implementation.
See also:
kdbhGetBackendData()

KDBCap* kdbhSetCapability ( KDB *  handle,
KDBCap *  cap 
)

Sets capabilty for handle.

Parameters:
cap a pointer to capability structure
handle contains internal information of opened key database
Returns:
The backend name set in handle.

void kdbhSetMountpoint ( KDB *  handle,
const Key *  mountpoint 
)

Sets mountpoint for handle.

You must not change the mountpoint inside your backend, it was set correctly already for you.

Parameters:
handle contains internal information of opened key database
mountpoint the key containing as name where backend is mounted and as value the backendname
See also:
kdbhGetMountpoint()
Returns:
nothing

void kdbhSetTrie ( KDB *  handle,
Trie *  trie 
)

Sets trie for handle.

The trie is a datastructure containing the mounted backends. This must not done inside backends, it was set correctly already for you.

Parameters:
handle contains internal information of opened key database
trie the datastructure referencing to the other handles of backends
See also:
kdbhGetTrie()
Returns:
nothing


Generated on Sat Jul 25 10:43:38 2009 for Elektra Projekt by  doxygen 1.5.9