Commit 5bbcdb77 authored by scoder's avatar scoder

Merge pull request #293 from larsmans/more-posix

Expanded POSIX interface
parents b82b9d64 fd1cbe0b
from posix.types cimport (blkcnt_t, blksize_t, dev_t, gid_t, ino_t, mode_t,
nlink_t, off_t, time_t, uid_t)
cdef extern from "sys/stat.h" nogil:
cdef struct struct_stat "stat":
dev_t st_dev
ino_t st_ino
# POSIX prescribes including both <sys/stat.h> and <unistd.h> for these
cdef extern from "unistd.h" nogil:
int fchmod(int, mode_t)
int chmod(const char *, mode_t)
int fstat(int, struct_stat *)
int lstat(const char *, struct_stat *)
int stat(const char *, struct_stat *)
# Macros for st_mode
mode_t S_ISREG(mode_t)
mode_t S_ISDIR(mode_t)
mode_t S_ISCHR(mode_t)
mode_t S_ISBLK(mode_t)
mode_t S_ISFIFO(mode_t)
mode_t S_ISLNK(mode_t)
mode_t S_ISSOCK(mode_t)
mode_t S_IFMT
mode_t S_IFREG
mode_t S_IFDIR
mode_t S_IFCHR
mode_t S_IFBLK
mode_t S_IFIFO
mode_t S_IFLNK
mode_t S_IFSOCK
# Permissions
mode_t S_ISUID
mode_t S_ISGID
mode_t S_ISVTX
mode_t S_IRWXU
mode_t S_IRUSR
mode_t S_IWUSR
mode_t S_IXUSR
mode_t S_IRWXG
mode_t S_IRGRP
mode_t S_IWGRP
mode_t S_IXGRP
mode_t S_IRWXO
mode_t S_IROTH
mode_t S_IWOTH
mode_t S_IXOTH
# POSIX additions to <stdlib.h>
# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html
cdef extern from "stdlib.h" nogil:
void _Exit(int)
double drand48()
double erand48(unsigned short *)
int getsubopt(char **, char *const *, char **)
void lcong48(unsigned short *)
long lrand()
char *mkdtemp(char *)
int mkstemp(char *)
long mrand()
long nrand48(unsigned short *)
int posix_memalign(void **, size_t, size_t)
int posix_openpt(int)
char *ptsname(int)
int putenv(char *)
int rand_r(unsigned *)
long random()
char *realpath(const char *, char *)
unsigned short *seed48(unsigned short *)
int setenv(const char *, const char *, int)
void setkey(const char *)
char *setstate(char *)
void srand48(long)
void srandom(unsigned)
int unlockpt(int)
int unsetenv(const char *)
cdef extern from "sys/types.h":
ctypedef long blkcnt_t
ctypedef long blksize_t
ctypedef long dev_t
ctypedef long gid_t
ctypedef long ino_t
ctypedef long mode_t
ctypedef long nlink_t
ctypedef long off_t
ctypedef long pid_t
ctypedef long time_t
ctypedef long uid_t
# http://www.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html
from posix.types cimport gid_t, pid_t, off_t, uid_t
cdef extern from "unistd.h" nogil:
#:NULL
......@@ -32,32 +34,25 @@ cdef extern from "unistd.h" nogil:
enum: STDOUT_FILENO #1
enum: STDERR_FILENO #2
#:ctypedef unsigned size_t
#:ctypedef signed ssize_t
ctypedef int uid_t
ctypedef int gid_t
ctypedef signed off_t
ctypedef signed pid_t
ctypedef unsigned useconds_t
ctypedef signed intptr_t
int access(char *, int)
int access(const char *, int)
unsigned alarm(unsigned)
int chdir(char *)
int chown(char *, uid_t, gid_t)
int chdir(const char *)
int chown(const char *, uid_t, gid_t)
int close(int)
size_t confstr(int, char *, size_t)
char *crypt(char *, char *)
char *crypt(const char *, const char *)
char *ctermid(char *)
int dup(int)
int dup2(int, int)
void encrypt(char[64], int)
int execl(char *, char *, ...)
int execle(char *, char *, ...)
int execlp(char *, char *, ...)
int execv(char *, char *[])
int execve(char *, char *[], char *[])
int execvp(char *, char *[])
int execl(const char *, const char *, ...)
int execle(const char *, const char *, ...)
int execlp(const char *, const char *, ...)
int execv(const char *, char *[])
int execve(const char *, char *[], char *[])
int execvp(const char *, char *[])
void _exit(int)
int fchown(int, uid_t, gid_t)
int fchdir(int)
......@@ -75,7 +70,7 @@ cdef extern from "unistd.h" nogil:
int gethostname(char *, size_t)
char *getlogin()
int getlogin_r(char *, size_t)
int getopt(int, char * [], char *)
int getopt(int, char * [], const char *)
pid_t getpgid(pid_t)
pid_t getpgrp()
pid_t getpid()
......@@ -84,8 +79,8 @@ cdef extern from "unistd.h" nogil:
uid_t getuid()
char *getwd(char *)
int isatty(int)
int lchown(char *, uid_t, gid_t)
int link(char *, char *)
int lchown(const char *, uid_t, gid_t)
int link(const char *, const char *)
int lockf(int, int, off_t)
off_t lseek(int, off_t, int)
int nice(int)
......@@ -93,10 +88,10 @@ cdef extern from "unistd.h" nogil:
int pause()
int pipe(int [2])
ssize_t pread(int, void *, size_t, off_t)
ssize_t pwrite(int, void *, size_t, off_t)
ssize_t pwrite(int, const void *, size_t, off_t)
ssize_t read(int, void *, size_t)
ssize_t readlink(char *, char *, size_t)
int rmdir(char *)
ssize_t readlink(const char *, char *, size_t)
int rmdir(const char *)
int setegid(gid_t)
int seteuid(uid_t)
int setgid(gid_t)
......@@ -107,20 +102,20 @@ cdef extern from "unistd.h" nogil:
pid_t setsid()
int setuid(uid_t)
unsigned sleep(unsigned)
void swab(void *, void *, ssize_t)
int symlink(char *, char *)
void swab(const void *, void *, ssize_t)
int symlink(const char *, const char *)
void sync()
long sysconf(int)
pid_t tcgetpgrp(int)
int tcsetpgrp(int, pid_t)
int truncate(char *, off_t)
int truncate(const char *, off_t)
char *ttyname(int)
int ttyname_r(int, char *, size_t)
useconds_t ualarm(useconds_t, useconds_t)
int unlink(char *)
int unlink(const char *)
int usleep(useconds_t)
pid_t vfork()
ssize_t write(int, void *, size_t)
ssize_t write(int, const void *, size_t)
char *optarg
int optind
int opterr
......
......@@ -10,3 +10,15 @@ from posix.unistd cimport *
cimport posix.fcntl
from posix cimport fcntl
from posix.fcntl cimport *
cimport posix.types
from posix cimport types
from posix.types cimport *
cimport posix.stat
from posix cimport stat
from posix.stat cimport *
cimport posix.stdlib
from posix cimport stdlib
from posix.stdlib cimport *
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment