Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
3e041586
Commit
3e041586
authored
Mar 16, 2010
by
Andrew Eikum
Committed by
Alexandre Julliard
Mar 17, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hlink: Split target at hash in HlinkCreateFromString.
parent
a8183a63
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
2 deletions
+118
-2
hlink_main.c
dlls/hlink/hlink_main.c
+40
-2
hlink.c
dlls/hlink/tests/hlink.c
+78
-0
No files found.
dlls/hlink/hlink_main.c
View file @
3e041586
...
...
@@ -99,6 +99,8 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation,
{
IHlink
*
hl
=
NULL
;
HRESULT
r
=
S_OK
;
WCHAR
*
hash
,
*
tgt
;
const
WCHAR
*
loc
;
TRACE
(
"%s %s %s %p %i %p %s %p
\n
"
,
debugstr_w
(
pwzTarget
),
debugstr_w
(
pwzLocation
),
debugstr_w
(
pwzFriendlyName
),
pihlsite
,
...
...
@@ -108,8 +110,44 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation,
if
(
FAILED
(
r
))
return
r
;
IHlink_SetStringReference
(
hl
,
HLINKSETF_TARGET
|
HLINKSETF_LOCATION
,
pwzTarget
,
pwzLocation
);
if
(
pwzTarget
)
{
hash
=
strchrW
(
pwzTarget
,
'#'
);
if
(
hash
)
{
if
(
hash
==
pwzTarget
)
tgt
=
NULL
;
else
{
int
tgt_len
=
hash
-
pwzTarget
;
tgt
=
heap_alloc
((
tgt_len
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
tgt
)
return
E_OUTOFMEMORY
;
memcpy
(
tgt
,
pwzTarget
,
tgt_len
*
sizeof
(
WCHAR
));
tgt
[
tgt_len
]
=
0
;
}
if
(
!
pwzLocation
)
loc
=
hash
+
1
;
else
loc
=
pwzLocation
;
}
else
{
tgt
=
hlink_strdupW
(
pwzTarget
);
if
(
!
tgt
)
return
E_OUTOFMEMORY
;
loc
=
pwzLocation
;
}
}
else
{
tgt
=
NULL
;
loc
=
pwzLocation
;
}
IHlink_SetStringReference
(
hl
,
HLINKSETF_TARGET
|
HLINKSETF_LOCATION
,
tgt
,
loc
);
heap_free
(
tgt
);
if
(
pwzFriendlyName
)
IHlink_SetFriendlyName
(
hl
,
pwzFriendlyName
);
...
...
dlls/hlink/tests/hlink.c
View file @
3e041586
...
...
@@ -1363,6 +1363,83 @@ static void test_HlinkMoniker(void)
IHlink_Release
(
hlink
);
}
static
void
test_HashLink
(
void
)
{
IHlink
*
hlink
;
IMoniker
*
pmk
;
const
WCHAR
hash_targetW
[]
=
{
'a'
,
'f'
,
'i'
,
'l'
,
'e'
,
'#'
,
'a'
,
'n'
,
'a'
,
'n'
,
'c'
,
'h'
,
'o'
,
'r'
,
0
};
const
WCHAR
two_hash_targetW
[]
=
{
'a'
,
'f'
,
'i'
,
'l'
,
'e'
,
'#'
,
'a'
,
'n'
,
'a'
,
'n'
,
'c'
,
'h'
,
'o'
,
'r'
,
'#'
,
'a'
,
'n'
,
'o'
,
't'
,
'h'
,
'e'
,
'r'
,
0
};
const
WCHAR
hash_no_tgtW
[]
=
{
'#'
,
'a'
,
'n'
,
'a'
,
'n'
,
'c'
,
'h'
,
'o'
,
'r'
,
0
};
const
WCHAR
tgt_partW
[]
=
{
'a'
,
'f'
,
'i'
,
'l'
,
'e'
,
0
};
const
WCHAR
loc_partW
[]
=
{
'a'
,
'n'
,
'a'
,
'n'
,
'c'
,
'h'
,
'o'
,
'r'
,
0
};
const
WCHAR
two_hash_loc_partW
[]
=
{
'a'
,
'n'
,
'a'
,
'n'
,
'c'
,
'h'
,
'o'
,
'r'
,
'#'
,
'a'
,
'n'
,
'o'
,
't'
,
'h'
,
'e'
,
'r'
,
0
};
const
WCHAR
test_locW
[]
=
{
't'
,
'e'
,
's'
,
't'
,
'l'
,
'o'
,
'c'
,
0
};
HRESULT
hres
;
/* simple single hash test */
hres
=
HlinkCreateFromString
(
hash_targetW
,
NULL
,
NULL
,
NULL
,
0
,
NULL
,
&
IID_IHlink
,
(
void
*
)
&
hlink
);
ok
(
hres
==
S_OK
,
"HlinkCreateFromString failed: 0x%08x
\n
"
,
hres
);
ok
(
hlink
!=
NULL
,
"Didn't get an hlink
\n
"
);
if
(
hlink
){
getStringRef
(
hlink
,
tgt_partW
,
loc_partW
);
pmk
=
getMonikerRef
(
hlink
,
(
IMoniker
*
)
0xFFFFFFFF
,
loc_partW
);
ok
(
pmk
!=
NULL
,
"Found moniker should not be NULL
\n
"
);
if
(
pmk
)
IMoniker_Release
(
pmk
);
setStringRef
(
hlink
,
HLINKSETF_TARGET
,
hash_targetW
,
NULL
);
getStringRef
(
hlink
,
hash_targetW
,
loc_partW
);
IHlink_Release
(
hlink
);
}
/* two hashes in the target */
hres
=
HlinkCreateFromString
(
two_hash_targetW
,
NULL
,
NULL
,
NULL
,
0
,
NULL
,
&
IID_IHlink
,
(
void
*
)
&
hlink
);
ok
(
hres
==
S_OK
,
"HlinkCreateFromString failed: 0x%08x
\n
"
,
hres
);
ok
(
hlink
!=
NULL
,
"Didn't get an hlink
\n
"
);
if
(
hlink
){
getStringRef
(
hlink
,
tgt_partW
,
two_hash_loc_partW
);
pmk
=
getMonikerRef
(
hlink
,
(
IMoniker
*
)
0xFFFFFFFF
,
two_hash_loc_partW
);
ok
(
pmk
!=
NULL
,
"Found moniker should not be NULL
\n
"
);
if
(
pmk
)
IMoniker_Release
(
pmk
);
IHlink_Release
(
hlink
);
}
/* target with hash plus a location string */
hres
=
HlinkCreateFromString
(
hash_targetW
,
test_locW
,
NULL
,
NULL
,
0
,
NULL
,
&
IID_IHlink
,
(
void
*
)
&
hlink
);
ok
(
hres
==
S_OK
,
"HlinkCreateFromString failed: 0x%08x
\n
"
,
hres
);
ok
(
hlink
!=
NULL
,
"Didn't get an hlink
\n
"
);
if
(
hlink
){
getStringRef
(
hlink
,
tgt_partW
,
test_locW
);
pmk
=
getMonikerRef
(
hlink
,
(
IMoniker
*
)
0xFFFFFFFF
,
test_locW
);
ok
(
pmk
!=
NULL
,
"Found moniker should not be NULL
\n
"
);
if
(
pmk
)
IMoniker_Release
(
pmk
);
IHlink_Release
(
hlink
);
}
/* target with hash containing no "target part" */
hres
=
HlinkCreateFromString
(
hash_no_tgtW
,
NULL
,
NULL
,
NULL
,
0
,
NULL
,
&
IID_IHlink
,
(
void
*
)
&
hlink
);
ok
(
hres
==
S_OK
,
"HlinkCreateFromString failed: 0x%08x
\n
"
,
hres
);
ok
(
hlink
!=
NULL
,
"Didn't get an hlink
\n
"
);
if
(
hlink
){
getStringRef
(
hlink
,
NULL
,
loc_partW
);
pmk
=
getMonikerRef
(
hlink
,
(
IMoniker
*
)
0xFFFFFFFF
,
loc_partW
);
ok
(
pmk
==
NULL
,
"Found moniker should be NULL
\n
"
);
if
(
pmk
)
IMoniker_Release
(
pmk
);
IHlink_Release
(
hlink
);
}
}
START_TEST
(
hlink
)
{
CoInitialize
(
NULL
);
...
...
@@ -1377,6 +1454,7 @@ START_TEST(hlink)
test_HlinkGetSetMonikerReference
();
test_HlinkGetSetStringReference
();
test_HlinkMoniker
();
test_HashLink
();
CoUninitialize
();
}
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