Git init
[pkgs/e/elektra.git] / doc / elektra-api / man / man3 / internal.3
1 .TH "KDB Backends :: Internal Helper for Elektra" 3 "30 Jun 2009" "Elektra Projekt" \" -*- nroff -*-
2 .ad l
3 .nh
4 .SH NAME
5 KDB Backends :: Internal Helper for Elektra \- Internal Methods for Elektra and Backends.  
6
7 .PP
8 .SS "Functions"
9
10 .in +1c
11 .ti -1c
12 .RI "int \fBkdbiStrCaseCmp\fP (const char *s1, const char *s2)"
13 .br
14 .ti -1c
15 .RI "int \fBkdbiRealloc\fP (void **buffer, size_t size)"
16 .br
17 .ti -1c
18 .RI "void \fBkdbiFree\fP (void *ptr)"
19 .br
20 .ti -1c
21 .RI "char * \fBkdbiStrDup\fP (const char *s)"
22 .br
23 .ti -1c
24 .RI "size_t \fBkdbiStrLen\fP (const char *s)"
25 .br
26 .in -1c
27 .SH "Detailed Description"
28 .PP 
29 Internal Methods for Elektra and Backends. 
30 .PP
31 To use them: 
32 .PP
33 .nf
34  #include <kdbbackend.h>
35
36 .fi
37 .PP
38 .PP
39 There are some areas where libraries have to reimplement some basic functions to archive support for non-standard systems, for testing purposes or to provide a little more convenience. 
40 .SH "Function Documentation"
41 .PP 
42 .SS "void kdbiFree (void * ptr)"
43 .PP
44 Free memory of elektra or its backends.
45 .PP
46 \fBParameters:\fP
47 .RS 4
48 \fIptr\fP the pointer to free
49 .RE
50 .PP
51 \fBSee also:\fP
52 .RS 4
53 kdbiMalloc 
54 .RE
55 .PP
56
57 .SS "int kdbiRealloc (void ** buffer, size_t size)"
58 .PP
59 Reallocate Storage in a save way.
60 .PP
61 .PP
62 .nf
63 if (kdbiRealloc ((void **) & buffer, new_length) < 0) {
64         // here comes the failure handler
65         // you can still use the old buffer
66 #if DEBUG
67         fprintf (stderr, 'Reallocation error\n');
68 #endif
69         free (buffer);
70         buffer = 0;
71         // return with error
72 }
73  *
74 .fi
75 .PP
76 .PP
77 \fBParameters:\fP
78 .RS 4
79 \fIbuffer\fP is a pointer to a malloc 
80 .br
81 \fIsize\fP is the new size for the memory 
82 .RE
83 .PP
84 \fBReturns:\fP
85 .RS 4
86 -1 on failure 
87 .PP
88 0 on success 
89 .RE
90 .PP
91
92 .SS "int kdbiStrCaseCmp (const char * s1, const char * s2)"
93 .PP
94 Compare Strings ignoring case.
95 .PP
96 \fBParameters:\fP
97 .RS 4
98 \fIs1\fP The first string to be compared 
99 .br
100 \fIs2\fP The second string to be compared
101 .RE
102 .PP
103 \fBReturns:\fP
104 .RS 4
105 a negative number if s1 is less than s2 
106 .PP
107 0 if s1 matches s2 
108 .PP
109 a positive number if s1 is greater than s2 
110 .RE
111 .PP
112
113 .SS "char* kdbiStrDup (const char * s)"
114 .PP
115 Copy string into new allocated memory.
116 .PP
117 You need to free the memory yourself.
118 .PP
119 \fBParameters:\fP
120 .RS 4
121 \fIs\fP the null-terminated string to duplicate
122 .RE
123 .PP
124 \fBSee also:\fP
125 .RS 4
126 \fBkdbiFree\fP 
127 .PP
128 \fBkdbiStrLen\fP 
129 .RE
130 .PP
131
132 .SS "size_t kdbiStrLen (const char * s)"
133 .PP
134 Calculates the length in bytes of a string.
135 .PP
136 This function differs from strlen() because it is Unicode and multibyte chars safe. While strlen() counts characters and ignores the final NULL, \fBkdbiStrLen()\fP count bytes including the ending NULL.
137 .PP
138 \fBParameters:\fP
139 .RS 4
140 \fIs\fP the string to get the length from 
141 .RE
142 .PP
143 \fBReturns:\fP
144 .RS 4
145 number of bytes used by the string, including the final NULL. 
146 .RE
147 .PP
148