diff --git a/tprint/tprint b/tprint/tprint new file mode 100755 index 0000000..fb9ae59 Binary files /dev/null and b/tprint/tprint differ diff --git a/tprint/tprint.c b/tprint/tprint.c index 6caeb0e..e439114 100644 --- a/tprint/tprint.c +++ b/tprint/tprint.c @@ -24,8 +24,24 @@ int main(int argc, char** argv) { v = atoi(*argv); if(v == 0) v = 1000; speed = 1.0/v; + } else if(strcmp(*argv,"-h") == 0) { + printf("usage: tprint [-h] [-s speed] [filename]\n"); + printf("\t-h: Print this help.\n"); + printf("\t-s speed: speed in characters per second (default: 3)\n"); + exit(0); + } else if(**argv == '-' && strlen(*argv) > 1) { + printf("Unkown option %s\n",*argv); + exit(1); } else { - fh = fopen(*argv,"r"); + if(strcmp(*argv,"-")==0) { + fh = stdin; + } else { + fh = fopen(*argv,"r"); + if(fh == NULL) { + printf("Unable to open %s\n", *argv); + exit(2); + } + } } }