Nagios
4.4.6
Dev docs for Nagios core and neb-module hackers
|
Go to the documentation of this file. 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.
struct kvvec * kvvec_create(int hint)
Create a key/value vector.
key/value vector buffer.
Definition: kvvec.h:29
key/value pair One of the two major components of the kvvec api
Definition: kvvec.h:18
int kv_alloc
Allocated size of key/value array.
Definition: kvvec.h:43
int value_len
Length of value.
Definition: kvvec.h:22
char * value
The value.
Definition: kvvec.h:20
int kvv_sorted
Determines if this kvvec has been sorted.
Definition: kvvec.h:45
unsigned long bufsize
Size of buffer (includes overalloc)
Definition: kvvec.h:32
int kv_pairs
Number of key/value pairs.
Definition: kvvec.h:44
key/value vector struct This is the main component of the kvvec library
Definition: kvvec.h:41
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.
unsigned int kvvec_capacity(struct kvvec *kvv)
Return remaining storage capacity of key/value vector.
int kvvec_grow(struct kvvec *kvv, int hint)
Grow a key/value vector.
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 kvvec_destroy(struct kvvec *kvv, int flags)
Destroy a key/value vector.
char * key
The key.
Definition: kvvec.h:19
int kvvec_sort(struct kvvec *kvv)
Sort a key/value vector alphabetically by key name.
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.
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.
struct kvvec * kvvec_init(struct kvvec *kvv, int hint)
Initialize a previously allocated key/value vector.
char * buf
The buffer.
Definition: kvvec.h:30
int kvvec_resize(struct kvvec *kvv, int size)
Resize a key/value vector Used by kvvec_grow().
int key_len
Length of key.
Definition: kvvec.h:21
struct key_value * kv
The key/value array.
Definition: kvvec.h:42
unsigned long buflen
Length of buffer.
Definition: kvvec.h:31