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() with `EXPAND_STEP' step
20 * as defined in libprop/prop_array.c
22 pa
= prop_array_create_with_capacity(10);
24 errx(EXIT_FAILURE
, "prop_array_create_with_capacity()");
26 /* For every argument, create a prop_string_t object
27 * that references it and store it in the array
29 for (i
= 0; i
< argc
; i
++) {
30 ps
= prop_string_create_cstring_nocopy(argv
[i
]);
32 prop_object_release(pa
);
33 errx(EXIT_FAILURE
, "prop_string_create_cstring_nocopy()");
36 if (prop_array_add(pa
, ps
) == FALSE
) {
37 prop_object_release(pa
);
38 errx(EXIT_FAILURE
, "prop_array_add()");
41 prop_object_release(ps
);
44 /* Export array contents to file as XML */
45 if (prop_array_externalize_to_file(pa
, "./data.xml") == FALSE
) {
46 prop_object_release(pa
);
47 errx(EXIT_FAILURE
, "prop_array_externalize_to_file()");
50 /* Release array object */
51 prop_object_release(pa
);