4 #include <prop/proplib.h>
7 main(int argc
, char *argv
[])
10 * Declare a pointer to a prop_array object
11 * Note that prop_array_t is a pointer being
12 * hidden inside a typedef, i.e.
13 * typedef struct _prop_array *prop_array_t;
20 * Create array object with initial capacity 10
21 * Note that the array will expand on demand
22 * by the prop_array_add() with `EXPAND_STEP' step
23 * as defined in libprop/prop_array.c
25 pa
= prop_array_create_with_capacity(10);
27 errx(EXIT_FAILURE
, "prop_array_create_with_capacity()");
30 * For every argument, create a prop_string_t object
31 * that references it and store it in the array
33 for (i
= 0; i
< argc
; i
++) {
34 ps
= prop_string_create_cstring_nocopy(argv
[i
]);
36 prop_object_release(pa
);
37 errx(EXIT_FAILURE
, "prop_string_create_cstring_nocopy()");
40 if (prop_array_add(pa
, ps
) == FALSE
) {
41 prop_object_release(pa
);
42 errx(EXIT_FAILURE
, "prop_array_add()");
45 prop_object_release(ps
);
48 /* Export array contents to file as XML */
49 if (prop_array_externalize_to_file(pa
, "./data.xml") == FALSE
) {
50 prop_object_release(pa
);
51 errx(EXIT_FAILURE
, "prop_array_externalize_to_file()");
54 /* Release array object */
55 prop_object_release(pa
);