![]() |
CAPS Universe documentation
1.0.4
All you need to know to be successful
|
Simple manager for key/value data pairs in a autosize table. More...
Data Structures | |
| struct | key_value |
Macros | |
| #define | INCREMENT_STEP 10 |
Functions | |
| void | caps_libkv_init (void) |
| static void | init_key_value (struct key_value *kv) |
| static void | cleanup_key_value (struct key_value *kv) |
| static struct key_value * | create_new_key_value_pair (struct caps_kv_table *kvt) |
| const char * | caps_kv_keys_value_get (const struct caps_kv_table *kvt, const char *key) |
| void | caps_kv_raw_entry_get (const struct caps_kv_table *kvt, size_t entry, const char **key, const char **value) |
| void | caps_kv_key_value_add (struct caps_kv_table *kvt, const char *key, const char *value) |
| void | caps_kv_keys_value_set (struct caps_kv_table *kvt, const char *key, const char *val) |
| void | caps_kv_init (struct caps_kv_table *kvt) |
| void | caps_kv_cleanup (struct caps_kv_table *kvt) |
| void | caps_kv_duplicate (struct caps_kv_table *dst, const struct caps_kv_table *src) |
| const struct key_value * | caps_kv_base_get (const struct caps_kv_table *kvt) |
| size_t | caps_kv_element_count_get (const struct caps_kv_table *kvt) |
| static bool | is_keyword (int c) |
| static bool | is_value (int c) |
| static ssize_t | split_key_value (const unsigned char *string, char **key, char **value) |
| int | caps_kv_key_value_parse_from_string (struct caps_kv_table *kvt, const char *string) |
Variables | |
| static const struct caps_table_desc | key_value_desc |
| static const char | its_true [] = "true" |
| #define INCREMENT_STEP 10 |
Whenever the dynamic array is exhausted, create additionally 10 elements
| void caps_libkv_init | ( | void | ) |
Initialize the library prior use
Mostly sets up NLS (if enabled) and its internally used libraries.
|
static |
Init a key/value structure
| [in,out] | kv | The key/value structure to init |
|
static |
Destroy a key/value structure
| [in,out] | kv | The key/value structure to destroy |
|
static |
Create a new key/value structure
| [in,out] | kvt | The key/value table structure |
| const char * caps_kv_keys_value_get | ( | const struct caps_kv_table * | kvt, |
| const char * | key | ||
| ) |
Query the value of the given key
| [in] | kvt | The key/value table to search in |
| [in] | key | The key to search for |
| string | Pointer to the value |
| NULL | If not found |
If a key is found but has no value, it is treated as a boolean key and the return value is always the string 'true'.
| void caps_kv_raw_entry_get | ( | const struct caps_kv_table * | kvt, |
| size_t | entry, | ||
| const char ** | key, | ||
| const char ** | val | ||
| ) |
Retrieve the data of the specified raw table entry
| [in] | kvt | The table to get the raw key/value pair from |
| [in] | entry | Element number |
| [out] | key | Where to store the key component |
| [out] | val | Where to store the value component |
| void caps_kv_key_value_add | ( | struct caps_kv_table * | kvt, |
| const char * | key, | ||
| const char * | value | ||
| ) |
| void caps_kv_keys_value_set | ( | struct caps_kv_table * | kvt, |
| const char * | key, | ||
| const char * | val | ||
| ) |
| void caps_kv_init | ( | struct caps_kv_table * | kvt | ) |
| void caps_kv_cleanup | ( | struct caps_kv_table * | kvt | ) |
| void caps_kv_duplicate | ( | struct caps_kv_table * | dst, |
| const struct caps_kv_table * | src | ||
| ) |
| const struct key_value * caps_kv_base_get | ( | const struct caps_kv_table * | kvt | ) |
Retrieve the array's base pointer
| [in] | kvt | The table to get its base pointer from |
| table | Base address of the managed table |
| NULL | If the table is uninitialized and thus, empty. |
| size_t caps_kv_element_count_get | ( | const struct caps_kv_table * | kvt | ) |
Retrieve the array's used elements count
| [in] | kvt | The table to get the elements count from |
| number | Elements count |
| 0 | If the array is empty. |
|
static |
Control the supported delimiters for key/value strings.
It's still unclear what strings are to be expected: KDE3 will use the space as the delimiter like this:
"sides=two-sided-long-edge copies=2 ColorModel=Mono Duplex=DuplexNoTumble"
but the manpage of cupsdoprint-trinity uses the comma as the delimiter:
"sides=two-sided-long-edge,copies=2,ColorModel=Mono,Duplex=DuplexNoTumble"
But the latter one will conflict with the 'page-ranges' option, which also uses the comma as the delimiter to the next range:
"page-ranges=1-4,7,9-12"
Or the 'media' entry: "media=A4,Normal,Upper" Check if the given character is an allowed one for a keyword
| [in] | c | The character to check |
All kind of characters are allowed for a keyword. Delimiters are:
|
static |
Check if the given character is an allowed one for a value
| [in] | c | The character to check |
All kind of characters are allowed for a value. Delimiters are:
|
static |
Split the first key/value pair from the given string
| [in] | string | String to work on ('\0' terminated) |
| [out] | key | Where to store the 'key' string |
| [out] | value | Where to store the 'value' string |
In case of failure, key and value are undefined!
Examples:
| int caps_kv_key_value_parse_from_string | ( | struct caps_kv_table * | kvt, |
| const char * | string | ||
| ) |
Parse a string with key/value pairs and split and store them into a key/value table
| [in,out] | kvt | The key/value table where to store the result |
| [in] | string | The string to parse (can be NULL, in this case nothing will be done) |
| 0 | on success |
| negative | errno |
The string can be of the form
TonerDensity=1 copies=1 orientation-requested=3
e.g. the key/value delimiter is space and the equal character separates key and value.
|
static |
|
static |
The static return for a boolean key. If it is given without a value, it defaults to 'true'