41#define MSITABLE_HASH_TABLE_SIZE 37
85#define MAX_STREAM_NAME 0x1f
93 return bytes_per_strref;
95 if( (col->
type & 0xff) <= 2)
98 if( (col->
type & 0xff) != 4 )
99 ERR(
"Invalid column size %u\n", col->
type & 0xff);
106 if( (
x>=
'0') && (
x<=
'9') )
108 if( (
x>=
'A') && (
x<=
'Z') )
110 if( (
x>=
'a') && (
x<=
'z') )
143 if( ( ch < 0x80 ) && (
utf2mime(ch) >= 0 ) )
172 return x - 10 - 26 +
'a';
173 if(
x == (10+26+26) )
183 while ( (ch = *
in++) )
185 if( (ch >= 0x3800 ) && (ch < 0x4840 ) )
212 r = IStorage_EnumElements( stg, 0,
NULL, 0, &stgenum );
220 r = IEnumSTATSTG_Next( stgenum, 1, &
stat, &
count );
229 IEnumSTATSTG_Release( stgenum );
247 r = IStorage_OpenStream(stg, encname,
NULL,
252 WARN(
"open stream failed r = %#lx - empty table?\n",
r );
256 r = IStream_Stat(stm, &
stat, STATFLAG_NONAME );
259 WARN(
"open stream failed r = %#lx!\n",
r );
263 if(
stat.cbSize.QuadPart >> 32 )
269 sz =
stat.cbSize.QuadPart;
273 WARN(
"couldn't allocate memory r = %#lx!\n",
r );
282 WARN(
"read stream failed r = %#lx!\n",
r);
291 IStream_Release( stm );
308 r = IStorage_OpenStream( stg, encname,
NULL,
312 r = IStorage_CreateStream( stg, encname,
318 WARN(
"open stream failed r = %#lx\n",
r );
323 r = IStream_SetSize( stm,
size );
326 WARN(
"Failed to SetSize\n");
331 r = IStream_Seek( stm,
pos, STREAM_SEEK_SET,
NULL );
334 WARN(
"Failed to Seek\n");
343 WARN(
"Failed to Write\n");
351 IStream_Release( stm );
387 last_col = &cols[
count - 1];
395 UINT rawsize = 0,
i,
j, row_size, row_size_mem;
407 TRACE(
"Read %d bytes\n", rawsize );
409 if( rawsize % row_size )
411 WARN(
"Table size is invalid %d/%d\n", rawsize, row_size );
415 if ((
t->row_count = rawsize / row_size))
422 TRACE(
"Transposing data from %d rows\n",
t->row_count );
423 for (
i = 0;
i <
t->row_count;
i++)
425 UINT ofs = 0, ofs_mem = 0;
430 t->data_persistent[
i] =
TRUE;
432 for (
j = 0;
j <
t->col_count;
j++)
438 if (
n != 2 &&
n != 3 &&
n != 4 )
440 ERR(
"oops - unknown column width %d\n",
n);
445 for (
k = 0;
k <
m;
k++)
448 t->data[
i][ofs_mem +
k] = rawdata[ofs *
t->row_count +
i *
n +
k];
450 t->data[
i][ofs_mem +
k] = 0;
455 for (
k = 0;
k <
n;
k++)
456 t->data[
i][ofs_mem +
k] = rawdata[ofs *
t->row_count +
i *
n +
k];
496 for (
i = 0; colinfo &&
i <
count;
i++)
503 TRACE(
"column %d is [%s] with type %08x ofs %d\n",
528 for (
i = 0;
i <
n;
i++)
530 if (colinfo &&
i < *sz) colinfo[
i] =
p[
i];
531 if (colinfo &&
i >= *sz)
break;
542 UINT r, column_count = 0;
551 *pcount = column_count;
591 table->row_count = 0;
595 table->col_count = 0;
644 ERR(
"couldn't load _Columns table\n");
655 TRACE(
"Table id is %d, row count is %d\n", table_id,
table->row_count);
660 if (colinfo)
memset( colinfo, 0, maxcount *
sizeof(*colinfo) );
671 if (col < 1 || col > maxcount)
673 ERR(
"column %d out of range (maxcount: %d)\n", col, maxcount);
677 if (colinfo[col - 1].
number)
679 ERR(
"duplicate column %d\n", col);
683 colinfo[col - 1].
number = col;
686 sizeof(
USHORT) ) - (1 << 15);
687 colinfo[col - 1].
offset = 0;
694 if (colinfo &&
n != maxcount)
696 ERR(
"missing column in table %s\n",
debugstr_w(szTableName));
726 table->ref_count = 0;
727 table->row_count = 0;
731 table->col_count = 0;
732 table->persistent = persistent;
738 for( col = col_info; col; col = col->
next )
748 for(
i = 0, col = col_info; col;
i++, col = col->
next )
754 table->colinfo[
i ].number =
i + 1;
757 table->colinfo[
i ].offset = 0;
763 TRACE(
"CreateView returned %x\n",
r);
771 TRACE(
"tv execute returned %x\n",
r);
784 TRACE(
"insert_row returned %x\n",
r);
802 TRACE(
"tv execute returned %x\n",
r);
819 for( col = col_info; col; col = col->
next )
861 UINT rawsize,
i,
j, row_size, row_count;
871 row_count =
t->row_count;
872 for (
i = 0;
i <
t->row_count;
i++)
874 if (!
t->data_persistent[
i])
880 rawsize = row_count * row_size;
889 for (
i = 0;
i < row_count;
i++)
891 UINT ofs = 0, ofs_mem = 0;
893 if (!
t->data_persistent[
i])
break;
895 for (
j = 0;
j <
t->col_count;
j++)
901 if (
n != 2 &&
n != 3 &&
n != 4)
903 ERR(
"oops - unknown column width %d\n",
n);
909 if (
id > 1 << bytes_per_strref * 8)
911 ERR(
"string id %u out of range\n",
id);
915 for (
k = 0;
k <
n;
k++)
917 rawdata[ofs * row_count +
i *
n +
k] =
t->data[
i][ofs_mem +
k];
925 TRACE(
"writing %d bytes\n", rawsize);
940 old_count =
table->col_count;
946 if (!
table->col_count)
return;
951 for (
n = 0;
n <
table->row_count;
n++ )
954 if (old_count < table->col_count)
979 ERR(
"table _Tables not available\n");
983 for(
i = 0;
i <
table->row_count;
i++ )
1013 if( (col==0) || (col>tv->
num_cols) )
1028 if (
n != 2 &&
n != 3 &&
n != 4)
1030 ERR(
"oops! what is %d bytes per column?\n",
n );
1095 ERR(
"oops - unknown column width %d\n",
n );
1138 if( !
view->ops->fetch_int )
1144 ERR(
"fetching stream, error = %u\n",
r);
1164 if( (col==0) || (col>tv->
num_cols) )
1181 if (
n != 2 &&
n != 3 &&
n != 4 )
1183 ERR(
"oops! what is %d bytes per column?\n",
n );
1188 for (
i = 0;
i <
n;
i++ )
1200 else if ((
val + 0x8000) & 0xffff0000)
1202 ERR(
"value %d out of range\n",
val);
1219 TRACE(
"row %u, col %u, val %d.\n",
row, col,
val);
1230 if (
key != table_int)
1232 ERR(
"Cannot modify primary key %s.%s.\n",
1269 ERR(
"Cannot modify primary key %s.%s.\n",
1405 if ( !(
mask&(1<<
i)) )
1431 IStream_Release( stm );
1436 IStream_Release( stm );
1480 BOOL **data_persist_ptr;
1483 TRACE(
"%p %s\n",
view, temporary ?
"TRUE" :
"FALSE");
1498 sz = (*row_count + 1) *
sizeof (
BYTE*);
1509 sz = (*row_count + 1) *
sizeof (
BOOL);
1510 if( *data_persist_ptr )
1522 (*data_ptr)[*row_count] =
row;
1524 *data_persist_ptr =
b;
1525 (*data_persist_ptr)[*row_count] = !temporary;
1615 TRACE(
"skipping binary column\n");
1663 WARN(
"TABLE_fetch_int should not fail here %u\n",
r);
1670 else if (ivalue ==
x)
1672 if (i < tv->
num_cols - 1)
continue;
1685 TRACE(
"%p %p\n", tv, rec);
1689 idx = (low + high) / 2;
1702 TRACE(
"found %u\n", high + 1);
1711 TRACE(
"%p %p %s\n", tv, rec, temporary ?
"TRUE" :
"FALSE" );
1722 TRACE(
"insert_row returned %08x\n",
r);
1792 ERR(
"can't find row to modify\n");
1844 TRACE(
"%p %d %p\n",
view, eModifyMode, rec );
1846 switch (eModifyMode)
1902 FIXME(
"%p %d %p - mode not implemented\n",
view, eModifyMode, rec );
2210 WARN(
"table not found\n");
2322 static const WCHAR query_pfx[] =
2323 L"INSERT INTO `_TransformView` (`new`, `Table`, `Column`, `Row`, `Data`, `Current`) VALUES (1, '";
2335 ERR(
"trying to modify existing column\n" );
2341 ERR(
"trying to modify existing table\n" );
2355 if (!(
mask & (1 <<
i)))
2468 static const WCHAR query_fmt[] =
2469 L"INSERT INTO `_TransformView` (`Table`, `Column`, `new`) VALUES ('%s', 'CREATE', 1)";
2503 static const WCHAR query_pfx[] =
2504 L"INSERT INTO `_TransformView` (`new`, `Table`, `Current`, `Column`, `Data`) VALUES (1, '";
2511 qlen =
p =
wcslen( query_pfx );
2512 for (
i = 1;
i <= 4;
i++)
2529 for (
i = 1;
i <= 4;
i++)
2557 static const WCHAR query_fmt[] =
2558 L"INSERT INTO `_TransformView` (`new`, `Table`, `Column`, `Row`) VALUES (1, '%s', 'INSERT', '%s')";
2606 static const WCHAR query_pfx[] =
L"INSERT INTO `_TransformView` ( `new`, `Table`, `Column` ) VALUES ( 1, '";
2607 static const WCHAR query_sfx[] =
L"', 'DROP' )";
2650 static const WCHAR query_pfx[] =
L"INSERT INTO `_TransformView` ( `new`, `Table`, `Column`, `Row`) VALUES ( 1, '";
2651 static const WCHAR query_column[] =
L"', 'DELETE', '";
2652 static const WCHAR query_sfx[] =
L"')";
2662 ERR(
"trying to remove column\n");
2768 static const WCHAR query_pfx[] =
L"SELECT `Column`, `Data`, `Current` FROM `_TransformView` WHERE `Table`='";
2769 static const WCHAR query_sfx[] =
L"' AND `Row` IS NULL AND `Current` IS NOT NULL AND `new` = 1";
2836 r =
q->view->ops->get_dimensions(
q->view, &add_col,
NULL );
2889 UINT r, bytes_per_strref;
2898 WARN(
"failed to save string table r=%08x\n",
r);
2907 WARN(
"failed to save table %s (r=%08x)\n",
2916 WARN(
"failed to commit changes %#lx\n",
hr );
2936 return t->persistent;
2955 TRACE(
"%p %p\n", tv, rec);
2986 mask = rawdata[0] | (rawdata[1] << 8);
3037 ofs += bytes_per_strref;
3048 TRACE(
" field %d [0x%04x]\n",
i+1,
val );
3054 TRACE(
" field %d [0x%08x]\n",
i+1,
val );
3057 ERR(
"oops - unknown column width %d\n",
n);
3069 for (
i = 0;
i < rawsize / 2;
i++)
3134 ERR(
"TABLE_fetch_int shouldn't fail here\n");
3178 UINT bytes_per_strref,
int err_cond )
3215 TRACE(
"name = %s columns = %u row_size = %u raw size = %u\n",
3219 for (
n = 0;
n < rawsize;)
3221 mask = rawdata[
n] | (rawdata[
n + 1] << 8);
3240 sz += bytes_per_strref;
3263 sz += bytes_per_strref;
3271 if (
n + sz > rawsize)
3319 TRACE(
"deleting row [%d]:\n",
row);
3322 WARN(
"failed to delete row %u\n",
r);
3326 TRACE(
"modifying full row [%d]:\n",
row);
3329 WARN(
"failed to modify row %u\n",
r);
3333 TRACE(
"modifying masked row [%d]:\n",
row);
3336 WARN(
"failed to modify row %u\n",
r);
3341 TRACE(
"inserting row\n");
3344 WARN(
"failed to insert row %u\n",
r);
3373 struct list transforms;
3381 UINT bytes_per_strref;
3385 TRACE(
"%p %p\n", db, stg );
3391 hr = IStorage_EnumElements( stg, 0,
NULL, 0, &stgenum );
3403 hr = IEnumSTATSTG_Next( stgenum, 1, &
stat, &
count );
3409 if (
name[0] != 0x4840 )
3429 property_update =
TRUE;
3449 L"`Table` CHAR(0) NOT NULL TEMPORARY, `Column` CHAR(0) NOT NULL TEMPORARY, "
3450 L"`Row` CHAR(0) TEMPORARY, `Data` CHAR(0) TEMPORARY, `Current` CHAR(0) TEMPORARY "
3451 L"PRIMARY KEY `Table`, `Column`, `Row` ) HOLD";
3517 IEnumSTATSTG_Release( stgenum );
static unsigned char bytes[4]
#define InterlockedIncrement
#define InterlockedDecrement
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
static WCHAR * strdupW(const WCHAR *src)
static void list_remove(struct list_entry *entry)
static int list_empty(struct list_entry *head)
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
static void list_add_head(struct list_entry *head, struct list_entry *entry)
static void list_init(struct list_entry *head)
#define ERROR_NOT_ENOUGH_MEMORY
static void transform_view(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
#define ERROR_CALL_NOT_IMPLEMENTED
#define ERROR_INVALID_PARAMETER
#define ERROR_NO_MORE_ITEMS
void append_storage_to_db(MSIDATABASE *db, IStorage *stg)
int msiobj_release(MSIOBJECTHDR *info)
static UINT TABLE_get_row(struct tagMSIVIEW *view, UINT row, MSIRECORD **rec)
static void dump_table(const string_table *st, const USHORT *rawdata, UINT rawsize)
static UINT save_table(MSIDATABASE *db, const MSITABLE *t, UINT bytes_per_strref)
static const MSIVIEWOPS table_ops
static UINT TABLE_modify(struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *rec, UINT row)
static UINT TABLE_insert_row(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row, BOOL temporary)
static UINT TABLE_delete_row(struct tagMSIVIEW *view, UINT row)
UINT msi_create_table(MSIDATABASE *db, LPCWSTR name, column_info *col_info, MSICONDITION persistent, BOOL hold)
static int utf2mime(int x)
static UINT TransformView_get_column_info(MSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
static UINT TransformView_insert_row(MSIVIEW *view, MSIRECORD *rec, UINT row, BOOL temporary)
static UINT TABLE_delete(struct tagMSIVIEW *view)
static void msi_free_colinfo(MSICOLUMNINFO *colinfo, UINT count)
static UINT msi_table_load_transform(MSIDATABASE *db, IStorage *stg, string_table *st, TRANSFORMDATA *transform, UINT bytes_per_strref, int err_cond)
static const MSICOLUMNINFO _Columns_cols[4]
static UINT TransformView_delete(MSIVIEW *view)
static UINT TABLE_add_column(struct tagMSIVIEW *view, LPCWSTR column, INT type, BOOL hold)
struct tagMSICOLUMNHASHENTRY MSICOLUMNHASHENTRY
static UINT TABLE_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask)
static UINT TransformView_add_column(MSITABLEVIEW *tv, MSIRECORD *rec)
static UINT TABLE_get_dimensions(struct tagMSIVIEW *view, UINT *rows, UINT *cols)
static UINT int_to_table_storage(const MSITABLEVIEW *tv, UINT col, int val, UINT *ret)
static int find_insert_index(MSITABLEVIEW *tv, MSIRECORD *rec)
BOOL TABLE_Exists(MSIDATABASE *db, LPCWSTR name)
static void free_table(MSITABLE *table)
static UINT msi_record_encoded_stream_name(const MSITABLEVIEW *tv, MSIRECORD *rec, LPWSTR *pstname)
static UINT table_validate_new(MSITABLEVIEW *tv, MSIRECORD *rec, UINT *column)
static UINT msi_table_assign(struct tagMSIVIEW *view, MSIRECORD *rec)
static UINT TABLE_drop(struct tagMSIVIEW *view)
static UINT TABLE_close(struct tagMSIVIEW *view)
static UINT msi_table_find_row(MSITABLEVIEW *tv, MSIRECORD *rec, UINT *row, UINT *column)
static WCHAR * create_key_string(MSITABLEVIEW *tv, MSIRECORD *rec)
static UINT TABLE_fetch_stream(struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm)
static MSITABLE * find_cached_table(MSIDATABASE *db, LPCWSTR name)
static UINT msi_refresh_record(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row)
static const MSIVIEWOPS transform_view_ops
static UINT TABLE_set_int(MSIVIEW *view, UINT row, UINT col, int val)
static UINT TransformView_fetch_stream(MSIVIEW *view, UINT row, UINT col, IStream **stm)
static UINT TransformView_get_dimensions(MSIVIEW *view, UINT *rows, UINT *cols)
static UINT TABLE_add_ref(struct tagMSIVIEW *view)
static UINT TABLE_release(struct tagMSIVIEW *view)
static UINT msi_row_matches(MSITABLEVIEW *tv, UINT row, const UINT *data, UINT *column)
static void msi_update_table_columns(MSIDATABASE *db, LPCWSTR name)
static int mime2utf(int x)
struct tagMSICOLUMNINFO MSICOLUMNINFO
LPWSTR encode_streamname(BOOL bTable, LPCWSTR in)
static UINT TransformView_fetch_int(MSIVIEW *view, UINT row, UINT col, UINT *val)
static UINT TABLE_remove_column(struct tagMSIVIEW *view, UINT number)
static UINT table_set_bytes(MSITABLEVIEW *tv, UINT row, UINT col, UINT val)
struct tagMSITABLEVIEW MSITABLEVIEW
UINT msi_table_apply_transform(MSIDATABASE *db, IStorage *stg, int err_cond)
static UINT get_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table_ret)
static UINT TABLE_execute(struct tagMSIVIEW *view, MSIRECORD *record)
static UINT read_table_int(BYTE *const *data, UINT row, UINT col, UINT bytes)
static MSIRECORD * msi_get_transform_record(const MSITABLEVIEW *tv, const string_table *st, IStorage *stg, const BYTE *rawdata, UINT bytes_per_strref)
BOOL decode_streamname(LPCWSTR in, LPWSTR out)
static UINT msi_record_stream_name(const MSITABLEVIEW *tv, MSIRECORD *rec, LPWSTR name, DWORD *len)
static UINT TransformView_drop_table(MSITABLEVIEW *tv, UINT row)
static UINT TransformView_create_table(MSITABLEVIEW *tv, MSIRECORD *rec)
static UINT TransformView_execute(MSIVIEW *view, MSIRECORD *record)
static UINT TABLE_set_stream(MSIVIEW *view, UINT row, UINT col, IStream *stream)
static UINT TABLE_set_string(MSIVIEW *view, UINT row, UINT col, const WCHAR *val, int len)
static UINT table_get_column_info(MSIDATABASE *db, LPCWSTR name, MSICOLUMNINFO **pcols, UINT *pcount)
void enum_stream_names(IStorage *stg)
static int compare_record(MSITABLEVIEW *tv, UINT row, MSIRECORD *rec)
MSICONDITION MSI_DatabaseIsTablePersistent(MSIDATABASE *db, LPCWSTR table)
static UINT TransformView_delete_row(MSIVIEW *view, UINT row)
static const MSICOLUMNINFO _Tables_cols[1]
static UINT read_table_from_storage(MSIDATABASE *db, MSITABLE *t, IStorage *stg)
static UINT TransformView_close(MSIVIEW *view)
static UINT TABLE_fetch_int(struct tagMSIVIEW *view, UINT row, UINT col, UINT *val)
static UINT msi_table_update(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row)
static UINT bytes_per_column(MSIDATABASE *db, const MSICOLUMNINFO *col, UINT bytes_per_strref)
static UINT table_create_new_row(struct tagMSIVIEW *view, UINT *num, BOOL temporary)
static UINT * msi_record_to_row(const MSITABLEVIEW *tv, MSIRECORD *rec)
UINT read_stream_data(IStorage *stg, LPCWSTR stname, BOOL table, BYTE **pdata, UINT *psz)
void free_cached_tables(MSIDATABASE *db)
static UINT get_tablecolumns(MSIDATABASE *db, LPCWSTR szTableName, MSICOLUMNINFO *colinfo, UINT *sz)
static void table_calc_column_offsets(MSIDATABASE *db, MSICOLUMNINFO *colinfo, DWORD count)
static UINT add_stream(MSIDATABASE *db, const WCHAR *name, IStream *data)
static UINT get_defaulttablecolumns(MSIDATABASE *db, LPCWSTR name, MSICOLUMNINFO *colinfo, UINT *sz)
UINT TransformView_Create(MSIDATABASE *db, string_table *st, LPCWSTR name, MSIVIEW **view)
static UINT TransformView_set_row(MSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask)
UINT TABLE_CreateView(MSIDATABASE *db, LPCWSTR name, MSIVIEW **view)
static UINT get_stream_name(const MSITABLEVIEW *tv, UINT row, WCHAR **pstname)
static UINT read_raw_int(const BYTE *data, UINT col, UINT bytes)
static UINT TABLE_get_column_info(struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
UINT MSI_CommitTables(MSIDATABASE *db)
UINT write_stream_data(IStorage *stg, LPCWSTR stname, LPCVOID data, UINT sz, BOOL bTable)
static UINT get_table_value_from_record(MSITABLEVIEW *tv, MSIRECORD *rec, UINT iField, UINT *pvalue)
static UINT msi_table_get_row_size(MSIDATABASE *db, const MSICOLUMNINFO *cols, UINT count, UINT bytes_per_strref)
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
struct nls_table * tables
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei GLenum type
GLuint GLuint GLsizei count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble r
GLdouble GLdouble GLdouble GLdouble q
GLuint GLenum GLenum transform
GLsizei const GLchar *const * strings