41#define MSITABLE_HASH_TABLE_SIZE 37
87#define MAX_STREAM_NAME 0x1f
95 return bytes_per_strref;
97 if( (col->
type & 0xff) <= 2)
100 if( (col->
type & 0xff) != 4 )
101 ERR(
"Invalid column size %u\n", col->
type & 0xff);
108 if( (
x>=
'0') && (
x<=
'9') )
110 if( (
x>=
'A') && (
x<=
'Z') )
112 if( (
x>=
'a') && (
x<=
'z') )
145 if( ( ch < 0x80 ) && (
utf2mime(ch) >= 0 ) )
174 return x - 10 - 26 +
'a';
175 if(
x == (10+26+26) )
185 while ( (ch = *
in++) )
187 if( (ch >= 0x3800 ) && (ch < 0x4840 ) )
214 r = IStorage_EnumElements( stg, 0,
NULL, 0, &stgenum );
222 r = IEnumSTATSTG_Next( stgenum, 1, &
stat, &
count );
231 IEnumSTATSTG_Release( stgenum );
249 r = IStorage_OpenStream(stg, encname,
NULL,
254 WARN(
"open stream failed r = %#lx - empty table?\n",
r );
258 r = IStream_Stat(stm, &
stat, STATFLAG_NONAME );
261 WARN(
"open stream failed r = %#lx!\n",
r );
265 if(
stat.cbSize.QuadPart >> 32 )
271 sz =
stat.cbSize.QuadPart;
275 WARN(
"couldn't allocate memory r = %#lx!\n",
r );
284 WARN(
"read stream failed r = %#lx!\n",
r);
293 IStream_Release( stm );
310 r = IStorage_OpenStream( stg, encname,
NULL,
314 r = IStorage_CreateStream( stg, encname,
320 WARN(
"open stream failed r = %#lx\n",
r );
325 r = IStream_SetSize( stm,
size );
328 WARN(
"Failed to SetSize\n");
333 r = IStream_Seek( stm,
pos, STREAM_SEEK_SET,
NULL );
336 WARN(
"Failed to Seek\n");
345 WARN(
"Failed to Write\n");
353 IStream_Release( stm );
389 last_col = &cols[
count - 1];
397 UINT rawsize = 0,
i,
j, row_size, row_size_mem;
409 TRACE(
"Read %d bytes\n", rawsize );
411 if( rawsize % row_size )
413 WARN(
"Table size is invalid %d/%d\n", rawsize, row_size );
417 if ((
t->row_count = rawsize / row_size))
420 if (!(
t->data_persistent =
calloc(
t->row_count,
sizeof(
BOOL) )))
goto err;
424 TRACE(
"Transposing data from %d rows\n",
t->row_count );
425 for (
i = 0;
i <
t->row_count;
i++)
427 UINT ofs = 0, ofs_mem = 0;
429 t->data[
i] =
malloc( row_size_mem );
432 t->data_persistent[
i] =
TRUE;
434 for (
j = 0;
j <
t->col_count;
j++)
440 if (
n != 2 &&
n != 3 &&
n != 4 )
442 ERR(
"oops - unknown column width %d\n",
n);
447 for (
k = 0;
k <
m;
k++)
450 t->data[
i][ofs_mem +
k] = rawdata[ofs *
t->row_count +
i *
n +
k];
452 t->data[
i][ofs_mem +
k] = 0;
457 for (
k = 0;
k <
n;
k++)
458 t->data[
i][ofs_mem +
k] = rawdata[ofs *
t->row_count +
i *
n +
k];
498 for (
i = 0; colinfo &&
i <
count;
i++)
505 TRACE(
"column %d is [%s] with type %08x ofs %d\n",
530 for (
i = 0;
i <
n;
i++)
532 if (colinfo &&
i < *sz) colinfo[
i] =
p[
i];
533 if (colinfo &&
i >= *sz)
break;
544 UINT r, column_count = 0;
553 *pcount = column_count;
561 columns =
malloc( column_count *
sizeof(*columns) );
593 table->row_count = 0;
597 table->col_count = 0;
646 ERR(
"couldn't load _Columns table\n");
657 TRACE(
"Table id is %d, row count is %d\n", table_id,
table->row_count);
662 if (colinfo)
memset( colinfo, 0, maxcount *
sizeof(*colinfo) );
673 if (col < 1 || col > maxcount)
675 ERR(
"column %d out of range (maxcount: %d)\n", col, maxcount);
679 if (colinfo[col - 1].
number)
681 ERR(
"duplicate column %d\n", col);
685 colinfo[col - 1].
number = col;
688 sizeof(
USHORT) ) - (1 << 15);
689 colinfo[col - 1].
offset = 0;
696 if (colinfo &&
n != maxcount)
698 ERR(
"missing column in table %s\n",
debugstr_w(szTableName));
728 table->ref_count = 0;
729 table->row_count = 0;
733 table->col_count = 0;
734 table->persistent = persistent;
740 for( col = col_info; col; col = col->next )
750 for(
i = 0, col = col_info; col;
i++, col = col->next )
756 table->colinfo[
i ].number =
i + 1;
759 table->colinfo[
i ].offset = 0;
765 TRACE(
"CreateView returned %x\n",
r);
773 TRACE(
"tv execute returned %x\n",
r);
786 TRACE(
"insert_row returned %x\n",
r);
804 TRACE(
"tv execute returned %x\n",
r);
821 for( col = col_info; col; col = col->next )
863 UINT rawsize,
i,
j, row_size, row_count;
873 row_count =
t->row_count;
874 for (
i = 0;
i <
t->row_count;
i++)
876 if (!
t->data_persistent[
i])
882 rawsize = row_count * row_size;
883 rawdata =
calloc( 1, rawsize );
891 for (
i = 0;
i < row_count;
i++)
893 UINT ofs = 0, ofs_mem = 0;
895 if (!
t->data_persistent[
i])
break;
897 for (
j = 0;
j <
t->col_count;
j++)
903 if (
n != 2 &&
n != 3 &&
n != 4)
905 ERR(
"oops - unknown column width %d\n",
n);
911 if (
id > 1 << bytes_per_strref * 8)
913 ERR(
"string id %u out of range\n",
id);
917 for (
k = 0;
k <
n;
k++)
919 rawdata[ofs * row_count +
i *
n +
k] =
t->data[
i][ofs_mem +
k];
927 TRACE(
"writing %d bytes\n", rawsize);
942 old_count =
table->col_count;
948 if (!
table->col_count)
return;
953 for (
n = 0;
n <
table->row_count;
n++ )
956 if (old_count < table->col_count)
981 ERR(
"table _Tables not available\n");
985 for(
i = 0;
i <
table->row_count;
i++ )
1015 if( (col==0) || (col>tv->
num_cols) )
1030 if (
n != 2 &&
n != 3 &&
n != 4)
1032 ERR(
"oops! what is %d bytes per column?\n",
n );
1097 ERR(
"oops - unknown column width %d\n",
n );
1140 if( !
view->ops->fetch_int )
1146 ERR(
"fetching stream, error = %u\n",
r);
1166 if( (col==0) || (col>tv->
num_cols) )
1183 if (
n != 2 &&
n != 3 &&
n != 4 )
1185 ERR(
"oops! what is %d bytes per column?\n",
n );
1190 for (
i = 0;
i <
n;
i++ )
1202 else if ((
val + 0x8000) & 0xffff0000)
1204 ERR(
"value %d out of range\n",
val);
1221 TRACE(
"row %u, col %u, val %d.\n",
row, col,
val);
1232 if (
key != table_int)
1234 ERR(
"Cannot modify primary key %s.%s.\n",
1271 ERR(
"Cannot modify primary key %s.%s.\n",
1407 if ( !(
mask&(1<<
i)) )
1433 IStream_Release( stm );
1438 IStream_Release( stm );
1482 BOOL **data_persist_ptr;
1485 TRACE(
"%p %s\n",
view, temporary ?
"TRUE" :
"FALSE");
1500 sz = (*row_count + 1) *
sizeof (
BYTE*);
1511 sz = (*row_count + 1) *
sizeof (
BOOL);
1512 if( *data_persist_ptr )
1513 b =
realloc( *data_persist_ptr, sz );
1524 (*data_ptr)[*row_count] =
row;
1526 *data_persist_ptr =
b;
1527 (*data_persist_ptr)[*row_count] = !temporary;
1590 *table_name = tv->
columns[
n-1].tablename;
1617 TRACE(
"skipping binary column\n");
1665 WARN(
"TABLE_fetch_int should not fail here %u\n",
r);
1672 else if (ivalue ==
x)
1674 if (i < tv->
num_cols - 1)
continue;
1687 TRACE(
"%p %p\n", tv, rec);
1691 idx = (low + high) / 2;
1704 TRACE(
"found %u\n", high + 1);
1713 TRACE(
"%p %p %s\n", tv, rec, temporary ?
"TRUE" :
"FALSE" );
1724 TRACE(
"insert_row returned %08x\n",
r);
1794 ERR(
"can't find row to modify\n");
1846 TRACE(
"%p %d %p\n",
view, eModifyMode, rec );
1848 switch (eModifyMode)
1904 FIXME(
"%p %d %p - mode not implemented\n",
view, eModifyMode, rec );
2212 WARN(
"table not found\n");
2324 static const WCHAR query_pfx[] =
2325 L"INSERT INTO `_TransformView` (`new`, `Table`, `Column`, `Row`, `Data`, `Current`) VALUES (1, '";
2337 ERR(
"trying to modify existing column\n" );
2343 ERR(
"trying to modify existing table\n" );
2357 if (!(
mask & (1 <<
i)))
2470 static const WCHAR query_fmt[] =
2471 L"INSERT INTO `_TransformView` (`Table`, `Column`, `new`) VALUES ('%s', 'CREATE', 1)";
2505 static const WCHAR query_pfx[] =
2506 L"INSERT INTO `_TransformView` (`new`, `Table`, `Current`, `Column`, `Data`) VALUES (1, '";
2513 qlen =
p =
wcslen( query_pfx );
2514 for (
i = 1;
i <= 4;
i++)
2531 for (
i = 1;
i <= 4;
i++)
2559 static const WCHAR query_fmt[] =
2560 L"INSERT INTO `_TransformView` (`new`, `Table`, `Column`, `Row`) VALUES (1, '%s', 'INSERT', '%s')";
2608 static const WCHAR query_pfx[] =
L"INSERT INTO `_TransformView` ( `new`, `Table`, `Column` ) VALUES ( 1, '";
2609 static const WCHAR query_sfx[] =
L"', 'DROP' )";
2652 static const WCHAR query_pfx[] =
L"INSERT INTO `_TransformView` ( `new`, `Table`, `Column`, `Row`) VALUES ( 1, '";
2653 static const WCHAR query_column[] =
L"', 'DELETE', '";
2654 static const WCHAR query_sfx[] =
L"')";
2664 ERR(
"trying to remove column\n");
2770 static const WCHAR query_pfx[] =
L"SELECT `Column`, `Data`, `Current` FROM `_TransformView` WHERE `Table`='";
2771 static const WCHAR query_sfx[] =
L"' AND `Row` IS NULL AND `Current` IS NOT NULL AND `new` = 1";
2833 r =
q->view->ops->get_dimensions(
q->view, &add_col,
NULL );
2888 UINT r, bytes_per_strref;
2897 WARN(
"failed to save string table r=%08x\n",
r);
2906 WARN(
"failed to save table %s (r=%08x)\n",
2915 WARN(
"failed to commit changes %#lx\n",
hr );
2935 return t->persistent;
2954 TRACE(
"%p %p\n", tv, rec);
2978 const BYTE *rawdata,
UINT bytes_per_strref )
2985 mask = rawdata[0] | (rawdata[1] << 8);
3036 ofs += bytes_per_strref;
3047 TRACE(
" field %d [0x%04x]\n",
i+1,
val );
3053 TRACE(
" field %d [0x%08x]\n",
i+1,
val );
3056 ERR(
"oops - unknown column width %d\n",
n);
3068 for (
i = 0;
i < rawsize / 2;
i++)
3133 ERR(
"TABLE_fetch_int shouldn't fail here\n");
3176 UINT bytes_per_strref,
int err_cond )
3213 TRACE(
"name = %s columns = %u row_size = %u raw size = %u\n",
3217 for (
n = 0;
n < rawsize;)
3219 mask = rawdata[
n] | (rawdata[
n + 1] << 8);
3238 sz += bytes_per_strref;
3261 sz += bytes_per_strref;
3269 if (
n + sz > rawsize)
3317 TRACE(
"deleting row [%d]:\n",
row);
3320 WARN(
"failed to delete row %u\n",
r);
3324 TRACE(
"modifying full row [%d]:\n",
row);
3327 WARN(
"failed to modify row %u\n",
r);
3331 TRACE(
"modifying masked row [%d]:\n",
row);
3334 WARN(
"failed to modify row %u\n",
r);
3339 TRACE(
"inserting row\n");
3342 WARN(
"failed to insert row %u\n",
r);
3370 struct list transforms;
3378 UINT bytes_per_strref;
3382 TRACE(
"%p %p\n", db, stg );
3388 hr = IStorage_EnumElements( stg, 0,
NULL, 0, &stgenum );
3400 hr = IEnumSTATSTG_Next( stgenum, 1, &
stat, &
count );
3406 if (
name[0] != 0x4840 )
3426 property_update =
TRUE;
3446 L"`Table` CHAR(0) NOT NULL TEMPORARY, `Column` CHAR(0) NOT NULL TEMPORARY, "
3447 L"`Row` CHAR(0) TEMPORARY, `Data` CHAR(0) TEMPORARY, `Current` CHAR(0) TEMPORARY "
3448 L"PRIMARY KEY `Table`, `Column`, `Row` ) HOLD";
3514 IEnumSTATSTG_Release( stgenum );
static unsigned char bytes[4]
#define InterlockedIncrement
#define InterlockedDecrement
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
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 int find_insert_index(struct table_view *tv, MSIRECORD *rec)
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 UINT table_update(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row)
static UINT TransformView_delete(MSIVIEW *view)
static UINT TABLE_add_column(struct tagMSIVIEW *view, LPCWSTR column, INT type, BOOL hold)
static UINT get_stream_name(const struct table_view *tv, UINT row, WCHAR **pstname)
static UINT TransformView_add_column(struct table_view *tv, MSIRECORD *rec)
static UINT TABLE_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask)
static UINT table_load_transform(MSIDATABASE *db, IStorage *stg, string_table *st, struct transform_data *transform, UINT bytes_per_strref, int err_cond)
static UINT record_encoded_stream_name(const struct table_view *tv, MSIRECORD *rec, WCHAR **pstname)
static UINT TABLE_get_dimensions(struct tagMSIVIEW *view, UINT *rows, UINT *cols)
BOOL TABLE_Exists(MSIDATABASE *db, LPCWSTR name)
static void free_table(MSITABLE *table)
static UINT TABLE_drop(struct tagMSIVIEW *view)
static UINT TABLE_close(struct tagMSIVIEW *view)
static UINT TABLE_fetch_stream(struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm)
static MSITABLE * find_cached_table(MSIDATABASE *db, LPCWSTR name)
static const MSIVIEWOPS transform_view_ops
static UINT refresh_record(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row)
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 int_to_table_storage(const struct table_view *tv, UINT col, int val, UINT *ret)
static UINT TABLE_release(struct tagMSIVIEW *view)
static UINT table_find_row(struct table_view *, MSIRECORD *, UINT *, UINT *)
static UINT table_validate_new(struct table_view *tv, MSIRECORD *rec, UINT *column)
static UINT bytes_per_column(MSIDATABASE *db, const struct column_info *col, UINT bytes_per_strref)
static int mime2utf(int x)
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 * record_to_row(const struct table_view *tv, MSIRECORD *rec)
static WCHAR * create_key_string(struct table_view *tv, MSIRECORD *rec)
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)
BOOL decode_streamname(LPCWSTR in, LPWSTR out)
static UINT table_assign(struct tagMSIVIEW *view, MSIRECORD *rec)
static int compare_record(struct table_view *tv, UINT row, MSIRECORD *rec)
static UINT get_tablecolumns(MSIDATABASE *, const WCHAR *, struct column_info *, UINT *)
static UINT get_defaulttablecolumns(MSIDATABASE *db, const WCHAR *name, struct column_info *colinfo, UINT *sz)
static UINT row_matches(struct table_view *tv, UINT row, const UINT *data, UINT *column)
static UINT TransformView_execute(MSIVIEW *view, MSIRECORD *record)
static UINT table_get_column_info(MSIDATABASE *db, const WCHAR *name, struct column_info **pcols, UINT *pcount)
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 const struct column_info _Tables_cols[1]
static MSIRECORD * get_transform_record(const struct table_view *tv, const string_table *st, IStorage *stg, const BYTE *rawdata, UINT bytes_per_strref)
void enum_stream_names(IStorage *stg)
MSICONDITION MSI_DatabaseIsTablePersistent(MSIDATABASE *db, LPCWSTR table)
static UINT TransformView_delete_row(MSIVIEW *view, UINT row)
static UINT read_table_from_storage(MSIDATABASE *db, MSITABLE *t, IStorage *stg)
static const struct column_info _Columns_cols[4]
static UINT record_stream_name(const struct table_view *tv, MSIRECORD *rec, WCHAR *name, DWORD *len)
static UINT TransformView_Create(MSIDATABASE *db, string_table *st, LPCWSTR name, MSIVIEW **view)
static UINT TransformView_close(MSIVIEW *view)
static UINT TABLE_fetch_int(struct tagMSIVIEW *view, UINT row, UINT col, UINT *val)
static void free_colinfo(struct column_info *colinfo, UINT count)
static UINT table_set_bytes(struct table_view *tv, UINT row, UINT col, UINT val)
static UINT table_create_new_row(struct tagMSIVIEW *view, UINT *num, BOOL temporary)
UINT read_stream_data(IStorage *stg, LPCWSTR stname, BOOL table, BYTE **pdata, UINT *psz)
void free_cached_tables(MSIDATABASE *db)
static UINT TransformView_create_table(struct table_view *tv, MSIRECORD *rec)
static UINT add_stream(MSIDATABASE *db, const WCHAR *name, IStream *data)
static UINT TransformView_set_row(MSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask)
UINT TABLE_CreateView(MSIDATABASE *db, LPCWSTR name, MSIVIEW **view)
static UINT table_get_row_size(MSIDATABASE *db, const struct column_info *cols, UINT count, UINT bytes_per_strref)
static UINT read_raw_int(const BYTE *data, UINT col, UINT bytes)
static void update_table_columns(MSIDATABASE *db, const WCHAR *name)
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)
static UINT get_table_value_from_record(struct table_view *tv, MSIRECORD *rec, UINT iField, UINT *pvalue)
static void table_calc_column_offsets(MSIDATABASE *db, struct column_info *colinfo, DWORD count)
static UINT TransformView_drop_table(struct table_view *tv, UINT row)
UINT write_stream_data(IStorage *stg, LPCWSTR stname, LPCVOID data, UINT sz, BOOL bTable)
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 count
GLuint GLuint GLsizei GLenum type
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
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf