d3d8: Hold the lock in IDirect3DIndexBuffer8 methods.
[wine.git] / dlls / msi / create.c
blob965a4a6049c0b7017dd1a6794a36ec916d3f28ee
1 /*
2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002-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 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
21 #include <stdarg.h>
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"
34 #include "query.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msidb);
39 /* below is the query interface to a table */
41 typedef struct tagMSICREATEVIEW
43 MSIVIEW view;
44 MSIDATABASE *db;
45 LPWSTR name;
46 BOOL bIsTemp;
47 column_info *col_info;
48 } MSICREATEVIEW;
50 static UINT CREATE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
52 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
54 TRACE("%p %d %d %p\n", cv, row, col, val );
56 return ERROR_FUNCTION_FAILED;
59 static UINT CREATE_execute( struct tagMSIVIEW *view, MSIRECORD *record )
61 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
62 MSITABLE *table;
64 TRACE("%p Table %s (%s)\n", cv, debugstr_w(cv->name),
65 cv->bIsTemp?"temporary":"permanent");
67 return msi_create_table( cv->db, cv->name, cv->col_info, !cv->bIsTemp, &table);
70 static UINT CREATE_close( struct tagMSIVIEW *view )
72 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
74 TRACE("%p\n", cv);
76 return ERROR_SUCCESS;
79 static UINT CREATE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
81 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
83 TRACE("%p %p %p\n", cv, rows, cols );
85 return ERROR_FUNCTION_FAILED;
88 static UINT CREATE_get_column_info( struct tagMSIVIEW *view,
89 UINT n, LPWSTR *name, UINT *type )
91 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
93 TRACE("%p %d %p %p\n", cv, n, name, type );
95 return ERROR_FUNCTION_FAILED;
98 static UINT CREATE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
99 MSIRECORD *rec)
101 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
103 TRACE("%p %d %p\n", cv, eModifyMode, rec );
105 return ERROR_FUNCTION_FAILED;
108 static UINT CREATE_delete( struct tagMSIVIEW *view )
110 MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
112 TRACE("%p\n", cv );
114 msiobj_release( &cv->db->hdr );
115 msi_free( cv );
117 return ERROR_SUCCESS;
121 static const MSIVIEWOPS create_ops =
123 CREATE_fetch_int,
124 NULL,
125 NULL,
126 NULL,
127 CREATE_execute,
128 CREATE_close,
129 CREATE_get_dimensions,
130 CREATE_get_column_info,
131 CREATE_modify,
132 CREATE_delete
135 static UINT check_columns( column_info *col_info )
137 column_info *c1, *c2;
139 /* check for two columns with the same name */
140 for( c1 = col_info; c1; c1 = c1->next )
141 for( c2 = c1->next; c2; c2 = c2->next )
142 if (!lstrcmpW(c1->column, c2->column))
143 return ERROR_BAD_QUERY_SYNTAX;
145 return ERROR_SUCCESS;
148 UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
149 column_info *col_info, BOOL hold )
151 MSICREATEVIEW *cv = NULL;
152 UINT r;
153 const column_info *col;
154 BOOL temp = TRUE;
156 TRACE("%p\n", cv );
158 r = check_columns( col_info );
159 if( r != ERROR_SUCCESS )
160 return r;
162 cv = msi_alloc_zero( sizeof *cv );
163 if( !cv )
164 return ERROR_FUNCTION_FAILED;
166 for( col = col_info; col; col = col->next )
167 if( !col->temporary )
169 temp = FALSE;
170 break;
173 /* fill the structure */
174 cv->view.ops = &create_ops;
175 msiobj_addref( &db->hdr );
176 cv->db = db;
177 cv->name = table;
178 cv->col_info = col_info;
179 cv->bIsTemp = temp;
180 *view = (MSIVIEW*) cv;
182 return ERROR_SUCCESS;