jscript: Use prototype for builtin Date properties.
[wine] / dlls / wbemprox / wbemprox_private.h
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 #include "wine/list.h"
20 #include "wine/unicode.h"
21
22 IClientSecurity client_security;
23 struct list *table_list;
24
25 #define SIZEOF(array) (sizeof(array)/sizeof((array)[0]))
26
27 #define COL_TYPE_MASK    0x0000ffff
28 #define COL_FLAG_DYNAMIC 0x00010000
29 #define COL_FLAG_KEY     0x00020000
30 #define COL_FLAG_METHOD  0x00040000
31
32 typedef HRESULT (class_method)(IWbemClassObject *, IWbemClassObject **);
33
34 struct column
35 {
36     const WCHAR *name;
37     UINT type;
38     VARTYPE vartype; /* 0 for default mapping */
39 };
40
41 #define TABLE_FLAG_DYNAMIC 0x00000001
42
43 struct table
44 {
45     const WCHAR *name;
46     UINT num_cols;
47     const struct column *columns;
48     UINT num_rows;
49     BYTE *data;
50     void (*fill)(struct table *);
51     UINT flags;
52     struct list entry;
53 };
54
55 struct property
56 {
57     const WCHAR *name;
58     const WCHAR *class;
59     const struct property *next;
60 };
61
62 enum operator
63 {
64     OP_EQ      = 1,
65     OP_AND     = 2,
66     OP_OR      = 3,
67     OP_GT      = 4,
68     OP_LT      = 5,
69     OP_LE      = 6,
70     OP_GE      = 7,
71     OP_NE      = 8,
72     OP_ISNULL  = 9,
73     OP_NOTNULL = 10,
74     OP_LIKE    = 11
75 };
76
77 struct expr;
78 struct complex_expr
79 {
80     enum operator op;
81     struct expr *left;
82     struct expr *right;
83 };
84
85 enum expr_type
86 {
87     EXPR_COMPLEX = 1,
88     EXPR_UNARY   = 2,
89     EXPR_PROPVAL = 3,
90     EXPR_SVAL    = 4,
91     EXPR_IVAL    = 5,
92     EXPR_BVAL    = 6
93 };
94
95 struct expr
96 {
97     enum expr_type type;
98     union
99     {
100         struct complex_expr expr;
101         const struct property *propval;
102         const WCHAR *sval;
103         int ival;
104     } u;
105 };
106
107 struct view
108 {
109     const struct property *proplist;
110     struct table *table;
111     const struct expr *cond;
112     UINT *result;
113     UINT  count;
114 };
115
116 struct query
117 {
118     LONG refs;
119     struct view *view;
120     struct list mem;
121 };
122
123 void addref_query( struct query * ) DECLSPEC_HIDDEN;
124 void release_query( struct query *query ) DECLSPEC_HIDDEN;
125 HRESULT exec_query( const WCHAR *, IEnumWbemClassObject ** ) DECLSPEC_HIDDEN;
126 HRESULT parse_query( const WCHAR *, struct view **, struct list * ) DECLSPEC_HIDDEN;
127 HRESULT create_view( const struct property *, const WCHAR *, const struct expr *,
128                      struct view ** ) DECLSPEC_HIDDEN;
129 void destroy_view( struct view * ) DECLSPEC_HIDDEN;
130 void init_table_list( void ) DECLSPEC_HIDDEN;
131 struct table *get_table( const WCHAR * ) DECLSPEC_HIDDEN;
132 struct table *create_table( const WCHAR *, UINT, const struct column *, UINT,
133                             BYTE *, void (*)(struct table *)) DECLSPEC_HIDDEN;
134 BOOL add_table( struct table * ) DECLSPEC_HIDDEN;
135 void free_columns( struct column *, UINT ) DECLSPEC_HIDDEN;
136 void free_table( struct table * ) DECLSPEC_HIDDEN;
137 HRESULT get_column_index( const struct table *, const WCHAR *, UINT * ) DECLSPEC_HIDDEN;
138 HRESULT get_value( const struct table *, UINT, UINT, LONGLONG * ) DECLSPEC_HIDDEN;
139 BSTR get_value_bstr( const struct table *, UINT, UINT ) DECLSPEC_HIDDEN;
140 HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *,
141                      CIMTYPE *, LONG * ) DECLSPEC_HIDDEN;
142 HRESULT get_properties( const struct view *, SAFEARRAY ** ) DECLSPEC_HIDDEN;
143
144 HRESULT WbemLocator_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
145 HRESULT WbemServices_create(IUnknown *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN;
146 HRESULT WbemClassObject_create(IUnknown *, IEnumWbemClassObject *, UINT, LPVOID *) DECLSPEC_HIDDEN;
147 HRESULT EnumWbemClassObject_create(IUnknown *, struct query *, LPVOID *) DECLSPEC_HIDDEN;
148
149 static void *heap_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
150 static inline void *heap_alloc( size_t len )
151 {
152     return HeapAlloc( GetProcessHeap(), 0, len );
153 }
154
155 static void *heap_realloc( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
156 static inline void *heap_realloc( void *mem, size_t len )
157 {
158     return HeapReAlloc( GetProcessHeap(), 0, mem, len );
159 }
160
161 static inline BOOL heap_free( void *mem )
162 {
163     return HeapFree( GetProcessHeap(), 0, mem );
164 }
165
166 static inline WCHAR *heap_strdupW( const WCHAR *src )
167 {
168     WCHAR *dst;
169     if (!src) return NULL;
170     if ((dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) ))) strcpyW( dst, src );
171     return dst;
172 }