.TH "functional.c" 3elektra "Fri Aug 4 2023" "Version 0.11.0" "Elektra" \" -*- nroff -*-
.ad l
.nh
.SH NAME
functional.c \- Functional helper\&.  

.SH SYNOPSIS
.br
.PP
\fC#include <kdb\&.h>\fP
.br
\fC#include <errno\&.h>\fP
.br
\fC#include <limits\&.h>\fP
.br
\fC#include <stdio\&.h>\fP
.br
\fC#include <stdlib\&.h>\fP
.br
\fC#include <string\&.h>\fP
.br

.SS "Functions"

.in +1c
.ti -1c
.RI "int \fBelektraKsFilter\fP (KeySet *result, KeySet *input, int(*filter)(const Key *k, void *argument), void *argument)"
.br
.RI "return only those keys from the given keyset that pass the supplied filter function with the supplied argument "
.ti -1c
.RI "int \fBelektraKsToMemArray\fP (KeySet *ks, Key **buffer)"
.br
.RI "Builds an array of pointers to the keys in the supplied keyset\&. "
.in -1c
.SH "Detailed Description"
.PP 
Functional helper\&. 


.PP
\fBCopyright\fP
.RS 4
BSD License (see LICENSE\&.md or https://www.libelektra.org) 
.RE
.PP

.SH "Function Documentation"
.PP 
.SS "int elektraKsFilter (KeySet * result, KeySet * input, int(*)(const Key *k, void *argument) filter, void * argument)"

.PP
return only those keys from the given keyset that pass the supplied filter function with the supplied argument 
.PP
\fBParameters\fP
.RS 4
\fIresult\fP the keyset that should contain the filtered keys 
.br
\fIinput\fP the keyset whose keys should be filtered 
.br
\fIfilter\fP a function pointer to a function that will be used to filter the keyset\&. A key will be taken if the function returns a value greater than 0\&. 
.br
\fIargument\fP an argument that will be passed to the filter function each time it is called 
.RE
.PP
\fBReturns\fP
.RS 4
the number of filtered keys if the filter function always returned a positive value, -1 otherwise 
.RE
.PP
\fBReturn values\fP
.RS 4
\fINULL\fP on NULL pointer 
.RE
.PP

.SS "int elektraKsToMemArray (KeySet * ks, Key ** buffer)"

.PP
Builds an array of pointers to the keys in the supplied keyset\&. The keys are not copied, calling keyDel may remove them from the keyset\&.
.PP
The size of the buffer can be easily allocated via ksGetSize\&. Example: 
.PP
.nf
KeySet *ks = somekeyset;
Key **keyArray = calloc (ksGetSize(ks), sizeof (Key *));
elektraKsToMemArray (ks, keyArray);
\&.\&.\&. work with the array \&.\&.\&.
elektraFree (keyArray);

.fi
.PP
.PP
\fBParameters\fP
.RS 4
\fIks\fP the keyset object to work with 
.br
\fIbuffer\fP the buffer to put the result into 
.RE
.PP
\fBReturns\fP
.RS 4
the number of elements in the array if successful 
.PP
a negative number on null pointers or if an error occurred 
.RE
.PP

.SH "Author"
.PP 
Generated automatically by Doxygen for Elektra from the source code\&.
