File: bsdopendirtype_build.py

package info (click to toggle)
python-cffi 1.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,540 kB
  • sloc: python: 26,777; ansic: 13,858; asm: 116; makefile: 103; sh: 28
file content (23 lines) | stat: -rw-r--r-- 575 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from cffi import FFI

ffibuilder = FFI()
ffibuilder.cdef("""
    typedef ... DIR;
    struct dirent {
        unsigned char d_type;   /* type of file */
        char d_name[];          /* filename */
        ...;
    };
    DIR *opendir(const char *name);
    int closedir(DIR *dirp);
    struct dirent *readdir(DIR *dirp);
    static const int DT_BLK, DT_CHR, DT_DIR, DT_FIFO, DT_LNK, DT_REG, DT_SOCK;
""")

ffibuilder.set_source("_bsdopendirtype", """
    #include <sys/types.h>
    #include <dirent.h>
""")

if __name__ == '__main__':
    ffibuilder.compile(verbose=True)