]> git.scottworley.com Git - overonion/blobdiff - reverse.c
Skip the sleep; rely on /dev/random to block.
[overonion] / reverse.c
index 2d83751338ded6b7f08c20433f74c9b05945b22d..02a349fc33009860caa43dea115fbc27fdc86b19 100644 (file)
--- a/reverse.c
+++ b/reverse.c
@@ -1,14 +1,17 @@
 #include "reverse_lib.h"
 
 #include <err.h>
+#include <stdio.h>
+#include <string.h>
 #include <sysexits.h>
 
 int main(int argc, char** argv) {
-  if (argc != 2) {
+  if (argc == 1 || (argc == 2 && strcmp(argv[1], "-") == 0)) {
+    reverse_stream(stdin, stdout);
+  } else if (argc == 2) {
+    reverse_file(argv[1], stdout);
+  } else {
     errx(EX_USAGE, "Usage: reverse filename");
   }
-
-  reverse_file(argv[1]);
-
   return 0;
 }