aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Holberton <taylorcholberton@gmail.com>2017-12-15 06:22:58 -0500
committerGitHub <noreply@github.com>2017-12-15 06:22:58 -0500
commit162f0b7f2543f6a8c0bf659d4aab2cb89e15fe12 (patch)
tree9047338bb971f47f01330c11464be4a92ec146ff
parentadb12103ab9a58b684308a377f5440e95bf7daaa (diff)
parentecf27a44ff4f4d8b5df13a87c8f8cfd629aed183 (diff)
Merge pull request #107 from magicalvidyakitty/master
Added reading from stdin.
-rw-r--r--utils/tinyplay.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/utils/tinyplay.c b/utils/tinyplay.c
index bd79eff..2e5f627 100644
--- a/utils/tinyplay.c
+++ b/utils/tinyplay.c
@@ -72,7 +72,7 @@ int cmd_parse_arg(struct cmd *cmd, int argc, const char **argv)
return 1;
}
- if (argv[0][0] != '-') {
+ if (argv[0][0] != '-' || (strcmp(argv[0],"-") == 0)) {
cmd->filename = argv[0];
return 1;
}
@@ -187,8 +187,11 @@ int ctx_init(struct ctx* ctx, const struct cmd *cmd)
fprintf(stderr, "filename not specified\n");
return -1;
}
-
- ctx->file = fopen(cmd->filename, "rb");
+ if (strcmp(cmd->filename, "-") == 0) {
+ ctx->file = stdin;
+ } else {
+ ctx->file = fopen(cmd->filename, "rb");
+ }
if (ctx->file == NULL) {
fprintf(stderr, "failed to open '%s'\n", cmd->filename);
return -1;