Don't forget to release prop_string object
[eleutheria.git] / proplib / prop_dict.c
blob0e28d49e8a025b88e1b4afae2894d94555e2ff03
1 #include <err.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <prop/proplib.h>
6 int main(int argc, char *argv[])
8 prop_dictionary_t pd;
9 prop_string_t ps;
10 unsigned int i;
12 /* Create a dictionary capable of holding `argc - 1' objects */
13 pd = prop_dictionary_create_with_capacity(argc - 1);
14 if (pd == NULL)
15 errx(EXIT_FAILURE, "prop_dictionary_create_with_capacity");
17 /* For every supplied argument, create a <key, symbol> pair
18 * and store it inside the dictionary
20 for (i = 1; i < argc; i++) {
21 ps = prop_string_create_cstring_nocopy(argv[i]);
22 prop_dictionary_set(pd, argv[i], ps);
23 prop_object_release(ps);
26 /* Output our property list as an XML file */
27 if (prop_dictionary_externalize_to_file(pd, "./data.xml") == FALSE) {
28 prop_object_release(pd);
29 errx(EXIT_FAILURE, "prop_dictionary_externalize_to_file");
32 prop_object_release(pd);
34 return EXIT_SUCCESS;