2014-04-02 16:04:43 +00:00
|
|
|
import ffi
|
2014-06-21 11:52:03 +00:00
|
|
|
import _libc
|
2014-04-02 16:04:43 +00:00
|
|
|
|
|
|
|
|
2014-06-21 11:52:03 +00:00
|
|
|
libc = _libc.get()
|
2014-04-02 16:04:43 +00:00
|
|
|
|
|
|
|
fcntl_l = libc.func("i", "fcntl", "iil")
|
2014-04-21 21:39:21 +00:00
|
|
|
fcntl_s = libc.func("i", "fcntl", "iip")
|
2014-04-02 16:04:43 +00:00
|
|
|
ioctl_l = libc.func("i", "ioctl", "iil")
|
2014-04-21 21:39:21 +00:00
|
|
|
ioctl_s = libc.func("i", "ioctl", "iip")
|
2014-04-02 16:04:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
def fcntl(fd, op, arg):
|
|
|
|
if type(arg) is int:
|
|
|
|
return fcntl_l(fd, op, arg)
|
|
|
|
else:
|
2014-12-22 22:55:43 +00:00
|
|
|
return fcntl_s(fd, op, arg)
|
2014-04-02 16:04:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
def ioctl(fd, op, arg):
|
|
|
|
if type(arg) is int:
|
|
|
|
return ioctl_l(fd, op, arg)
|
|
|
|
else:
|
2014-12-22 22:55:43 +00:00
|
|
|
return ioctl_s(fd, op, arg)
|