1 #ifndef LIBNAGIOS_KVVEC_H_INCLUDED 2 #define LIBNAGIOS_KVVEC_H_INCLUDED 49 #define KVVEC_INITIALIZER { NULL, 0, 0, 0 } 52 #define KVVEC_FREE_KEYS 1 53 #define KVVEC_FREE_VALUES 2 55 #define KVVEC_FREE_ALL (KVVEC_FREE_KEYS | KVVEC_FREE_VALUES) 57 #define KVVEC_ASSIGN 0 59 #define KVVEC_APPEND 2 125 extern int kvvec_addkv_wlen(
struct kvvec *kvv,
const char *key,
int keylen,
const char *value,
int valuelen);
134 #define kvvec_addkv(kvv, key, value) kvvec_addkv_wlen(kvv, key, 0, value, 0) 191 extern struct kvvec *
buf2kvvec(
char *str,
unsigned int len,
const char kvsep,
const char pair_sep,
int flags);
205 extern int buf2kvvec_prealloc(
struct kvvec *kvv,
char *str,
unsigned int len,
const char kvsep,
const char pair_sep,
int flags);
struct kvvec_buf * kvvec2buf(struct kvvec *kvv, char kv_sep, char pair_sep, int overalloc)
Create a linear buffer of all the key/value pairs and return it as a kvvec_buf.
int kvvec_foreach(struct kvvec *kvv, void *arg, int(*callback)(struct key_value *, void *))
Walk each key/value pair in a key/value vector, sending them as arguments to a callback function...
int value_len
Length of value.
Definition: kvvec.h:22
struct kvvec * kvvec_init(struct kvvec *kvv, int hint)
Initialize a previously allocated key/value vector.
int kv_pairs
Number of key/value pairs.
Definition: kvvec.h:44
int kvvec_grow(struct kvvec *kvv, int hint)
Grow a key/value vector.
key/value pair One of the two major components of the kvvec api
Definition: kvvec.h:18
int kvvec_sort(struct kvvec *kvv)
Sort a key/value vector alphabetically by key name.
unsigned long bufsize
Size of buffer (includes overalloc)
Definition: kvvec.h:32
key/value vector buffer.
Definition: kvvec.h:29
int kvv_sorted
Determines if this kvvec has been sorted.
Definition: kvvec.h:45
int kvvec_addkv_wlen(struct kvvec *kvv, const char *key, int keylen, const char *value, int valuelen)
Add a key/value pair to an existing key/value vector, with lengths of strings already calculated...
void kvvec_free_kvpairs(struct kvvec *kvv, int flags)
Free key/value pairs associated with a key/value vector.
int buf2kvvec_prealloc(struct kvvec *kvv, char *str, unsigned int len, const char kvsep, const char pair_sep, int flags)
Parse a buffer into the pre-allocated key/value vector.
char * value
The value.
Definition: kvvec.h:20
struct kvvec * buf2kvvec(char *str, unsigned int len, const char kvsep, const char pair_sep, int flags)
Create a key/value vector from a pre-parsed buffer.
char * key
The key.
Definition: kvvec.h:19
int kv_alloc
Allocated size of key/value array.
Definition: kvvec.h:43
int kvvec_resize(struct kvvec *kvv, int size)
Resize a key/value vector Used by kvvec_grow().
int kvvec_destroy(struct kvvec *kvv, int flags)
Destroy a key/value vector.
key/value vector struct This is the main component of the kvvec library
Definition: kvvec.h:41
struct kvvec * kvvec_create(int hint)
Create a key/value vector.
unsigned int kvvec_capacity(struct kvvec *kvv)
Return remaining storage capacity of key/value vector.
struct key_value * kv
The key/value array.
Definition: kvvec.h:42
unsigned long buflen
Length of buffer.
Definition: kvvec.h:31
int key_len
Length of key.
Definition: kvvec.h:21
char * buf
The buffer.
Definition: kvvec.h:30