Main Page | Modules | Data Structures | File List | Data Fields

template.c

00001 /***************************************************************************
00002             temaple.c  -  Skeleton of backends to access the Key Database
00003                              -------------------
00004     begin                : Mon Dec 26 2004
00005     copyright            : (C) 2004 by Avi Alkalay
00006     email                : avi@unix.sh
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the BSD License (revised).                      *
00013  *                                                                         *
00014  ***************************************************************************/
00015 
00016 
00017 
00018 /***************************************************************************
00019  *                                                                         *
00020  *   This is the skeleton of the methods you'll have to implement in order *
00021  *   to provide libelektra.so a valid backend.                             *
00022  *   Simple fill the empty _backend functions with your code and you are   *
00023  *   ready to go.                                                          *
00024  *                                                                         *
00025  ***************************************************************************/
00026 
00027 
00028 /* Subversion stuff
00029 
00030 $Id: template.c 601 2006-02-15 02:32:13Z aviram $
00031 $LastChangedBy: mraab $
00032 
00033 */
00034 
00035 
00036 
00037 #include <kdb.h>
00038 #include <kdbbackend.h>
00039 
00040 
00041 #define BACKENDNAME "my_backend"
00042 
00043 
00044 
00046 #ifdef PATH_MAX
00047 #define MAX_PATH_LENGTH PATH_MAX
00048 
00049 #elif __USE_POSIX
00050 #define MAX_PATH_LENGTH _POSIX_PATH_MAX
00051 #else 
00052 #define MAX_PATH_LENGTH 4096
00053 #endif
00054 
00055 
00056 
00057 
00133 int kdbOpen_backend() {
00134     /* backend initialization logic */
00135     return 0;
00136 }
00137 
00138 
00139 
00140 
00154 int kdbClose_backend() {
00155     /* free all backend resources and shut it down */
00156     return 0; /* success */
00157 }
00158 
00159 
00160 
00171 int kdbStatKey_backend(Key *key) {
00172     /* get the most possible key metainfo */
00173     return 0; /* success */
00174 }
00175 
00176 
00187 int kdbGetKey_backend(Key *key) {
00188     /* fully gets a key */
00189     return 0; /* success */
00190 }
00191 
00192 
00193 
00206 int kdbSetKey_backend(Key *key) {
00207     /* fully sets a key */
00208     return 0; /* success */
00209 }
00210 
00211 
00212 
00219 int kdbRename_backend(Key *key, const char *newName) {
00220     /* rename a key to another name */
00221     return 0; /* success */
00222 }
00223 
00224 
00225 
00226 
00233 int kdbRemoveKey_backend(const Key *key) {
00234     /* remove a key from the database */
00235     return 0;  /* success */
00236 }
00237 
00238 
00239 
00240 
00247 ssize_t kdbGetKeyChildKeys_backend(const Key *parentKey, KeySet *returned, unsigned long options) {
00248     /* retrieve multiple hierarchical keys */
00249     return returned->size; /* success */
00250 }
00251 
00252 
00263 int kdbSetKeys_backend(KeySet *ks) {
00264     /* set many keys */
00265     return 0;
00266 }
00267 
00268 
00277 uint32_t kdbMonitorKeys_backend(KeySet *interests, uint32_t diffMask,
00278         unsigned long iterations, unsigned sleep) {
00279     return 0;
00280 }
00281 
00282 
00283 
00293 uint32_t kdbMonitorKey_backend(Key *interest, uint32_t diffMask,
00294         unsigned long iterations, unsigned sleep) {
00295     return 0;
00296 }
00297 
00298 
00314 KDBBackend *kdbBackendFactory(void) {
00315     return kdbBackendExport(BACKENDNAME,
00316         KDB_BE_OPEN,           &kdbOpen_backend,
00317         KDB_BE_CLOSE,          &kdbClose_backend,
00318         KDB_BE_GETKEY,         &kdbGetKey_backend,
00319         KDB_BE_SETKEY,         &kdbSetKey_backend,
00320         KDB_BE_STATKEY,        &kdbStatKey_backend,
00321         KDB_BE_RENAME,         &kdbRename_backend,
00322         KDB_BE_REMOVEKEY,      &kdbRemoveKey_backend,
00323         KDB_BE_GETCHILD,       &kdbGetKeyChildKeys_backend,
00324         KDB_BE_MONITORKEY,     &kdbMonitorKey_backend,
00325         KDB_BE_MONITORKEYS,    &kdbMonitorKeys_backend,
00326         /* set to default implementation: 
00327          * Don't set default. */
00328 /*      KDB_BE_SETKEYS,        &kdbSetKeys_default,*/
00329         KDB_BE_END);
00330 }

Generated on Sun Feb 19 10:05:37 2006 for Elektra Project by  doxygen 1.3.9.1