Skip to content

Commit b2532a3

Browse files
committed
change: foe_tool print to stdout if destination filename is obmitted
1 parent 1903411 commit b2532a3

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

tools/foe_tool/foe_tool.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,17 @@ int main(int argc, char **argv) {
150150
ec_foe_read(&ec, slave, password, first_fn, &string, &fsize, &err);
151151

152152
if (string != NULL) {
153-
if (strcmp(second_fn, ".") == 0) { second_fn = first_fn; }
154-
FILE *f = fopen(second_fn, "wb");
155-
fwrite(string, fsize, 1, f);
156-
fclose(f);
157-
158-
free(string);
153+
if (second_fn == NULL) {
154+
write(1, string, fsize);
155+
write(1, "\n", 1);
156+
} else {
157+
if (strcmp(second_fn, ".") == 0) { second_fn = first_fn; }
158+
FILE *f = fopen(second_fn, "wb");
159+
fwrite(string, fsize, 1, f);
160+
fclose(f);
161+
162+
free(string);
163+
}
159164
} else {
160165
printf("file read was not successfull: data %p, fsize %" PRIu64 ", err %s\n", string, fsize, err);
161166
}

0 commit comments

Comments
 (0)