readme
This commit is contained in:
parent
84fd6725e0
commit
6e1f2e3db8
1 changed files with 2 additions and 4 deletions
|
@ -31,18 +31,16 @@ FILE* fp;
|
||||||
toml_table_t* conf;
|
toml_table_t* conf;
|
||||||
char errbuf[200];
|
char errbuf[200];
|
||||||
|
|
||||||
/* Open the file. */
|
/* Open the file and parse content */
|
||||||
if (0 == (fp = fopen("path/to/file.toml", "r"))) {
|
if (0 == (fp = fopen("path/to/file.toml", "r"))) {
|
||||||
return handle_error();
|
return handle_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run the file through the parser. */
|
|
||||||
conf = toml_parse_file(fp, errbuf, sizeof(errbuf));
|
conf = toml_parse_file(fp, errbuf, sizeof(errbuf));
|
||||||
|
fclose(fp);
|
||||||
if (0 == conf) {
|
if (0 == conf) {
|
||||||
return handle_error();
|
return handle_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
/* Alternatively, use `toml_parse` which takes a string rather than a file. */
|
/* Alternatively, use `toml_parse` which takes a string rather than a file. */
|
||||||
conf = toml_parse("A null terminated string that is TOML\0", errbuf, sizeof(errbuf));
|
conf = toml_parse("A null terminated string that is TOML\0", errbuf, sizeof(errbuf));
|
||||||
|
|
Loading…
Reference in a new issue