Add .o files in .gitignore
[eleutheria.git] / proplib / prop_dict.c
blobd842e32f8707385e9e4998fefab0441c27a2b6a6
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 errx(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 errx(EXIT_FAILURE, "prop_dictionary_externalize_to_file");
38 prop_object_release(pd);
40 return EXIT_SUCCESS;