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

update.c
Go to the documentation of this file.
00001 /*
00002  * Implementation of the Microsoft Installer (msi.dll)
00003  *
00004  * Copyright 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 "msi.h"
00028 #include "msiquery.h"
00029 #include "objbase.h"
00030 #include "objidl.h"
00031 #include "msipriv.h"
00032 #include "winnls.h"
00033 
00034 #include "query.h"
00035 
00036 WINE_DEFAULT_DEBUG_CHANNEL(msidb);
00037 
00038 
00039 /* below is the query interface to a table */
00040 
00041 typedef struct tagMSIUPDATEVIEW
00042 {
00043     MSIVIEW          view;
00044     MSIDATABASE     *db;
00045     MSIVIEW         *wv;
00046     column_info     *vals;
00047 } MSIUPDATEVIEW;
00048 
00049 static UINT UPDATE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
00050 {
00051     MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
00052 
00053     TRACE("%p %d %d %p\n", uv, row, col, val );
00054 
00055     return ERROR_FUNCTION_FAILED;
00056 }
00057 
00058 static UINT UPDATE_execute( struct tagMSIVIEW *view, MSIRECORD *record )
00059 {
00060     MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
00061     UINT i, r, col_count = 0, row_count = 0;
00062     MSIRECORD *values = NULL;
00063     MSIRECORD *where = NULL;
00064     MSIVIEW *wv;
00065     UINT cols_count, where_count;
00066     column_info *col = uv->vals;
00067 
00068     TRACE("%p %p\n", uv, record );
00069 
00070     /* extract the where markers from the record */
00071     if (record)
00072     {
00073         r = MSI_RecordGetFieldCount(record);
00074 
00075         for (i = 0; col; col = col->next)
00076             i++;
00077 
00078         cols_count = i;
00079         where_count = r - i;
00080 
00081         if (where_count > 0)
00082         {
00083             where = MSI_CreateRecord(where_count);
00084 
00085             if (where)
00086                 for (i = 1; i <= where_count; i++)
00087                     MSI_RecordCopyField(record, cols_count + i, where, i);
00088         }
00089     }
00090 
00091     wv = uv->wv;
00092     if( !wv )
00093     {
00094         r = ERROR_FUNCTION_FAILED;
00095         goto done;
00096     }
00097 
00098     r = wv->ops->execute( wv, where );
00099     TRACE("tv execute returned %x\n", r);
00100     if( r )
00101         goto done;
00102 
00103     r = wv->ops->get_dimensions( wv, &row_count, &col_count );
00104     if( r )
00105         goto done;
00106 
00107     values = msi_query_merge_record( col_count, uv->vals, record );
00108     if (!values)
00109     {
00110         r = ERROR_FUNCTION_FAILED;
00111         goto done;
00112     }
00113 
00114     for ( i=0; i<row_count; i++ )
00115     {
00116         r = wv->ops->set_row( wv, i, values, (1 << col_count) - 1 );
00117         if (r != ERROR_SUCCESS)
00118             break;
00119     }
00120 
00121 done:
00122     if ( where ) msiobj_release( &where->hdr );
00123     if ( values ) msiobj_release( &values->hdr );
00124 
00125     return r;
00126 }
00127 
00128 
00129 static UINT UPDATE_close( struct tagMSIVIEW *view )
00130 {
00131     MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
00132     MSIVIEW *wv;
00133 
00134     TRACE("%p\n", uv);
00135 
00136     wv = uv->wv;
00137     if( !wv )
00138         return ERROR_FUNCTION_FAILED;
00139 
00140     return wv->ops->close( wv );
00141 }
00142 
00143 static UINT UPDATE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
00144 {
00145     MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
00146     MSIVIEW *wv;
00147 
00148     TRACE("%p %p %p\n", uv, rows, cols );
00149 
00150     wv = uv->wv;
00151     if( !wv )
00152         return ERROR_FUNCTION_FAILED;
00153 
00154     return wv->ops->get_dimensions( wv, rows, cols );
00155 }
00156 
00157 static UINT UPDATE_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
00158                                     UINT *type, BOOL *temporary, LPCWSTR *table_name )
00159 {
00160     MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
00161     MSIVIEW *wv;
00162 
00163     TRACE("%p %d %p %p %p %p\n", uv, n, name, type, temporary, table_name );
00164 
00165     wv = uv->wv;
00166     if( !wv )
00167         return ERROR_FUNCTION_FAILED;
00168 
00169     return wv->ops->get_column_info( wv, n, name, type, temporary, table_name );
00170 }
00171 
00172 static UINT UPDATE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
00173                            MSIRECORD *rec, UINT row )
00174 {
00175     MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
00176 
00177     TRACE("%p %d %p\n", uv, eModifyMode, rec );
00178 
00179     return ERROR_FUNCTION_FAILED;
00180 }
00181 
00182 static UINT UPDATE_delete( struct tagMSIVIEW *view )
00183 {
00184     MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
00185     MSIVIEW *wv;
00186 
00187     TRACE("%p\n", uv );
00188 
00189     wv = uv->wv;
00190     if( wv )
00191         wv->ops->delete( wv );
00192     msiobj_release( &uv->db->hdr );
00193     msi_free( uv );
00194 
00195     return ERROR_SUCCESS;
00196 }
00197 
00198 static UINT UPDATE_find_matching_rows( struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle )
00199 {
00200     TRACE("%p %d %d %p\n", view, col, val, *handle );
00201 
00202     return ERROR_FUNCTION_FAILED;
00203 }
00204 
00205 
00206 static const MSIVIEWOPS update_ops =
00207 {
00208     UPDATE_fetch_int,
00209     NULL,
00210     NULL,
00211     NULL,
00212     NULL,
00213     NULL,
00214     UPDATE_execute,
00215     UPDATE_close,
00216     UPDATE_get_dimensions,
00217     UPDATE_get_column_info,
00218     UPDATE_modify,
00219     UPDATE_delete,
00220     UPDATE_find_matching_rows,
00221     NULL,
00222     NULL,
00223     NULL,
00224     NULL,
00225     NULL,
00226 };
00227 
00228 UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
00229                         column_info *columns, struct expr *expr )
00230 {
00231     MSIUPDATEVIEW *uv = NULL;
00232     UINT r;
00233     MSIVIEW *sv = NULL, *wv = NULL;
00234 
00235     TRACE("%p\n", uv );
00236 
00237     if (expr)
00238         r = WHERE_CreateView( db, &wv, table, expr );
00239     else
00240         r = TABLE_CreateView( db, table, &wv );
00241 
00242     if( r != ERROR_SUCCESS )
00243         return r;
00244 
00245     /* then select the columns we want */
00246     r = SELECT_CreateView( db, &sv, wv, columns );
00247     if( r != ERROR_SUCCESS )
00248     {
00249         wv->ops->delete( wv );
00250         return r;
00251     }
00252 
00253     uv = msi_alloc_zero( sizeof *uv );
00254     if( !uv )
00255     {
00256         wv->ops->delete( wv );
00257         return ERROR_FUNCTION_FAILED;
00258     }
00259 
00260     /* fill the structure */
00261     uv->view.ops = &update_ops;
00262     msiobj_addref( &db->hdr );
00263     uv->db = db;
00264     uv->vals = columns;
00265     uv->wv = sv;
00266     *view = (MSIVIEW*) uv;
00267 
00268     return ERROR_SUCCESS;
00269 }

Generated on Fri May 25 2012 04:23:23 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.