Commit cd340ac8 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wbemprox: Support overriding the CIM to VARIANT type mapping for integer properties.

parent ada3dff1
...@@ -662,11 +662,43 @@ static HRESULT get_system_propval( const struct view *view, UINT index, const WC ...@@ -662,11 +662,43 @@ static HRESULT get_system_propval( const struct view *view, UINT index, const WC
return WBEM_E_NOT_FOUND; return WBEM_E_NOT_FOUND;
} }
static void set_variant( VARTYPE vartype, LONGLONG val, BSTR val_bstr, VARIANT *ret )
{
switch (vartype)
{
case VT_BSTR:
V_VT( ret ) = VT_BSTR;
V_BSTR( ret ) = val_bstr;
return;
case VT_I2:
V_VT( ret ) = VT_I2;
V_I2( ret ) = val;
return;
case VT_UI2:
V_VT( ret ) = VT_UI2;
V_UI2( ret ) = val;
return;
case VT_I4:
V_VT( ret ) = VT_I4;
V_I4( ret ) = val;
return;
case VT_UI4:
V_VT( ret ) = VT_UI4;
V_UI4( ret ) = val;
return;
default:
ERR("unhandled variant type %u\n", vartype);
return;
}
}
HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VARIANT *ret, HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VARIANT *ret,
CIMTYPE *type, LONG *flavor ) CIMTYPE *type, LONG *flavor )
{ {
HRESULT hr; HRESULT hr;
UINT column, row = view->result[index]; UINT column, row = view->result[index];
VARTYPE vartype;
BSTR val_bstr = NULL;
LONGLONG val; LONGLONG val;
if (is_system_prop( name )) return get_system_propval( view, index, name, ret, type, flavor ); if (is_system_prop( name )) return get_system_propval( view, index, name, ret, type, flavor );
...@@ -675,6 +707,8 @@ HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VAR ...@@ -675,6 +707,8 @@ HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VAR
hr = get_column_index( view->table, name, &column ); hr = get_column_index( view->table, name, &column );
if (hr != S_OK) return WBEM_E_NOT_FOUND; if (hr != S_OK) return WBEM_E_NOT_FOUND;
vartype = view->table->columns[column].vartype;
hr = get_value( view->table, row, column, &val ); hr = get_value( view->table, row, column, &val );
if (hr != S_OK) return hr; if (hr != S_OK) return hr;
...@@ -682,37 +716,34 @@ HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VAR ...@@ -682,37 +716,34 @@ HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VAR
{ {
case CIM_STRING: case CIM_STRING:
case CIM_DATETIME: case CIM_DATETIME:
V_VT( ret ) = VT_BSTR; vartype = VT_BSTR;
V_BSTR( ret ) = SysAllocString( (const WCHAR *)(INT_PTR)val ); val_bstr = SysAllocString( (const WCHAR *)(INT_PTR)val );
break; break;
case CIM_SINT16: case CIM_SINT16:
V_VT( ret ) = VT_I2; if (!vartype) vartype = VT_I2;
V_I2( ret ) = val;
break; break;
case CIM_UINT16: case CIM_UINT16:
V_VT( ret ) = VT_UI2; if (!vartype) vartype = VT_UI2;
V_UI2( ret ) = val;
break; break;
case CIM_SINT32: case CIM_SINT32:
V_VT( ret ) = VT_I4; if (!vartype) vartype = VT_I4;
V_I4( ret ) = val;
break; break;
case CIM_UINT32: case CIM_UINT32:
V_VT( ret ) = VT_UI4; if (!vartype) vartype = VT_UI4;
V_UI4( ret ) = val;
break; break;
case CIM_SINT64: case CIM_SINT64:
V_VT( ret ) = VT_BSTR; vartype = VT_BSTR;
V_BSTR( ret ) = get_value_bstr( view->table, row, column ); val_bstr = get_value_bstr( view->table, row, column );
break; break;
case CIM_UINT64: case CIM_UINT64:
V_VT( ret ) = VT_BSTR; vartype = VT_BSTR;
V_BSTR( ret ) = get_value_bstr( view->table, row, column ); val_bstr = get_value_bstr( view->table, row, column );
break; break;
default: default:
ERR("unhandled column type %u\n", view->table->columns[column].type); ERR("unhandled column type %u\n", view->table->columns[column].type);
return WBEM_E_FAILED; return WBEM_E_FAILED;
} }
set_variant( vartype, val, val_bstr, ret );
if (type) *type = view->table->columns[column].type & COL_TYPE_MASK; if (type) *type = view->table->columns[column].type & COL_TYPE_MASK;
if (flavor) *flavor = 0; if (flavor) *flavor = 0;
return S_OK; return S_OK;
......
...@@ -31,6 +31,7 @@ struct column ...@@ -31,6 +31,7 @@ struct column
{ {
const WCHAR *name; const WCHAR *name;
UINT type; UINT type;
VARTYPE vartype; /* 0 for default mapping */
}; };
struct table struct table
......
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