diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-08-11 01:39:00 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-08-11 01:39:00 +0000 |
commit | 1898ad520c080ec1da6fad8c0b4e0b6644672104 (patch) | |
tree | 770318e8c67a960df906c4824528afdea70e8ae5 /test-fts.c | |
parent | a48dab80b41e90194711a45e5012659b7a83da4f (diff) | |
download | mandoc-1898ad520c080ec1da6fad8c0b4e0b6644672104.tar.gz |
Provide a fallback version of fts(3) for systems lacking it.
I chose the OpenBSD version because it apparently contains various
bugfixes that never made it into libnbcompat. To reduce size and
complexity, i stripped out the features we don't need.
Diffstat (limited to 'test-fts.c')
-rw-r--r-- | test-fts.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test-fts.c b/test-fts.c new file mode 100644 index 00000000..5c6fc2d0 --- /dev/null +++ b/test-fts.c @@ -0,0 +1,42 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <fts.h> +#include <stdio.h> + +int +main(void) +{ + const char *argv[2]; + FTS *ftsp; + FTSENT *entry; + + argv[0] = "."; + argv[1] = (char *)NULL; + + ftsp = fts_open((char * const *)argv, + FTS_PHYSICAL | FTS_NOCHDIR, NULL); + + if (ftsp == NULL) { + perror("fts_open"); + return(1); + } + + entry = fts_read(ftsp); + + if (entry == NULL) { + perror("fts_read"); + return(1); + } + + if (fts_set(ftsp, entry, FTS_SKIP) != 0) { + perror("fts_set"); + return(1); + } + + if (fts_close(NULL) != 0) { + perror("fts_close"); + return(1); + } + + return(0); +} |