2 * Copyright 2012 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
28 #include "wine/debug.h"
29 #include "wbemprox_private.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
33 HRESULT create_view( const struct property *proplist, const WCHAR *class,
34 const struct expr *cond, struct view **ret )
36 struct view *view = heap_alloc( sizeof(struct view) );
38 if (!view) return E_OUTOFMEMORY;
39 view->proplist = proplist;
45 void destroy_view( struct view *view )
50 static struct query *alloc_query(void)
54 if (!(query = heap_alloc( sizeof(*query) ))) return NULL;
55 list_init( &query->mem );
59 void free_query( struct query *query )
61 struct list *mem, *next;
63 destroy_view( query->view );
64 LIST_FOR_EACH_SAFE( mem, next, &query->mem )
71 HRESULT exec_query( const WCHAR *str, IEnumWbemClassObject **result )
77 if (!(query = alloc_query())) return E_OUTOFMEMORY;
78 hr = parse_query( str, &query->view, &query->mem );
84 hr = EnumWbemClassObject_create( NULL, query, (void **)result );
85 if (hr != S_OK) free_query( query );