Use err(), instread of errx()
[eleutheria.git] / proplib / prop_dict.c
bloba57978fdd231ff4e7d3bca14a1b06ab4748dc05b
1 /*
2 * Compile with:
3 * gcc prop_dict.c -o prop_dict -lprop -Wall -W -Wextra -ansi -pedantic
4 */
6 #include <err.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <prop/proplib.h>
11 int main(int argc, char *argv[])
13 prop_dictionary_t pd;
14 prop_string_t ps;
15 unsigned int i;
17 /* Create a dictionary capable of holding `argc - 1' objects */
18 pd = prop_dictionary_create_with_capacity(argc - 1);
19 if (pd == NULL)
20 err(EXIT_FAILURE, "prop_dictionary_create_with_capacity()");
23 * For every supplied argument, create a <key, symbol> pair
24 * and store it inside the dictionary
26 for (i = 1; i < argc; i++) {
27 ps = prop_string_create_cstring_nocopy(argv[i]);
28 prop_dictionary_set(pd, argv[i], ps);
29 prop_object_release(ps);
32 /* Output our property list as an XML file */
33 if (prop_dictionary_externalize_to_file(pd, "./data.xml") == FALSE) {
34 prop_object_release(pd);
35 err(EXIT_FAILURE, "prop_dictionary_externalize_to_file()");
38 /* Release dictionary */
39 prop_object_release(pd);
41 return EXIT_SUCCESS;