pypy / lib_pypy /

Python interface to the Microsoft Visual C Runtime
Library, providing access to those non-portable, but
still useful routines.

# XXX incomplete: implemented only functions needed by
# PAC: 2010/08 added MS locking for Whoosh

import ctypes
from ctypes_support import standard_c_lib as _c
from ctypes_support import get_errno
import errno

    open_osfhandle = _c._open_osfhandle
except AttributeError: # we are not on windows
    raise ImportError

try: from __pypy__ import builtinify
except ImportError: builtinify = lambda f: f

open_osfhandle.argtypes = [ctypes.c_int, ctypes.c_int]
open_osfhandle.restype = ctypes.c_int

get_osfhandle = _c._get_osfhandle
get_osfhandle.argtypes = [ctypes.c_int]
get_osfhandle.restype = ctypes.c_int

setmode = _c._setmode
setmode.argtypes = [ctypes.c_int, ctypes.c_int]
setmode.restype = ctypes.c_int


_locking = _c._locking
_locking.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_int]
_locking.restype = ctypes.c_int

def locking(fd, mode, nbytes):
    '''lock or unlock a number of bytes in a file.'''
    rv = _locking(fd, mode, nbytes)
    if rv != 0:
        e = get_errno()
        raise IOError(e, errno.errorcode[e])

# Console I/O routines

kbhit = _c._kbhit
kbhit.argtypes = []
kbhit.restype = ctypes.c_int

getch = _c._getch
getch.argtypes = []
getch.restype = ctypes.c_char

getwch = _c._getwch
getwch.argtypes = []
getwch.restype = ctypes.c_wchar

getche = _c._getche
getche.argtypes = []
getche.restype = ctypes.c_char

getwche = _c._getwche
getwche.argtypes = []
getwche.restype = ctypes.c_wchar

putch = _c._putch
putch.argtypes = [ctypes.c_char]
putch.restype = None

putwch = _c._putwch
putwch.argtypes = [ctypes.c_wchar]
putwch.restype = None

ungetch = _c._ungetch
ungetch.argtypes = [ctypes.c_char]
ungetch.restype = None

ungetwch = _c._ungetwch
ungetwch.argtypes = [ctypes.c_wchar]
ungetwch.restype = None

del ctypes
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.