4 #include <prop/proplib.h>
6 int main(int argc
, char *argv
[])
8 /* Declare a pointer to a prop_array object
9 * Note that prop_array_t is a pointer being
10 * hidden inside a typedef, i.e.
11 * typedef struct _prop_array *prop_array_t;
17 /* Create array object with initial capacity 10
18 * Note that the array will expand on demand
19 * by the prop_array_add()
21 pa
= prop_array_create_with_capacity(10);
23 errx(EXIT_FAILURE
, "prop_array_create_with_capacity()");
25 /* For every argument, create a reference to it
26 * and store it in the array
28 for (i
= 0; i
< argc
; i
++) {
29 ps
= prop_string_create_cstring_nocopy(argv
[i
]);
31 prop_object_release(pa
);
32 errx(EXIT_FAILURE
, "prop_string_create_cstring_nocopy()");
35 if (prop_array_add(pa
, ps
) == FALSE
) {
36 prop_object_release(pa
);
37 errx(EXIT_FAILURE
, "prop_array_add()");
40 prop_object_release(ps
);
43 /* Export array contents to file as XML */
44 if (prop_array_externalize_to_file(pa
, "./data.xml") == FALSE
) {
45 prop_object_release(pa
);
46 errx(EXIT_FAILURE
, "prop_array_externalize_to_file()");
49 /* Release array object */
50 prop_object_release(pa
);