ntdll: Added parsing of public key token in manifests.
[wine] / dlls / msi / alter.c
1 /*
2  * Implementation of the Microsoft Installer (msi.dll)
3  *
4  * Copyright 2006 Mike McCormack
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdarg.h>
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "wine/debug.h"
27 #include "msi.h"
28 #include "msiquery.h"
29 #include "objbase.h"
30 #include "objidl.h"
31 #include "msipriv.h"
32
33 #include "query.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(msidb);
36
37 typedef struct tagMSIALTERVIEW
38 {
39     MSIVIEW        view;
40     MSIDATABASE   *db;
41     MSIVIEW       *table;
42     INT hold;
43 } MSIALTERVIEW;
44
45 static UINT ALTER_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
46 {
47     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
48
49     TRACE("%p %d %d %p\n", av, row, col, val );
50
51     return ERROR_FUNCTION_FAILED;
52 }
53
54 static UINT ALTER_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm)
55 {
56     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
57
58     TRACE("%p %d %d %p\n", av, row, col, stm );
59
60     return ERROR_FUNCTION_FAILED;
61 }
62
63 static UINT ALTER_execute( struct tagMSIVIEW *view, MSIRECORD *record )
64 {
65     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
66
67     TRACE("%p %p\n", av, record);
68
69     if (av->hold == 1)
70         av->table->ops->add_ref(av->table);
71     else if (av->hold == -1)
72         av->table->ops->release(av->table);
73
74     return ERROR_SUCCESS;
75 }
76
77 static UINT ALTER_close( struct tagMSIVIEW *view )
78 {
79     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
80
81     TRACE("%p\n", av );
82
83     return ERROR_SUCCESS;
84 }
85
86 static UINT ALTER_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
87 {
88     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
89
90     TRACE("%p %p %p\n", av, rows, cols );
91
92     return ERROR_FUNCTION_FAILED;
93 }
94
95 static UINT ALTER_get_column_info( struct tagMSIVIEW *view,
96                 UINT n, LPWSTR *name, UINT *type )
97 {
98     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
99
100     TRACE("%p %d %p %p\n", av, n, name, type );
101
102     return ERROR_FUNCTION_FAILED;
103 }
104
105 static UINT ALTER_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
106                 MSIRECORD *rec )
107 {
108     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
109
110     TRACE("%p %d %p\n", av, eModifyMode, rec );
111
112     return ERROR_FUNCTION_FAILED;
113 }
114
115 static UINT ALTER_delete( struct tagMSIVIEW *view )
116 {
117     MSIALTERVIEW *av = (MSIALTERVIEW*)view;
118
119     TRACE("%p\n", av );
120     msi_free( av );
121     av->table->ops->delete( av->table );
122
123     return ERROR_SUCCESS;
124 }
125
126 static UINT ALTER_find_matching_rows( struct tagMSIVIEW *view, UINT col,
127     UINT val, UINT *row, MSIITERHANDLE *handle )
128 {
129     TRACE("%p, %d, %u, %p\n", view, col, val, *handle);
130
131     return ERROR_FUNCTION_FAILED;
132 }
133
134 static const MSIVIEWOPS alter_ops =
135 {
136     ALTER_fetch_int,
137     ALTER_fetch_stream,
138     NULL,
139     NULL,
140     NULL,
141     ALTER_execute,
142     ALTER_close,
143     ALTER_get_dimensions,
144     ALTER_get_column_info,
145     ALTER_modify,
146     ALTER_delete,
147     ALTER_find_matching_rows,
148     NULL,
149     NULL,
150 };
151
152 UINT ALTER_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR name, int hold )
153 {
154     MSIALTERVIEW *av;
155     UINT r;
156
157     TRACE("%p %s %d\n", view, debugstr_w(name), hold );
158
159     av = msi_alloc_zero( sizeof *av );
160     if( !av )
161         return ERROR_FUNCTION_FAILED;
162
163     r = TABLE_CreateView( db, name, &av->table );
164     if (r != ERROR_SUCCESS || !av->table)
165         return r;
166
167     /* fill the structure */
168     av->view.ops = &alter_ops;
169     av->db = db;
170     av->hold = hold;
171
172     *view = &av->view;
173
174     return ERROR_SUCCESS;
175 }