summaryrefslogtreecommitdiffstats
path: root/libmsi
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-12-05 10:11:47 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2012-12-06 20:30:34 +0100
commit1222609fc5d9c980c1da9fb839f86455047c7c91 (patch)
tree745775fe5729f7cfa13dc99f9ff085f7aa52caca /libmsi
parent175346aac4942eb97ccf2f00ca127cf700cd2eff (diff)
downloadmsitools-1222609fc5d9c980c1da9fb839f86455047c7c91.tar.gz
msitools-1222609fc5d9c980c1da9fb839f86455047c7c91.tar.xz
msitools-1222609fc5d9c980c1da9fb839f86455047c7c91.zip
eliminate WCHAR
Diffstat (limited to 'libmsi')
-rw-r--r--libmsi/Makefile.am3
-rw-r--r--libmsi/alter.c16
-rw-r--r--libmsi/create.c12
-rw-r--r--libmsi/database.c460
-rw-r--r--libmsi/delete.c4
-rw-r--r--libmsi/distinct.c4
-rw-r--r--libmsi/drop.c4
-rw-r--r--libmsi/insert.c22
-rw-r--r--libmsi/msipriv.h167
-rw-r--r--libmsi/msiquery.c124
-rw-r--r--libmsi/query.h28
-rw-r--r--libmsi/record.c115
-rw-r--r--libmsi/select.c14
-rw-r--r--libmsi/sql-parser.y48
-rw-r--r--libmsi/storages.c14
-rw-r--r--libmsi/streams.c20
-rw-r--r--libmsi/string.c110
-rw-r--r--libmsi/suminfo.c36
-rw-r--r--libmsi/table.c367
-rw-r--r--libmsi/tokenize.c10
-rw-r--r--libmsi/unicode.h155
-rw-r--r--libmsi/update.c6
-rw-r--r--libmsi/utf16/snprintfW.c38
-rw-r--r--libmsi/utf16/sprintfW.c38
-rw-r--r--libmsi/utf16/strtolW.c176
-rw-r--r--libmsi/where.c30
26 files changed, 715 insertions, 1306 deletions
diff --git a/libmsi/Makefile.am b/libmsi/Makefile.am
index a7bccde..7e38a78 100644
--- a/libmsi/Makefile.am
+++ b/libmsi/Makefile.am
@@ -17,8 +17,7 @@ noinst_HEADERS = \
libmsi_la_SOURCES = alter.c create.c database.c delete.c distinct.c \
drop.c handle.c insert.c msiquery.c record.c select.c storages.c \
streams.c string.c suminfo.c table.c tokenize.c update.c where.c \
- sql-parser.y \
- utf16/snprintfW.c utf16/sprintfW.c utf16/strtolW.c
+ sql-parser.y
libmsi_la_LDFLAGS = -no-undefined -rpath $(libdir) \
-export-symbols-regex='^libmsi_'
diff --git a/libmsi/alter.c b/libmsi/alter.c
index 9e1e5d9..7110f05 100644
--- a/libmsi/alter.c
+++ b/libmsi/alter.c
@@ -74,13 +74,13 @@ static unsigned count_iter(LibmsiRecord *row, void *param)
return LIBMSI_RESULT_SUCCESS;
}
-static bool check_column_exists(LibmsiDatabase *db, const WCHAR *table, const WCHAR *column)
+static bool check_column_exists(LibmsiDatabase *db, const char *table, const char *column)
{
LibmsiQuery *view;
LibmsiRecord *rec;
unsigned r;
- static const WCHAR query[] = {
+ static const char query[] = {
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
'`','_','C','o','l','u','m','n','s','`',' ','W','H','E','R','E',' ',
'`','T','a','b','l','e','`','=','\'','%','s','\'',' ','A','N','D',' ',
@@ -110,8 +110,8 @@ static unsigned alter_add_column(LibmsiAlterView *av)
LibmsiQuery *view;
LibmsiView *columns;
- static const WCHAR szColumns[] = {'_','C','o','l','u','m','n','s',0};
- static const WCHAR query[] = {
+ static const char szColumns[] = {'_','C','o','l','u','m','n','s',0};
+ static const char query[] = {
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
'`','_','C','o','l','u','m','n','s','`',' ','W','H','E','R','E',' ',
'`','T','a','b','l','e','`','=','\'','%','s','\'',' ','O','R','D','E','R',' ',
@@ -187,8 +187,8 @@ static unsigned alter_view_get_dimensions( LibmsiView *view, unsigned *rows, uns
return LIBMSI_RESULT_FUNCTION_FAILED;
}
-static unsigned alter_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name,
- unsigned *type, bool *temporary, const WCHAR **table_name )
+static unsigned alter_view_get_column_info( LibmsiView *view, unsigned n, const char **name,
+ unsigned *type, bool *temporary, const char **table_name )
{
LibmsiAlterView *av = (LibmsiAlterView*)view;
@@ -239,12 +239,12 @@ static const LibmsiViewOps alter_ops =
NULL,
};
-unsigned alter_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR *name, column_info *colinfo, int hold )
+unsigned alter_view_create( LibmsiDatabase *db, LibmsiView **view, const char *name, column_info *colinfo, int hold )
{
LibmsiAlterView *av;
unsigned r;
- TRACE("%p %p %s %d\n", view, colinfo, debugstr_w(name), hold );
+ TRACE("%p %p %s %d\n", view, colinfo, debugstr_a(name), hold );
av = msi_alloc_zero( sizeof *av );
if( !av )
diff --git a/libmsi/create.c b/libmsi/create.c
index 49a021d..567fe77 100644
--- a/libmsi/create.c
+++ b/libmsi/create.c
@@ -41,7 +41,7 @@ typedef struct LibmsiCreateView
{
LibmsiView view;
LibmsiDatabase *db;
- const WCHAR * name;
+ const char * name;
bool bIsTemp;
bool hold;
column_info *col_info;
@@ -61,7 +61,7 @@ static unsigned create_view_execute( LibmsiView *view, LibmsiRecord *record )
LibmsiCreateView *cv = (LibmsiCreateView*)view;
bool persist = (cv->bIsTemp) ? LIBMSI_CONDITION_FALSE : LIBMSI_CONDITION_TRUE;
- TRACE("%p Table %s (%s)\n", cv, debugstr_w(cv->name),
+ TRACE("%p Table %s (%s)\n", cv, debugstr_a(cv->name),
cv->bIsTemp?"temporary":"permanent");
if (cv->bIsTemp && !cv->hold)
@@ -88,8 +88,8 @@ static unsigned create_view_get_dimensions( LibmsiView *view, unsigned *rows, un
return LIBMSI_RESULT_FUNCTION_FAILED;
}
-static unsigned create_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name,
- unsigned *type, bool *temporary, const WCHAR **table_name )
+static unsigned create_view_get_column_info( LibmsiView *view, unsigned n, const char **name,
+ unsigned *type, bool *temporary, const char **table_name )
{
LibmsiCreateView *cv = (LibmsiCreateView*)view;
@@ -139,13 +139,13 @@ static unsigned check_columns( const column_info *col_info )
/* check for two columns with the same name */
for( c1 = col_info; c1; c1 = c1->next )
for( c2 = c1->next; c2; c2 = c2->next )
- if (!strcmpW( c1->column, c2->column ))
+ if (!strcmp( c1->column, c2->column ))
return LIBMSI_RESULT_BAD_QUERY_SYNTAX;
return LIBMSI_RESULT_SUCCESS;
}
-unsigned create_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR *table,
+unsigned create_view_create( LibmsiDatabase *db, LibmsiView **view, const char *table,
column_info *col_info, bool hold )
{
LibmsiCreateView *cv = NULL;
diff --git a/libmsi/database.c b/libmsi/database.c
index 7198a1d..cbb6d7c 100644
--- a/libmsi/database.c
+++ b/libmsi/database.c
@@ -62,44 +62,41 @@ typedef struct LibmsiTransform {
typedef struct LibmsiStorage {
struct list entry;
- WCHAR *name;
+ char *name;
GsfInfile *stg;
} LibmsiStorage;
typedef struct LibmsiStream {
struct list entry;
- WCHAR *name;
+ char *name;
GsfInput *stm;
} LibmsiStream;
-unsigned msi_open_storage( LibmsiDatabase *db, const WCHAR *stname )
+unsigned msi_open_storage( LibmsiDatabase *db, const char *stname )
{
unsigned r = LIBMSI_RESULT_NOT_ENOUGH_MEMORY;
LibmsiStorage *storage;
GsfInput *in;
- char *utf8name;
LIST_FOR_EACH_ENTRY( storage, &db->storages, LibmsiStorage, entry )
{
- if( !strcmpW( stname, storage->name ) )
+ if( !strcmp( stname, storage->name ) )
{
- TRACE("found %s\n", debugstr_w(stname));
+ TRACE("found %s\n", debugstr_a(stname));
return;
}
}
if (!(storage = msi_alloc_zero( sizeof(LibmsiStorage) ))) return LIBMSI_RESULT_NOT_ENOUGH_MEMORY;
- storage->name = strdupW( stname );
+ storage->name = strdup( stname );
if (!storage->name)
goto done;
- utf8name = strdupWtoUTF8(stname);
- in = gsf_infile_child_by_name(db->infile, utf8name);
+ in = gsf_infile_child_by_name(db->infile, stname);
if (!GSF_IS_INFILE(in))
goto done;
storage->stg = GSF_INFILE(in);
- msi_free(utf8name);
if (!storage->stg)
goto done;
@@ -115,7 +112,7 @@ done:
return r;
}
-unsigned msi_create_storage( LibmsiDatabase *db, const WCHAR *stname, GsfInput *stm )
+unsigned msi_create_storage( LibmsiDatabase *db, const char *stname, GsfInput *stm )
{
LibmsiStorage *storage;
GsfInfile *origstg = NULL;
@@ -127,9 +124,9 @@ unsigned msi_create_storage( LibmsiDatabase *db, const WCHAR *stname, GsfInput *
LIST_FOR_EACH_ENTRY( storage, &db->storages, LibmsiStorage, entry )
{
- if( !strcmpW( stname, storage->name ) )
+ if( !strcmp( stname, storage->name ) )
{
- TRACE("found %s\n", debugstr_w(stname));
+ TRACE("found %s\n", debugstr_a(stname));
found = true;
break;
}
@@ -137,7 +134,7 @@ unsigned msi_create_storage( LibmsiDatabase *db, const WCHAR *stname, GsfInput *
if (!found) {
if (!(storage = msi_alloc_zero( sizeof(LibmsiStorage) ))) return LIBMSI_RESULT_NOT_ENOUGH_MEMORY;
- storage->name = strdupW( stname );
+ storage->name = strdup( stname );
if (!storage->name)
{
msi_free(storage);
@@ -175,15 +172,15 @@ done:
return r;
}
-void msi_destroy_storage( LibmsiDatabase *db, const WCHAR *stname )
+void msi_destroy_storage( LibmsiDatabase *db, const char *stname )
{
LibmsiStorage *storage, *storage2;
LIST_FOR_EACH_ENTRY_SAFE( storage, storage2, &db->storages, LibmsiStorage, entry )
{
- if (!strcmpW( stname, storage->name ))
+ if (!strcmp( stname, storage->name ))
{
- TRACE("destroying %s\n", debugstr_w(stname));
+ TRACE("destroying %s\n", debugstr_a(stname));
list_remove( &storage->entry );
g_object_unref(G_OBJECT(storage->stg));
@@ -193,15 +190,15 @@ void msi_destroy_storage( LibmsiDatabase *db, const WCHAR *stname )
}
}
-static unsigned find_infile_stream( LibmsiDatabase *db, const WCHAR *name, GsfInput **stm )
+static unsigned find_infile_stream( LibmsiDatabase *db, const char *name, GsfInput **stm )
{
LibmsiStream *stream;
LIST_FOR_EACH_ENTRY( stream, &db->streams, LibmsiStream, entry )
{
- if( !strcmpW( name, stream->name ) )
+ if( !strcmp( name, stream->name ) )
{
- TRACE("found %s\n", debugstr_w(name));
+ TRACE("found %s\n", debugstr_a(name));
*stm = stream->stm;
return LIBMSI_RESULT_SUCCESS;
}
@@ -210,20 +207,20 @@ static unsigned find_infile_stream( LibmsiDatabase *db, const WCHAR *name, GsfIn
return LIBMSI_RESULT_FUNCTION_FAILED;
}
-static unsigned msi_alloc_stream( LibmsiDatabase *db, const WCHAR *stname, GsfInput *stm)
+static unsigned msi_alloc_stream( LibmsiDatabase *db, const char *stname, GsfInput *stm)
{
LibmsiStream *stream;
- TRACE("%p %s %p", db, debugstr_w(stname), stm);
+ TRACE("%p %s %p", db, debugstr_a(stname), stm);
if (!(stream = msi_alloc( sizeof(LibmsiStream) ))) return LIBMSI_RESULT_NOT_ENOUGH_MEMORY;
- stream->name = strdupW( stname );
+ stream->name = strdup( stname );
stream->stm = stm;
g_object_ref(G_OBJECT(stm));
list_add_tail( &db->streams, &stream->entry );
return LIBMSI_RESULT_SUCCESS;
}
-unsigned write_raw_stream_data( LibmsiDatabase *db, const WCHAR *stname,
+unsigned write_raw_stream_data( LibmsiDatabase *db, const char *stname,
const void *data, unsigned sz, GsfInput **outstm )
{
unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED;
@@ -236,7 +233,7 @@ unsigned write_raw_stream_data( LibmsiDatabase *db, const WCHAR *stname,
LIST_FOR_EACH_ENTRY( stream, &db->streams, LibmsiStream, entry )
{
- if( !strcmpW( stname, stream->name ) )
+ if( !strcmp( stname, stream->name ) )
{
msi_destroy_stream( db, stname );
break;
@@ -256,10 +253,10 @@ unsigned write_raw_stream_data( LibmsiDatabase *db, const WCHAR *stname,
return ret;
}
-unsigned msi_create_stream( LibmsiDatabase *db, const WCHAR *stname, GsfInput *stm )
+unsigned msi_create_stream( LibmsiDatabase *db, const char *stname, GsfInput *stm )
{
LibmsiStream *stream;
- WCHAR *encname = NULL;
+ char *encname = NULL;
unsigned r = LIBMSI_RESULT_FUNCTION_FAILED;
bool found = false;
@@ -270,7 +267,7 @@ unsigned msi_create_stream( LibmsiDatabase *db, const WCHAR *stname, GsfInput *s
LIST_FOR_EACH_ENTRY( stream, &db->streams, LibmsiStream, entry )
{
- if( !strcmpW( encname, stream->name ) )
+ if( !strcmp( encname, stream->name ) )
{
found = true;
break;
@@ -286,13 +283,14 @@ unsigned msi_create_stream( LibmsiDatabase *db, const WCHAR *stname, GsfInput *s
} else
r = msi_alloc_stream( db, encname, stm );
+ msi_free(encname);
return r;
}
static void cache_infile_structure( LibmsiDatabase *db )
{
int i, n;
- WCHAR decname[0x40];
+ char decname[0x40];
unsigned r;
n = gsf_infile_num_children(db->infile);
@@ -303,37 +301,33 @@ static void cache_infile_structure( LibmsiDatabase *db )
{
GsfInput *in = gsf_infile_child_by_index(db->infile, i);
const uint8_t *name = (const uint8_t *) gsf_input_name(in);
- WCHAR *stname = strdupUTF8toW(name);
/* table streams are not in the _Streams table */
if (!GSF_IS_INFILE(in) || gsf_infile_num_children(GSF_INFILE(in)) == -1) {
- if (*stname == 0x4840)
+ /* UTF-8 encoding of 0x4840. */
+ if (name[0] == 0xe4 && name[1] == 0xa1 && name[2] == 0x80)
{
- decode_streamname( stname + 1, decname );
- if ( !strcmpW( decname, szStringPool ) ||
- !strcmpW( decname, szStringData ) )
- {
- msi_free(stname);
+ decode_streamname( name + 3, decname );
+ if ( !strcmp( decname, szStringPool ) ||
+ !strcmp( decname, szStringData ) )
continue;
- }
r = _libmsi_open_table( db, decname, false );
}
else
{
- r = msi_alloc_stream(db, stname, GSF_INPUT(in));
+ r = msi_alloc_stream(db, name, GSF_INPUT(in));
g_object_unref(G_OBJECT(in));
}
} else {
- msi_open_storage(db, stname);
+ msi_open_storage(db, name);
}
- msi_free(stname);
}
}
unsigned msi_enum_db_streams(LibmsiDatabase *db,
- unsigned (*fn)(const WCHAR *, GsfInput *, void *),
+ unsigned (*fn)(const char *, GsfInput *, void *),
void *opaque)
{
unsigned r;
@@ -357,7 +351,7 @@ unsigned msi_enum_db_streams(LibmsiDatabase *db,
}
unsigned msi_enum_db_storages(LibmsiDatabase *db,
- unsigned (*fn)(const WCHAR *, GsfInfile *, void *),
+ unsigned (*fn)(const char *, GsfInfile *, void *),
void *opaque)
{
unsigned r;
@@ -380,7 +374,7 @@ unsigned msi_enum_db_storages(LibmsiDatabase *db,
return LIBMSI_RESULT_SUCCESS;
}
-unsigned clone_infile_stream( LibmsiDatabase *db, const WCHAR *name, GsfInput **stm )
+unsigned clone_infile_stream( LibmsiDatabase *db, const char *name, GsfInput **stm )
{
GsfInput *stream;
@@ -401,22 +395,21 @@ unsigned clone_infile_stream( LibmsiDatabase *db, const WCHAR *name, GsfInput **
return LIBMSI_RESULT_FUNCTION_FAILED;
}
-unsigned msi_get_raw_stream( LibmsiDatabase *db, const WCHAR *stname, GsfInput **stm )
+unsigned msi_get_raw_stream( LibmsiDatabase *db, const char *stname, GsfInput **stm )
{
unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED;
- WCHAR decoded[MAX_STREAM_NAME_LEN];
+ char decoded[MAX_STREAM_NAME_LEN];
LibmsiTransform *transform;
decode_streamname( stname, decoded );
- TRACE("%s -> %s\n", debugstr_w(stname), debugstr_w(decoded));
+ TRACE("%s -> %s\n", debugstr_a(stname), debugstr_a(decoded));
if (clone_infile_stream( db, stname, stm ) == LIBMSI_RESULT_SUCCESS)
return LIBMSI_RESULT_SUCCESS;
- char *utf8name = strdupWtoUTF8(stname);
LIST_FOR_EACH_ENTRY( transform, &db->transforms, LibmsiTransform, entry )
{
- *stm = gsf_infile_child_by_name( transform->stg, utf8name );
+ *stm = gsf_infile_child_by_name( transform->stg, stname );
if (*stm)
{
ret = LIBMSI_RESULT_SUCCESS;
@@ -424,7 +417,6 @@ unsigned msi_get_raw_stream( LibmsiDatabase *db, const WCHAR *stname, GsfInput *
}
}
- msi_free(utf8name);
return ret;
}
@@ -440,15 +432,15 @@ static void free_transforms( LibmsiDatabase *db )
}
}
-void msi_destroy_stream( LibmsiDatabase *db, const WCHAR *stname )
+void msi_destroy_stream( LibmsiDatabase *db, const char *stname )
{
LibmsiStream *stream, *stream2;
LIST_FOR_EACH_ENTRY_SAFE( stream, stream2, &db->streams, LibmsiStream, entry )
{
- if (!strcmpW( stname, stream->name ))
+ if (!strcmp( stname, stream->name ))
{
- TRACE("destroying %s\n", debugstr_w(stname));
+ TRACE("destroying %s\n", debugstr_a(stname));
list_remove( &stream->entry );
g_object_unref(G_OBJECT(stream->stm));
@@ -771,43 +763,23 @@ end:
return ret;
}
-static WCHAR *msi_read_text_archive(const char *path, unsigned *len)
+static char *msi_read_text_archive(const char *path, unsigned *len)
{
- int fd;
- struct stat st;
- char *data = NULL;
- WCHAR *wdata = NULL;
- ssize_t nread;
-
- /* TODO g_file_get_contents */
- fd = open( path, O_RDONLY | O_BINARY);
- if (fd == -1)
- return NULL;
-
- fstat (fd, &st);
- if (!(data = msi_alloc( st.st_size ))) goto done;
-
- nread = read(fd, data, st.st_size);
- if (nread != st.st_size) goto done;
+ char *data;
+ size_t nread;
- while (!data[st.st_size - 1]) st.st_size--;
- *len = MultiByteToWideChar( CP_ACP, 0, data, st.st_size, NULL, 0 );
- if ((wdata = msi_alloc( (*len + 1) * sizeof(WCHAR) )))
- {
- MultiByteToWideChar( CP_ACP, 0, data, st.st_size, wdata, *len );
- wdata[*len] = 0;
- }
+ if (!g_file_get_contents(path, &data, &nread, NULL))
+ return NULL;
-done:
- close( fd );
- msi_free( data );
- return wdata;
+ while (!data[nread - 1]) nread--;
+ *len = nread;
+ return data;
}
-static void msi_parse_line(WCHAR **line, WCHAR ***entries, unsigned *num_entries, unsigned *len)
+static void msi_parse_line(char **line, char ***entries, unsigned *num_entries, unsigned *len)
{
- WCHAR *ptr = *line;
- WCHAR *save;
+ char *ptr = *line;
+ char *save;
unsigned i, count = 1, chars_left = *len;
*entries = NULL;
@@ -823,7 +795,7 @@ static void msi_parse_line(WCHAR **line, WCHAR ***entries, unsigned *num_entries
chars_left--;
}
- *entries = msi_alloc(count * sizeof(WCHAR *));
+ *entries = msi_alloc(count * sizeof(char *));
if (!*entries)
return;
@@ -874,41 +846,41 @@ static void msi_parse_line(WCHAR **line, WCHAR ***entries, unsigned *num_entries
*num_entries = count;
}
-static WCHAR *msi_build_createsql_prelude(WCHAR *table)
+static char *msi_build_createsql_prelude(char *table)
{
- WCHAR *prelude;
+ char *prelude;
unsigned size;
- static const WCHAR create_fmt[] = {'C','R','E','A','T','E',' ','T','A','B','L','E',' ','`','%','s','`',' ','(',' ',0};
+ static const char create_fmt[] = {'C','R','E','A','T','E',' ','T','A','B','L','E',' ','`','%','s','`',' ','(',' ',0};
- size = sizeof(create_fmt)/sizeof(create_fmt[0]) + strlenW(table) - 2;
- prelude = msi_alloc(size * sizeof(WCHAR));
+ size = sizeof(create_fmt)/sizeof(create_fmt[0]) + strlen(table) - 2;
+ prelude = msi_alloc(size * sizeof(char));
if (!prelude)
return NULL;
- sprintfW(prelude, create_fmt, table);
+ sprintf(prelude, create_fmt, table);
return prelude;
}
-static WCHAR *msi_build_createsql_columns(WCHAR **columns_data, WCHAR **types, unsigned num_columns)
+static char *msi_build_createsql_columns(char **columns_data, char **types, unsigned num_columns)
{
- WCHAR *columns;
- WCHAR *p;
- const WCHAR *type;
+ char *columns;
+ char *p;
+ const char *type;
unsigned sql_size = 1, i, len;
- WCHAR expanded[128], *ptr;
- WCHAR size[10], comma[2], extra[30];
-
- static const WCHAR column_fmt[] = {'`','%','s','`',' ','%','s','%','s','%','s','%','s',' ',0};
- static const WCHAR size_fmt[] = {'(','%','s',')',0};
- static const WCHAR type_char[] = {'C','H','A','R',0};
- static const WCHAR type_int[] = {'I','N','T',0};
- static const WCHAR type_long[] = {'L','O','N','G',0};
- static const WCHAR type_object[] = {'O','B','J','E','C','T',0};
- static const WCHAR type_notnull[] = {' ','N','O','T',' ','N','U','L','L',0};
- static const WCHAR localizable[] = {' ','L','O','C','A','L','I','Z','A','B','L','E',0};
-
- columns = msi_alloc_zero(sql_size * sizeof(WCHAR));
+ char expanded[128], *ptr;
+ char size[10], comma[2], extra[30];
+
+ static const char column_fmt[] = {'`','%','s','`',' ','%','s','%','s','%','s','%','s',' ',0};
+ static const char size_fmt[] = {'(','%','s',')',0};
+ static const char type_char[] = {'C','H','A','R',0};
+ static const char type_int[] = {'I','N','T',0};
+ static const char type_long[] = {'L','O','N','G',0};
+ static const char type_object[] = {'O','B','J','E','C','T',0};
+ static const char type_notnull[] = {' ','N','O','T',' ','N','U','L','L',0};
+ static const char localizable[] = {' ','L','O','C','A','L','I','Z','A','B','L','E',0};
+
+ columns = msi_alloc_zero(sql_size * sizeof(char));
if (!columns)
return NULL;
@@ -923,28 +895,28 @@ static WCHAR *msi_build_createsql_columns(WCHAR **columns_data, WCHAR **types, u
comma[0] = ',';
ptr = &types[i][1];
- len = atolW(ptr);
+ len = atol(ptr);
extra[0] = '\0';
switch (types[i][0])
{
case 'l':
- strcpyW(extra, type_notnull);
+ strcpy(extra, type_notnull);
/* fall through */
case 'L':
- strcatW(extra, localizable);
+ strcat(extra, localizable);
type = type_char;
- sprintfW(size, size_fmt, ptr);
+ sprintf(size, size_fmt, ptr);
break;
case 's':
- strcpyW(extra, type_notnull);
+ strcpy(extra, type_notnull);
/* fall through */
case 'S':
type = type_char;
- sprintfW(size, size_fmt, ptr);
+ sprintf(size, size_fmt, ptr);
break;
case 'i':
- strcpyW(extra, type_notnull);
+ strcpy(extra, type_notnull);
/* fall through */
case 'I':
if (len <= 2)
@@ -959,7 +931,7 @@ static WCHAR *msi_build_createsql_columns(WCHAR **columns_data, WCHAR **types, u
}
break;
case 'v':
- strcpyW(extra, type_notnull);
+ strcpy(extra, type_notnull);
/* fall through */
case 'V':
type = type_object;
@@ -970,10 +942,10 @@ static WCHAR *msi_build_createsql_columns(WCHAR **columns_data, WCHAR **types, u
return NULL;
}
- sprintfW(expanded, column_fmt, columns_data[i], type, size, extra, comma);
- sql_size += strlenW(expanded);
+ sprintf(expanded, column_fmt, columns_data[i], type, size, extra, comma);
+ sql_size += strlen(expanded);
- p = msi_realloc(columns, sql_size * sizeof(WCHAR));
+ p = msi_realloc(columns, sql_size * sizeof(char));
if (!p)
{
msi_free(columns);
@@ -981,60 +953,60 @@ static WCHAR *msi_build_createsql_columns(WCHAR **columns_data, WCHAR **types, u
}
columns = p;
- strcatW(columns, expanded);
+ strcat(columns, expanded);
}
return columns;
}
-static WCHAR *msi_build_createsql_postlude(WCHAR **primary_keys, unsigned num_keys)
+static char *msi_build_createsql_postlude(char **primary_keys, unsigned num_keys)
{
- WCHAR *postlude;
- WCHAR *keys;
- WCHAR *ptr;
+ char *postlude;
+ char *keys;
+ char *ptr;
unsigned size, key_size, i;
- static const WCHAR key_fmt[] = {'`','%','s','`',',',' ',0};
- static const WCHAR postlude_fmt[] = {'P','R','I','M','A','R','Y',' ','K','E','Y',' ','%','s',')',0};
+ static const char key_fmt[] = {'`','%','s','`',',',' ',0};
+ static const char postlude_fmt[] = {'P','R','I','M','A','R','Y',' ','K','E','Y',' ','%','s',')',0};
for (i = 0, size = 1; i < num_keys; i++)
- size += strlenW(key_fmt) + strlenW(primary_keys[i]) - 2;
+ size += strlen(key_fmt) + strlen(primary_keys[i]) - 2;
- keys = msi_alloc(size * sizeof(WCHAR));
+ keys = msi_alloc(size * sizeof(char));
if (!keys)
return NULL;
for (i = 0, ptr = keys; i < num_keys; i++)
{
- key_size = strlenW(key_fmt) + strlenW(primary_keys[i]) -2;
- sprintfW(ptr, key_fmt, primary_keys[i]);
+ key_size = strlen(key_fmt) + strlen(primary_keys[i]) -2;
+ sprintf(ptr, key_fmt, primary_keys[i]);
ptr += key_size;
}
/* remove final ', ' */
*(ptr - 2) = '\0';
- size = strlenW(postlude_fmt) + size - 1;
- postlude = msi_alloc(size * sizeof(WCHAR));
+ size = strlen(postlude_fmt) + size - 1;
+ postlude = msi_alloc(size * sizeof(char));
if (!postlude)
goto done;
- sprintfW(postlude, postlude_fmt, keys);
+ sprintf(postlude, postlude_fmt, keys);
done:
msi_free(keys);
return postlude;
}
-static unsigned msi_add_table_to_db(LibmsiDatabase *db, WCHAR **columns, WCHAR **types, WCHAR **labels, unsigned num_labels, unsigned num_columns)
+static unsigned msi_add_table_to_db(LibmsiDatabase *db, char **columns, char **types, char **labels, unsigned num_labels, unsigned num_columns)
{
unsigned r = LIBMSI_RESULT_OUTOFMEMORY;
unsigned size;
LibmsiQuery *view;
- WCHAR *create_sql = NULL;
- WCHAR *prelude;
- WCHAR *columns_sql;
- WCHAR *postlude;
+ char *create_sql = NULL;
+ char *prelude;
+ char *columns_sql;
+ char *postlude;
prelude = msi_build_createsql_prelude(labels[0]);
columns_sql = msi_build_createsql_columns(columns, types, num_columns);
@@ -1043,14 +1015,14 @@ static unsigned msi_add_table_to_db(LibmsiDatabase *db, WCHAR **columns, WCHAR *
if (!prelude || !columns_sql || !postlude)
goto done;
- size = strlenW(prelude) + strlenW(columns_sql) + strlenW(postlude) + 1;
- create_sql = msi_alloc(size * sizeof(WCHAR));
+ size = strlen(prelude) + strlen(columns_sql) + strlen(postlude) + 1;
+ create_sql = msi_alloc(size * sizeof(char));
if (!create_sql)
goto done;
- strcpyW(create_sql, prelude);
- strcatW(create_sql, columns_sql);
- strcatW(create_sql, postlude);
+ strcpy(create_sql, prelude);
+ strcat(create_sql, columns_sql);
+ strcat(create_sql, postlude);
r = _libmsi_database_open_query( db, create_sql, &view );
if (r != LIBMSI_RESULT_SUCCESS)
@@ -1068,14 +1040,13 @@ done:
return r;
}
-static char *msi_import_stream_filename(const char *path, const WCHAR *name)
+static char *msi_import_stream_filename(const char *path, const char *name)
{
unsigned len;
- char *ascii_name = strdupWtoA(name);
char *fullname;
char *ptr;
- len = strlen(path) + strlen(ascii_name) + 1;
+ len = strlen(path) + strlen(name) + 1;
fullname = msi_alloc(len);
if (!fullname)
return NULL;
@@ -1090,13 +1061,12 @@ static char *msi_import_stream_filename(const char *path, const WCHAR *name)
return NULL;
}
*ptr++ = '\\';
- strcpy( ptr, ascii_name );
- msi_free( ascii_name );
+ strcpy( ptr, name );
return fullname;
}
-static unsigned construct_record(unsigned num_columns, WCHAR **types,
- WCHAR **data, const char *path, LibmsiRecord **rec)
+static unsigned construct_record(unsigned num_columns, char **types,
+ char **data, const char *path, LibmsiRecord **rec)
{
unsigned i;
@@ -1109,11 +1079,11 @@ static unsigned construct_record(unsigned num_columns, WCHAR **types,
switch (types[i][0])
{
case 'L': case 'l': case 'S': case 's':
- _libmsi_record_set_stringW(*rec, i + 1, data[i]);
+ libmsi_record_set_string(*rec, i + 1, data[i]);
break;
case 'I': case 'i':
if (*data[i])
- libmsi_record_set_int(*rec, i + 1, atoiW(data[i]));
+ libmsi_record_set_int(*rec, i + 1, atoi(data[i]));
break;
case 'V': case 'v':
if (*data[i])
@@ -1139,8 +1109,8 @@ static unsigned construct_record(unsigned num_columns, WCHAR **types,
return LIBMSI_RESULT_SUCCESS;
}
-static unsigned msi_add_records_to_table(LibmsiDatabase *db, WCHAR **columns, WCHAR **types,
- WCHAR **labels, WCHAR ***records,
+static unsigned msi_add_records_to_table(LibmsiDatabase *db, char **columns, char **types,
+ char **labels, char ***records,
int num_columns, int num_records,
const char *path)
{
@@ -1192,17 +1162,17 @@ static unsigned _libmsi_database_import(LibmsiDatabase *db, const char *folder,
unsigned num_labels, num_types;
unsigned num_columns, num_records = 0;
char *path;
- WCHAR **columns;
- WCHAR **types;
- WCHAR **labels;
- WCHAR *ptr;
- WCHAR *data;
- WCHAR ***records = NULL;
- WCHAR ***temp_records;
-
- static const WCHAR suminfo[] =
+ char **columns;
+ char **types;
+ char **labels;
+ char *ptr;
+ char *data;
+ char ***records = NULL;
+ char ***temp_records;
+
+ static const char suminfo[] =
{'_','S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',0};
- static const WCHAR forcecodepage[] =
+ static const char forcecodepage[] =
{'_','F','o','r','c','e','C','o','d','e','p','a','g','e',0};
TRACE("%p %s %s\n", db, debugstr_a(folder), debugstr_a(file) );
@@ -1229,9 +1199,9 @@ static unsigned _libmsi_database_import(LibmsiDatabase *db, const char *folder,
msi_parse_line( &ptr, &labels, &num_labels, &len );
if (num_columns == 1 && !columns[0][0] && num_labels == 1 && !labels[0][0] &&
- num_types == 2 && !strcmpW( types[1], forcecodepage ))
+ num_types == 2 && !strcmp( types[1], forcecodepage ))
{
- r = msi_set_string_table_codepage( db->strings, atoiW( types[0] ) );
+ r = msi_set_string_table_codepage( db->strings, atoi( types[0] ) );
goto done;
}
@@ -1241,7 +1211,7 @@ static unsigned _libmsi_database_import(LibmsiDatabase *db, const char *folder,
goto done;
}
- records = msi_alloc(sizeof(WCHAR **));
+ records = msi_alloc(sizeof(char **));
if (!records)
{
r = LIBMSI_RESULT_OUTOFMEMORY;
@@ -1254,7 +1224,7 @@ static unsigned _libmsi_database_import(LibmsiDatabase *db, const char *folder,
msi_parse_line( &ptr, &records[num_records], NULL, &len );
num_records++;
- temp_records = msi_realloc(records, (num_records + 1) * sizeof(WCHAR **));
+ temp_records = msi_realloc(records, (num_records + 1) * sizeof(char **));
if (!temp_records)
{
r = LIBMSI_RESULT_OUTOFMEMORY;
@@ -1263,7 +1233,7 @@ static unsigned _libmsi_database_import(LibmsiDatabase *db, const char *folder,
records = temp_records;
}
- if (!strcmpW(labels[0], suminfo))
+ if (!strcmp(labels[0], suminfo))
{
r = msi_add_suminfo( db, records, num_records, num_columns );
if (r != LIBMSI_RESULT_SUCCESS)
@@ -1385,20 +1355,20 @@ static unsigned msi_export_forcecodepage( int fd, unsigned codepage )
return LIBMSI_RESULT_SUCCESS;
}
-static unsigned _libmsi_database_export( LibmsiDatabase *db, const WCHAR *table,
+static unsigned _libmsi_database_export( LibmsiDatabase *db, const char *table,
int fd)
{
- static const WCHAR query[] = {
+ static const char query[] = {
's','e','l','e','c','t',' ','*',' ','f','r','o','m',' ','%','s',0 };
- static const WCHAR forcecodepage[] = {
+ static const char forcecodepage[] = {
'_','F','o','r','c','e','C','o','d','e','p','a','g','e',0 };
LibmsiRecord *rec = NULL;
LibmsiQuery *view = NULL;
unsigned r;
- TRACE("%p %s %d\n", db, debugstr_w(table), fd );
+ TRACE("%p %s %d\n", db, debugstr_a(table), fd );
- if (!strcmpW( table, forcecodepage ))
+ if (!strcmp( table, forcecodepage ))
{
unsigned codepage = msi_get_string_table_codepage( db->strings );
r = msi_export_forcecodepage( fd, codepage );
@@ -1428,7 +1398,7 @@ static unsigned _libmsi_database_export( LibmsiDatabase *db, const WCHAR *table,
r = _libmsi_database_get_primary_keys( db, table, &rec );
if (r == LIBMSI_RESULT_SUCCESS)
{
- _libmsi_record_set_stringW( rec, 0, table );
+ libmsi_record_set_string( rec, 0, table );
msi_export_record( fd, rec, 0 );
msiobj_release( &rec->hdr );
}
@@ -1443,7 +1413,7 @@ done:
}
/***********************************************************************
- * MsiExportDatabaseW [MSI.@]
+ * MsiExportDatabase [MSI.@]
*
* Writes a file containing the table data as tab separated ASCII.
*
@@ -1460,32 +1430,16 @@ done:
LibmsiResult libmsi_database_export( LibmsiDatabase *db, const char *szTable,
int fd )
{
- WCHAR *path = NULL;
- WCHAR *file = NULL;
- WCHAR *table = NULL;
unsigned r = LIBMSI_RESULT_OUTOFMEMORY;
TRACE("%x %s %d\n", db, debugstr_a(szTable), fd);
- if( szTable )
- {
- table = strdupAtoW( szTable );
- if( !table )
- goto end;
- }
-
if( !db )
return LIBMSI_RESULT_INVALID_HANDLE;
msiobj_addref ( &db->hdr );
- r = _libmsi_database_export( db, table, fd );
+ r = _libmsi_database_export( db, szTable, fd );
msiobj_release( &db->hdr );
-
-end:
- msi_free( table );
- msi_free( path );
- msi_free( file );
-
return r;
}
@@ -1493,13 +1447,13 @@ typedef struct _tagMERGETABLE
{
struct list entry;
struct list rows;
- WCHAR *name;
+ char *name;
unsigned numconflicts;
- WCHAR **columns;
+ char **columns;
unsigned numcolumns;
- WCHAR **types;
+ char **types;
unsigned numtypes;
- WCHAR **labels;
+ char **labels;
unsigned numlabels;
} MERGETABLE;
@@ -1518,7 +1472,7 @@ typedef struct _tagMERGEDATA
struct list *tabledata;
} MERGEDATA;
-static bool merge_type_match(const WCHAR *type1, const WCHAR *type2)
+static bool merge_type_match(const char *type1, const char *type2)
{
if (((type1[0] == 'l') || (type1[0] == 's')) &&
((type2[0] == 'l') || (type2[0] == 's')))
@@ -1528,7 +1482,7 @@ static bool merge_type_match(const WCHAR *type1, const WCHAR *type2)
((type2[0] == 'L') || (type2[0] == 'S')))
return true;
- return !strcmpW( type1, type2 );
+ return !strcmp( type1, type2 );
}
static unsigned merge_verify_colnames(LibmsiQuery *dbview, LibmsiQuery *mergeview)
@@ -1550,7 +1504,7 @@ static unsigned merge_verify_colnames(LibmsiQuery *dbview, LibmsiQuery *mergevie
if (!_libmsi_record_get_string_raw(mergerec, i))
break;
- if (strcmpW( _libmsi_record_get_string_raw( dbrec, i ), _libmsi_record_get_string_raw( mergerec, i ) ))
+ if (strcmp( _libmsi_record_get_string_raw( dbrec, i ), _libmsi_record_get_string_raw( mergerec, i ) ))
{
r = LIBMSI_RESULT_DATATYPE_MISMATCH;
goto done;
@@ -1591,7 +1545,7 @@ done:
}
static unsigned merge_verify_primary_keys(LibmsiDatabase *db, LibmsiDatabase *mergedb,
- const WCHAR *table)
+ const char *table)
{
LibmsiRecord *dbrec, *mergerec = NULL;
unsigned r, i, count;
@@ -1613,7 +1567,7 @@ static unsigned merge_verify_primary_keys(LibmsiDatabase *db, LibmsiDatabase *me
for (i = 1; i <= count; i++)
{
- if (strcmpW( _libmsi_record_get_string_raw( dbrec, i ), _libmsi_record_get_string_raw( mergerec, i ) ))
+ if (strcmp( _libmsi_record_get_string_raw( dbrec, i ), _libmsi_record_get_string_raw( mergerec, i ) ))
{
r = LIBMSI_RESULT_DATATYPE_MISMATCH;
goto done;
@@ -1627,11 +1581,11 @@ done:
return r;
}
-static WCHAR *get_key_value(LibmsiQuery *view, const WCHAR *key, LibmsiRecord *rec)
+static char *get_key_value(LibmsiQuery *view, const char *key, LibmsiRecord *rec)
{
LibmsiRecord *colnames;
- WCHAR *str;
- WCHAR *val;
+ char *str;
+ char *val;
unsigned r, i = 0, sz = 0;
int cmp;
@@ -1642,13 +1596,13 @@ static WCHAR *get_key_value(LibmsiQuery *view, const WCHAR *key, LibmsiRecord *r
do
{
str = msi_dup_record_field(colnames, ++i);
- cmp = strcmpW( key, str );
+ cmp = strcmp( key, str );
msi_free(str);
} while (cmp);
msiobj_release(&colnames->hdr);
- r = _libmsi_record_get_stringW(rec, i, NULL, &sz);
+ r = _libmsi_record_get_string(rec, i, NULL, &sz);
if (r != LIBMSI_RESULT_SUCCESS)
return NULL;
sz++;
@@ -1656,24 +1610,24 @@ static WCHAR *get_key_value(LibmsiQuery *view, const WCHAR *key, LibmsiRecord *r
if (_libmsi_record_get_string_raw(rec, i)) /* check record field is a string */
{
/* quote string record fields */
- const WCHAR szQuote[] = {'\'', 0};
+ const char szQuote[] = {'\'', 0};
sz += 2;
- val = msi_alloc(sz*sizeof(WCHAR));
+ val = msi_alloc(sz*sizeof(char));
if (!val)
return NULL;
- strcpyW(val, szQuote);
- r = _libmsi_record_get_stringW(rec, i, val+1, &sz);
- strcpyW(val+1+sz, szQuote);
+ strcpy(val, szQuote);
+ r = _libmsi_record_get_string(rec, i, val+1, &sz);
+ strcpy(val+1+sz, szQuote);
}
else
{
/* do not quote integer record fields */
- val = msi_alloc(sz*sizeof(WCHAR));
+ val = msi_alloc(sz*sizeof(char));
if (!val)
return NULL;
- r = _libmsi_record_get_stringW(rec, i, val, &sz);
+ r = _libmsi_record_get_string(rec, i, val, &sz);
}
if (r != LIBMSI_RESULT_SUCCESS)
@@ -1686,23 +1640,23 @@ static WCHAR *get_key_value(LibmsiQuery *view, const WCHAR *key, LibmsiRecord *r
return val;
}
-static WCHAR *create_diff_row_query(LibmsiDatabase *merge, LibmsiQuery *view,
- WCHAR *table, LibmsiRecord *rec)
+static char *create_diff_row_query(LibmsiDatabase *merge, LibmsiQuery *view,
+ char *table, LibmsiRecord *rec)
{
- WCHAR *query = NULL;
- WCHAR *clause = NULL;
- WCHAR *val;
- const WCHAR *setptr;
- const WCHAR *key;
+ char *query = NULL;
+ char *clause = NULL;
+ char *val;
+ const char *setptr;
+ const char *key;
unsigned size, oldsize;
LibmsiRecord *keys;
unsigned r, i, count;
- static const WCHAR keyset[] = {
+ static const char keyset[] = {
'`','%','s','`',' ','=',' ','%','s',' ','A','N','D',' ',0};
- static const WCHAR lastkeyset[] = {
+ static const char lastkeyset[] = {
'`','%','s','`',' ','=',' ','%','s',' ',0};
- static const WCHAR fmt[] = {'S','E','L','E','C','T',' ','*',' ',
+ static const char fmt[] = {'S','E','L','E','C','T',' ','*',' ',
'F','R','O','M',' ','`','%','s','`',' ',
'W','H','E','R','E',' ','%','s',0};
@@ -1710,7 +1664,7 @@ static WCHAR *create_diff_row_query(LibmsiDatabase *merge, LibmsiQuery *view,
if (r != LIBMSI_RESULT_SUCCESS)
return NULL;
- clause = msi_alloc_zero(sizeof(WCHAR));
+ clause = msi_alloc_zero(sizeof(char));
if (!clause)
goto done;
@@ -1727,24 +1681,24 @@ static WCHAR *create_diff_row_query(LibmsiDatabase *merge, LibmsiQuery *view,
setptr = keyset;
oldsize = size;
- size += strlenW(setptr) + strlenW(key) + strlenW(val) - 4;
- clause = msi_realloc(clause, size * sizeof (WCHAR));
+ size += strlen(setptr) + strlen(key) + strlen(val) - 4;
+ clause = msi_realloc(clause, size * sizeof (char));
if (!clause)
{
msi_free(val);
goto done;
}
- sprintfW(clause + oldsize - 1, setptr, key, val);
+ sprintf(clause + oldsize - 1, setptr, key, val);
msi_free(val);
}
- size = strlenW(fmt) + strlenW(table) + strlenW(clause) + 1;
- query = msi_alloc(size * sizeof(WCHAR));
+ size = strlen(fmt) + strlen(table) + strlen(clause) + 1;
+ query = msi_alloc(size * sizeof(char));
if (!query)
goto done;
- sprintfW(query, fmt, table, clause);
+ sprintf(query, fmt, table, clause);
done:
msi_free(clause);
@@ -1759,7 +1713,7 @@ static unsigned merge_diff_row(LibmsiRecord *rec, void *param)
MERGEROW *mergerow;
LibmsiQuery *dbview = NULL;
LibmsiRecord *row = NULL;
- WCHAR *query = NULL;
+ char *query = NULL;
unsigned r = LIBMSI_RESULT_SUCCESS;
if (table_view_exists(data->db, table->name))
@@ -1812,7 +1766,7 @@ done:
return r;
}
-static unsigned msi_get_table_labels(LibmsiDatabase *db, const WCHAR *table, WCHAR ***labels, unsigned *numlabels)
+static unsigned msi_get_table_labels(LibmsiDatabase *db, const char *table, char ***labels, unsigned *numlabels)
{
unsigned r, i, count;
LibmsiRecord *prec = NULL;
@@ -1823,17 +1777,17 @@ static unsigned msi_get_table_labels(LibmsiDatabase *db, const WCHAR *table, WCH
count = libmsi_record_get_field_count(prec);
*numlabels = count + 1;
- *labels = msi_alloc((*numlabels)*sizeof(WCHAR *));
+ *labels = msi_alloc((*numlabels)*sizeof(char *));
if (!*labels)
{
r = LIBMSI_RESULT_OUTOFMEMORY;
goto end;
}
- (*labels)[0] = strdupW(table);
+ (*labels)[0] = strdup(table);
for (i=1; i<=count; i++ )
{
- (*labels)[i] = strdupW(_libmsi_record_get_string_raw(prec, i));
+ (*labels)[i] = strdup(_libmsi_record_get_string_raw(prec, i));
}
end:
@@ -1841,7 +1795,7 @@ end:
return r;
}
-static unsigned msi_get_query_columns(LibmsiQuery *query, WCHAR ***columns, unsigned *numcolumns)
+static unsigned msi_get_query_columns(LibmsiQuery *query, char ***columns, unsigned *numcolumns)
{
unsigned r, i, count;
LibmsiRecord *prec = NULL;
@@ -1851,7 +1805,7 @@ static unsigned msi_get_query_columns(LibmsiQuery *query, WCHAR ***columns, unsi
return r;
count = libmsi_record_get_field_count(prec);
- *columns = msi_alloc(count*sizeof(WCHAR *));
+ *columns = msi_alloc(count*sizeof(char *));
if (!*columns)
{
r = LIBMSI_RESULT_OUTOFMEMORY;
@@ -1860,7 +1814,7 @@ static unsigned msi_get_query_columns(LibmsiQuery *query, WCHAR ***columns, unsi
for (i=1; i<=count; i++ )
{
- (*columns)[i-1] = strdupW(_libmsi_record_get_string_raw(prec, i));
+ (*columns)[i-1] = strdup(_libmsi_record_get_string_raw(prec, i));
}
*numcolumns = count;
@@ -1870,7 +1824,7 @@ end:
return r;
}
-static unsigned msi_get_query_types(LibmsiQuery *query, WCHAR ***types, unsigned *numtypes)
+static unsigned msi_get_query_types(LibmsiQuery *query, char ***types, unsigned *numtypes)
{
unsigned r, i, count;
LibmsiRecord *prec = NULL;
@@ -1880,7 +1834,7 @@ static unsigned msi_get_query_types(LibmsiQuery *query, WCHAR ***types, unsigned
return r;
count = libmsi_record_get_field_count(prec);
- *types = msi_alloc(count*sizeof(WCHAR *));
+ *types = msi_alloc(count*sizeof(char *));
if (!*types)
{
r = LIBMSI_RESULT_OUTOFMEMORY;
@@ -1890,7 +1844,7 @@ static unsigned msi_get_query_types(LibmsiQuery *query, WCHAR ***types, unsigned
*numtypes = count;
for (i=1; i<=count; i++ )
{
- (*types)[i-1] = strdupW(_libmsi_record_get_string_raw(prec, i));
+ (*types)[i-1] = strdup(_libmsi_record_get_string_raw(prec, i));
}
end:
@@ -1946,13 +1900,13 @@ static void free_merge_table(MERGETABLE *table)
msi_free(table);
}
-static unsigned msi_get_merge_table (LibmsiDatabase *db, const WCHAR *name, MERGETABLE **ptable)
+static unsigned msi_get_merge_table (LibmsiDatabase *db, const char *name, MERGETABLE **ptable)
{
unsigned r;
MERGETABLE *table;
LibmsiQuery *mergeview = NULL;
- static const WCHAR query[] = {'S','E','L','E','C','T',' ','*',' ',
+ static const char query[] = {'S','E','L','E','C','T',' ','*',' ',
'F','R','O','M',' ','`','%','s','`',0};
table = msi_alloc_zero(sizeof(MERGETABLE));
@@ -1980,7 +1934,7 @@ static unsigned msi_get_merge_table (LibmsiDatabase *db, const WCHAR *name, MERG
list_init(&table->rows);
- table->name = strdupW(name);
+ table->name = strdup(name);
table->numconflicts = 0;
msiobj_release(&mergeview->hdr);
@@ -2000,10 +1954,10 @@ static unsigned merge_diff_tables(LibmsiRecord *rec, void *param)
MERGETABLE *table;
LibmsiQuery *dbview = NULL;
LibmsiQuery *mergeview = NULL;
- const WCHAR *name;
+ const char *name;
unsigned r;
- static const WCHAR query[] = {'S','E','L','E','C','T',' ','*',' ',
+ static const char query[] = {'S','E','L','E','C','T',' ','*',' ',
'F','R','O','M',' ','`','%','s','`',0};
name = _libmsi_record_get_string_raw(rec, 1);
@@ -2051,7 +2005,7 @@ done:
static unsigned gather_merge_data(LibmsiDatabase *db, LibmsiDatabase *merge,
struct list *tabledata)
{
- static const WCHAR query[] = {
+ static const char query[] = {
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
'`','_','T','a','b','l','e','s','`',0};
LibmsiQuery *view;
@@ -2100,13 +2054,13 @@ static unsigned merge_table(LibmsiDatabase *db, MERGETABLE *table)
return LIBMSI_RESULT_SUCCESS;
}
-static unsigned update_merge_errors(LibmsiDatabase *db, const WCHAR *error,
- WCHAR *table, unsigned numconflicts)
+static unsigned update_merge_errors(LibmsiDatabase *db, const char *error,
+ char *table, unsigned numconflicts)
{
unsigned r;
LibmsiQuery *view;
- static const WCHAR create[] = {
+ static const char create[] = {
'C','R','E','A','T','E',' ','T','A','B','L','E',' ',
'`','%','s','`',' ','(','`','T','a','b','l','e','`',' ',
'C','H','A','R','(','2','5','5',')',' ','N','O','T',' ',
@@ -2114,7 +2068,7 @@ static unsigned update_merge_errors(LibmsiDatabase *db, const WCHAR *error,
'C','o','n','f','l','i','c','t','s','`',' ','S','H','O','R','T',' ',
'N','O','T',' ','N','U','L','L',' ','P','R','I','M','A','R','Y',' ',
'K','E','Y',' ','`','T','a','b','l','e','`',')',0};
- static const WCHAR insert[] = {
+ static const char insert[] = {
'I','N','S','E','R','T',' ','I','N','T','O',' ',
'`','%','s','`',' ','(','`','T','a','b','l','e','`',',',' ',
'`','N','u','m','R','o','w','M','e','r','g','e',
@@ -2147,7 +2101,6 @@ LibmsiResult libmsi_database_merge(LibmsiDatabase *db, LibmsiDatabase *merge,
{
struct list tabledata = LIST_INIT(tabledata);
struct list *item, *cursor;
- WCHAR *szwTableName;
MERGETABLE *table;
bool conflicts;
unsigned r;
@@ -2161,7 +2114,6 @@ LibmsiResult libmsi_database_merge(LibmsiDatabase *db, LibmsiDatabase *merge,
if (!db || !merge)
return LIBMSI_RESULT_INVALID_HANDLE;
- szwTableName = strdupAtoW(szTableName);
msiobj_addref( &db->hdr );
msiobj_addref( &merge->hdr );
r = gather_merge_data(db, merge, &tabledata);
@@ -2175,7 +2127,7 @@ LibmsiResult libmsi_database_merge(LibmsiDatabase *db, LibmsiDatabase *merge,
{
conflicts = true;
- r = update_merge_errors(db, szwTableName, table->name,
+ r = update_merge_errors(db, szTableName, table->name,
table->numconflicts);
if (r != LIBMSI_RESULT_SUCCESS)
break;
diff --git a/libmsi/delete.c b/libmsi/delete.c
index b18c369..232da77 100644
--- a/libmsi/delete.c
+++ b/libmsi/delete.c
@@ -124,8 +124,8 @@ static unsigned delete_view_get_dimensions( LibmsiView *view, unsigned *rows, un
return dv->table->ops->get_dimensions( dv->table, NULL, cols );
}
-static unsigned delete_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name,
- unsigned *type, bool *temporary, const WCHAR **table_name )
+static unsigned delete_view_get_column_info( LibmsiView *view, unsigned n, const char **name,
+ unsigned *type, bool *temporary, const char **table_name )
{
LibmsiDeleteView *dv = (LibmsiDeleteView*)view;
diff --git a/libmsi/distinct.c b/libmsi/distinct.c
index 3d2bee6..42b230d 100644
--- a/libmsi/distinct.c
+++ b/libmsi/distinct.c
@@ -202,8 +202,8 @@ static unsigned distinct_view_get_dimensions( LibmsiView *view, unsigned *rows,
return dv->table->ops->get_dimensions( dv->table, NULL, cols );
}
-static unsigned distinct_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name,
- unsigned *type, bool *temporary, const WCHAR **table_name )
+static unsigned distinct_view_get_column_info( LibmsiView *view, unsigned n, const char **name,
+ unsigned *type, bool *temporary, const char **table_name )
{
LibmsiDistinctView *dv = (LibmsiDistinctView*)view;
diff --git a/libmsi/drop.c b/libmsi/drop.c
index ba59eb4..46303e7 100644
--- a/libmsi/drop.c
+++ b/libmsi/drop.c
@@ -112,12 +112,12 @@ static const LibmsiViewOps drop_ops =
NULL,
};
-unsigned drop_view_create(LibmsiDatabase *db, LibmsiView **view, const WCHAR *name)
+unsigned drop_view_create(LibmsiDatabase *db, LibmsiView **view, const char *name)
{
LibmsiDropView *dv;
unsigned r;
- TRACE("%p %s\n", view, debugstr_w(name));
+ TRACE("%p %s\n", view, debugstr_a(name));
dv = msi_alloc_zero(sizeof *dv );
if(!dv)
diff --git a/libmsi/insert.c b/libmsi/insert.c
index 1ff1293..5f7c422 100644
--- a/libmsi/insert.c
+++ b/libmsi/insert.c
@@ -78,8 +78,8 @@ LibmsiRecord *msi_query_merge_record( unsigned fields, const column_info *vl, Li
switch( vl->val->type )
{
case EXPR_SVAL:
- TRACE("field %d -> %s\n", i, debugstr_w(vl->val->u.sval));
- _libmsi_record_set_stringW( merged, i, vl->val->u.sval );
+ TRACE("field %d -> %s\n", i, debugstr_a(vl->val->u.sval));
+ libmsi_record_set_string( merged, i, vl->val->u.sval );
break;
case EXPR_IVAL:
libmsi_record_set_int( merged, i, vl->val->u.ival );
@@ -107,8 +107,8 @@ err:
*/
static bool msi_columns_in_order(LibmsiInsertView *iv, unsigned col_count)
{
- const WCHAR *a;
- const WCHAR *b;
+ const char *a;
+ const char *b;
unsigned i;
for (i = 1; i <= col_count; i++)
@@ -116,7 +116,7 @@ static bool msi_columns_in_order(LibmsiInsertView *iv, unsigned col_count)
iv->sv->ops->get_column_info(iv->sv, i, &a, NULL, NULL, NULL);
iv->table->ops->get_column_info(iv->table, i, &b, NULL, NULL, NULL);
- if (strcmpW( a, b )) return false;
+ if (strcmp( a, b )) return false;
}
return true;
}
@@ -129,8 +129,8 @@ static unsigned msi_arrange_record(LibmsiInsertView *iv, LibmsiRecord **values)
LibmsiRecord *padded;
unsigned col_count, val_count;
unsigned r, i, colidx;
- const WCHAR *a;
- const WCHAR *b;
+ const char *a;
+ const char *b;
r = iv->table->ops->get_dimensions(iv->table, NULL, &col_count);
if (r != LIBMSI_RESULT_SUCCESS)
@@ -161,7 +161,7 @@ static unsigned msi_arrange_record(LibmsiInsertView *iv, LibmsiRecord **values)
if (r != LIBMSI_RESULT_SUCCESS)
goto err;
- if (!strcmpW( a, b ))
+ if (!strcmp( a, b ))
{
_libmsi_record_copy_field(*values, colidx, padded, i);
break;
@@ -278,8 +278,8 @@ static unsigned insert_view_get_dimensions( LibmsiView *view, unsigned *rows, un
return sv->ops->get_dimensions( sv, rows, cols );
}
-static unsigned insert_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name,
- unsigned *type, bool *temporary, const WCHAR **table_name )
+static unsigned insert_view_get_column_info( LibmsiView *view, unsigned n, const char **name,
+ unsigned *type, bool *temporary, const char **table_name )
{
LibmsiInsertView *iv = (LibmsiInsertView*)view;
LibmsiView *sv;
@@ -348,7 +348,7 @@ static unsigned count_column_info( const column_info *ci )
return n;
}
-unsigned insert_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR *table,
+unsigned insert_view_create( LibmsiDatabase *db, LibmsiView **view, const char *table,
column_info *columns, column_info *values, bool temp )
{
LibmsiInsertView *iv = NULL;
diff --git a/libmsi/msipriv.h b/libmsi/msipriv.h
index ada9eea..db55a1a 100644
--- a/libmsi/msipriv.h
+++ b/libmsi/msipriv.h
@@ -122,7 +122,7 @@ typedef struct LibmsiField
{
int iVal;
intptr_t pVal;
- WCHAR *szwVal;
+ char *szVal;
GsfInput *stream;
} u;
} LibmsiField;
@@ -136,8 +136,8 @@ typedef struct LibmsiRecord
typedef struct _column_info
{
- const WCHAR *table;
- const WCHAR *column;
+ const char *table;
+ const char *column;
int type;
bool temporary;
struct expr *val;
@@ -213,8 +213,8 @@ typedef struct LibmsiViewOps
*
* The column information can be queried at any time.
*/
- unsigned (*get_column_info)( LibmsiView *view, unsigned n, const WCHAR **name, unsigned *type,
- bool *temporary, const WCHAR **table_name );
+ unsigned (*get_column_info)( LibmsiView *view, unsigned n, const char **name, unsigned *type,
+ bool *temporary, const char **table_name );
/*
* delete - destroys the structure completely
@@ -247,12 +247,12 @@ typedef struct LibmsiViewOps
/*
* add_column - adds a column to the table
*/
- unsigned (*add_column)( LibmsiView *view, const WCHAR *table, unsigned number, const WCHAR *column, unsigned type, bool hold );
+ unsigned (*add_column)( LibmsiView *view, const char *table, unsigned number, const char *column, unsigned type, bool hold );
/*
* remove_column - removes the column represented by table name and column number from the table
*/
- unsigned (*remove_column)( LibmsiView *view, const WCHAR *table, unsigned number );
+ unsigned (*remove_column)( LibmsiView *view, const char *table, unsigned number );
/*
* sort - orders the table by columns
@@ -269,7 +269,7 @@ struct LibmsiView
{
const LibmsiViewOps *ops;
LibmsiDBError error;
- const WCHAR *error_column;
+ const char *error_column;
};
#define MSI_MAX_PROPS 20
@@ -311,7 +311,7 @@ typedef struct {
bool unicode;
union {
char *a;
- WCHAR *w;
+ char *w;
} str;
} awstring;
@@ -319,11 +319,11 @@ typedef struct {
bool unicode;
union {
const char *a;
- const WCHAR *w;
+ const char *w;
} str;
} awcstring;
-unsigned msi_strcpy_to_awstring( const WCHAR *str, awstring *awbuf, unsigned *sz );
+unsigned msi_strcpy_to_awstring( const char *str, awstring *awbuf, unsigned *sz );
/* handle functions */
extern void *alloc_msiobject(unsigned size, msihandledestructor destroy );
@@ -341,25 +341,25 @@ enum StringPersistence
StringNonPersistent = 1
};
-extern int _libmsi_add_string( string_table *st, const WCHAR *data, int len, uint16_t refcount, enum StringPersistence persistence );
-extern unsigned _libmsi_id_from_stringW( const string_table *st, const WCHAR *buffer, unsigned *id );
+extern int _libmsi_add_string( string_table *st, const char *data, int len, uint16_t refcount, enum StringPersistence persistence );
+extern unsigned _libmsi_id_from_string_utf8( const string_table *st, const char *buffer, unsigned *id );
extern VOID msi_destroy_stringtable( string_table *st );
-extern const WCHAR *msi_string_lookup_id( const string_table *st, unsigned id );
+extern const char *msi_string_lookup_id( const string_table *st, unsigned id );
extern string_table *msi_init_string_table( unsigned *bytes_per_strref );
extern string_table *msi_load_string_table( GsfInfile *stg, unsigned *bytes_per_strref );
extern unsigned msi_save_string_table( const string_table *st, LibmsiDatabase *db, unsigned *bytes_per_strref );
extern unsigned msi_get_string_table_codepage( const string_table *st );
extern unsigned msi_set_string_table_codepage( string_table *st, unsigned codepage );
-unsigned _libmsi_open_table( LibmsiDatabase *db, const WCHAR *name, bool encoded );
-extern bool table_view_exists( LibmsiDatabase *db, const WCHAR *name );
-extern LibmsiCondition _libmsi_database_is_table_persistent( LibmsiDatabase *db, const WCHAR *table );
+unsigned _libmsi_open_table( LibmsiDatabase *db, const char *name, bool encoded );
+extern bool table_view_exists( LibmsiDatabase *db, const char *name );
+extern LibmsiCondition _libmsi_database_is_table_persistent( LibmsiDatabase *db, const char *table );
-extern unsigned read_stream_data( GsfInfile *stg, const WCHAR *stname,
+extern unsigned read_stream_data( GsfInfile *stg, const char *stname,
uint8_t **pdata, unsigned *psz );
-extern unsigned write_stream_data( LibmsiDatabase *db, const WCHAR *stname,
+extern unsigned write_stream_data( LibmsiDatabase *db, const char *stname,
const void *data, unsigned sz );
-extern unsigned write_raw_stream_data( LibmsiDatabase *db, const WCHAR *stname,
+extern unsigned write_raw_stream_data( LibmsiDatabase *db, const char *stname,
const void *data, unsigned sz, GsfInput **outstm );
extern unsigned _libmsi_database_commit_streams( LibmsiDatabase *db );
@@ -374,14 +374,13 @@ extern unsigned _libmsi_database_commit_storages( LibmsiDatabase *db );
extern void _libmsi_record_destroy( LibmsiObject * );
extern unsigned _libmsi_record_set_gsf_input( LibmsiRecord *, unsigned, GsfInput *);
extern unsigned _libmsi_record_get_gsf_input( const LibmsiRecord *, unsigned, GsfInput **);
-extern const WCHAR *_libmsi_record_get_string_raw( const LibmsiRecord *, unsigned );
+extern const char *_libmsi_record_get_string_raw( const LibmsiRecord *, unsigned );
extern unsigned _libmsi_record_set_int_ptr( LibmsiRecord *, unsigned, intptr_t );
-extern unsigned _libmsi_record_set_stringW( LibmsiRecord *, unsigned, const WCHAR *);
-extern unsigned _libmsi_record_get_stringW( const LibmsiRecord *, unsigned, WCHAR *, unsigned *);
+extern unsigned _libmsi_record_get_string( const LibmsiRecord *, unsigned, char *, unsigned *);
extern intptr_t _libmsi_record_get_int_ptr( const LibmsiRecord *, unsigned );
extern unsigned _libmsi_record_save_stream( const LibmsiRecord *, unsigned, char *, unsigned *);
extern unsigned _libmsi_record_load_stream(LibmsiRecord *, unsigned, GsfInput *);
-extern unsigned _libmsi_record_save_stream_to_file( const LibmsiRecord *, unsigned, const WCHAR *);
+extern unsigned _libmsi_record_save_stream_to_file( const LibmsiRecord *, unsigned, const char *);
extern unsigned _libmsi_record_load_stream_from_file( LibmsiRecord *, unsigned, const char *);
extern unsigned _libmsi_record_copy_field( LibmsiRecord *, unsigned, LibmsiRecord *, unsigned );
extern LibmsiRecord *_libmsi_record_clone( LibmsiRecord * );
@@ -390,53 +389,53 @@ extern bool _libmsi_record_compare_fields(const LibmsiRecord *a, const LibmsiRec
/* stream internals */
extern void enum_stream_names( GsfInfile *stg );
-extern WCHAR *encode_streamname(bool bTable, const WCHAR *in);
-extern void decode_streamname(const WCHAR *in, WCHAR *out);
+extern char *encode_streamname(bool bTable, const char *in);
+extern void decode_streamname(const char *in, char *out);
/* database internals */
extern LibmsiResult _libmsi_database_start_transaction(LibmsiDatabase *db, const char *szPersist);
extern LibmsiResult _libmsi_database_open(LibmsiDatabase *db);
extern LibmsiResult _libmsi_database_close(LibmsiDatabase *db, bool committed);
-unsigned msi_create_stream( LibmsiDatabase *db, const WCHAR *stname, GsfInput *stm );
-extern unsigned msi_get_raw_stream( LibmsiDatabase *, const WCHAR *, GsfInput **);
-void msi_destroy_stream( LibmsiDatabase *, const WCHAR * );
-extern unsigned msi_enum_db_streams(LibmsiDatabase *, unsigned (*fn)(const WCHAR *, GsfInput *, void *), void *);
-unsigned msi_create_storage( LibmsiDatabase *db, const WCHAR *stname, GsfInput *stm );
-unsigned msi_open_storage( LibmsiDatabase *db, const WCHAR *stname );
-void msi_destroy_storage( LibmsiDatabase *db, const WCHAR *stname );
-extern unsigned msi_enum_db_storages(LibmsiDatabase *, unsigned (*fn)(const WCHAR *, GsfInfile *, void *), void *);
-extern unsigned _libmsi_database_open_query(LibmsiDatabase *, const WCHAR *, LibmsiQuery **);
-extern unsigned _libmsi_query_open( LibmsiDatabase *, LibmsiQuery **, const WCHAR *, ... );
+unsigned msi_create_stream( LibmsiDatabase *db, const char *stname, GsfInput *stm );
+extern unsigned msi_get_raw_stream( LibmsiDatabase *, const char *, GsfInput **);
+void msi_destroy_stream( LibmsiDatabase *, const char * );
+extern unsigned msi_enum_db_streams(LibmsiDatabase *, unsigned (*fn)(const char *, GsfInput *, void *), void *);
+unsigned msi_create_storage( LibmsiDatabase *db, const char *stname, GsfInput *stm );
+unsigned msi_open_storage( LibmsiDatabase *db, const char *stname );
+void msi_destroy_storage( LibmsiDatabase *db, const char *stname );
+extern unsigned msi_enum_db_storages(LibmsiDatabase *, unsigned (*fn)(const char *, GsfInfile *, void *), void *);
+extern unsigned _libmsi_database_open_query(LibmsiDatabase *, const char *, LibmsiQuery **);
+extern unsigned _libmsi_query_open( LibmsiDatabase *, LibmsiQuery **, const char *, ... );
typedef unsigned (*record_func)( LibmsiRecord *, void *);
extern unsigned _libmsi_query_iterate_records( LibmsiQuery *, unsigned *, record_func, void *);
-extern LibmsiRecord *_libmsi_query_get_record( LibmsiDatabase *db, const WCHAR *query, ... );
-extern unsigned _libmsi_database_get_primary_keys( LibmsiDatabase *, const WCHAR *, LibmsiRecord **);
+extern LibmsiRecord *_libmsi_query_get_record( LibmsiDatabase *db, const char *query, ... );
+extern unsigned _libmsi_database_get_primary_keys( LibmsiDatabase *, const char *, LibmsiRecord **);
/* view internals */
extern unsigned _libmsi_query_execute( LibmsiQuery*, LibmsiRecord * );
extern unsigned _libmsi_query_fetch( LibmsiQuery*, LibmsiRecord ** );
extern unsigned _libmsi_query_get_column_info(LibmsiQuery *, LibmsiColInfo, LibmsiRecord **);
-extern unsigned _libmsi_view_find_column( LibmsiView *, const WCHAR *, const WCHAR *, unsigned *);
+extern unsigned _libmsi_view_find_column( LibmsiView *, const char *, const char *, unsigned *);
extern unsigned msi_view_get_row(LibmsiDatabase *, LibmsiView *, unsigned, LibmsiRecord **);
/* summary information */
-extern unsigned msi_add_suminfo( LibmsiDatabase *db, WCHAR ***records, int num_records, int num_columns );
+extern unsigned msi_add_suminfo( LibmsiDatabase *db, char ***records, int num_records, int num_columns );
/* Helpers */
-extern WCHAR *msi_dup_record_field(LibmsiRecord *row, int index);
-extern WCHAR *msi_dup_property( LibmsiDatabase *db, const WCHAR *prop );
-extern unsigned msi_set_property( LibmsiDatabase *, const WCHAR *, const WCHAR *);
-extern unsigned msi_get_property( LibmsiDatabase *, const WCHAR *, WCHAR *, unsigned *);
-extern int msi_get_property_int( LibmsiDatabase *package, const WCHAR *prop, int def );
+extern char *msi_dup_record_field(LibmsiRecord *row, int index);
+extern char *msi_dup_property( LibmsiDatabase *db, const char *prop );
+extern unsigned msi_set_property( LibmsiDatabase *, const char *, const char *);
+extern unsigned msi_get_property( LibmsiDatabase *, const char *, char *, unsigned *);
+extern int msi_get_property_int( LibmsiDatabase *package, const char *prop, int def );
/* common strings */
-static const WCHAR szEmpty[] = {0};
-static const WCHAR szStreams[] = {'_','S','t','r','e','a','m','s',0};
-static const WCHAR szStorages[] = {'_','S','t','o','r','a','g','e','s',0};
-static const WCHAR szStringData[] = {'_','S','t','r','i','n','g','D','a','t','a',0};
-static const WCHAR szStringPool[] = {'_','S','t','r','i','n','g','P','o','o','l',0};
-static const WCHAR szName[] = {'N','a','m','e',0};
-static const WCHAR szData[] = {'D','a','t','a',0};
+static const char szEmpty[] = {0};
+static const char szStreams[] = {'_','S','t','r','e','a','m','s',0};
+static const char szStorages[] = {'_','S','t','o','r','a','g','e','s',0};
+static const char szStringData[] = {'_','S','t','r','i','n','g','D','a','t','a',0};
+static const char szStringPool[] = {'_','S','t','r','i','n','g','P','o','o','l',0};
+static const char szName[] = {'N','a','m','e',0};
+static const char szData[] = {'D','a','t','a',0};
/* memory allocation macro functions */
@@ -477,7 +476,7 @@ static inline void msi_free( void *mem )
free(mem);
}
-static inline char *strcpynA( char *dst, const char *src, unsigned count )
+static inline char *strcpyn( char *dst, const char *src, unsigned count )
{
char *d = dst;
const char *s = src;
@@ -491,68 +490,6 @@ static inline char *strcpynA( char *dst, const char *src, unsigned count )
return dst;
}
-static inline char *strdupWtoUTF8( const WCHAR *str )
-{
- char *ret = NULL;
- unsigned len;
-
- if (!str) return ret;
- len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL);
- ret = msi_alloc( len );
- if (ret)
- WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL );
- return ret;
-}
-
-static inline WCHAR *strdupUTF8toW( const char *str )
-{
- WCHAR *ret = NULL;
- unsigned len;
-
- if (!str) return ret;
- len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 );
- ret = msi_alloc( len * sizeof(WCHAR) );
- if (ret)
- MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len );
- return ret;
-}
-
-static inline char *strdupWtoA( const WCHAR *str )
-{
- char *ret = NULL;
- unsigned len;
-
- if (!str) return ret;
- len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
- ret = msi_alloc( len );
- if (ret)
- WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
- return ret;
-}
-
-static inline WCHAR *strdupAtoW( const char *str )
-{
- WCHAR *ret = NULL;
- unsigned len;
-
- if (!str) return ret;
- len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
- ret = msi_alloc( len * sizeof(WCHAR) );
- if (ret)
- MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
- return ret;
-}
-
-static inline WCHAR *strdupW( const WCHAR *src )
-{
- WCHAR *dest;
- if (!src) return NULL;
- dest = msi_alloc( (strlenW(src)+1)*sizeof(WCHAR) );
- if (dest)
- strcpyW(dest, src);
- return dest;
-}
-
#pragma GCC visibility pop
#endif /* __WINE_MSI_PRIVATE__ */
diff --git a/libmsi/msiquery.c b/libmsi/msiquery.c
index 805b5a5..4a12623 100644
--- a/libmsi/msiquery.c
+++ b/libmsi/msiquery.c
@@ -51,10 +51,10 @@ static void _libmsi_query_destroy( LibmsiObject *arg )
}
}
-unsigned _libmsi_view_find_column( LibmsiView *table, const WCHAR *name, const WCHAR *table_name, unsigned *n )
+unsigned _libmsi_view_find_column( LibmsiView *table, const char *name, const char *table_name, unsigned *n )
{
- const WCHAR *col_name;
- const WCHAR *haystack_table_name;
+ const char *col_name;
+ const char *haystack_table_name;
unsigned i, count, r;
r = table->ops->get_dimensions( table, NULL, &count );
@@ -69,9 +69,9 @@ unsigned _libmsi_view_find_column( LibmsiView *table, const WCHAR *name, const W
NULL, &haystack_table_name );
if( r != LIBMSI_RESULT_SUCCESS )
return r;
- x = strcmpW( name, col_name );
+ x = strcmp( name, col_name );
if( table_name )
- x |= strcmpW( table_name, haystack_table_name );
+ x |= strcmp( table_name, haystack_table_name );
if( !x )
{
*n = i;
@@ -85,37 +85,26 @@ LibmsiResult libmsi_database_open_query(LibmsiDatabase *db,
const char *szQuery, LibmsiQuery **pQuery)
{
unsigned r;
- WCHAR *szwQuery;
TRACE("%d %s %p\n", db, debugstr_a(szQuery), pQuery);
- if( szQuery )
- {
- szwQuery = strdupAtoW( szQuery );
- if( !szwQuery )
- return LIBMSI_RESULT_FUNCTION_FAILED;
- }
- else
- szwQuery = NULL;
-
if( !db )
return LIBMSI_RESULT_INVALID_HANDLE;
msiobj_addref( &db->hdr);
- r = _libmsi_database_open_query( db, szwQuery, pQuery );
+ r = _libmsi_database_open_query( db, szQuery, pQuery );
msiobj_release( &db->hdr );
- msi_free( szwQuery );
return r;
}
unsigned _libmsi_database_open_query(LibmsiDatabase *db,
- const WCHAR *szQuery, LibmsiQuery **pView)
+ const char *szQuery, LibmsiQuery **pView)
{
LibmsiQuery *query;
unsigned r;
- TRACE("%s %p\n", debugstr_w(szQuery), pView);
+ TRACE("%s %p\n", debugstr_a(szQuery), pView);
if( !szQuery)
return LIBMSI_RESULT_INVALID_PARAMETER;
@@ -140,19 +129,19 @@ unsigned _libmsi_database_open_query(LibmsiDatabase *db,
return r;
}
-unsigned _libmsi_query_open( LibmsiDatabase *db, LibmsiQuery **view, const WCHAR *fmt, ... )
+unsigned _libmsi_query_open( LibmsiDatabase *db, LibmsiQuery **view, const char *fmt, ... )
{
unsigned r;
int size = 100, res;
- WCHAR *query;
+ char *query;
/* construct the string */
for (;;)
{
va_list va;
- query = msi_alloc( size*sizeof(WCHAR) );
+ query = msi_alloc( size*sizeof(char) );
va_start(va, fmt);
- res = vsnprintfW(query, size, fmt, va);
+ res = vsnprintf(query, size, fmt, va);
va_end(va);
if (res == -1) size *= 2;
else if (res >= size) size = res + 1;
@@ -203,21 +192,21 @@ unsigned _libmsi_query_iterate_records( LibmsiQuery *view, unsigned *count,
}
/* return a single record from a query */
-LibmsiRecord *_libmsi_query_get_record( LibmsiDatabase *db, const WCHAR *fmt, ... )
+LibmsiRecord *_libmsi_query_get_record( LibmsiDatabase *db, const char *fmt, ... )
{
LibmsiRecord *rec = NULL;
LibmsiQuery *view = NULL;
unsigned r;
int size = 100, res;
- WCHAR *query;
+ char *query;
/* construct the string */
for (;;)
{
va_list va;
- query = msi_alloc( size*sizeof(WCHAR) );
+ query = msi_alloc( size*sizeof(char) );
va_start(va, fmt);
- res = vsnprintfW(query, size, fmt, va);
+ res = vsnprintf(query, size, fmt, va);
va_end(va);
if (res == -1) size *= 2;
else if (res >= size) size = res + 1;
@@ -299,10 +288,10 @@ unsigned msi_view_get_row(LibmsiDatabase *db, LibmsiView *view, unsigned row, Li
if (type & MSITYPE_STRING)
{
- const WCHAR *sval;
+ const char *sval;
sval = msi_string_lookup_id(db->strings, ival);
- _libmsi_record_set_stringW(*rec, i, sval);
+ libmsi_record_set_string(*rec, i, sval);
}
else
{
@@ -418,8 +407,8 @@ LibmsiResult libmsi_query_execute(LibmsiQuery *query, LibmsiRecord *rec)
static unsigned msi_set_record_type_string( LibmsiRecord *rec, unsigned field,
unsigned type, bool temporary )
{
- static const WCHAR fmt[] = { '%','d',0 };
- WCHAR szType[0x10];
+ static const char fmt[] = { '%','d',0 };
+ char szType[0x10];
if (MSITYPE_IS_BINARY(type))
szType[0] = 'v';
@@ -445,11 +434,11 @@ static unsigned msi_set_record_type_string( LibmsiRecord *rec, unsigned field,
if (type & MSITYPE_NULLABLE)
szType[0] &= ~0x20;
- sprintfW( &szType[1], fmt, (type&0xff) );
+ sprintf( &szType[1], fmt, (type&0xff) );
- TRACE("type %04x -> %s\n", type, debugstr_w(szType) );
+ TRACE("type %04x -> %s\n", type, debugstr_a(szType) );
- return _libmsi_record_set_stringW( rec, field, szType );
+ return libmsi_record_set_string( rec, field, szType );
}
unsigned _libmsi_query_get_column_info( LibmsiQuery *query, LibmsiColInfo info, LibmsiRecord **prec )
@@ -457,7 +446,7 @@ unsigned _libmsi_query_get_column_info( LibmsiQuery *query, LibmsiColInfo info,
unsigned r = LIBMSI_RESULT_FUNCTION_FAILED, i, count = 0, type;
LibmsiRecord *rec;
LibmsiView *view = query->view;
- const WCHAR *name;
+ const char *name;
bool temporary;
if( !view )
@@ -483,7 +472,7 @@ unsigned _libmsi_query_get_column_info( LibmsiQuery *query, LibmsiColInfo info,
if( r != LIBMSI_RESULT_SUCCESS )
continue;
if (info == LIBMSI_COL_INFO_NAMES)
- _libmsi_record_set_stringW( rec, i+1, name );
+ libmsi_record_set_string( rec, i+1, name );
else
msi_set_record_type_string( rec, i+1, type, temporary );
}
@@ -515,7 +504,7 @@ LibmsiResult libmsi_query_get_column_info(LibmsiQuery *query, LibmsiColInfo info
LibmsiDBError libmsi_query_get_error( LibmsiQuery *query, char *buffer, unsigned *buflen )
{
- const WCHAR *column;
+ const char *column;
LibmsiDBError r;
unsigned len;
@@ -531,15 +520,16 @@ LibmsiDBError libmsi_query_get_error( LibmsiQuery *query, char *buffer, unsigned
if ((r = query->view->error)) column = query->view->error_column;
else column = szEmpty;
- len = WideCharToMultiByte( CP_ACP, 0, column, -1, NULL, 0, NULL, NULL );
+ len = strlen(column);
if (buffer)
{
if (*buflen >= len)
- WideCharToMultiByte( CP_ACP, 0, column, -1, buffer, *buflen, NULL, NULL );
+ strcpy(buffer, column);
else
r = LIBMSI_DB_ERROR_MOREDATA;
}
- *buflen = len - 1;
+
+ *buflen = len;
msiobj_release( &query->hdr );
return r;
}
@@ -621,18 +611,15 @@ static int gsf_infile_copy(GsfInfile *inf, GsfOutfile *outf)
return true;
}
-static unsigned commit_storage( const WCHAR *name, GsfInfile *stg, void *opaque)
+static unsigned commit_storage( const char *name, GsfInfile *stg, void *opaque)
{
LibmsiDatabase *db = opaque;
GsfOutfile *outstg;
unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED;
- char *utf8name;
- TRACE("%s %p %p\n", debugstr_w(name), stg, opaque);
+ TRACE("%s %p %p\n", debugstr_a(name), stg, opaque);
- utf8name = strdupWtoUTF8(name);
- outstg = GSF_OUTFILE(gsf_outfile_new_child( db->outfile, utf8name, true ));
- msi_free( utf8name );
+ outstg = GSF_OUTFILE(gsf_outfile_new_child( db->outfile, name, true ));
if ( !outstg )
return LIBMSI_RESULT_FUNCTION_FAILED;
@@ -647,20 +634,17 @@ end:
return ret;
}
-static unsigned commit_stream( const WCHAR *name, GsfInput *stm, void *opaque)
+static unsigned commit_stream( const char *name, GsfInput *stm, void *opaque)
{
LibmsiDatabase *db = opaque;
GsfOutput *outstm;
unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED;
- WCHAR decname[0x40];
- char *utf8name;
+ char decname[0x40];
decode_streamname(name, decname);
- TRACE("%s(%s) %p %p\n", debugstr_w(name), debugstr_w(decname), stm, opaque);
+ TRACE("%s(%s) %p %p\n", debugstr_a(name), debugstr_a(decname), stm, opaque);
- utf8name = strdupWtoUTF8(name);
- outstm = gsf_outfile_new_child( db->outfile, utf8name, false );
- msi_free( utf8name );
+ outstm = gsf_outfile_new_child( db->outfile, name, false );
if ( !outstm )
return LIBMSI_RESULT_FUNCTION_FAILED;
@@ -744,8 +728,8 @@ struct msi_primary_key_record_info
static unsigned msi_primary_key_iterator( LibmsiRecord *rec, void *param )
{
struct msi_primary_key_record_info *info = param;
- const WCHAR *name;
- const WCHAR *table;
+ const char *name;
+ const char *table;
unsigned type;
type = libmsi_record_get_integer( rec, 4 );
@@ -757,11 +741,11 @@ static unsigned msi_primary_key_iterator( LibmsiRecord *rec, void *param )
if ( info->n == 1 )
{
table = _libmsi_record_get_string_raw( rec, 1 );
- _libmsi_record_set_stringW( info->rec, 0, table);
+ libmsi_record_set_string( info->rec, 0, table);
}
name = _libmsi_record_get_string_raw( rec, 3 );
- _libmsi_record_set_stringW( info->rec, info->n, name );
+ libmsi_record_set_string( info->rec, info->n, name );
}
}
@@ -769,9 +753,9 @@ static unsigned msi_primary_key_iterator( LibmsiRecord *rec, void *param )
}
unsigned _libmsi_database_get_primary_keys( LibmsiDatabase *db,
- const WCHAR *table, LibmsiRecord **prec )
+ const char *table, LibmsiRecord **prec )
{
- static const WCHAR sql[] = {
+ static const char sql[] = {
's','e','l','e','c','t',' ','*',' ',
'f','r','o','m',' ','`','_','C','o','l','u','m','n','s','`',' ',
'w','h','e','r','e',' ',
@@ -812,25 +796,16 @@ unsigned _libmsi_database_get_primary_keys( LibmsiDatabase *db,
LibmsiResult libmsi_database_get_primary_keys(LibmsiDatabase *db,
const char *table, LibmsiRecord **prec)
{
- WCHAR *szwTable = NULL;
unsigned r;
TRACE("%d %s %p\n", db, debugstr_a(table), prec);
- if( table )
- {
- szwTable = strdupAtoW( table );
- if( !szwTable )
- return LIBMSI_RESULT_OUTOFMEMORY;
- }
-
if( !db )
return LIBMSI_RESULT_INVALID_HANDLE;
msiobj_addref( &db->hdr );
- r = _libmsi_database_get_primary_keys( db, szwTable, prec );
+ r = _libmsi_database_get_primary_keys( db, table, prec );
msiobj_release( &db->hdr );
- msi_free( szwTable );
return r;
}
@@ -838,26 +813,17 @@ LibmsiResult libmsi_database_get_primary_keys(LibmsiDatabase *db,
LibmsiCondition libmsi_database_is_table_persistent(
LibmsiDatabase *db, const char *szTableName)
{
- WCHAR *szwTableName = NULL;
LibmsiCondition r;
TRACE("%x %s\n", db, debugstr_a(szTableName));
- if( szTableName )
- {
- szwTableName = strdupAtoW( szTableName );
- if( !szwTableName )
- return LIBMSI_CONDITION_ERROR;
- }
-
msiobj_addref( &db->hdr );
if( !db )
return LIBMSI_CONDITION_ERROR;
- r = _libmsi_database_is_table_persistent( db, szwTableName );
+ r = _libmsi_database_is_table_persistent( db, szTableName );
msiobj_release( &db->hdr );
- msi_free( szwTableName );
return r;
}
diff --git a/libmsi/query.h b/libmsi/query.h
index 48e4ebc..d2c569f 100644
--- a/libmsi/query.h
+++ b/libmsi/query.h
@@ -58,7 +58,7 @@
#define EXPR_UNARY 12
struct sql_str {
- const WCHAR *data;
+ const char *data;
int len;
};
@@ -74,8 +74,8 @@ union ext_column
{
struct
{
- const WCHAR *column;
- const WCHAR *table;
+ const char *column;
+ const char *table;
} unparsed;
struct
{
@@ -92,15 +92,15 @@ struct expr
struct complex_expr expr;
int ival;
unsigned uval;
- const WCHAR *sval;
+ const char *sval;
union ext_column column;
} u;
};
-unsigned _libmsi_parse_sql( LibmsiDatabase *db, const WCHAR *command, LibmsiView **phview,
+unsigned _libmsi_parse_sql( LibmsiDatabase *db, const char *command, LibmsiView **phview,
struct list *mem );
-unsigned table_view_create( LibmsiDatabase *db, const WCHAR *name, LibmsiView **view );
+unsigned table_view_create( LibmsiDatabase *db, const char *name, LibmsiView **view );
unsigned select_view_create( LibmsiDatabase *db, LibmsiView **view, LibmsiView *table,
const column_info *columns );
@@ -110,33 +110,33 @@ unsigned distinct_view_create( LibmsiDatabase *db, LibmsiView **view, LibmsiView
unsigned order_view_create( LibmsiDatabase *db, LibmsiView **view, LibmsiView *table,
column_info *columns );
-unsigned where_view_create( LibmsiDatabase *db, LibmsiView **view, WCHAR *tables,
+unsigned where_view_create( LibmsiDatabase *db, LibmsiView **view, char *tables,
struct expr *cond );
-unsigned create_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR *table,
+unsigned create_view_create( LibmsiDatabase *db, LibmsiView **view, const char *table,
column_info *col_info, bool hold );
-unsigned insert_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR *table,
+unsigned insert_view_create( LibmsiDatabase *db, LibmsiView **view, const char *table,
column_info *columns, column_info *values, bool temp );
-unsigned update_view_create( LibmsiDatabase *db, LibmsiView **view, WCHAR *table,
+unsigned update_view_create( LibmsiDatabase *db, LibmsiView **view, char *table,
column_info *list, struct expr *expr );
unsigned delete_view_create( LibmsiDatabase *db, LibmsiView **view, LibmsiView *table );
-unsigned alter_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR *name, column_info *colinfo, int hold );
+unsigned alter_view_create( LibmsiDatabase *db, LibmsiView **view, const char *name, column_info *colinfo, int hold );
unsigned streams_view_create( LibmsiDatabase *db, LibmsiView **view );
unsigned storages_view_create( LibmsiDatabase *db, LibmsiView **view );
-unsigned drop_view_create( LibmsiDatabase *db, LibmsiView **view, const WCHAR *name );
+unsigned drop_view_create( LibmsiDatabase *db, LibmsiView **view, const char *name );
-int sql_get_token(const WCHAR *z, int *tokenType, int *skip);
+int sql_get_token(const char *z, int *tokenType, int *skip);
LibmsiRecord *msi_query_merge_record( unsigned fields, const column_info *vl, LibmsiRecord *rec );
-unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *col_info,
+unsigned msi_create_table( LibmsiDatabase *db, const char *name, column_info *col_info,
LibmsiCondition persistent );
#pragma GCC visibility pop
diff --git a/libmsi/record.c b/libmsi/record.c
index 524d3bd..d792f55 100644
--- a/libmsi/record.c
+++ b/libmsi/record.c
@@ -40,7 +40,7 @@
#define LIBMSI_FIELD_TYPE_NULL 0
#define LIBMSI_FIELD_TYPE_INT 1
-#define LIBMSI_FIELD_TYPE_WSTR 3
+#define LIBMSI_FIELD_TYPE_STR 3
#define LIBMSI_FIELD_TYPE_STREAM 4
#define LIBMSI_FIELD_TYPE_INTPTR 5
@@ -52,8 +52,8 @@ static void _libmsi_free_field( LibmsiField *field )
case LIBMSI_FIELD_TYPE_INT:
case LIBMSI_FIELD_TYPE_INTPTR:
break;
- case LIBMSI_FIELD_TYPE_WSTR:
- msi_free( field->u.szwVal);
+ case LIBMSI_FIELD_TYPE_STR:
+ msi_free( field->u.szVal);
break;
case LIBMSI_FIELD_TYPE_STREAM:
g_object_unref(G_OBJECT(field->u.stream));
@@ -97,10 +97,10 @@ unsigned libmsi_record_get_field_count( const LibmsiRecord *rec )
return rec->count;
}
-static bool expr_int_from_string( const WCHAR *str, int *out )
+static bool expr_int_from_string( const char *str, int *out )
{
int x = 0;
- const WCHAR *p = str;
+ const char *p = str;
if( *p == '-' ) /* skip the minus sign */
p++;
@@ -129,7 +129,7 @@ unsigned _libmsi_record_copy_field( LibmsiRecord *in_rec, unsigned in_n,
r = LIBMSI_RESULT_FUNCTION_FAILED;
else if ( in_rec != out_rec || in_n != out_n )
{
- WCHAR *str;
+ char *str;
LibmsiField *in, *out;
in = &in_rec->fields[in_n];
@@ -145,12 +145,12 @@ unsigned _libmsi_record_copy_field( LibmsiRecord *in_rec, unsigned in_n,
case LIBMSI_FIELD_TYPE_INTPTR:
out->u.pVal = in->u.pVal;
break;
- case LIBMSI_FIELD_TYPE_WSTR:
- str = strdupW( in->u.szwVal );
+ case LIBMSI_FIELD_TYPE_STR:
+ str = strdup( in->u.szVal );
if ( !str )
r = LIBMSI_RESULT_OUTOFMEMORY;
else
- out->u.szwVal = str;
+ out->u.szVal = str;
break;
case LIBMSI_FIELD_TYPE_STREAM:
g_object_ref(G_OBJECT(in->u.stream));
@@ -181,8 +181,8 @@ intptr_t _libmsi_record_get_int_ptr( const LibmsiRecord *rec, unsigned iField )
return rec->fields[iField].u.iVal;
case LIBMSI_FIELD_TYPE_INTPTR:
return rec->fields[iField].u.pVal;
- case LIBMSI_FIELD_TYPE_WSTR:
- if( expr_int_from_string( rec->fields[iField].u.szwVal, &ret ) )
+ case LIBMSI_FIELD_TYPE_STR:
+ if( expr_int_from_string( rec->fields[iField].u.szVal, &ret ) )
return ret;
return INTPTR_MIN;
default:
@@ -210,8 +210,8 @@ int libmsi_record_get_integer( const LibmsiRecord *rec, unsigned iField)
return rec->fields[iField].u.iVal;
case LIBMSI_FIELD_TYPE_INTPTR:
return rec->fields[iField].u.pVal;
- case LIBMSI_FIELD_TYPE_WSTR:
- if( expr_int_from_string( rec->fields[iField].u.szwVal, &ret ) )
+ case LIBMSI_FIELD_TYPE_STR:
+ if( expr_int_from_string( rec->fields[iField].u.szVal, &ret ) )
return ret;
return MSI_NULL_INTEGER;
default:
@@ -312,21 +312,15 @@ LibmsiResult libmsi_record_get_string(const LibmsiRecord *rec, unsigned iField,
switch( rec->fields[iField].type )
{
case LIBMSI_FIELD_TYPE_INT:
- wsprintfA(buffer, "%d", rec->fields[iField].u.iVal);
+ sprintf(buffer, "%d", rec->fields[iField].u.iVal);
len = strlen( buffer );
if (szValue)
- strcpynA(szValue, buffer, *pcchValue);
+ strcpyn(szValue, buffer, *pcchValue);
break;
- case LIBMSI_FIELD_TYPE_WSTR:
- len = WideCharToMultiByte( CP_ACP, 0, rec->fields[iField].u.szwVal, -1,
- NULL, 0 , NULL, NULL);
+ case LIBMSI_FIELD_TYPE_STR:
+ len = strlen( rec->fields[iField].u.szVal );
if (szValue)
- WideCharToMultiByte( CP_ACP, 0, rec->fields[iField].u.szwVal, -1,
- szValue, *pcchValue, NULL, NULL);
- if( szValue && *pcchValue && len>*pcchValue )
- szValue[*pcchValue-1] = 0;
- if( len )
- len--;
+ strcpyn(szValue, rec->fields[iField].u.szVal, *pcchValue );
break;
case LIBMSI_FIELD_TYPE_NULL:
if( szValue && *pcchValue > 0 )
@@ -344,23 +338,23 @@ LibmsiResult libmsi_record_get_string(const LibmsiRecord *rec, unsigned iField,
return ret;
}
-const WCHAR *_libmsi_record_get_string_raw( const LibmsiRecord *rec, unsigned iField )
+const char *_libmsi_record_get_string_raw( const LibmsiRecord *rec, unsigned iField )
{
if( iField > rec->count )
return NULL;
- if( rec->fields[iField].type != LIBMSI_FIELD_TYPE_WSTR )
+ if( rec->fields[iField].type != LIBMSI_FIELD_TYPE_STR )
return NULL;
- return rec->fields[iField].u.szwVal;
+ return rec->fields[iField].u.szVal;
}
-unsigned _libmsi_record_get_stringW(const LibmsiRecord *rec, unsigned iField,
- WCHAR *szValue, unsigned *pcchValue)
+unsigned _libmsi_record_get_string(const LibmsiRecord *rec, unsigned iField,
+ char *szValue, unsigned *pcchValue)
{
unsigned len=0, ret;
- WCHAR buffer[16];
- static const WCHAR szFormat[] = { '%','d',0 };
+ char buffer[16];
+ static const char szFormat[] = { '%','d',0 };
TRACE("%p %d %p %p\n", rec, iField, szValue, pcchValue);
@@ -377,15 +371,15 @@ unsigned _libmsi_record_get_stringW(const LibmsiRecord *rec, unsigned iField,
switch( rec->fields[iField].type )
{
case LIBMSI_FIELD_TYPE_INT:
- wsprintfW(buffer, szFormat, rec->fields[iField].u.iVal);
- len = strlenW( buffer );
+ sprintf(buffer, szFormat, rec->fields[iField].u.iVal);
+ len = strlen( buffer );
if (szValue)
- strcpynW(szValue, buffer, *pcchValue);
+ strcpyn(szValue, buffer, *pcchValue);
break;
- case LIBMSI_FIELD_TYPE_WSTR:
- len = strlenW( rec->fields[iField].u.szwVal );
+ case LIBMSI_FIELD_TYPE_STR:
+ len = strlen( rec->fields[iField].u.szVal );
if (szValue)
- strcpynW(szValue, rec->fields[iField].u.szwVal, *pcchValue);
+ strcpyn(szValue, rec->fields[iField].u.szVal, *pcchValue);
break;
case LIBMSI_FIELD_TYPE_NULL:
if( szValue && *pcchValue > 0 )
@@ -416,8 +410,8 @@ unsigned libmsi_record_get_field_size(const LibmsiRecord *rec, unsigned iField)
{
case LIBMSI_FIELD_TYPE_INT:
return sizeof (int);
- case LIBMSI_FIELD_TYPE_WSTR:
- return strlenW( rec->fields[iField].u.szwVal );
+ case LIBMSI_FIELD_TYPE_STR:
+ return strlen( rec->fields[iField].u.szVal );
case LIBMSI_FIELD_TYPE_NULL:
break;
case LIBMSI_FIELD_TYPE_STREAM:
@@ -428,23 +422,13 @@ unsigned libmsi_record_get_field_size(const LibmsiRecord *rec, unsigned iField)
LibmsiResult libmsi_record_set_string( LibmsiRecord *rec, unsigned iField, const char *szValue )
{
- WCHAR *str;
+ char *str;
TRACE("%d %d %s\n", rec, iField, debugstr_a(szValue));
if( !rec )
return LIBMSI_RESULT_INVALID_HANDLE;
- str = strdupAtoW( szValue );
- return _libmsi_record_set_stringW( rec, iField, str );
-}
-
-unsigned _libmsi_record_set_stringW( LibmsiRecord *rec, unsigned iField, const WCHAR *szValue )
-{
- WCHAR *str;
-
- TRACE("%p %d %s\n", rec, iField, debugstr_w(szValue));
-
if( iField > rec->count )
return LIBMSI_RESULT_INVALID_FIELD;
@@ -452,14 +436,14 @@ unsigned _libmsi_record_set_stringW( LibmsiRecord *rec, unsigned iField, const W
if( szValue && szValue[0] )
{
- str = strdupW( szValue );
- rec->fields[iField].type = LIBMSI_FIELD_TYPE_WSTR;
- rec->fields[iField].u.szwVal = str;
+ str = strdup( szValue );
+ rec->fields[iField].type = LIBMSI_FIELD_TYPE_STR;
+ rec->fields[iField].u.szVal = str;
}
else
{
rec->fields[iField].type = LIBMSI_FIELD_TYPE_NULL;
- rec->fields[iField].u.szwVal = NULL;
+ rec->fields[iField].u.szVal = NULL;
}
return 0;
@@ -662,15 +646,12 @@ unsigned _libmsi_record_get_gsf_input( const LibmsiRecord *rec, unsigned iField,
return LIBMSI_RESULT_SUCCESS;
}
-static unsigned msi_dump_stream_to_file( GsfInput *stm, const WCHAR *fname )
+static unsigned msi_dump_stream_to_file( GsfInput *stm, const char *name )
{
GsfOutput *out;
- char *name;
bool ok;
- name = strdupWtoA(fname);
out = gsf_output_stdio_new( name, NULL );
- free(name);
if( !out )
return LIBMSI_RESULT_FUNCTION_FAILED;
@@ -682,12 +663,12 @@ static unsigned msi_dump_stream_to_file( GsfInput *stm, const WCHAR *fname )
return LIBMSI_RESULT_SUCCESS;
}
-unsigned _libmsi_record_save_stream_to_file( const LibmsiRecord *rec, unsigned iField, const WCHAR *name )
+unsigned _libmsi_record_save_stream_to_file( const LibmsiRecord *rec, unsigned iField, const char *name )
{
GsfInput *stm = NULL;
unsigned r;
- TRACE("%p %u %s\n", rec, iField, debugstr_w(name));
+ TRACE("%p %u %s\n", rec, iField, debugstr_a(name));
r = _libmsi_record_get_gsf_input( rec, iField, &stm );
if( r == LIBMSI_RESULT_SUCCESS )
@@ -751,8 +732,8 @@ bool _libmsi_record_compare_fields(const LibmsiRecord *a, const LibmsiRecord *b,
return false;
break;
- case LIBMSI_FIELD_TYPE_WSTR:
- if (strcmpW(a->fields[field].u.szwVal, b->fields[field].u.szwVal))
+ case LIBMSI_FIELD_TYPE_STR:
+ if (strcmp(a->fields[field].u.szVal, b->fields[field].u.szVal))
return false;
break;
@@ -780,23 +761,23 @@ bool _libmsi_record_compare(const LibmsiRecord *a, const LibmsiRecord *b)
return true;
}
-WCHAR *msi_dup_record_field( LibmsiRecord *rec, int field )
+char *msi_dup_record_field( LibmsiRecord *rec, int field )
{
unsigned sz = 0;
- WCHAR *str;
+ char *str;
unsigned r;
if (libmsi_record_is_null( rec, field )) return NULL;
- r = _libmsi_record_get_stringW( rec, field, NULL, &sz );
+ r = _libmsi_record_get_string( rec, field, NULL, &sz );
if (r != LIBMSI_RESULT_SUCCESS)
return NULL;
sz++;
- str = msi_alloc( sz * sizeof(WCHAR) );
+ str = msi_alloc( sz * sizeof(char) );
if (!str) return NULL;
str[0] = 0;
- r = _libmsi_record_get_stringW( rec, field, str, &sz );
+ r = _libmsi_record_get_string( rec, field, str, &sz );
if (r != LIBMSI_RESULT_SUCCESS)
{
ERR("failed to get string!\n");
diff --git a/libmsi/select.c b/libmsi/select.c
index 55d9a4b..bbcce29 100644
--- a/libmsi/select.c
+++ b/libmsi/select.c
@@ -214,8 +214,8 @@ static unsigned select_view_get_dimensions( LibmsiView *view, unsigned *rows, un
return sv->table->ops->get_dimensions( sv->table, rows, NULL );
}
-static unsigned select_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name,
- unsigned *type, bool *temporary, const WCHAR **table_name )
+static unsigned select_view_get_column_info( LibmsiView *view, unsigned n, const char **name,
+ unsigned *type, bool *temporary, const char **table_name )
{
LibmsiSelectView *sv = (LibmsiSelectView*)view;
@@ -296,14 +296,14 @@ static const LibmsiViewOps select_ops =
NULL,
};
-static unsigned select_view_add_column( LibmsiSelectView *sv, const WCHAR *name,
- const WCHAR *table_name )
+static unsigned select_view_add_column( LibmsiSelectView *sv, const char *name,
+ const char *table_name )
{
unsigned r, n;
LibmsiView *table;
- TRACE("%p adding %s.%s\n", sv, debugstr_w( table_name ),
- debugstr_w( name ));
+ TRACE("%p adding %s.%s\n", sv, debugstr_a( table_name ),
+ debugstr_a( name ));
if( sv->view.ops != &select_ops )
return LIBMSI_RESULT_FUNCTION_FAILED;
@@ -329,7 +329,7 @@ static unsigned select_view_add_column( LibmsiSelectView *sv, const WCHAR *name,
sv->cols[sv->num_cols] = n;
TRACE("Translating column %s from %d -> %d\n",
- debugstr_w( name ), sv->num_cols, n);
+ debugstr_a( name ), sv->num_cols, n);
sv->num_cols++;
diff --git a/libmsi/sql-parser.y b/libmsi/sql-parser.y
index 0c975f6..8b76124 100644
--- a/libmsi/sql-parser.y
+++ b/libmsi/sql-parser.y
@@ -43,7 +43,7 @@ static int sql_error(void *info, const char *str);
typedef struct LibmsiSQLInput
{
LibmsiDatabase *db;
- const WCHAR *command;
+ const char *command;
unsigned n, len;
unsigned r;
LibmsiView **view; /* View structure for the resulting query. This value
@@ -53,13 +53,13 @@ typedef struct LibmsiSQLInput
struct list *mem;
} SQL_input;
-static unsigned sql_unescape_string( void *info, const struct sql_str *strdata, WCHAR **str );
+static unsigned sql_unescape_string( void *info, const struct sql_str *strdata, char **str );
static INT sql_atoi( void *info );
static int sql_lex( void *SQL_lval, SQL_input *info );
-static WCHAR *parser_add_table( void *info, const WCHAR *list, const WCHAR *table );
+static char *parser_add_table( void *info, const char *list, const char *table );
static void *parser_alloc( void *info, unsigned int sz );
-static column_info *parser_alloc_column( void *info, const WCHAR *table, const WCHAR *column );
+static column_info *parser_alloc_column( void *info, const char *table, const char *column );
static bool sql_mark_primary_keys( column_info **cols, column_info *keys);
@@ -83,7 +83,7 @@ static struct expr * build_expr_wildcard( void *info );
%union
{
struct sql_str str;
- WCHAR *string;
+ char *string;
column_info *column_list;
LibmsiView *query;
struct expr *expr;
@@ -753,18 +753,18 @@ number:
%%
-static WCHAR *parser_add_table( void *info, const WCHAR *list, const WCHAR *table )
+static char *parser_add_table( void *info, const char *list, const char *table )
{
- static const WCHAR space[] = {' ',0};
- unsigned len = strlenW( list ) + strlenW( table ) + 2;
- WCHAR *ret;
+ static const char space[] = {' ',0};
+ unsigned len = strlen( list ) + strlen( table ) + 2;
+ char *ret;
- ret = parser_alloc( info, len * sizeof(WCHAR) );
+ ret = parser_alloc( info, len * sizeof(char) );
if( ret )
{
- strcpyW( ret, list );
- strcatW( ret, space );
- strcatW( ret, table );
+ strcpy( ret, list );
+ strcat( ret, space );
+ strcat( ret, table );
}
return ret;
}
@@ -779,7 +779,7 @@ static void *parser_alloc( void *info, unsigned int sz )
return &mem[1];
}
-static column_info *parser_alloc_column( void *info, const WCHAR *table, const WCHAR *column )
+static column_info *parser_alloc_column( void *info, const char *table, const char *column )
{
column_info *col;
@@ -807,7 +807,7 @@ static int sql_lex( void *SQL_lval, SQL_input *sql )
if( ! sql->command[sql->n] )
return 0; /* end of input */
- /* TRACE("string : %s\n", debugstr_w(&sql->command[sql->n])); */
+ /* TRACE("string : %s\n", debugstr_a(&sql->command[sql->n])); */
sql->len = sql_get_token( &sql->command[sql->n], &token, &skip );
if( sql->len==0 )
break;
@@ -817,14 +817,14 @@ static int sql_lex( void *SQL_lval, SQL_input *sql )
}
while( token == TK_SPACE );
- /* TRACE("token : %d (%s)\n", token, debugstr_wn(&sql->command[sql->n], sql->len)); */
+ /* TRACE("token : %d (%s)\n", token, debugstr_an(&sql->command[sql->n], sql->len)); */
return token;
}
-unsigned sql_unescape_string( void *info, const struct sql_str *strdata, WCHAR **str )
+unsigned sql_unescape_string( void *info, const struct sql_str *strdata, char **str )
{
- const WCHAR *p = strdata->data;
+ const char *p = strdata->data;
unsigned len = strdata->len;
/* match quotes */
@@ -839,10 +839,10 @@ unsigned sql_unescape_string( void *info, const struct sql_str *strdata, WCHAR *
p++;
len -= 2;
}
- *str = parser_alloc( info, (len + 1)*sizeof(WCHAR) );
+ *str = parser_alloc( info, (len + 1)*sizeof(char) );
if( !*str )
return LIBMSI_RESULT_OUTOFMEMORY;
- memcpy( *str, p, len*sizeof(WCHAR) );
+ memcpy( *str, p, len*sizeof(char) );
(*str)[len]=0;
return LIBMSI_RESULT_SUCCESS;
@@ -851,7 +851,7 @@ unsigned sql_unescape_string( void *info, const struct sql_str *strdata, WCHAR *
INT sql_atoi( void *info )
{
SQL_input* sql = (SQL_input*) info;
- const WCHAR *p = &sql->command[sql->n];
+ const char *p = &sql->command[sql->n];
INT i, r = 0;
for( i=0; i<sql->len; i++ )
@@ -937,7 +937,7 @@ static struct expr * build_expr_sval( void *info, const struct sql_str *str )
if( e )
{
e->type = EXPR_SVAL;
- if( sql_unescape_string( info, str, (WCHAR **)&e->u.sval ) != LIBMSI_RESULT_SUCCESS )
+ if( sql_unescape_string( info, str, (char **)&e->u.sval ) != LIBMSI_RESULT_SUCCESS )
return NULL; /* e will be freed by query destructor */
}
return e;
@@ -987,7 +987,7 @@ static bool sql_mark_primary_keys( column_info **cols,
found = false;
for( c = *cols, idx = 0; c && !found; c = c->next, idx++ )
{
- if( strcmpW( k->column, c->column ) )
+ if( strcmp( k->column, c->column ) )
continue;
c->type |= MSITYPE_KEY;
found = true;
@@ -999,7 +999,7 @@ static bool sql_mark_primary_keys( column_info **cols,
return found;
}
-unsigned _libmsi_parse_sql( LibmsiDatabase *db, const WCHAR *command, LibmsiView **phview,
+unsigned _libmsi_parse_sql( LibmsiDatabase *db, const char *command, LibmsiView **phview,
struct list *mem )
{
SQL_input sql;
diff --git a/libmsi/storages.c b/libmsi/storages.c
index 314ddf5..776ce7d 100644
--- a/libmsi/storages.c
+++ b/libmsi/storages.c
@@ -65,7 +65,7 @@ static bool storages_set_table_size(LibmsiStorageView *sv, unsigned size)
return true;
}
-static STORAGE *create_storage(LibmsiStorageView *sv, const WCHAR *name)
+static STORAGE *create_storage(LibmsiStorageView *sv, const char *name)
{
STORAGE *storage;
@@ -120,7 +120,7 @@ static unsigned storages_view_set_row(LibmsiView *view, unsigned row, LibmsiReco
{
LibmsiStorageView *sv = (LibmsiStorageView *)view;
GsfInput *stm;
- WCHAR *name = NULL;
+ char *name = NULL;
unsigned r = LIBMSI_RESULT_FUNCTION_FAILED;
TRACE("(%p, %p)\n", view, rec);
@@ -132,7 +132,7 @@ static unsigned storages_view_set_row(LibmsiView *view, unsigned row, LibmsiReco
if (r != LIBMSI_RESULT_SUCCESS)
return r;
- name = strdupW(_libmsi_record_get_string_raw(rec, 1));
+ name = strdup(_libmsi_record_get_string_raw(rec, 1));
if (!name)
{
r = LIBMSI_RESULT_OUTOFMEMORY;
@@ -169,7 +169,7 @@ static unsigned storages_view_insert_row(LibmsiView *view, LibmsiRecord *rec, un
static unsigned storages_view_delete_row(LibmsiView *view, unsigned row)
{
LibmsiStorageView *sv = (LibmsiStorageView *)view;
- const WCHAR *name;
+ const char *name;
unsigned i;
if (row > sv->num_rows)
@@ -218,8 +218,8 @@ static unsigned storages_view_get_dimensions(LibmsiView *view, unsigned *rows, u
return LIBMSI_RESULT_SUCCESS;
}
-static unsigned storages_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name,
- unsigned *type, bool *temporary, const WCHAR **table_name )
+static unsigned storages_view_get_column_info( LibmsiView *view, unsigned n, const char **name,
+ unsigned *type, bool *temporary, const char **table_name )
{
TRACE("(%p, %d, %p, %p, %p, %p)\n", view, n, name, type, temporary,
table_name);
@@ -312,7 +312,7 @@ static const LibmsiViewOps storages_ops =
NULL,
};
-static unsigned add_storage_to_table(const WCHAR *name, GsfInfile *stg, void *opaque)
+static unsigned add_storage_to_table(const char *name, GsfInfile *stg, void *opaque)
{
LibmsiStorageView *sv = (LibmsiStorageView *)opaque;
STORAGE *storage;
diff --git a/libmsi/streams.c b/libmsi/streams.c
index 25efd19..1858baf 100644
--- a/libmsi/streams.c
+++ b/libmsi/streams.c
@@ -66,10 +66,10 @@ static bool streams_set_table_size(LibmsiStreamsView *sv, unsigned size)
return true;
}
-static STREAM *create_stream(LibmsiStreamsView *sv, const WCHAR *name, bool encoded, GsfInput *stm)
+static STREAM *create_stream(LibmsiStreamsView *sv, const char *name, bool encoded, GsfInput *stm)
{
STREAM *stream;
- WCHAR decoded[MAX_STREAM_NAME_LEN];
+ char decoded[MAX_STREAM_NAME_LEN];
stream = msi_alloc(sizeof(STREAM));
if (!stream)
@@ -78,7 +78,7 @@ static STREAM *create_stream(LibmsiStreamsView *sv, const WCHAR *name, bool enco
if (encoded)
{
decode_streamname(name, decoded);
- TRACE("stream -> %s %s\n", debugstr_w(name), debugstr_w(decoded));
+ TRACE("stream -> %s %s\n", debugstr_a(name), debugstr_a(decoded));
name = decoded;
}
@@ -136,7 +136,7 @@ static unsigned streams_view_set_row(LibmsiView *view, unsigned row, LibmsiRecor
LibmsiStreamsView *sv = (LibmsiStreamsView *)view;
STREAM *stream = NULL;
GsfInput *stm;
- WCHAR *name = NULL;
+ char *name = NULL;
unsigned r;
TRACE("(%p, %d, %p, %08x)\n", view, row, rec, mask);
@@ -148,7 +148,7 @@ static unsigned streams_view_set_row(LibmsiView *view, unsigned row, LibmsiRecor
if (r != LIBMSI_RESULT_SUCCESS)
return r;
- name = strdupW(_libmsi_record_get_string_raw(rec, 1));
+ name = strdup(_libmsi_record_get_string_raw(rec, 1));
if (!name)
{
WARN("failed to retrieve stream name\n");
@@ -203,8 +203,8 @@ static unsigned streams_view_insert_row(LibmsiView *view, LibmsiRecord *rec, uns
static unsigned streams_view_delete_row(LibmsiView *view, unsigned row)
{
LibmsiStreamsView *sv = (LibmsiStreamsView *)view;
- const WCHAR *name;
- WCHAR *encname;
+ const char *name;
+ char *encname;
unsigned i;
if (row > sv->num_rows)
@@ -254,8 +254,8 @@ static unsigned streams_view_get_dimensions(LibmsiView *view, unsigned *rows, un
return LIBMSI_RESULT_SUCCESS;
}
-static unsigned streams_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name,
- unsigned *type, bool *temporary, const WCHAR **table_name )
+static unsigned streams_view_get_column_info( LibmsiView *view, unsigned n, const char **name,
+ unsigned *type, bool *temporary, const char **table_name )
{
TRACE("(%p, %d, %p, %p, %p, %p)\n", view, n, name, type, temporary,
table_name);
@@ -355,7 +355,7 @@ static const LibmsiViewOps streams_ops =
NULL,
};
-static unsigned add_stream_to_table(const WCHAR *name, GsfInput *stm, void *opaque)
+static unsigned add_stream_to_table(const char *name, GsfInput *stm, void *opaque)
{
LibmsiStreamsView *sv = (LibmsiStreamsView *)opaque;
STREAM *stream;
diff --git a/libmsi/string.c b/libmsi/string.c
index 3c89b53..c894d06 100644
--- a/libmsi/string.c
+++ b/libmsi/string.c
@@ -24,6 +24,7 @@
#include <stdarg.h>
#include <assert.h>
+#include <gsf/gsf-msole-utils.h>
#include "windef.h"
#include "winbase.h"
@@ -43,7 +44,7 @@ struct msistring
{
uint16_t persistent_refcount;
uint16_t nonpersistent_refcount;
- WCHAR *str;
+ char *str;
};
struct string_table
@@ -179,7 +180,7 @@ static int find_insert_index( const string_table *st, unsigned string_id )
while (low <= high)
{
i = (low + high) / 2;
- c = strcmpW( st->strings[string_id].str, st->strings[st->sorted[i]].str );
+ c = strcmp( st->strings[string_id].str, st->strings[st->sorted[i]].str );
if (c < 0)
high = i - 1;
@@ -204,7 +205,7 @@ static void insert_string_sorted( string_table *st, unsigned string_id )
st->sortcount++;
}
-static void set_st_entry( string_table *st, unsigned n, WCHAR *str, uint16_t refcount, enum StringPersistence persistence )
+static void set_st_entry( string_table *st, unsigned n, char *str, uint16_t refcount, enum StringPersistence persistence )
{
if (persistence == StringPersistent)
{
@@ -227,9 +228,11 @@ static void set_st_entry( string_table *st, unsigned n, WCHAR *str, uint16_t ref
static unsigned _libmsi_id_from_string( const string_table *st, const char *buffer, unsigned *id )
{
- unsigned sz;
+ size_t sz;
unsigned r = LIBMSI_RESULT_INVALID_PARAMETER;
- WCHAR *str;
+ char *str;
+ int codepage;
+ GIConv cpconv;
TRACE("Finding string %s in string table\n", debugstr_a(buffer) );
@@ -239,24 +242,24 @@ static unsigned _libmsi_id_from_string( const string_table *st, const char *buff
return LIBMSI_RESULT_SUCCESS;
}
- sz = MultiByteToWideChar( st->codepage, 0, buffer, -1, NULL, 0 );
- if( sz <= 0 )
- return r;
- str = msi_alloc( sz*sizeof(WCHAR) );
+ codepage = st->codepage ? st->codepage : gsf_msole_iconv_win_codepage();
+ cpconv = gsf_msole_iconv_open_codepage_for_export(codepage);
+ str = g_convert_with_iconv(buffer, -1, cpconv, NULL, &sz, NULL);
+ g_iconv_close(cpconv);
if( !str )
- return LIBMSI_RESULT_NOT_ENOUGH_MEMORY;
- MultiByteToWideChar( st->codepage, 0, buffer, -1, str, sz );
+ return r;
- r = _libmsi_id_from_stringW( st, str, id );
+ r = _libmsi_id_from_string_utf8( st, str, id );
msi_free( str );
-
return r;
}
static int msi_addstring( string_table *st, unsigned n, const char *data, int len, uint16_t refcount, enum StringPersistence persistence )
{
- WCHAR *str;
- int sz;
+ char *str;
+ size_t sz;
+ int codepage;
+ GIConv cpconv;
if( !data )
return 0;
@@ -290,31 +293,27 @@ static int msi_addstring( string_table *st, unsigned n, const char *data, int le
}
/* allocate a new string */
- if( len < 0 )
- len = strlen(data);
- sz = MultiByteToWideChar( st->codepage, 0, data, len, NULL, 0 );
- str = msi_alloc( (sz+1)*sizeof(WCHAR) );
- if( !str )
- return -1;
- MultiByteToWideChar( st->codepage, 0, data, len, str, sz );
- str[sz] = 0;
+ codepage = st->codepage ? st->codepage : gsf_msole_iconv_win_codepage();
+ cpconv = gsf_msole_iconv_open_for_import(codepage);
+ str = g_convert_with_iconv(data, len, cpconv, NULL, &sz, NULL);
+ g_iconv_close(cpconv);
set_st_entry( st, n, str, refcount, persistence );
return n;
}
-int _libmsi_add_string( string_table *st, const WCHAR *data, int len, uint16_t refcount, enum StringPersistence persistence )
+int _libmsi_add_string( string_table *st, const char *data, int len, uint16_t refcount, enum StringPersistence persistence )
{
unsigned n;
- WCHAR *str;
+ char *str;
if( !data )
return 0;
if( !data[0] )
return 0;
- if( _libmsi_id_from_stringW( st, data, &n ) == LIBMSI_RESULT_SUCCESS )
+ if( _libmsi_id_from_string_utf8( st, data, &n ) == LIBMSI_RESULT_SUCCESS )
{
if (persistence == StringPersistent)
st->strings[n].persistent_refcount += refcount;
@@ -329,13 +328,13 @@ int _libmsi_add_string( string_table *st, const WCHAR *data, int len, uint16_t r
/* allocate a new string */
if(len<0)
- len = strlenW(data);
- TRACE("%s, n = %d len = %d\n", debugstr_w(data), n, len );
+ len = strlen(data);
+ TRACE("%s, n = %d len = %d\n", debugstr_a(data), n, len );
- str = msi_alloc( (len+1)*sizeof(WCHAR) );
+ str = msi_alloc( (len+1)*sizeof(char) );
if( !str )
return -1;
- memcpy( str, data, len*sizeof(WCHAR) );
+ memcpy( str, data, len*sizeof(char) );
str[len] = 0;
set_st_entry( st, n, str, refcount, persistence );
@@ -344,7 +343,7 @@ int _libmsi_add_string( string_table *st, const WCHAR *data, int len, uint16_t r
}
/* find the string identified by an id - return null if there's none */
-const WCHAR *msi_string_lookup_id( const string_table *st, unsigned id )
+const char *msi_string_lookup_id( const string_table *st, unsigned id )
{
if( id == 0 )
return szEmpty;
@@ -367,45 +366,52 @@ const WCHAR *msi_string_lookup_id( const string_table *st, unsigned id )
* [in/out] sz - number of bytes available in the buffer on input
* number of bytes used on output
*
- * Returned string is not nul terminated.
+ * Returned string is not NUL-terminated.
*/
static unsigned _libmsi_string_id( const string_table *st, unsigned id, char *buffer, unsigned *sz )
{
- unsigned len, lenW;
- const WCHAR *str;
+ const char *str_utf8;
+ char *str;
+ size_t len;
+ GIConv cpconv;
+ int codepage;
TRACE("Finding string %d of %d\n", id, st->maxcount);
- str = msi_string_lookup_id( st, id );
- if( !str )
+ str_utf8 = msi_string_lookup_id( st, id );
+ if( !str_utf8 )
return LIBMSI_RESULT_FUNCTION_FAILED;
- lenW = strlenW( str );
- len = WideCharToMultiByte( st->codepage, 0, str, lenW, NULL, 0, NULL, NULL );
+ codepage = st->codepage ? st->codepage : gsf_msole_iconv_win_codepage();
+ cpconv = gsf_msole_iconv_open_codepage_for_export(codepage);
+ str = g_convert_with_iconv(str_utf8, -1, cpconv, NULL, &len, NULL);
+ g_iconv_close(cpconv);
if( *sz < len )
{
*sz = len;
return LIBMSI_RESULT_MORE_DATA;
}
- *sz = WideCharToMultiByte( st->codepage, 0, str, lenW, buffer, *sz, NULL, NULL );
+ *sz = len;
+ memcpy(buffer, str, len);
+ msi_free(str);
return LIBMSI_RESULT_SUCCESS;
}
/*
- * _libmsi_id_from_stringW
+ * _libmsi_id_from_string_utf8
*
* [in] st - pointer to the string table
* [in] str - string to find in the string table
* [out] id - id of the string, if found
*/
-unsigned _libmsi_id_from_stringW( const string_table *st, const WCHAR *str, unsigned *id )
+unsigned _libmsi_id_from_string_utf8( const string_table *st, const char *str, unsigned *id )
{
int i, c, low = 0, high = st->sortcount - 1;
while (low <= high)
{
i = (low + high) / 2;
- c = strcmpW( str, st->strings[st->sorted[i]].str );
+ c = strcmp( str, st->strings[st->sorted[i]].str );
if (c < 0)
high = i - 1;
@@ -423,11 +429,17 @@ unsigned _libmsi_id_from_stringW( const string_table *st, const WCHAR *str, unsi
static void string_totalsize( const string_table *st, unsigned *datasize, unsigned *poolsize )
{
- unsigned i, len, holesize;
+ unsigned i, holesize;
+ size_t len;
+ int codepage;
+ GIConv cpconv;
+ char *str;
if( st->strings[0].str || st->strings[0].persistent_refcount || st->strings[0].nonpersistent_refcount)
ERR("oops. element 0 has a string\n");
+ codepage = st->codepage ? st->codepage : gsf_msole_iconv_win_codepage();
+
*poolsize = 4;
*datasize = 0;
holesize = 0;
@@ -435,16 +447,16 @@ static void string_totalsize( const string_table *st, unsigned *datasize, unsign
{
if( !st->strings[i].persistent_refcount )
{
- TRACE("[%u] nonpersistent = %s\n", i, debugstr_w(st->strings[i].str));
+ TRACE("[%u] nonpersistent = %s\n", i, debugstr_a(st->strings[i].str));
(*poolsize) += 4;
}
else if( st->strings[i].str )
{
- TRACE("[%u] = %s\n", i, debugstr_w(st->strings[i].str));
- len = WideCharToMultiByte( st->codepage, 0,
- st->strings[i].str, -1, NULL, 0, NULL, NULL);
- if( len )
- len--;
+ TRACE("[%u] = %s\n", i, debugstr_a(st->strings[i].str));
+ cpconv = gsf_msole_iconv_open_codepage_for_export(codepage);
+ str = g_convert_with_iconv( st->strings[i].str, -1, cpconv, NULL, &len, NULL);
+ g_iconv_close(cpconv);
+ msi_free(str);
(*datasize) += len;
if (len>0xffff)
(*poolsize) += 4;
diff --git a/libmsi/suminfo.c b/libmsi/suminfo.c
index ec6b551..cc71ae8 100644
--- a/libmsi/suminfo.c
+++ b/libmsi/suminfo.c
@@ -30,7 +30,7 @@
#include "libmsi.h"
#include "msipriv.h"
-static const WCHAR szSumInfo[] = {5 ,'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',0};
+static const char szSumInfo[] = {5 ,'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',0};
static const uint8_t fmtid_SummaryInformation[16] =
{ 0xe0, 0x85, 0x9f, 0xf2, 0xf9, 0x4f, 0x68, 0x10, 0xab, 0x91, 0x08, 0x00, 0x2b, 0x27, 0xb3, 0xd9};
@@ -115,41 +115,41 @@ static unsigned read_dword( const uint8_t *data, unsigned *ofs )
return val;
}
-static void parse_filetime( const WCHAR *str, uint64_t *ft )
+static void parse_filetime( const char *str, uint64_t *ft )
{
struct tm tm;
time_t t;
- const WCHAR *p = str;
- WCHAR *end;
+ const char *p = str;
+ char *end;
/* YYYY/MM/DD hh:mm:ss */
while ( *p == ' ' || *p == '\t' ) p++;
- tm.tm_year = strtolW( p, &end, 10 );
+ tm.tm_year = strtol( p, &end, 10 );
if (*end != '/') return;
p = end + 1;
- tm.tm_mon = strtolW( p, &end, 10 ) - 1;
+ tm.tm_mon = strtol( p, &end, 10 ) - 1;
if (*end != '/') return;
p = end + 1;
- tm.tm_mday = strtolW( p, &end, 10 );
+ tm.tm_mday = strtol( p, &end, 10 );
if (*end != ' ') return;
p = end + 1;
while ( *p == ' ' || *p == '\t' ) p++;
- tm.tm_hour = strtolW( p, &end, 10 );
+ tm.tm_hour = strtol( p, &end, 10 );
if (*end != ':') return;
p = end + 1;
- tm.tm_min = strtolW( p, &end, 10 );
+ tm.tm_min = strtol( p, &end, 10 );
if (*end != ':') return;
p = end + 1;
- tm.tm_sec = strtolW( p, &end, 10 );
+ tm.tm_sec = strtol( p, &end, 10 );
t = mktime(&tm);
@@ -243,9 +243,7 @@ static void read_properties_from_data( LibmsiOLEVariant *prop, const uint8_t *da
if( type == OLEVT_I2 || type == OLEVT_I4) {
property->intval = atoi( str );
} else if( type == OLEVT_FILETIME) {
- WCHAR *wstr = strdupAtoW(str);
- parse_filetime( wstr, &property->filetime );
- msi_free (wstr);
+ parse_filetime( str, &property->filetime );
}
msi_free (str);
}
@@ -553,7 +551,7 @@ LibmsiResult libmsi_summary_info_get_property(
len = strlen( prop->strval );
if( szValueBuf )
- strcpynA(szValueBuf, prop->strval, *pcchValueBuf );
+ strcpyn(szValueBuf, prop->strval, *pcchValueBuf );
if (len >= *pcchValueBuf)
ret = LIBMSI_RESULT_MORE_DATA;
*pcchValueBuf = len;
@@ -670,10 +668,10 @@ LibmsiResult libmsi_summary_info_set_property( LibmsiSummaryInfo *si, unsigned u
return _libmsi_summary_info_set_property( si, uiProperty, type, intvalue, pftValue, szValue );
}
-static unsigned parse_prop( const WCHAR *prop, const WCHAR *value, unsigned *pid, int *int_value,
+static unsigned parse_prop( const char *prop, const char *value, unsigned *pid, int *int_value,
uint64_t *ft_value, char **str_value )
{
- *pid = atoiW( prop );
+ *pid = atoi( prop );
switch (*pid)
{
case MSI_PID_CODEPAGE:
@@ -681,7 +679,7 @@ static unsigned parse_prop( const WCHAR *prop, const WCHAR *value, unsigned *pid
case MSI_PID_CHARCOUNT:
case MSI_PID_SECURITY:
case MSI_PID_PAGECOUNT:
- *int_value = atoiW( value );
+ *int_value = atoi( value );
break;
case MSI_PID_LASTPRINTED:
@@ -699,7 +697,7 @@ static unsigned parse_prop( const WCHAR *prop, const WCHAR *value, unsigned *pid
case MSI_PID_REVNUMBER:
case MSI_PID_APPNAME:
case MSI_PID_TITLE:
- *str_value = strdupWtoA(value);
+ *str_value = strdup(value);
break;
default:
@@ -710,7 +708,7 @@ static unsigned parse_prop( const WCHAR *prop, const WCHAR *value, unsigned *pid
return LIBMSI_RESULT_SUCCESS;
}
-unsigned msi_add_suminfo( LibmsiDatabase *db, WCHAR ***records, int num_records, int num_columns )
+unsigned msi_add_suminfo( LibmsiDatabase *db, char ***records, int num_records, int num_columns )
{
unsigned r = LIBMSI_RESULT_FUNCTION_FAILED;
unsigned i, j;
diff --git a/libmsi/table.c b/libmsi/table.c
index 3c3e942..4366a9e 100644
--- a/libmsi/table.c
+++ b/libmsi/table.c
@@ -41,7 +41,7 @@
#define LibmsiTable_HASH_TABLE_SIZE 37
-static const WCHAR szDot[] = {'.',0};
+static const char szDot[] = {'.',0};
typedef struct LibmsiColumnHashEntry
{
@@ -52,9 +52,9 @@ typedef struct LibmsiColumnHashEntry
typedef struct LibmsiColumnInfo
{
- const WCHAR *tablename;
+ const char *tablename;
unsigned number;
- const WCHAR *colname;
+ const char *colname;
unsigned type;
unsigned offset;
int ref_count;
@@ -72,15 +72,15 @@ struct LibmsiTable
unsigned col_count;
LibmsiCondition persistent;
int ref_count;
- WCHAR name[1];
+ char name[1];
};
/* information for default tables */
-static const WCHAR szTables[] = {'_','T','a','b','l','e','s',0};
-static const WCHAR szTable[] = {'T','a','b','l','e',0};
-static const WCHAR szColumns[] = {'_','C','o','l','u','m','n','s',0};
-static const WCHAR szNumber[] = {'N','u','m','b','e','r',0};
-static const WCHAR szType[] = {'T','y','p','e',0};
+static const char szTables[] = {'_','T','a','b','l','e','s',0};
+static const char szTable[] = {'T','a','b','l','e',0};
+static const char szColumns[] = {'_','C','o','l','u','m','n','s',0};
+static const char szNumber[] = {'N','u','m','b','e','r',0};
+static const char szType[] = {'T','y','p','e',0};
static const LibmsiColumnInfo _Columns_cols[4] = {
{ szColumns, 1, szTable, MSITYPE_VALID | MSITYPE_STRING | MSITYPE_KEY | 64, 0, 0, 0, NULL },
@@ -127,16 +127,15 @@ static int utf2mime(int x)
return -1;
}
-WCHAR *encode_streamname(bool bTable, const WCHAR *in)
+char *encode_streamname(bool bTable, const char *in)
{
unsigned count = MAX_STREAM_NAME;
unsigned ch, next;
- WCHAR *out_wc;
- CHAR *out;
- CHAR *p;
+ char *out;
+ char *p;
if( !bTable )
- count = strlenW( in )+2;
+ count = strlen( in )+2;
if (!(out = msi_alloc( count*3 ))) return NULL;
p = out;
@@ -154,11 +153,7 @@ WCHAR *encode_streamname(bool bTable, const WCHAR *in)
if( !ch )
{
*p = ch;
-
- /* Convert UTF-8 to WCHAR */
- out_wc = strdupUTF8toW(out);
- msi_free(out);
- return out_wc;
+ return out;
}
if( ( ch < 0x80 ) && ( utf2mime(ch) >= 0 ) )
{
@@ -183,11 +178,10 @@ WCHAR *encode_streamname(bool bTable, const WCHAR *in)
in++;
}
} else {
- // *p++ = ch;
- p += WideCharToMultiByte( CP_UTF8, 0, &ch, 1, p, 5, NULL, NULL );
+ *p++ = ch;
}
}
- ERR("Failed to encode stream name (%s)\n",debugstr_w(in));
+ ERR("Failed to encode stream name (%s)\n",debugstr_a(in));
msi_free( out );
return NULL;
}
@@ -205,14 +199,11 @@ static int mime2utf(int x)
return '_';
}
-void decode_streamname(const WCHAR *in, WCHAR *out)
+void decode_streamname(const char *in, char *out)
{
unsigned count = 0;
- uint8_t *enc_utf8 = strdupWtoUTF8(in);
- uint8_t *p = enc_utf8;
-
- uint8_t *dec_utf8 = strdup(enc_utf8);
- uint8_t *q = dec_utf8;
+ const uint8_t *p = (const uint8_t *)in;
+ uint8_t *q = (uint8_t *)out;
while ( *p )
{
@@ -246,51 +237,41 @@ void decode_streamname(const WCHAR *in, WCHAR *out)
count++;
}
*q = 0;
- msi_free(enc_utf8);
-
- /* convert UTF8 to WCHAR */
- MultiByteToWideChar( CP_UTF8, 0, dec_utf8, -1, out, count + 1 );
- msi_free(dec_utf8);
}
void enum_stream_names( GsfInfile *stg )
{
unsigned n, i;
- WCHAR name[0x40];
+ char name[0x40];
n = gsf_infile_num_children(stg);
for (i = 0; i < n; i++)
{
- const char *utf8name = gsf_infile_name_by_index(stg, i);
- WCHAR *stname = strdupUTF8toW(utf8name);
+ const char *stname = gsf_infile_name_by_index(stg, i);
decode_streamname( stname, name );
TRACE("stream %2d -> %s %s\n", n,
- debugstr_w(stname), debugstr_w(name) );
- msi_free(stname);
+ debugstr_a(stname), debugstr_a(name) );
}
}
-unsigned read_stream_data( GsfInfile *stg, const WCHAR *stname,
+unsigned read_stream_data( GsfInfile *stg, const char *stname,
uint8_t **pdata, unsigned *psz )
{
unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED;
VOID *data;
unsigned sz;
GsfInput *stm = NULL;
- WCHAR *encname;
- char *utf8name;
+ char *encname;
encname = encode_streamname(true, stname);
- utf8name = strdupWtoUTF8(encname);
- TRACE("%s -> %s\n",debugstr_w(stname),debugstr_w(encname));
- msi_free(encname);
+ TRACE("%s -> %s\n",debugstr_a(stname),debugstr_a(encname));
if ( !stg )
return LIBMSI_RESULT_FUNCTION_FAILED;
- stm = gsf_infile_child_by_name(stg, utf8name );
- msi_free( utf8name );
+ stm = gsf_infile_child_by_name(stg, encname );
+ msi_free(encname);
if( !stm )
{
WARN("open stream failed - empty table?\n");
@@ -336,23 +317,20 @@ end:
return ret;
}
-unsigned write_stream_data( LibmsiDatabase *db, const WCHAR *stname,
+unsigned write_stream_data( LibmsiDatabase *db, const char *stname,
const void *data, unsigned sz )
{
unsigned ret = LIBMSI_RESULT_FUNCTION_FAILED;
- WCHAR *encname;
- char *utf8name;
+ char *encname;
GsfOutput *stm;
if (!db->outfile)
return ret;
encname = encode_streamname(true, stname );
- utf8name = strdupWtoUTF8(encname);
- msi_free( encname );
- stm = gsf_outfile_new_child( db->outfile, utf8name, false );
- msi_free( utf8name );
+ stm = gsf_outfile_new_child( db->outfile, encname, false );
+ msi_free( encname );
if( !stm )
{
WARN("open stream failed\n");
@@ -414,7 +392,7 @@ static unsigned read_table_from_storage( LibmsiDatabase *db, LibmsiTable *t, Gsf
uint8_t *rawdata = NULL;
unsigned rawsize = 0, i, j, row_size, row_size_mem;
- TRACE("%s\n",debugstr_w(t->name));
+ TRACE("%s\n",debugstr_a(t->name));
row_size = msi_table_get_row_size( db, t->colinfo, t->col_count, db->bytes_per_strref );
row_size_mem = msi_table_get_row_size( db, t->colinfo, t->col_count, LONG_STR_BYTES );
@@ -500,12 +478,12 @@ void free_cached_tables( LibmsiDatabase *db )
}
}
-static LibmsiTable *find_cached_table( LibmsiDatabase *db, const WCHAR *name )
+static LibmsiTable *find_cached_table( LibmsiDatabase *db, const char *name )
{
LibmsiTable *t;
LIST_FOR_EACH_ENTRY( t, &db->tables, LibmsiTable, entry )
- if( !strcmpW( name, t->name ) )
+ if( !strcmp( name, t->name ) )
return t;
return NULL;
@@ -523,24 +501,24 @@ static void table_calc_column_offsets( LibmsiDatabase *db, LibmsiColumnInfo *col
else colinfo[i].offset = 0;
TRACE("column %d is [%s] with type %08x ofs %d\n",
- colinfo[i].number, debugstr_w(colinfo[i].colname),
+ colinfo[i].number, debugstr_a(colinfo[i].colname),
colinfo[i].type, colinfo[i].offset);
}
}
-static unsigned get_defaulttablecolumns( LibmsiDatabase *db, const WCHAR *name, LibmsiColumnInfo *colinfo, unsigned *sz )
+static unsigned get_defaulttablecolumns( LibmsiDatabase *db, const char *name, LibmsiColumnInfo *colinfo, unsigned *sz )
{
const LibmsiColumnInfo *p;
unsigned i, n;
- TRACE("%s\n", debugstr_w(name));
+ TRACE("%s\n", debugstr_a(name));
- if (!strcmpW( name, szTables ))
+ if (!strcmp( name, szTables ))
{
p = _Tables_cols;
n = 1;
}
- else if (!strcmpW( name, szColumns ))
+ else if (!strcmp( name, szColumns ))
{
p = _Columns_cols;
n = 4;
@@ -557,9 +535,9 @@ static unsigned get_defaulttablecolumns( LibmsiDatabase *db, const WCHAR *name,
return LIBMSI_RESULT_SUCCESS;
}
-static unsigned get_tablecolumns( LibmsiDatabase *db, const WCHAR *szTableName, LibmsiColumnInfo *colinfo, unsigned *sz );
+static unsigned get_tablecolumns( LibmsiDatabase *db, const char *szTableName, LibmsiColumnInfo *colinfo, unsigned *sz );
-static unsigned table_get_column_info( LibmsiDatabase *db, const WCHAR *name, LibmsiColumnInfo **pcols, unsigned *pcount )
+static unsigned table_get_column_info( LibmsiDatabase *db, const char *name, LibmsiColumnInfo **pcols, unsigned *pcount )
{
unsigned r, column_count = 0;
LibmsiColumnInfo *columns;
@@ -576,7 +554,7 @@ static unsigned table_get_column_info( LibmsiDatabase *db, const WCHAR *name, Li
if (!column_count)
return LIBMSI_RESULT_INVALID_PARAMETER;
- TRACE("table %s found\n", debugstr_w(name));
+ TRACE("table %s found\n", debugstr_a(name));
columns = msi_alloc( column_count * sizeof(LibmsiColumnInfo) );
if (!columns)
@@ -592,33 +570,33 @@ static unsigned table_get_column_info( LibmsiDatabase *db, const WCHAR *name, Li
return r;
}
-unsigned _libmsi_open_table( LibmsiDatabase *db, const WCHAR *name, bool encoded )
+unsigned _libmsi_open_table( LibmsiDatabase *db, const char *name, bool encoded )
{
- WCHAR decname[0x40];
+ char decname[0x40];
LibmsiTable *table;
if (encoded)
{
- assert(name[0] == 0x4840);
+ assert(name[0] == 0xe4 && name[1] == 0xa1 && name[2] == 0x80);
decode_streamname( name + 1, decname );
name = decname;
}
- table = msi_alloc_zero( sizeof(LibmsiTable) + strlenW( name ) * sizeof(WCHAR) );
+ table = msi_alloc_zero( sizeof(LibmsiTable) + strlen( name ) * sizeof(char) );
if (!table)
return LIBMSI_RESULT_FUNCTION_FAILED;
table->persistent = LIBMSI_CONDITION_TRUE;
- strcpyW( table->name, name );
+ strcpy( table->name, name );
- if (!strcmpW( name, szTables ) || !strcmpW( name, szColumns ))
+ if (!strcmp( name, szTables ) || !strcmp( name, szColumns ))
table->persistent = LIBMSI_CONDITION_NONE;
list_add_head( &db->tables, &table->entry );
return LIBMSI_RESULT_SUCCESS;
}
-static unsigned get_table( LibmsiDatabase *db, const WCHAR *name, LibmsiTable **table_ret )
+static unsigned get_table( LibmsiDatabase *db, const char *name, LibmsiTable **table_ret )
{
LibmsiTable *table;
unsigned r;
@@ -669,12 +647,12 @@ static unsigned read_table_int( uint8_t *const *data, unsigned row, unsigned col
return ret;
}
-static unsigned get_tablecolumns( LibmsiDatabase *db, const WCHAR *szTableName, LibmsiColumnInfo *colinfo, unsigned *sz )
+static unsigned get_tablecolumns( LibmsiDatabase *db, const char *szTableName, LibmsiColumnInfo *colinfo, unsigned *sz )
{
unsigned r, i, n = 0, table_id, count, maxcount = *sz;
LibmsiTable *table = NULL;
- TRACE("%s\n", debugstr_w(szTableName));
+ TRACE("%s\n", debugstr_a(szTableName));
/* first check if there is a default table with that name */
r = get_defaulttablecolumns( db, szTableName, colinfo, sz );
@@ -689,10 +667,10 @@ static unsigned get_tablecolumns( LibmsiDatabase *db, const WCHAR *szTableName,
}
/* convert table and column names to IDs from the string table */
- r = _libmsi_id_from_stringW( db->strings, szTableName, &table_id );
+ r = _libmsi_id_from_string_utf8( db->strings, szTableName, &table_id );
if (r != LIBMSI_RESULT_SUCCESS)
{
- WARN("Couldn't find id for %s\n", debugstr_w(szTableName));
+ WARN("Couldn't find id for %s\n", debugstr_a(szTableName));
return r;
}
TRACE("Table id is %d, row count is %d\n", table_id, table->row_count);
@@ -733,11 +711,11 @@ static unsigned get_tablecolumns( LibmsiDatabase *db, const WCHAR *szTableName,
}
n++;
}
- TRACE("%s has %d columns\n", debugstr_w(szTableName), n);
+ TRACE("%s has %d columns\n", debugstr_a(szTableName), n);
if (colinfo && n != maxcount)
{
- ERR("missing column in table %s\n", debugstr_w(szTableName));
+ ERR("missing column in table %s\n", debugstr_a(szTableName));
msi_free_colinfo( colinfo, maxcount );
return LIBMSI_RESULT_FUNCTION_FAILED;
}
@@ -746,7 +724,7 @@ static unsigned get_tablecolumns( LibmsiDatabase *db, const WCHAR *szTableName,
return LIBMSI_RESULT_SUCCESS;
}
-unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *col_info,
+unsigned msi_create_table( LibmsiDatabase *db, const char *name, column_info *col_info,
LibmsiCondition persistent )
{
enum StringPersistence string_persistence = (persistent) ? StringPersistent : StringNonPersistent;
@@ -760,11 +738,11 @@ unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *c
/* only add tables that don't exist already */
if( table_view_exists(db, name ) )
{
- WARN("table %s exists\n", debugstr_w(name));
+ WARN("table %s exists\n", debugstr_a(name));
return LIBMSI_RESULT_BAD_QUERY_SYNTAX;
}
- table = msi_alloc( sizeof (LibmsiTable) + strlenW(name)*sizeof (WCHAR) );
+ table = msi_alloc( sizeof (LibmsiTable) + strlen(name)*sizeof (char) );
if( !table )
return LIBMSI_RESULT_FUNCTION_FAILED;
@@ -775,7 +753,7 @@ unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *c
table->colinfo = NULL;
table->col_count = 0;
table->persistent = persistent;
- strcpyW( table->name, name );
+ strcpy( table->name, name );
for( col = col_info; col; col = col->next )
table->col_count++;
@@ -820,7 +798,7 @@ unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *c
if( !rec )
goto err;
- r = _libmsi_record_set_stringW( rec, 1, name );
+ r = libmsi_record_set_string( rec, 1, name );
if( r )
goto err;
@@ -851,7 +829,7 @@ unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *c
if( !rec )
goto err;
- r = _libmsi_record_set_stringW( rec, 1, name );
+ r = libmsi_record_set_string( rec, 1, name );
if( r )
goto err;
@@ -866,7 +844,7 @@ unsigned msi_create_table( LibmsiDatabase *db, const WCHAR *name, column_info *c
if( r )
goto err;
- r = _libmsi_record_set_stringW( rec, 3, col->column );
+ r = libmsi_record_set_string( rec, 3, col->column );
if( r )
goto err;
@@ -913,10 +891,10 @@ static unsigned save_table( LibmsiDatabase *db, const LibmsiTable *t, unsigned b
* we can just skip them if they are empty. However, always
* save the Tables stream.
*/
- if ( t->row_count == 0 && strcmpW(t->name, szTables) )
+ if ( t->row_count == 0 && strcmp(t->name, szTables) )
return LIBMSI_RESULT_SUCCESS;
- TRACE("Saving %s\n", debugstr_w( t->name ) );
+ TRACE("Saving %s\n", debugstr_a( t->name ) );
row_size = msi_table_get_row_size( db, t->colinfo, t->col_count, bytes_per_strref );
row_count = t->row_count;
@@ -981,7 +959,7 @@ err:
return r;
}
-static void msi_update_table_columns( LibmsiDatabase *db, const WCHAR *name )
+static void msi_update_table_columns( LibmsiDatabase *db, const char *name )
{
LibmsiTable *table;
unsigned size, offset, old_count;
@@ -1008,26 +986,26 @@ static void msi_update_table_columns( LibmsiDatabase *db, const WCHAR *name )
}
/* try to find the table name in the _Tables table */
-bool table_view_exists( LibmsiDatabase *db, const WCHAR *name )
+bool table_view_exists( LibmsiDatabase *db, const char *name )
{
unsigned r, table_id, i;
LibmsiTable *table;
- if( !strcmpW( name, szTables ) || !strcmpW( name, szColumns ) ||
- !strcmpW( name, szStreams ) || !strcmpW( name, szStorages ) )
+ if( !strcmp( name, szTables ) || !strcmp( name, szColumns ) ||
+ !strcmp( name, szStreams ) || !strcmp( name, szStorages ) )
return true;
- r = _libmsi_id_from_stringW( db->strings, name, &table_id );
+ r = _libmsi_id_from_string_utf8( db->strings, name, &table_id );
if( r != LIBMSI_RESULT_SUCCESS )
{
- TRACE("Couldn't find id for %s\n", debugstr_w(name));
+ TRACE("Couldn't find id for %s\n", debugstr_a(name));
return false;
}
r = get_table( db, szTables, &table );
if( r != LIBMSI_RESULT_SUCCESS )
{
- ERR("table %s not available\n", debugstr_w(szTables));
+ ERR("table %s not available\n", debugstr_a(szTables));
return false;
}
@@ -1050,7 +1028,7 @@ typedef struct LibmsiTableView
LibmsiColumnInfo *columns;
unsigned num_cols;
unsigned row_size;
- WCHAR name[1];
+ char name[1];
} LibmsiTableView;
static unsigned table_view_fetch_int( LibmsiView *view, unsigned row, unsigned col, unsigned *val )
@@ -1090,33 +1068,33 @@ static unsigned table_view_fetch_int( LibmsiView *view, unsigned row, unsigned c
return LIBMSI_RESULT_SUCCESS;
}
-static unsigned msi_stream_name( const LibmsiTableView *tv, unsigned row, WCHAR **pstname )
+static unsigned msi_stream_name( const LibmsiTableView *tv, unsigned row, char **pstname )
{
- WCHAR *p;
- WCHAR *stname = NULL;
+ char *p;
+ char *stname = NULL;
unsigned i, r, type, ival;
unsigned len;
- const WCHAR *sval;
+ const char *sval;
LibmsiView *view = (LibmsiView *) tv;
TRACE("%p %d\n", tv, row);
- len = strlenW( tv->name ) + 1;
- stname = msi_alloc( len*sizeof(WCHAR) );
+ len = strlen( tv->name ) + 1;
+ stname = msi_alloc( len*sizeof(char) );
if ( !stname )
{
r = LIBMSI_RESULT_OUTOFMEMORY;
goto err;
}
- strcpyW( stname, tv->name );
+ strcpy( stname, tv->name );
for ( i = 0; i < tv->num_cols; i++ )
{
type = tv->columns[i].type;
if ( type & MSITYPE_KEY )
{
- WCHAR number[0x20];
+ char number[0x20];
r = table_view_fetch_int( view, row, i+1, &ival );
if ( r != LIBMSI_RESULT_SUCCESS )
@@ -1133,16 +1111,16 @@ static unsigned msi_stream_name( const LibmsiTableView *tv, unsigned row, WCHAR
}
else
{
- static const WCHAR fmt[] = { '%','d',0 };
+ static const char fmt[] = { '%','d',0 };
unsigned n = bytes_per_column( tv->db, &tv->columns[i], LONG_STR_BYTES );
switch( n )
{
case 2:
- sprintfW( number, fmt, ival-0x8000 );
+ sprintf( number, fmt, ival-0x8000 );
break;
case 4:
- sprintfW( number, fmt, ival^0x80000000 );
+ sprintf( number, fmt, ival^0x80000000 );
break;
default:
ERR( "oops - unknown column width %d\n", n );
@@ -1152,8 +1130,8 @@ static unsigned msi_stream_name( const LibmsiTableView *tv, unsigned row, WCHAR
sval = number;
}
- len += strlenW( szDot ) + strlenW( sval );
- p = msi_realloc ( stname, len*sizeof(WCHAR) );
+ len += strlen( szDot ) + strlen( sval );
+ p = msi_realloc ( stname, len*sizeof(char) );
if ( !p )
{
r = LIBMSI_RESULT_OUTOFMEMORY;
@@ -1161,8 +1139,8 @@ static unsigned msi_stream_name( const LibmsiTableView *tv, unsigned row, WCHAR
}
stname = p;
- strcatW( stname, szDot );
- strcatW( stname, sval );
+ strcat( stname, szDot );
+ strcat( stname, sval );
}
else
continue;
@@ -1186,8 +1164,8 @@ static unsigned table_view_fetch_stream( LibmsiView *view, unsigned row, unsigne
{
LibmsiTableView *tv = (LibmsiTableView*)view;
unsigned r;
- WCHAR *encname;
- WCHAR *full_name = NULL;
+ char *encname;
+ char *full_name = NULL;
if( !view->ops->fetch_int )
return LIBMSI_RESULT_INVALID_PARAMETER;
@@ -1202,7 +1180,7 @@ static unsigned table_view_fetch_stream( LibmsiView *view, unsigned row, unsigne
encname = encode_streamname( false, full_name );
r = msi_get_raw_stream( tv->db, encname, stm );
if( r )
- ERR("fetching stream %s, error = %d\n",debugstr_w(full_name), r);
+ ERR("fetching stream %s, error = %d\n",debugstr_a(full_name), r);
msi_free( full_name );
msi_free( encname );
@@ -1256,9 +1234,9 @@ static unsigned table_view_get_row( LibmsiView *view, unsigned row, LibmsiRecord
return msi_view_get_row(tv->db, view, row, rec);
}
-static unsigned _libmsi_add_stream( LibmsiDatabase *db, const WCHAR *name, GsfInput *data )
+static unsigned _libmsi_add_stream( LibmsiDatabase *db, const char *name, GsfInput *data )
{
- static const WCHAR insert[] = {
+ static const char insert[] = {
'I','N','S','E','R','T',' ','I','N','T','O',' ',
'`','_','S','t','r','e','a','m','s','`',' ',
'(','`','N','a','m','e','`',',','`','D','a','t','a','`',')',' ',
@@ -1267,13 +1245,13 @@ static unsigned _libmsi_add_stream( LibmsiDatabase *db, const WCHAR *name, GsfIn
LibmsiRecord *rec;
unsigned r;
- TRACE("%p %s %p\n", db, debugstr_w(name), data);
+ TRACE("%p %s %p\n", db, debugstr_a(name), data);
rec = libmsi_record_create( 2 );
if ( !rec )
return LIBMSI_RESULT_OUTOFMEMORY;
- r = _libmsi_record_set_stringW( rec, 1, name );
+ r = libmsi_record_set_string( rec, 1, name );
if ( r != LIBMSI_RESULT_SUCCESS )
goto err;
@@ -1311,10 +1289,10 @@ static unsigned get_table_value_from_record( LibmsiTableView *tv, LibmsiRecord *
}
else if ( columninfo.type & MSITYPE_STRING )
{
- const WCHAR *sval = _libmsi_record_get_string_raw( rec, iField );
+ const char *sval = _libmsi_record_get_string_raw( rec, iField );
if (sval)
{
- r = _libmsi_id_from_stringW(tv->db->strings, sval, pvalue);
+ r = _libmsi_id_from_string_utf8(tv->db->strings, sval, pvalue);
if (r != LIBMSI_RESULT_SUCCESS)
return LIBMSI_RESULT_NOT_FOUND;
}
@@ -1369,7 +1347,7 @@ static unsigned table_view_set_row( LibmsiView *view, unsigned row, LibmsiRecord
if ( MSITYPE_IS_BINARY(tv->columns[ i ].type) )
{
GsfInput *stm;
- WCHAR *stname;
+ char *stname;
if ( r != LIBMSI_RESULT_SUCCESS )
return LIBMSI_RESULT_FUNCTION_FAILED;
@@ -1398,7 +1376,7 @@ static unsigned table_view_set_row( LibmsiView *view, unsigned row, LibmsiRecord
if ( r != LIBMSI_RESULT_SUCCESS )
{
- const WCHAR *sval = _libmsi_record_get_string_raw( rec, i + 1 );
+ const char *sval = _libmsi_record_get_string_raw( rec, i + 1 );
val = _libmsi_add_string( tv->db->strings, sval, -1, 1,
persistent ? StringPersistent : StringNonPersistent );
}
@@ -1519,8 +1497,8 @@ static unsigned table_view_get_dimensions( LibmsiView *view, unsigned *rows, uns
}
static unsigned table_view_get_column_info( LibmsiView *view,
- unsigned n, const WCHAR **name, unsigned *type, bool *temporary,
- const WCHAR **table_name )
+ unsigned n, const char **name, unsigned *type, bool *temporary,
+ const char **table_name )
{
LibmsiTableView *tv = (LibmsiTableView*)view;
@@ -1568,7 +1546,7 @@ static unsigned table_validate_new( LibmsiTableView *tv, LibmsiRecord *rec, unsi
TRACE("skipping binary column\n");
else if ( tv->columns[i].type & MSITYPE_STRING )
{
- const WCHAR *str;
+ const char *str;
str = _libmsi_record_get_string_raw( rec, i+1 );
if (str == NULL || str[0] == 0)
@@ -1836,7 +1814,7 @@ static unsigned table_view_add_ref(LibmsiView *view)
return __sync_add_and_fetch(&tv->table->ref_count, 1);
}
-static unsigned table_view_remove_column(LibmsiView *view, const WCHAR *table, unsigned number)
+static unsigned table_view_remove_column(LibmsiView *view, const char *table, unsigned number)
{
LibmsiTableView *tv = (LibmsiTableView*)view;
LibmsiRecord *rec = NULL;
@@ -1847,7 +1825,7 @@ static unsigned table_view_remove_column(LibmsiView *view, const WCHAR *table, u
if (!rec)
return LIBMSI_RESULT_OUTOFMEMORY;
- _libmsi_record_set_stringW(rec, 1, table);
+ libmsi_record_set_string(rec, 1, table);
libmsi_record_set_int(rec, 2, number);
r = table_view_create(tv->db, szColumns, &columns);
@@ -1907,8 +1885,8 @@ static unsigned table_view_release(LibmsiView *view)
return ref;
}
-static unsigned table_view_add_column(LibmsiView *view, const WCHAR *table, unsigned number,
- const WCHAR *column, unsigned type, bool hold)
+static unsigned table_view_add_column(LibmsiView *view, const char *table, unsigned number,
+ const char *column, unsigned type, bool hold)
{
LibmsiTableView *tv = (LibmsiTableView*)view;
LibmsiTable *msitable;
@@ -1919,9 +1897,9 @@ static unsigned table_view_add_column(LibmsiView *view, const WCHAR *table, unsi
if (!rec)
return LIBMSI_RESULT_OUTOFMEMORY;
- _libmsi_record_set_stringW(rec, 1, table);
+ libmsi_record_set_string(rec, 1, table);
libmsi_record_set_int(rec, 2, number);
- _libmsi_record_set_stringW(rec, 3, column);
+ libmsi_record_set_string(rec, 3, column);
libmsi_record_set_int(rec, 4, type);
r = table_view_insert_row(&tv->view, rec, -1, false);
@@ -1936,7 +1914,7 @@ static unsigned table_view_add_column(LibmsiView *view, const WCHAR *table, unsi
msitable = find_cached_table(tv->db, table);
for (i = 0; i < msitable->col_count; i++)
{
- if (!strcmpW( msitable->colinfo[i].colname, column ))
+ if (!strcmp( msitable->colinfo[i].colname, column ))
{
__sync_add_and_fetch(&msitable->colinfo[i].ref_count, 1);
break;
@@ -1956,7 +1934,7 @@ static unsigned table_view_drop(LibmsiView *view)
unsigned r, row;
int i;
- TRACE("dropping table %s\n", debugstr_w(tv->name));
+ TRACE("dropping table %s\n", debugstr_a(tv->name));
for (i = tv->table->col_count - 1; i >= 0; i--)
{
@@ -1970,7 +1948,7 @@ static unsigned table_view_drop(LibmsiView *view)
if (!rec)
return LIBMSI_RESULT_OUTOFMEMORY;
- _libmsi_record_set_stringW(rec, 1, tv->name);
+ libmsi_record_set_string(rec, 1, tv->name);
r = table_view_create(tv->db, szTables, &tables);
if (r != LIBMSI_RESULT_SUCCESS)
@@ -2016,19 +1994,19 @@ static const LibmsiViewOps table_ops =
table_view_drop,
};
-unsigned table_view_create( LibmsiDatabase *db, const WCHAR *name, LibmsiView **view )
+unsigned table_view_create( LibmsiDatabase *db, const char *name, LibmsiView **view )
{
LibmsiTableView *tv ;
unsigned r, sz;
- TRACE("%p %s %p\n", db, debugstr_w(name), view );
+ TRACE("%p %s %p\n", db, debugstr_a(name), view );
- if ( !strcmpW( name, szStreams ) )
+ if ( !strcmp( name, szStreams ) )
return streams_view_create( db, view );
- else if ( !strcmpW( name, szStorages ) )
+ else if ( !strcmp( name, szStorages ) )
return storages_view_create( db, view );
- sz = sizeof *tv + strlenW(name)*sizeof name[0] ;
+ sz = sizeof *tv + strlen(name)*sizeof name[0] ;
tv = msi_alloc_zero( sz );
if( !tv )
return LIBMSI_RESULT_FUNCTION_FAILED;
@@ -2050,10 +2028,10 @@ unsigned table_view_create( LibmsiDatabase *db, const WCHAR *name, LibmsiView **
tv->num_cols = tv->table->col_count;
tv->row_size = msi_table_get_row_size( db, tv->table->colinfo, tv->table->col_count, LONG_STR_BYTES );
- TRACE("%s one row is %d bytes\n", debugstr_w(name), tv->row_size );
+ TRACE("%s one row is %d bytes\n", debugstr_a(name), tv->row_size );
*view = (LibmsiView*) tv;
- strcpyW( tv->name, name );
+ strcpy( tv->name, name );
return LIBMSI_RESULT_SUCCESS;
}
@@ -2075,14 +2053,14 @@ unsigned _libmsi_database_commit_tables( LibmsiDatabase *db, unsigned bytes_per_
if( r != LIBMSI_RESULT_SUCCESS )
{
WARN("failed to load table %s (r=%08x)\n",
- debugstr_w(table->name), r);
+ debugstr_a(table->name), r);
return r;
}
r = save_table( db, table, bytes_per_strref );
if( r != LIBMSI_RESULT_SUCCESS )
{
WARN("failed to save table %s (r=%08x)\n",
- debugstr_w(table->name), r);
+ debugstr_a(table->name), r);
return r;
}
list_remove(&table->entry);
@@ -2092,12 +2070,12 @@ unsigned _libmsi_database_commit_tables( LibmsiDatabase *db, unsigned bytes_per_
return r;
}
-LibmsiCondition _libmsi_database_is_table_persistent( LibmsiDatabase *db, const WCHAR *table )
+LibmsiCondition _libmsi_database_is_table_persistent( LibmsiDatabase *db, const char *table )
{
LibmsiTable *t;
unsigned r;
- TRACE("%p %s\n", db, debugstr_w(table));
+ TRACE("%p %s\n", db, debugstr_a(table));
if (!table)
return LIBMSI_CONDITION_ERROR;
@@ -2119,25 +2097,25 @@ static unsigned read_raw_int(const uint8_t *data, unsigned col, unsigned bytes)
return ret;
}
-static unsigned msi_record_encoded_stream_name( const LibmsiTableView *tv, LibmsiRecord *rec, WCHAR **pstname )
+static unsigned msi_record_encoded_stream_name( const LibmsiTableView *tv, LibmsiRecord *rec, char **pstname )
{
- WCHAR *stname = NULL;
- WCHAR *sval;
- WCHAR *p;
+ char *stname = NULL;
+ char *sval;
+ char *p;
unsigned len;
unsigned i, r;
TRACE("%p %p\n", tv, rec);
- len = strlenW( tv->name ) + 1;
- stname = msi_alloc( len*sizeof(WCHAR) );
+ len = strlen( tv->name ) + 1;
+ stname = msi_alloc( len*sizeof(char) );
if ( !stname )
{
r = LIBMSI_RESULT_OUTOFMEMORY;
goto err;
}
- strcpyW( stname, tv->name );
+ strcpy( stname, tv->name );
for ( i = 0; i < tv->num_cols; i++ )
{
@@ -2150,8 +2128,8 @@ static unsigned msi_record_encoded_stream_name( const LibmsiTableView *tv, Libms
goto err;
}
- len += strlenW( szDot ) + strlenW ( sval );
- p = msi_realloc ( stname, len*sizeof(WCHAR) );
+ len += strlen( szDot ) + strlen ( sval );
+ p = msi_realloc ( stname, len*sizeof(char) );
if ( !p )
{
r = LIBMSI_RESULT_OUTOFMEMORY;
@@ -2159,8 +2137,8 @@ static unsigned msi_record_encoded_stream_name( const LibmsiTableView *tv, Libms
}
stname = p;
- strcatW( stname, szDot );
- strcatW( stname, sval );
+ strcat( stname, szDot );
+ strcat( stname, sval );
msi_free( sval );
}
@@ -2206,8 +2184,7 @@ static LibmsiRecord *msi_get_transform_record( const LibmsiTableView *tv, const
if( MSITYPE_IS_BINARY(tv->columns[i].type) )
{
- WCHAR *encname;
- char *utf8name;
+ char *encname;
GsfInput *stm = NULL;
unsigned r;
@@ -2217,9 +2194,7 @@ static LibmsiRecord *msi_get_transform_record( const LibmsiTableView *tv, const
if ( r != LIBMSI_RESULT_SUCCESS )
return NULL;
- utf8name = strdupWtoUTF8(encname);
- stm = gsf_infile_child_by_name( stg, utf8name );
- msi_free(utf8name);
+ stm = gsf_infile_child_by_name( stg, encname );
if ( r != LIBMSI_RESULT_SUCCESS )
{
msi_free( encname );
@@ -2227,17 +2202,17 @@ static LibmsiRecord *msi_get_transform_record( const LibmsiTableView *tv, const
}
_libmsi_record_load_stream( rec, i+1, stm );
- TRACE(" field %d [%s]\n", i+1, debugstr_w(encname));
+ TRACE(" field %d [%s]\n", i+1, debugstr_a(encname));
msi_free( encname );
}
else if( columns[i].type & MSITYPE_STRING )
{
- const WCHAR *sval;
+ const char *sval;
val = read_raw_int(rawdata, ofs, bytes_per_strref);
sval = msi_string_lookup_id( st, val );
- _libmsi_record_set_stringW( rec, i+1, sval );
- TRACE(" field %d [%s]\n", i+1, debugstr_w(sval));
+ libmsi_record_set_string( rec, i+1, sval );
+ TRACE(" field %d [%s]\n", i+1, debugstr_a(sval));
ofs += bytes_per_strref;
}
else
@@ -2274,12 +2249,12 @@ static void dump_record( LibmsiRecord *rec )
n = libmsi_record_get_field_count( rec );
for( i=1; i<=n; i++ )
{
- const WCHAR *sval;
+ const char *sval;
if( libmsi_record_is_null( rec, i ) )
TRACE("row -> []\n");
else if( (sval = _libmsi_record_get_string_raw( rec, i )) )
- TRACE("row -> [%s]\n", debugstr_w(sval));
+ TRACE("row -> [%s]\n", debugstr_a(sval));
else
TRACE("row -> [0x%08x]\n", libmsi_record_get_integer( rec, i ) );
}
@@ -2287,19 +2262,19 @@ static void dump_record( LibmsiRecord *rec )
static void dump_table( const string_table *st, const uint16_t *rawdata, unsigned rawsize )
{
- const WCHAR *sval;
+ const char *sval;
unsigned i;
for( i=0; i<(rawsize/2); i++ )
{
sval = msi_string_lookup_id( st, rawdata[i] );
- TRACE(" %04x %s\n", rawdata[i], debugstr_w(sval) );
+ TRACE(" %04x %s\n", rawdata[i], debugstr_a(sval) );
}
}
static unsigned* msi_record_to_row( const LibmsiTableView *tv, LibmsiRecord *rec )
{
- const WCHAR *str;
+ const char *str;
unsigned i, r, *data;
data = msi_alloc( tv->num_cols *sizeof (unsigned) );
@@ -2317,7 +2292,7 @@ static unsigned* msi_record_to_row( const LibmsiTableView *tv, LibmsiRecord *rec
str = _libmsi_record_get_string_raw( rec, i+1 );
if (str)
{
- r = _libmsi_id_from_stringW( tv->db->strings, str, &data[i] );
+ r = _libmsi_id_from_string_utf8( tv->db->strings, str, &data[i] );
/* if there's no matching string in the string table,
these keys can't match any record, so fail now. */
@@ -2396,7 +2371,7 @@ static unsigned msi_table_find_row( LibmsiTableView *tv, LibmsiRecord *rec, unsi
typedef struct
{
struct list entry;
- WCHAR *name;
+ char *name;
} TRANSFORMDATA;
static unsigned msi_table_load_transform( LibmsiDatabase *db, GsfInfile *stg,
@@ -2407,8 +2382,8 @@ static unsigned msi_table_load_transform( LibmsiDatabase *db, GsfInfile *stg,
LibmsiTableView *tv = NULL;
unsigned r, n, sz, i, mask, num_cols, colcol = 0, rawsize = 0;
LibmsiRecord *rec = NULL;
- WCHAR coltable[32];
- const WCHAR *name;
+ char coltable[32];
+ const char *name;
if (!transform)
return LIBMSI_RESULT_SUCCESS;
@@ -2416,13 +2391,13 @@ static unsigned msi_table_load_transform( LibmsiDatabase *db, GsfInfile *stg,
name = transform->name;
coltable[0] = 0;
- TRACE("%p %p %p %s\n", db, stg, st, debugstr_w(name) );
+ TRACE("%p %p %p %s\n", db, stg, st, debugstr_a(name) );
/* read the transform data */
read_stream_data( stg, name, &rawdata, &rawsize );
if ( !rawdata )
{
- TRACE("table %s empty\n", debugstr_w(name) );
+ TRACE("table %s empty\n", debugstr_a(name) );
return LIBMSI_RESULT_INVALID_TABLE;
}
@@ -2436,7 +2411,7 @@ static unsigned msi_table_load_transform( LibmsiDatabase *db, GsfInfile *stg,
goto err;
TRACE("name = %s columns = %u row_size = %u raw size = %u\n",
- debugstr_w(name), tv->num_cols, tv->row_size, rawsize );
+ debugstr_a(name), tv->num_cols, tv->row_size, rawsize );
/* interpret the data */
for (n = 0; n < rawsize;)
@@ -2495,14 +2470,14 @@ static unsigned msi_table_load_transform( LibmsiDatabase *db, GsfInfile *stg,
rec = msi_get_transform_record( tv, st, stg, &rawdata[n], bytes_per_strref );
if (rec)
{
- WCHAR table[32];
+ char table[32];
unsigned sz = 32;
unsigned number = MSI_NULL_INTEGER;
unsigned row = 0;
- if (!strcmpW( name, szColumns ))
+ if (!strcmp( name, szColumns ))
{
- _libmsi_record_get_stringW( rec, 1, table, &sz );
+ _libmsi_record_get_string( rec, 1, table, &sz );
number = libmsi_record_get_integer( rec, 2 );
/*
@@ -2512,10 +2487,10 @@ static unsigned msi_table_load_transform( LibmsiDatabase *db, GsfInfile *stg,
if ( number == MSI_NULL_INTEGER )
{
/* reset the column number on a new table */
- if (strcmpW( coltable, table ))
+ if (strcmp( coltable, table ))
{
colcol = 0;
- strcpyW( coltable, table );
+ strcpy( coltable, table );
}
/* fix nul column numbers */
@@ -2558,7 +2533,7 @@ static unsigned msi_table_load_transform( LibmsiDatabase *db, GsfInfile *stg,
WARN("failed to insert row %u\n", r);
}
- if (number != MSI_NULL_INTEGER && !strcmpW( name, szColumns ))
+ if (number != MSI_NULL_INTEGER && !strcmp( name, szColumns ))
msi_update_table_columns( db, table );
msiobj_release( &rec->hdr );
@@ -2604,22 +2579,16 @@ unsigned msi_table_apply_transform( LibmsiDatabase *db, GsfInfile *stg )
for (i = 0; i < n; i++)
{
LibmsiTableView *tv = NULL;
- const uint8_t *utf8name;
- WCHAR *encname;
- WCHAR name[0x40];
+ const uint8_t *encname;
+ char name[0x40];
- utf8name = (const uint8_t *) gsf_infile_name_by_index(stg, i);
- encname = strdupUTF8toW(utf8name);
- if ( encname[0] != 0x4840 )
- {
- msi_free( encname );
+ encname = (const uint8_t *) gsf_infile_name_by_index(stg, i);
+ if ( encname[0] != 0xe4 || encname[1] != 0xa1 || encname[2] != 0x80)
continue;
- }
decode_streamname( encname, name );
- msi_free( encname );
- if ( !strcmpW( name+1, szStringPool ) ||
- !strcmpW( name+1, szStringData ) )
+ if ( !strcmp( name+3, szStringPool ) ||
+ !strcmp( name+3, szStringData ) )
continue;
transform = msi_alloc_zero( sizeof(TRANSFORMDATA) );
@@ -2628,14 +2597,14 @@ unsigned msi_table_apply_transform( LibmsiDatabase *db, GsfInfile *stg )
list_add_tail( &transforms, &transform->entry );
- transform->name = strdupW( name + 1 );
+ transform->name = strdup( name + 1 );
- if ( !strcmpW( transform->name, szTables ) )
+ if ( !strcmp( transform->name, szTables ) )
tables = transform;
- else if (!strcmpW( transform->name, szColumns ) )
+ else if (!strcmp( transform->name, szColumns ) )
columns = transform;
- TRACE("transform contains stream %s\n", debugstr_w(name));
+ TRACE("transform contains stream %s\n", debugstr_a(name));
/* load the table */
r = table_view_create( db, transform->name, (LibmsiView**) &tv );
@@ -2670,8 +2639,8 @@ unsigned msi_table_apply_transform( LibmsiDatabase *db, GsfInfile *stg )
{
transform = LIST_ENTRY( list_head( &transforms ), TRANSFORMDATA, entry );
- if ( strcmpW( transform->name, szColumns ) &&
- strcmpW( transform->name, szTables ) &&
+ if ( strcmp( transform->name, szColumns ) &&
+ strcmp( transform->name, szTables ) &&
ret == LIBMSI_RESULT_SUCCESS )
{
ret = msi_table_load_transform( db, stg, strings, transform, bytes_per_strref );
diff --git a/libmsi/tokenize.c b/libmsi/tokenize.c
index 007411e..c19a9ad 100644
--- a/libmsi/tokenize.c
+++ b/libmsi/tokenize.c
@@ -88,7 +88,7 @@ static const Keyword aKeywordTable[] = {
** Comparison function for binary search.
*/
static int sql_compare_keyword(const void *m1, const void *m2){
- const WCHAR *p = m1;
+ const char *p = m1;
const Keyword *k = m2;
const char *q = k->zName;
@@ -111,14 +111,14 @@ static int sql_compare_keyword(const void *m1, const void *m2){
** keyword. If it is a keyword, the token code of that keyword is
** returned. If the input is not a keyword, TK_ID is returned.
*/
-static int sqlite_find_keyword(const WCHAR *z, int n){
- WCHAR str[MAX_TOKEN_LEN+1];
+static int sqlite_find_keyword(const char *z, int n){
+ char str[MAX_TOKEN_LEN+1];
Keyword *r;
if( n>MAX_TOKEN_LEN )
return TK_ID;
- memcpy( str, z, n*sizeof (WCHAR) );
+ memcpy( str, z, n*sizeof (char) );
str[n] = 0;
r = bsearch( str, aKeywordTable, KEYWORD_COUNT, sizeof (Keyword), sql_compare_keyword );
if( r )
@@ -163,7 +163,7 @@ static const char isIdChar[] = {
** -1 if the token is (or might be) incomplete. Store the token
** type in *tokenType before returning.
*/
-int sql_get_token(const WCHAR *z, int *tokenType, int *skip){
+int sql_get_token(const char *z, int *tokenType, int *skip){
int i;
*skip = 0;
diff --git a/libmsi/unicode.h b/libmsi/unicode.h
index d134f3e..d37d6ae 100644
--- a/libmsi/unicode.h
+++ b/libmsi/unicode.h
@@ -1,154 +1 @@
-/*
- * Wine internal Unicode definitions
- *
- * Copyright 2000 Alexandre Julliard
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#ifndef __WINE_WINE_UNICODE_H
-#define __WINE_WINE_UNICODE_H
-
-#include <stdarg.h>
-
-#include <windef.h>
-#include <winbase.h>
-#include <winnls.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern long int strtolW( const WCHAR *nptr, WCHAR **endptr, int base );
-extern int sprintfW( WCHAR *str, const WCHAR *format, ... );
-extern int snprintfW( WCHAR *str, size_t len, const WCHAR *format, ... );
-extern int vsprintfW( WCHAR *str, const WCHAR *format, va_list valist );
-extern int vsnprintfW( WCHAR *str, size_t len, const WCHAR *format, va_list valist );
-
-/* some useful string manipulation routines */
-
-static inline unsigned int strlenW( const WCHAR *str )
-{
- const WCHAR *s = str;
- while (*s) s++;
- return s - str;
-}
-
-static inline WCHAR *strcpyW( WCHAR *dst, const WCHAR *src )
-{
- WCHAR *p = dst;
- while ((*p++ = *src++));
- return dst;
-}
-
-/* strncpy doesn't do what you think, don't use it */
-#define strncpyW(d,s,n) error do_not_use_strncpyW_use_lstrcpynW_or_memcpy_instead
-
-static inline WCHAR *strcpynW( WCHAR *dst, const WCHAR *src, unsigned count )
-{
- WCHAR *d = dst;
- const WCHAR *s = src;
-
- while ((count > 1) && *s)
- {
- count--;
- *d++ = *s++;
- }
- if (count) *d = 0;
- return dst;
-}
-
-static inline int strcmpW( const WCHAR *str1, const WCHAR *str2 )
-{
- while (*str1 && (*str1 == *str2)) { str1++; str2++; }
- return *str1 - *str2;
-}
-
-static inline int strncmpW( const WCHAR *str1, const WCHAR *str2, int n )
-{
- if (n <= 0) return 0;
- while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
- return *str1 - *str2;
-}
-
-static inline WCHAR *strcatW( WCHAR *dst, const WCHAR *src )
-{
- strcpyW( dst + strlenW(dst), src );
- return dst;
-}
-
-static inline WCHAR *strchrW( const WCHAR *str, WCHAR ch )
-{
- do { if (*str == ch) return (WCHAR *)(uintptr_t)str; } while (*str++);
- return NULL;
-}
-
-static inline WCHAR *strrchrW( const WCHAR *str, WCHAR ch )
-{
- WCHAR *ret = NULL;
- do { if (*str == ch) ret = (WCHAR *)(uintptr_t)str; } while (*str++);
- return ret;
-}
-
-static inline WCHAR *strpbrkW( const WCHAR *str, const WCHAR *accept )
-{
- for ( ; *str; str++) if (strchrW( accept, *str )) return (WCHAR *)(uintptr_t)str;
- return NULL;
-}
-
-static inline size_t strspnW( const WCHAR *str, const WCHAR *accept )
-{
- const WCHAR *ptr;
- for (ptr = str; *ptr; ptr++) if (!strchrW( accept, *ptr )) break;
- return ptr - str;
-}
-
-static inline size_t strcspnW( const WCHAR *str, const WCHAR *reject )
-{
- const WCHAR *ptr;
- for (ptr = str; *ptr; ptr++) if (strchrW( reject, *ptr )) break;
- return ptr - str;
-}
-
-static inline WCHAR *memchrW( const WCHAR *ptr, WCHAR ch, size_t n )
-{
- const WCHAR *end;
- for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) return (WCHAR *)(uintptr_t)ptr;
- return NULL;
-}
-
-static inline WCHAR *memrchrW( const WCHAR *ptr, WCHAR ch, size_t n )
-{
- const WCHAR *end;
- WCHAR *ret = NULL;
- for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) ret = (WCHAR *)(uintptr_t)ptr;
- return ret;
-}
-
-static inline long int atolW( const WCHAR *str )
-{
- return strtolW( str, (WCHAR **)0, 10 );
-}
-
-static inline int atoiW( const WCHAR *str )
-{
- return (int)atolW( str );
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __WINE_WINE_UNICODE_H */
+/* not used */
diff --git a/libmsi/update.c b/libmsi/update.c
index f1f3d8d..7310ec4 100644
--- a/libmsi/update.c
+++ b/libmsi/update.c
@@ -152,8 +152,8 @@ static unsigned update_view_get_dimensions( LibmsiView *view, unsigned *rows, un
return wv->ops->get_dimensions( wv, rows, cols );
}
-static unsigned update_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name,
- unsigned *type, bool *temporary, const WCHAR **table_name )
+static unsigned update_view_get_column_info( LibmsiView *view, unsigned n, const char **name,
+ unsigned *type, bool *temporary, const char **table_name )
{
LibmsiUpdateView *uv = (LibmsiUpdateView*)view;
LibmsiView *wv;
@@ -212,7 +212,7 @@ static const LibmsiViewOps update_ops =
NULL,
};
-unsigned update_view_create( LibmsiDatabase *db, LibmsiView **view, WCHAR *table,
+unsigned update_view_create( LibmsiDatabase *db, LibmsiView **view, char *table,
column_info *columns, struct expr *expr )
{
LibmsiUpdateView *uv = NULL;
diff --git a/libmsi/utf16/snprintfW.c b/libmsi/utf16/snprintfW.c
deleted file mode 100644
index 3e3ee05..0000000
--- a/libmsi/utf16/snprintfW.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Formatted output to strings.
- Copyright (C) 1999, 2002, 2005-2007, 2009-2012 Free Software Foundation,
- Inc.
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include "unicode.h"
-#include <stdarg.h>
-#include <stdlib.h>
-
-int
-snprintfW (WCHAR *buf, size_t size, const WCHAR *format, ...)
-{
- va_list args;
- int result;
-
- va_start (args, format);
- result = vsnprintfW (buf, size, format, args);
- va_end (args);
- return result;
-}
-
-int
-vsnprintfW (WCHAR *buf, size_t size, const WCHAR *format, va_list args)
-{
- return _vsnwprintf (buf, size, format, args);
-}
diff --git a/libmsi/utf16/sprintfW.c b/libmsi/utf16/sprintfW.c
deleted file mode 100644
index ebb8909..0000000
--- a/libmsi/utf16/sprintfW.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Formatted output to strings.
- Copyright (C) 1999, 2002, 2005-2007, 2009-2012 Free Software Foundation,
- Inc.
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include "unicode.h"
-#include <stdarg.h>
-#include <limits.h>
-
-int
-sprintfW (WCHAR *buf, const WCHAR *format, ...)
-{
- va_list args;
- int result;
-
- va_start (args, format);
- result = vsprintfW (buf, format, args);
- va_end (args);
- return result;
-}
-
-int
-vsprintfW (WCHAR *buf, const WCHAR *format, va_list args)
-{
- return _vsnwprintf (buf, INT_MAX, format, args);
-}
diff --git a/libmsi/utf16/strtolW.c b/libmsi/utf16/strtolW.c
deleted file mode 100644
index 5c2a818..0000000
--- a/libmsi/utf16/strtolW.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/* Convert string representation of a number into an integer value.
-
- Copyright (C) 1991-1992, 1994-1999, 2003, 2005-2007, 2009-2012 Free Software
- Foundation, Inc.
-
- NOTE: The canonical source of this file is maintained with the GNU C
- Library. Bugs can be reported to bug-glibc@gnu.org.
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 3 of the License, or any
- later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifdef _LIBC
-# define USE_NUMBER_GROUPING
-#else
-# include <config.h>
-#endif
-
-#include "unicode.h"
-#include <errno.h>
-#ifndef __set_errno
-# define __set_errno(Val) errno = (Val)
-#endif
-
-#include <limits.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* Convert NPTR to an 'unsigned long int' or 'long int' in base BASE.
- If BASE is 0 the base is determined by the presence of a leading
- zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal.
- If BASE is < 2 or > 36, it is reset to 10.
- If ENDPTR is not NULL, a pointer to the character after the last
- one converted is stored in *ENDPTR. */
-
-long
-strtolW (const WCHAR *nptr, WCHAR **endptr, int base)
-{
- int negative;
- unsigned long cutoff;
- unsigned int cutlim;
- unsigned long i;
- const WCHAR *s;
- UCHAR c;
- const WCHAR *save, *end;
- int overflow;
-
- if (base < 0 || base == 1 || base > 36)
- {
- __set_errno (EINVAL);
- return 0;
- }
-
- save = s = nptr;
-
- /* Skip white space. */
- while (*s == ' ' || *s == '\n' )
- ++s;
- if (*s == '\0')
- goto noconv;
-
- /* Check for a sign. */
- if (*s == '-')
- {
- negative = 1;
- ++s;
- }
- else if (*s == '+')
- {
- negative = 0;
- ++s;
- }
- else
- negative = 0;
-
- /* Recognize number prefix and if BASE is zero, figure it out ourselves. */
- if (*s == '0')
- {
- if ((base == 0 || base == 16) && (s[1] == 'X' || s[1] == 'x'))
- {
- s += 2;
- base = 16;
- }
- else if (base == 0)
- base = 8;
- }
- else if (base == 0)
- base = 10;
-
- /* Save the pointer so we can check later if anything happened. */
- save = s;
-
- end = NULL;
-
- cutoff = ULONG_MAX / (unsigned long) base;
- cutlim = ULONG_MAX % (unsigned long) base;
-
- overflow = 0;
- i = 0;
- for (c = *s; c; c = *++s)
- {
- if (s == end)
- break;
- if (c >= '0' && c <= '9')
- c -= '0';
- else if (c >= 'A' && c <= 'Z')
- c = c - 'A' + 10;
- else if (c >= 'a' && c <= 'z')
- c = c - 'a' + 10;
- else
- break;
- if ((int) c >= base)
- break;
- /* Check for overflow. */
- if (i > cutoff || (i == cutoff && c > cutlim))
- overflow = 1;
- else
- {
- i *= (unsigned long) base;
- i += c;
- }
- }
-
- /* Check if anything actually happened. */
- if (s == save)
- goto noconv;
-
- /* Store in ENDPTR the address of one character
- past the last character we converted. */
- if (endptr != NULL)
- *endptr = (WCHAR *) s;
-
- /* Check for a value that is within the range of
- 'unsigned long', but outside the range of 'long'. */
- if (overflow == 0
- && i > (negative
- ? -((unsigned long int) (LONG_MIN + 1)) + 1
- : (unsigned long int) LONG_MAX))
- overflow = 1;
-
- if (overflow)
- {
- __set_errno (ERANGE);
- return ULONG_MAX;
- }
-
- /* Return the result of the appropriate sign. */
- return negative ? -i : i;
-
-noconv:
- /* We must handle a special case here: the base is 0 or 16 and the
- first two characters are '0' and 'x', but the rest are no
- hexadecimal digits. This is no error case. We return 0 and
- ENDPTR points to the 'x'. */
- if (endptr != NULL)
- {
- if (save - nptr >= 2 && (save[-1] == 'X' || save[-1] == 'x')
- && save[-2] == '0')
- *endptr = (WCHAR *) &save[-1];
- else
- /* There was no number to convert. */
- *endptr = (WCHAR *) nptr;
- }
-
- return 0L;
-}
diff --git a/libmsi/where.c b/libmsi/where.c
index 104c61c..f389c58 100644
--- a/libmsi/where.c
+++ b/libmsi/where.c
@@ -178,7 +178,7 @@ static unsigned parse_column(LibmsiWhereView *wv, union ext_column *column,
do
{
- const WCHAR *table_name;
+ const char *table_name;
if (column->unparsed.table)
{
@@ -186,20 +186,20 @@ static unsigned parse_column(LibmsiWhereView *wv, union ext_column *column,
NULL, &table_name);
if (r != LIBMSI_RESULT_SUCCESS)
return r;
- if (strcmpW(table_name, column->unparsed.table) != 0)
+ if (strcmp(table_name, column->unparsed.table) != 0)
continue;
}
for(i = 1; i <= table->col_count; i++)
{
- const WCHAR *col_name;
+ const char *col_name;
r = table->view->ops->get_column_info(table->view, i, &col_name, column_type,
NULL, NULL);
if(r != LIBMSI_RESULT_SUCCESS )
return r;
- if(strcmpW(col_name, column->unparsed.column))
+ if(strcmp(col_name, column->unparsed.column))
continue;
column->parsed.column = i;
column->parsed.table = table;
@@ -208,7 +208,7 @@ static unsigned parse_column(LibmsiWhereView *wv, union ext_column *column,
}
while ((table = table->next));
- WARN("Couldn't find column %s.%s\n", debugstr_w( column->unparsed.table ), debugstr_w( column->unparsed.column ) );
+ WARN("Couldn't find column %s.%s\n", debugstr_a( column->unparsed.table ), debugstr_a( column->unparsed.column ) );
return LIBMSI_RESULT_BAD_QUERY_SYNTAX;
}
@@ -484,7 +484,7 @@ static unsigned expr_eval_unary( LibmsiWhereView *wv, const unsigned rows[],
static unsigned expr_eval_string( LibmsiWhereView *wv, const unsigned rows[],
const struct expr *expr,
const LibmsiRecord *record,
- const WCHAR **str )
+ const char **str )
{
unsigned val = 0, r = LIBMSI_RESULT_SUCCESS;
@@ -519,7 +519,7 @@ static unsigned expr_eval_strcmp( LibmsiWhereView *wv, const unsigned rows[], co
int *val, const LibmsiRecord *record )
{
int sr;
- const WCHAR *l_str, *r_str;
+ const char *l_str, *r_str;
unsigned r;
*val = true;
@@ -538,7 +538,7 @@ static unsigned expr_eval_strcmp( LibmsiWhereView *wv, const unsigned rows[], co
else if( r_str && ! l_str )
sr = -1;
else
- sr = strcmpW( l_str, r_str );
+ sr = strcmp( l_str, r_str );
*val = ( expr->op == OP_EQ && ( sr == 0 ) ) ||
( expr->op == OP_NE && ( sr != 0 ) );
@@ -857,8 +857,8 @@ static unsigned where_view_get_dimensions( LibmsiView *view, unsigned *rows, uns
return LIBMSI_RESULT_SUCCESS;
}
-static unsigned where_view_get_column_info( LibmsiView *view, unsigned n, const WCHAR **name,
- unsigned *type, bool *temporary, const WCHAR **table_name )
+static unsigned where_view_get_column_info( LibmsiView *view, unsigned n, const char **name,
+ unsigned *type, bool *temporary, const char **table_name )
{
LibmsiWhereView *wv = (LibmsiWhereView*)view;
JOINTABLE *table;
@@ -1097,14 +1097,14 @@ static unsigned where_view_verify_condition( LibmsiWhereView *wv, struct expr *c
return LIBMSI_RESULT_SUCCESS;
}
-unsigned where_view_create( LibmsiDatabase *db, LibmsiView **view, WCHAR *tables,
+unsigned where_view_create( LibmsiDatabase *db, LibmsiView **view, char *tables,
struct expr *cond )
{
LibmsiWhereView *wv = NULL;
unsigned r, valid = 0;
- WCHAR *ptr;
+ char *ptr;
- TRACE("(%s)\n", debugstr_w(tables) );
+ TRACE("(%s)\n", debugstr_a(tables) );
wv = msi_alloc_zero( sizeof *wv );
if( !wv )
@@ -1120,7 +1120,7 @@ unsigned where_view_create( LibmsiDatabase *db, LibmsiView **view, WCHAR *tables
{
JOINTABLE *table;
- if ((ptr = strchrW(tables, ' ')))
+ if ((ptr = strchr(tables, ' ')))
*ptr = '\0';
table = msi_alloc(sizeof(JOINTABLE));
@@ -1133,7 +1133,7 @@ unsigned where_view_create( LibmsiDatabase *db, LibmsiView **view, WCHAR *tables
r = table_view_create(db, tables, &table->view);
if (r != LIBMSI_RESULT_SUCCESS)
{
- WARN("can't create table: %s\n", debugstr_w(tables));
+ WARN("can't create table: %s\n", debugstr_a(tables));
msi_free(table);
r = LIBMSI_RESULT_BAD_QUERY_SYNTAX;
goto end;