"""Python interface to the Microsoft Visual C RuntimeLibrary, providing access to those non-portable, butstill useful routines."""# XXX incomplete: implemented only functions needed by subprocess.py# PAC: 2010/08 added MS locking for Whooshimportctypesfromctypes_supportimportstandard_c_libas_cfromctypes_supportimportget_errnoimporterrnotry:open_osfhandle=_c._open_osfhandleexceptAttributeError:# we are not on windowsraiseImportErrortry:from__pypy__importbuiltinifyexceptImportError:builtinify=lambdaf:fopen_osfhandle.argtypes=[ctypes.c_int,ctypes.c_int]open_osfhandle.restype=ctypes.c_intget_osfhandle=_c._get_osfhandleget_osfhandle.argtypes=[ctypes.c_int]get_osfhandle.restype=ctypes.c_intsetmode=_c._setmodesetmode.argtypes=[ctypes.c_int,ctypes.c_int]setmode.restype=ctypes.c_intLK_UNLCK,LK_LOCK,LK_NBLCK,LK_RLCK,LK_NBRLCK=range(5)_locking=_c._locking_locking.argtypes=[ctypes.c_int,ctypes.c_int,ctypes.c_int]_locking.restype=ctypes.c_int@builtinifydeflocking(fd,mode,nbytes):'''lock or unlock a number of bytes in a file.'''rv=_locking(fd,mode,nbytes)ifrv!=0:e=get_errno()raiseIOError(e,errno.errorcode[e])# Console I/O routineskbhit=_c._kbhitkbhit.argtypes=[]kbhit.restype=ctypes.c_intgetch=_c._getchgetch.argtypes=[]getch.restype=ctypes.c_chargetwch=_c._getwchgetwch.argtypes=[]getwch.restype=ctypes.c_wchargetche=_c._getchegetche.argtypes=[]getche.restype=ctypes.c_chargetwche=_c._getwchegetwche.argtypes=[]getwche.restype=ctypes.c_wcharputch=_c._putchputch.argtypes=[ctypes.c_char]putch.restype=Noneputwch=_c._putwchputwch.argtypes=[ctypes.c_wchar]putwch.restype=Noneungetch=_c._ungetchungetch.argtypes=[ctypes.c_char]ungetch.restype=Noneungetwch=_c._ungetwchungetwch.argtypes=[ctypes.c_wchar]ungetwch.restype=Nonedelctypes