{-# LANGUAGE PackageImports #-}{- | Module : System.Win32.String Copyright : 2013 shelarcy License : BSD-style Maintainer : shelarcy@gmail.com Stability : Provisional Portability : Non-portable (Win32 API) Utilities for primitive marshalling of Windows' C strings. -}moduleSystem.Win32.WindowsString.String(LPSTR,LPCSTR,LPWSTR,LPCWSTR,TCHAR,LPTSTR,LPCTSTR,LPCTSTR_,withTString,withTStringLen,peekTString,peekTStringLen,newTString,withTStringBuffer,withTStringBufferLen)whereimportSystem.Win32.Stringhiding(withTStringBuffer,withTStringBufferLen,withTString,withTStringLen,peekTString,peekTStringLen,newTString)importSystem.Win32.WindowsString.TypesimportSystem.OsString.Internal.Types #if MIN_VERSION_filepath(1, 5, 0) importqualified"os-string"System.OsString.Data.ByteString.ShortasSBS #else importqualified"filepath"System.OsPath.Data.ByteString.ShortasSBS #endif importData.Word(Word8)-- | Marshal a dummy Haskell string into a NUL terminated C wide string -- using temporary storage. -- -- * the Haskell string is created by length parameter. And the Haskell -- string contains /only/ NUL characters. -- -- * the memory is freed when the subcomputation terminates (either -- normally or via an exception), so the pointer to the temporary -- storage must /not/ be used after this. -- withTStringBuffer::Int->(LPTSTR->IOa)->IOawithTStringBuffermaxLength=letdummyBuffer=WindowsString$SBS.pack$replicate(ifevenmaxLengththenmaxLengthelsemaxLength+1)_nulinwithTStringdummyBuffer-- | Marshal a dummy Haskell string into a C wide string (i.e. wide -- character array) in temporary storage, with explicit length -- information. -- -- * the Haskell string is created by length parameter. And the Haskell -- string contains /only/ NUL characters. -- -- * the memory is freed when the subcomputation terminates (either -- normally or via an exception), so the pointer to the temporary -- storage must /not/ be used after this. -- withTStringBufferLen::Int->((LPTSTR,Int)->IOa)->IOawithTStringBufferLenmaxLength=letdummyBuffer=WindowsString$SBS.pack$replicate(ifevenmaxLengththenmaxLengthelsemaxLength+1)_nulinwithTStringLendummyBuffer_nul::Word8_nul=0x00