#include <stdarg.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wine/debug.h"
#include "msi.h"
#include "msiquery.h"
#include "objbase.h"
#include "objidl.h"
#include "msipriv.h"
#include "winnls.h"
#include "query.h"
Go to the source code of this file.
|
| WINE_DEFAULT_DEBUG_CHANNEL (msidb) |
|
static BOOL | validate_codepage (UINT codepage) |
|
static string_table * | init_stringtable (int entries, UINT codepage) |
|
VOID | msi_destroy_stringtable (string_table *st) |
|
static int | st_find_free_entry (string_table *st) |
|
static int | cmp_string (const WCHAR *str1, int len1, const WCHAR *str2, int len2) |
|
static int | find_insert_index (const string_table *st, UINT string_id) |
|
static void | insert_string_sorted (string_table *st, UINT string_id) |
|
static void | set_st_entry (string_table *st, UINT n, WCHAR *str, int len, USHORT refcount, BOOL persistent) |
|
static UINT | string2id (const string_table *st, const char *buffer, UINT *id) |
|
static int | add_string (string_table *st, UINT n, const char *data, UINT len, USHORT refcount, BOOL persistent) |
|
int | msi_add_string (string_table *st, const WCHAR *data, int len, BOOL persistent) |
|
const WCHAR * | msi_string_lookup (const string_table *st, UINT id, int *len) |
|
static UINT | id2string (const string_table *st, UINT id, char *buffer, UINT *sz) |
|
UINT | msi_string2id (const string_table *st, const WCHAR *str, int len, UINT *id) |
|
static void | string_totalsize (const string_table *st, UINT *datasize, UINT *poolsize) |
|
HRESULT | msi_init_string_table (IStorage *stg) |
|
string_table * | msi_load_string_table (IStorage *stg, UINT *bytes_per_strref) |
|
UINT | msi_save_string_table (const string_table *st, IStorage *storage, UINT *bytes_per_strref) |
|
UINT | msi_get_string_table_codepage (const string_table *st) |
|
UINT | msi_set_string_table_codepage (string_table *st, UINT codepage) |
|
◆ COBJMACROS
◆ add_string()
Definition at line 257 of file string.c.
258{
260 int sz;
261
263 return 0;
265 {
266 if( st->
strings[
n].persistent_refcount ||
267 st->
strings[
n].nonpersistent_refcount )
268 return -1;
269 }
270 else
271 {
273 {
274 if (persistent)
275 st->
strings[
n].persistent_refcount += refcount;
276 else
277 st->
strings[
n].nonpersistent_refcount += refcount;
279 }
282 return -1;
283 }
284
286 {
288 return -1;
289 }
290
291
295 return -1;
298
301}
#define MultiByteToWideChar
static int st_find_free_entry(string_table *st)
static void set_st_entry(string_table *st, UINT n, WCHAR *str, int len, USHORT refcount, BOOL persistent)
static UINT string2id(const string_table *st, const char *buffer, UINT *id)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
struct msistring * strings
Referenced by msi_load_string_table().
◆ cmp_string()
Definition at line 163 of file string.c.
164{
165 if (len1 < len2) return -1;
166 else if (len1 > len2) return 1;
167 while (len1)
168 {
169 if (*str1 == *str2) { str1++; str2++; }
170 else return *str1 - *str2;
171 len1--;
172 }
173 return 0;
174}
Referenced by find_insert_index(), and msi_string2id().
◆ find_insert_index()
Definition at line 176 of file string.c.
177{
179
180 while (low <= high)
181 {
182 i = (low + high) / 2;
189 else
190 return -1;
191 }
192 return high + 1;
193}
static int cmp_string(const WCHAR *str1, int len1, const WCHAR *str2, int len2)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Referenced by insert_string_sorted().
◆ id2string()
Definition at line 372 of file string.c.
373{
376
378
382
385 {
388 }
391}
#define WideCharToMultiByte
const WCHAR * msi_string_lookup(const string_table *st, UINT id, int *len)
#define ERROR_FUNCTION_FAILED
Referenced by msi_save_string_table().
◆ init_stringtable()
Definition at line 71 of file string.c.
72{
74
77
79 if( !st )
81 if( entries < 1 )
82 entries = 1;
83
86 {
89 }
90
93 {
97 }
98
103
104 return st;
105}
static BOOL validate_codepage(UINT codepage)
Referenced by msi_load_string_table().
◆ insert_string_sorted()
Definition at line 195 of file string.c.
196{
198
201 return;
202
206}
static int find_insert_index(const string_table *st, UINT string_id)
#define memmove(s1, s2, n)
Referenced by set_st_entry().
◆ msi_add_string()
Definition at line 303 of file string.c.
304{
307
309 return 0;
310
312
314 return 0;
315
317 {
318 if (persistent)
319 st->
strings[
n].persistent_refcount++;
320 else
321 st->
strings[
n].nonpersistent_refcount++;
323 }
324
327 return -1;
328
329
331
334 return -1;
337
340}
UINT msi_string2id(const string_table *st, const WCHAR *str, int len, UINT *id)
#define memcpy(s1, s2, n)
Referenced by add_storages_to_table(), append_stream(), msi_create_table(), STORAGES_set_row(), STREAMS_set_row(), TABLE_add_column(), TABLE_set_row(), and TABLE_set_string().
◆ msi_destroy_stringtable()
◆ msi_get_string_table_codepage()
◆ msi_init_string_table()
Definition at line 460 of file string.c.
461{
464
465
469
470
474
476}
UINT write_stream_data(IStorage *stg, LPCWSTR stname, LPCVOID data, UINT sz, BOOL bTable)
Referenced by db_initialize().
◆ msi_load_string_table()
Definition at line 478 of file string.c.
479{
485
492
493 if ( (poolsize > 4) && (
pool[1] & 0x8000) )
495 else
496 *bytes_per_strref =
sizeof(
USHORT);
497
499 if( poolsize > 4 )
501 else
504 if (!st)
506
511 {
512
514
515
516 if (
pool[
i*2] == 0 && refs == 0)
517 {
520 continue;
521 }
522
523
524
525
526
527
529 {
532 }
533 else
534 {
537 }
538
540 {
541 ERR(
"string table corrupt?\n");
542 break;
543 }
544
547 ERR(
"Failed to add string %lu\n",
n );
550 }
551
553 ERR(
"string table load failed! (%u != %lu), please report\n",
datasize,
offset );
554
556
560
561 return st;
562}
static int add_string(string_table *st, UINT n, const char *data, UINT len, USHORT refcount, BOOL persistent)
static string_table * init_stringtable(int entries, UINT codepage)
GLuint GLuint GLsizei count
GLdouble GLdouble GLdouble r
static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream)
Referenced by MSI_OpenDatabaseW(), and msi_table_apply_transform().
◆ msi_save_string_table()
Definition at line 564 of file string.c.
565{
570
572
573
575
577
580 {
581 WARN(
"Failed to alloc pool %d bytes\n", poolsize );
583 }
586 {
589 }
590
596 {
599 }
600 else
601 *bytes_per_strref =
sizeof(
USHORT);
602
605 {
606 if( !st->
strings[
i].persistent_refcount )
607 {
611 continue;
612 }
613
617 {
618 ERR(
"failed to fetch string\n");
619 sz = 0;
620 }
621
622 if (sz)
624 else
626 if (sz < 0x10000)
627 {
630 }
631 else
632 {
634 pool[
n*2 + 2 ] = sz&0xffff;
635 pool[
n*2 + 3 ] = (sz>>16);
637 }
640 {
643 }
644 }
645
647 {
650 }
651
652
654 TRACE(
"Wrote StringData r=%08x\n",
r);
658 TRACE(
"Wrote StringPool r=%08x\n",
r);
661
663
667
669}
static UINT id2string(const string_table *st, UINT id, char *buffer, UINT *sz)
static void string_totalsize(const string_table *st, UINT *datasize, UINT *poolsize)
Referenced by MSI_CommitTables().
◆ msi_set_string_table_codepage()
◆ msi_string2id()
Definition at line 400 of file string.c.
401{
403
405
406 while (low <= high)
407 {
408 i = (low + high) / 2;
410
415 else
416 {
419 }
420 }
422}
#define ERROR_INVALID_PARAMETER
Referenced by find_stream(), get_table_value_from_record(), get_tablecolumns(), join_find_row(), msi_add_string(), record_to_row(), storages_find_row(), streams_find_row(), string2id(), TABLE_add_column(), TABLE_Exists(), TABLE_set_string(), and TransformView_Create().
◆ msi_string_lookup()
Definition at line 343 of file string.c.
344{
345 if( id == 0 )
346 {
349 }
352
353 if(
id && !st->
strings[
id].persistent_refcount && !st->
strings[
id].nonpersistent_refcount)
355
357
359}
Referenced by dump_table(), get_stream_name(), get_tablecolumns(), get_transform_record(), id2string(), msi_commit_streams(), msi_create_table(), msi_view_refresh_row(), STORAGES_set_stream(), STREAMS_delete_row(), STRING_evaluate(), TABLE_add_column(), TransformView_Create(), and TransformView_drop_table().
◆ set_st_entry()
Definition at line 208 of file string.c.
210{
211 if (persistent)
212 {
213 st->
strings[
n].persistent_refcount = refcount;
214 st->
strings[
n].nonpersistent_refcount = 0;
215 }
216 else
217 {
218 st->
strings[
n].persistent_refcount = 0;
219 st->
strings[
n].nonpersistent_refcount = refcount;
220 }
221
224
226
227 if( n < st->maxcount )
229}
static void insert_string_sorted(string_table *st, UINT string_id)
Referenced by add_string(), and msi_add_string().
◆ st_find_free_entry()
Definition at line 122 of file string.c.
123{
126
128
130 {
131 for(
i = st->
freeslot; i < st->maxcount;
i++ )
132 if( !st->
strings[
i].persistent_refcount &&
133 !st->
strings[
i].nonpersistent_refcount )
135 }
137 if( !st->
strings[
i].persistent_refcount &&
138 !st->
strings[
i].nonpersistent_refcount )
140
141
145
147 {
149 return -1;
150 }
151
154
159 ERR(
"oops. expected freeslot to be free...\n");
161}
Referenced by add_string(), and msi_add_string().
◆ string2id()
Definition at line 231 of file string.c.
232{
233 int sz;
236
238
240 {
241 *id = 0;
243 }
244
251
255}
#define ERROR_NOT_ENOUGH_MEMORY
Referenced by add_string().
◆ string_totalsize()
Definition at line 424 of file string.c.
425{
427
428 if( st->
strings[0].data || st->
strings[0].persistent_refcount || st->
strings[0].nonpersistent_refcount)
429 ERR(
"oops. element 0 has a string\n");
430
431 *poolsize = 4;
433 holesize = 0;
435 {
436 if( !st->
strings[
i].persistent_refcount )
437 {
439 (*poolsize) += 4;
440 }
442 {
450 (*poolsize) += 4;
451 (*poolsize) += holesize + 4;
452 holesize = 0;
453 }
454 else
455 holesize += 4;
456 }
458}
Referenced by msi_save_string_table().
◆ validate_codepage()
static BOOL validate_codepage |
( |
UINT |
codepage | ) |
|
|
static |
◆ WINE_DEFAULT_DEBUG_CHANNEL()
WINE_DEFAULT_DEBUG_CHANNEL |
( |
msidb |
| ) |
|