diff options
Diffstat (limited to 'src/plist.c')
| -rw-r--r-- | src/plist.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/plist.c b/src/plist.c index 76ae954..66a74c3 100644 --- a/src/plist.c +++ b/src/plist.c | |||
| @@ -29,7 +29,7 @@ | |||
| 29 | #include <stdio.h> | 29 | #include <stdio.h> |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | void plist_new_plist(plist_t * plist) | 32 | void plist_new_dict(plist_t * plist) |
| 33 | { | 33 | { |
| 34 | if (*plist != NULL) | 34 | if (*plist != NULL) |
| 35 | return; | 35 | return; |
| @@ -38,7 +38,16 @@ void plist_new_plist(plist_t * plist) | |||
| 38 | *plist = g_node_new(data); | 38 | *plist = g_node_new(data); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | void plist_new_dict_in_plist(plist_t plist, dict_t * dict) | 41 | void plist_new_array(plist_t * plist) |
| 42 | { | ||
| 43 | if (*plist != NULL) | ||
| 44 | return; | ||
| 45 | struct plist_data *data = (struct plist_data *) calloc(sizeof(struct plist_data), 1); | ||
| 46 | data->type = PLIST_ARRAY; | ||
| 47 | *plist = g_node_new(data); | ||
| 48 | } | ||
| 49 | |||
| 50 | void plist_new_dict_in_plist(plist_t plist, plist_t * dict) | ||
| 42 | { | 51 | { |
| 43 | if (!plist || *dict) | 52 | if (!plist || *dict) |
| 44 | return; | 53 | return; |
| @@ -49,9 +58,6 @@ void plist_new_dict_in_plist(plist_t plist, dict_t * dict) | |||
| 49 | g_node_append(plist, *dict); | 58 | g_node_append(plist, *dict); |
| 50 | } | 59 | } |
| 51 | 60 | ||
| 52 | void plist_new_array_in_plist(plist_t plist, int length, plist_type type, void **values, array_t * array) | ||
| 53 | { | ||
| 54 | } | ||
| 55 | 61 | ||
| 56 | /** Adds a new key pair to a dict. | 62 | /** Adds a new key pair to a dict. |
| 57 | * | 63 | * |
| @@ -61,7 +67,7 @@ void plist_new_array_in_plist(plist_t plist, int length, plist_type type, void * | |||
| 61 | * @param value a pointer to the actual buffer containing the value. WARNING : the buffer is supposed to match the type of the value | 67 | * @param value a pointer to the actual buffer containing the value. WARNING : the buffer is supposed to match the type of the value |
| 62 | * | 68 | * |
| 63 | */ | 69 | */ |
| 64 | void plist_add_dict_element(dict_t dict, char *key, plist_type type, void *value) | 70 | void plist_add_dict_element(plist_t dict, char *key, plist_type type, void *value) |
| 65 | { | 71 | { |
| 66 | if (!dict || !key || !value) | 72 | if (!dict || !key || !value) |
| 67 | return; | 73 | return; |
| @@ -110,7 +116,7 @@ void plist_free(plist_t plist) | |||
| 110 | g_node_destroy(plist); | 116 | g_node_destroy(plist); |
| 111 | } | 117 | } |
| 112 | 118 | ||
| 113 | GNode *find_query_node(plist_t plist, char *key, char *request) | 119 | plist_t find_query_node(plist_t plist, char *key, char *request) |
| 114 | { | 120 | { |
| 115 | if (!plist) | 121 | if (!plist) |
| 116 | return NULL; | 122 | return NULL; |
| @@ -167,7 +173,7 @@ char compare_node_value(plist_type type, struct plist_data *data, void *value) | |||
| 167 | return res; | 173 | return res; |
| 168 | } | 174 | } |
| 169 | 175 | ||
| 170 | GNode *find_node(plist_t plist, plist_type type, void *value) | 176 | plist_t find_node(plist_t plist, plist_type type, void *value) |
| 171 | { | 177 | { |
| 172 | if (!plist) | 178 | if (!plist) |
| 173 | return NULL; | 179 | return NULL; |
| @@ -228,7 +234,10 @@ void get_type_and_value(GNode * node, plist_type * type, void *value) | |||
| 228 | 234 | ||
| 229 | plist_type plist_get_node_type(plist_t node) | 235 | plist_type plist_get_node_type(plist_t node) |
| 230 | { | 236 | { |
| 231 | return ((struct plist_data *) node->data)->type; | 237 | if (node && node->data) |
| 238 | return ((struct plist_data *) node->data)->type; | ||
| 239 | else | ||
| 240 | return PLIST_NONE; | ||
| 232 | } | 241 | } |
| 233 | 242 | ||
| 234 | uint64_t plist_get_node_uint_val(plist_t node) | 243 | uint64_t plist_get_node_uint_val(plist_t node) |
