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/list.h"
20 #include "wine/unicode.h"
22 IClientSecurity client_security;
23 struct list *table_list;
25 #define SIZEOF(array) (sizeof(array)/sizeof((array)[0]))
34 #define COL_TYPE_MASK 0x0000ffff
35 #define COL_FLAG_DYNAMIC 0x00010000
36 #define COL_FLAG_KEY 0x00020000
37 #define COL_FLAG_METHOD 0x00040000
39 typedef HRESULT (class_method)(IWbemClassObject *, IWbemClassObject **);
45 VARTYPE vartype; /* 0 for default mapping */
48 #define TABLE_FLAG_DYNAMIC 0x00000001
54 const struct column *columns;
57 void (*fill)(struct table *);
66 const struct property *next;
107 struct complex_expr expr;
108 const struct property *propval;
116 const struct property *proplist;
118 const struct expr *cond;
130 void addref_query( struct query * ) DECLSPEC_HIDDEN;
131 void release_query( struct query *query ) DECLSPEC_HIDDEN;
132 HRESULT exec_query( const WCHAR *, IEnumWbemClassObject ** ) DECLSPEC_HIDDEN;
133 HRESULT parse_query( const WCHAR *, struct view **, struct list * ) DECLSPEC_HIDDEN;
134 HRESULT create_view( const struct property *, const WCHAR *, const struct expr *,
135 struct view ** ) DECLSPEC_HIDDEN;
136 void destroy_view( struct view * ) DECLSPEC_HIDDEN;
137 void init_table_list( void ) DECLSPEC_HIDDEN;
138 struct table *get_table( const WCHAR * ) DECLSPEC_HIDDEN;
139 struct table *create_table( const WCHAR *, UINT, const struct column *, UINT,
140 BYTE *, void (*)(struct table *)) DECLSPEC_HIDDEN;
141 BOOL add_table( struct table * ) DECLSPEC_HIDDEN;
142 void free_columns( struct column *, UINT ) DECLSPEC_HIDDEN;
143 void free_table( struct table * ) DECLSPEC_HIDDEN;
144 UINT get_type_size( CIMTYPE ) DECLSPEC_HIDDEN;
145 HRESULT get_column_index( const struct table *, const WCHAR *, UINT * ) DECLSPEC_HIDDEN;
146 HRESULT get_value( const struct table *, UINT, UINT, LONGLONG * ) DECLSPEC_HIDDEN;
147 BSTR get_value_bstr( const struct table *, UINT, UINT ) DECLSPEC_HIDDEN;
148 HRESULT set_value( const struct table *, UINT, UINT, LONGLONG, CIMTYPE ) DECLSPEC_HIDDEN;
149 HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *,
150 CIMTYPE *, LONG * ) DECLSPEC_HIDDEN;
151 HRESULT put_propval( const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE ) DECLSPEC_HIDDEN;
152 HRESULT get_properties( const struct view *, SAFEARRAY ** ) DECLSPEC_HIDDEN;
153 HRESULT get_object( const WCHAR *, IWbemClassObject ** ) DECLSPEC_HIDDEN;
154 const WCHAR *get_method_name( const WCHAR *, UINT ) DECLSPEC_HIDDEN;
155 const WCHAR *get_property_name( const WCHAR *, UINT ) DECLSPEC_HIDDEN;
157 HRESULT WbemLocator_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
158 HRESULT WbemServices_create(IUnknown *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN;
159 HRESULT create_class_object(const WCHAR *, IEnumWbemClassObject *, UINT,
160 IWbemClassObject **) DECLSPEC_HIDDEN;
161 HRESULT EnumWbemClassObject_create(IUnknown *, struct query *, LPVOID *) DECLSPEC_HIDDEN;
163 static void *heap_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
164 static inline void *heap_alloc( size_t len )
166 return HeapAlloc( GetProcessHeap(), 0, len );
169 static void *heap_realloc( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
170 static inline void *heap_realloc( void *mem, size_t len )
172 return HeapReAlloc( GetProcessHeap(), 0, mem, len );
175 static void *heap_alloc_zero( size_t len ) __WINE_ALLOC_SIZE(1);
176 static inline void *heap_alloc_zero( size_t len )
178 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
181 static inline BOOL heap_free( void *mem )
183 return HeapFree( GetProcessHeap(), 0, mem );
186 static inline WCHAR *heap_strdupW( const WCHAR *src )
189 if (!src) return NULL;
190 if ((dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) ))) strcpyW( dst, src );