summaryrefslogtreecommitdiffstats
path: root/src/plist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plist.c')
-rw-r--r--src/plist.c96
1 files changed, 48 insertions, 48 deletions
diff --git a/src/plist.c b/src/plist.c
index 317a758..c38b6eb 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -87,14 +87,14 @@ static int plist_free_node(node_t* node)
87 return node_index; 87 return node_index;
88} 88}
89 89
90plist_t plist_new_dict(void) 90PLIST_API plist_t plist_new_dict(void)
91{ 91{
92 plist_data_t data = plist_new_plist_data(); 92 plist_data_t data = plist_new_plist_data();
93 data->type = PLIST_DICT; 93 data->type = PLIST_DICT;
94 return plist_new_node(data); 94 return plist_new_node(data);
95} 95}
96 96
97plist_t plist_new_array(void) 97PLIST_API plist_t plist_new_array(void)
98{ 98{
99 plist_data_t data = plist_new_plist_data(); 99 plist_data_t data = plist_new_plist_data();
100 data->type = PLIST_ARRAY; 100 data->type = PLIST_ARRAY;
@@ -111,7 +111,7 @@ static plist_t plist_new_key(const char *val)
111 return plist_new_node(data); 111 return plist_new_node(data);
112} 112}
113 113
114plist_t plist_new_string(const char *val) 114PLIST_API plist_t plist_new_string(const char *val)
115{ 115{
116 plist_data_t data = plist_new_plist_data(); 116 plist_data_t data = plist_new_plist_data();
117 data->type = PLIST_STRING; 117 data->type = PLIST_STRING;
@@ -120,7 +120,7 @@ plist_t plist_new_string(const char *val)
120 return plist_new_node(data); 120 return plist_new_node(data);
121} 121}
122 122
123plist_t plist_new_bool(uint8_t val) 123PLIST_API plist_t plist_new_bool(uint8_t val)
124{ 124{
125 plist_data_t data = plist_new_plist_data(); 125 plist_data_t data = plist_new_plist_data();
126 data->type = PLIST_BOOLEAN; 126 data->type = PLIST_BOOLEAN;
@@ -129,7 +129,7 @@ plist_t plist_new_bool(uint8_t val)
129 return plist_new_node(data); 129 return plist_new_node(data);
130} 130}
131 131
132plist_t plist_new_uint(uint64_t val) 132PLIST_API plist_t plist_new_uint(uint64_t val)
133{ 133{
134 plist_data_t data = plist_new_plist_data(); 134 plist_data_t data = plist_new_plist_data();
135 data->type = PLIST_UINT; 135 data->type = PLIST_UINT;
@@ -138,7 +138,7 @@ plist_t plist_new_uint(uint64_t val)
138 return plist_new_node(data); 138 return plist_new_node(data);
139} 139}
140 140
141plist_t plist_new_uid(uint64_t val) 141PLIST_API plist_t plist_new_uid(uint64_t val)
142{ 142{
143 plist_data_t data = plist_new_plist_data(); 143 plist_data_t data = plist_new_plist_data();
144 data->type = PLIST_UID; 144 data->type = PLIST_UID;
@@ -147,7 +147,7 @@ plist_t plist_new_uid(uint64_t val)
147 return plist_new_node(data); 147 return plist_new_node(data);
148} 148}
149 149
150plist_t plist_new_real(double val) 150PLIST_API plist_t plist_new_real(double val)
151{ 151{
152 plist_data_t data = plist_new_plist_data(); 152 plist_data_t data = plist_new_plist_data();
153 data->type = PLIST_REAL; 153 data->type = PLIST_REAL;
@@ -156,7 +156,7 @@ plist_t plist_new_real(double val)
156 return plist_new_node(data); 156 return plist_new_node(data);
157} 157}
158 158
159plist_t plist_new_data(const char *val, uint64_t length) 159PLIST_API plist_t plist_new_data(const char *val, uint64_t length)
160{ 160{
161 plist_data_t data = plist_new_plist_data(); 161 plist_data_t data = plist_new_plist_data();
162 data->type = PLIST_DATA; 162 data->type = PLIST_DATA;
@@ -166,7 +166,7 @@ plist_t plist_new_data(const char *val, uint64_t length)
166 return plist_new_node(data); 166 return plist_new_node(data);
167} 167}
168 168
169plist_t plist_new_date(int32_t sec, int32_t usec) 169PLIST_API plist_t plist_new_date(int32_t sec, int32_t usec)
170{ 170{
171 plist_data_t data = plist_new_plist_data(); 171 plist_data_t data = plist_new_plist_data();
172 data->type = PLIST_DATE; 172 data->type = PLIST_DATE;
@@ -176,7 +176,7 @@ plist_t plist_new_date(int32_t sec, int32_t usec)
176 return plist_new_node(data); 176 return plist_new_node(data);
177} 177}
178 178
179void plist_free(plist_t plist) 179PLIST_API void plist_free(plist_t plist)
180{ 180{
181 if (plist) 181 if (plist)
182 { 182 {
@@ -231,14 +231,14 @@ static void plist_copy_node(node_t *node, void *parent_node_ptr)
231 node_iterator_destroy(ni); 231 node_iterator_destroy(ni);
232} 232}
233 233
234plist_t plist_copy(plist_t node) 234PLIST_API plist_t plist_copy(plist_t node)
235{ 235{
236 plist_t copied = NULL; 236 plist_t copied = NULL;
237 plist_copy_node(node, &copied); 237 plist_copy_node(node, &copied);
238 return copied; 238 return copied;
239} 239}
240 240
241uint32_t plist_array_get_size(plist_t node) 241PLIST_API uint32_t plist_array_get_size(plist_t node)
242{ 242{
243 uint32_t ret = 0; 243 uint32_t ret = 0;
244 if (node && PLIST_ARRAY == plist_get_node_type(node)) 244 if (node && PLIST_ARRAY == plist_get_node_type(node))
@@ -248,7 +248,7 @@ uint32_t plist_array_get_size(plist_t node)
248 return ret; 248 return ret;
249} 249}
250 250
251plist_t plist_array_get_item(plist_t node, uint32_t n) 251PLIST_API plist_t plist_array_get_item(plist_t node, uint32_t n)
252{ 252{
253 plist_t ret = NULL; 253 plist_t ret = NULL;
254 if (node && PLIST_ARRAY == plist_get_node_type(node)) 254 if (node && PLIST_ARRAY == plist_get_node_type(node))
@@ -258,7 +258,7 @@ plist_t plist_array_get_item(plist_t node, uint32_t n)
258 return ret; 258 return ret;
259} 259}
260 260
261uint32_t plist_array_get_item_index(plist_t node) 261PLIST_API uint32_t plist_array_get_item_index(plist_t node)
262{ 262{
263 plist_t father = plist_get_parent(node); 263 plist_t father = plist_get_parent(node);
264 if (PLIST_ARRAY == plist_get_node_type(father)) 264 if (PLIST_ARRAY == plist_get_node_type(father))
@@ -268,7 +268,7 @@ uint32_t plist_array_get_item_index(plist_t node)
268 return 0; 268 return 0;
269} 269}
270 270
271void plist_array_set_item(plist_t node, plist_t item, uint32_t n) 271PLIST_API void plist_array_set_item(plist_t node, plist_t item, uint32_t n)
272{ 272{
273 if (node && PLIST_ARRAY == plist_get_node_type(node)) 273 if (node && PLIST_ARRAY == plist_get_node_type(node))
274 { 274 {
@@ -286,7 +286,7 @@ void plist_array_set_item(plist_t node, plist_t item, uint32_t n)
286 return; 286 return;
287} 287}
288 288
289void plist_array_append_item(plist_t node, plist_t item) 289PLIST_API void plist_array_append_item(plist_t node, plist_t item)
290{ 290{
291 if (node && PLIST_ARRAY == plist_get_node_type(node)) 291 if (node && PLIST_ARRAY == plist_get_node_type(node))
292 { 292 {
@@ -295,7 +295,7 @@ void plist_array_append_item(plist_t node, plist_t item)
295 return; 295 return;
296} 296}
297 297
298void plist_array_insert_item(plist_t node, plist_t item, uint32_t n) 298PLIST_API void plist_array_insert_item(plist_t node, plist_t item, uint32_t n)
299{ 299{
300 if (node && PLIST_ARRAY == plist_get_node_type(node)) 300 if (node && PLIST_ARRAY == plist_get_node_type(node))
301 { 301 {
@@ -304,7 +304,7 @@ void plist_array_insert_item(plist_t node, plist_t item, uint32_t n)
304 return; 304 return;
305} 305}
306 306
307void plist_array_remove_item(plist_t node, uint32_t n) 307PLIST_API void plist_array_remove_item(plist_t node, uint32_t n)
308{ 308{
309 if (node && PLIST_ARRAY == plist_get_node_type(node)) 309 if (node && PLIST_ARRAY == plist_get_node_type(node))
310 { 310 {
@@ -317,7 +317,7 @@ void plist_array_remove_item(plist_t node, uint32_t n)
317 return; 317 return;
318} 318}
319 319
320uint32_t plist_dict_get_size(plist_t node) 320PLIST_API uint32_t plist_dict_get_size(plist_t node)
321{ 321{
322 uint32_t ret = 0; 322 uint32_t ret = 0;
323 if (node && PLIST_DICT == plist_get_node_type(node)) 323 if (node && PLIST_DICT == plist_get_node_type(node))
@@ -327,7 +327,7 @@ uint32_t plist_dict_get_size(plist_t node)
327 return ret; 327 return ret;
328} 328}
329 329
330void plist_dict_new_iter(plist_t node, plist_dict_iter *iter) 330PLIST_API void plist_dict_new_iter(plist_t node, plist_dict_iter *iter)
331{ 331{
332 if (iter && *iter == NULL) 332 if (iter && *iter == NULL)
333 { 333 {
@@ -337,7 +337,7 @@ void plist_dict_new_iter(plist_t node, plist_dict_iter *iter)
337 return; 337 return;
338} 338}
339 339
340void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val) 340PLIST_API void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val)
341{ 341{
342 uint32_t* iter_int = (uint32_t*) iter; 342 uint32_t* iter_int = (uint32_t*) iter;
343 343
@@ -368,7 +368,7 @@ void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_
368 return; 368 return;
369} 369}
370 370
371void plist_dict_get_item_key(plist_t node, char **key) 371PLIST_API void plist_dict_get_item_key(plist_t node, char **key)
372{ 372{
373 plist_t father = plist_get_parent(node); 373 plist_t father = plist_get_parent(node);
374 if (PLIST_DICT == plist_get_node_type(father)) 374 if (PLIST_DICT == plist_get_node_type(father))
@@ -377,7 +377,7 @@ void plist_dict_get_item_key(plist_t node, char **key)
377 } 377 }
378} 378}
379 379
380plist_t plist_dict_get_item(plist_t node, const char* key) 380PLIST_API plist_t plist_dict_get_item(plist_t node, const char* key)
381{ 381{
382 plist_t ret = NULL; 382 plist_t ret = NULL;
383 383
@@ -403,7 +403,7 @@ plist_t plist_dict_get_item(plist_t node, const char* key)
403 return ret; 403 return ret;
404} 404}
405 405
406void plist_dict_set_item(plist_t node, const char* key, plist_t item) 406PLIST_API void plist_dict_set_item(plist_t node, const char* key, plist_t item)
407{ 407{
408 if (node && PLIST_DICT == plist_get_node_type(node)) { 408 if (node && PLIST_DICT == plist_get_node_type(node)) {
409 node_t* old_item = plist_dict_get_item(node, key); 409 node_t* old_item = plist_dict_get_item(node, key);
@@ -422,12 +422,12 @@ void plist_dict_set_item(plist_t node, const char* key, plist_t item)
422 return; 422 return;
423} 423}
424 424
425void plist_dict_insert_item(plist_t node, const char* key, plist_t item) 425PLIST_API void plist_dict_insert_item(plist_t node, const char* key, plist_t item)
426{ 426{
427 plist_dict_set_item(node, key, item); 427 plist_dict_set_item(node, key, item);
428} 428}
429 429
430void plist_dict_remove_item(plist_t node, const char* key) 430PLIST_API void plist_dict_remove_item(plist_t node, const char* key)
431{ 431{
432 if (node && PLIST_DICT == plist_get_node_type(node)) 432 if (node && PLIST_DICT == plist_get_node_type(node))
433 { 433 {
@@ -442,7 +442,7 @@ void plist_dict_remove_item(plist_t node, const char* key)
442 return; 442 return;
443} 443}
444 444
445void plist_dict_merge(plist_t *target, plist_t source) 445PLIST_API void plist_dict_merge(plist_t *target, plist_t source)
446{ 446{
447 if (!target || !*target || (plist_get_node_type(*target) != PLIST_DICT) || !source || (plist_get_node_type(source) != PLIST_DICT)) 447 if (!target || !*target || (plist_get_node_type(*target) != PLIST_DICT) || !source || (plist_get_node_type(source) != PLIST_DICT))
448 return; 448 return;
@@ -466,7 +466,7 @@ void plist_dict_merge(plist_t *target, plist_t source)
466 free(it); 466 free(it);
467} 467}
468 468
469plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v) 469PLIST_API plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v)
470{ 470{
471 plist_t current = plist; 471 plist_t current = plist;
472 plist_type type = PLIST_NONE; 472 plist_type type = PLIST_NONE;
@@ -490,7 +490,7 @@ plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v)
490 return current; 490 return current;
491} 491}
492 492
493plist_t plist_access_path(plist_t plist, uint32_t length, ...) 493PLIST_API plist_t plist_access_path(plist_t plist, uint32_t length, ...)
494{ 494{
495 plist_t ret = NULL; 495 plist_t ret = NULL;
496 va_list v; 496 va_list v;
@@ -545,12 +545,12 @@ static void plist_get_type_and_value(plist_t node, plist_type * type, void *valu
545 } 545 }
546} 546}
547 547
548plist_t plist_get_parent(plist_t node) 548PLIST_API plist_t plist_get_parent(plist_t node)
549{ 549{
550 return node ? (plist_t) ((node_t*) node)->parent : NULL; 550 return node ? (plist_t) ((node_t*) node)->parent : NULL;
551} 551}
552 552
553plist_type plist_get_node_type(plist_t node) 553PLIST_API plist_type plist_get_node_type(plist_t node)
554{ 554{
555 if (node) 555 if (node)
556 { 556 {
@@ -561,7 +561,7 @@ plist_type plist_get_node_type(plist_t node)
561 return PLIST_NONE; 561 return PLIST_NONE;
562} 562}
563 563
564void plist_get_key_val(plist_t node, char **val) 564PLIST_API void plist_get_key_val(plist_t node, char **val)
565{ 565{
566 plist_type type = plist_get_node_type(node); 566 plist_type type = plist_get_node_type(node);
567 uint64_t length = 0; 567 uint64_t length = 0;
@@ -570,7 +570,7 @@ void plist_get_key_val(plist_t node, char **val)
570 assert(length == strlen(*val)); 570 assert(length == strlen(*val));
571} 571}
572 572
573void plist_get_string_val(plist_t node, char **val) 573PLIST_API void plist_get_string_val(plist_t node, char **val)
574{ 574{
575 plist_type type = plist_get_node_type(node); 575 plist_type type = plist_get_node_type(node);
576 uint64_t length = 0; 576 uint64_t length = 0;
@@ -579,7 +579,7 @@ void plist_get_string_val(plist_t node, char **val)
579 assert(length == strlen(*val)); 579 assert(length == strlen(*val));
580} 580}
581 581
582void plist_get_bool_val(plist_t node, uint8_t * val) 582PLIST_API void plist_get_bool_val(plist_t node, uint8_t * val)
583{ 583{
584 plist_type type = plist_get_node_type(node); 584 plist_type type = plist_get_node_type(node);
585 uint64_t length = 0; 585 uint64_t length = 0;
@@ -588,7 +588,7 @@ void plist_get_bool_val(plist_t node, uint8_t * val)
588 assert(length == sizeof(uint8_t)); 588 assert(length == sizeof(uint8_t));
589} 589}
590 590
591void plist_get_uint_val(plist_t node, uint64_t * val) 591PLIST_API void plist_get_uint_val(plist_t node, uint64_t * val)
592{ 592{
593 plist_type type = plist_get_node_type(node); 593 plist_type type = plist_get_node_type(node);
594 uint64_t length = 0; 594 uint64_t length = 0;
@@ -597,7 +597,7 @@ void plist_get_uint_val(plist_t node, uint64_t * val)
597 assert(length == sizeof(uint64_t)); 597 assert(length == sizeof(uint64_t));
598} 598}
599 599
600void plist_get_uid_val(plist_t node, uint64_t * val) 600PLIST_API void plist_get_uid_val(plist_t node, uint64_t * val)
601{ 601{
602 plist_type type = plist_get_node_type(node); 602 plist_type type = plist_get_node_type(node);
603 uint64_t length = 0; 603 uint64_t length = 0;
@@ -606,7 +606,7 @@ void plist_get_uid_val(plist_t node, uint64_t * val)
606 assert(length == sizeof(uint64_t)); 606 assert(length == sizeof(uint64_t));
607} 607}
608 608
609void plist_get_real_val(plist_t node, double *val) 609PLIST_API void plist_get_real_val(plist_t node, double *val)
610{ 610{
611 plist_type type = plist_get_node_type(node); 611 plist_type type = plist_get_node_type(node);
612 uint64_t length = 0; 612 uint64_t length = 0;
@@ -615,14 +615,14 @@ void plist_get_real_val(plist_t node, double *val)
615 assert(length == sizeof(double)); 615 assert(length == sizeof(double));
616} 616}
617 617
618void plist_get_data_val(plist_t node, char **val, uint64_t * length) 618PLIST_API void plist_get_data_val(plist_t node, char **val, uint64_t * length)
619{ 619{
620 plist_type type = plist_get_node_type(node); 620 plist_type type = plist_get_node_type(node);
621 if (PLIST_DATA == type) 621 if (PLIST_DATA == type)
622 plist_get_type_and_value(node, &type, (void *) val, length); 622 plist_get_type_and_value(node, &type, (void *) val, length);
623} 623}
624 624
625void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec) 625PLIST_API void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec)
626{ 626{
627 plist_type type = plist_get_node_type(node); 627 plist_type type = plist_get_node_type(node);
628 uint64_t length = 0; 628 uint64_t length = 0;
@@ -695,7 +695,7 @@ int plist_data_compare(const void *a, const void *b)
695 return FALSE; 695 return FALSE;
696} 696}
697 697
698char plist_compare_node_value(plist_t node_l, plist_t node_r) 698PLIST_API char plist_compare_node_value(plist_t node_l, plist_t node_r)
699{ 699{
700 return plist_data_compare(node_l, node_r); 700 return plist_data_compare(node_l, node_r);
701} 701}
@@ -757,42 +757,42 @@ static void plist_set_element_val(plist_t node, plist_type type, const void *val
757 } 757 }
758} 758}
759 759
760void plist_set_key_val(plist_t node, const char *val) 760PLIST_API void plist_set_key_val(plist_t node, const char *val)
761{ 761{
762 plist_set_element_val(node, PLIST_KEY, val, strlen(val)); 762 plist_set_element_val(node, PLIST_KEY, val, strlen(val));
763} 763}
764 764
765void plist_set_string_val(plist_t node, const char *val) 765PLIST_API void plist_set_string_val(plist_t node, const char *val)
766{ 766{
767 plist_set_element_val(node, PLIST_STRING, val, strlen(val)); 767 plist_set_element_val(node, PLIST_STRING, val, strlen(val));
768} 768}
769 769
770void plist_set_bool_val(plist_t node, uint8_t val) 770PLIST_API void plist_set_bool_val(plist_t node, uint8_t val)
771{ 771{
772 plist_set_element_val(node, PLIST_BOOLEAN, &val, sizeof(uint8_t)); 772 plist_set_element_val(node, PLIST_BOOLEAN, &val, sizeof(uint8_t));
773} 773}
774 774
775void plist_set_uint_val(plist_t node, uint64_t val) 775PLIST_API void plist_set_uint_val(plist_t node, uint64_t val)
776{ 776{
777 plist_set_element_val(node, PLIST_UINT, &val, sizeof(uint64_t)); 777 plist_set_element_val(node, PLIST_UINT, &val, sizeof(uint64_t));
778} 778}
779 779
780void plist_set_uid_val(plist_t node, uint64_t val) 780PLIST_API void plist_set_uid_val(plist_t node, uint64_t val)
781{ 781{
782 plist_set_element_val(node, PLIST_UID, &val, sizeof(uint64_t)); 782 plist_set_element_val(node, PLIST_UID, &val, sizeof(uint64_t));
783} 783}
784 784
785void plist_set_real_val(plist_t node, double val) 785PLIST_API void plist_set_real_val(plist_t node, double val)
786{ 786{
787 plist_set_element_val(node, PLIST_REAL, &val, sizeof(double)); 787 plist_set_element_val(node, PLIST_REAL, &val, sizeof(double));
788} 788}
789 789
790void plist_set_data_val(plist_t node, const char *val, uint64_t length) 790PLIST_API void plist_set_data_val(plist_t node, const char *val, uint64_t length)
791{ 791{
792 plist_set_element_val(node, PLIST_DATA, val, length); 792 plist_set_element_val(node, PLIST_DATA, val, length);
793} 793}
794 794
795void plist_set_date_val(plist_t node, int32_t sec, int32_t usec) 795PLIST_API void plist_set_date_val(plist_t node, int32_t sec, int32_t usec)
796{ 796{
797 struct timeval val = { sec, usec }; 797 struct timeval val = { sec, usec };
798 plist_set_element_val(node, PLIST_DATE, &val, sizeof(struct timeval)); 798 plist_set_element_val(node, PLIST_DATE, &val, sizeof(struct timeval));