Skip to content

Commit

Permalink
Merge pull request #37 from lars18th/enable-stdout
Browse files Browse the repository at this point in the history
Enable stdout for file output
  • Loading branch information
gfto authored Mar 13, 2024
2 parents 4189c5b + 284c9d6 commit 4e1b1a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ static void show_usage(void) {
puts("\t-D\t\tDebug");
puts("");
puts("\t-W\t\tWrite output file (recommended to use with -N)");
puts("\t-f\t\tThe output filename (default: mptsd-output.ts)");
puts("\t-f\t\tThe output filename (default: mptsd-output.ts) (use - for stdout)");
puts("\t-E\t\tWrite input file");
puts("");
}
Expand Down
7 changes: 6 additions & 1 deletion data.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,12 @@ OUTPUT *output_new() {
}

void output_open_file(char *filename, OUTPUT *o) {
int fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0660);
int fd = -1;
if (strcmp(filename, "-") == 0) {
fd = STDOUT_FILENO;
} else {
fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0660);
}
if (fd == -1) {
perror("Cannot open output file\n");
exit(1);
Expand Down

0 comments on commit 4e1b1a3

Please sign in to comment.