+static void usage(void) {
+ fprintf(stderr, "usage: %s [-d] [-p] [logfile]\n", progname);
+ exit(1);
+}
+
+int main(int argc, char *argv[]) {
+ int c, opts;
+ FILE *inf;
+
+ progname= strrchr(*argv, '/');
+ if (progname)
+ progname++;
+ else
+ progname= *argv;
+ opts= 0;
+
+ while ((c= getopt(argc, argv, "dp")) != -1)
+ switch (c) {
+ case 'd':
+ opts|= OPT_DEBUG;
+ break;
+ case 'p':
+ opts|= OPT_POLL;
+ break;
+ default:
+ usage();
+ }
+
+ argc-= optind;
+ argv+= optind;
+
+ inf= NULL;
+ if (argc == 0)
+ inf= stdin;
+ else if (argc == 1)
+ inf= fopen(*argv, "r");
+ else
+ usage();
+
+ if (!inf)
+ aargh("couldn't open input");
+
+ proclog(inf, stdout, opts);
+
+ if (fclose(inf))
+ aargh("fclose input");
+ if (fclose(stdout))
+ aargh("fclose output");
+