mirror of
https://github.com/reactos/reactos.git
synced 2026-05-31 08:17:09 +08:00
[WBEMPROX] Sync with Wine Staging 4.18. CORE-16441
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -18,8 +18,10 @@
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
#ifdef __REACTOS__
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
@@ -114,6 +116,7 @@ static HRESULT WINAPI enum_class_object_Next(
|
||||
{
|
||||
struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
|
||||
struct view *view = ec->query->view;
|
||||
struct table *table;
|
||||
static int once = 0;
|
||||
HRESULT hr;
|
||||
|
||||
@@ -124,14 +127,15 @@ static HRESULT WINAPI enum_class_object_Next(
|
||||
if (lTimeout != WBEM_INFINITE && !once++) FIXME("timeout not supported\n");
|
||||
|
||||
*puReturned = 0;
|
||||
if (ec->index >= view->count) return WBEM_S_FALSE;
|
||||
if (ec->index >= view->result_count) return WBEM_S_FALSE;
|
||||
|
||||
hr = create_class_object( view->table->name, iface, ec->index, NULL, apObjects );
|
||||
table = get_view_table( view, ec->index );
|
||||
hr = create_class_object( table->name, iface, ec->index, NULL, apObjects );
|
||||
if (hr != S_OK) return hr;
|
||||
|
||||
ec->index++;
|
||||
*puReturned = 1;
|
||||
if (ec->index == view->count && uCount > 1) return WBEM_S_FALSE;
|
||||
if (ec->index == view->result_count && uCount > 1) return WBEM_S_FALSE;
|
||||
if (uCount > 1) return WBEM_S_TIMEDOUT;
|
||||
return WBEM_S_NO_ERROR;
|
||||
}
|
||||
@@ -169,11 +173,11 @@ static HRESULT WINAPI enum_class_object_Skip(
|
||||
|
||||
if (lTimeout != WBEM_INFINITE && !once++) FIXME("timeout not supported\n");
|
||||
|
||||
if (!view->count) return WBEM_S_FALSE;
|
||||
if (!view->result_count) return WBEM_S_FALSE;
|
||||
|
||||
if (nCount > view->count - ec->index)
|
||||
if (nCount > view->result_count - ec->index)
|
||||
{
|
||||
ec->index = view->count - 1;
|
||||
ec->index = view->result_count - 1;
|
||||
return WBEM_S_FALSE;
|
||||
}
|
||||
ec->index += nCount;
|
||||
@@ -226,7 +230,6 @@ static struct record *create_record( struct table *table )
|
||||
for (i = 0; i < table->num_cols; i++)
|
||||
{
|
||||
record->fields[i].type = table->columns[i].type;
|
||||
record->fields[i].vartype = table->columns[i].vartype;
|
||||
record->fields[i].u.ival = 0;
|
||||
}
|
||||
record->count = table->num_cols;
|
||||
@@ -236,13 +239,11 @@ static struct record *create_record( struct table *table )
|
||||
|
||||
void destroy_array( struct array *array, CIMTYPE type )
|
||||
{
|
||||
UINT i, size;
|
||||
|
||||
UINT i;
|
||||
if (!array) return;
|
||||
if (type == CIM_STRING || type == CIM_DATETIME)
|
||||
if (type == CIM_STRING || type == CIM_DATETIME || type == CIM_REFERENCE)
|
||||
{
|
||||
size = get_type_size( type );
|
||||
for (i = 0; i < array->count; i++) heap_free( *(WCHAR **)((char *)array->ptr + i * size) );
|
||||
for (i = 0; i < array->count; i++) heap_free( *(WCHAR **)((char *)array->ptr + i * array->elem_size) );
|
||||
}
|
||||
heap_free( array->ptr );
|
||||
heap_free( array );
|
||||
@@ -256,8 +257,9 @@ static void destroy_record( struct record *record )
|
||||
release_table( record->table );
|
||||
for (i = 0; i < record->count; i++)
|
||||
{
|
||||
if (record->fields[i].type == CIM_STRING || record->fields[i].type == CIM_DATETIME)
|
||||
heap_free( record->fields[i].u.sval );
|
||||
if (record->fields[i].type == CIM_STRING ||
|
||||
record->fields[i].type == CIM_DATETIME ||
|
||||
record->fields[i].type == CIM_REFERENCE) heap_free( record->fields[i].u.sval );
|
||||
else if (record->fields[i].type & CIM_FLAG_ARRAY)
|
||||
destroy_array( record->fields[i].u.aval, record->fields[i].type & CIM_TYPE_MASK );
|
||||
}
|
||||
@@ -338,19 +340,22 @@ static HRESULT WINAPI class_object_GetQualifierSet(
|
||||
IWbemClassObject *iface,
|
||||
IWbemQualifierSet **ppQualSet )
|
||||
{
|
||||
FIXME("%p, %p\n", iface, ppQualSet);
|
||||
return E_NOTIMPL;
|
||||
struct class_object *co = impl_from_IWbemClassObject( iface );
|
||||
|
||||
TRACE("%p, %p\n", iface, ppQualSet);
|
||||
|
||||
return WbemQualifierSet_create( co->name, NULL, (void **)ppQualSet );
|
||||
}
|
||||
|
||||
static HRESULT record_get_value( const struct record *record, UINT index, VARIANT *var, CIMTYPE *type )
|
||||
{
|
||||
VARTYPE vartype = record->fields[index].vartype;
|
||||
VARTYPE vartype = to_vartype( record->fields[index].type & CIM_TYPE_MASK );
|
||||
|
||||
if (type) *type = record->fields[index].type;
|
||||
|
||||
if (record->fields[index].type & CIM_FLAG_ARRAY)
|
||||
{
|
||||
V_VT( var ) = vartype ? vartype : to_vartype( record->fields[index].type & CIM_TYPE_MASK ) | VT_ARRAY;
|
||||
V_VT( var ) = vartype | VT_ARRAY;
|
||||
V_ARRAY( var ) = to_safearray( record->fields[index].u.aval, record->fields[index].type & CIM_TYPE_MASK );
|
||||
return S_OK;
|
||||
}
|
||||
@@ -358,15 +363,13 @@ static HRESULT record_get_value( const struct record *record, UINT index, VARIAN
|
||||
{
|
||||
case CIM_STRING:
|
||||
case CIM_DATETIME:
|
||||
if (!vartype) vartype = VT_BSTR;
|
||||
case CIM_REFERENCE:
|
||||
V_BSTR( var ) = SysAllocString( record->fields[index].u.sval );
|
||||
break;
|
||||
case CIM_SINT32:
|
||||
if (!vartype) vartype = VT_I4;
|
||||
V_I4( var ) = record->fields[index].u.ival;
|
||||
break;
|
||||
case CIM_UINT32:
|
||||
if (!vartype) vartype = VT_UI4;
|
||||
V_UI4( var ) = record->fields[index].u.ival;
|
||||
break;
|
||||
default:
|
||||
@@ -419,6 +422,7 @@ static HRESULT record_set_value( struct record *record, UINT index, VARIANT *var
|
||||
{
|
||||
case CIM_STRING:
|
||||
case CIM_DATETIME:
|
||||
case CIM_REFERENCE:
|
||||
record->fields[index].u.sval = (WCHAR *)(INT_PTR)val;
|
||||
return S_OK;
|
||||
case CIM_SINT16:
|
||||
@@ -488,7 +492,7 @@ static HRESULT WINAPI class_object_GetNames(
|
||||
if (wszQualifierName || pQualifierVal)
|
||||
FIXME("qualifier not supported\n");
|
||||
|
||||
return get_properties( ec->query->view, lFlags, pNames );
|
||||
return get_properties( ec->query->view, co->index, lFlags, pNames );
|
||||
}
|
||||
|
||||
static HRESULT WINAPI class_object_BeginEnumeration(
|
||||
@@ -516,17 +520,18 @@ static HRESULT WINAPI class_object_Next(
|
||||
struct class_object *obj = impl_from_IWbemClassObject( iface );
|
||||
struct enum_class_object *iter = impl_from_IEnumWbemClassObject( obj->iter );
|
||||
struct view *view = iter->query->view;
|
||||
struct table *table = get_view_table( view, obj->index );
|
||||
BSTR prop;
|
||||
HRESULT hr;
|
||||
UINT i;
|
||||
|
||||
TRACE("%p, %08x, %p, %p, %p, %p\n", iface, lFlags, strName, pVal, pType, plFlavor);
|
||||
|
||||
for (i = obj->index_property; i < view->table->num_cols; i++)
|
||||
for (i = obj->index_property; i < table->num_cols; i++)
|
||||
{
|
||||
if (is_method( view->table, i )) continue;
|
||||
if (!is_selected_prop( view, view->table->columns[i].name )) continue;
|
||||
if (!(prop = SysAllocString( view->table->columns[i].name ))) return E_OUTOFMEMORY;
|
||||
if (is_method( table, i )) continue;
|
||||
if (!is_result_prop( view, table->columns[i].name )) continue;
|
||||
if (!(prop = SysAllocString( table->columns[i].name ))) return E_OUTOFMEMORY;
|
||||
if ((hr = get_propval( view, obj->index, prop, pVal, pType, plFlavor )) != S_OK)
|
||||
{
|
||||
SysFreeString( prop );
|
||||
@@ -586,7 +591,7 @@ static BSTR get_body_text( const struct table *table, UINT row, UINT *len )
|
||||
if ((value = get_value_bstr( table, row, i )))
|
||||
{
|
||||
*len += ARRAY_SIZE( fmtW );
|
||||
*len += strlenW( table->columns[i].name );
|
||||
*len += lstrlenW( table->columns[i].name );
|
||||
*len += SysStringLen( value );
|
||||
SysFreeString( value );
|
||||
}
|
||||
@@ -597,7 +602,7 @@ static BSTR get_body_text( const struct table *table, UINT row, UINT *len )
|
||||
{
|
||||
if ((value = get_value_bstr( table, row, i )))
|
||||
{
|
||||
p += sprintfW( p, fmtW, table->columns[i].name, value );
|
||||
p += swprintf( p, fmtW, table->columns[i].name, value );
|
||||
SysFreeString( value );
|
||||
}
|
||||
}
|
||||
@@ -609,15 +614,16 @@ static BSTR get_object_text( const struct view *view, UINT index )
|
||||
static const WCHAR fmtW[] =
|
||||
{'\n','i','n','s','t','a','n','c','e',' ','o','f',' ','%','s','\n','{','%','s','\n','}',';',0};
|
||||
UINT len, len_body, row = view->result[index];
|
||||
struct table *table = get_view_table( view, index );
|
||||
BSTR ret, body;
|
||||
|
||||
len = ARRAY_SIZE( fmtW );
|
||||
len += strlenW( view->table->name );
|
||||
if (!(body = get_body_text( view->table, row, &len_body ))) return NULL;
|
||||
len += lstrlenW( table->name );
|
||||
if (!(body = get_body_text( table, row, &len_body ))) return NULL;
|
||||
len += len_body;
|
||||
|
||||
if (!(ret = SysAllocStringLen( NULL, len ))) return NULL;
|
||||
sprintfW( ret, fmtW, view->table->name, body );
|
||||
swprintf( ret, fmtW, table->name, body );
|
||||
SysFreeString( body );
|
||||
return ret;
|
||||
}
|
||||
@@ -657,12 +663,12 @@ static HRESULT WINAPI class_object_SpawnInstance(
|
||||
{
|
||||
struct class_object *co = impl_from_IWbemClassObject( iface );
|
||||
struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter );
|
||||
struct view *view = ec->query->view;
|
||||
struct table *table = get_view_table( ec->query->view, co->index );
|
||||
struct record *record;
|
||||
|
||||
TRACE("%p, %08x, %p\n", iface, lFlags, ppNewInstance);
|
||||
|
||||
if (!(record = create_record( view->table ))) return E_OUTOFMEMORY;
|
||||
if (!(record = create_record( table ))) return E_OUTOFMEMORY;
|
||||
|
||||
return create_class_object( co->name, NULL, 0, record, ppNewInstance );
|
||||
}
|
||||
@@ -728,7 +734,6 @@ static HRESULT create_signature_columns_and_data( IEnumWbemClassObject *iter, UI
|
||||
{
|
||||
static const WCHAR parameterW[] = {'P','a','r','a','m','e','t','e','r',0};
|
||||
static const WCHAR typeW[] = {'T','y','p','e',0};
|
||||
static const WCHAR varianttypeW[] = {'V','a','r','i','a','n','t','T','y','p','e',0};
|
||||
static const WCHAR defaultvalueW[] = {'D','e','f','a','u','l','t','V','a','l','u','e',0};
|
||||
struct column *columns;
|
||||
BYTE *row;
|
||||
@@ -757,10 +762,6 @@ static HRESULT create_signature_columns_and_data( IEnumWbemClassObject *iter, UI
|
||||
if (hr != S_OK) goto error;
|
||||
columns[i].type = V_UI4( &val );
|
||||
|
||||
hr = IWbemClassObject_Get( param, varianttypeW, 0, &val, NULL, NULL );
|
||||
if (hr != S_OK) goto error;
|
||||
columns[i].vartype = V_UI4( &val );
|
||||
|
||||
hr = IWbemClassObject_Get( param, defaultvalueW, 0, &val, NULL, NULL );
|
||||
if (hr != S_OK) goto error;
|
||||
if (V_UI4( &val )) set_default_value( columns[i].type, V_UI4( &val ), row + offset );
|
||||
@@ -807,12 +808,12 @@ static WCHAR *build_signature_table_name( const WCHAR *class, const WCHAR *metho
|
||||
static const WCHAR fmtW[] = {'_','_','%','s','_','%','s','_','%','s',0};
|
||||
static const WCHAR outW[] = {'O','U','T',0};
|
||||
static const WCHAR inW[] = {'I','N',0};
|
||||
UINT len = ARRAY_SIZE(fmtW) + ARRAY_SIZE(outW) + strlenW( class ) + strlenW( method );
|
||||
UINT len = ARRAY_SIZE(fmtW) + ARRAY_SIZE(outW) + lstrlenW( class ) + lstrlenW( method );
|
||||
WCHAR *ret;
|
||||
|
||||
if (!(ret = heap_alloc( len * sizeof(WCHAR) ))) return NULL;
|
||||
sprintfW( ret, fmtW, class, method, dir == PARAM_IN ? inW : outW );
|
||||
return struprW( ret );
|
||||
swprintf( ret, fmtW, class, method, dir == PARAM_IN ? inW : outW );
|
||||
return _wcsupr( ret );
|
||||
}
|
||||
|
||||
HRESULT create_signature( const WCHAR *class, const WCHAR *method, enum param_direction dir,
|
||||
@@ -831,9 +832,9 @@ HRESULT create_signature( const WCHAR *class, const WCHAR *method, enum param_di
|
||||
WCHAR *query, *name;
|
||||
HRESULT hr;
|
||||
|
||||
len += strlenW( class ) + strlenW( method );
|
||||
len += lstrlenW( class ) + lstrlenW( method );
|
||||
if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
|
||||
sprintfW( query, selectW, class, method, dir >= 0 ? geW : leW );
|
||||
swprintf( query, selectW, class, method, dir >= 0 ? geW : leW );
|
||||
|
||||
hr = exec_query( query, &iter );
|
||||
heap_free( query );
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#ifndef _WBEMPROX_PRECOMP_H_
|
||||
#define _WBEMPROX_PRECOMP_H_
|
||||
|
||||
#include <wine/config.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define _INC_WINDOWS
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
#ifdef __REACTOS__
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
@@ -102,19 +104,32 @@ static HRESULT create_qualifier_enum( const WCHAR *class, const WCHAR *member, c
|
||||
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','_','_','Q','U','A','L',
|
||||
'I','F','I','E','R','S',' ','W','H','E','R','E',' ','C','l','a','s','s','=',
|
||||
'\'','%','s','\'',' ','A','N','D',' ','M','e','m','b','e','r','=','\'','%','s','\'',0};
|
||||
static const WCHAR noneW[] = {'_','_','N','O','N','E',0};
|
||||
static const WCHAR fmt3W[] =
|
||||
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','_','_','Q','U','A','L',
|
||||
'I','F','I','E','R','S',' ','W','H','E','R','E',' ','C','l','a','s','s','=',
|
||||
'\'','%','s','\'',0};
|
||||
WCHAR *query;
|
||||
HRESULT hr;
|
||||
int len;
|
||||
|
||||
if (!member) member = noneW;
|
||||
len = strlenW( class ) + strlenW( member );
|
||||
if (name) len += strlenW( name ) + ARRAY_SIZE(fmtW);
|
||||
else len += ARRAY_SIZE(fmt2W);
|
||||
|
||||
if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
|
||||
if (name) sprintfW( query, fmtW, class, member, name );
|
||||
else sprintfW( query, fmt2W, class, member );
|
||||
if (member && name)
|
||||
{
|
||||
len = lstrlenW( class ) + lstrlenW( member ) + lstrlenW( name ) + ARRAY_SIZE(fmtW);
|
||||
if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
|
||||
swprintf( query, fmtW, class, member, name );
|
||||
}
|
||||
else if (member)
|
||||
{
|
||||
len = lstrlenW( class ) + lstrlenW( member ) + ARRAY_SIZE(fmt2W);
|
||||
if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
|
||||
swprintf( query, fmt2W, class, member );
|
||||
}
|
||||
else
|
||||
{
|
||||
len = lstrlenW( class ) + ARRAY_SIZE(fmt3W);
|
||||
if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
|
||||
swprintf( query, fmt3W, class );
|
||||
}
|
||||
|
||||
hr = exec_query( query, iter );
|
||||
heap_free( query );
|
||||
@@ -124,9 +139,9 @@ static HRESULT create_qualifier_enum( const WCHAR *class, const WCHAR *member, c
|
||||
static HRESULT get_qualifier_value( const WCHAR *class, const WCHAR *member, const WCHAR *name,
|
||||
VARIANT *val, LONG *flavor )
|
||||
{
|
||||
static const WCHAR qualifiersW[] = {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
|
||||
static const WCHAR intvalueW[] = {'I','n','t','e','g','e','r','V','a','l','u','e',0};
|
||||
static const WCHAR strvalueW[] = {'S','t','r','i','n','g','V','a','l','u','e',0};
|
||||
static const WCHAR boolvalueW[] = {'B','o','o','l','V','a','l','u','e',0};
|
||||
static const WCHAR flavorW[] = {'F','l','a','v','o','r',0};
|
||||
static const WCHAR typeW[] = {'T','y','p','e',0};
|
||||
IEnumWbemClassObject *iter;
|
||||
@@ -137,7 +152,7 @@ static HRESULT get_qualifier_value( const WCHAR *class, const WCHAR *member, con
|
||||
hr = create_qualifier_enum( class, member, name, &iter );
|
||||
if (FAILED( hr )) return hr;
|
||||
|
||||
hr = create_class_object( qualifiersW, iter, 0, NULL, &obj );
|
||||
hr = create_class_object( NULL, iter, 0, NULL, &obj );
|
||||
IEnumWbemClassObject_Release( iter );
|
||||
if (FAILED( hr )) return hr;
|
||||
|
||||
@@ -157,6 +172,9 @@ static HRESULT get_qualifier_value( const WCHAR *class, const WCHAR *member, con
|
||||
case CIM_SINT32:
|
||||
hr = IWbemClassObject_Get( obj, intvalueW, 0, val, NULL, NULL );
|
||||
break;
|
||||
case CIM_BOOLEAN:
|
||||
hr = IWbemClassObject_Get( obj, boolvalueW, 0, val, NULL, NULL );
|
||||
break;
|
||||
default:
|
||||
ERR("unhandled type %u\n", V_UI4( &var ));
|
||||
break;
|
||||
@@ -176,7 +194,12 @@ static HRESULT WINAPI qualifier_set_Get(
|
||||
{
|
||||
struct qualifier_set *set = impl_from_IWbemQualifierSet( iface );
|
||||
|
||||
FIXME("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszName), lFlags, pVal, plFlavor);
|
||||
TRACE("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszName), lFlags, pVal, plFlavor);
|
||||
if (lFlags)
|
||||
{
|
||||
FIXME("flags %08x not supported\n", lFlags);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
return get_qualifier_value( set->class, set->member, wszName, pVal, plFlavor );
|
||||
}
|
||||
|
||||
@@ -203,8 +226,28 @@ static HRESULT WINAPI qualifier_set_GetNames(
|
||||
LONG lFlags,
|
||||
SAFEARRAY **pNames )
|
||||
{
|
||||
FIXME("%p, %08x, %p\n", iface, lFlags, pNames);
|
||||
return E_NOTIMPL;
|
||||
struct qualifier_set *set = impl_from_IWbemQualifierSet( iface );
|
||||
IEnumWbemClassObject *iter;
|
||||
IWbemClassObject *obj;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("%p, %08x, %p\n", iface, lFlags, pNames);
|
||||
if (lFlags)
|
||||
{
|
||||
FIXME("flags %08x not supported\n", lFlags);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
hr = create_qualifier_enum( set->class, set->member, NULL, &iter );
|
||||
if (FAILED( hr )) return hr;
|
||||
|
||||
hr = create_class_object( NULL, iter, 0, NULL, &obj );
|
||||
IEnumWbemClassObject_Release( iter );
|
||||
if (FAILED( hr )) return hr;
|
||||
|
||||
hr = IWbemClassObject_GetNames( obj, NULL, 0, NULL, pNames );
|
||||
IWbemClassObject_Release( obj );
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI qualifier_set_BeginEnumeration(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,6 @@
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
#ifdef __REACTOS__
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
@@ -27,7 +29,6 @@
|
||||
#include "wbemcli.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/unicode.h"
|
||||
#include "wbemprox_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
|
||||
@@ -279,7 +280,7 @@ static HRESULT WINAPI wbem_services_OpenNamespace(
|
||||
TRACE("%p, %s, 0x%08x, %p, %p, %p\n", iface, debugstr_w(strNamespace), lFlags,
|
||||
pCtx, ppWorkingNamespace, ppResult);
|
||||
|
||||
if ((strcmpiW( strNamespace, cimv2W ) && strcmpiW( strNamespace, defaultW )) || ws->namespace)
|
||||
if ((wcsicmp( strNamespace, cimv2W ) && wcsicmp( strNamespace, defaultW )) || ws->namespace)
|
||||
return WBEM_E_INVALID_NAMESPACE;
|
||||
|
||||
return WbemServices_create( cimv2W, (void **)ppWorkingNamespace );
|
||||
@@ -322,15 +323,7 @@ static HRESULT WINAPI wbem_services_QueryObjectSink(
|
||||
return WBEM_E_FAILED;
|
||||
}
|
||||
|
||||
struct path
|
||||
{
|
||||
WCHAR *class;
|
||||
UINT class_len;
|
||||
WCHAR *filter;
|
||||
UINT filter_len;
|
||||
};
|
||||
|
||||
static HRESULT parse_path( const WCHAR *str, struct path **ret )
|
||||
HRESULT parse_path( const WCHAR *str, struct path **ret )
|
||||
{
|
||||
struct path *path;
|
||||
const WCHAR *p = str, *q;
|
||||
@@ -340,31 +333,47 @@ static HRESULT parse_path( const WCHAR *str, struct path **ret )
|
||||
|
||||
if (*p == '\\')
|
||||
{
|
||||
static const WCHAR cimv2W[] = {'R','O','O','T','\\','C','I','M','V','2'};
|
||||
|
||||
static const WCHAR cimv2W[] = {'R','O','O','T','\\','C','I','M','V','2',0};
|
||||
WCHAR server[MAX_COMPUTERNAME_LENGTH+1];
|
||||
DWORD server_len = ARRAY_SIZE(server);
|
||||
|
||||
p++;
|
||||
if (*p != '\\') return WBEM_E_INVALID_OBJECT_PATH;
|
||||
if (*p != '\\')
|
||||
{
|
||||
heap_free( path );
|
||||
return WBEM_E_INVALID_OBJECT_PATH;
|
||||
}
|
||||
p++;
|
||||
|
||||
q = p;
|
||||
while (*p && *p != '\\') p++;
|
||||
if (!*p) return WBEM_E_INVALID_OBJECT_PATH;
|
||||
if (!*p)
|
||||
{
|
||||
heap_free( path );
|
||||
return WBEM_E_INVALID_OBJECT_PATH;
|
||||
}
|
||||
|
||||
len = p - q;
|
||||
if (!GetComputerNameW( server, &server_len ) || server_len != len
|
||||
|| memcmp( q, server, server_len * sizeof(WCHAR) ))
|
||||
if (!GetComputerNameW( server, &server_len ) || server_len != len || _wcsnicmp( q, server, server_len ))
|
||||
{
|
||||
heap_free( path );
|
||||
return WBEM_E_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
q = ++p;
|
||||
while (*p && *p != ':') p++;
|
||||
if (!*p) return WBEM_E_INVALID_OBJECT_PATH;
|
||||
if (!*p)
|
||||
{
|
||||
heap_free( path );
|
||||
return WBEM_E_INVALID_OBJECT_PATH;
|
||||
}
|
||||
|
||||
len = p - q;
|
||||
if (len != ARRAY_SIZE(cimv2W) || memcmp( q, cimv2W, sizeof(cimv2W) ))
|
||||
if (len != ARRAY_SIZE(cimv2W) - 1 || _wcsnicmp( q, cimv2W, ARRAY_SIZE(cimv2W) - 1 ))
|
||||
{
|
||||
heap_free( path );
|
||||
return WBEM_E_INVALID_NAMESPACE;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
@@ -401,14 +410,15 @@ static HRESULT parse_path( const WCHAR *str, struct path **ret )
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void free_path( struct path *path )
|
||||
void free_path( struct path *path )
|
||||
{
|
||||
if (!path) return;
|
||||
heap_free( path->class );
|
||||
heap_free( path->filter );
|
||||
heap_free( path );
|
||||
}
|
||||
|
||||
static WCHAR *query_from_path( const struct path *path )
|
||||
WCHAR *query_from_path( const struct path *path )
|
||||
{
|
||||
static const WCHAR selectW[] =
|
||||
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','%','s',' ',
|
||||
@@ -422,14 +432,14 @@ static WCHAR *query_from_path( const struct path *path )
|
||||
{
|
||||
len = path->class_len + path->filter_len + ARRAY_SIZE(selectW);
|
||||
if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return NULL;
|
||||
sprintfW( query, selectW, path->class, path->filter );
|
||||
swprintf( query, selectW, path->class, path->filter );
|
||||
}
|
||||
else
|
||||
{
|
||||
len = path->class_len + ARRAY_SIZE(select_allW);
|
||||
if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return NULL;
|
||||
strcpyW( query, select_allW );
|
||||
strcatW( query, path->class );
|
||||
lstrcpyW( query, select_allW );
|
||||
lstrcatW( query, path->class );
|
||||
}
|
||||
return query;
|
||||
}
|
||||
@@ -653,7 +663,7 @@ static HRESULT WINAPI wbem_services_ExecQuery(
|
||||
debugstr_w(strQuery), lFlags, pCtx, ppEnum);
|
||||
|
||||
if (!strQueryLanguage || !strQuery || !strQuery[0]) return WBEM_E_INVALID_PARAMETER;
|
||||
if (strcmpiW( strQueryLanguage, wqlW )) return WBEM_E_INVALID_QUERY_TYPE;
|
||||
if (wcsicmp( strQueryLanguage, wqlW )) return WBEM_E_INVALID_QUERY_TYPE;
|
||||
return exec_query( strQuery, ppEnum );
|
||||
}
|
||||
|
||||
@@ -823,6 +833,7 @@ static HRESULT WINAPI wbem_services_ExecMethod(
|
||||
struct path *path;
|
||||
WCHAR *str;
|
||||
class_method *func;
|
||||
struct table *table;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("%p, %s, %s, %08x, %p, %p, %p, %p\n", iface, debugstr_w(strObjectPath),
|
||||
@@ -850,10 +861,11 @@ static HRESULT WINAPI wbem_services_ExecMethod(
|
||||
hr = EnumWbemClassObject_create( query, (void **)&result );
|
||||
if (hr != S_OK) goto done;
|
||||
|
||||
hr = create_class_object( query->view->table->name, result, 0, NULL, &obj );
|
||||
table = get_view_table( query->view, 0 );
|
||||
hr = create_class_object( table->name, result, 0, NULL, &obj );
|
||||
if (hr != S_OK) goto done;
|
||||
|
||||
hr = get_method( query->view->table, strMethodName, &func );
|
||||
hr = get_method( table, strMethodName, &func );
|
||||
if (hr != S_OK) goto done;
|
||||
|
||||
hr = func( obj, pInParams, ppOutParams );
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
#ifdef __REACTOS__
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
@@ -35,7 +37,7 @@ HRESULT get_column_index( const struct table *table, const WCHAR *name, UINT *co
|
||||
UINT i;
|
||||
for (i = 0; i < table->num_cols; i++)
|
||||
{
|
||||
if (!strcmpiW( table->columns[i].name, name ))
|
||||
if (!wcsicmp( table->columns[i].name, name ))
|
||||
{
|
||||
*column = i;
|
||||
return S_OK;
|
||||
@@ -65,8 +67,11 @@ UINT get_type_size( CIMTYPE type )
|
||||
case CIM_UINT64:
|
||||
return sizeof(INT64);
|
||||
case CIM_DATETIME:
|
||||
case CIM_REFERENCE:
|
||||
case CIM_STRING:
|
||||
return sizeof(WCHAR *);
|
||||
case CIM_REAL32:
|
||||
return sizeof(FLOAT);
|
||||
default:
|
||||
ERR("unhandled type %u\n", type);
|
||||
break;
|
||||
@@ -111,6 +116,7 @@ HRESULT get_value( const struct table *table, UINT row, UINT column, LONGLONG *v
|
||||
*val = *(const int *)ptr;
|
||||
break;
|
||||
case CIM_DATETIME:
|
||||
case CIM_REFERENCE:
|
||||
case CIM_STRING:
|
||||
*val = (INT_PTR)*(const WCHAR **)ptr;
|
||||
break;
|
||||
@@ -138,6 +144,9 @@ HRESULT get_value( const struct table *table, UINT row, UINT column, LONGLONG *v
|
||||
case CIM_UINT64:
|
||||
*val = *(const UINT64 *)ptr;
|
||||
break;
|
||||
case CIM_REAL32:
|
||||
memcpy( val, ptr, sizeof(FLOAT) );
|
||||
break;
|
||||
default:
|
||||
ERR("invalid column type %u\n", table->columns[column].type & COL_TYPE_MASK);
|
||||
*val = 0;
|
||||
@@ -174,21 +183,22 @@ BSTR get_value_bstr( const struct table *table, UINT row, UINT column )
|
||||
else return SysAllocString( falseW );
|
||||
|
||||
case CIM_DATETIME:
|
||||
case CIM_REFERENCE:
|
||||
case CIM_STRING:
|
||||
if (!val) return NULL;
|
||||
len = strlenW( (const WCHAR *)(INT_PTR)val ) + 2;
|
||||
len = lstrlenW( (const WCHAR *)(INT_PTR)val ) + 2;
|
||||
if (!(ret = SysAllocStringLen( NULL, len ))) return NULL;
|
||||
sprintfW( ret, fmt_strW, (const WCHAR *)(INT_PTR)val );
|
||||
swprintf( ret, fmt_strW, (const WCHAR *)(INT_PTR)val );
|
||||
return ret;
|
||||
|
||||
case CIM_SINT16:
|
||||
case CIM_SINT32:
|
||||
sprintfW( number, fmt_signedW, val );
|
||||
swprintf( number, fmt_signedW, val );
|
||||
return SysAllocString( number );
|
||||
|
||||
case CIM_UINT16:
|
||||
case CIM_UINT32:
|
||||
sprintfW( number, fmt_unsignedW, val );
|
||||
swprintf( number, fmt_unsignedW, val );
|
||||
return SysAllocString( number );
|
||||
|
||||
case CIM_SINT64:
|
||||
@@ -221,6 +231,7 @@ HRESULT set_value( const struct table *table, UINT row, UINT column, LONGLONG va
|
||||
switch (table->columns[column].type & COL_TYPE_MASK)
|
||||
{
|
||||
case CIM_DATETIME:
|
||||
case CIM_REFERENCE:
|
||||
case CIM_STRING:
|
||||
*(WCHAR **)ptr = (WCHAR *)(INT_PTR)val;
|
||||
break;
|
||||
@@ -263,7 +274,7 @@ HRESULT get_method( const struct table *table, const WCHAR *name, class_method *
|
||||
{
|
||||
for (j = 0; j < table->num_cols; j++)
|
||||
{
|
||||
if (table->columns[j].type & COL_FLAG_METHOD && !strcmpW( table->columns[j].name, name ))
|
||||
if (table->columns[j].type & COL_FLAG_METHOD && !wcscmp( table->columns[j].name, name ))
|
||||
{
|
||||
HRESULT hr;
|
||||
LONGLONG val;
|
||||
@@ -288,7 +299,7 @@ void free_row_values( const struct table *table, UINT row )
|
||||
if (!(table->columns[i].type & COL_FLAG_DYNAMIC)) continue;
|
||||
|
||||
type = table->columns[i].type & COL_TYPE_MASK;
|
||||
if (type == CIM_STRING || type == CIM_DATETIME)
|
||||
if (type == CIM_STRING || type == CIM_DATETIME || type == CIM_REFERENCE)
|
||||
{
|
||||
if (get_value( table, row, i, &val ) == S_OK) heap_free( (void *)(INT_PTR)val );
|
||||
}
|
||||
@@ -357,7 +368,7 @@ struct table *grab_table( const WCHAR *name )
|
||||
|
||||
LIST_FOR_EACH_ENTRY( table, table_list, struct table, entry )
|
||||
{
|
||||
if (!strcmpiW( table->name, name ))
|
||||
if (name && !wcsicmp( table->name, name ))
|
||||
{
|
||||
TRACE("returning %p\n", table);
|
||||
return addref_table( table );
|
||||
@@ -392,7 +403,7 @@ BOOL add_table( struct table *table )
|
||||
|
||||
LIST_FOR_EACH_ENTRY( iter, table_list, struct table, entry )
|
||||
{
|
||||
if (!strcmpiW( iter->name, table->name ))
|
||||
if (!wcsicmp( iter->name, table->name ))
|
||||
{
|
||||
TRACE("table %s already exists\n", debugstr_w(table->name));
|
||||
return FALSE;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
@@ -27,7 +26,6 @@
|
||||
#include "wbemcli.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/unicode.h"
|
||||
#include "wbemprox_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
|
||||
@@ -93,16 +91,16 @@ static BOOL is_local_machine( const WCHAR *server )
|
||||
WCHAR buffer[MAX_COMPUTERNAME_LENGTH + 1];
|
||||
DWORD len = ARRAY_SIZE( buffer );
|
||||
|
||||
if (!server || !strcmpW( server, dotW ) || !strcmpiW( server, localhostW )) return TRUE;
|
||||
if (GetComputerNameW( buffer, &len ) && !strcmpiW( server, buffer )) return TRUE;
|
||||
if (!server || !wcscmp( server, dotW ) || !wcsicmp( server, localhostW )) return TRUE;
|
||||
if (GetComputerNameW( buffer, &len ) && !wcsicmp( server, buffer )) return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static HRESULT parse_resource( const WCHAR *resource, WCHAR **server, WCHAR **namespace )
|
||||
{
|
||||
static const WCHAR rootW[] = {'R','O','O','T'};
|
||||
static const WCHAR cimv2W[] = {'C','I','M','V','2'};
|
||||
static const WCHAR defaultW[] = {'D','E','F','A','U','L','T'};
|
||||
static const WCHAR cimv2W[] = {'C','I','M','V','2',0};
|
||||
static const WCHAR defaultW[] = {'D','E','F','A','U','L','T',0};
|
||||
HRESULT hr = WBEM_E_INVALID_NAMESPACE;
|
||||
const WCHAR *p, *q;
|
||||
unsigned int len;
|
||||
@@ -133,16 +131,15 @@ static HRESULT parse_resource( const WCHAR *resource, WCHAR **server, WCHAR **na
|
||||
p = q;
|
||||
while (*q && *q != '\\' && *q != '/') q++;
|
||||
len = q - p;
|
||||
if (len >= ARRAY_SIZE( rootW ) && memicmpW( rootW, p, len )) goto done;
|
||||
if (len >= ARRAY_SIZE( rootW ) && _wcsnicmp( rootW, p, len )) goto done;
|
||||
if (!*q)
|
||||
{
|
||||
hr = S_OK;
|
||||
goto done;
|
||||
}
|
||||
q++;
|
||||
len = strlenW( q );
|
||||
if ((len != ARRAY_SIZE( cimv2W ) || memicmpW( q, cimv2W, len )) &&
|
||||
(len != ARRAY_SIZE( defaultW ) || memicmpW( q, defaultW, len )))
|
||||
len = lstrlenW( q );
|
||||
if (wcsicmp( q, cimv2W ) && wcsicmp( q, defaultW ))
|
||||
goto done;
|
||||
if (!(*namespace = heap_alloc( (len + 1) * sizeof(WCHAR) ))) hr = E_OUTOFMEMORY;
|
||||
else
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
#include "wine/debug.h"
|
||||
#include "wine/heap.h"
|
||||
#include "wine/list.h"
|
||||
#include "wine/unicode.h"
|
||||
#ifdef __REACTOS__
|
||||
#include <winnls.h>
|
||||
#endif
|
||||
|
||||
IClientSecurity client_security DECLSPEC_HIDDEN;
|
||||
struct list *table_list DECLSPEC_HIDDEN;
|
||||
@@ -92,7 +94,6 @@ struct column
|
||||
{
|
||||
const WCHAR *name;
|
||||
UINT type;
|
||||
VARTYPE vartype; /* 0 for default mapping */
|
||||
};
|
||||
|
||||
enum fill_status
|
||||
@@ -127,6 +128,7 @@ struct property
|
||||
|
||||
struct array
|
||||
{
|
||||
UINT elem_size;
|
||||
UINT count;
|
||||
void *ptr;
|
||||
};
|
||||
@@ -134,7 +136,6 @@ struct array
|
||||
struct field
|
||||
{
|
||||
UINT type;
|
||||
VARTYPE vartype; /* 0 for default mapping */
|
||||
union
|
||||
{
|
||||
LONGLONG ival;
|
||||
@@ -150,13 +151,30 @@ struct record
|
||||
struct table *table;
|
||||
};
|
||||
|
||||
struct keyword
|
||||
{
|
||||
const WCHAR *name;
|
||||
const WCHAR *value;
|
||||
const struct keyword *next;
|
||||
};
|
||||
|
||||
enum view_type
|
||||
{
|
||||
VIEW_TYPE_SELECT,
|
||||
VIEW_TYPE_ASSOCIATORS,
|
||||
};
|
||||
|
||||
struct view
|
||||
{
|
||||
const struct property *proplist;
|
||||
struct table *table;
|
||||
enum view_type type;
|
||||
const WCHAR *path; /* ASSOCIATORS OF query */
|
||||
const struct keyword *keywordlist;
|
||||
const struct property *proplist; /* SELECT query */
|
||||
const struct expr *cond;
|
||||
UINT table_count;
|
||||
struct table **table;
|
||||
UINT result_count;
|
||||
UINT *result;
|
||||
UINT count;
|
||||
};
|
||||
|
||||
struct query
|
||||
@@ -166,16 +184,29 @@ struct query
|
||||
struct list mem;
|
||||
};
|
||||
|
||||
struct path
|
||||
{
|
||||
WCHAR *class;
|
||||
UINT class_len;
|
||||
WCHAR *filter;
|
||||
UINT filter_len;
|
||||
};
|
||||
|
||||
HRESULT parse_path( const WCHAR *, struct path ** ) DECLSPEC_HIDDEN;
|
||||
void free_path( struct path * ) DECLSPEC_HIDDEN;
|
||||
WCHAR *query_from_path( const struct path * ) DECLSPEC_HIDDEN;
|
||||
|
||||
struct query *create_query(void) DECLSPEC_HIDDEN;
|
||||
void free_query( struct query * ) DECLSPEC_HIDDEN;
|
||||
struct query *addref_query( struct query * ) DECLSPEC_HIDDEN;
|
||||
void release_query( struct query *query ) DECLSPEC_HIDDEN;
|
||||
HRESULT exec_query( const WCHAR *, IEnumWbemClassObject ** ) DECLSPEC_HIDDEN;
|
||||
HRESULT parse_query( const WCHAR *, struct view **, struct list * ) DECLSPEC_HIDDEN;
|
||||
HRESULT create_view( const struct property *, const WCHAR *, const struct expr *,
|
||||
struct view ** ) DECLSPEC_HIDDEN;
|
||||
HRESULT create_view( enum view_type, const WCHAR *, const struct keyword *, const WCHAR *, const struct property *,
|
||||
const struct expr *, struct view ** ) DECLSPEC_HIDDEN;
|
||||
void destroy_view( struct view * ) DECLSPEC_HIDDEN;
|
||||
HRESULT execute_view( struct view * ) DECLSPEC_HIDDEN;
|
||||
struct table *get_view_table( const struct view *, UINT ) DECLSPEC_HIDDEN;
|
||||
void init_table_list( void ) DECLSPEC_HIDDEN;
|
||||
struct table *grab_table( const WCHAR * ) DECLSPEC_HIDDEN;
|
||||
struct table *addref_table( struct table * ) DECLSPEC_HIDDEN;
|
||||
@@ -195,15 +226,14 @@ BSTR get_value_bstr( const struct table *, UINT, UINT ) DECLSPEC_HIDDEN;
|
||||
HRESULT set_value( const struct table *, UINT, UINT, LONGLONG, CIMTYPE ) DECLSPEC_HIDDEN;
|
||||
BOOL is_method( const struct table *, UINT ) DECLSPEC_HIDDEN;
|
||||
HRESULT get_method( const struct table *, const WCHAR *, class_method ** ) DECLSPEC_HIDDEN;
|
||||
HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *,
|
||||
CIMTYPE *, LONG * ) DECLSPEC_HIDDEN;
|
||||
HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE *, LONG * ) DECLSPEC_HIDDEN;
|
||||
HRESULT put_propval( const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE ) DECLSPEC_HIDDEN;
|
||||
HRESULT to_longlong( VARIANT *, LONGLONG *, CIMTYPE * ) DECLSPEC_HIDDEN;
|
||||
SAFEARRAY *to_safearray( const struct array *, CIMTYPE ) DECLSPEC_HIDDEN;
|
||||
VARTYPE to_vartype( CIMTYPE ) DECLSPEC_HIDDEN;
|
||||
void destroy_array( struct array *, CIMTYPE ) DECLSPEC_HIDDEN;
|
||||
BOOL is_selected_prop( const struct view *, const WCHAR * ) DECLSPEC_HIDDEN;
|
||||
HRESULT get_properties( const struct view *, LONG, SAFEARRAY ** ) DECLSPEC_HIDDEN;
|
||||
BOOL is_result_prop( const struct view *, const WCHAR * ) DECLSPEC_HIDDEN;
|
||||
HRESULT get_properties( const struct view *, UINT, LONG, SAFEARRAY ** ) DECLSPEC_HIDDEN;
|
||||
HRESULT get_object( const WCHAR *, IWbemClassObject ** ) DECLSPEC_HIDDEN;
|
||||
BSTR get_method_name( const WCHAR *, UINT ) DECLSPEC_HIDDEN;
|
||||
void set_variant( VARTYPE, LONGLONG, void *, VARIANT * ) DECLSPEC_HIDDEN;
|
||||
@@ -233,7 +263,17 @@ static inline WCHAR *heap_strdupW( const WCHAR *src )
|
||||
{
|
||||
WCHAR *dst;
|
||||
if (!src) return NULL;
|
||||
if ((dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) ))) strcpyW( dst, src );
|
||||
if ((dst = heap_alloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) ))) lstrcpyW( dst, src );
|
||||
return dst;
|
||||
}
|
||||
|
||||
static inline WCHAR *heap_strdupAW( const char *src )
|
||||
{
|
||||
int len;
|
||||
WCHAR *dst;
|
||||
if (!src) return NULL;
|
||||
len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
|
||||
if ((dst = heap_alloc( len * sizeof(*dst) ))) MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,9 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0. */
|
||||
/* A Bison parser, made by GNU Bison 3.4.1. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -30,6 +31,9 @@
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/* Undocumented macros, especially those whose name start with YY_,
|
||||
are private implementation details. Do not rely on them. */
|
||||
|
||||
#ifndef YY_WQL_E_REACTOSSYNC_GCC_DLL_WIN32_WBEMPROX_WQL_TAB_H_INCLUDED
|
||||
# define YY_WQL_E_REACTOSSYNC_GCC_DLL_WIN32_WBEMPROX_WQL_TAB_H_INCLUDED
|
||||
/* Debug traces. */
|
||||
@@ -62,37 +66,42 @@ extern int wql_debug;
|
||||
TK_MINUS = 272,
|
||||
TK_ILLEGAL = 273,
|
||||
TK_BY = 274,
|
||||
TK_STRING = 275,
|
||||
TK_ID = 276,
|
||||
TK_OR = 277,
|
||||
TK_AND = 278,
|
||||
TK_NOT = 279,
|
||||
TK_EQ = 280,
|
||||
TK_NE = 281,
|
||||
TK_LT = 282,
|
||||
TK_GT = 283,
|
||||
TK_LE = 284,
|
||||
TK_GE = 285,
|
||||
TK_LIKE = 286
|
||||
TK_ASSOCIATORS = 275,
|
||||
TK_OF = 276,
|
||||
TK_STRING = 277,
|
||||
TK_ID = 278,
|
||||
TK_PATH = 279,
|
||||
TK_OR = 280,
|
||||
TK_AND = 281,
|
||||
TK_NOT = 282,
|
||||
TK_EQ = 283,
|
||||
TK_NE = 284,
|
||||
TK_LT = 285,
|
||||
TK_GT = 286,
|
||||
TK_LE = 287,
|
||||
TK_GE = 288,
|
||||
TK_LIKE = 289
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Value type. */
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
union YYSTYPE
|
||||
{
|
||||
#line 194 "wql.y" /* yacc.c:1909 */
|
||||
#line 222 "wql.y"
|
||||
|
||||
struct string str;
|
||||
WCHAR *string;
|
||||
struct property *proplist;
|
||||
struct keyword *keywordlist;
|
||||
struct view *view;
|
||||
struct expr *expr;
|
||||
int integer;
|
||||
|
||||
#line 95 "wql.tab.h" /* yacc.c:1909 */
|
||||
#line 102 "wql.tab.h"
|
||||
|
||||
};
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
@@ -28,7 +27,6 @@
|
||||
|
||||
#include "wine/list.h"
|
||||
#include "wine/debug.h"
|
||||
#include "wine/unicode.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
|
||||
|
||||
@@ -67,6 +65,18 @@ static struct property *alloc_property( struct parser *parser, const WCHAR *clas
|
||||
return prop;
|
||||
}
|
||||
|
||||
static struct keyword *alloc_keyword( struct parser *parser, const WCHAR *name, const WCHAR *value )
|
||||
{
|
||||
struct keyword *keyword = alloc_mem( parser, sizeof(*keyword) );
|
||||
if (keyword)
|
||||
{
|
||||
keyword->name = name;
|
||||
keyword->value = value;
|
||||
keyword->next = NULL;
|
||||
}
|
||||
return keyword;
|
||||
}
|
||||
|
||||
static WCHAR *get_string( struct parser *parser, const struct string *str )
|
||||
{
|
||||
const WCHAR *p = str->data;
|
||||
@@ -87,6 +97,24 @@ static WCHAR *get_string( struct parser *parser, const struct string *str )
|
||||
return ret;
|
||||
}
|
||||
|
||||
static WCHAR *get_path( struct parser *parser, const struct string *str )
|
||||
{
|
||||
const WCHAR *p = str->data;
|
||||
int len = str->len;
|
||||
WCHAR *ret;
|
||||
|
||||
if (p[0] == '{' && p[len - 1] == '}')
|
||||
{
|
||||
p++;
|
||||
len -= 2;
|
||||
}
|
||||
|
||||
if (!(ret = alloc_mem( parser, (len + 1) * sizeof(WCHAR) ))) return NULL;
|
||||
memcpy( ret, p, len * sizeof(WCHAR) );
|
||||
ret[len] = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int get_int( struct parser *parser )
|
||||
{
|
||||
const WCHAR *p = &parser->cmd[parser->idx];
|
||||
@@ -187,7 +215,7 @@ static int wql_lex( void *val, struct parser *parser );
|
||||
|
||||
%lex-param { struct parser *ctx }
|
||||
%parse-param { struct parser *ctx }
|
||||
%error-verbose
|
||||
%define parse.error verbose
|
||||
%pure-parser
|
||||
|
||||
%union
|
||||
@@ -195,28 +223,92 @@ static int wql_lex( void *val, struct parser *parser );
|
||||
struct string str;
|
||||
WCHAR *string;
|
||||
struct property *proplist;
|
||||
struct keyword *keywordlist;
|
||||
struct view *view;
|
||||
struct expr *expr;
|
||||
int integer;
|
||||
}
|
||||
|
||||
%token TK_SELECT TK_FROM TK_STAR TK_COMMA TK_DOT TK_IS TK_LP TK_RP TK_NULL TK_FALSE TK_TRUE
|
||||
%token TK_INTEGER TK_WHERE TK_SPACE TK_MINUS TK_ILLEGAL TK_BY
|
||||
%token <str> TK_STRING TK_ID
|
||||
%token TK_INTEGER TK_WHERE TK_SPACE TK_MINUS TK_ILLEGAL TK_BY TK_ASSOCIATORS TK_OF
|
||||
%token <str> TK_STRING TK_ID TK_PATH
|
||||
|
||||
%type <string> id
|
||||
%type <string> id path
|
||||
%type <proplist> prop proplist
|
||||
%type <view> select
|
||||
%type <keywordlist> keyword keywordlist
|
||||
%type <view> query select associatorsof
|
||||
%type <expr> expr prop_val const_val string_val
|
||||
%type <integer> number
|
||||
|
||||
%left TK_OR
|
||||
%left TK_AND
|
||||
%left TK_NOT
|
||||
%left TK_EQ TK_NE TK_LT TK_GT TK_LE TK_GE TK_LIKE
|
||||
%left TK_OR TK_AND TK_NOT TK_EQ TK_NE TK_LT TK_GT TK_LE TK_GE TK_LIKE
|
||||
|
||||
%%
|
||||
|
||||
query:
|
||||
select
|
||||
|
|
||||
associatorsof
|
||||
;
|
||||
|
||||
path:
|
||||
TK_PATH
|
||||
{
|
||||
$$ = get_path( ctx, &$1 );
|
||||
if (!$$)
|
||||
YYABORT;
|
||||
}
|
||||
;
|
||||
|
||||
keyword:
|
||||
id
|
||||
{
|
||||
$$ = alloc_keyword( ctx, $1, NULL );
|
||||
if (!$$)
|
||||
YYABORT;
|
||||
}
|
||||
| id TK_EQ id
|
||||
{
|
||||
$$ = alloc_keyword( ctx, $1, $3 );
|
||||
if (!$$)
|
||||
YYABORT;
|
||||
}
|
||||
;
|
||||
|
||||
keywordlist:
|
||||
keyword
|
||||
| keyword keywordlist
|
||||
{
|
||||
$1->next = $2;
|
||||
}
|
||||
;
|
||||
|
||||
associatorsof:
|
||||
TK_ASSOCIATORS TK_OF path
|
||||
{
|
||||
HRESULT hr;
|
||||
struct parser *parser = ctx;
|
||||
struct view *view;
|
||||
|
||||
hr = create_view( VIEW_TYPE_ASSOCIATORS, $3, NULL, NULL, NULL, NULL, &view );
|
||||
if (hr != S_OK)
|
||||
YYABORT;
|
||||
|
||||
PARSER_BUBBLE_UP_VIEW( parser, $$, view );
|
||||
}
|
||||
| TK_ASSOCIATORS TK_OF path TK_WHERE keywordlist
|
||||
{
|
||||
HRESULT hr;
|
||||
struct parser *parser = ctx;
|
||||
struct view *view;
|
||||
|
||||
hr = create_view( VIEW_TYPE_ASSOCIATORS, $3, $5, NULL, NULL, NULL, &view );
|
||||
if (hr != S_OK)
|
||||
YYABORT;
|
||||
|
||||
PARSER_BUBBLE_UP_VIEW( parser, $$, view );
|
||||
}
|
||||
;
|
||||
|
||||
select:
|
||||
TK_SELECT TK_FROM id
|
||||
{
|
||||
@@ -224,7 +316,7 @@ select:
|
||||
struct parser *parser = ctx;
|
||||
struct view *view;
|
||||
|
||||
hr = create_view( NULL, $3, NULL, &view );
|
||||
hr = create_view( VIEW_TYPE_SELECT, NULL, NULL, $3, NULL, NULL, &view );
|
||||
if (hr != S_OK)
|
||||
YYABORT;
|
||||
|
||||
@@ -236,7 +328,7 @@ select:
|
||||
struct parser *parser = ctx;
|
||||
struct view *view;
|
||||
|
||||
hr = create_view( $2, $4, NULL, &view );
|
||||
hr = create_view( VIEW_TYPE_SELECT, NULL, NULL, $4, $2, NULL, &view );
|
||||
if (hr != S_OK)
|
||||
YYABORT;
|
||||
|
||||
@@ -248,7 +340,7 @@ select:
|
||||
struct parser *parser = ctx;
|
||||
struct view *view;
|
||||
|
||||
hr = create_view( $2, $4, $6, &view );
|
||||
hr = create_view( VIEW_TYPE_SELECT, NULL, NULL, $4, $2, $6, &view );
|
||||
if (hr != S_OK)
|
||||
YYABORT;
|
||||
|
||||
@@ -535,16 +627,18 @@ static const char id_char[] =
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
};
|
||||
|
||||
struct keyword
|
||||
struct wql_keyword
|
||||
{
|
||||
const WCHAR *name;
|
||||
unsigned int len;
|
||||
int type;
|
||||
};
|
||||
|
||||
#define MAX_TOKEN_LEN 6
|
||||
#define MIN_TOKEN_LEN 2
|
||||
#define MAX_TOKEN_LEN 11
|
||||
|
||||
static const WCHAR andW[] = {'A','N','D'};
|
||||
static const WCHAR associatorsW[] = {'A','S','S','O','C','I','A','T','O','R','S'};
|
||||
static const WCHAR byW[] = {'B','Y'};
|
||||
static const WCHAR falseW[] = {'F','A','L','S','E'};
|
||||
static const WCHAR fromW[] = {'F','R','O','M'};
|
||||
@@ -552,34 +646,37 @@ static const WCHAR isW[] = {'I','S'};
|
||||
static const WCHAR likeW[] = {'L','I','K','E'};
|
||||
static const WCHAR notW[] = {'N','O','T'};
|
||||
static const WCHAR nullW[] = {'N','U','L','L'};
|
||||
static const WCHAR ofW[] = {'O','F'};
|
||||
static const WCHAR orW[] = {'O','R'};
|
||||
static const WCHAR selectW[] = {'S','E','L','E','C','T'};
|
||||
static const WCHAR trueW[] = {'T','R','U','E'};
|
||||
static const WCHAR whereW[] = {'W','H','E','R','E'};
|
||||
|
||||
static const struct keyword keyword_table[] =
|
||||
static const struct wql_keyword keyword_table[] =
|
||||
{
|
||||
{ andW, ARRAY_SIZE(andW), TK_AND },
|
||||
{ byW, ARRAY_SIZE(byW), TK_BY },
|
||||
{ falseW, ARRAY_SIZE(falseW), TK_FALSE },
|
||||
{ fromW, ARRAY_SIZE(fromW), TK_FROM },
|
||||
{ isW, ARRAY_SIZE(isW), TK_IS },
|
||||
{ likeW, ARRAY_SIZE(likeW), TK_LIKE },
|
||||
{ notW, ARRAY_SIZE(notW), TK_NOT },
|
||||
{ nullW, ARRAY_SIZE(nullW), TK_NULL },
|
||||
{ orW, ARRAY_SIZE(orW), TK_OR },
|
||||
{ selectW, ARRAY_SIZE(selectW), TK_SELECT },
|
||||
{ trueW, ARRAY_SIZE(trueW), TK_TRUE },
|
||||
{ whereW, ARRAY_SIZE(whereW), TK_WHERE }
|
||||
{ andW, ARRAY_SIZE(andW), TK_AND },
|
||||
{ associatorsW, ARRAY_SIZE(associatorsW), TK_ASSOCIATORS },
|
||||
{ byW, ARRAY_SIZE(byW), TK_BY },
|
||||
{ falseW, ARRAY_SIZE(falseW), TK_FALSE },
|
||||
{ fromW, ARRAY_SIZE(fromW), TK_FROM },
|
||||
{ isW, ARRAY_SIZE(isW), TK_IS },
|
||||
{ likeW, ARRAY_SIZE(likeW), TK_LIKE },
|
||||
{ notW, ARRAY_SIZE(notW), TK_NOT },
|
||||
{ nullW, ARRAY_SIZE(nullW), TK_NULL },
|
||||
{ ofW, ARRAY_SIZE(ofW), TK_OF },
|
||||
{ orW, ARRAY_SIZE(orW), TK_OR },
|
||||
{ selectW, ARRAY_SIZE(selectW), TK_SELECT },
|
||||
{ trueW, ARRAY_SIZE(trueW), TK_TRUE },
|
||||
{ whereW, ARRAY_SIZE(whereW), TK_WHERE }
|
||||
};
|
||||
|
||||
static int cmp_keyword( const void *arg1, const void *arg2 )
|
||||
static int __cdecl cmp_keyword( const void *arg1, const void *arg2 )
|
||||
{
|
||||
const struct keyword *key1 = arg1, *key2 = arg2;
|
||||
const struct wql_keyword *key1 = arg1, *key2 = arg2;
|
||||
int len = min( key1->len, key2->len );
|
||||
int ret;
|
||||
|
||||
if ((ret = memicmpW( key1->name, key2->name, len ))) return ret;
|
||||
if ((ret = _wcsnicmp( key1->name, key2->name, len ))) return ret;
|
||||
if (key1->len < key2->len) return -1;
|
||||
else if (key1->len > key2->len) return 1;
|
||||
return 0;
|
||||
@@ -587,14 +684,14 @@ static int cmp_keyword( const void *arg1, const void *arg2 )
|
||||
|
||||
static int keyword_type( const WCHAR *str, unsigned int len )
|
||||
{
|
||||
struct keyword key, *ret;
|
||||
struct wql_keyword key, *ret;
|
||||
|
||||
if (len > MAX_TOKEN_LEN) return TK_ID;
|
||||
if (len < MIN_TOKEN_LEN || len > MAX_TOKEN_LEN) return TK_ID;
|
||||
|
||||
key.name = str;
|
||||
key.len = len;
|
||||
key.type = 0;
|
||||
ret = bsearch( &key, keyword_table, ARRAY_SIZE(keyword_table), sizeof(struct keyword), cmp_keyword );
|
||||
ret = bsearch( &key, keyword_table, ARRAY_SIZE(keyword_table), sizeof(struct wql_keyword), cmp_keyword );
|
||||
if (ret) return ret->type;
|
||||
return TK_ID;
|
||||
}
|
||||
@@ -609,7 +706,7 @@ static int get_token( const WCHAR *s, int *token )
|
||||
case '\t':
|
||||
case '\r':
|
||||
case '\n':
|
||||
for (i = 1; isspaceW( s[i] ); i++) {}
|
||||
for (i = 1; iswspace( s[i] ); i++) {}
|
||||
*token = TK_SPACE;
|
||||
return i;
|
||||
case '-':
|
||||
@@ -622,6 +719,15 @@ static int get_token( const WCHAR *s, int *token )
|
||||
case ')':
|
||||
*token = TK_RP;
|
||||
return 1;
|
||||
case '{':
|
||||
for (i = 1; s[i] && s[i] != '}'; i++) {}
|
||||
if (s[i] != '}')
|
||||
{
|
||||
*token = TK_ILLEGAL;
|
||||
return i;
|
||||
}
|
||||
*token = TK_PATH;
|
||||
return i + 1;
|
||||
case '*':
|
||||
*token = TK_STAR;
|
||||
return 1;
|
||||
@@ -679,7 +785,7 @@ static int get_token( const WCHAR *s, int *token )
|
||||
*token = TK_STRING;
|
||||
return i;
|
||||
case '.':
|
||||
if (!isdigitW( s[1] ))
|
||||
if (!iswdigit( s[1] ))
|
||||
{
|
||||
*token = TK_DOT;
|
||||
return 1;
|
||||
@@ -688,7 +794,7 @@ static int get_token( const WCHAR *s, int *token )
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
*token = TK_INTEGER;
|
||||
for (i = 1; isdigitW( s[i] ); i++) {}
|
||||
for (i = 1; iswdigit( s[i] ); i++) {}
|
||||
return i;
|
||||
default:
|
||||
if (!id_char[*s]) break;
|
||||
|
||||
@@ -196,7 +196,7 @@ dll/win32/vbscript # Synced to WineStaging-4.18
|
||||
dll/win32/version # Synced to WineStaging-4.18
|
||||
dll/win32/vssapi # Synced to WineStaging-4.18
|
||||
dll/win32/wbemdisp # Synced to WineStaging-4.18
|
||||
dll/win32/wbemprox # Synced to WineStaging-4.0
|
||||
dll/win32/wbemprox # Synced to WineStaging-4.18
|
||||
dll/win32/windowscodecs # Synced to WineStaging-4.0
|
||||
dll/win32/windowscodecsext # Synced to WineStaging-2.9
|
||||
dll/win32/winemp3.acm # Synced to WineStaging-3.3
|
||||
|
||||
Reference in New Issue
Block a user