Exemplo n.º 1
0
def res_init():
    libc = ctypes_utils.get_libc()
    libc.__res_init.argtypes = ()
    libc.__res_init.restype = c_int
    rc = libc.__res_init()
    if rc:
        ctypes_utils.throw_errno(libc)
Exemplo n.º 2
0
def res_init():
    libc = ctypes_utils.get_libc()
    libc.__res_init.argtypes = ()
    libc.__res_init.restype = c_int
    rc = libc.__res_init()
    if rc:
        ctypes_utils.throw_errno(libc)
Exemplo n.º 3
0
def res_init():
    if os.name != 'posix':
        return
    libc = ctypes_utils.get_libc()
    libc.__res_init.argtypes = ()
    libc.__res_init.restype = c_int
    rc = libc.__res_init()
    if rc:
        ctypes_utils.throw_errno(libc)
Exemplo n.º 4
0
def res_init():
    if os.name != 'posix':
        return
    libc = ctypes_utils.get_libc()
    libc.__res_init.argtypes = ()
    libc.__res_init.restype = c_int
    rc = libc.__res_init()
    if rc:
        ctypes_utils.throw_errno(libc)
Exemplo n.º 5
0
def pread(fobj, count, offset):
    if offset >= 0x8000000000000000:
        raise OverflowError
    buf = ctypes.create_string_buffer(count)
    libc = ctypes_utils.get_libc()
    libc.pread.argtypes = (c_int, c_void_p, c_size_t, c_long)
    libc.pread.restype = c_int
    rc = libc.pread(_fileno(fobj), buf, count, offset)
    if rc < 0:
        ctypes_utils.throw_errno(libc)
    else:
        return buf[:rc]
Exemplo n.º 6
0
def pwrite(fobj, data, offset):
    if offset >= 0x8000000000000000:
        raise OverflowError
    fd = _fileno(fobj)
    if os.name != 'posix':
        os.lseek(fd, offset, os.SEEK_SET)
        return os.write(fd, data)
    libc = ctypes_utils.get_libc()
    libc.pread.argtypes = (c_int, c_void_p, c_size_t, c_size_t)
    libc.pread.restype = c_int
    rc = libc.pwrite(fd, data, len(data), offset)
    if rc < 0:
        ctypes_utils.throw_errno(libc)
    else:
        return rc
Exemplo n.º 7
0
def pwrite(fobj, data, offset):
    if offset >= 0x8000000000000000:
        raise OverflowError
    fd = _fileno(fobj)
    if os.name != 'posix':
        os.lseek(fd, offset, os.SEEK_SET)
        return os.write(fd, data)
    libc = ctypes_utils.get_libc()
    libc.pread.argtypes = (c_int, c_void_p, c_size_t, c_size_t)
    libc.pread.restype = c_int
    rc = libc.pwrite(fd, data, len(data), offset)
    if rc < 0:
        ctypes_utils.throw_errno(libc)
    else:
        return rc
Exemplo n.º 8
0
def pread(fobj, count, offset):
    if offset >= 0x8000000000000000:
        raise OverflowError
    fd = _fileno(fobj)
    if os.name != 'posix':
        os.lseek(fd, offset, os.SEEK_SET)
        return os.read(fd, count)
    buf = ctypes.create_string_buffer(count)
    libc = ctypes_utils.get_libc()
    libc.pread.argtypes = (c_int, c_void_p, c_size_t, c_size_t)
    libc.pread.restype = c_int
    rc = libc.pread(fd, buf, count, offset)
    if rc < 0:
        ctypes_utils.throw_errno(libc)
    else:
        return buf[:rc]
Exemplo n.º 9
0
def pread(fobj, count, offset):
    if offset >= 0x8000000000000000:
        raise OverflowError
    fd = _fileno(fobj)
    if os.name != 'posix':
        os.lseek(fd, offset, os.SEEK_SET)
        return os.read(fd, count)
    buf = ctypes.create_string_buffer(count)
    libc = ctypes_utils.get_libc()
    libc.pread.argtypes = (c_int, c_void_p, c_size_t, c_size_t)
    libc.pread.restype = c_int
    rc = libc.pread(fd, buf, count, offset)
    if rc < 0:
        ctypes_utils.throw_errno(libc)
    else:
        return buf[:rc]