From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/CONTRIB/SNIP/xtest.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 reference/C/CONTRIB/SNIP/xtest.c (limited to 'reference/C/CONTRIB/SNIP/xtest.c') diff --git a/reference/C/CONTRIB/SNIP/xtest.c b/reference/C/CONTRIB/SNIP/xtest.c new file mode 100755 index 0000000..7a22074 --- /dev/null +++ b/reference/C/CONTRIB/SNIP/xtest.c @@ -0,0 +1,35 @@ +#include +#include "xfile.h" + + +int main(int argc, char **argv) +{ + while (*++argv != 0) + { + XFILE *f = xopen(*argv); + + if (f == 0) + fprintf(stderr, "ERROR: can't open file %s\n", *argv); + else + { +#if 0 + char *s; + + fprintf(stdout, "--- %s ---\n", *argv); + while ((s = xgetline(f)) != 0) + fputs(s, stdout); + xclose(f); +#else + unsigned int nLines = 0; + char *s; + + while ((s = xgetline(f)) != 0) + ++nLines; + printf("%5u lines in %s\n", nLines, *argv); + xclose(f); +#endif + } + } + + return 0; +} -- cgit v1.2.3-54-g00ecf