2025-10-28 15:21:19 +00:00
|
|
|
#include "blue/serial/toml.h"
|
|
|
|
|
|
2025-09-22 10:55:20 +01:00
|
|
|
#include <blue/io/file.h>
|
|
|
|
|
#include <blue/io/path.h>
|
|
|
|
|
#include <blue/serial.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
int main(int argc, const char **argv)
|
|
|
|
|
{
|
|
|
|
|
if (argc < 2) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *path_cstr = argv[1];
|
|
|
|
|
b_path *path = b_path_create_from_cstr(path_cstr);
|
|
|
|
|
|
2025-10-24 12:51:54 +01:00
|
|
|
b_file *src = NULL;
|
|
|
|
|
b_result result = b_file_open(NULL, path, B_FILE_READ_ONLY, &src);
|
2025-09-22 10:55:20 +01:00
|
|
|
if (b_result_is_error(result)) {
|
|
|
|
|
b_throw(result);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-28 15:21:19 +00:00
|
|
|
b_serial_ctx *ctx = b_toml_serial_ctx_create();
|
2025-09-22 10:55:20 +01:00
|
|
|
|
2025-10-19 21:02:30 +01:00
|
|
|
b_object *data = NULL;
|
2025-10-28 15:21:19 +00:00
|
|
|
b_status status = b_serial_ctx_deserialise(ctx, src, &data, 0);
|
2025-09-22 10:55:20 +01:00
|
|
|
if (!B_OK(status)) {
|
|
|
|
|
fprintf(stderr, "cannot read data\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!data) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-19 21:02:30 +01:00
|
|
|
b_object_to_string(data, b_stdout);
|
2025-09-22 10:55:20 +01:00
|
|
|
b_stream_write_char(b_stdout, '\n');
|
|
|
|
|
|
2025-10-19 21:02:30 +01:00
|
|
|
b_object_unref(data);
|
2025-10-24 12:51:54 +01:00
|
|
|
b_object_unref(src);
|
2025-10-28 15:21:19 +00:00
|
|
|
b_serial_ctx_unref(ctx);
|
2025-09-22 10:55:20 +01:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|