Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msi/table.c | 53 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 27 deletions(-)
diff --git a/dlls/msi/table.c b/dlls/msi/table.c index b507268eb7..e4f6b56f18 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -1201,6 +1201,26 @@ static UINT TABLE_set_int( MSITABLEVIEW *tv, UINT row, UINT col, UINT val ) return ERROR_SUCCESS; }
+static UINT int_to_table_storage( const MSITABLEVIEW *tv, UINT col, int val, UINT *ret ) +{ + if ((tv->columns[col-1].type & MSI_DATASIZEMASK) == 2) + { + if (val == MSI_NULL_INTEGER) + *ret = 0; + else if ((val + 0x8000) & 0xffff0000) + { + ERR("value %d out of range\n", val); + return ERROR_FUNCTION_FAILED; + } + else + *ret = val + 0x8000; + } + else + *ret = val ^ 0x80000000; + + return ERROR_SUCCESS; +} + static UINT TABLE_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec ) { MSITABLEVIEW *tv = (MSITABLEVIEW *)view; @@ -1276,7 +1296,6 @@ static UINT get_table_value_from_record( MSITABLEVIEW *tv, MSIRECORD *rec, UINT { MSICOLUMNINFO columninfo; UINT r; - int ival;
if (!iField || iField > tv->num_cols || MSI_RecordIsNull( rec, iField )) return ERROR_FUNCTION_FAILED; @@ -1299,25 +1318,8 @@ static UINT get_table_value_from_record( MSITABLEVIEW *tv, MSIRECORD *rec, UINT } else *pvalue = 0; } - else if ( bytes_per_column( tv->db, &columninfo, LONG_STR_BYTES ) == 2 ) - { - ival = MSI_RecordGetInteger( rec, iField ); - if (ival == 0x80000000) *pvalue = 0x8000; - else - { - *pvalue = 0x8000 + MSI_RecordGetInteger( rec, iField ); - if (*pvalue & 0xffff0000) - { - ERR("field %u value %d out of range\n", iField, *pvalue - 0x8000); - return ERROR_FUNCTION_FAILED; - } - } - } else - { - ival = MSI_RecordGetInteger( rec, iField ); - *pvalue = ival ^ 0x80000000; - } + return int_to_table_storage( tv, iField, MSI_RecordGetInteger( rec, iField ), pvalue );
return ERROR_SUCCESS; } @@ -2370,14 +2372,11 @@ static UINT* msi_record_to_row( const MSITABLEVIEW *tv, MSIRECORD *rec ) } else { - data[i] = MSI_RecordGetInteger( rec, i+1 ); - - if (data[i] == MSI_NULL_INTEGER) - data[i] = 0; - else if ((tv->columns[i].type&0xff) == 2) - data[i] += 0x8000; - else - data[i] += 0x80000000; + if (int_to_table_storage( tv, i + 1, MSI_RecordGetInteger( rec, i + 1 ), &data[i] )) + { + msi_free( data ); + return NULL; + } } } return data;
In order to avoid the need to create a temporary record and copy values back and forth.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msi/alter.c | 2 ++ dlls/msi/create.c | 2 ++ dlls/msi/delete.c | 2 ++ dlls/msi/distinct.c | 2 ++ dlls/msi/drop.c | 2 ++ dlls/msi/insert.c | 2 ++ dlls/msi/msipriv.h | 14 +++++++++ dlls/msi/select.c | 26 ++++++----------- dlls/msi/storages.c | 8 +++++ dlls/msi/streams.c | 8 +++++ dlls/msi/table.c | 71 +++++++++++++++++++++++++++++++++++++++++++-- dlls/msi/update.c | 2 ++ dlls/msi/where.c | 42 +++++++++++++++++++++++++++ 13 files changed, 164 insertions(+), 19 deletions(-)
diff --git a/dlls/msi/alter.c b/dlls/msi/alter.c index 011a2dcfb8..96ff284a3d 100644 --- a/dlls/msi/alter.c +++ b/dlls/msi/alter.c @@ -229,6 +229,8 @@ static const MSIVIEWOPS alter_ops = NULL, NULL, NULL, + NULL, + NULL, ALTER_execute, ALTER_close, ALTER_get_dimensions, diff --git a/dlls/msi/create.c b/dlls/msi/create.c index dd4739df12..2777954aa7 100644 --- a/dlls/msi/create.c +++ b/dlls/msi/create.c @@ -130,6 +130,8 @@ static const MSIVIEWOPS create_ops = NULL, NULL, NULL, + NULL, + NULL, CREATE_execute, CREATE_close, CREATE_get_dimensions, diff --git a/dlls/msi/delete.c b/dlls/msi/delete.c index 468115186b..81bd9d7db2 100644 --- a/dlls/msi/delete.c +++ b/dlls/msi/delete.c @@ -172,6 +172,8 @@ static const MSIVIEWOPS delete_ops = NULL, NULL, NULL, + NULL, + NULL, DELETE_execute, DELETE_close, DELETE_get_dimensions, diff --git a/dlls/msi/distinct.c b/dlls/msi/distinct.c index b1945a1546..e102adb3de 100644 --- a/dlls/msi/distinct.c +++ b/dlls/msi/distinct.c @@ -255,6 +255,8 @@ static const MSIVIEWOPS distinct_ops = NULL, NULL, NULL, + NULL, + NULL, DISTINCT_execute, DISTINCT_close, DISTINCT_get_dimensions, diff --git a/dlls/msi/drop.c b/dlls/msi/drop.c index 3179f14219..89fac9dfc7 100644 --- a/dlls/msi/drop.c +++ b/dlls/msi/drop.c @@ -94,6 +94,8 @@ static UINT DROP_delete( struct tagMSIVIEW *view )
static const MSIVIEWOPS drop_ops = { + NULL, + NULL, NULL, NULL, NULL, diff --git a/dlls/msi/insert.c b/dlls/msi/insert.c index a5333c9cdc..f1185eebae 100644 --- a/dlls/msi/insert.c +++ b/dlls/msi/insert.c @@ -326,6 +326,8 @@ static const MSIVIEWOPS insert_ops = NULL, NULL, NULL, + NULL, + NULL, INSERT_execute, INSERT_close, INSERT_get_dimensions, diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 1cbeae4af0..e9c000de58 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -248,6 +248,20 @@ typedef struct tagMSIVIEWOPS */ UINT (*get_row)( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec );
+ /* + * set_int - set the integer value at {row, col} + * This function has undefined behaviour if the column does not contain + * integers. + */ + UINT (*set_int)( struct tagMSIVIEW *view, UINT row, UINT col, int val ); + + /* + * set_string - set the string value at {row, col} + * This function has undefined behaviour if the column does not contain + * strings. + */ + UINT (*set_string)( struct tagMSIVIEW *view, UINT row, UINT col, const WCHAR *val, int len ); + /* * set_row - sets values in a row as specified by mask * diff --git a/dlls/msi/select.c b/dlls/msi/select.c index e17cbbbdf2..91765c8ec3 100644 --- a/dlls/msi/select.c +++ b/dlls/msi/select.c @@ -247,16 +247,11 @@ static UINT msi_select_update(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row) MSISELECTVIEW *sv = (MSISELECTVIEW*)view; UINT r, i, num_columns, col, type, val; LPCWSTR str; - MSIRECORD *mod;
r = SELECT_get_dimensions(view, NULL, &num_columns); if (r != ERROR_SUCCESS) return r;
- r = sv->table->ops->get_row(sv->table, row, &mod); - if (r != ERROR_SUCCESS) - return r; - for (i = 0; i < num_columns; i++) { col = sv->cols[i]; @@ -265,39 +260,34 @@ static UINT msi_select_update(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row) if (r != ERROR_SUCCESS) { ERR("Failed to get column information: %d\n", r); - goto done; + return r; }
if (MSITYPE_IS_BINARY(type)) { ERR("Cannot modify binary data!\n"); - r = ERROR_FUNCTION_FAILED; - goto done; + return ERROR_FUNCTION_FAILED; } else if (type & MSITYPE_STRING) { int len; - str = msi_record_get_string( rec, i + 1, &len ); - r = msi_record_set_string( mod, col, str, len ); + str = msi_record_get_string(rec, i + 1, &len); + r = sv->table->ops->set_string(sv->table, row, col, str, len); } else { val = MSI_RecordGetInteger(rec, i + 1); - r = MSI_RecordSetInteger(mod, col, val); + r = sv->table->ops->set_int(sv->table, row, col, val); }
if (r != ERROR_SUCCESS) { ERR("Failed to modify record: %d\n", r); - goto done; + return r; } }
- r = sv->table->ops->modify(sv->table, MSIMODIFY_UPDATE, mod, row); - -done: - msiobj_release(&mod->hdr); - return r; + return ERROR_SUCCESS; }
static UINT SELECT_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode, @@ -336,6 +326,8 @@ static const MSIVIEWOPS select_ops = SELECT_fetch_int, SELECT_fetch_stream, SELECT_get_row, + NULL, + NULL, SELECT_set_row, SELECT_insert_row, NULL, diff --git a/dlls/msi/storages.c b/dlls/msi/storages.c index 4379ae268b..ad020dec55 100644 --- a/dlls/msi/storages.c +++ b/dlls/msi/storages.c @@ -124,6 +124,12 @@ static UINT STORAGES_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec return ERROR_CALL_NOT_IMPLEMENTED; }
+static UINT STORAGES_set_string( struct tagMSIVIEW *view, UINT row, UINT col, const WCHAR *val, int len ) +{ + ERR("Cannot modify primary key.\n"); + return ERROR_FUNCTION_FAILED; +} + static HRESULT stream_to_storage(IStream *stm, IStorage **stg) { ILockBytes *lockbytes = NULL; @@ -420,6 +426,8 @@ static const MSIVIEWOPS storages_ops = STORAGES_fetch_int, STORAGES_fetch_stream, STORAGES_get_row, + NULL, + STORAGES_set_string, STORAGES_set_row, STORAGES_insert_row, STORAGES_delete_row, diff --git a/dlls/msi/streams.c b/dlls/msi/streams.c index fc9f715bb6..ae45c1df8f 100644 --- a/dlls/msi/streams.c +++ b/dlls/msi/streams.c @@ -104,6 +104,12 @@ static UINT STREAMS_fetch_stream(struct tagMSIVIEW *view, UINT row, UINT col, IS return ERROR_SUCCESS; }
+static UINT STREAMS_set_string( struct tagMSIVIEW *view, UINT row, UINT col, const WCHAR *val, int len ) +{ + ERR("Cannot modify primary key.\n"); + return ERROR_FUNCTION_FAILED; +} + static UINT STREAMS_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec ) { MSISTREAMSVIEW *sv = (MSISTREAMSVIEW *)view; @@ -342,6 +348,8 @@ static const MSIVIEWOPS streams_ops = STREAMS_fetch_int, STREAMS_fetch_stream, STREAMS_get_row, + NULL, + STREAMS_set_string, STREAMS_set_row, STREAMS_insert_row, STREAMS_delete_row, diff --git a/dlls/msi/table.c b/dlls/msi/table.c index e4f6b56f18..a5de8ccf59 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -1164,7 +1164,8 @@ static UINT TABLE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, ISt return r; }
-static UINT TABLE_set_int( MSITABLEVIEW *tv, UINT row, UINT col, UINT val ) +/* Set a table value, i.e. preadjusted integer or string ID. */ +static UINT table_set_bytes( MSITABLEVIEW *tv, UINT row, UINT col, UINT val ) { UINT offset, n, i;
@@ -1221,6 +1222,70 @@ static UINT int_to_table_storage( const MSITABLEVIEW *tv, UINT col, int val, UIN return ERROR_SUCCESS; }
+static UINT TABLE_set_int( MSIVIEW *view, UINT row, UINT col, int val ) +{ + MSITABLEVIEW *tv = (MSITABLEVIEW *)view; + UINT r, table_int; + + TRACE("row %u, col %u, val %d.\n", row, col, val); + + if ((r = int_to_table_storage( tv, col, val, &table_int ))) + return r; + + if (tv->columns[col-1].type & MSITYPE_KEY) + { + UINT key; + + if ((r = TABLE_fetch_int( view, row, col, &key ))) + return r; + if (key != table_int) + { + ERR("Cannot modify primary key %s.%s.\n", + debugstr_w(tv->table->name), debugstr_w(tv->columns[col-1].colname)); + return ERROR_FUNCTION_FAILED; + } + } + + return table_set_bytes( tv, row, col, table_int ); +} + +static UINT TABLE_set_string( MSIVIEW *view, UINT row, UINT col, const WCHAR *val, int len ) +{ + MSITABLEVIEW *tv = (MSITABLEVIEW *)view; + BOOL persistent; + UINT id, r; + + TRACE("row %u, col %u, val %s.\n", row, col, debugstr_wn(val, len)); + + persistent = (tv->table->persistent != MSICONDITION_FALSE) + && tv->table->data_persistent[row]; + + if (val) + { + r = msi_string2id( tv->db->strings, val, len, &id ); + if (r != ERROR_SUCCESS) + id = msi_add_string( tv->db->strings, val, len, persistent ); + } + else + id = 0; + + if (tv->columns[col-1].type & MSITYPE_KEY) + { + UINT key; + + if ((r = TABLE_fetch_int( view, row, col, &key ))) + return r; + if (key != id) + { + ERR("Cannot modify primary key %s.%s.\n", + debugstr_w(tv->table->name), debugstr_w(tv->columns[col-1].colname)); + return ERROR_FUNCTION_FAILED; + } + } + + return table_set_bytes( tv, row, col, id ); +} + static UINT TABLE_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec ) { MSITABLEVIEW *tv = (MSITABLEVIEW *)view; @@ -1402,7 +1467,7 @@ static UINT TABLE_set_row( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UI } }
- r = TABLE_set_int( tv, row, i+1, val ); + r = table_set_bytes( tv, row, i+1, val ); if ( r != ERROR_SUCCESS ) break; } @@ -2060,6 +2125,8 @@ static const MSIVIEWOPS table_ops = TABLE_fetch_int, TABLE_fetch_stream, TABLE_get_row, + TABLE_set_int, + TABLE_set_string, TABLE_set_row, TABLE_insert_row, TABLE_delete_row, diff --git a/dlls/msi/update.c b/dlls/msi/update.c index ff4e1abf5f..e61342d11e 100644 --- a/dlls/msi/update.c +++ b/dlls/msi/update.c @@ -203,6 +203,8 @@ static const MSIVIEWOPS update_ops = NULL, NULL, NULL, + NULL, + NULL, UPDATE_execute, UPDATE_close, UPDATE_get_dimensions, diff --git a/dlls/msi/where.c b/dlls/msi/where.c index 234ba5e008..6a10a049a6 100644 --- a/dlls/msi/where.c +++ b/dlls/msi/where.c @@ -271,6 +271,46 @@ static UINT WHERE_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec ) return msi_view_get_row( wv->db, view, row, rec ); }
+static UINT WHERE_set_int(struct tagMSIVIEW *view, UINT row, UINT col, int val) +{ + MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view; + JOINTABLE *table; + UINT *rows; + UINT r; + + TRACE("view %p, row %u, col %u, val %d.\n", wv, row, col, val ); + + r = find_row(wv, row, &rows); + if (r != ERROR_SUCCESS) + return r; + + table = find_table(wv, col, &col); + if (!table) + return ERROR_FUNCTION_FAILED; + + return table->view->ops->set_int(table->view, rows[table->table_index], col, val); +} + +static UINT WHERE_set_string(struct tagMSIVIEW *view, UINT row, UINT col, const WCHAR *val, int len) +{ + MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view; + JOINTABLE *table; + UINT *rows; + UINT r; + + TRACE("view %p, row %u, col %u, val %s.\n", wv, row, col, debugstr_wn(val, len)); + + r = find_row(wv, row, &rows); + if (r != ERROR_SUCCESS) + return r; + + table = find_table(wv, col, &col); + if (!table) + return ERROR_FUNCTION_FAILED; + + return table->view->ops->set_string(table->view, rows[table->table_index], col, val, len); +} + static UINT WHERE_set_row( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask ) { MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view; @@ -1069,6 +1109,8 @@ static const MSIVIEWOPS where_ops = WHERE_fetch_int, WHERE_fetch_stream, WHERE_get_row, + WHERE_set_int, + WHERE_set_string, WHERE_set_row, NULL, WHERE_delete_row,
Signed-off-by: Hans Leidekker hans@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msi/alter.c | 10 ---------- dlls/msi/create.c | 1 - dlls/msi/delete.c | 1 - dlls/msi/distinct.c | 1 - dlls/msi/drop.c | 1 - dlls/msi/insert.c | 1 - dlls/msi/msipriv.h | 6 ------ dlls/msi/select.c | 13 ------------- dlls/msi/storages.c | 10 ---------- dlls/msi/streams.c | 10 ---------- dlls/msi/table.c | 1 - dlls/msi/update.c | 1 - dlls/msi/where.c | 13 ------------- 13 files changed, 69 deletions(-)
diff --git a/dlls/msi/alter.c b/dlls/msi/alter.c index 96ff284a3d..d1a481ebfc 100644 --- a/dlls/msi/alter.c +++ b/dlls/msi/alter.c @@ -61,15 +61,6 @@ static UINT ALTER_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, ISt return ERROR_FUNCTION_FAILED; }
-static UINT ALTER_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec ) -{ - MSIALTERVIEW *av = (MSIALTERVIEW*)view; - - TRACE("%p %d %p\n", av, row, rec ); - - return av->table->ops->get_row(av->table, row, rec); -} - static UINT ITERATE_columns(MSIRECORD *row, LPVOID param) { (*(UINT *)param)++; @@ -225,7 +216,6 @@ static const MSIVIEWOPS alter_ops = { ALTER_fetch_int, ALTER_fetch_stream, - ALTER_get_row, NULL, NULL, NULL, diff --git a/dlls/msi/create.c b/dlls/msi/create.c index 2777954aa7..3c00b70c53 100644 --- a/dlls/msi/create.c +++ b/dlls/msi/create.c @@ -131,7 +131,6 @@ static const MSIVIEWOPS create_ops = NULL, NULL, NULL, - NULL, CREATE_execute, CREATE_close, CREATE_get_dimensions, diff --git a/dlls/msi/delete.c b/dlls/msi/delete.c index 81bd9d7db2..e2e0e34678 100644 --- a/dlls/msi/delete.c +++ b/dlls/msi/delete.c @@ -173,7 +173,6 @@ static const MSIVIEWOPS delete_ops = NULL, NULL, NULL, - NULL, DELETE_execute, DELETE_close, DELETE_get_dimensions, diff --git a/dlls/msi/distinct.c b/dlls/msi/distinct.c index e102adb3de..5bd5bf8676 100644 --- a/dlls/msi/distinct.c +++ b/dlls/msi/distinct.c @@ -256,7 +256,6 @@ static const MSIVIEWOPS distinct_ops = NULL, NULL, NULL, - NULL, DISTINCT_execute, DISTINCT_close, DISTINCT_get_dimensions, diff --git a/dlls/msi/drop.c b/dlls/msi/drop.c index 89fac9dfc7..60a9202106 100644 --- a/dlls/msi/drop.c +++ b/dlls/msi/drop.c @@ -94,7 +94,6 @@ static UINT DROP_delete( struct tagMSIVIEW *view )
static const MSIVIEWOPS drop_ops = { - NULL, NULL, NULL, NULL, diff --git a/dlls/msi/insert.c b/dlls/msi/insert.c index f1185eebae..ed913c034c 100644 --- a/dlls/msi/insert.c +++ b/dlls/msi/insert.c @@ -327,7 +327,6 @@ static const MSIVIEWOPS insert_ops = NULL, NULL, NULL, - NULL, INSERT_execute, INSERT_close, INSERT_get_dimensions, diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index e9c000de58..3ff5ac2350 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -242,12 +242,6 @@ typedef struct tagMSIVIEWOPS */ UINT (*fetch_stream)( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm );
- /* - * get_row - gets values from a row - * - */ - UINT (*get_row)( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec ); - /* * set_int - set the integer value at {row, col} * This function has undefined behaviour if the column does not contain diff --git a/dlls/msi/select.c b/dlls/msi/select.c index 91765c8ec3..99339c24b8 100644 --- a/dlls/msi/select.c +++ b/dlls/msi/select.c @@ -90,18 +90,6 @@ static UINT SELECT_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, IS return sv->table->ops->fetch_stream( sv->table, row, col, stm ); }
-static UINT SELECT_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec ) -{ - MSISELECTVIEW *sv = (MSISELECTVIEW *)view; - - TRACE("%p %d %p\n", sv, row, rec ); - - if( !sv->table ) - return ERROR_FUNCTION_FAILED; - - return msi_view_get_row(sv->db, view, row, rec); -} - static UINT SELECT_set_row( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask ) { MSISELECTVIEW *sv = (MSISELECTVIEW*)view; @@ -325,7 +313,6 @@ static const MSIVIEWOPS select_ops = { SELECT_fetch_int, SELECT_fetch_stream, - SELECT_get_row, NULL, NULL, SELECT_set_row, diff --git a/dlls/msi/storages.c b/dlls/msi/storages.c index ad020dec55..9e161c9e1b 100644 --- a/dlls/msi/storages.c +++ b/dlls/msi/storages.c @@ -115,15 +115,6 @@ static UINT STORAGES_fetch_stream(struct tagMSIVIEW *view, UINT row, UINT col, I return ERROR_INVALID_DATA; }
-static UINT STORAGES_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec ) -{ - MSISTORAGESVIEW *sv = (MSISTORAGESVIEW *)view; - - FIXME("%p %d %p\n", sv, row, rec); - - return ERROR_CALL_NOT_IMPLEMENTED; -} - static UINT STORAGES_set_string( struct tagMSIVIEW *view, UINT row, UINT col, const WCHAR *val, int len ) { ERR("Cannot modify primary key.\n"); @@ -425,7 +416,6 @@ static const MSIVIEWOPS storages_ops = { STORAGES_fetch_int, STORAGES_fetch_stream, - STORAGES_get_row, NULL, STORAGES_set_string, STORAGES_set_row, diff --git a/dlls/msi/streams.c b/dlls/msi/streams.c index ae45c1df8f..2d458adb68 100644 --- a/dlls/msi/streams.c +++ b/dlls/msi/streams.c @@ -110,15 +110,6 @@ static UINT STREAMS_set_string( struct tagMSIVIEW *view, UINT row, UINT col, con return ERROR_FUNCTION_FAILED; }
-static UINT STREAMS_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec ) -{ - MSISTREAMSVIEW *sv = (MSISTREAMSVIEW *)view; - - TRACE("%p %d %p\n", sv, row, rec); - - return msi_view_get_row( sv->db, view, row, rec ); -} - static UINT STREAMS_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask) { MSISTREAMSVIEW *sv = (MSISTREAMSVIEW *)view; @@ -347,7 +338,6 @@ static const MSIVIEWOPS streams_ops = { STREAMS_fetch_int, STREAMS_fetch_stream, - STREAMS_get_row, NULL, STREAMS_set_string, STREAMS_set_row, diff --git a/dlls/msi/table.c b/dlls/msi/table.c index a5de8ccf59..f26ab9f5b4 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -2124,7 +2124,6 @@ static const MSIVIEWOPS table_ops = { TABLE_fetch_int, TABLE_fetch_stream, - TABLE_get_row, TABLE_set_int, TABLE_set_string, TABLE_set_row, diff --git a/dlls/msi/update.c b/dlls/msi/update.c index e61342d11e..af629d2236 100644 --- a/dlls/msi/update.c +++ b/dlls/msi/update.c @@ -204,7 +204,6 @@ static const MSIVIEWOPS update_ops = NULL, NULL, NULL, - NULL, UPDATE_execute, UPDATE_close, UPDATE_get_dimensions, diff --git a/dlls/msi/where.c b/dlls/msi/where.c index 6a10a049a6..eaadac4310 100644 --- a/dlls/msi/where.c +++ b/dlls/msi/where.c @@ -259,18 +259,6 @@ static UINT WHERE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, ISt return table->view->ops->fetch_stream( table->view, rows[table->table_index], col, stm ); }
-static UINT WHERE_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec ) -{ - MSIWHEREVIEW *wv = (MSIWHEREVIEW *)view; - - TRACE("%p %d %p\n", wv, row, rec ); - - if (!wv->tables) - return ERROR_FUNCTION_FAILED; - - return msi_view_get_row( wv->db, view, row, rec ); -} - static UINT WHERE_set_int(struct tagMSIVIEW *view, UINT row, UINT col, int val) { MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view; @@ -1108,7 +1096,6 @@ static const MSIVIEWOPS where_ops = { WHERE_fetch_int, WHERE_fetch_stream, - WHERE_get_row, WHERE_set_int, WHERE_set_string, WHERE_set_row,
Signed-off-by: Hans Leidekker hans@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msi/select.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/dlls/msi/select.c b/dlls/msi/select.c index 99339c24b8..c6e7b20903 100644 --- a/dlls/msi/select.c +++ b/dlls/msi/select.c @@ -233,14 +233,10 @@ static UINT SELECT_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *na static UINT msi_select_update(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row) { MSISELECTVIEW *sv = (MSISELECTVIEW*)view; - UINT r, i, num_columns, col, type, val; + UINT r, i, col, type, val; LPCWSTR str;
- r = SELECT_get_dimensions(view, NULL, &num_columns); - if (r != ERROR_SUCCESS) - return r; - - for (i = 0; i < num_columns; i++) + for (i = 0; i < sv->num_cols; i++) { col = sv->cols[i];
Signed-off-by: Hans Leidekker hans@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msi/storages.c | 66 +++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 44 deletions(-)
diff --git a/dlls/msi/storages.c b/dlls/msi/storages.c index 9e161c9e1b..76a0e2e03f 100644 --- a/dlls/msi/storages.c +++ b/dlls/msi/storages.c @@ -50,7 +50,7 @@ typedef struct tagMSISTORAGESVIEW { MSIVIEW view; MSIDATABASE *db; - STORAGE **storages; + STORAGE *storages; UINT max_storages; UINT num_rows; UINT row_size; @@ -61,7 +61,7 @@ static BOOL storages_set_table_size(MSISTORAGESVIEW *sv, UINT size) if (size >= sv->max_storages) { sv->max_storages *= 2; - sv->storages = msi_realloc(sv->storages, sv->max_storages * sizeof(STORAGE *)); + sv->storages = msi_realloc(sv->storages, sv->max_storages * sizeof(*sv->storages)); if (!sv->storages) return FALSE; } @@ -69,23 +69,6 @@ static BOOL storages_set_table_size(MSISTORAGESVIEW *sv, UINT size) return TRUE; }
-static STORAGE *create_storage(MSISTORAGESVIEW *sv, LPCWSTR name, IStorage *stg) -{ - STORAGE *storage; - - storage = msi_alloc(sizeof(STORAGE)); - if (!storage) - return NULL; - - storage->str_index = msi_add_string(sv->db->strings, name, -1, FALSE); - storage->storage = stg; - - if (storage->storage) - IStorage_AddRef(storage->storage); - - return storage; -} - static UINT STORAGES_fetch_int(struct tagMSIVIEW *view, UINT row, UINT col, UINT *val) { MSISTORAGESVIEW *sv = (MSISTORAGESVIEW *)view; @@ -98,7 +81,7 @@ static UINT STORAGES_fetch_int(struct tagMSIVIEW *view, UINT row, UINT col, UINT if (row >= sv->num_rows) return ERROR_NO_MORE_ITEMS;
- *val = sv->storages[row]->str_index; + *val = sv->storages[row].str_index;
return ERROR_SUCCESS; } @@ -173,7 +156,7 @@ done: static UINT STORAGES_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask) { MSISTORAGESVIEW *sv = (MSISTORAGESVIEW *)view; - IStorage *stg, *substg = NULL; + IStorage *stg, *substg = NULL, *prev; IStream *stm; LPWSTR name = NULL; HRESULT hr; @@ -181,7 +164,7 @@ static UINT STORAGES_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec,
TRACE("(%p, %p)\n", view, rec);
- if (row > sv->num_rows) + if (row >= sv->num_rows) return ERROR_FUNCTION_FAILED;
r = MSI_RecordGetIStream(rec, 2, &stm); @@ -218,9 +201,11 @@ static UINT STORAGES_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, goto done; }
- sv->storages[row] = create_storage(sv, name, stg); - if (!sv->storages[row]) - r = ERROR_FUNCTION_FAILED; + prev = sv->storages[row].storage; + sv->storages[row].str_index = msi_add_string(sv->db->strings, name, -1, FALSE); + IStorage_AddRef(stg); + sv->storages[row].storage = stg; + if (prev) IStorage_Release(prev);
done: msi_free(name); @@ -242,6 +227,8 @@ static UINT STORAGES_insert_row(struct tagMSIVIEW *view, MSIRECORD *rec, UINT ro if (row == -1) row = sv->num_rows - 1;
+ memset(&sv->storages[row], 0, sizeof(sv->storages[row])); + /* FIXME have to readjust rows */
return STORAGES_set_row(view, row, rec, 0); @@ -400,9 +387,8 @@ static UINT STORAGES_delete(struct tagMSIVIEW *view)
for (i = 0; i < sv->num_rows; i++) { - if (sv->storages[i]->storage) - IStorage_Release(sv->storages[i]->storage); - msi_free(sv->storages[i]); + if (sv->storages[i].storage) + IStorage_Release(sv->storages[i].storage); }
msi_free(sv->storages); @@ -436,7 +422,6 @@ static const MSIVIEWOPS storages_ops =
static INT add_storages_to_table(MSISTORAGESVIEW *sv) { - STORAGE *storage = NULL; IEnumSTATSTG *stgenum = NULL; STATSTG stat; HRESULT hr; @@ -447,7 +432,7 @@ static INT add_storages_to_table(MSISTORAGESVIEW *sv) return -1;
sv->max_storages = 1; - sv->storages = msi_alloc(sizeof(STORAGE *)); + sv->storages = msi_alloc(sizeof(*sv->storages)); if (!sv->storages) return -1;
@@ -466,26 +451,19 @@ static INT add_storages_to_table(MSISTORAGESVIEW *sv)
TRACE("enumerated storage %s\n", debugstr_w(stat.pwcsName));
- storage = create_storage(sv, stat.pwcsName, NULL); - if (!storage) - { - count = -1; - CoTaskMemFree(stat.pwcsName); - break; - } - - IStorage_OpenStorage(sv->db->storage, stat.pwcsName, NULL, - STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, - &storage->storage); - CoTaskMemFree(stat.pwcsName); - if (!storages_set_table_size(sv, ++count)) { count = -1; break; }
- sv->storages[count - 1] = storage; + sv->storages[count - 1].str_index = msi_add_string(sv->db->strings, stat.pwcsName, -1, FALSE); + sv->storages[count - 1].storage = NULL; + + IStorage_OpenStorage(sv->db->storage, stat.pwcsName, NULL, + STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, + &sv->storages[count - 1].storage); + CoTaskMemFree(stat.pwcsName); }
IEnumSTATSTG_Release(stgenum);
Signed-off-by: Hans Leidekker hans@codeweavers.com