Git init
[pkgs/e/elektra.git] / src / backends / template / template.c
1 /***************************************************************************
2             template.c  -  Skeleton of backends to access the Key Database
3                              -------------------
4     begin                : Mon Dec 26 2004
5     copyright            : (C) 2004 by Avi Alkalay
6     email                : avi@unix.sh
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the BSD License (revised).                      *
13  *                                                                         *
14  ***************************************************************************/
15
16
17
18 /***************************************************************************
19  *                                                                         *
20  *   This is the skeleton of the methods you'll have to implement in order *
21  *   to provide libelektra.so a valid backend.                             *
22  *   Simple fill the empty _template functions with your code and you are   *
23  *   ready to go.                                                          *
24  *                                                                         *
25  ***************************************************************************/
26
27
28 #include <template.h>
29
30 int kdbOpen_template(KDB *handle)
31 {
32         int errnosave = errno;
33         KDBCap *cap = kdbhGetCapability (handle);
34
35         cap->onlyFullGet=1;
36         cap->noStat=1;
37
38         cap->onlyRemoveAll=1;
39
40         cap->onlyFullSet=1;
41         cap->onlyAddKeys=1;
42
43         cap->onlySystem=1;
44         cap->onlyUser=1;
45
46         cap->noOwner=1;
47         cap->noValue=1;
48         cap->noComment=1;
49         cap->noUID=1;
50         cap->noGID=1;
51         cap->noMode=1;
52         cap->noDir=1;
53         cap->noATime=1;
54         cap->noMTime=1;
55         cap->noCTime=1;
56         cap->noRemove=1;
57         cap->noLink=1;
58         cap->noMount=1;
59         cap->noBinary=1;
60         cap->noString=1;
61         cap->noTypes=1;
62         cap->noError=1;
63
64         cap->noLock=1;
65         cap->noThread=1;
66
67         /* backend initialization logic */
68
69         errno = errnosave;
70         return 0;
71 }
72
73 int kdbClose_template(KDB *handle)
74 {
75         int errnosave = errno;
76         /* free all backend resources and shut it down */
77
78         errno = errnosave;
79         return 0; /* success */
80 }
81
82 ssize_t kdbGet_template(KDB *handle, KeySet *returned, const Key *parentKey)
83 {
84         ssize_t nr_keys = 0;
85         int errnosave = errno;
86
87         /* get all keys below parentKey and count them with nr_keys */
88
89         errno = errnosave;
90         return nr_keys; /* success */
91 }
92
93 ssize_t kdbSet_template(KDB *handle, KeySet *returned, const Key *parentKey)
94 {
95         ssize_t nr_keys = 0;
96         int errnosave = errno;
97
98         /* set all keys below parentKey and count them with nr_keys */
99
100         errno = errnosave;
101         return nr_keys;
102 }
103
104 KDBEXPORT(template)
105 {
106         return kdbBackendExport(BACKENDNAME,
107                 KDB_BE_OPEN,    &kdbOpen_template,
108                 KDB_BE_CLOSE,   &kdbClose_template,
109                 KDB_BE_GET,     &kdbGet_template,
110                 KDB_BE_SET,     &kdbSet_template,
111                 KDB_BE_VERSION,        BACKENDVERSION,
112                 KDB_BE_AUTHOR,  "Full Name <email@libelektra.org>",
113                 KDB_BE_LICENCE, "BSD",
114                 KDB_BE_DESCRIPTION,
115                         "Add description here",
116                 KDB_BE_END);
117 }
118