From b2532a304a35c12f78f2f6344c0d345d65ca9bfc Mon Sep 17 00:00:00 2001 From: Robert Burger Date: Wed, 31 Jul 2024 07:14:02 +0200 Subject: [PATCH] change: foe_tool print to stdout if destination filename is obmitted --- tools/foe_tool/foe_tool.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/foe_tool/foe_tool.c b/tools/foe_tool/foe_tool.c index b2c48ab..0c399e5 100644 --- a/tools/foe_tool/foe_tool.c +++ b/tools/foe_tool/foe_tool.c @@ -150,12 +150,17 @@ int main(int argc, char **argv) { ec_foe_read(&ec, slave, password, first_fn, &string, &fsize, &err); if (string != NULL) { - if (strcmp(second_fn, ".") == 0) { second_fn = first_fn; } - FILE *f = fopen(second_fn, "wb"); - fwrite(string, fsize, 1, f); - fclose(f); - - free(string); + if (second_fn == NULL) { + write(1, string, fsize); + write(1, "\n", 1); + } else { + if (strcmp(second_fn, ".") == 0) { second_fn = first_fn; } + FILE *f = fopen(second_fn, "wb"); + fwrite(string, fsize, 1, f); + fclose(f); + + free(string); + } } else { printf("file read was not successfull: data %p, fsize %" PRIu64 ", err %s\n", string, fsize, err); }