wbemprox: Rewrite IWbemServices::ExecMethod with low-level functions so we can reuse...
[wine/multimedia.git] / dlls / wbemprox / wbemprox_private.h
blobe11cdff429d3b2d1102ff4fcb58fd2c34aabbb14
1 /*
2 * Copyright 2009 Hans Leidekker for CodeWeavers
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.
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.
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
19 #include "wine/debug.h"
20 #include "wine/list.h"
21 #include "wine/unicode.h"
23 IClientSecurity client_security;
24 struct list *table_list;
26 #define SIZEOF(array) (sizeof(array)/sizeof((array)[0]))
28 enum param_direction
30 PARAM_OUT = -1,
31 PARAM_INOUT = 0,
32 PARAM_IN = 1
35 #define CIM_TYPE_MASK 0x00000fff
37 #define COL_TYPE_MASK 0x0000ffff
38 #define COL_FLAG_DYNAMIC 0x00010000
39 #define COL_FLAG_KEY 0x00020000
40 #define COL_FLAG_METHOD 0x00040000
42 typedef HRESULT (class_method)(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **);
44 enum operator
46 OP_EQ = 1,
47 OP_AND = 2,
48 OP_OR = 3,
49 OP_GT = 4,
50 OP_LT = 5,
51 OP_LE = 6,
52 OP_GE = 7,
53 OP_NE = 8,
54 OP_ISNULL = 9,
55 OP_NOTNULL = 10,
56 OP_LIKE = 11
59 struct expr;
60 struct complex_expr
62 enum operator op;
63 struct expr *left;
64 struct expr *right;
67 enum expr_type
69 EXPR_COMPLEX = 1,
70 EXPR_UNARY = 2,
71 EXPR_PROPVAL = 3,
72 EXPR_SVAL = 4,
73 EXPR_IVAL = 5,
74 EXPR_BVAL = 6
77 struct expr
79 enum expr_type type;
80 union
82 struct complex_expr expr;
83 const struct property *propval;
84 const WCHAR *sval;
85 int ival;
86 } u;
89 struct column
91 const WCHAR *name;
92 UINT type;
93 VARTYPE vartype; /* 0 for default mapping */
96 enum fill_status
98 FILL_STATUS_FAILED = -1,
99 FILL_STATUS_UNFILTERED,
100 FILL_STATUS_FILTERED
103 #define TABLE_FLAG_DYNAMIC 0x00000001
105 struct table
107 const WCHAR *name;
108 UINT num_cols;
109 const struct column *columns;
110 UINT num_rows;
111 BYTE *data;
112 enum fill_status (*fill)(struct table *, const struct expr *cond);
113 UINT flags;
114 struct list entry;
115 LONG refs;
118 struct property
120 const WCHAR *name;
121 const WCHAR *class;
122 const struct property *next;
125 struct array
127 UINT count;
128 void *ptr;
131 struct field
133 UINT type;
134 VARTYPE vartype; /* 0 for default mapping */
135 union
137 LONGLONG ival;
138 WCHAR *sval;
139 struct array *aval;
140 } u;
143 struct record
145 UINT count;
146 struct field *fields;
147 struct table *table;
150 struct view
152 const struct property *proplist;
153 struct table *table;
154 const struct expr *cond;
155 UINT *result;
156 UINT count;
159 struct query
161 LONG refs;
162 struct view *view;
163 struct list mem;
166 struct query *create_query(void) DECLSPEC_HIDDEN;
167 void free_query( struct query * ) DECLSPEC_HIDDEN;
168 struct query *addref_query( struct query * ) DECLSPEC_HIDDEN;
169 void release_query( struct query *query ) DECLSPEC_HIDDEN;
170 HRESULT exec_query( const WCHAR *, IEnumWbemClassObject ** ) DECLSPEC_HIDDEN;
171 HRESULT parse_query( const WCHAR *, struct view **, struct list * ) DECLSPEC_HIDDEN;
172 HRESULT create_view( const struct property *, const WCHAR *, const struct expr *,
173 struct view ** ) DECLSPEC_HIDDEN;
174 void destroy_view( struct view * ) DECLSPEC_HIDDEN;
175 HRESULT execute_view( struct view * ) DECLSPEC_HIDDEN;
176 void init_table_list( void ) DECLSPEC_HIDDEN;
177 struct table *grab_table( const WCHAR * ) DECLSPEC_HIDDEN;
178 struct table *addref_table( struct table * ) DECLSPEC_HIDDEN;
179 void release_table( struct table * ) DECLSPEC_HIDDEN;
180 struct table *create_table( const WCHAR *, UINT, const struct column *, UINT, BYTE *,
181 enum fill_status (*)(struct table *, const struct expr *) ) DECLSPEC_HIDDEN;
182 BOOL add_table( struct table * ) DECLSPEC_HIDDEN;
183 void free_columns( struct column *, UINT ) DECLSPEC_HIDDEN;
184 void free_row_values( const struct table *, UINT ) DECLSPEC_HIDDEN;
185 void clear_table( struct table * ) DECLSPEC_HIDDEN;
186 void free_table( struct table * ) DECLSPEC_HIDDEN;
187 UINT get_type_size( CIMTYPE ) DECLSPEC_HIDDEN;
188 HRESULT eval_cond( const struct table *, UINT, const struct expr *, LONGLONG * ) DECLSPEC_HIDDEN;
189 HRESULT get_column_index( const struct table *, const WCHAR *, UINT * ) DECLSPEC_HIDDEN;
190 HRESULT get_value( const struct table *, UINT, UINT, LONGLONG * ) DECLSPEC_HIDDEN;
191 BSTR get_value_bstr( const struct table *, UINT, UINT ) DECLSPEC_HIDDEN;
192 HRESULT set_value( const struct table *, UINT, UINT, LONGLONG, CIMTYPE ) DECLSPEC_HIDDEN;
193 HRESULT get_method( const struct table *, const WCHAR *, class_method ** ) DECLSPEC_HIDDEN;
194 HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *,
195 CIMTYPE *, LONG * ) DECLSPEC_HIDDEN;
196 HRESULT put_propval( const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE ) DECLSPEC_HIDDEN;
197 HRESULT to_longlong( VARIANT *, LONGLONG *, CIMTYPE * ) DECLSPEC_HIDDEN;
198 SAFEARRAY *to_safearray( const struct array *, CIMTYPE ) DECLSPEC_HIDDEN;
199 VARTYPE to_vartype( CIMTYPE ) DECLSPEC_HIDDEN;
200 void destroy_array( struct array *, CIMTYPE ) DECLSPEC_HIDDEN;
201 HRESULT get_properties( const struct view *, SAFEARRAY ** ) DECLSPEC_HIDDEN;
202 HRESULT get_object( const WCHAR *, IWbemClassObject ** ) DECLSPEC_HIDDEN;
203 BSTR get_method_name( const WCHAR *, UINT ) DECLSPEC_HIDDEN;
204 BSTR get_property_name( const WCHAR *, UINT ) DECLSPEC_HIDDEN;
205 void set_variant( VARTYPE, LONGLONG, void *, VARIANT * ) DECLSPEC_HIDDEN;
206 HRESULT create_signature( const WCHAR *, const WCHAR *, enum param_direction,
207 IWbemClassObject ** ) DECLSPEC_HIDDEN;
209 HRESULT WbemLocator_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
210 HRESULT WbemServices_create(IUnknown *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN;
211 HRESULT create_class_object(const WCHAR *, IEnumWbemClassObject *, UINT,
212 struct record *, IWbemClassObject **) DECLSPEC_HIDDEN;
213 HRESULT EnumWbemClassObject_create(IUnknown *, struct query *, LPVOID *) DECLSPEC_HIDDEN;
214 HRESULT WbemQualifierSet_create(IUnknown *, const WCHAR *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN;
216 HRESULT process_get_owner(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
217 HRESULT reg_enum_key(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
218 HRESULT reg_enum_values(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
219 HRESULT reg_get_stringvalue(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
220 HRESULT service_pause_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
221 HRESULT service_resume_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
222 HRESULT service_start_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
223 HRESULT service_stop_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
225 static void *heap_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
226 static inline void *heap_alloc( size_t len )
228 return HeapAlloc( GetProcessHeap(), 0, len );
231 static void *heap_realloc( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
232 static inline void *heap_realloc( void *mem, size_t len )
234 return HeapReAlloc( GetProcessHeap(), 0, mem, len );
237 static void *heap_alloc_zero( size_t len ) __WINE_ALLOC_SIZE(1);
238 static inline void *heap_alloc_zero( size_t len )
240 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
243 static inline BOOL heap_free( void *mem )
245 return HeapFree( GetProcessHeap(), 0, mem );
248 static inline WCHAR *heap_strdupW( const WCHAR *src )
250 WCHAR *dst;
251 if (!src) return NULL;
252 if ((dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) ))) strcpyW( dst, src );
253 return dst;
256 static inline const char *debugstr_variant( const VARIANT *v )
258 if (!v) return "(null)";
259 switch (V_VT(v))
261 case VT_EMPTY:
262 return "{VT_EMPTY}";
263 case VT_NULL:
264 return "{VT_NULL}";
265 case VT_I4:
266 return wine_dbg_sprintf( "{VT_I4: %d}", V_I4(v) );
267 case VT_R8:
268 return wine_dbg_sprintf( "{VT_R8: %lf}", V_R8(v) );
269 case VT_BSTR:
270 return wine_dbg_sprintf( "{VT_BSTR: %s}", debugstr_w(V_BSTR(v)) );
271 case VT_DISPATCH:
272 return wine_dbg_sprintf( "{VT_DISPATCH: %p}", V_DISPATCH(v) );
273 case VT_BOOL:
274 return wine_dbg_sprintf( "{VT_BOOL: %x}", V_BOOL(v) );
275 case VT_UNKNOWN:
276 return wine_dbg_sprintf( "{VT_UNKNOWN: %p}", V_UNKNOWN(v) );
277 case VT_UINT:
278 return wine_dbg_sprintf( "{VT_UINT: %u}", V_UINT(v) );
279 case VT_BSTR|VT_BYREF:
280 return wine_dbg_sprintf( "{VT_BSTR|VT_BYREF: ptr %p, data %s}",
281 V_BSTRREF(v), V_BSTRREF(v) ? debugstr_w( *V_BSTRREF(v) ) : NULL );
282 default:
283 return wine_dbg_sprintf( "{vt %d}", V_VT(v) );
287 static const WCHAR class_processW[] = {'W','i','n','3','2','_','P','r','o','c','e','s','s',0};
288 static const WCHAR class_serviceW[] = {'W','i','n','3','2','_','S','e','r','v','i','c','e',0};
289 static const WCHAR class_stdregprovW[] = {'S','t','d','R','e','g','P','r','o','v',0};
291 static const WCHAR prop_nameW[] = {'N','a','m','e',0};
293 static const WCHAR method_enumkeyW[] = {'E','n','u','m','K','e','y',0};
294 static const WCHAR method_enumvaluesW[] = {'E','n','u','m','V','a','l','u','e','s',0};
295 static const WCHAR method_getownerW[] = {'G','e','t','O','w','n','e','r',0};
296 static const WCHAR method_getstringvalueW[] = {'G','e','t','S','t','r','i','n','g','V','a','l','u','e',0};
297 static const WCHAR method_pauseserviceW[] = {'P','a','u','s','e','S','e','r','v','i','c','e',0};
298 static const WCHAR method_resumeserviceW[] = {'R','e','s','u','m','e','S','e','r','v','i','c','e',0};
299 static const WCHAR method_startserviceW[] = {'S','t','a','r','t','S','e','r','v','i','c','e',0};
300 static const WCHAR method_stopserviceW[] = {'S','t','o','p','S','e','r','v','i','c','e',0};
302 static const WCHAR param_defkeyW[] = {'h','D','e','f','K','e','y',0};
303 static const WCHAR param_domainW[] = {'D','o','m','a','i','n',0};
304 static const WCHAR param_namesW[] = {'s','N','a','m','e','s',0};
305 static const WCHAR param_returnvalueW[] = {'R','e','t','u','r','n','V','a','l','u','e',0};
306 static const WCHAR param_subkeynameW[] = {'s','S','u','b','K','e','y','N','a','m','e',0};
307 static const WCHAR param_typesW[] = {'T','y','p','e','s',0};
308 static const WCHAR param_userW[] = {'U','s','e','r',0};
309 static const WCHAR param_valueW[] = {'s','V','a','l','u','e',0};
310 static const WCHAR param_valuenameW[] = {'s','V','a','l','u','e','N','a','m','e',0};