Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Implementation of the Microsoft Installer (msi.dll) |
| 3 | * |
Mike McCormack | 068b4ec | 2004-03-19 01:16:36 +0000 | [diff] [blame] | 4 | * Copyright 2002-2004 Mike McCormack for CodeWeavers |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 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 |
Jonathan Ernst | 360a3f9 | 2006-05-18 14:49:52 +0200 | [diff] [blame] | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 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 | |
Mike McCormack | 50684c1 | 2005-11-02 14:24:21 +0000 | [diff] [blame] | 36 | WINE_DEFAULT_DEBUG_CHANNEL(msidb); |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 37 | |
| 38 | |
| 39 | /* below is the query interface to a table */ |
| 40 | |
| 41 | typedef struct tagMSICREATEVIEW |
| 42 | { |
| 43 | MSIVIEW view; |
| 44 | MSIDATABASE *db; |
| 45 | LPWSTR name; |
| 46 | BOOL bIsTemp; |
Mike McCormack | d1a55eb | 2005-05-29 20:17:16 +0000 | [diff] [blame] | 47 | column_info *col_info; |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 48 | } MSICREATEVIEW; |
| 49 | |
| 50 | static UINT CREATE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val ) |
| 51 | { |
| 52 | MSICREATEVIEW *cv = (MSICREATEVIEW*)view; |
| 53 | |
| 54 | TRACE("%p %d %d %p\n", cv, row, col, val ); |
| 55 | |
| 56 | return ERROR_FUNCTION_FAILED; |
| 57 | } |
| 58 | |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 59 | static UINT CREATE_execute( struct tagMSIVIEW *view, MSIRECORD *record ) |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 60 | { |
| 61 | MSICREATEVIEW *cv = (MSICREATEVIEW*)view; |
Rob Shearman | ba0507a | 2007-04-23 08:21:32 +0100 | [diff] [blame] | 62 | MSITABLE *table; |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 63 | |
Mike McCormack | 068b4ec | 2004-03-19 01:16:36 +0000 | [diff] [blame] | 64 | TRACE("%p Table %s (%s)\n", cv, debugstr_w(cv->name), |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 65 | cv->bIsTemp?"temporary":"permanent"); |
| 66 | |
Rob Shearman | ba0507a | 2007-04-23 08:21:32 +0100 | [diff] [blame] | 67 | return msi_create_table( cv->db, cv->name, cv->col_info, !cv->bIsTemp, &table); |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | static UINT CREATE_close( struct tagMSIVIEW *view ) |
| 71 | { |
| 72 | MSICREATEVIEW *cv = (MSICREATEVIEW*)view; |
| 73 | |
Mike McCormack | 068b4ec | 2004-03-19 01:16:36 +0000 | [diff] [blame] | 74 | TRACE("%p\n", cv); |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 75 | |
| 76 | return ERROR_SUCCESS; |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | static UINT CREATE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols ) |
| 80 | { |
| 81 | MSICREATEVIEW *cv = (MSICREATEVIEW*)view; |
| 82 | |
| 83 | TRACE("%p %p %p\n", cv, rows, cols ); |
| 84 | |
| 85 | return ERROR_FUNCTION_FAILED; |
| 86 | } |
| 87 | |
| 88 | static UINT CREATE_get_column_info( struct tagMSIVIEW *view, |
| 89 | UINT n, LPWSTR *name, UINT *type ) |
| 90 | { |
| 91 | MSICREATEVIEW *cv = (MSICREATEVIEW*)view; |
| 92 | |
| 93 | TRACE("%p %d %p %p\n", cv, n, name, type ); |
| 94 | |
| 95 | return ERROR_FUNCTION_FAILED; |
| 96 | } |
| 97 | |
Mike McCormack | ef1d367 | 2005-02-08 13:44:25 +0000 | [diff] [blame] | 98 | static UINT CREATE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode, |
| 99 | MSIRECORD *rec) |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 100 | { |
| 101 | MSICREATEVIEW *cv = (MSICREATEVIEW*)view; |
| 102 | |
Mike McCormack | ef1d367 | 2005-02-08 13:44:25 +0000 | [diff] [blame] | 103 | TRACE("%p %d %p\n", cv, eModifyMode, rec ); |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 104 | |
| 105 | return ERROR_FUNCTION_FAILED; |
| 106 | } |
| 107 | |
| 108 | static UINT CREATE_delete( struct tagMSIVIEW *view ) |
| 109 | { |
| 110 | MSICREATEVIEW *cv = (MSICREATEVIEW*)view; |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 111 | |
| 112 | TRACE("%p\n", cv ); |
| 113 | |
Aric Stewart | bc6ce2b | 2004-08-25 17:31:39 +0000 | [diff] [blame] | 114 | msiobj_release( &cv->db->hdr ); |
Mike McCormack | 8dc28d5 | 2005-09-20 11:57:19 +0000 | [diff] [blame] | 115 | msi_free( cv ); |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 116 | |
| 117 | return ERROR_SUCCESS; |
| 118 | } |
| 119 | |
Alexandre Julliard | 9a59ee7 | 2006-06-10 12:02:39 +0200 | [diff] [blame] | 120 | static const MSIVIEWOPS create_ops = |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 121 | { |
| 122 | CREATE_fetch_int, |
Mike McCormack | 068b4ec | 2004-03-19 01:16:36 +0000 | [diff] [blame] | 123 | NULL, |
| 124 | NULL, |
Mike McCormack | 24e9a34 | 2004-07-06 18:56:12 +0000 | [diff] [blame] | 125 | NULL, |
James Hawkins | 9309f4d | 2007-06-18 13:49:31 -0700 | [diff] [blame] | 126 | NULL, |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 127 | CREATE_execute, |
| 128 | CREATE_close, |
| 129 | CREATE_get_dimensions, |
| 130 | CREATE_get_column_info, |
| 131 | CREATE_modify, |
James Hawkins | 3b1ab76 | 2007-07-18 18:21:00 -0700 | [diff] [blame] | 132 | CREATE_delete, |
| 133 | NULL, |
| 134 | NULL, |
James Hawkins | 0fd733b | 2007-07-20 14:01:13 -0700 | [diff] [blame^] | 135 | NULL, |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 136 | }; |
| 137 | |
Mike McCormack | 2924501 | 2006-08-31 17:04:40 +0900 | [diff] [blame] | 138 | static UINT check_columns( column_info *col_info ) |
| 139 | { |
| 140 | column_info *c1, *c2; |
| 141 | |
| 142 | /* check for two columns with the same name */ |
| 143 | for( c1 = col_info; c1; c1 = c1->next ) |
| 144 | for( c2 = c1->next; c2; c2 = c2->next ) |
| 145 | if (!lstrcmpW(c1->column, c2->column)) |
| 146 | return ERROR_BAD_QUERY_SYNTAX; |
| 147 | |
| 148 | return ERROR_SUCCESS; |
| 149 | } |
| 150 | |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 151 | UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table, |
Rob Shearman | 697d820 | 2007-04-23 08:26:44 +0100 | [diff] [blame] | 152 | column_info *col_info, BOOL hold ) |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 153 | { |
| 154 | MSICREATEVIEW *cv = NULL; |
Mike McCormack | 2924501 | 2006-08-31 17:04:40 +0900 | [diff] [blame] | 155 | UINT r; |
Rob Shearman | 697d820 | 2007-04-23 08:26:44 +0100 | [diff] [blame] | 156 | const column_info *col; |
| 157 | BOOL temp = TRUE; |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 158 | |
| 159 | TRACE("%p\n", cv ); |
| 160 | |
Mike McCormack | 2924501 | 2006-08-31 17:04:40 +0900 | [diff] [blame] | 161 | r = check_columns( col_info ); |
| 162 | if( r != ERROR_SUCCESS ) |
| 163 | return r; |
| 164 | |
Mike McCormack | 8dc28d5 | 2005-09-20 11:57:19 +0000 | [diff] [blame] | 165 | cv = msi_alloc_zero( sizeof *cv ); |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 166 | if( !cv ) |
| 167 | return ERROR_FUNCTION_FAILED; |
Mike McCormack | 2924501 | 2006-08-31 17:04:40 +0900 | [diff] [blame] | 168 | |
Rob Shearman | 697d820 | 2007-04-23 08:26:44 +0100 | [diff] [blame] | 169 | for( col = col_info; col; col = col->next ) |
| 170 | if( !col->temporary ) |
| 171 | { |
| 172 | temp = FALSE; |
| 173 | break; |
| 174 | } |
| 175 | |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 176 | /* fill the structure */ |
| 177 | cv->view.ops = &create_ops; |
Alexandre Julliard | a7a6f5f | 2004-07-09 22:25:34 +0000 | [diff] [blame] | 178 | msiobj_addref( &db->hdr ); |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 179 | cv->db = db; |
Mike McCormack | 0093007 | 2005-05-23 12:08:17 +0000 | [diff] [blame] | 180 | cv->name = table; |
Mike McCormack | 14ec526 | 2004-03-16 19:18:22 +0000 | [diff] [blame] | 181 | cv->col_info = col_info; |
| 182 | cv->bIsTemp = temp; |
| 183 | *view = (MSIVIEW*) cv; |
| 184 | |
| 185 | return ERROR_SUCCESS; |
| 186 | } |