diff options
author | Armin Rigo <arigo@tunes.org> | 2015-04-26 16:47:31 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2015-04-26 16:47:31 +0200 |
commit | 079752fd845e3a18f254e8b8025452a7f4a2dd82 (patch) | |
tree | b8d9a2ffb3a539a5960009783c3083018faf277e /demo/readdir2_build.py | |
parent | b441a136882987eb453de2768fa54dd6f30ca0ea (diff) | |
download | cffi-079752fd845e3a18f254e8b8025452a7f4a2dd82.tar.gz |
Move the demos from _cffi1/ back in the demo/ directory. Add the
cffi-1.0 version of the _curses demo too.
Diffstat (limited to 'demo/readdir2_build.py')
-rw-r--r-- | demo/readdir2_build.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/demo/readdir2_build.py b/demo/readdir2_build.py new file mode 100644 index 0000000..368b2af --- /dev/null +++ b/demo/readdir2_build.py @@ -0,0 +1,34 @@ +from cffi import FFI +from _cffi1 import recompile + +ffi = FFI() +ffi.cdef(""" + + typedef ... DIR; + + struct dirent { + unsigned char d_type; /* type of file; not supported + by all file system types */ + char d_name[...]; /* filename */ + ...; + }; + + int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); + int openat(int dirfd, const char *pathname, int flags); + DIR *fdopendir(int fd); + int closedir(DIR *dirp); + + static const int DT_DIR; + +""") +recompile(ffi, "_readdir2", """ +#ifndef _ATFILE_SOURCE +# define _ATFILE_SOURCE +#endif +#ifndef _BSD_SOURCE +# define _BSD_SOURCE +#endif +#include <fcntl.h> +#include <sys/types.h> +#include <dirent.h> +""") |