summaryrefslogtreecommitdiff
path: root/reference/C/CONTRIB/SNIP/xtest.c
blob: 7a2207474840d63b86193af297074c2c962663c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#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;
}