Annotation of mandoc/test-fts.c, Revision 1.4
1.1 schwarze 1: #include <sys/types.h>
2: #include <sys/stat.h>
3: #include <fts.h>
4: #include <stdio.h>
1.4 ! schwarze 5: #include <string.h>
! 6:
! 7: #ifdef FTS_COMPARE_CONST
! 8: int fts_compare(const FTSENT *const *, const FTSENT *const *);
! 9: #else
! 10: int fts_compare(const FTSENT **, const FTSENT **);
! 11: #endif
1.1 schwarze 12:
13: int
14: main(void)
15: {
16: const char *argv[2];
17: FTS *ftsp;
18: FTSENT *entry;
19:
20: argv[0] = ".";
21: argv[1] = (char *)NULL;
22:
23: ftsp = fts_open((char * const *)argv,
1.4 ! schwarze 24: FTS_PHYSICAL | FTS_NOCHDIR, fts_compare);
1.1 schwarze 25:
26: if (ftsp == NULL) {
27: perror("fts_open");
1.3 schwarze 28: return 1;
1.1 schwarze 29: }
30:
31: entry = fts_read(ftsp);
32:
33: if (entry == NULL) {
34: perror("fts_read");
1.3 schwarze 35: return 1;
1.1 schwarze 36: }
37:
38: if (fts_set(ftsp, entry, FTS_SKIP) != 0) {
39: perror("fts_set");
1.3 schwarze 40: return 1;
1.1 schwarze 41: }
42:
1.2 schwarze 43: if (fts_close(ftsp) != 0) {
1.1 schwarze 44: perror("fts_close");
1.3 schwarze 45: return 1;
1.1 schwarze 46: }
47:
1.3 schwarze 48: return 0;
1.4 ! schwarze 49: }
! 50:
! 51: int
! 52: #ifdef FTS_COMPARE_CONST
! 53: fts_compare(const FTSENT *const *a, const FTSENT *const *b)
! 54: #else
! 55: fts_compare(const FTSENT **a, const FTSENT **b)
! 56: #endif
! 57: {
! 58: return strcmp((*a)->fts_name, (*b)->fts_name);
1.1 schwarze 59: }
CVSweb