2026-03-16 10:35:43 +00:00
|
|
|
#include <fx/io/file.h>
|
|
|
|
|
#include <fx/io/path.h>
|
|
|
|
|
#include <fx/serial.h>
|
|
|
|
|
#include <fx/serial/toml.h>
|
2025-09-22 10:55:20 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
int main(int argc, const char **argv)
|
|
|
|
|
{
|
|
|
|
|
if (argc < 2) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-12 22:15:25 +01:00
|
|
|
const char *path = argv[1];
|
2025-09-22 10:55:20 +01:00
|
|
|
|
2026-03-16 10:35:43 +00:00
|
|
|
fx_file *src = NULL;
|
2026-07-12 22:15:25 +01:00
|
|
|
fx_result result
|
|
|
|
|
= fx_file_open(NULL, FX_CSTR(path), FX_FILE_READ_ONLY, &src);
|
2026-03-16 10:35:43 +00:00
|
|
|
if (fx_result_is_error(result)) {
|
|
|
|
|
fx_throw(result);
|
2025-09-22 10:55:20 +01:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-16 10:35:43 +00:00
|
|
|
fx_serial_ctx *ctx = fx_toml_serial_ctx_create();
|
2025-09-22 10:55:20 +01:00
|
|
|
|
2026-05-29 20:20:31 +01:00
|
|
|
fx_value data = FX_VALUE_EMPTY;
|
2026-05-02 14:31:17 +01:00
|
|
|
result = fx_serial_ctx_deserialise(ctx, src, &data, 0);
|
|
|
|
|
if (fx_result_is_error(result)) {
|
|
|
|
|
fx_throw(result);
|
2025-09-22 10:55:20 +01:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-29 20:20:31 +01:00
|
|
|
if (!fx_value_is_set(&data)) {
|
2025-09-22 10:55:20 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-29 20:20:31 +01:00
|
|
|
fx_value_to_string(&data, fx_stdout, NULL);
|
2026-03-16 10:35:43 +00:00
|
|
|
fx_stream_write_char(fx_stdout, '\n');
|
2025-09-22 10:55:20 +01:00
|
|
|
|
2026-05-29 20:20:31 +01:00
|
|
|
fx_value_unset(&data);
|
2026-03-16 10:35:43 +00:00
|
|
|
fx_object_unref(src);
|
|
|
|
|
fx_serial_ctx_unref(ctx);
|
2025-09-22 10:55:20 +01:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|