ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

create.c
Go to the documentation of this file.
00001 /*
00002  * Implementation of the Microsoft Installer (msi.dll)
00003  *
00004  * Copyright 2002-2004 Mike McCormack for CodeWeavers
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #include <stdarg.h>
00022 
00023 #include "windef.h"
00024 #include "winbase.h"
00025 #include "winerror.h"
00026 #include "wine/debug.h"
00027 #include "wine/unicode.h"
00028 #include "msi.h"
00029 #include "msiquery.h"
00030 #include "objbase.h"
00031 #include "objidl.h"
00032 #include "msipriv.h"
00033 #include "winnls.h"
00034 
00035 #include "query.h"
00036 
00037 WINE_DEFAULT_DEBUG_CHANNEL(msidb);
00038 
00039 
00040 /* below is the query interface to a table */
00041 
00042 typedef struct tagMSICREATEVIEW
00043 {
00044     MSIVIEW          view;
00045     MSIDATABASE     *db;
00046     LPCWSTR          name;
00047     BOOL             bIsTemp;
00048     BOOL             hold;
00049     column_info     *col_info;
00050 } MSICREATEVIEW;
00051 
00052 static UINT CREATE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
00053 {
00054     MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
00055 
00056     TRACE("%p %d %d %p\n", cv, row, col, val );
00057 
00058     return ERROR_FUNCTION_FAILED;
00059 }
00060 
00061 static UINT CREATE_execute( struct tagMSIVIEW *view, MSIRECORD *record )
00062 {
00063     MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
00064     BOOL persist = (cv->bIsTemp) ? MSICONDITION_FALSE : MSICONDITION_TRUE;
00065 
00066     TRACE("%p Table %s (%s)\n", cv, debugstr_w(cv->name),
00067           cv->bIsTemp?"temporary":"permanent");
00068 
00069     if (cv->bIsTemp && !cv->hold)
00070         return ERROR_SUCCESS;
00071 
00072     return msi_create_table( cv->db, cv->name, cv->col_info, persist );
00073 }
00074 
00075 static UINT CREATE_close( struct tagMSIVIEW *view )
00076 {
00077     MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
00078 
00079     TRACE("%p\n", cv);
00080 
00081     return ERROR_SUCCESS;
00082 }
00083 
00084 static UINT CREATE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
00085 {
00086     MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
00087 
00088     TRACE("%p %p %p\n", cv, rows, cols );
00089 
00090     return ERROR_FUNCTION_FAILED;
00091 }
00092 
00093 static UINT CREATE_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
00094                                     UINT *type, BOOL *temporary, LPCWSTR *table_name )
00095 {
00096     MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
00097 
00098     TRACE("%p %d %p %p %p %p\n", cv, n, name, type, temporary, table_name );
00099 
00100     return ERROR_FUNCTION_FAILED;
00101 }
00102 
00103 static UINT CREATE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
00104                            MSIRECORD *rec, UINT row)
00105 {
00106     MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
00107 
00108     TRACE("%p %d %p\n", cv, eModifyMode, rec );
00109 
00110     return ERROR_FUNCTION_FAILED;
00111 }
00112 
00113 static UINT CREATE_delete( struct tagMSIVIEW *view )
00114 {
00115     MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
00116 
00117     TRACE("%p\n", cv );
00118 
00119     msiobj_release( &cv->db->hdr );
00120     msi_free( cv );
00121 
00122     return ERROR_SUCCESS;
00123 }
00124 
00125 static const MSIVIEWOPS create_ops =
00126 {
00127     CREATE_fetch_int,
00128     NULL,
00129     NULL,
00130     NULL,
00131     NULL,
00132     NULL,
00133     CREATE_execute,
00134     CREATE_close,
00135     CREATE_get_dimensions,
00136     CREATE_get_column_info,
00137     CREATE_modify,
00138     CREATE_delete,
00139     NULL,
00140     NULL,
00141     NULL,
00142     NULL,
00143     NULL,
00144     NULL,
00145     NULL,
00146 };
00147 
00148 static UINT check_columns( const column_info *col_info )
00149 {
00150     const column_info *c1, *c2;
00151 
00152     /* check for two columns with the same name */
00153     for( c1 = col_info; c1; c1 = c1->next )
00154         for( c2 = c1->next; c2; c2 = c2->next )
00155             if (!strcmpW( c1->column, c2->column ))
00156                 return ERROR_BAD_QUERY_SYNTAX;
00157 
00158     return ERROR_SUCCESS;
00159 }
00160 
00161 UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table,
00162                         column_info *col_info, BOOL hold )
00163 {
00164     MSICREATEVIEW *cv = NULL;
00165     UINT r;
00166     column_info *col;
00167     BOOL temp = TRUE;
00168     BOOL tempprim = FALSE;
00169 
00170     TRACE("%p\n", cv );
00171 
00172     r = check_columns( col_info );
00173     if( r != ERROR_SUCCESS )
00174         return r;
00175 
00176     cv = msi_alloc_zero( sizeof *cv );
00177     if( !cv )
00178         return ERROR_FUNCTION_FAILED;
00179 
00180     for( col = col_info; col; col = col->next )
00181     {
00182         if (!col->table)
00183             col->table = table;
00184 
00185         if( !col->temporary )
00186             temp = FALSE;
00187         else if ( col->type & MSITYPE_KEY )
00188             tempprim = TRUE;
00189     }
00190 
00191     if ( !temp && tempprim )
00192     {
00193         msi_free( cv );
00194         return ERROR_FUNCTION_FAILED;
00195     }
00196 
00197     /* fill the structure */
00198     cv->view.ops = &create_ops;
00199     msiobj_addref( &db->hdr );
00200     cv->db = db;
00201     cv->name = table;
00202     cv->col_info = col_info;
00203     cv->bIsTemp = temp;
00204     cv->hold = hold;
00205     *view = (MSIVIEW*) cv;
00206 
00207     return ERROR_SUCCESS;
00208 }

Generated on Sun May 27 2012 04:16:58 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.