--- wikisrc/examples/proplib.mdwn 2010/04/17 17:01:32 1.1 +++ wikisrc/examples/proplib.mdwn 2011/05/13 08:47:34 1.2 @@ -4,62 +4,61 @@ Here's a little example code to show som This will create a dictionary and store it as an xml file on the disk: -int -main() -{ - prop_dictionary_t d; - bool r; - - d = prop_dictionary_create(); - - if (d == NULL) - goto error; - - r = prop_dictionary_set_cstring(d, "name", "Adam"); - if (!r) - goto error; - r = prop_dictionary_set_uint32(d, "year", 1986); - if (!r) - goto error; - - r = prop_dictionary_externalize_to_file(d, "test.plist"); - if (!r) - goto error; - - return EXIT_SUCCESS; - -error : - fprintf(stderr, "error\n"); - return EXIT_FAILURE; -} - + int + main(void) + { + prop_dictionary_t d; + bool r; + + d = prop_dictionary_create(); + + if (d == NULL) + goto error; + + r = prop_dictionary_set_cstring(d, "name", "Adam"); + if (!r) + goto error; + r = prop_dictionary_set_uint32(d, "year", 1986); + if (!r) + goto error; + + r = prop_dictionary_externalize_to_file(d, "test.plist"); + if (!r) + goto error; + + return EXIT_SUCCESS; + + error : + fprintf(stderr, "error\n"); + return EXIT_FAILURE; + } And this will read it and display the values: -int -main() -{ - prop_dictionary_t d; - uint32_t year; - char *name; - bool r; - - d = prop_dictionary_internalize_from_file("test.plist"); - if (d == NULL) - goto error; - - r = prop_dictionary_get_cstring(d, "name", &name); - if (!r) - goto error; - r = prop_dictionary_get_uint32(d, "year", &year); - if (!r) - goto error; - - printf("name: %s, year: %u\n", name, year); - - return EXIT_SUCCESS; - -error : - fprintf(stderr, "error\n"); - return EXIT_FAILURE; -} + int + main(void) + { + prop_dictionary_t d; + uint32_t year; + char *name; + bool r; + + d = prop_dictionary_internalize_from_file("test.plist"); + if (d == NULL) + goto error; + + r = prop_dictionary_get_cstring(d, "name", &name); + if (!r) + goto error; + r = prop_dictionary_get_uint32(d, "year", &year); + if (!r) + goto error; + + printf("name: %s, year: %u\n", name, year); + + return EXIT_SUCCESS; + + error : + fprintf(stderr, "error\n"); + return EXIT_FAILURE; + }