2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2004 Mike McCormack for CodeWeavers
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.
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.
16 * You should have receuved a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
39 /* below is the query interface to a table */
41 typedef struct tagMSIUPDATEVIEW
49 static UINT
UPDATE_fetch_int( struct tagMSIVIEW
*view
, UINT row
, UINT col
, UINT
*val
)
51 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
53 TRACE("%p %d %d %p\n", uv
, row
, col
, val
);
55 return ERROR_FUNCTION_FAILED
;
58 static UINT
UPDATE_execute( struct tagMSIVIEW
*view
, MSIRECORD
*record
)
60 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
61 UINT n
, type
, val
, r
, row
, col_count
= 0, row_count
= 0;
64 TRACE("%p %p\n", uv
, record
);
67 return ERROR_FUNCTION_FAILED
;
71 return ERROR_FUNCTION_FAILED
;
73 r
= wv
->ops
->execute( wv
, 0 );
74 TRACE("tv execute returned %x\n", r
);
78 r
= wv
->ops
->get_dimensions( wv
, &row_count
, &col_count
);
82 for( row
= 0; row
< row_count
; row
++ )
84 for( n
= 1; n
<= col_count
; n
++ )
86 r
= wv
->ops
->get_column_info( wv
, n
, NULL
, &type
);
90 if( type
& MSITYPE_STRING
)
92 const WCHAR
*str
= MSI_RecordGetString( record
, n
);
93 val
= msi_addstringW( uv
->db
->strings
, 0, str
, -1, 1 );
97 val
= MSI_RecordGetInteger( record
, n
);
100 r
= wv
->ops
->set_int( wv
, row
, n
, val
);
107 return ERROR_SUCCESS
;
111 static UINT
UPDATE_close( struct tagMSIVIEW
*view
)
113 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
120 return ERROR_FUNCTION_FAILED
;
122 return wv
->ops
->close( wv
);
125 static UINT
UPDATE_get_dimensions( struct tagMSIVIEW
*view
, UINT
*rows
, UINT
*cols
)
127 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
130 TRACE("%p %p %p\n", uv
, rows
, cols
);
134 return ERROR_FUNCTION_FAILED
;
136 return wv
->ops
->get_dimensions( wv
, rows
, cols
);
139 static UINT
UPDATE_get_column_info( struct tagMSIVIEW
*view
,
140 UINT n
, LPWSTR
*name
, UINT
*type
)
142 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
145 TRACE("%p %d %p %p\n", uv
, n
, name
, type
);
149 return ERROR_FUNCTION_FAILED
;
151 return wv
->ops
->get_column_info( wv
, n
, name
, type
);
154 static UINT
UPDATE_modify( struct tagMSIVIEW
*view
, MSIMODIFY eModifyMode
,
157 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
159 TRACE("%p %d %p\n", uv
, eModifyMode
, rec
);
161 return ERROR_FUNCTION_FAILED
;
164 static UINT
UPDATE_delete( struct tagMSIVIEW
*view
)
166 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
173 wv
->ops
->delete( wv
);
174 delete_value_list( uv
->vals
);
175 msiobj_release( &uv
->db
->hdr
);
176 HeapFree( GetProcessHeap(), 0, uv
);
178 return ERROR_SUCCESS
;
182 static MSIVIEWOPS update_ops
=
190 UPDATE_get_dimensions
,
191 UPDATE_get_column_info
,
196 UINT
UPDATE_CreateView( MSIDATABASE
*db
, MSIVIEW
**view
, LPWSTR table
,
197 column_assignment
*list
, struct expr
*expr
)
199 MSIUPDATEVIEW
*uv
= NULL
;
201 MSIVIEW
*tv
= NULL
, *sv
= NULL
, *wv
= NULL
;
205 r
= TABLE_CreateView( db
, table
, &tv
);
206 if( r
!= ERROR_SUCCESS
)
209 /* add conditions first */
210 r
= WHERE_CreateView( db
, &wv
, tv
, expr
);
211 if( r
!= ERROR_SUCCESS
)
214 sv
->ops
->delete( tv
);
218 /* then select the columns we want */
219 r
= SELECT_CreateView( db
, &sv
, wv
, list
->col_list
);
220 if( r
!= ERROR_SUCCESS
)
223 tv
->ops
->delete( sv
);
227 uv
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof *uv
);
229 return ERROR_FUNCTION_FAILED
;
231 /* fill the structure */
232 uv
->view
.ops
= &update_ops
;
233 msiobj_addref( &db
->hdr
);
235 uv
->vals
= list
->val_list
;
237 *view
= (MSIVIEW
*) uv
;
239 return ERROR_SUCCESS
;