Main include of libplist.
More...
#include <stdint.h>
#include <sys/types.h>
#include <stdarg.h>
|
#define | PLIST_WARN_DEPRECATED(x) |
|
#define | _PLIST_IS_TYPE(__plist, __plist_type) (__plist && (plist_get_node_type(__plist) == PLIST_##__plist_type)) |
|
#define | PLIST_IS_BOOLEAN(__plist) _PLIST_IS_TYPE(__plist, BOOLEAN) |
|
#define | PLIST_IS_UINT(__plist) _PLIST_IS_TYPE(__plist, UINT) |
|
#define | PLIST_IS_REAL(__plist) _PLIST_IS_TYPE(__plist, REAL) |
|
#define | PLIST_IS_STRING(__plist) _PLIST_IS_TYPE(__plist, STRING) |
|
#define | PLIST_IS_ARRAY(__plist) _PLIST_IS_TYPE(__plist, ARRAY) |
|
#define | PLIST_IS_DICT(__plist) _PLIST_IS_TYPE(__plist, DICT) |
|
#define | PLIST_IS_DATE(__plist) _PLIST_IS_TYPE(__plist, DATE) |
|
#define | PLIST_IS_DATA(__plist) _PLIST_IS_TYPE(__plist, DATA) |
|
#define | PLIST_IS_KEY(__plist) _PLIST_IS_TYPE(__plist, KEY) |
|
#define | PLIST_IS_UID(__plist) _PLIST_IS_TYPE(__plist, UID) |
|
|
enum | plist_type {
PLIST_BOOLEAN,
PLIST_UINT,
PLIST_REAL,
PLIST_STRING,
PLIST_ARRAY,
PLIST_DICT,
PLIST_DATE,
PLIST_DATA,
PLIST_KEY,
PLIST_UID,
PLIST_NONE
} |
| The enumeration of plist node types. More...
|
|
|
plist_t | plist_new_dict (void) |
| Create a new root plist_t type PLIST_DICT. More...
|
|
plist_t | plist_new_array (void) |
| Create a new root plist_t type PLIST_ARRAY. More...
|
|
plist_t | plist_new_string (const char *val) |
| Create a new plist_t type PLIST_STRING. More...
|
|
plist_t | plist_new_bool (uint8_t val) |
| Create a new plist_t type PLIST_BOOLEAN. More...
|
|
plist_t | plist_new_uint (uint64_t val) |
| Create a new plist_t type PLIST_UINT. More...
|
|
plist_t | plist_new_real (double val) |
| Create a new plist_t type PLIST_REAL. More...
|
|
plist_t | plist_new_data (const char *val, uint64_t length) |
| Create a new plist_t type PLIST_DATA. More...
|
|
plist_t | plist_new_date (int32_t sec, int32_t usec) |
| Create a new plist_t type PLIST_DATE. More...
|
|
plist_t | plist_new_uid (uint64_t val) |
| Create a new plist_t type PLIST_UID. More...
|
|
void | plist_free (plist_t plist) |
| Destruct a plist_t node and all its children recursively. More...
|
|
plist_t | plist_copy (plist_t node) |
| Return a copy of passed node and it's children. More...
|
|
uint32_t | plist_array_get_size (plist_t node) |
| Get size of a PLIST_ARRAY node. More...
|
|
plist_t | plist_array_get_item (plist_t node, uint32_t n) |
| Get the nth item in a PLIST_ARRAY node. More...
|
|
uint32_t | plist_array_get_item_index (plist_t node) |
| Get the index of an item. More...
|
|
void | plist_array_set_item (plist_t node, plist_t item, uint32_t n) |
| Set the nth item in a PLIST_ARRAY node. More...
|
|
void | plist_array_append_item (plist_t node, plist_t item) |
| Append a new item at the end of a PLIST_ARRAY node. More...
|
|
void | plist_array_insert_item (plist_t node, plist_t item, uint32_t n) |
| Insert a new item at position n in a PLIST_ARRAY node. More...
|
|
void | plist_array_remove_item (plist_t node, uint32_t n) |
| Remove an existing position in a PLIST_ARRAY node. More...
|
|
void | plist_array_item_remove (plist_t node) |
| Remove a node that is a child node of a PLIST_ARRAY node. More...
|
|
void | plist_array_new_iter (plist_t node, plist_array_iter *iter) |
| Create an iterator of a PLIST_ARRAY node. More...
|
|
void | plist_array_next_item (plist_t node, plist_array_iter iter, plist_t *item) |
| Increment iterator of a PLIST_ARRAY node. More...
|
|
uint32_t | plist_dict_get_size (plist_t node) |
| Get size of a PLIST_DICT node. More...
|
|
void | plist_dict_new_iter (plist_t node, plist_dict_iter *iter) |
| Create an iterator of a PLIST_DICT node. More...
|
|
void | plist_dict_next_item (plist_t node, plist_dict_iter iter, char **key, plist_t *val) |
| Increment iterator of a PLIST_DICT node. More...
|
|
void | plist_dict_get_item_key (plist_t node, char **key) |
| Get key associated key to an item. More...
|
|
plist_t | plist_dict_get_item (plist_t node, const char *key) |
| Get the nth item in a PLIST_DICT node. More...
|
|
plist_t | plist_dict_item_get_key (plist_t node) |
| Get key node associated to an item. More...
|
|
void | plist_dict_set_item (plist_t node, const char *key, plist_t item) |
| Set item identified by key in a PLIST_DICT node. More...
|
|
void | plist_dict_insert_item (plist_t node, const char *key, plist_t item) |
| Insert a new item into a PLIST_DICT node. More...
|
|
void | plist_dict_remove_item (plist_t node, const char *key) |
| Remove an existing position in a PLIST_DICT node. More...
|
|
void | plist_dict_merge (plist_t *target, plist_t source) |
| Merge a dictionary into another. More...
|
|
plist_t | plist_get_parent (plist_t node) |
| Get the parent of a node. More...
|
|
plist_type | plist_get_node_type (plist_t node) |
| Get the plist_type of a node. More...
|
|
void | plist_get_key_val (plist_t node, char **val) |
| Get the value of a PLIST_KEY node. More...
|
|
void | plist_get_string_val (plist_t node, char **val) |
| Get the value of a PLIST_STRING node. More...
|
|
const char * | plist_get_string_ptr (plist_t node, uint64_t *length) |
| Get a pointer to the buffer of a PLIST_STRING node. More...
|
|
void | plist_get_bool_val (plist_t node, uint8_t *val) |
| Get the value of a PLIST_BOOLEAN node. More...
|
|
void | plist_get_uint_val (plist_t node, uint64_t *val) |
| Get the value of a PLIST_UINT node. More...
|
|
void | plist_get_real_val (plist_t node, double *val) |
| Get the value of a PLIST_REAL node. More...
|
|
void | plist_get_data_val (plist_t node, char **val, uint64_t *length) |
| Get the value of a PLIST_DATA node. More...
|
|
const char * | plist_get_data_ptr (plist_t node, uint64_t *length) |
| Get a pointer to the data buffer of a PLIST_DATA node. More...
|
|
void | plist_get_date_val (plist_t node, int32_t *sec, int32_t *usec) |
| Get the value of a PLIST_DATE node. More...
|
|
void | plist_get_uid_val (plist_t node, uint64_t *val) |
| Get the value of a PLIST_UID node. More...
|
|
void | plist_set_key_val (plist_t node, const char *val) |
| Set the value of a node. More...
|
|
void | plist_set_string_val (plist_t node, const char *val) |
| Set the value of a node. More...
|
|
void | plist_set_bool_val (plist_t node, uint8_t val) |
| Set the value of a node. More...
|
|
void | plist_set_uint_val (plist_t node, uint64_t val) |
| Set the value of a node. More...
|
|
void | plist_set_real_val (plist_t node, double val) |
| Set the value of a node. More...
|
|
void | plist_set_data_val (plist_t node, const char *val, uint64_t length) |
| Set the value of a node. More...
|
|
void | plist_set_date_val (plist_t node, int32_t sec, int32_t usec) |
| Set the value of a node. More...
|
|
void | plist_set_uid_val (plist_t node, uint64_t val) |
| Set the value of a node. More...
|
|
void | plist_to_xml (plist_t plist, char **plist_xml, uint32_t *length) |
| Export the plist_t structure to XML format. More...
|
|
void | plist_to_xml_free (char *plist_xml) |
| Frees the memory allocated by plist_to_xml(). More...
|
|
void | plist_to_bin (plist_t plist, char **plist_bin, uint32_t *length) |
| Export the plist_t structure to binary format. More...
|
|
void | plist_to_bin_free (char *plist_bin) |
| Frees the memory allocated by plist_to_bin(). More...
|
|
void | plist_from_xml (const char *plist_xml, uint32_t length, plist_t *plist) |
| Import the plist_t structure from XML format. More...
|
|
void | plist_from_bin (const char *plist_bin, uint32_t length, plist_t *plist) |
| Import the plist_t structure from binary format. More...
|
|
void | plist_from_memory (const char *plist_data, uint32_t length, plist_t *plist) |
| Import the plist_t structure from memory data. More...
|
|
int | plist_is_binary (const char *plist_data, uint32_t length) |
| Test if in-memory plist data is binary or XML This method will look at the first bytes of plist_data to determine if plist_data contains a binary or XML plist. More...
|
|
plist_t | plist_access_path (plist_t plist, uint32_t length,...) |
| Get a node from its path. More...
|
|
plist_t | plist_access_pathv (plist_t plist, uint32_t length, va_list v) |
| Variadic version of plist_access_path. More...
|
|
char | plist_compare_node_value (plist_t node_l, plist_t node_r) |
| Compare two node values. More...
|
|
int | plist_bool_val_is_true (plist_t boolnode) |
| Helper function to check the value of a PLIST_BOOL node. More...
|
|
int | plist_uint_val_compare (plist_t uintnode, uint64_t cmpval) |
| Helper function to compare the value of a PLIST_UINT node against a given value. More...
|
|
int | plist_uid_val_compare (plist_t uidnode, uint64_t cmpval) |
| Helper function to compare the value of a PLIST_UID node against a given value. More...
|
|
int | plist_real_val_compare (plist_t realnode, double cmpval) |
| Helper function to compare the value of a PLIST_REAL node against a given value. More...
|
|
int | plist_date_val_compare (plist_t datenode, int32_t cmpsec, int32_t cmpusec) |
| Helper function to compare the value of a PLIST_DATE node against a given set of seconds and fraction of a second since epoch. More...
|
|
int | plist_string_val_compare (plist_t strnode, const char *cmpval) |
| Helper function to compare the value of a PLIST_STRING node against a given value. More...
|
|
int | plist_string_val_compare_with_size (plist_t strnode, const char *cmpval, size_t n) |
| Helper function to compare the value of a PLIST_STRING node against a given value, while not comparing more than n characters. More...
|
|
int | plist_string_val_contains (plist_t strnode, const char *substr) |
| Helper function to match a given substring in the value of a PLIST_STRING node. More...
|
|
int | plist_key_val_compare (plist_t keynode, const char *cmpval) |
| Helper function to compare the value of a PLIST_KEY node against a given value. More...
|
|
int | plist_key_val_compare_with_size (plist_t keynode, const char *cmpval, size_t n) |
| Helper function to compare the value of a PLIST_KEY node against a given value, while not comparing more than n characters. More...
|
|
int | plist_key_val_contains (plist_t keynode, const char *substr) |
| Helper function to match a given substring in the value of a PLIST_KEY node. More...
|
|
int | plist_data_val_compare (plist_t datanode, const uint8_t *cmpval, size_t n) |
| Helper function to compare the data of a PLIST_DATA node against a given blob and size. More...
|
|
int | plist_data_val_compare_with_size (plist_t datanode, const uint8_t *cmpval, size_t n) |
| Helper function to compare the data of a PLIST_DATA node against a given blob and size, while no more than n bytes are compared. More...
|
|
int | plist_data_val_contains (plist_t datanode, const uint8_t *cmpval, size_t n) |
| Helper function to match a given data blob within the value of a PLIST_DATA node. More...
|
|
Main include of libplist.
◆ plist_type
The enumeration of plist node types.
Enumerator |
---|
PLIST_BOOLEAN | Boolean, scalar type.
|
PLIST_UINT | Unsigned integer, scalar type.
|
PLIST_REAL | Real, scalar type.
|
PLIST_STRING | ASCII string, scalar type.
|
PLIST_ARRAY | Ordered array, structured type.
|
PLIST_DICT | Unordered dictionary (key/value pair), structured type.
|
PLIST_DATE | Date, scalar type.
|
PLIST_DATA | Binary data, scalar type.
|
PLIST_KEY | Key in dictionaries (ASCII String), scalar type.
|
PLIST_UID | Special type used for 'keyed encoding'.
|
PLIST_NONE | No type.
|
◆ plist_access_path()
Get a node from its path.
Each path element depends on the associated father node type. For Dictionaries, var args are casted to const char*, for arrays, var args are caster to uint32_t Search is breath first order.
- Parameters
-
plist | the node to access result from. |
length | length of the path to access |
- Returns
- the value to access.
◆ plist_access_pathv()
plist_t plist_access_pathv |
( |
plist_t |
plist, |
|
|
uint32_t |
length, |
|
|
va_list |
v |
|
) |
| |
Variadic version of plist_access_path.
- Parameters
-
plist | the node to access result from. |
length | length of the path to access |
v | list of array's index and dic'st key |
- Returns
- the value to access.
◆ plist_array_append_item()
Append a new item at the end of a PLIST_ARRAY node.
- Parameters
-
node | the node of type PLIST_ARRAY |
item | the new item. The array is responsible for freeing item when it is no longer needed. |
◆ plist_array_get_item()
Get the nth item in a PLIST_ARRAY node.
- Parameters
-
node | the node of type PLIST_ARRAY |
n | the index of the item to get. Range is [0, array_size[ |
- Returns
- the nth item or NULL if node is not of type PLIST_ARRAY
◆ plist_array_get_item_index()
uint32_t plist_array_get_item_index |
( |
plist_t |
node | ) |
|
Get the index of an item.
item must be a member of a PLIST_ARRAY node.
- Parameters
-
- Returns
- the node index or UINT_MAX if node index can't be determined
◆ plist_array_get_size()
uint32_t plist_array_get_size |
( |
plist_t |
node | ) |
|
◆ plist_array_insert_item()
void plist_array_insert_item |
( |
plist_t |
node, |
|
|
plist_t |
item, |
|
|
uint32_t |
n |
|
) |
| |
Insert a new item at position n in a PLIST_ARRAY node.
- Parameters
-
node | the node of type PLIST_ARRAY |
item | the new item to insert. The array is responsible for freeing item when it is no longer needed. |
n | The position at which the node will be stored. Range is [0, array_size[. Assert if n is not in range. |
◆ plist_array_item_remove()
void plist_array_item_remove |
( |
plist_t |
node | ) |
|
Remove a node that is a child node of a PLIST_ARRAY node.
node will be freed using plist_free.
- Parameters
-
node | The node to be removed from its PLIST_ARRAY parent. |
◆ plist_array_new_iter()
Create an iterator of a PLIST_ARRAY node.
The allocated iterator should be freed with the standard free function.
- Parameters
-
node | The node of type PLIST_ARRAY |
iter | Location to store the iterator for the array. |
◆ plist_array_next_item()
Increment iterator of a PLIST_ARRAY node.
- Parameters
-
node | The node of type PLIST_ARRAY. |
iter | Iterator of the array |
item | Location to store the item. The caller must not free the returned item. Will be set to NULL when no more items are left to iterate. |
◆ plist_array_remove_item()
void plist_array_remove_item |
( |
plist_t |
node, |
|
|
uint32_t |
n |
|
) |
| |
Remove an existing position in a PLIST_ARRAY node.
Removed position will be freed using plist_free.
- Parameters
-
node | the node of type PLIST_ARRAY |
n | The position to remove. Range is [0, array_size[. Assert if n is not in range. |
◆ plist_array_set_item()
Set the nth item in a PLIST_ARRAY node.
The previous item at index n will be freed using plist_free
- Parameters
-
node | the node of type PLIST_ARRAY |
item | the new item at index n. The array is responsible for freeing item when it is no longer needed. |
n | the index of the item to get. Range is [0, array_size[. Assert if n is not in range. |
◆ plist_bool_val_is_true()
int plist_bool_val_is_true |
( |
plist_t |
boolnode | ) |
|
Helper function to check the value of a PLIST_BOOL node.
- Parameters
-
boolnode | node of type PLIST_BOOL |
- Returns
- 1 if the boolean node has a value of TRUE, 0 if FALSE, or -1 if the node is not of type PLIST_BOOL
◆ plist_compare_node_value()
Compare two node values.
- Parameters
-
node_l | left node to compare |
node_r | rigth node to compare |
- Returns
- TRUE is type and value match, FALSE otherwise.
◆ plist_copy()
Return a copy of passed node and it's children.
- Parameters
-
- Returns
- copied plist
◆ plist_data_val_compare()
int plist_data_val_compare |
( |
plist_t |
datanode, |
|
|
const uint8_t * |
cmpval, |
|
|
size_t |
n |
|
) |
| |
Helper function to compare the data of a PLIST_DATA node against a given blob and size.
This function basically behaves like memcmp after making sure the size of the node's data value is equal to the size of cmpval (n), making this a "full match" comparison.
- Parameters
-
datanode | node of type PLIST_DATA |
cmpval | data blob to compare against |
n | size of data blob passed in cmpval |
- Returns
- 0 if the node's data blob and cmpval are equal, > 0 if the node's value is lexicographically greater than cmpval, or < 0 if the node's value is lexicographically less than cmpval.
◆ plist_data_val_compare_with_size()
int plist_data_val_compare_with_size |
( |
plist_t |
datanode, |
|
|
const uint8_t * |
cmpval, |
|
|
size_t |
n |
|
) |
| |
Helper function to compare the data of a PLIST_DATA node against a given blob and size, while no more than n bytes are compared.
This function basically behaves like memcmp after making sure the size of the node's data value is at least n, making this a "starts with" comparison.
- Parameters
-
datanode | node of type PLIST_DATA |
cmpval | data blob to compare against |
n | size of data blob passed in cmpval |
- Returns
- 0 if the node's value and cmpval are equal, > 0 if the node's value is lexicographically greater than cmpval, or < 0 if the node's value is lexicographically less than cmpval.
◆ plist_data_val_contains()
int plist_data_val_contains |
( |
plist_t |
datanode, |
|
|
const uint8_t * |
cmpval, |
|
|
size_t |
n |
|
) |
| |
Helper function to match a given data blob within the value of a PLIST_DATA node.
- Parameters
-
datanode | node of type PLIST_KEY |
cmpval | data blob to match |
n | size of data blob passed in cmpval |
- Returns
- 1 if the node's value contains the given data blob or 0 if not.
◆ plist_date_val_compare()
int plist_date_val_compare |
( |
plist_t |
datenode, |
|
|
int32_t |
cmpsec, |
|
|
int32_t |
cmpusec |
|
) |
| |
Helper function to compare the value of a PLIST_DATE node against a given set of seconds and fraction of a second since epoch.
- Parameters
-
datenode | node of type PLIST_DATE |
cmpsec | number of seconds since epoch to compare against |
cmpusec | fraction of a second in microseconds to compare against |
- Returns
- 0 if the node's date is equal to the supplied values, 1 if the node's date is greater than the supplied values, or -1 if the node's date is less than the supplied values.
◆ plist_dict_get_item()
Get the nth item in a PLIST_DICT node.
- Parameters
-
node | the node of type PLIST_DICT |
key | the identifier of the item to get. |
- Returns
- the item or NULL if node is not of type PLIST_DICT. The caller should not free the returned node.
◆ plist_dict_get_item_key()
void plist_dict_get_item_key |
( |
plist_t |
node, |
|
|
char ** |
key |
|
) |
| |
Get key associated key to an item.
Item must be member of a dictionary.
- Parameters
-
node | the item |
key | a location to store the key. The caller is responsible for freeing the returned string. |
◆ plist_dict_get_size()
uint32_t plist_dict_get_size |
( |
plist_t |
node | ) |
|
◆ plist_dict_insert_item()
void plist_dict_insert_item |
( |
plist_t |
node, |
|
|
const char * |
key, |
|
|
plist_t |
item |
|
) |
| |
Insert a new item into a PLIST_DICT node.
- Deprecated:
- Deprecated. Use plist_dict_set_item instead.
- Parameters
-
node | the node of type PLIST_DICT |
item | the new item to insert |
key | The identifier of the item to insert. |
◆ plist_dict_item_get_key()
Get key node associated to an item.
Item must be member of a dictionary.
- Parameters
-
- Returns
- the key node of the given item, or NULL.
◆ plist_dict_merge()
Merge a dictionary into another.
This will add all key/value pairs from the source dictionary to the target dictionary, overwriting any existing key/value pairs that are already present in target.
- Parameters
-
target | pointer to an existing node of type PLIST_DICT |
source | node of type PLIST_DICT that should be merged into target |
◆ plist_dict_new_iter()
Create an iterator of a PLIST_DICT node.
The allocated iterator should be freed with the standard free function.
- Parameters
-
node | The node of type PLIST_DICT. |
iter | Location to store the iterator for the dictionary. |
◆ plist_dict_next_item()
Increment iterator of a PLIST_DICT node.
- Parameters
-
node | The node of type PLIST_DICT |
iter | Iterator of the dictionary |
key | Location to store the key, or NULL. The caller is responsible for freeing the the returned string. |
val | Location to store the value, or NULL. The caller must not free the returned value. Will be set to NULL when no more key/value pairs are left to iterate. |
◆ plist_dict_remove_item()
void plist_dict_remove_item |
( |
plist_t |
node, |
|
|
const char * |
key |
|
) |
| |
Remove an existing position in a PLIST_DICT node.
Removed position will be freed using plist_free
- Parameters
-
node | the node of type PLIST_DICT |
key | The identifier of the item to remove. Assert if identifier is not present. |
◆ plist_dict_set_item()
void plist_dict_set_item |
( |
plist_t |
node, |
|
|
const char * |
key, |
|
|
plist_t |
item |
|
) |
| |
Set item identified by key in a PLIST_DICT node.
The previous item identified by key will be freed using plist_free. If there is no item for the given key a new item will be inserted.
- Parameters
-
node | the node of type PLIST_DICT |
item | the new item associated to key |
key | the identifier of the item to set. |
◆ plist_free()
Destruct a plist_t node and all its children recursively.
- Parameters
-
◆ plist_from_bin()
void plist_from_bin |
( |
const char * |
plist_bin, |
|
|
uint32_t |
length, |
|
|
plist_t * |
plist |
|
) |
| |
Import the plist_t structure from binary format.
- Parameters
-
plist_bin | a pointer to the xml buffer. |
length | length of the buffer to read. |
plist | a pointer to the imported plist. |
◆ plist_from_memory()
void plist_from_memory |
( |
const char * |
plist_data, |
|
|
uint32_t |
length, |
|
|
plist_t * |
plist |
|
) |
| |
Import the plist_t structure from memory data.
This method will look at the first bytes of plist_data to determine if plist_data contains a binary or XML plist.
- Parameters
-
plist_data | a pointer to the memory buffer containing plist data. |
length | length of the buffer to read. |
plist | a pointer to the imported plist. |
◆ plist_from_xml()
void plist_from_xml |
( |
const char * |
plist_xml, |
|
|
uint32_t |
length, |
|
|
plist_t * |
plist |
|
) |
| |
Import the plist_t structure from XML format.
- Parameters
-
plist_xml | a pointer to the xml buffer. |
length | length of the buffer to read. |
plist | a pointer to the imported plist. |
◆ plist_get_bool_val()
void plist_get_bool_val |
( |
plist_t |
node, |
|
|
uint8_t * |
val |
|
) |
| |
Get the value of a PLIST_BOOLEAN node.
This function does nothing if node is not of type PLIST_BOOLEAN
- Parameters
-
node | the node |
val | a pointer to a uint8_t variable. |
◆ plist_get_data_ptr()
const char* plist_get_data_ptr |
( |
plist_t |
node, |
|
|
uint64_t * |
length |
|
) |
| |
Get a pointer to the data buffer of a PLIST_DATA node.
- Note
- DO NOT MODIFY the buffer. Mind that the buffer is only available until the plist node gets freed. Make a copy if needed.
- Parameters
-
node | The node |
length | Pointer to a uint64_t that will be set to the length of the buffer |
- Returns
- Pointer to the buffer
◆ plist_get_data_val()
void plist_get_data_val |
( |
plist_t |
node, |
|
|
char ** |
val, |
|
|
uint64_t * |
length |
|
) |
| |
Get the value of a PLIST_DATA node.
This function does nothing if node is not of type PLIST_DATA
- Parameters
-
node | the node |
val | a pointer to an unallocated char buffer. This function allocates the memory, caller is responsible for freeing it. |
length | the length of the buffer |
◆ plist_get_date_val()
void plist_get_date_val |
( |
plist_t |
node, |
|
|
int32_t * |
sec, |
|
|
int32_t * |
usec |
|
) |
| |
Get the value of a PLIST_DATE node.
This function does nothing if node is not of type PLIST_DATE
- Parameters
-
node | the node |
sec | a pointer to an int32_t variable. Represents the number of seconds since 01/01/2001. |
usec | a pointer to an int32_t variable. Represents the number of microseconds |
◆ plist_get_key_val()
void plist_get_key_val |
( |
plist_t |
node, |
|
|
char ** |
val |
|
) |
| |
Get the value of a PLIST_KEY node.
This function does nothing if node is not of type PLIST_KEY
- Parameters
-
node | the node |
val | a pointer to a C-string. This function allocates the memory, caller is responsible for freeing it. |
◆ plist_get_node_type()
Get the plist_type of a node.
- Parameters
-
- Returns
- the type of the node
◆ plist_get_parent()
Get the parent of a node.
- Parameters
-
node | the parent (NULL if node is root) |
◆ plist_get_real_val()
void plist_get_real_val |
( |
plist_t |
node, |
|
|
double * |
val |
|
) |
| |
Get the value of a PLIST_REAL node.
This function does nothing if node is not of type PLIST_REAL
- Parameters
-
node | the node |
val | a pointer to a double variable. |
◆ plist_get_string_ptr()
const char* plist_get_string_ptr |
( |
plist_t |
node, |
|
|
uint64_t * |
length |
|
) |
| |
Get a pointer to the buffer of a PLIST_STRING node.
- Note
- DO NOT MODIFY the buffer. Mind that the buffer is only available until the plist node gets freed. Make a copy if needed.
- Parameters
-
node | The node |
length | If non-NULL, will be set to the length of the string |
- Returns
- Pointer to the NULL-terminated buffer.
◆ plist_get_string_val()
void plist_get_string_val |
( |
plist_t |
node, |
|
|
char ** |
val |
|
) |
| |
Get the value of a PLIST_STRING node.
This function does nothing if node is not of type PLIST_STRING
- Parameters
-
node | the node |
val | a pointer to a C-string. This function allocates the memory, caller is responsible for freeing it. Data is UTF-8 encoded. |
◆ plist_get_uid_val()
void plist_get_uid_val |
( |
plist_t |
node, |
|
|
uint64_t * |
val |
|
) |
| |
Get the value of a PLIST_UID node.
This function does nothing if node is not of type PLIST_UID
- Parameters
-
node | the node |
val | a pointer to a uint64_t variable. |
◆ plist_get_uint_val()
void plist_get_uint_val |
( |
plist_t |
node, |
|
|
uint64_t * |
val |
|
) |
| |
Get the value of a PLIST_UINT node.
This function does nothing if node is not of type PLIST_UINT
- Parameters
-
node | the node |
val | a pointer to a uint64_t variable. |
◆ plist_is_binary()
int plist_is_binary |
( |
const char * |
plist_data, |
|
|
uint32_t |
length |
|
) |
| |
Test if in-memory plist data is binary or XML This method will look at the first bytes of plist_data to determine if plist_data contains a binary or XML plist.
This method is not validating the whole memory buffer to check if the content is truly a plist, it's only using some heuristic on the first few bytes of plist_data.
- Parameters
-
plist_data | a pointer to the memory buffer containing plist data. |
length | length of the buffer to read. |
- Returns
- 1 if the buffer is a binary plist, 0 otherwise.
◆ plist_key_val_compare()
int plist_key_val_compare |
( |
plist_t |
keynode, |
|
|
const char * |
cmpval |
|
) |
| |
Helper function to compare the value of a PLIST_KEY node against a given value.
This function basically behaves like strcmp.
- Parameters
-
keynode | node of type PLIST_KEY |
cmpval | value to compare against |
- Returns
- 0 if the node's value and cmpval are equal, > 0 if the node's value is lexicographically greater than cmpval, or < 0 if the node's value is lexicographically less than cmpval.
◆ plist_key_val_compare_with_size()
int plist_key_val_compare_with_size |
( |
plist_t |
keynode, |
|
|
const char * |
cmpval, |
|
|
size_t |
n |
|
) |
| |
Helper function to compare the value of a PLIST_KEY node against a given value, while not comparing more than n characters.
This function basically behaves like strncmp.
- Parameters
-
keynode | node of type PLIST_KEY |
cmpval | value to compare against |
n | maximum number of characters to compare |
- Returns
- 0 if the node's value and cmpval are equal, > 0 if the node's value is lexicographically greater than cmpval, or < 0 if the node's value is lexicographically less than cmpval.
◆ plist_key_val_contains()
int plist_key_val_contains |
( |
plist_t |
keynode, |
|
|
const char * |
substr |
|
) |
| |
Helper function to match a given substring in the value of a PLIST_KEY node.
- Parameters
-
keynode | node of type PLIST_KEY |
substr | value to match |
- Returns
- 1 if the node's value contains the given substring, or 0 if not.
◆ plist_new_array()
◆ plist_new_bool()
plist_t plist_new_bool |
( |
uint8_t |
val | ) |
|
Create a new plist_t type PLIST_BOOLEAN.
- Parameters
-
val | the boolean value, 0 is false, other values are true. |
- Returns
- the created item
- See also
- plist_type
◆ plist_new_data()
plist_t plist_new_data |
( |
const char * |
val, |
|
|
uint64_t |
length |
|
) |
| |
Create a new plist_t type PLIST_DATA.
- Parameters
-
val | the binary buffer |
length | the length of the buffer |
- Returns
- the created item
- See also
- plist_type
◆ plist_new_date()
plist_t plist_new_date |
( |
int32_t |
sec, |
|
|
int32_t |
usec |
|
) |
| |
Create a new plist_t type PLIST_DATE.
- Parameters
-
sec | the number of seconds since 01/01/2001 |
usec | the number of microseconds |
- Returns
- the created item
- See also
- plist_type
◆ plist_new_dict()
◆ plist_new_real()
plist_t plist_new_real |
( |
double |
val | ) |
|
◆ plist_new_string()
plist_t plist_new_string |
( |
const char * |
val | ) |
|
Create a new plist_t type PLIST_STRING.
- Parameters
-
val | the sting value, encoded in UTF8. |
- Returns
- the created item
- See also
- plist_type
◆ plist_new_uid()
plist_t plist_new_uid |
( |
uint64_t |
val | ) |
|
Create a new plist_t type PLIST_UID.
- Parameters
-
val | the unsigned integer value |
- Returns
- the created item
- See also
- plist_type
◆ plist_new_uint()
plist_t plist_new_uint |
( |
uint64_t |
val | ) |
|
Create a new plist_t type PLIST_UINT.
- Parameters
-
val | the unsigned integer value |
- Returns
- the created item
- See also
- plist_type
◆ plist_real_val_compare()
int plist_real_val_compare |
( |
plist_t |
realnode, |
|
|
double |
cmpval |
|
) |
| |
Helper function to compare the value of a PLIST_REAL node against a given value.
- Note
- WARNING: Comparing floating point values can give inaccurate results because of the nature of floating point values on computer systems. While this function is designed to be as accurate as possible, please don't rely on it too much.
- Parameters
-
realnode | node of type PLIST_REAL |
cmpval | value to compare against |
- Returns
- 0 if the node's value and cmpval are (almost) equal, 1 if the node's value is greater than cmpval, or -1 if the node's value is less than cmpval.
◆ plist_set_bool_val()
void plist_set_bool_val |
( |
plist_t |
node, |
|
|
uint8_t |
val |
|
) |
| |
Set the value of a node.
Forces type of node to PLIST_BOOLEAN
- Parameters
-
node | the node |
val | the boolean value |
◆ plist_set_data_val()
void plist_set_data_val |
( |
plist_t |
node, |
|
|
const char * |
val, |
|
|
uint64_t |
length |
|
) |
| |
Set the value of a node.
Forces type of node to PLIST_DATA
- Parameters
-
node | the node |
val | the binary buffer. The buffer is copied when set and will be freed by the node. |
length | the length of the buffer |
◆ plist_set_date_val()
void plist_set_date_val |
( |
plist_t |
node, |
|
|
int32_t |
sec, |
|
|
int32_t |
usec |
|
) |
| |
Set the value of a node.
Forces type of node to PLIST_DATE
- Parameters
-
node | the node |
sec | the number of seconds since 01/01/2001 |
usec | the number of microseconds |
◆ plist_set_key_val()
void plist_set_key_val |
( |
plist_t |
node, |
|
|
const char * |
val |
|
) |
| |
Set the value of a node.
Forces type of node to PLIST_KEY
- Parameters
-
node | the node |
val | the key value |
◆ plist_set_real_val()
void plist_set_real_val |
( |
plist_t |
node, |
|
|
double |
val |
|
) |
| |
Set the value of a node.
Forces type of node to PLIST_REAL
- Parameters
-
node | the node |
val | the real value |
◆ plist_set_string_val()
void plist_set_string_val |
( |
plist_t |
node, |
|
|
const char * |
val |
|
) |
| |
Set the value of a node.
Forces type of node to PLIST_STRING
- Parameters
-
node | the node |
val | the string value. The string is copied when set and will be freed by the node. |
◆ plist_set_uid_val()
void plist_set_uid_val |
( |
plist_t |
node, |
|
|
uint64_t |
val |
|
) |
| |
Set the value of a node.
Forces type of node to PLIST_UID
- Parameters
-
node | the node |
val | the unsigned integer value |
◆ plist_set_uint_val()
void plist_set_uint_val |
( |
plist_t |
node, |
|
|
uint64_t |
val |
|
) |
| |
Set the value of a node.
Forces type of node to PLIST_UINT
- Parameters
-
node | the node |
val | the unsigned integer value |
◆ plist_string_val_compare()
int plist_string_val_compare |
( |
plist_t |
strnode, |
|
|
const char * |
cmpval |
|
) |
| |
Helper function to compare the value of a PLIST_STRING node against a given value.
This function basically behaves like strcmp.
- Parameters
-
strnode | node of type PLIST_STRING |
cmpval | value to compare against |
- Returns
- 0 if the node's value and cmpval are equal, > 0 if the node's value is lexicographically greater than cmpval, or < 0 if the node's value is lexicographically less than cmpval.
◆ plist_string_val_compare_with_size()
int plist_string_val_compare_with_size |
( |
plist_t |
strnode, |
|
|
const char * |
cmpval, |
|
|
size_t |
n |
|
) |
| |
Helper function to compare the value of a PLIST_STRING node against a given value, while not comparing more than n characters.
This function basically behaves like strncmp.
- Parameters
-
strnode | node of type PLIST_STRING |
cmpval | value to compare against |
n | maximum number of characters to compare |
- Returns
- 0 if the node's value and cmpval are equal, > 0 if the node's value is lexicographically greater than cmpval, or < 0 if the node's value is lexicographically less than cmpval.
◆ plist_string_val_contains()
int plist_string_val_contains |
( |
plist_t |
strnode, |
|
|
const char * |
substr |
|
) |
| |
Helper function to match a given substring in the value of a PLIST_STRING node.
- Parameters
-
strnode | node of type PLIST_STRING |
substr | value to match |
- Returns
- 1 if the node's value contains the given substring, or 0 if not.
◆ plist_to_bin()
void plist_to_bin |
( |
plist_t |
plist, |
|
|
char ** |
plist_bin, |
|
|
uint32_t * |
length |
|
) |
| |
Export the plist_t structure to binary format.
- Parameters
-
plist | the root node to export |
plist_bin | a pointer to a char* buffer. This function allocates the memory, caller is responsible for freeing it. |
length | a pointer to an uint32_t variable. Represents the length of the allocated buffer. |
◆ plist_to_bin_free()
void plist_to_bin_free |
( |
char * |
plist_bin | ) |
|
◆ plist_to_xml()
void plist_to_xml |
( |
plist_t |
plist, |
|
|
char ** |
plist_xml, |
|
|
uint32_t * |
length |
|
) |
| |
Export the plist_t structure to XML format.
- Parameters
-
plist | the root node to export |
plist_xml | a pointer to a C-string. This function allocates the memory, caller is responsible for freeing it. Data is UTF-8 encoded. |
length | a pointer to an uint32_t variable. Represents the length of the allocated buffer. |
◆ plist_to_xml_free()
void plist_to_xml_free |
( |
char * |
plist_xml | ) |
|
◆ plist_uid_val_compare()
int plist_uid_val_compare |
( |
plist_t |
uidnode, |
|
|
uint64_t |
cmpval |
|
) |
| |
Helper function to compare the value of a PLIST_UID node against a given value.
- Parameters
-
uidnode | node of type PLIST_UID |
cmpval | value to compare against |
- Returns
- 0 if the node's value and cmpval are equal, 1 if the node's value is greater than cmpval, or -1 if the node's value is less than cmpval.
◆ plist_uint_val_compare()
int plist_uint_val_compare |
( |
plist_t |
uintnode, |
|
|
uint64_t |
cmpval |
|
) |
| |
Helper function to compare the value of a PLIST_UINT node against a given value.
- Parameters
-
uintnode | node of type PLIST_UINT |
cmpval | value to compare against |
- Returns
- 0 if the node's value and cmpval are equal, 1 if the node's value is greater than cmpval, or -1 if the node's value is less than cmpval.
void plist_dict_remove_item(plist_t node, const char *key)
Remove an existing position in a PLIST_DICT node.
void plist_get_data_val(plist_t node, char **val, uint64_t *length)
Get the value of a PLIST_DATA node.
plist_type
The enumeration of plist node types.
Definition: plist.h:104
void plist_set_real_val(plist_t node, double val)
Set the value of a node.
plist_t plist_access_path(plist_t plist, uint32_t length,...)
Get a node from its path.
void * plist_dict_iter
The plist dictionary iterator.
Definition: plist.h:94
int plist_data_val_contains(plist_t datanode, const uint8_t *cmpval, size_t n)
Helper function to match a given data blob within the value of a PLIST_DATA node.
void plist_from_xml(const char *plist_xml, uint32_t length, plist_t *plist)
Import the plist_t structure from XML format.
void plist_get_key_val(plist_t node, char **val)
Get the value of a PLIST_KEY node.
plist_t plist_new_uid(uint64_t val)
Create a new plist_t type PLIST_UID.
void plist_free(plist_t plist)
Destruct a plist_t node and all its children recursively.
@ PLIST_DICT
Unordered dictionary (key/value pair), structured type.
Definition: plist.h:111
plist_t plist_new_date(int32_t sec, int32_t usec)
Create a new plist_t type PLIST_DATE.
@ PLIST_BOOLEAN
Boolean, scalar type.
Definition: plist.h:106
@ PLIST_UINT
Unsigned integer, scalar type.
Definition: plist.h:107
uint32_t plist_array_get_size(plist_t node)
Get size of a PLIST_ARRAY node.
void plist_get_string_val(plist_t node, char **val)
Get the value of a PLIST_STRING node.
void plist_to_bin(plist_t plist, char **plist_bin, uint32_t *length)
Export the plist_t structure to binary format.
void * plist_t
The basic plist abstract data type.
Definition: plist.h:89
plist_t plist_new_array(void)
Create a new root plist_t type PLIST_ARRAY.
plist_t plist_new_real(double val)
Create a new plist_t type PLIST_REAL.
void plist_get_date_val(plist_t node, int32_t *sec, int32_t *usec)
Get the value of a PLIST_DATE node.
int plist_data_val_compare_with_size(plist_t datanode, const uint8_t *cmpval, size_t n)
Helper function to compare the data of a PLIST_DATA node against a given blob and size,...
void plist_set_bool_val(plist_t node, uint8_t val)
Set the value of a node.
int plist_is_binary(const char *plist_data, uint32_t length)
Test if in-memory plist data is binary or XML This method will look at the first bytes of plist_data ...
@ PLIST_DATE
Date, scalar type.
Definition: plist.h:112
void plist_dict_new_iter(plist_t node, plist_dict_iter *iter)
Create an iterator of a PLIST_DICT node.
int plist_date_val_compare(plist_t datenode, int32_t cmpsec, int32_t cmpusec)
Helper function to compare the value of a PLIST_DATE node against a given set of seconds and fraction...
@ PLIST_UID
Special type used for 'keyed encoding'.
Definition: plist.h:115
void plist_from_bin(const char *plist_bin, uint32_t length, plist_t *plist)
Import the plist_t structure from binary format.
int plist_bool_val_is_true(plist_t boolnode)
Helper function to check the value of a PLIST_BOOL node.
void plist_array_new_iter(plist_t node, plist_array_iter *iter)
Create an iterator of a PLIST_ARRAY node.
void plist_array_item_remove(plist_t node)
Remove a node that is a child node of a PLIST_ARRAY node.
void plist_get_uint_val(plist_t node, uint64_t *val)
Get the value of a PLIST_UINT node.
plist_type plist_get_node_type(plist_t node)
Get the plist_type of a node.
plist_t plist_dict_get_item(plist_t node, const char *key)
Get the nth item in a PLIST_DICT node.
uint32_t plist_dict_get_size(plist_t node)
Get size of a PLIST_DICT node.
void plist_set_uid_val(plist_t node, uint64_t val)
Set the value of a node.
void plist_get_uid_val(plist_t node, uint64_t *val)
Get the value of a PLIST_UID node.
int plist_uint_val_compare(plist_t uintnode, uint64_t cmpval)
Helper function to compare the value of a PLIST_UINT node against a given value.
plist_t plist_new_data(const char *val, uint64_t length)
Create a new plist_t type PLIST_DATA.
void plist_get_bool_val(plist_t node, uint8_t *val)
Get the value of a PLIST_BOOLEAN node.
int plist_key_val_compare(plist_t keynode, const char *cmpval)
Helper function to compare the value of a PLIST_KEY node against a given value.
plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v)
Variadic version of plist_access_path.
void plist_set_string_val(plist_t node, const char *val)
Set the value of a node.
char plist_compare_node_value(plist_t node_l, plist_t node_r)
Compare two node values.
void plist_set_data_val(plist_t node, const char *val, uint64_t length)
Set the value of a node.
void * plist_array_iter
The plist array iterator.
Definition: plist.h:99
plist_t plist_new_string(const char *val)
Create a new plist_t type PLIST_STRING.
void plist_array_append_item(plist_t node, plist_t item)
Append a new item at the end of a PLIST_ARRAY node.
void plist_dict_merge(plist_t *target, plist_t source)
Merge a dictionary into another.
int plist_uid_val_compare(plist_t uidnode, uint64_t cmpval)
Helper function to compare the value of a PLIST_UID node against a given value.
@ PLIST_KEY
Key in dictionaries (ASCII String), scalar type.
Definition: plist.h:114
plist_t plist_array_get_item(plist_t node, uint32_t n)
Get the nth item in a PLIST_ARRAY node.
plist_t plist_new_bool(uint8_t val)
Create a new plist_t type PLIST_BOOLEAN.
void plist_array_remove_item(plist_t node, uint32_t n)
Remove an existing position in a PLIST_ARRAY node.
plist_t plist_copy(plist_t node)
Return a copy of passed node and it's children.
void plist_to_xml(plist_t plist, char **plist_xml, uint32_t *length)
Export the plist_t structure to XML format.
void plist_get_real_val(plist_t node, double *val)
Get the value of a PLIST_REAL node.
void plist_from_memory(const char *plist_data, uint32_t length, plist_t *plist)
Import the plist_t structure from memory data.
void plist_set_key_val(plist_t node, const char *val)
Set the value of a node.
@ PLIST_ARRAY
Ordered array, structured type.
Definition: plist.h:110
int plist_real_val_compare(plist_t realnode, double cmpval)
Helper function to compare the value of a PLIST_REAL node against a given value.
void plist_to_xml_free(char *plist_xml)
Frees the memory allocated by plist_to_xml().
int plist_key_val_contains(plist_t keynode, const char *substr)
Helper function to match a given substring in the value of a PLIST_KEY node.
int plist_key_val_compare_with_size(plist_t keynode, const char *cmpval, size_t n)
Helper function to compare the value of a PLIST_KEY node against a given value, while not comparing m...
void plist_array_next_item(plist_t node, plist_array_iter iter, plist_t *item)
Increment iterator of a PLIST_ARRAY node.
void plist_dict_insert_item(plist_t node, const char *key, plist_t item)
Insert a new item into a PLIST_DICT node.
@ PLIST_STRING
ASCII string, scalar type.
Definition: plist.h:109
void plist_to_bin_free(char *plist_bin)
Frees the memory allocated by plist_to_bin().
const char * plist_get_data_ptr(plist_t node, uint64_t *length)
Get a pointer to the data buffer of a PLIST_DATA node.
void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val)
Increment iterator of a PLIST_DICT node.
plist_t plist_new_dict(void)
Create a new root plist_t type PLIST_DICT.
void plist_dict_get_item_key(plist_t node, char **key)
Get key associated key to an item.
@ PLIST_DATA
Binary data, scalar type.
Definition: plist.h:113
@ PLIST_REAL
Real, scalar type.
Definition: plist.h:108
int plist_data_val_compare(plist_t datanode, const uint8_t *cmpval, size_t n)
Helper function to compare the data of a PLIST_DATA node against a given blob and size.
uint32_t plist_array_get_item_index(plist_t node)
Get the index of an item.
plist_t plist_new_uint(uint64_t val)
Create a new plist_t type PLIST_UINT.
void plist_set_uint_val(plist_t node, uint64_t val)
Set the value of a node.
plist_t plist_get_parent(plist_t node)
Get the parent of a node.
void plist_set_date_val(plist_t node, int32_t sec, int32_t usec)
Set the value of a node.
int plist_string_val_contains(plist_t strnode, const char *substr)
Helper function to match a given substring in the value of a PLIST_STRING node.
int plist_string_val_compare_with_size(plist_t strnode, const char *cmpval, size_t n)
Helper function to compare the value of a PLIST_STRING node against a given value,...
const char * plist_get_string_ptr(plist_t node, uint64_t *length)
Get a pointer to the buffer of a PLIST_STRING node.
plist_t plist_dict_item_get_key(plist_t node)
Get key node associated to an item.
int plist_string_val_compare(plist_t strnode, const char *cmpval)
Helper function to compare the value of a PLIST_STRING node against a given value.
void plist_dict_set_item(plist_t node, const char *key, plist_t item)
Set item identified by key in a PLIST_DICT node.
@ PLIST_NONE
No type.
Definition: plist.h:116
void plist_array_insert_item(plist_t node, plist_t item, uint32_t n)
Insert a new item at position n in a PLIST_ARRAY node.
void plist_array_set_item(plist_t node, plist_t item, uint32_t n)
Set the nth item in a PLIST_ARRAY node.