msado15: Implement _Stream_get_Charset and _Stream_put_Charset.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c66411f742
commit
3e6b9394bc
|
@ -31,4 +31,12 @@ static inline void *heap_realloc_zero( void *mem, SIZE_T len )
|
|||
return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
|
||||
}
|
||||
|
||||
static inline WCHAR *strdupW( const WCHAR *src )
|
||||
{
|
||||
WCHAR *dst;
|
||||
if (!src) return NULL;
|
||||
if ((dst = heap_alloc( (lstrlenW( src ) + 1) * sizeof(*dst) ))) lstrcpyW( dst, src );
|
||||
return dst;
|
||||
}
|
||||
|
||||
#endif /* _WINE_MSADO15_PRIVATE_H_ */
|
||||
|
|
|
@ -38,6 +38,7 @@ struct stream
|
|||
ConnectModeEnum mode;
|
||||
StreamTypeEnum type;
|
||||
LineSeparatorEnum sep;
|
||||
WCHAR *charset;
|
||||
LONG size;
|
||||
LONG allocated;
|
||||
LONG pos;
|
||||
|
@ -62,6 +63,7 @@ static ULONG WINAPI stream_Release( _Stream *iface )
|
|||
if (!refs)
|
||||
{
|
||||
TRACE( "destroying %p\n", stream );
|
||||
heap_free( stream->charset );
|
||||
heap_free( stream->buf );
|
||||
heap_free( stream );
|
||||
}
|
||||
|
@ -240,14 +242,28 @@ static HRESULT WINAPI stream_put_Mode( _Stream *iface, ConnectModeEnum mode )
|
|||
|
||||
static HRESULT WINAPI stream_get_Charset( _Stream *iface, BSTR *charset )
|
||||
{
|
||||
FIXME( "%p, %p\n", iface, charset );
|
||||
return E_NOTIMPL;
|
||||
struct stream *stream = impl_from_Stream( iface );
|
||||
const WCHAR *src = stream->charset ? stream->charset : L"Unicode";
|
||||
BSTR dst;
|
||||
|
||||
TRACE( "%p, %p\n", stream, charset );
|
||||
|
||||
if (!(dst = SysAllocString( src ))) return E_OUTOFMEMORY;
|
||||
*charset = dst;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI stream_put_Charset( _Stream *iface, BSTR charset )
|
||||
{
|
||||
FIXME( "%p, %s\n", iface, debugstr_w(charset) );
|
||||
return E_NOTIMPL;
|
||||
struct stream *stream = impl_from_Stream( iface );
|
||||
WCHAR *str;
|
||||
|
||||
TRACE( "%p, %s\n", stream, debugstr_w(charset) );
|
||||
|
||||
if (!(str = strdupW( charset ))) return E_OUTOFMEMORY;
|
||||
heap_free( stream->charset );
|
||||
stream->charset = str;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT create_byte_array( BYTE *data, LONG len, VARIANT *ret )
|
||||
|
|
|
@ -55,6 +55,7 @@ static void test_Stream(void)
|
|||
LONG refs, size, pos;
|
||||
ObjectStateEnum state;
|
||||
ConnectModeEnum mode;
|
||||
BSTR charset, str;
|
||||
VARIANT missing, val;
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -112,6 +113,16 @@ static void test_Stream(void)
|
|||
hr = _Stream_put_Mode( stream, adModeReadWrite );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
hr = _Stream_get_Charset( stream, &charset );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
ok( !lstrcmpW( charset, L"Unicode" ), "got %s\n", wine_dbgstr_w(charset) );
|
||||
SysFreeString( charset );
|
||||
|
||||
str = SysAllocString( L"Unicode" );
|
||||
hr = _Stream_put_Charset( stream, str );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
SysFreeString( str );
|
||||
|
||||
hr = _Stream_Read( stream, 2, &val );
|
||||
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08x\n", hr );
|
||||
|
||||
|
|
Loading…
Reference in New Issue