api: posix header test
[libc-test] / src / api / ftw.c
diff --git a/src/api/ftw.c b/src/api/ftw.c
new file mode 100644 (file)
index 0000000..1c63627
--- /dev/null
@@ -0,0 +1,76 @@
+#ifdef _XOPEN_SOURCE
+#include <ftw.h>
+#define T(t) (t*)0;
+#define F(t,n) {t *y = &x.n;}
+#define C(n) switch(n){case n:;}
+static void f()
+{
+T(struct FTW)
+T(struct stat)
+C(FTW_F)
+C(FTW_D)
+C(FTW_DNR)
+C(FTW_DP)
+C(FTW_NS)
+C(FTW_SL)
+C(FTW_SLN)
+C(FTW_PHYS)
+C(FTW_MOUNT)
+C(FTW_DEPTH)
+C(FTW_CHDIR)
+C(S_IRWXU)
+C(S_IRUSR)
+C(S_IWUSR)
+C(S_IXUSR)
+C(S_IRWXG)
+C(S_IRGRP)
+C(S_IWGRP)
+C(S_IXGRP)
+C(S_IRWXO)
+C(S_IROTH)
+C(S_IWOTH)
+C(S_IXOTH)
+C(S_ISUID)
+C(S_ISGID)
+C(S_ISVTX)
+C(S_IFMT)
+C(S_IFBLK)
+C(S_IFCHR)
+C(S_IFIFO)
+C(S_IFREG)
+C(S_IFDIR)
+C(S_IFLNK)
+C(S_IFSOCK)
+C(S_ISBLK(0))
+C(S_ISCHR(0))
+C(S_ISDIR(0))
+C(S_ISFIFO(0))
+C(S_ISREG(0))
+C(S_ISLNK(0))
+C(S_ISSOCK(0))
+{
+struct FTW x;
+F(int, base)
+F(int, level)
+}
+{
+struct stat x;
+F(dev_t, st_dev)
+F(ino_t, st_ino)
+F(mode_t, st_mode)
+F(nlink_t, st_nlink)
+F(uid_t, st_uid)
+F(gid_t, st_gid)
+F(dev_t, st_rdev)
+F(off_t, st_size)
+F(struct timespec, st_atim)
+F(struct timespec, st_mtim)
+F(struct timespec, st_ctim)
+F(blksize_t, st_blksize)
+F(blkcnt_t, st_blocks)
+}
+int(*p_ftw)(const char*,int(*)(const char*,const struct stat*,int),int) = ftw;
+int(*p_nftw)(const char*,int(*)(const char*,const struct stat*,int,struct FTW*),int,int) = nftw;
+}
+#endif
+