From: Martin Mares Date: Sat, 17 Jul 2010 17:29:04 +0000 (+0200) Subject: osdc: stdin can be used as an option argument X-Git-Tag: v1.0~13 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=45ae33902e54e10b6950cadb4a1e3d96e59a0341;p=osdd.git osdc: stdin can be used as an option argument --- diff --git a/osdc.c b/osdc.c index 27b6c63..0f01ae7 100644 --- a/osdc.c +++ b/osdc.c @@ -14,41 +14,70 @@ #include "util.h" #include "send.h" +static struct osd_msg *msg; + static void NONRET usage(void) { - fprintf(stderr, "Usage: osdc [--= | ]*\n"); + fprintf(stderr, "\ +Usage: osdc [--= | ]*\n\ +\n\ +Either or can be `-' for standard input.\n\ +"); exit(1); } +static void +parse_stdin(char *key) +{ + char line[1024]; + while (fgets(line, sizeof(line), stdin)) + { + char *nl = strchr(line, '\n'); + if (nl) + *nl = 0; + osd_add_line(msg, key, line); + } +} + int main(int argc, char **argv) { - struct osd_msg *m = osd_new_msg(); + msg = osd_new_msg(); int more_opts = 1; for (int i=1; i