ReactOS  0.4.14-dev-52-g6116262
wbemprox_private.h
Go to the documentation of this file.
1 /*
2  * Copyright 2009 Hans Leidekker for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #pragma once
20 
21 #include "wine/debug.h"
22 #include "wine/heap.h"
23 #include "wine/list.h"
24 #include "wine/unicode.h"
25 
27 struct list *table_list DECLSPEC_HIDDEN;
28 
30 {
31  PARAM_OUT = -1,
34 };
35 
36 #define CIM_TYPE_MASK 0x00000fff
37 
38 #define COL_TYPE_MASK 0x0000ffff
39 #define COL_FLAG_DYNAMIC 0x00010000
40 #define COL_FLAG_KEY 0x00020000
41 #define COL_FLAG_METHOD 0x00040000
42 
44 
45 enum operator
46 {
47  OP_EQ = 1,
48  OP_AND = 2,
49  OP_OR = 3,
50  OP_GT = 4,
51  OP_LT = 5,
52  OP_LE = 6,
53  OP_GE = 7,
54  OP_NE = 8,
55  OP_ISNULL = 9,
56  OP_NOTNULL = 10,
57  OP_LIKE = 11,
58  OP_NOT = 12
59 };
60 
61 struct expr;
62 struct complex_expr
63 {
64  enum operator op;
65  struct expr *left;
66  struct expr *right;
67 };
68 
70 {
74  EXPR_SVAL = 4,
75  EXPR_IVAL = 5,
77 };
78 
79 struct expr
80 {
82  union
83  {
84  struct complex_expr expr;
85  const struct property *propval;
86  const WCHAR *sval;
87  int ival;
88  } u;
89 };
90 
91 struct column
92 {
93  const WCHAR *name;
95  VARTYPE vartype; /* 0 for default mapping */
96 };
97 
99 {
103 };
104 
105 #define TABLE_FLAG_DYNAMIC 0x00000001
106 
107 struct table
108 {
109  const WCHAR *name;
111  const struct column *columns;
115  enum fill_status (*fill)(struct table *, const struct expr *cond);
117  struct list entry;
119 };
120 
121 struct property
122 {
123  const WCHAR *name;
124  const WCHAR *class;
125  const struct property *next;
126 };
127 
128 struct array
129 {
131  void *ptr;
132 };
133 
134 struct field
135 {
137  VARTYPE vartype; /* 0 for default mapping */
138  union
139  {
142  struct array *aval;
143  } u;
144 };
145 
146 struct record
147 {
149  struct field *fields;
150  struct table *table;
151 };
152 
153 struct view
154 {
155  const struct property *proplist;
156  struct table *table;
157  const struct expr *cond;
160 };
161 
162 struct query
163 {
165  struct view *view;
166  struct list mem;
167 };
168 
169 struct query *create_query(void) DECLSPEC_HIDDEN;
170 void free_query( struct query * ) DECLSPEC_HIDDEN;
171 struct query *addref_query( struct query * ) DECLSPEC_HIDDEN;
172 void release_query( struct query *query ) DECLSPEC_HIDDEN;
174 HRESULT parse_query( const WCHAR *, struct view **, struct list * ) DECLSPEC_HIDDEN;
175 HRESULT create_view( const struct property *, const WCHAR *, const struct expr *,
176  struct view ** ) DECLSPEC_HIDDEN;
177 void destroy_view( struct view * ) DECLSPEC_HIDDEN;
179 void init_table_list( void ) DECLSPEC_HIDDEN;
180 struct table *grab_table( const WCHAR * ) DECLSPEC_HIDDEN;
181 struct table *addref_table( struct table * ) DECLSPEC_HIDDEN;
182 void release_table( struct table * ) DECLSPEC_HIDDEN;
183 struct table *create_table( const WCHAR *, UINT, const struct column *, UINT, UINT, BYTE *,
184  enum fill_status (*)(struct table *, const struct expr *) ) DECLSPEC_HIDDEN;
185 BOOL add_table( struct table * ) DECLSPEC_HIDDEN;
186 void free_columns( struct column *, UINT ) DECLSPEC_HIDDEN;
187 void free_row_values( const struct table *, UINT ) DECLSPEC_HIDDEN;
188 void clear_table( struct table * ) DECLSPEC_HIDDEN;
189 void free_table( struct table * ) DECLSPEC_HIDDEN;
191 HRESULT eval_cond( const struct table *, UINT, const struct expr *, LONGLONG *, UINT * ) DECLSPEC_HIDDEN;
192 HRESULT get_column_index( const struct table *, const WCHAR *, UINT * ) DECLSPEC_HIDDEN;
193 HRESULT get_value( const struct table *, UINT, UINT, LONGLONG * ) DECLSPEC_HIDDEN;
194 BSTR get_value_bstr( const struct table *, UINT, UINT ) DECLSPEC_HIDDEN;
196 BOOL is_method( const struct table *, UINT ) DECLSPEC_HIDDEN;
197 HRESULT get_method( const struct table *, const WCHAR *, class_method ** ) DECLSPEC_HIDDEN;
198 HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *,
200 HRESULT put_propval( const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE ) DECLSPEC_HIDDEN;
204 void destroy_array( struct array *, CIMTYPE ) DECLSPEC_HIDDEN;
205 BOOL is_selected_prop( const struct view *, const WCHAR * ) DECLSPEC_HIDDEN;
210 HRESULT create_signature( const WCHAR *, const WCHAR *, enum param_direction,
212 
219 
231 
232 static inline WCHAR *heap_strdupW( const WCHAR *src )
233 {
234  WCHAR *dst;
235  if (!src) return NULL;
236  if ((dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) ))) strcpyW( dst, src );
237  return dst;
238 }
239 
240 static const WCHAR class_processW[] = {'W','i','n','3','2','_','P','r','o','c','e','s','s',0};
241 static const WCHAR class_serviceW[] = {'W','i','n','3','2','_','S','e','r','v','i','c','e',0};
242 static const WCHAR class_stdregprovW[] = {'S','t','d','R','e','g','P','r','o','v',0};
243 static const WCHAR class_systemsecurityW[] = {'_','_','S','y','s','t','e','m','S','e','c','u','r','i','t','y',0};
244 
245 static const WCHAR prop_nameW[] = {'N','a','m','e',0};
246 
247 static const WCHAR method_createkeyW[] = {'C','r','e','a','t','e','K','e','y',0};
248 static const WCHAR method_enumkeyW[] = {'E','n','u','m','K','e','y',0};
249 static const WCHAR method_enumvaluesW[] = {'E','n','u','m','V','a','l','u','e','s',0};
250 static const WCHAR method_getownerW[] = {'G','e','t','O','w','n','e','r',0};
251 static const WCHAR method_getsdW[] = {'G','e','t','S','D',0};
252 static const WCHAR method_getstringvalueW[] = {'G','e','t','S','t','r','i','n','g','V','a','l','u','e',0};
253 static const WCHAR method_pauseserviceW[] = {'P','a','u','s','e','S','e','r','v','i','c','e',0};
254 static const WCHAR method_resumeserviceW[] = {'R','e','s','u','m','e','S','e','r','v','i','c','e',0};
255 static const WCHAR method_setsdW[] = {'S','e','t','S','D',0};
256 static const WCHAR method_startserviceW[] = {'S','t','a','r','t','S','e','r','v','i','c','e',0};
257 static const WCHAR method_stopserviceW[] = {'S','t','o','p','S','e','r','v','i','c','e',0};
258 
259 static const WCHAR param_defkeyW[] = {'h','D','e','f','K','e','y',0};
260 static const WCHAR param_domainW[] = {'D','o','m','a','i','n',0};
261 static const WCHAR param_namesW[] = {'s','N','a','m','e','s',0};
262 static const WCHAR param_returnvalueW[] = {'R','e','t','u','r','n','V','a','l','u','e',0};
263 static const WCHAR param_sdW[] = {'S','D',0};
264 static const WCHAR param_subkeynameW[] = {'s','S','u','b','K','e','y','N','a','m','e',0};
265 static const WCHAR param_typesW[] = {'T','y','p','e','s',0};
266 static const WCHAR param_userW[] = {'U','s','e','r',0};
267 static const WCHAR param_valueW[] = {'s','V','a','l','u','e',0};
268 static const WCHAR param_valuenameW[] = {'s','V','a','l','u','e','N','a','m','e',0};
HRESULT set_value(const struct table *, UINT, UINT, LONGLONG, CIMTYPE) DECLSPEC_HIDDEN
Definition: table.c:209
UINT num_cols
#define HRESULT
Definition: msvc.h:9
struct query * addref_query(struct query *) DECLSPEC_HIDDEN
Definition: query.c:460
BSTR get_value_bstr(const struct table *, UINT, UINT) DECLSPEC_HIDDEN
Definition: table.c:149
void destroy_array(struct array *, CIMTYPE) DECLSPEC_HIDDEN
Definition: class.c:237
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
BOOL is_selected_prop(const struct view *, const WCHAR *) DECLSPEC_HIDDEN
Definition: query.c:489
static const WCHAR method_getsdW[]
const WCHAR * name
HRESULT reg_get_stringvalue(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: reg.c:392
HRESULT process_get_owner(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: process.c:66
union field::@560 u
void release_query(struct query *query) DECLSPEC_HIDDEN
Definition: query.c:466
void set_variant(VARTYPE, LONGLONG, void *, VARIANT *) DECLSPEC_HIDDEN
Definition: query.c:797
HRESULT execute_view(struct view *) DECLSPEC_HIDDEN
Definition: query.c:405
void release_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:343
UINT num_rows
static const WCHAR method_enumvaluesW[]
static const WCHAR class_systemsecurityW[]
HRESULT put_propval(const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE) DECLSPEC_HIDDEN
Definition: query.c:1046
HRESULT get_object(const WCHAR *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: services.c:448
VARTYPE vartype
static const WCHAR method_pauseserviceW[]
const struct column * columns
HRESULT to_longlong(VARIANT *, LONGLONG *, CIMTYPE *) DECLSPEC_HIDDEN
Definition: query.c:996
static const WCHAR method_resumeserviceW[]
struct table * addref_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:348
void free_columns(struct column *, UINT) DECLSPEC_HIDDEN
Definition: table.c:319
HRESULT get_column_index(const struct table *, const WCHAR *, UINT *) DECLSPEC_HIDDEN
Definition: table.c:33
SAFEARRAY * to_safearray(const struct array *, CIMTYPE) DECLSPEC_HIDDEN
Definition: query.c:765
struct field * fields
const WCHAR * sval
expr_type
void destroy_view(struct view *) DECLSPEC_HIDDEN
Definition: query.c:48
OLECHAR * BSTR
Definition: compat.h:1934
HRESULT WbemLocator_create(LPVOID *) DECLSPEC_HIDDEN
Definition: wbemlocator.c:215
IClientSecurity client_security DECLSPEC_HIDDEN
Definition: query.h:86
static const WCHAR param_subkeynameW[]
struct array * aval
UINT count
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const struct expr * cond
static const WCHAR method_enumkeyW[]
HRESULT WbemServices_create(const WCHAR *, LPVOID *) DECLSPEC_HIDDEN
Definition: services.c:913
enum fill_status(* fill)(struct table *, const struct expr *cond)
WCHAR * sval
HRESULT get_value(const struct table *, UINT, UINT, LONGLONG *) DECLSPEC_HIDDEN
Definition: table.c:94
HRESULT get_method(const struct table *, const WCHAR *, class_method **) DECLSPEC_HIDDEN
Definition: table.c:258
struct table * table
HRESULT security_get_sd(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: security.c:133
static const WCHAR param_typesW[]
const WCHAR * name
unsigned int BOOL
Definition: ntddk_ex.h:94
int type
Definition: query.h:88
long LONG
Definition: pedump.c:60
const struct property * next
struct list entry
static const WCHAR param_namesW[]
HRESULT service_stop_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: service.c:239
HRESULT parse_query(const WCHAR *, struct view **, struct list *) DECLSPEC_HIDDEN
Definition: wql.tab.c:2086
UINT * result
HRESULT reg_enum_values(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: reg.c:309
smooth NULL
Definition: ftsmooth.c:416
BSTR get_method_name(const WCHAR *, UINT) DECLSPEC_HIDDEN
Definition: table.c:406
static const WCHAR class_stdregprovW[]
static const WCHAR method_setsdW[]
struct table * table
HRESULT create_signature(const WCHAR *, const WCHAR *, enum param_direction, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: class.c:818
void free_row_values(const struct table *, UINT) DECLSPEC_HIDDEN
Definition: table.c:281
HRESULT security_set_sd(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: security.c:188
HRESULT exec_query(const WCHAR *, IEnumWbemClassObject **) DECLSPEC_HIDDEN
Definition: query.c:471
const struct property * proplist
int64_t LONGLONG
Definition: typedefs.h:66
static const WCHAR prop_nameW[]
static const WCHAR param_valuenameW[]
__wchar_t WCHAR
Definition: xmlstorage.h:180
HRESULT service_start_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: service.c:194
Definition: parser.c:43
LONG HRESULT
Definition: typedefs.h:77
UINT num_rows_allocated
struct expr * right
Definition: query.h:68
HRESULT service_pause_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: service.c:80
UINT get_type_size(CIMTYPE) DECLSPEC_HIDDEN
Definition: table.c:47
static const WCHAR class_serviceW[]
HRESULT get_propval(const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE *, LONG *) DECLSPEC_HIDDEN
Definition: query.c:840
static const WCHAR method_startserviceW[]
void free_query(struct query *) DECLSPEC_HIDDEN
Definition: query.c:450
HRESULT eval_cond(const struct table *, UINT, const struct expr *, LONGLONG *, UINT *) DECLSPEC_HIDDEN
Definition: query.c:364
void free_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:327
struct table * create_table(const WCHAR *, UINT, const struct column *, UINT, UINT, BYTE *, enum fill_status(*)(struct table *, const struct expr *)) DECLSPEC_HIDDEN
HRESULT create_view(const struct property *, const WCHAR *, const struct expr *, struct view **) DECLSPEC_HIDDEN
Definition: query.c:33
VARTYPE vartype
HRESULT reg_enum_key(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: reg.c:199
HRESULT get_properties(const struct view *, LONG, SAFEARRAY **) DECLSPEC_HIDDEN
Definition: query.c:1067
UINT op
Definition: query.h:66
static WCHAR * heap_strdupW(const WCHAR *src)
static const WCHAR method_getownerW[]
HRESULT create_class_object(const WCHAR *, IEnumWbemClassObject *, UINT, struct record *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: class.c:1020
static const WCHAR method_getstringvalueW[]
static const WCHAR param_userW[]
static const WCHAR param_defkeyW[]
unsigned char BYTE
Definition: mem.h:68
Definition: _list.h:228
long CIMTYPE
Definition: wbemcli.idl:258
HRESULT EnumWbemClassObject_create(struct query *, LPVOID *) DECLSPEC_HIDDEN
Definition: class.c:195
GLenum src
Definition: glext.h:6340
BOOL add_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:389
param_direction
static const WCHAR class_processW[]
HRESULT() class_method(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **)
static const WCHAR method_stopserviceW[]
static const WCHAR param_domainW[]
void clear_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:303
static const WCHAR param_sdW[]
fill_status
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
void * ptr
const WCHAR * name
BYTE * data
struct table * grab_table(const WCHAR *) DECLSPEC_HIDDEN
Definition: table.c:354
HRESULT WbemQualifierSet_create(const WCHAR *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN
Definition: qualifier.c:250
GLenum GLenum dst
Definition: glext.h:6340
unsigned short VARTYPE
Definition: compat.h:1895
struct view * view
const struct property * propval
unsigned int UINT
Definition: ndis.h:50
static const WCHAR param_valueW[]
HRESULT service_resume_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: service.c:125
void init_table_list(void) DECLSPEC_HIDDEN
Definition: builtin.c:3601
static const WCHAR method_createkeyW[]
Definition: mem.c:156
static const WCHAR param_returnvalueW[]
HRESULT reg_create_key(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: reg.c:100
union expr::@485 u
VARTYPE to_vartype(CIMTYPE) DECLSPEC_HIDDEN
Definition: query.c:743
LONGLONG ival
struct query * create_query(void) DECLSPEC_HIDDEN
Definition: query.c:440
BOOL is_method(const struct table *, UINT) DECLSPEC_HIDDEN
Definition: query.c:628
struct expr * left
Definition: query.h:67