#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], 1);
-
return 0;
}