ReactOS 0.4.15-dev-8339-g4028de8
update.c
Go to the documentation of this file.
1/*
2 * Implementation of the Microsoft Installer (msi.dll)
3 *
4 * Copyright 2004 Mike McCormack for CodeWeavers
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#include "winnls.h"
33
34#include "query.h"
35
37
38
39/* below is the query interface to a table */
40
41typedef struct tagMSIUPDATEVIEW
42{
48
50{
52
53 TRACE("%p %d %d %p\n", uv, row, col, val );
54
56}
57
59{
61 UINT i, r, col_count = 0, row_count = 0;
63 MSIRECORD *where = NULL;
64 MSIVIEW *wv;
65 UINT cols_count, where_count;
66 column_info *col = uv->vals;
67
68 TRACE("%p %p\n", uv, record );
69
70 /* extract the where markers from the record */
71 if (record)
72 {
74
75 for (i = 0; col; col = col->next)
76 i++;
77
78 cols_count = i;
79 where_count = r - i;
80
81 if (where_count > 0)
82 {
83 where = MSI_CreateRecord(where_count);
84
85 if (where)
86 for (i = 1; i <= where_count; i++)
87 MSI_RecordCopyField(record, cols_count + i, where, i);
88 }
89 }
90
91 wv = uv->wv;
92 if( !wv )
93 {
95 goto done;
96 }
97
98 r = wv->ops->execute( wv, where );
99 TRACE("tv execute returned %x\n", r);
100 if( r )
101 goto done;
102
103 r = wv->ops->get_dimensions( wv, &row_count, &col_count );
104 if( r )
105 goto done;
106
107 values = msi_query_merge_record( col_count, uv->vals, record );
108 if (!values)
109 {
111 goto done;
112 }
113
114 for ( i=0; i<row_count; i++ )
115 {
116 r = msi_select_update( wv, values, i );
117 if (r != ERROR_SUCCESS)
118 break;
119 }
120
121done:
122 if ( where ) msiobj_release( &where->hdr );
123 if ( values ) msiobj_release( &values->hdr );
124
125 return r;
126}
127
128
130{
132 MSIVIEW *wv;
133
134 TRACE("%p\n", uv);
135
136 wv = uv->wv;
137 if( !wv )
139
140 return wv->ops->close( wv );
141}
142
143static UINT UPDATE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
144{
146 MSIVIEW *wv;
147
148 TRACE("%p %p %p\n", uv, rows, cols );
149
150 wv = uv->wv;
151 if( !wv )
153
154 return wv->ops->get_dimensions( wv, rows, cols );
155}
156
158 UINT *type, BOOL *temporary, LPCWSTR *table_name )
159{
161 MSIVIEW *wv;
162
163 TRACE("%p %d %p %p %p %p\n", uv, n, name, type, temporary, table_name );
164
165 wv = uv->wv;
166 if( !wv )
168
169 return wv->ops->get_column_info( wv, n, name, type, temporary, table_name );
170}
171
172static UINT UPDATE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
173 MSIRECORD *rec, UINT row )
174{
176
177 TRACE("%p %d %p\n", uv, eModifyMode, rec );
178
180}
181
183{
185 MSIVIEW *wv;
186
187 TRACE("%p\n", uv );
188
189 wv = uv->wv;
190 if( wv )
191 wv->ops->delete( wv );
192 msiobj_release( &uv->db->hdr );
193 msi_free( uv );
194
195 return ERROR_SUCCESS;
196}
197
198static const MSIVIEWOPS update_ops =
199{
201 NULL,
202 NULL,
203 NULL,
204 NULL,
205 NULL,
206 NULL,
207 NULL,
214 NULL,
215 NULL,
216 NULL,
217 NULL,
218};
219
221 column_info *columns, struct expr *expr )
222{
223 MSIUPDATEVIEW *uv = NULL;
224 UINT r;
225 MSIVIEW *sv = NULL, *wv = NULL;
226
227 TRACE("%p\n", uv );
228
229 if (expr)
230 r = WHERE_CreateView( db, &wv, table, expr );
231 else
232 r = TABLE_CreateView( db, table, &wv );
233
234 if( r != ERROR_SUCCESS )
235 return r;
236
237 /* then select the columns we want */
238 r = SELECT_CreateView( db, &sv, wv, columns );
239 if( r != ERROR_SUCCESS )
240 {
241 wv->ops->delete( wv );
242 return r;
243 }
244
245 uv = msi_alloc_zero( sizeof *uv );
246 if( !uv )
247 {
248 wv->ops->delete( wv );
250 }
251
252 /* fill the structure */
253 uv->view.ops = &update_ops;
254 msiobj_addref( &db->hdr );
255 uv->db = db;
256 uv->vals = columns;
257 uv->wv = sv;
258 *view = (MSIVIEW*) uv;
259
260 return ERROR_SUCCESS;
261}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
void msiobj_addref(MSIOBJECTHDR *info)
Definition: handle.c:217
int msiobj_release(MSIOBJECTHDR *info)
Definition: handle.c:241
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
GLuint GLfloat * val
Definition: glext.h:7180
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
MSIRECORD * msi_query_merge_record(UINT fields, const column_info *vl, MSIRECORD *rec)
Definition: insert.c:66
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1148
static void msi_free(void *mem)
Definition: msipriv.h:1159
UINT MSI_RecordGetFieldCount(const MSIRECORD *rec) DECLSPEC_HIDDEN
Definition: record.c:108
MSIRECORD * MSI_CreateRecord(UINT) DECLSPEC_HIDDEN
Definition: record.c:76
UINT MSI_RecordCopyField(MSIRECORD *, UINT, MSIRECORD *, UINT) DECLSPEC_HIDDEN
Definition: record.c:166
unsigned int UINT
Definition: ndis.h:50
UINT TABLE_CreateView(MSIDATABASE *db, LPCWSTR name, MSIVIEW **view) DECLSPEC_HIDDEN
Definition: table.c:2189
UINT msi_select_update(MSIVIEW *view, MSIRECORD *rec, UINT row) DECLSPEC_HIDDEN
Definition: select.c:249
UINT WHERE_CreateView(MSIDATABASE *db, MSIVIEW **view, LPWSTR tables, struct expr *cond) DECLSPEC_HIDDEN
Definition: where.c:1226
UINT SELECT_CreateView(MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, const column_info *columns) DECLSPEC_HIDDEN
Definition: select.c:423
#define TRACE(s)
Definition: solgame.cpp:4
struct _column_info * next
Definition: msipriv.h:226
Definition: query.h:87
Definition: name.c:39
MSIOBJECTHDR hdr
Definition: msipriv.h:108
MSIOBJECTHDR hdr
Definition: msipriv.h:151
MSIDATABASE * db
Definition: update.c:44
MSIVIEW view
Definition: update.c:43
column_info * vals
Definition: update.c:46
MSIVIEW * wv
Definition: update.c:45
UINT(* close)(struct tagMSIVIEW *view)
Definition: msipriv.h:298
UINT(* get_dimensions)(struct tagMSIVIEW *view, UINT *rows, UINT *cols)
Definition: msipriv.h:306
UINT(* execute)(struct tagMSIVIEW *view, MSIRECORD *record)
Definition: msipriv.h:293
UINT(* get_column_info)(struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
Definition: msipriv.h:313
UINT(* delete)(struct tagMSIVIEW *)
Definition: msipriv.h:324
const MSIVIEWOPS * ops
Definition: msipriv.h:355
UINT UPDATE_CreateView(MSIDATABASE *db, MSIVIEW **view, LPWSTR table, column_info *columns, struct expr *expr)
Definition: update.c:220
static UINT UPDATE_execute(struct tagMSIVIEW *view, MSIRECORD *record)
Definition: update.c:58
static const MSIVIEWOPS update_ops
Definition: update.c:198
static UINT UPDATE_get_column_info(struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
Definition: update.c:157
static UINT UPDATE_close(struct tagMSIVIEW *view)
Definition: update.c:129
static UINT UPDATE_get_dimensions(struct tagMSIVIEW *view, UINT *rows, UINT *cols)
Definition: update.c:143
static UINT UPDATE_delete(struct tagMSIVIEW *view)
Definition: update.c:182
static UINT UPDATE_modify(struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *rec, UINT row)
Definition: update.c:172
struct tagMSIUPDATEVIEW MSIUPDATEVIEW
static UINT UPDATE_fetch_int(struct tagMSIVIEW *view, UINT row, UINT col, UINT *val)
Definition: update.c:49
int MSIMODIFY
Definition: winemsi.idl:33
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185