Get rid of ctx->fout, use stdout instead

This commit is contained in:
Ivan Baravy 2022-05-31 20:06:33 +04:00
parent 5314ef2cae
commit 52c2167249
3 changed files with 687 additions and 579 deletions

1256
shell.c

File diff suppressed because it is too large Load Diff

View File

@ -19,8 +19,6 @@ struct shell_var {
};
struct shell_ctx {
FILE *fin;
FILE *fout;
int reproducible;
const char *hist_file;
struct shell_var *var;

View File

@ -57,8 +57,8 @@ main(int argc, char **argv) {
" -r reproducible logs (without pointers and datetime)\n"
" -c collect coverage";
const char *infile = NULL, *outfile = NULL;
struct shell_ctx ctx = {.fin = stdin, .fout = stdout, .reproducible = 0,
.hist_file = history_filename, .var = NULL};
struct shell_ctx ctx = {.reproducible = 0, .hist_file = history_filename,
.var = NULL};
build_history_filename();
/*
kos_boot.memmap_block_cnt = 3;
@ -98,11 +98,11 @@ main(int argc, char **argv) {
exit(1);
}
}
if (infile && !(ctx.fin = freopen(infile, "r", stdin))) {
if (infile && !freopen(infile, "r", stdin)) {
fprintf(stderr, "[!] can't open file for reading: %s", infile);
exit(1);
}
if (outfile && !(ctx.fout = freopen(outfile, "w", stdout))) {
if (outfile && !freopen(outfile, "w", stdout)) {
fprintf(stderr, "[!] can't open file for writing: %s", outfile);
exit(1);
}