2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msi);
38 typedef struct tagMSIQUERY
45 UINT WINAPI MsiDatabaseIsTablePersistentA(
46 MSIHANDLE hDatabase, LPSTR szTableName)
48 FIXME("%lx %s\n", hDatabase, debugstr_a(szTableName));
49 return ERROR_CALL_NOT_IMPLEMENTED;
52 UINT WINAPI MsiDatabaseIsTablePersistentW(
53 MSIHANDLE hDatabase, LPWSTR szTableName)
55 FIXME("%lx %s\n", hDatabase, debugstr_w(szTableName));
56 return ERROR_CALL_NOT_IMPLEMENTED;
59 void MSI_CloseView( VOID *arg )
61 MSIQUERY *query = arg;
63 if( query->view && query->view->ops->delete )
64 query->view->ops->delete( query->view );
67 UINT VIEW_find_column( MSIVIEW *table, LPWSTR name, UINT *n )
72 r = table->ops->get_dimensions( table, NULL, &count );
73 if( r != ERROR_SUCCESS )
76 for( i=1; i<=count; i++ )
81 r = table->ops->get_column_info( table, i, &col_name, NULL );
82 if( r != ERROR_SUCCESS )
84 x = lstrcmpW( name, col_name );
85 HeapFree( GetProcessHeap(), 0, col_name );
93 return ERROR_INVALID_PARAMETER;
96 UINT WINAPI MsiDatabaseOpenViewA(MSIHANDLE hdb,
97 LPCSTR szQuery, MSIHANDLE *phView)
102 TRACE("%ld %s %p\n", hdb, debugstr_a(szQuery), phView);
106 szwQuery = HEAP_strdupAtoW( GetProcessHeap(), 0, szQuery );
108 return ERROR_FUNCTION_FAILED;
113 r = MsiDatabaseOpenViewW( hdb, szwQuery, phView);
118 UINT WINAPI MsiDatabaseOpenViewW(MSIHANDLE hdb,
119 LPCWSTR szQuery, MSIHANDLE *phView)
126 TRACE("%s %p\n", debugstr_w(szQuery), phView);
129 return ERROR_INVALID_PARAMETER;
131 db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE );
133 return ERROR_INVALID_HANDLE;
135 /* pre allocate a handle to hold a pointer to the view */
136 handle = alloc_msihandle( MSIHANDLETYPE_VIEW, sizeof (MSIQUERY), MSI_CloseView );
138 return ERROR_FUNCTION_FAILED;
139 query = msihandle2msiinfo( handle, MSIHANDLETYPE_VIEW );
141 return ERROR_FUNCTION_FAILED;
147 r = MSI_ParseSQL( db, szQuery, &query->view );
148 if( r != ERROR_SUCCESS )
150 MsiCloseHandle( handle );
156 return ERROR_SUCCESS;
159 UINT WINAPI MsiViewFetch(MSIHANDLE hView, MSIHANDLE *record)
164 UINT row_count = 0, col_count = 0, i, ival, ret, type;
166 TRACE("%ld %p\n", hView, record);
168 query = msihandle2msiinfo( hView, MSIHANDLETYPE_VIEW );
170 return ERROR_INVALID_HANDLE;
173 return ERROR_FUNCTION_FAILED;
175 ret = view->ops->get_dimensions( view, &row_count, &col_count );
179 return ERROR_INVALID_PARAMETER;
181 if( query->row >= row_count )
182 return ERROR_NO_MORE_ITEMS;
184 handle = MsiCreateRecord( col_count );
186 return ERROR_FUNCTION_FAILED;
188 for( i=1; i<=col_count; i++ )
190 ret = view->ops->get_column_info( view, i, NULL, &type );
193 ERR("Error getting column type for %d\n", i );
196 ret = view->ops->fetch_int( view, query->row, i, &ival );
199 ERR("Error fetching data for %d\n", i );
202 if( ! (type & MSITYPE_VALID ) )
203 ERR("Invalid type!\n");
205 /* check if it's nul (0) - if so, don't set anything */
209 if( type & MSITYPE_STRING )
211 LPWSTR sval = MSI_makestring( query->db, ival );
212 MsiRecordSetStringW( handle, i, sval );
213 HeapFree( GetProcessHeap(), 0, sval );
217 if( (type & MSI_DATASIZEMASK) == 2 )
218 MsiRecordSetInteger( handle, i, ival - (1<<15) );
220 MsiRecordSetInteger( handle, i, ival - (1<<31) );
227 return ERROR_SUCCESS;
230 UINT WINAPI MsiViewClose(MSIHANDLE hView)
235 TRACE("%ld\n", hView );
237 query = msihandle2msiinfo( hView, MSIHANDLETYPE_VIEW );
239 return ERROR_INVALID_HANDLE;
243 return ERROR_FUNCTION_FAILED;
244 if( !view->ops->close )
245 return ERROR_FUNCTION_FAILED;
247 return view->ops->close( view );
250 UINT WINAPI MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRec)
255 TRACE("%ld %ld\n", hView, hRec);
257 query = msihandle2msiinfo( hView, MSIHANDLETYPE_VIEW );
259 return ERROR_INVALID_HANDLE;
263 return ERROR_FUNCTION_FAILED;
264 if( !view->ops->execute )
265 return ERROR_FUNCTION_FAILED;
268 return view->ops->execute( view, hRec );
271 UINT WINAPI MsiViewGetColumnInfo(MSIHANDLE hView, MSICOLINFO info, MSIHANDLE *hRec)
276 UINT ret, i, count = 0, type;
279 TRACE("%ld %d %p\n", hView, info, hRec);
281 query = msihandle2msiinfo( hView, MSIHANDLETYPE_VIEW );
283 return ERROR_INVALID_HANDLE;
287 return ERROR_FUNCTION_FAILED;
289 if( !view->ops->get_dimensions )
290 return ERROR_FUNCTION_FAILED;
292 ret = view->ops->get_dimensions( view, NULL, &count );
296 return ERROR_INVALID_PARAMETER;
298 handle = MsiCreateRecord( count );
300 return ERROR_FUNCTION_FAILED;
302 for( i=0; i<count; i++ )
305 ret = view->ops->get_column_info( view, i+1, &name, &type );
306 if( ret != ERROR_SUCCESS )
308 MsiRecordSetStringW( handle, i+1, name );
309 HeapFree( GetProcessHeap(), 0, name );
314 return ERROR_SUCCESS;
318 UINT WINAPI MsiDoActionA( MSIHANDLE hInstall, LPCSTR szAction )
320 FIXME("%ld %s\n", hInstall, debugstr_a(szAction) );
321 return ERROR_CALL_NOT_IMPLEMENTED;
324 UINT WINAPI MsiDoActionW( MSIHANDLE hInstall, LPCWSTR szAction )
326 FIXME("%ld %s\n", hInstall, debugstr_w(szAction) );
327 return ERROR_CALL_NOT_IMPLEMENTED;
330 UINT WINAPI MsiDatabaseApplyTransformA( MSIHANDLE hdb,
331 LPCSTR szTransformFile, int iErrorCond)
333 FIXME("%ld %s %d\n", hdb, debugstr_a(szTransformFile), iErrorCond);
334 return ERROR_CALL_NOT_IMPLEMENTED;
337 UINT WINAPI MsiDatabaseApplyTransformW( MSIHANDLE hdb,
338 LPCWSTR szTransformFile, int iErrorCond)
340 FIXME("%ld %s %d\n", hdb, debugstr_w(szTransformFile), iErrorCond);
341 return ERROR_CALL_NOT_IMPLEMENTED;
344 UINT WINAPI MsiDatabaseGenerateTransformA( MSIHANDLE hdb, MSIHANDLE hdbref,
345 LPCSTR szTransformFile, int iReserved1, int iReserved2 )
347 FIXME("%ld %ld %s %d %d\n", hdb, hdbref,
348 debugstr_a(szTransformFile), iReserved1, iReserved2);
349 return ERROR_CALL_NOT_IMPLEMENTED;
352 UINT WINAPI MsiDatabaseGenerateTransformW( MSIHANDLE hdb, MSIHANDLE hdbref,
353 LPCWSTR szTransformFile, int iReserved1, int iReserved2 )
355 FIXME("%ld %ld %s %d %d\n", hdb, hdbref,
356 debugstr_w(szTransformFile), iReserved1, iReserved2);
357 return ERROR_CALL_NOT_IMPLEMENTED;
360 UINT WINAPI MsiDatabaseCommit( MSIHANDLE hdb )
363 return ERROR_SUCCESS;
366 UINT WINAPI MsiDatabaseGetPrimaryKeysA(MSIHANDLE hdb,
367 LPCSTR table, MSIHANDLE* rec)
369 FIXME("%ld %s %p\n", hdb, debugstr_a(table), rec);
370 return ERROR_CALL_NOT_IMPLEMENTED;
373 UINT WINAPI MsiDatabaseGetPrimaryKeysW(MSIHANDLE hdb,
374 LPCWSTR table, MSIHANDLE* rec)
376 FIXME("%ld %s %p\n", hdb, debugstr_w(table), rec);
377 return ERROR_CALL_NOT_IMPLEMENTED;