[Libsysio-commit] HEAD: libsysio/tests test_stats.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2007-08-28 17:37:13
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23409 Modified Files: test_stats.c Log Message: Modified to allow a list of path names to be passed via stdin. Preserves the old behavior of taking them from the ocmmand line as well. If any are present on the ocmmand line it ignores stdin. Index: test_stats.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stats.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- test_stats.c 28 Mar 2007 21:27:12 -0000 1.10 +++ test_stats.c 28 Aug 2007 17:37:08 -0000 1.11 @@ -43,6 +43,7 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <unistd.h> #include <errno.h> #include <sys/types.h> @@ -95,8 +96,27 @@ main(int argc, char * const argv[]) (void )SYSIO_INTERFACE_NAME(umask)(022); + if (optind < argc) { while (optind < argc) do_stats(argv[optind++]); + } else { + int doflush; + static char buf[4096]; + size_t len; + char *cp; + char c; + + doflush = 0; + while (fgets(buf, sizeof(buf), stdin) != NULL) { + len = strlen(buf); + cp = buf + len - 1; + c = *cp; + *cp = '\0'; + if (!doflush) + do_stats(buf); + doflush = c == '\n' ? 0 : 1; + } + } /* * Clean up. |