2026-03-16 10:35:43 +00:00
|
|
|
#include <fx/io/file.h>
|
|
|
|
|
#include <fx/io/path.h>
|
|
|
|
|
#include <fx/serial.h>
|
2025-06-27 21:54:23 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
int main(int argc, const char **argv)
|
|
|
|
|
{
|
|
|
|
|
if (argc < 2) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *path_cstr = argv[1];
|
2026-03-16 10:35:43 +00:00
|
|
|
fx_path *path = fx_path_create_from_cstr(path_cstr);
|
2025-06-27 21:54:23 +01:00
|
|
|
|
2026-03-16 10:35:43 +00:00
|
|
|
fx_file *src = NULL;
|
|
|
|
|
fx_result result = fx_file_open(NULL, path, FX_FILE_READ_ONLY, &src);
|
|
|
|
|
if (fx_result_is_error(result)) {
|
|
|
|
|
fx_throw(result);
|
2025-06-27 21:54:23 +01:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-28 15:21:19 +00:00
|
|
|
/* TODO re-implement json support */
|
2026-03-16 10:35:43 +00:00
|
|
|
fx_serial_ctx *ctx = NULL;
|
2025-06-27 21:54:23 +01:00
|
|
|
|
2026-03-16 10:35:43 +00:00
|
|
|
fx_object *data;
|
|
|
|
|
fx_status status = fx_serial_ctx_deserialise(ctx, src, &data, 0);
|
|
|
|
|
if (!FX_OK(status)) {
|
2025-06-27 21:54:23 +01:00
|
|
|
fprintf(stderr, "cannot read data\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-16 10:35:43 +00:00
|
|
|
fx_object_to_string(data, fx_stdout);
|
|
|
|
|
fx_stream_write_char(fx_stdout, '\n');
|
2025-06-27 21:54:23 +01:00
|
|
|
|
2026-03-16 10:35:43 +00:00
|
|
|
fx_object_unref(data);
|
|
|
|
|
fx_object_unref(src);
|
|
|
|
|
fx_serial_ctx_unref(ctx);
|
2025-06-27 21:54:23 +01:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|