45 lines
835 B
C
45 lines
835 B
C
#include <fx/io/file.h>
|
|
#include <fx/io/path.h>
|
|
#include <fx/serial.h>
|
|
#include <fx/serial/toml.h>
|
|
#include <stdio.h>
|
|
|
|
int main(int argc, const char **argv)
|
|
{
|
|
if (argc < 2) {
|
|
return -1;
|
|
}
|
|
|
|
const char *path = argv[1];
|
|
|
|
fx_file *src = NULL;
|
|
fx_result result
|
|
= fx_file_open(NULL, FX_CSTR(path), FX_FILE_READ_ONLY, &src);
|
|
if (fx_result_is_error(result)) {
|
|
fx_throw(result);
|
|
return -1;
|
|
}
|
|
|
|
fx_serial_ctx *ctx = fx_toml_serial_ctx_create();
|
|
|
|
fx_value data = FX_VALUE_EMPTY;
|
|
result = fx_serial_ctx_deserialise(ctx, src, &data, 0);
|
|
if (fx_result_is_error(result)) {
|
|
fx_throw(result);
|
|
return -1;
|
|
}
|
|
|
|
if (!fx_value_is_set(&data)) {
|
|
return 0;
|
|
}
|
|
|
|
fx_value_to_string(&data, fx_stdout, NULL);
|
|
fx_stream_write_char(fx_stdout, '\n');
|
|
|
|
fx_value_unset(&data);
|
|
fx_object_unref(src);
|
|
fx_serial_ctx_unref(ctx);
|
|
|
|
return 0;
|
|
}
|