3 * gcc prop_dict.c -o prop_dict -lprop -Wall -W -Wextra -ansi -pedantic
9 #include <prop/proplib.h>
11 int main(int argc
, char *argv
[])
17 /* Create a dictionary capable of holding `argc - 1' objects */
18 pd
= prop_dictionary_create_with_capacity(argc
- 1);
20 err(EXIT_FAILURE
, "prop_dictionary_create_with_capacity()");
23 * For every supplied argument, create a <key, value> pair
24 * and store it inside the dictionary.
26 for (i
= 1; i
< argc
; i
++) {
27 ps
= prop_string_create_cstring_nocopy(argv
[i
]);
29 prop_object_release(pd
);
30 err(EXIT_FAILURE
, "prop_string_create_cstring_nocopy()");
33 if (prop_dictionary_set(pd
, argv
[i
], ps
) == false) {
34 prop_object_release(ps
);
35 prop_object_release(pd
);
36 err(EXIT_FAILURE
, "prop_dictionary_set()");
39 prop_object_release(ps
);
42 /* Output our property list as an XML file */
43 if (prop_dictionary_externalize_to_file(pd
, "./data.xml") == false) {
44 prop_object_release(pd
);
45 err(EXIT_FAILURE
, "prop_dictionary_externalize_to_file()");
48 /* Release dictionary */
49 prop_object_release(pd
);