[MSI]
[reactos.git] / reactos / dll / win32 / msi / drop.c
1 /*
2 * Implementation of the Microsoft Installer (msi.dll)
3 *
4 * Copyright 2008 James Hawkins
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 "msipriv.h"
22
23 WINE_DEFAULT_DEBUG_CHANNEL(msidb);
24
25 typedef struct tagMSIDROPVIEW
26 {
27 MSIVIEW view;
28 MSIDATABASE *db;
29 MSIVIEW *table;
30 column_info *colinfo;
31 INT hold;
32 } MSIDROPVIEW;
33
34 static UINT DROP_execute(struct tagMSIVIEW *view, MSIRECORD *record)
35 {
36 MSIDROPVIEW *dv = (MSIDROPVIEW*)view;
37 UINT r;
38
39 TRACE("%p %p\n", dv, record);
40
41 if( !dv->table )
42 return ERROR_FUNCTION_FAILED;
43
44 r = dv->table->ops->execute(dv->table, record);
45 if (r != ERROR_SUCCESS)
46 return r;
47
48 return dv->table->ops->drop(dv->table);
49 }
50
51 static UINT DROP_close(struct tagMSIVIEW *view)
52 {
53 MSIDROPVIEW *dv = (MSIDROPVIEW*)view;
54
55 TRACE("%p\n", dv);
56
57 return ERROR_SUCCESS;
58 }
59
60 static UINT DROP_get_dimensions(struct tagMSIVIEW *view, UINT *rows, UINT *cols)
61 {
62 MSIDROPVIEW *dv = (MSIDROPVIEW*)view;
63
64 TRACE("%p %p %p\n", dv, rows, cols);
65
66 return ERROR_FUNCTION_FAILED;
67 }
68
69 static UINT DROP_delete( struct tagMSIVIEW *view )
70 {
71 MSIDROPVIEW *dv = (MSIDROPVIEW*)view;
72
73 TRACE("%p\n", dv );
74
75 if( dv->table )
76 dv->table->ops->delete( dv->table );
77
78 msi_free( dv );
79
80 return ERROR_SUCCESS;
81 }
82
83 static const MSIVIEWOPS drop_ops =
84 {
85 NULL,
86 NULL,
87 NULL,
88 NULL,
89 NULL,
90 NULL,
91 DROP_execute,
92 DROP_close,
93 DROP_get_dimensions,
94 NULL,
95 NULL,
96 DROP_delete,
97 NULL,
98 NULL,
99 NULL,
100 NULL,
101 NULL,
102 NULL,
103 NULL,
104 };
105
106 UINT DROP_CreateView(MSIDATABASE *db, MSIVIEW **view, LPCWSTR name)
107 {
108 MSIDROPVIEW *dv;
109 UINT r;
110
111 TRACE("%p %s\n", view, debugstr_w(name));
112
113 dv = msi_alloc_zero(sizeof *dv);
114 if(!dv)
115 return ERROR_FUNCTION_FAILED;
116
117 r = TABLE_CreateView(db, name, &dv->table);
118 if (r != ERROR_SUCCESS)
119 {
120 msi_free( dv );
121 return r;
122 }
123
124 dv->view.ops = &drop_ops;
125 dv->db = db;
126
127 *view = (MSIVIEW *)dv;
128
129 return ERROR_SUCCESS;
130 }