ReactOS  0.4.15-dev-5496-g599ba9c
create.c
Go to the documentation of this file.
1 /*
2  * Implementation of the Microsoft Installer (msi.dll)
3  *
4  * Copyright 2002-2004 Mike McCormack for CodeWeavers
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 <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 
37 
38 
39 /* below is the query interface to a table */
40 
41 typedef struct tagMSICREATEVIEW
42 {
50 
52 {
54 
55  TRACE("%p %d %d %p\n", cv, row, col, val );
56 
57  return ERROR_FUNCTION_FAILED;
58 }
59 
61 {
64 
65  TRACE("%p Table %s (%s)\n", cv, debugstr_w(cv->name),
66  cv->bIsTemp?"temporary":"permanent");
67 
68  if (cv->bIsTemp && !cv->hold)
69  return ERROR_SUCCESS;
70 
71  return msi_create_table( cv->db, cv->name, cv->col_info, persist, cv->hold );
72 }
73 
74 static UINT CREATE_close( struct tagMSIVIEW *view )
75 {
77 
78  TRACE("%p\n", cv);
79 
80  return ERROR_SUCCESS;
81 }
82 
83 static UINT CREATE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
84 {
86 
87  TRACE("%p %p %p\n", cv, rows, cols );
88 
89  return ERROR_FUNCTION_FAILED;
90 }
91 
93  UINT *type, BOOL *temporary, LPCWSTR *table_name )
94 {
96 
97  TRACE("%p %d %p %p %p %p\n", cv, n, name, type, temporary, table_name );
98 
99  return ERROR_FUNCTION_FAILED;
100 }
101 
102 static UINT CREATE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
103  MSIRECORD *rec, UINT row)
104 {
106 
107  TRACE("%p %d %p\n", cv, eModifyMode, rec );
108 
109  return ERROR_FUNCTION_FAILED;
110 }
111 
113 {
115 
116  TRACE("%p\n", cv );
117 
118  msiobj_release( &cv->db->hdr );
119  msi_free( cv );
120 
121  return ERROR_SUCCESS;
122 }
123 
124 static const MSIVIEWOPS create_ops =
125 {
127  NULL,
128  NULL,
129  NULL,
130  NULL,
131  NULL,
132  NULL,
133  NULL,
135  CREATE_close,
140  NULL,
141  NULL,
142  NULL,
143  NULL,
144  NULL,
145 };
146 
147 static UINT check_columns( const column_info *col_info )
148 {
149  const column_info *c1, *c2;
150 
151  /* check for two columns with the same name */
152  for( c1 = col_info; c1; c1 = c1->next )
153  for( c2 = c1->next; c2; c2 = c2->next )
154  if (!wcscmp( c1->column, c2->column ))
155  return ERROR_BAD_QUERY_SYNTAX;
156 
157  return ERROR_SUCCESS;
158 }
159 
161  column_info *col_info, BOOL hold )
162 {
163  MSICREATEVIEW *cv = NULL;
164  UINT r;
165  column_info *col;
166  BOOL temp = TRUE;
167  BOOL tempprim = FALSE;
168 
169  TRACE("%p\n", cv );
170 
171  r = check_columns( col_info );
172  if( r != ERROR_SUCCESS )
173  return r;
174 
175  cv = msi_alloc_zero( sizeof *cv );
176  if( !cv )
177  return ERROR_FUNCTION_FAILED;
178 
179  for( col = col_info; col; col = col->next )
180  {
181  if (!col->table)
182  col->table = table;
183 
184  if( !(col->type & MSITYPE_TEMPORARY) )
185  temp = FALSE;
186  else if ( col->type & MSITYPE_KEY )
187  tempprim = TRUE;
188  }
189 
190  if ( !temp && tempprim )
191  {
192  msi_free( cv );
193  return ERROR_FUNCTION_FAILED;
194  }
195 
196  /* fill the structure */
197  cv->view.ops = &create_ops;
198  msiobj_addref( &db->hdr );
199  cv->db = db;
200  cv->name = table;
201  cv->col_info = col_info;
202  cv->bIsTemp = temp;
203  cv->hold = hold;
204  *view = (MSIVIEW*) cv;
205 
206  return ERROR_SUCCESS;
207 }
void msiobj_addref(MSIOBJECTHDR *info)
Definition: handle.c:217
static const MSIVIEWOPS create_ops
Definition: create.c:124
#define ERROR_SUCCESS
Definition: deptool.c:10
static UINT CREATE_delete(struct tagMSIVIEW *view)
Definition: create.c:112
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
struct _column_info * next
Definition: msipriv.h:226
static void msi_free(void *mem)
Definition: msipriv.h:1159
MSIVIEW view
Definition: create.c:43
static UINT CREATE_get_column_info(struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
Definition: create.c:92
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1148
BOOL bIsTemp
Definition: create.c:46
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
LPCWSTR name
Definition: create.c:45
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
LPCWSTR column
Definition: msipriv.h:223
int MSIMODIFY
Definition: winemsi.idl:33
static UINT CREATE_fetch_int(struct tagMSIVIEW *view, UINT row, UINT col, UINT *val)
Definition: create.c:51
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:355
struct tagMSICREATEVIEW MSICREATEVIEW
static UINT CREATE_modify(struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *rec, UINT row)
Definition: create.c:102
#define MSITYPE_KEY
Definition: msipriv.h:52
int msiobj_release(MSIOBJECTHDR *info)
Definition: handle.c:241
static UINT CREATE_execute(struct tagMSIVIEW *view, MSIRECORD *record)
Definition: create.c:60
UINT CREATE_CreateView(MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, column_info *col_info, BOOL hold)
Definition: create.c:160
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
UINT msi_create_table(MSIDATABASE *db, LPCWSTR name, column_info *col_info, MSICONDITION persistent, BOOL hold) DECLSPEC_HIDDEN
Definition: table.c:705
#define MSITYPE_TEMPORARY
Definition: msipriv.h:53
static calc_node_t temp
Definition: rpn_ieee.c:38
static UINT CREATE_close(struct tagMSIVIEW *view)
Definition: create.c:74
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
LPCWSTR table
Definition: msipriv.h:222
Definition: name.c:38
MSIDATABASE * db
Definition: create.c:44
static UINT check_columns(const column_info *col_info)
Definition: create.c:147
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
column_info * col_info
Definition: create.c:48
static UINT CREATE_get_dimensions(struct tagMSIVIEW *view, UINT *rows, UINT *cols)
Definition: create.c:83
MSIOBJECTHDR hdr
Definition: msipriv.h:108
#define ERROR_BAD_QUERY_SYNTAX
Definition: winerror.h:973
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
WINE_DEFAULT_DEBUG_CHANNEL(msidb)