2009-07-14 12:26:38 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Hans Leidekker for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2012-06-15 15:46:51 +02:00
|
|
|
#include "wine/list.h"
|
2012-06-15 15:47:28 +02:00
|
|
|
#include "wine/unicode.h"
|
2012-06-15 15:46:51 +02:00
|
|
|
|
|
|
|
#define SIZEOF(array) (sizeof(array)/sizeof((array)[0]))
|
|
|
|
|
2012-06-15 15:47:28 +02:00
|
|
|
struct column
|
|
|
|
{
|
|
|
|
const WCHAR *name;
|
|
|
|
CIMTYPE_ENUMERATION type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct table
|
|
|
|
{
|
|
|
|
const WCHAR *name;
|
|
|
|
UINT num_cols;
|
|
|
|
const struct column *columns;
|
|
|
|
UINT num_rows;
|
|
|
|
BYTE *data;
|
2012-06-18 09:32:02 +02:00
|
|
|
void (*fill)(struct table *);
|
2012-06-15 15:47:28 +02:00
|
|
|
};
|
|
|
|
|
2012-06-15 15:46:51 +02:00
|
|
|
struct property
|
|
|
|
{
|
|
|
|
const WCHAR *name;
|
|
|
|
const WCHAR *class;
|
|
|
|
const struct property *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum operator
|
|
|
|
{
|
|
|
|
OP_EQ = 1,
|
|
|
|
OP_AND = 2,
|
|
|
|
OP_OR = 3,
|
|
|
|
OP_GT = 4,
|
|
|
|
OP_LT = 5,
|
|
|
|
OP_LE = 6,
|
|
|
|
OP_GE = 7,
|
|
|
|
OP_NE = 8,
|
|
|
|
OP_ISNULL = 9,
|
|
|
|
OP_NOTNULL = 10,
|
|
|
|
OP_LIKE = 11
|
|
|
|
};
|
|
|
|
|
|
|
|
struct expr;
|
|
|
|
struct complex_expr
|
|
|
|
{
|
|
|
|
enum operator op;
|
|
|
|
struct expr *left;
|
|
|
|
struct expr *right;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum expr_type
|
|
|
|
{
|
|
|
|
EXPR_COMPLEX = 1,
|
|
|
|
EXPR_UNARY = 2,
|
|
|
|
EXPR_PROPVAL = 3,
|
|
|
|
EXPR_SVAL = 4,
|
|
|
|
EXPR_IVAL = 5,
|
|
|
|
EXPR_BVAL = 6
|
|
|
|
};
|
|
|
|
|
|
|
|
struct expr
|
|
|
|
{
|
|
|
|
enum expr_type type;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct complex_expr expr;
|
|
|
|
const struct property *propval;
|
|
|
|
const WCHAR *sval;
|
|
|
|
int ival;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct view
|
|
|
|
{
|
|
|
|
const struct property *proplist;
|
2012-06-15 15:47:28 +02:00
|
|
|
struct table *table;
|
2012-06-15 15:46:51 +02:00
|
|
|
const struct expr *cond;
|
2012-06-15 15:47:54 +02:00
|
|
|
UINT *result;
|
|
|
|
UINT count;
|
2012-06-15 15:48:32 +02:00
|
|
|
UINT index;
|
2012-06-15 15:46:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct query
|
|
|
|
{
|
|
|
|
struct view *view;
|
|
|
|
struct list mem;
|
|
|
|
};
|
|
|
|
|
|
|
|
void free_query( struct 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;
|
|
|
|
void destroy_view( struct view * ) DECLSPEC_HIDDEN;
|
2012-06-15 15:47:28 +02:00
|
|
|
struct table *get_table( const WCHAR * ) DECLSPEC_HIDDEN;
|
2012-06-18 09:31:29 +02:00
|
|
|
HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *,
|
|
|
|
CIMTYPE * ) DECLSPEC_HIDDEN;
|
2012-06-19 10:19:38 +02:00
|
|
|
HRESULT get_properties( const struct view *, SAFEARRAY ** ) DECLSPEC_HIDDEN;
|
2012-06-15 15:46:51 +02:00
|
|
|
|
2011-05-13 18:24:41 +02:00
|
|
|
HRESULT WbemLocator_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
|
2012-06-14 16:02:38 +02:00
|
|
|
HRESULT WbemServices_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
|
2012-06-15 15:48:32 +02:00
|
|
|
HRESULT WbemClassObject_create(IUnknown *, IEnumWbemClassObject *, UINT, LPVOID *) DECLSPEC_HIDDEN;
|
2012-06-15 15:46:51 +02:00
|
|
|
HRESULT EnumWbemClassObject_create(IUnknown *, struct query *, LPVOID *) DECLSPEC_HIDDEN;
|
2012-06-14 16:03:26 +02:00
|
|
|
|
|
|
|
static void *heap_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
|
|
|
|
static inline void *heap_alloc( size_t len )
|
|
|
|
{
|
|
|
|
return HeapAlloc( GetProcessHeap(), 0, len );
|
|
|
|
}
|
|
|
|
|
2012-06-15 15:47:54 +02:00
|
|
|
static void *heap_realloc( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
|
|
|
|
static inline void *heap_realloc( void *mem, size_t len )
|
|
|
|
{
|
|
|
|
return HeapReAlloc( GetProcessHeap(), 0, mem, len );
|
|
|
|
}
|
|
|
|
|
2012-06-14 16:03:26 +02:00
|
|
|
static inline BOOL heap_free( void *mem )
|
|
|
|
{
|
|
|
|
return HeapFree( GetProcessHeap(), 0, mem );
|
|
|
|
}
|
2012-06-18 09:32:02 +02:00
|
|
|
|
|
|
|
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 );
|
|
|
|
return dst;
|
|
|
|
}
|