/* This example reads the configuration file 'example.cfg', adds a new
* movie record to the movies list, and writes the updated configuration to
* 'updated.cfg'.
*/
int main(int argc, char **argv)
{
static const char *output_file = "updated.cfg";
config_t cfg;
config_setting_t *root, *setting, *movie;
config_init(&cfg);
/* Read the file. If there is an error, report it and exit. */
if(! config_read_file(&cfg, "example.cfg"))
{
fprintf(stderr, "%s:%d - %s\n", config_error_file(&cfg),
config_error_line(&cfg), config_error_text(&cfg));
config_destroy(&cfg);
return(EXIT_FAILURE);
}
/* Find the 'movies' setting. Add intermediate settings if they don't yet
* exist.
*/
root = config_root_setting(&cfg);
setting = config_setting_get_member(root, "inventory");
if(!setting)
setting = config_setting_add(root, "inventory", CONFIG_TYPE_GROUP);
setting = config_setting_get_member(setting, "movies");
if(!setting)
setting = config_setting_add(setting, "movies", CONFIG_TYPE_LIST);
/* Create the new movie entry. */
movie = config_setting_add(setting, NULL, CONFIG_TYPE_GROUP);
setting = config_setting_add(movie, "title", CONFIG_TYPE_STRING);
config_setting_set_string(setting, "Buckaroo Banzai");
setting = config_setting_add(movie, "media", CONFIG_TYPE_STRING);
config_setting_set_string(setting, "DVD");
setting = config_setting_add(movie, "price", CONFIG_TYPE_FLOAT);
config_setting_set_float(setting, 12.99);
setting = config_setting_add(movie, "qty", CONFIG_TYPE_INT);
config_setting_set_float(setting, 20);
/* Write out the updated configuration. */
if(! config_write_file(&cfg, output_file))
{
fprintf(stderr, "Error while writing file.\n");
config_destroy(&cfg);
return(EXIT_FAILURE);
}
fprintf(stderr, "Updated configuration successfully written to: %s\n",
output_file);
config_destroy(&cfg);
return(EXIT_SUCCESS);
}
/* eof */
class='logheader'>| 2004-05-27 | [lcd4linux @ 2004-05-27 03:39:47 by reinelt] | reinelt | 8 | -37/+70 |
|
changed function naming scheme to plugin::function
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@437 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
|
|
Curses driver ported.
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@436 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
|
|
MilfordInstruments driver ported
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@435 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
|
|
'make distcheck' bugs fixed
release number changed to 0.10.0-RC1
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@434 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
|
|
Status updated
obsolete files removed
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@433 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
|
|
Changelog updated
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@432 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
|
ables.git/tag/?h=upstream/0%2bgit20161227.ac7535a'>upstream/0+git20161227.ac7535aJonathan McCrohan | 39 | -1522/+4879 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
No changes required
|