Commit 903cf0ff authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ole32: Use nameless unions.

parent 5d8dde1a
...@@ -2,7 +2,7 @@ MODULE = ole32.dll ...@@ -2,7 +2,7 @@ MODULE = ole32.dll
IMPORTLIB = ole32 IMPORTLIB = ole32
IMPORTS = uuid advapi32 user32 gdi32 combase rpcrt4 IMPORTS = uuid advapi32 user32 gdi32 combase rpcrt4
DELAYIMPORTS = oleaut32 DELAYIMPORTS = oleaut32
EXTRADEFS = -D_OLE32_ -DWINE_NO_NAMELESS_EXTENSION EXTRADEFS = -D_OLE32_
EXTRADLLFLAGS = -mno-cygwin EXTRADLLFLAGS = -mno-cygwin
......
...@@ -511,11 +511,11 @@ static HRESULT WINAPI IPropertyStorage_fnReadMultiple( ...@@ -511,11 +511,11 @@ static HRESULT WINAPI IPropertyStorage_fnReadMultiple(
{ {
case PID_CODEPAGE: case PID_CODEPAGE:
rgpropvar[i].vt = VT_I2; rgpropvar[i].vt = VT_I2;
rgpropvar[i].u.iVal = This->codePage; rgpropvar[i].iVal = This->codePage;
break; break;
case PID_LOCALE: case PID_LOCALE:
rgpropvar[i].vt = VT_I4; rgpropvar[i].vt = VT_I4;
rgpropvar[i].u.lVal = This->locale; rgpropvar[i].lVal = This->locale;
break; break;
default: default:
{ {
...@@ -629,12 +629,12 @@ static HRESULT PropertyStorage_PropVariantCopy(PROPVARIANT *prop, const PROPVARI ...@@ -629,12 +629,12 @@ static HRESULT PropertyStorage_PropVariantCopy(PROPVARIANT *prop, const PROPVARI
switch (propvar->vt) switch (propvar->vt)
{ {
case VT_LPSTR: case VT_LPSTR:
hr = PropertyStorage_StringCopy(propvar->u.pszVal, srcCP, &prop->u.pszVal, targetCP); hr = PropertyStorage_StringCopy(propvar->pszVal, srcCP, &prop->pszVal, targetCP);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
prop->vt = VT_LPSTR; prop->vt = VT_LPSTR;
break; break;
case VT_BSTR: case VT_BSTR:
if ((prop->u.bstrVal = SysAllocStringLen(propvar->u.bstrVal, SysStringLen(propvar->u.bstrVal)))) if ((prop->bstrVal = SysAllocStringLen(propvar->bstrVal, SysStringLen(propvar->bstrVal))))
prop->vt = VT_BSTR; prop->vt = VT_BSTR;
else else
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
...@@ -802,7 +802,7 @@ static HRESULT WINAPI IPropertyStorage_fnWriteMultiple( ...@@ -802,7 +802,7 @@ static HRESULT WINAPI IPropertyStorage_fnWriteMultiple(
if (dictionary_num_entries(This->propid_to_prop) == 0 && if (dictionary_num_entries(This->propid_to_prop) == 0 &&
rgpropvar[i].vt == VT_I2) rgpropvar[i].vt == VT_I2)
{ {
This->codePage = rgpropvar[i].u.iVal; This->codePage = rgpropvar[i].iVal;
if (This->codePage == CP_UNICODE) if (This->codePage == CP_UNICODE)
This->grfFlags &= ~PROPSETFLAG_ANSI; This->grfFlags &= ~PROPSETFLAG_ANSI;
else else
...@@ -815,7 +815,7 @@ static HRESULT WINAPI IPropertyStorage_fnWriteMultiple( ...@@ -815,7 +815,7 @@ static HRESULT WINAPI IPropertyStorage_fnWriteMultiple(
/* Can only set the locale if nothing else has been set */ /* Can only set the locale if nothing else has been set */
if (dictionary_num_entries(This->propid_to_prop) == 0 && if (dictionary_num_entries(This->propid_to_prop) == 0 &&
rgpropvar[i].vt == VT_I4) rgpropvar[i].vt == VT_I4)
This->locale = rgpropvar[i].u.lVal; This->locale = rgpropvar[i].lVal;
else else
hr = STG_E_INVALIDPARAMETER; hr = STG_E_INVALIDPARAMETER;
break; break;
...@@ -1257,46 +1257,46 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_ ...@@ -1257,46 +1257,46 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_
hr = S_OK; hr = S_OK;
break; break;
case VT_I1: case VT_I1:
hr = buffer_read_byte(buffer, offset, (BYTE *)&prop->u.cVal); hr = buffer_read_byte(buffer, offset, (BYTE *)&prop->cVal);
TRACE("Read char 0x%x ('%c')\n", prop->u.cVal, prop->u.cVal); TRACE("Read char 0x%x ('%c')\n", prop->cVal, prop->cVal);
break; break;
case VT_UI1: case VT_UI1:
hr = buffer_read_byte(buffer, offset, &prop->u.bVal); hr = buffer_read_byte(buffer, offset, &prop->bVal);
TRACE("Read byte 0x%x\n", prop->u.bVal); TRACE("Read byte 0x%x\n", prop->bVal);
break; break;
case VT_BOOL: case VT_BOOL:
hr = buffer_read_word(buffer, offset, (WORD *)&prop->u.boolVal); hr = buffer_read_word(buffer, offset, (WORD *)&prop->boolVal);
TRACE("Read bool %d\n", prop->u.boolVal); TRACE("Read bool %d\n", prop->boolVal);
break; break;
case VT_I2: case VT_I2:
hr = buffer_read_word(buffer, offset, (WORD *)&prop->u.iVal); hr = buffer_read_word(buffer, offset, (WORD *)&prop->iVal);
TRACE("Read short %d\n", prop->u.iVal); TRACE("Read short %d\n", prop->iVal);
break; break;
case VT_UI2: case VT_UI2:
hr = buffer_read_word(buffer, offset, &prop->u.uiVal); hr = buffer_read_word(buffer, offset, &prop->uiVal);
TRACE("Read ushort %d\n", prop->u.uiVal); TRACE("Read ushort %d\n", prop->uiVal);
break; break;
case VT_INT: case VT_INT:
case VT_I4: case VT_I4:
hr = buffer_read_dword(buffer, offset, (DWORD *)&prop->u.lVal); hr = buffer_read_dword(buffer, offset, (DWORD *)&prop->lVal);
TRACE("Read long %d\n", prop->u.lVal); TRACE("Read long %d\n", prop->lVal);
break; break;
case VT_UINT: case VT_UINT:
case VT_UI4: case VT_UI4:
hr = buffer_read_dword(buffer, offset, &prop->u.ulVal); hr = buffer_read_dword(buffer, offset, &prop->ulVal);
TRACE("Read ulong %d\n", prop->u.ulVal); TRACE("Read ulong %d\n", prop->ulVal);
break; break;
case VT_I8: case VT_I8:
hr = buffer_read_uint64(buffer, offset, (ULARGE_INTEGER *)&prop->u.hVal); hr = buffer_read_uint64(buffer, offset, (ULARGE_INTEGER *)&prop->hVal);
TRACE("Read long long %s\n", wine_dbgstr_longlong(prop->u.hVal.QuadPart)); TRACE("Read long long %s\n", wine_dbgstr_longlong(prop->hVal.QuadPart));
break; break;
case VT_UI8: case VT_UI8:
hr = buffer_read_uint64(buffer, offset, &prop->u.uhVal); hr = buffer_read_uint64(buffer, offset, &prop->uhVal);
TRACE("Read ulong long %s\n", wine_dbgstr_longlong(prop->u.uhVal.QuadPart)); TRACE("Read ulong long %s\n", wine_dbgstr_longlong(prop->uhVal.QuadPart));
break; break;
case VT_R8: case VT_R8:
hr = buffer_read_len(buffer, offset, &prop->u.dblVal, sizeof(prop->u.dblVal)); hr = buffer_read_len(buffer, offset, &prop->dblVal, sizeof(prop->dblVal));
TRACE("Read double %f\n", prop->u.dblVal); TRACE("Read double %f\n", prop->dblVal);
break; break;
case VT_LPSTR: case VT_LPSTR:
{ {
...@@ -1314,10 +1314,10 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_ ...@@ -1314,10 +1314,10 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_
} }
else else
{ {
prop->u.pszVal = allocate(allocate_data, count); prop->pszVal = allocate(allocate_data, count);
if (prop->u.pszVal) if (prop->pszVal)
{ {
if (FAILED(hr = buffer_read_len(buffer, offset, prop->u.pszVal, count))) if (FAILED(hr = buffer_read_len(buffer, offset, prop->pszVal, count)))
break; break;
/* This is stored in the code page specified in codepage. /* This is stored in the code page specified in codepage.
...@@ -1326,15 +1326,15 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_ ...@@ -1326,15 +1326,15 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_
if (codepage == CP_UNICODE) if (codepage == CP_UNICODE)
{ {
/* Make sure it's NULL-terminated */ /* Make sure it's NULL-terminated */
prop->u.pszVal[count / sizeof(WCHAR) - 1] = '\0'; prop->pszVal[count / sizeof(WCHAR) - 1] = '\0';
TRACE("Read string value %s\n", TRACE("Read string value %s\n",
debugstr_w(prop->u.pwszVal)); debugstr_w(prop->pwszVal));
} }
else else
{ {
/* Make sure it's NULL-terminated */ /* Make sure it's NULL-terminated */
prop->u.pszVal[count - 1] = '\0'; prop->pszVal[count - 1] = '\0';
TRACE("Read string value %s\n", debugstr_a(prop->u.pszVal)); TRACE("Read string value %s\n", debugstr_a(prop->pszVal));
} }
} }
else else
...@@ -1367,17 +1367,17 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_ ...@@ -1367,17 +1367,17 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_
wcount = MultiByteToWideChar(codepage, 0, (LPCSTR)(buffer->data + offset), count, NULL, 0); wcount = MultiByteToWideChar(codepage, 0, (LPCSTR)(buffer->data + offset), count, NULL, 0);
} }
prop->u.bstrVal = SysAllocStringLen(NULL, wcount); /* FIXME: use allocator? */ prop->bstrVal = SysAllocStringLen(NULL, wcount); /* FIXME: use allocator? */
if (prop->u.bstrVal) if (prop->bstrVal)
{ {
if (codepage == CP_UNICODE) if (codepage == CP_UNICODE)
hr = buffer_read_len(buffer, offset, prop->u.bstrVal, count); hr = buffer_read_len(buffer, offset, prop->bstrVal, count);
else else
MultiByteToWideChar(codepage, 0, (LPCSTR)(buffer->data + offset), count, prop->u.bstrVal, wcount); MultiByteToWideChar(codepage, 0, (LPCSTR)(buffer->data + offset), count, prop->bstrVal, wcount);
prop->u.bstrVal[wcount - 1] = '\0'; prop->bstrVal[wcount - 1] = '\0';
TRACE("Read string value %s\n", debugstr_w(prop->u.bstrVal)); TRACE("Read string value %s\n", debugstr_w(prop->bstrVal));
} }
else else
hr = STG_E_INSUFFICIENTMEMORY; hr = STG_E_INSUFFICIENTMEMORY;
...@@ -1393,11 +1393,11 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_ ...@@ -1393,11 +1393,11 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_
offset += sizeof(DWORD); offset += sizeof(DWORD);
prop->u.blob.cbSize = count; prop->blob.cbSize = count;
prop->u.blob.pBlobData = allocate(allocate_data, count); prop->blob.pBlobData = allocate(allocate_data, count);
if (prop->u.blob.pBlobData) if (prop->blob.pBlobData)
{ {
hr = buffer_read_len(buffer, offset, prop->u.blob.pBlobData, count); hr = buffer_read_len(buffer, offset, prop->blob.pBlobData, count);
TRACE("Read blob value of size %d\n", count); TRACE("Read blob value of size %d\n", count);
} }
else else
...@@ -1413,15 +1413,15 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_ ...@@ -1413,15 +1413,15 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_
offset += sizeof(DWORD); offset += sizeof(DWORD);
prop->u.pwszVal = allocate(allocate_data, count * sizeof(WCHAR)); prop->pwszVal = allocate(allocate_data, count * sizeof(WCHAR));
if (prop->u.pwszVal) if (prop->pwszVal)
{ {
if (SUCCEEDED(hr = buffer_read_len(buffer, offset, prop->u.pwszVal, count * sizeof(WCHAR)))) if (SUCCEEDED(hr = buffer_read_len(buffer, offset, prop->pwszVal, count * sizeof(WCHAR))))
{ {
/* make sure string is NULL-terminated */ /* make sure string is NULL-terminated */
prop->u.pwszVal[count - 1] = '\0'; prop->pwszVal[count - 1] = '\0';
PropertyStorage_ByteSwapString(prop->u.pwszVal, count); PropertyStorage_ByteSwapString(prop->pwszVal, count);
TRACE("Read string value %s\n", debugstr_w(prop->u.pwszVal)); TRACE("Read string value %s\n", debugstr_w(prop->pwszVal));
} }
} }
else else
...@@ -1429,7 +1429,7 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_ ...@@ -1429,7 +1429,7 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_
break; break;
} }
case VT_FILETIME: case VT_FILETIME:
hr = buffer_read_uint64(buffer, offset, (ULARGE_INTEGER *)&prop->u.filetime); hr = buffer_read_uint64(buffer, offset, (ULARGE_INTEGER *)&prop->filetime);
break; break;
case VT_CF: case VT_CF:
{ {
...@@ -1445,22 +1445,22 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_ ...@@ -1445,22 +1445,22 @@ static HRESULT propertystorage_read_scalar(PROPVARIANT *prop, const struct read_
if (len > 8) if (len > 8)
{ {
len -= 8; len -= 8;
prop->u.pclipdata = allocate(allocate_data, sizeof (CLIPDATA)); prop->pclipdata = allocate(allocate_data, sizeof (CLIPDATA));
prop->u.pclipdata->cbSize = len; prop->pclipdata->cbSize = len;
prop->u.pclipdata->ulClipFmt = tag; prop->pclipdata->ulClipFmt = tag;
prop->u.pclipdata->pClipData = allocate(allocate_data, len - sizeof(prop->u.pclipdata->ulClipFmt)); prop->pclipdata->pClipData = allocate(allocate_data, len - sizeof(prop->pclipdata->ulClipFmt));
hr = buffer_read_len(buffer, offset, prop->u.pclipdata->pClipData, len - sizeof(prop->u.pclipdata->ulClipFmt)); hr = buffer_read_len(buffer, offset, prop->pclipdata->pClipData, len - sizeof(prop->pclipdata->ulClipFmt));
} }
else else
hr = STG_E_INVALIDPARAMETER; hr = STG_E_INVALIDPARAMETER;
} }
break; break;
case VT_CLSID: case VT_CLSID:
if (!(prop->u.puuid = allocate(allocate_data, sizeof (*prop->u.puuid)))) if (!(prop->puuid = allocate(allocate_data, sizeof (*prop->puuid))))
return STG_E_INSUFFICIENTMEMORY; return STG_E_INSUFFICIENTMEMORY;
if (SUCCEEDED(hr = buffer_test_offset(buffer, offset, sizeof(*prop->u.puuid)))) if (SUCCEEDED(hr = buffer_test_offset(buffer, offset, sizeof(*prop->puuid))))
StorageUtl_ReadGUID(buffer->data, offset, prop->u.puuid); StorageUtl_ReadGUID(buffer->data, offset, prop->puuid);
break; break;
default: default:
...@@ -1478,23 +1478,23 @@ static size_t propertystorage_get_elemsize(const PROPVARIANT *prop) ...@@ -1478,23 +1478,23 @@ static size_t propertystorage_get_elemsize(const PROPVARIANT *prop)
switch (prop->vt & ~VT_VECTOR) switch (prop->vt & ~VT_VECTOR)
{ {
case VT_I1: return sizeof(*prop->u.cac.pElems); case VT_I1: return sizeof(*prop->cac.pElems);
case VT_UI1: return sizeof(*prop->u.caub.pElems); case VT_UI1: return sizeof(*prop->caub.pElems);
case VT_I2: return sizeof(*prop->u.cai.pElems); case VT_I2: return sizeof(*prop->cai.pElems);
case VT_UI2: return sizeof(*prop->u.caui.pElems); case VT_UI2: return sizeof(*prop->caui.pElems);
case VT_BOOL: return sizeof(*prop->u.cabool.pElems); case VT_BOOL: return sizeof(*prop->cabool.pElems);
case VT_I4: return sizeof(*prop->u.cal.pElems); case VT_I4: return sizeof(*prop->cal.pElems);
case VT_UI4: return sizeof(*prop->u.caul.pElems); case VT_UI4: return sizeof(*prop->caul.pElems);
case VT_R4: return sizeof(*prop->u.caflt.pElems); case VT_R4: return sizeof(*prop->caflt.pElems);
case VT_ERROR: return sizeof(*prop->u.cascode.pElems); case VT_ERROR: return sizeof(*prop->cascode.pElems);
case VT_I8: return sizeof(*prop->u.cah.pElems); case VT_I8: return sizeof(*prop->cah.pElems);
case VT_UI8: return sizeof(*prop->u.cauh.pElems); case VT_UI8: return sizeof(*prop->cauh.pElems);
case VT_R8: return sizeof(*prop->u.cadbl.pElems); case VT_R8: return sizeof(*prop->cadbl.pElems);
case VT_CY: return sizeof(*prop->u.cacy.pElems); case VT_CY: return sizeof(*prop->cacy.pElems);
case VT_DATE: return sizeof(*prop->u.cadate.pElems); case VT_DATE: return sizeof(*prop->cadate.pElems);
case VT_FILETIME: return sizeof(*prop->u.cafiletime.pElems); case VT_FILETIME: return sizeof(*prop->cafiletime.pElems);
case VT_CLSID: return sizeof(*prop->u.cauuid.pElems); case VT_CLSID: return sizeof(*prop->cauuid.pElems);
case VT_VARIANT: return sizeof(*prop->u.capropvar.pElems); case VT_VARIANT: return sizeof(*prop->capropvar.pElems);
default: default:
FIXME("Unhandled type %#x.\n", prop->vt); FIXME("Unhandled type %#x.\n", prop->vt);
return 0; return 0;
...@@ -1540,9 +1540,9 @@ static HRESULT PropertyStorage_ReadProperty(PROPVARIANT *prop, const struct read ...@@ -1540,9 +1540,9 @@ static HRESULT PropertyStorage_ReadProperty(PROPVARIANT *prop, const struct read
offset += sizeof(DWORD); offset += sizeof(DWORD);
if ((prop->u.capropvar.pElems = allocate(allocate_data, elemsize * count))) if ((prop->capropvar.pElems = allocate(allocate_data, elemsize * count)))
{ {
prop->u.capropvar.cElems = count; prop->capropvar.cElems = count;
elem.vt = prop->vt & ~VT_VECTOR; elem.vt = prop->vt & ~VT_VECTOR;
for (i = 0; i < count; ++i) for (i = 0; i < count; ++i)
...@@ -1550,7 +1550,7 @@ static HRESULT PropertyStorage_ReadProperty(PROPVARIANT *prop, const struct read ...@@ -1550,7 +1550,7 @@ static HRESULT PropertyStorage_ReadProperty(PROPVARIANT *prop, const struct read
if (SUCCEEDED(hr = propertystorage_read_scalar(&elem, buffer, offset + i * elemsize, codepage, if (SUCCEEDED(hr = propertystorage_read_scalar(&elem, buffer, offset + i * elemsize, codepage,
allocate, allocate_data))) allocate, allocate_data)))
{ {
memcpy(&prop->u.capropvar.pElems[i], &elem.u.lVal, elemsize); memcpy(&prop->capropvar.pElems[i], &elem.lVal, elemsize);
} }
} }
} }
...@@ -1870,14 +1870,14 @@ static HRESULT PropertyStorage_ReadFromStream(PropertyStorage_impl *This) ...@@ -1870,14 +1870,14 @@ static HRESULT PropertyStorage_ReadFromStream(PropertyStorage_impl *This)
{ {
case PID_CODEPAGE: case PID_CODEPAGE:
if (prop.vt == VT_I2) if (prop.vt == VT_I2)
This->codePage = (UINT)prop.u.iVal; This->codePage = (UINT)prop.iVal;
break; break;
case PID_LOCALE: case PID_LOCALE:
if (prop.vt == VT_I4) if (prop.vt == VT_I4)
This->locale = (LCID)prop.u.lVal; This->locale = (LCID)prop.lVal;
break; break;
case PID_BEHAVIOR: case PID_BEHAVIOR:
if (prop.vt == VT_I4 && prop.u.lVal) if (prop.vt == VT_I4 && prop.lVal)
This->grfFlags |= PROPSETFLAG_CASE_SENSITIVE; This->grfFlags |= PROPSETFLAG_CASE_SENSITIVE;
/* The format should already be 1, but just in case */ /* The format should already be 1, but just in case */
This->format = 1; This->format = 1;
...@@ -2140,7 +2140,7 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This, ...@@ -2140,7 +2140,7 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This,
break; break;
case VT_I1: case VT_I1:
case VT_UI1: case VT_UI1:
hr = IStream_Write(This->stm, &var->u.cVal, sizeof(var->u.cVal), hr = IStream_Write(This->stm, &var->cVal, sizeof(var->cVal),
&count); &count);
bytesWritten = count; bytesWritten = count;
break; break;
...@@ -2149,7 +2149,7 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This, ...@@ -2149,7 +2149,7 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This,
{ {
WORD wTemp; WORD wTemp;
StorageUtl_WriteWord(&wTemp, 0, var->u.iVal); StorageUtl_WriteWord(&wTemp, 0, var->iVal);
hr = IStream_Write(This->stm, &wTemp, sizeof(wTemp), &count); hr = IStream_Write(This->stm, &wTemp, sizeof(wTemp), &count);
bytesWritten = count; bytesWritten = count;
break; break;
...@@ -2157,7 +2157,7 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This, ...@@ -2157,7 +2157,7 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This,
case VT_I4: case VT_I4:
case VT_UI4: case VT_UI4:
{ {
StorageUtl_WriteDWord(&dwTemp, 0, var->u.lVal); StorageUtl_WriteDWord(&dwTemp, 0, var->lVal);
hr = IStream_Write(This->stm, &dwTemp, sizeof(dwTemp), &count); hr = IStream_Write(This->stm, &dwTemp, sizeof(dwTemp), &count);
bytesWritten = count; bytesWritten = count;
break; break;
...@@ -2165,21 +2165,21 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This, ...@@ -2165,21 +2165,21 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This,
case VT_I8: case VT_I8:
case VT_UI8: case VT_UI8:
{ {
StorageUtl_WriteULargeInteger(&ularge, 0, &var->u.uhVal); StorageUtl_WriteULargeInteger(&ularge, 0, &var->uhVal);
hr = IStream_Write(This->stm, &ularge, sizeof(ularge), &bytesWritten); hr = IStream_Write(This->stm, &ularge, sizeof(ularge), &bytesWritten);
break; break;
} }
case VT_LPSTR: case VT_LPSTR:
{ {
if (This->codePage == CP_UNICODE) if (This->codePage == CP_UNICODE)
len = (lstrlenW(var->u.pwszVal) + 1) * sizeof(WCHAR); len = (lstrlenW(var->pwszVal) + 1) * sizeof(WCHAR);
else else
len = lstrlenA(var->u.pszVal) + 1; len = lstrlenA(var->pszVal) + 1;
StorageUtl_WriteDWord(&dwTemp, 0, len); StorageUtl_WriteDWord(&dwTemp, 0, len);
hr = IStream_Write(This->stm, &dwTemp, sizeof(dwTemp), &count); hr = IStream_Write(This->stm, &dwTemp, sizeof(dwTemp), &count);
if (FAILED(hr)) if (FAILED(hr))
goto end; goto end;
hr = IStream_Write(This->stm, var->u.pszVal, len, &count); hr = IStream_Write(This->stm, var->pszVal, len, &count);
bytesWritten = count + sizeof(DWORD); bytesWritten = count + sizeof(DWORD);
break; break;
} }
...@@ -2187,17 +2187,17 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This, ...@@ -2187,17 +2187,17 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This,
{ {
if (This->codePage == CP_UNICODE) if (This->codePage == CP_UNICODE)
{ {
len = SysStringByteLen(var->u.bstrVal) + sizeof(WCHAR); len = SysStringByteLen(var->bstrVal) + sizeof(WCHAR);
StorageUtl_WriteDWord(&dwTemp, 0, len); StorageUtl_WriteDWord(&dwTemp, 0, len);
hr = IStream_Write(This->stm, &dwTemp, sizeof(dwTemp), &count); hr = IStream_Write(This->stm, &dwTemp, sizeof(dwTemp), &count);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = IStream_Write(This->stm, var->u.bstrVal, len, &count); hr = IStream_Write(This->stm, var->bstrVal, len, &count);
} }
else else
{ {
char *str; char *str;
len = WideCharToMultiByte(This->codePage, 0, var->u.bstrVal, SysStringLen(var->u.bstrVal) + 1, len = WideCharToMultiByte(This->codePage, 0, var->bstrVal, SysStringLen(var->bstrVal) + 1,
NULL, 0, NULL, NULL); NULL, 0, NULL, NULL);
str = heap_alloc(len); str = heap_alloc(len);
...@@ -2207,7 +2207,7 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This, ...@@ -2207,7 +2207,7 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This,
goto end; goto end;
} }
WideCharToMultiByte(This->codePage, 0, var->u.bstrVal, SysStringLen(var->u.bstrVal), WideCharToMultiByte(This->codePage, 0, var->bstrVal, SysStringLen(var->bstrVal),
str, len, NULL, NULL); str, len, NULL, NULL);
StorageUtl_WriteDWord(&dwTemp, 0, len); StorageUtl_WriteDWord(&dwTemp, 0, len);
hr = IStream_Write(This->stm, &dwTemp, sizeof(dwTemp), &count); hr = IStream_Write(This->stm, &dwTemp, sizeof(dwTemp), &count);
...@@ -2221,13 +2221,13 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This, ...@@ -2221,13 +2221,13 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This,
} }
case VT_LPWSTR: case VT_LPWSTR:
{ {
len = lstrlenW(var->u.pwszVal) + 1; len = lstrlenW(var->pwszVal) + 1;
StorageUtl_WriteDWord(&dwTemp, 0, len); StorageUtl_WriteDWord(&dwTemp, 0, len);
hr = IStream_Write(This->stm, &dwTemp, sizeof(dwTemp), &count); hr = IStream_Write(This->stm, &dwTemp, sizeof(dwTemp), &count);
if (FAILED(hr)) if (FAILED(hr))
goto end; goto end;
hr = IStream_Write(This->stm, var->u.pwszVal, len * sizeof(WCHAR), hr = IStream_Write(This->stm, var->pwszVal, len * sizeof(WCHAR),
&count); &count);
bytesWritten = count + sizeof(DWORD); bytesWritten = count + sizeof(DWORD);
break; break;
...@@ -2236,7 +2236,7 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This, ...@@ -2236,7 +2236,7 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This,
{ {
FILETIME temp; FILETIME temp;
StorageUtl_WriteULargeInteger(&temp, 0, (const ULARGE_INTEGER *)&var->u.filetime); StorageUtl_WriteULargeInteger(&temp, 0, (const ULARGE_INTEGER *)&var->filetime);
hr = IStream_Write(This->stm, &temp, sizeof(temp), &count); hr = IStream_Write(This->stm, &temp, sizeof(temp), &count);
bytesWritten = count; bytesWritten = count;
break; break;
...@@ -2245,14 +2245,14 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This, ...@@ -2245,14 +2245,14 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This,
{ {
DWORD cf_hdr[2]; DWORD cf_hdr[2];
len = var->u.pclipdata->cbSize; len = var->pclipdata->cbSize;
StorageUtl_WriteDWord(&cf_hdr[0], 0, len + 8); StorageUtl_WriteDWord(&cf_hdr[0], 0, len + 8);
StorageUtl_WriteDWord(&cf_hdr[1], 0, var->u.pclipdata->ulClipFmt); StorageUtl_WriteDWord(&cf_hdr[1], 0, var->pclipdata->ulClipFmt);
hr = IStream_Write(This->stm, cf_hdr, sizeof(cf_hdr), &count); hr = IStream_Write(This->stm, cf_hdr, sizeof(cf_hdr), &count);
if (FAILED(hr)) if (FAILED(hr))
goto end; goto end;
hr = IStream_Write(This->stm, var->u.pclipdata->pClipData, hr = IStream_Write(This->stm, var->pclipdata->pClipData,
len - sizeof(var->u.pclipdata->ulClipFmt), &count); len - sizeof(var->pclipdata->ulClipFmt), &count);
if (FAILED(hr)) if (FAILED(hr))
goto end; goto end;
bytesWritten = count + sizeof cf_hdr; bytesWritten = count + sizeof cf_hdr;
...@@ -2262,7 +2262,7 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This, ...@@ -2262,7 +2262,7 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This,
{ {
CLSID temp; CLSID temp;
StorageUtl_WriteGUID(&temp, 0, var->u.puuid); StorageUtl_WriteGUID(&temp, 0, var->puuid);
hr = IStream_Write(This->stm, &temp, sizeof(temp), &count); hr = IStream_Write(This->stm, &temp, sizeof(temp), &count);
bytesWritten = count; bytesWritten = count;
break; break;
...@@ -2407,7 +2407,7 @@ static HRESULT PropertyStorage_WriteToStream(PropertyStorage_impl *This) ...@@ -2407,7 +2407,7 @@ static HRESULT PropertyStorage_WriteToStream(PropertyStorage_impl *This)
PropVariantInit(&var); PropVariantInit(&var);
var.vt = VT_I2; var.vt = VT_I2;
var.u.iVal = This->codePage; var.iVal = This->codePage;
hr = PropertyStorage_WritePropertyToStream(This, prop++, PID_CODEPAGE, hr = PropertyStorage_WritePropertyToStream(This, prop++, PID_CODEPAGE,
&var, &sectionOffset); &var, &sectionOffset);
if (FAILED(hr)) if (FAILED(hr))
...@@ -2416,7 +2416,7 @@ static HRESULT PropertyStorage_WriteToStream(PropertyStorage_impl *This) ...@@ -2416,7 +2416,7 @@ static HRESULT PropertyStorage_WriteToStream(PropertyStorage_impl *This)
if (This->locale != LOCALE_SYSTEM_DEFAULT) if (This->locale != LOCALE_SYSTEM_DEFAULT)
{ {
var.vt = VT_I4; var.vt = VT_I4;
var.u.lVal = This->locale; var.lVal = This->locale;
hr = PropertyStorage_WritePropertyToStream(This, prop++, PID_LOCALE, hr = PropertyStorage_WritePropertyToStream(This, prop++, PID_LOCALE,
&var, &sectionOffset); &var, &sectionOffset);
if (FAILED(hr)) if (FAILED(hr))
...@@ -2426,7 +2426,7 @@ static HRESULT PropertyStorage_WriteToStream(PropertyStorage_impl *This) ...@@ -2426,7 +2426,7 @@ static HRESULT PropertyStorage_WriteToStream(PropertyStorage_impl *This)
if (This->grfFlags & PROPSETFLAG_CASE_SENSITIVE) if (This->grfFlags & PROPSETFLAG_CASE_SENSITIVE)
{ {
var.vt = VT_I4; var.vt = VT_I4;
var.u.lVal = 1; var.lVal = 1;
hr = PropertyStorage_WritePropertyToStream(This, prop++, PID_BEHAVIOR, hr = PropertyStorage_WritePropertyToStream(This, prop++, PID_BEHAVIOR,
&var, &sectionOffset); &var, &sectionOffset);
if (FAILED(hr)) if (FAILED(hr))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment