Ticket #750 (new enhancement)

Opened 3 years ago

Last modified 3 years ago

Additional libc .pxd definitions

Reported by: nikratio Owned by:
Priority: major Milestone: wishlist
Component: Library Keywords:
Cc: nikratio

Description

It'd be great if the following definitions could be added to the .pxd files shipped with Cython:

cdef extern from "attr/xattr.h" nogil:
    int setxattr (char *path, char *name,
                  void *value, int size, int flags)
    
    int getxattr (char *path, char *name,
                  void *value, int size)

    int XATTR_CREATE
    int XATTR_REPLACE

cdef extern from "dirent.h" nogil:
    ctypedef struct DIR:
        pass
    cdef struct dirent:
        char* d_name
        
    dirent* readdir(DIR* dirp)
    int readdir_r(DIR *dirp, dirent *entry, dirent **result)

cdef extern from "sys/types.h" nogil:
    DIR *opendir(char *name)
    int closedir(DIR* dirp)

from libc.sys.types cimport *
cdef extern from "sys/stat.h" nogil:
    enum st_mode_constants:
        S_IFMT
        S_IFDIR

    struct stat:
        dev_t     st_dev
        ino_t     st_ino
        mode_t    st_mode
        nlink_t   st_nlink
        uid_t     st_uid
        gid_t     st_gid
        dev_t     st_rdev
        off_t     st_size
        blksize_t st_blksize
        blkcnt_t  st_blocks
        time_t    st_atime
        time_t    st_mtime
        time_t    st_ctime

cdef extern from "sys/statvfs.h" nogil:
    ctypedef int fsblkcnt_t
    ctypedef int fsfilcnt_t
    
    struct statvfs: 
        int f_bsize
        int f_frsize
        fsblkcnt_t     f_blocks
        fsblkcnt_t     f_bfree
        fsblkcnt_t     f_bavail
        fsfilcnt_t     f_files
        fsfilcnt_t     f_ffree
        fsfilcnt_t     f_favail
cdef extern from "sys/types.h" nogil:
    ctypedef int pid_t
    ctypedef int dev_t
    ctypedef int ino_t
    ctypedef int mode_t
    ctypedef int nlink_t
    ctypedef int uid_t
    ctypedef int gid_t
    ctypedef int dev_t
    ctypedef int off_t
    ctypedef int blksize_t
    ctypedef int blkcnt_t
    ctypedef int time_t

Also, the libc.stdio definitions lacks a

    FILE *fdopen(int fd, const_char *mode)

Change History

Changed 3 years ago by nikratio

  • cc nikratio added
Note: See TracTickets for help on using tickets.