Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
80399479
Commit
80399479
authored
Nov 10, 2020
by
Michael Stefaniuc
Committed by
Alexandre Julliard
Nov 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msidb: Use wide-char string literals.
Signed-off-by:
Michael Stefaniuc
<
mstefani@winehq.org
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e06ae69d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
30 deletions
+12
-30
main.c
programs/msidb/main.c
+12
-30
No files found.
programs/msidb/main.c
View file @
80399479
...
...
@@ -229,13 +229,10 @@ static const WCHAR *basenameW( const WCHAR *filename )
static
int
add_stream
(
struct
msidb_state
*
state
,
const
WCHAR
*
stream_filename
)
{
static
const
WCHAR
insert_command
[]
=
{
'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'
,
')'
,
' '
,
'V'
,
'A'
,
'L'
,
'U'
,
'E'
,
'S'
,
' '
,
'('
,
'?'
,
','
,
' '
,
'?'
,
')'
,
0
};
MSIHANDLE
view
=
0
,
record
=
0
;
UINT
ret
;
ret
=
MsiDatabaseOpenViewW
(
state
->
database_handle
,
insert_command
,
&
view
);
ret
=
MsiDatabaseOpenViewW
(
state
->
database_handle
,
L"INSERT INTO _Streams (Name, Data) VALUES (?, ?)"
,
&
view
);
if
(
ret
!=
ERROR_SUCCESS
)
{
ERR
(
"Failed to open _Streams table.
\n
"
);
...
...
@@ -290,13 +287,10 @@ static int add_streams( struct msidb_state *state )
static
int
kill_stream
(
struct
msidb_state
*
state
,
const
WCHAR
*
stream_filename
)
{
static
const
WCHAR
delete_command
[]
=
{
'D'
,
'E'
,
'L'
,
'E'
,
'T'
,
'E'
,
' '
,
'F'
,
'R'
,
'O'
,
'M'
,
' '
,
'_'
,
'S'
,
't'
,
'r'
,
'e'
,
'a'
,
'm'
,
's'
,
' '
,
'W'
,
'H'
,
'E'
,
'R'
,
'E'
,
' '
,
'N'
,
'a'
,
'm'
,
'e'
,
' '
,
'='
,
' '
,
'?'
,
0
};
MSIHANDLE
view
=
0
,
record
=
0
;
UINT
ret
;
ret
=
MsiDatabaseOpenViewW
(
state
->
database_handle
,
delete_command
,
&
view
);
ret
=
MsiDatabaseOpenViewW
(
state
->
database_handle
,
L"DELETE FROM _Streams WHERE Name = ?"
,
&
view
);
if
(
ret
!=
ERROR_SUCCESS
)
{
ERR
(
"Failed to open _Streams table.
\n
"
);
...
...
@@ -345,9 +339,6 @@ static int kill_streams( struct msidb_state *state )
static
int
extract_stream
(
struct
msidb_state
*
state
,
const
WCHAR
*
stream_filename
)
{
static
const
WCHAR
select_command
[]
=
{
'S'
,
'E'
,
'L'
,
'E'
,
'C'
,
'T'
,
' '
,
'D'
,
'a'
,
't'
,
'a'
,
' '
,
'F'
,
'R'
,
'O'
,
'M'
,
' '
,
'_'
,
'S'
,
't'
,
'r'
,
'e'
,
'a'
,
'm'
,
's'
,
' '
,
'W'
,
'H'
,
'E'
,
'R'
,
'E'
,
' '
,
'N'
,
'a'
,
'm'
,
'e'
,
' '
,
'='
,
' '
,
'?'
,
0
};
HANDLE
file
=
INVALID_HANDLE_VALUE
;
MSIHANDLE
view
=
0
,
record
=
0
;
DWORD
read_size
,
write_size
;
...
...
@@ -362,7 +353,7 @@ static int extract_stream( struct msidb_state *state, const WCHAR *stream_filena
ERR
(
"Failed to open destination file %s.
\n
"
,
wine_dbgstr_w
(
stream_filename
)
);
goto
cleanup
;
}
ret
=
MsiDatabaseOpenViewW
(
state
->
database_handle
,
select_command
,
&
view
);
ret
=
MsiDatabaseOpenViewW
(
state
->
database_handle
,
L"SELECT Data FROM _Streams WHERE Name = ?"
,
&
view
);
if
(
ret
!=
ERROR_SUCCESS
)
{
ERR
(
"Failed to open _Streams table.
\n
"
);
...
...
@@ -449,8 +440,6 @@ static int import_table( struct msidb_state *state, const WCHAR *table_path )
static
int
import_tables
(
struct
msidb_state
*
state
)
{
const
WCHAR
idt_ext
[]
=
{
'.'
,
'i'
,
'd'
,
't'
,
0
};
const
WCHAR
wildcard
[]
=
{
'*'
,
0
};
struct
msidb_listentry
*
data
;
LIST_FOR_EACH_ENTRY
(
data
,
&
state
->
table_list
,
struct
msidb_listentry
,
entry
)
...
...
@@ -460,7 +449,7 @@ static int import_tables( struct msidb_state *state )
WCHAR
*
ext
;
/* permit specifying tables with wildcards ('Feature*') */
if
(
wcsstr
(
table_name
,
wildcard
)
!=
NULL
)
if
(
wcsstr
(
table_name
,
L"*"
)
!=
NULL
)
{
WIN32_FIND_DATAW
f
;
HANDLE
handle
;
...
...
@@ -484,7 +473,7 @@ static int import_tables( struct msidb_state *state )
if
(
f
.
cFileName
[
0
]
==
'.'
&&
f
.
cFileName
[
1
]
==
'.'
&&
!
f
.
cFileName
[
2
])
continue
;
if
(
f
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
continue
;
if
((
ext
=
PathFindExtensionW
(
f
.
cFileName
))
==
NULL
)
continue
;
if
(
lstrcmpW
(
ext
,
idt_ext
)
!=
0
)
continue
;
if
(
lstrcmpW
(
ext
,
L".idt"
)
!=
0
)
continue
;
if
(
!
import_table
(
state
,
f
.
cFileName
))
{
FindClose
(
handle
);
...
...
@@ -495,10 +484,10 @@ static int import_tables( struct msidb_state *state )
continue
;
}
/* permit specifying tables by filename (*.idt) */
if
((
ext
=
PathFindExtensionW
(
table_name
))
==
NULL
||
lstrcmpW
(
ext
,
idt_ext
)
!=
0
)
if
((
ext
=
PathFindExtensionW
(
table_name
))
==
NULL
||
lstrcmpW
(
ext
,
L".idt"
)
!=
0
)
{
const
WCHAR
format
[]
=
{
'%'
,
'.'
,
'8'
,
's'
,
'.'
,
'i'
,
'd'
,
't'
,
0
};
/* truncate to 8 characters */
swprintf
(
table_path
,
ARRAY_SIZE
(
table_path
),
format
,
table_name
);
/* truncate to 8 characters */
swprintf
(
table_path
,
ARRAY_SIZE
(
table_path
),
L"%.8s.idt"
,
table_name
);
table_name
=
table_path
;
}
if
(
!
import_table
(
state
,
table_name
))
...
...
@@ -509,9 +498,7 @@ static int import_tables( struct msidb_state *state )
static
int
export_table
(
struct
msidb_state
*
state
,
const
WCHAR
*
table_name
)
{
const
WCHAR
format_dos
[]
=
{
'%'
,
'.'
,
'8'
,
's'
,
'.'
,
'i'
,
'd'
,
't'
,
0
};
/* truncate to 8 characters */
const
WCHAR
format_full
[]
=
{
'%'
,
's'
,
'.'
,
'i'
,
'd'
,
't'
,
0
};
const
WCHAR
*
format
=
(
state
->
short_filenames
?
format_dos
:
format_full
);
const
WCHAR
*
format
=
(
state
->
short_filenames
?
L"%.8s.idt"
:
L"%s.idt"
);
WCHAR
table_path
[
MAX_PATH
];
UINT
ret
;
...
...
@@ -527,14 +514,10 @@ static int export_table( struct msidb_state *state, const WCHAR *table_name )
static
int
export_all_tables
(
struct
msidb_state
*
state
)
{
static
const
WCHAR
summary_information
[]
=
{
'_'
,
'S'
,
'u'
,
'm'
,
'm'
,
'a'
,
'r'
,
'y'
,
'I'
,
'n'
,
'f'
,
'o'
,
'r'
,
'm'
,
'a'
,
't'
,
'i'
,
'o'
,
'n'
,
0
};
static
const
WCHAR
query_command
[]
=
{
'S'
,
'E'
,
'L'
,
'E'
,
'C'
,
'T'
,
' '
,
'N'
,
'a'
,
'm'
,
'e'
,
' '
,
'F'
,
'R'
,
'O'
,
'M'
,
' '
,
'_'
,
'T'
,
'a'
,
'b'
,
'l'
,
'e'
,
's'
,
0
};
MSIHANDLE
view
=
0
;
UINT
ret
;
ret
=
MsiDatabaseOpenViewW
(
state
->
database_handle
,
query_command
,
&
view
);
ret
=
MsiDatabaseOpenViewW
(
state
->
database_handle
,
L"SELECT Name FROM _Tables"
,
&
view
);
if
(
ret
!=
ERROR_SUCCESS
)
{
ERR
(
"Failed to open _Tables table.
\n
"
);
...
...
@@ -581,7 +564,7 @@ static int export_all_tables( struct msidb_state *state )
}
ret
=
ERROR_SUCCESS
;
/* the _SummaryInformation table is not listed in _Tables */
if
(
!
export_table
(
state
,
summary_information
))
if
(
!
export_table
(
state
,
L"_SummaryInformation"
))
{
ret
=
ERROR_FUNCTION_FAILED
;
goto
cleanup
;
...
...
@@ -598,12 +581,11 @@ cleanup:
static
int
export_tables
(
struct
msidb_state
*
state
)
{
const
WCHAR
wildcard
[]
=
{
'*'
,
0
};
struct
msidb_listentry
*
data
;
LIST_FOR_EACH_ENTRY
(
data
,
&
state
->
table_list
,
struct
msidb_listentry
,
entry
)
{
if
(
lstrcmpW
(
data
->
name
,
wildcard
)
==
0
)
if
(
lstrcmpW
(
data
->
name
,
L"*"
)
==
0
)
{
if
(
!
export_all_tables
(
state
))
return
0
;
/* failed, do not commit changes */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment