urlmon: Added CopyStgMedium implementation.

This commit is contained in:
Jacek Caban 2008-01-31 18:09:04 +01:00 committed by Alexandre Julliard
parent 53c6cdf918
commit fd0d1d0765
4 changed files with 68 additions and 1 deletions

View File

@ -18,6 +18,7 @@
#define COBJMACROS #define COBJMACROS
#define CONST_VTABLE #define CONST_VTABLE
#define NONAMELESSUNION
#include <wine/test.h> #include <wine/test.h>
#include <stdarg.h> #include <stdarg.h>
@ -1177,6 +1178,37 @@ static void test_ReleaseBindInfo(void)
ok(bi.pUnk == &unk, "bi.pUnk=%p, expected %p\n", bi.pUnk, &unk); ok(bi.pUnk == &unk, "bi.pUnk=%p, expected %p\n", bi.pUnk, &unk);
} }
static void test_CopyStgMedium(void)
{
STGMEDIUM src, dst;
HRESULT hres;
memset(&src, 0xf0, sizeof(src));
memset(&dst, 0xe0, sizeof(dst));
src.tymed = TYMED_NULL;
src.pUnkForRelease = NULL;
hres = CopyStgMedium(&src, &dst);
ok(hres == S_OK, "CopyStgMedium failed: %08x\n", hres);
ok(dst.tymed == TYMED_NULL, "tymed=%d\n", dst.tymed);
ok(dst.u.hGlobal == (void*)0xf0f0f0f0, "u=%p\n", dst.u.hGlobal);
ok(!dst.pUnkForRelease, "pUnkForRelease=%p, expected NULL\n", dst.pUnkForRelease);
memset(&dst, 0xe0, sizeof(dst));
src.tymed = TYMED_ISTREAM;
src.u.pstm = NULL;
src.pUnkForRelease = NULL;
hres = CopyStgMedium(&src, &dst);
ok(hres == S_OK, "CopyStgMedium failed: %08x\n", hres);
ok(dst.tymed == TYMED_ISTREAM, "tymed=%d\n", dst.tymed);
ok(!dst.u.pstm, "pstm=%p\n", dst.u.pstm);
ok(!dst.pUnkForRelease, "pUnkForRelease=%p, expected NULL\n", dst.pUnkForRelease);
hres = CopyStgMedium(&src, NULL);
ok(hres == E_POINTER, "CopyStgMedium failed: %08x, expected E_POINTER\n", hres);
hres = CopyStgMedium(NULL, &dst);
ok(hres == E_POINTER, "CopyStgMedium failed: %08x, expected E_POINTER\n", hres);
}
static void test_UrlMkGetSessionOption(void) static void test_UrlMkGetSessionOption(void)
{ {
DWORD encoding, size; DWORD encoding, size;
@ -1339,6 +1371,7 @@ START_TEST(misc)
test_NameSpace(); test_NameSpace();
test_MimeFilter(); test_MimeFilter();
test_ReleaseBindInfo(); test_ReleaseBindInfo();
test_CopyStgMedium();
test_UrlMkGetSessionOption(); test_UrlMkGetSessionOption();
test_ObtainUserAgentString(); test_ObtainUserAgentString();
test_MkParseDisplayNameEx(); test_MkParseDisplayNameEx();

View File

@ -21,7 +21,7 @@
@ stdcall CoInternetQueryInfo(ptr long long ptr long ptr long) @ stdcall CoInternetQueryInfo(ptr long long ptr long ptr long)
@ stub CompareSecurityIds @ stub CompareSecurityIds
@ stub CopyBindInfo @ stub CopyBindInfo
@ stub CopyStgMedium @ stdcall CopyStgMedium(ptr ptr)
@ stdcall CreateAsyncBindCtx(long ptr ptr ptr) @ stdcall CreateAsyncBindCtx(long ptr ptr ptr)
@ stdcall CreateAsyncBindCtxEx(ptr long ptr ptr ptr long) @ stdcall CreateAsyncBindCtxEx(ptr long ptr ptr ptr long)
@ stdcall CreateFormatEnumerator(long ptr ptr) @ stdcall CreateFormatEnumerator(long ptr ptr)

View File

@ -406,6 +406,39 @@ void WINAPI ReleaseBindInfo(BINDINFO* pbindinfo)
pbindinfo->cbSize = size; pbindinfo->cbSize = size;
} }
/***********************************************************************
* CopyStgMedium (URLMON.@)
*/
HRESULT WINAPI CopyStgMedium(const STGMEDIUM *src, STGMEDIUM *dst)
{
TRACE("(%p %p)\n", src, dst);
if(!src || !dst)
return E_POINTER;
memcpy(dst, src, sizeof(STGMEDIUM));
switch(dst->tymed) {
case TYMED_NULL:
break;
case TYMED_ISTREAM:
if(dst->u.pstm)
IStream_AddRef(dst->u.pstm);
break;
case TYMED_ISTORAGE:
if(dst->u.pstg)
IStorage_AddRef(dst->u.pstg);
break;
default:
FIXME("Unimplemented tymed %d\n", src->tymed);
}
if(dst->pUnkForRelease)
IUnknown_AddRef(dst->pUnkForRelease);
return S_OK;
}
static BOOL text_richtext_filter(const BYTE *b, DWORD size) static BOOL text_richtext_filter(const BYTE *b, DWORD size)
{ {
return size > 5 && !memcmp(b, "{\\rtf", 5); return size > 5 && !memcmp(b, "{\\rtf", 5);

View File

@ -1279,6 +1279,7 @@ cpp_quote("HRESULT WINAPI ObtainUserAgentString(DWORD,LPSTR,DWORD*);")
cpp_quote("HRESULT WINAPI RegisterFormatEnumerator(LPBC,IEnumFORMATETC*,DWORD);") cpp_quote("HRESULT WINAPI RegisterFormatEnumerator(LPBC,IEnumFORMATETC*,DWORD);")
cpp_quote("HRESULT WINAPI RevokeFormatEnumerator(LPBC,IEnumFORMATETC*);") cpp_quote("HRESULT WINAPI RevokeFormatEnumerator(LPBC,IEnumFORMATETC*);")
cpp_quote("HRESULT WINAPI RevokeBindStatusCallback(LPBC,IBindStatusCallback*);") cpp_quote("HRESULT WINAPI RevokeBindStatusCallback(LPBC,IBindStatusCallback*);")
cpp_quote("HRESULT WINAPI CopyStgMedium(const STGMEDIUM*,STGMEDIUM*);")
cpp_quote("void WINAPI ReleaseBindInfo(BINDINFO*);") cpp_quote("void WINAPI ReleaseBindInfo(BINDINFO*);")
cpp_quote("HRESULT WINAPI UrlMkGetSessionOption(DWORD,LPVOID,DWORD,DWORD*,DWORD);") cpp_quote("HRESULT WINAPI UrlMkGetSessionOption(DWORD,LPVOID,DWORD,DWORD*,DWORD);")
cpp_quote("HRESULT WINAPI UrlMkSetSessionOption(DWORD,LPVOID,DWORD,DWORD);") cpp_quote("HRESULT WINAPI UrlMkSetSessionOption(DWORD,LPVOID,DWORD,DWORD);")