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
7458d741
Commit
7458d741
authored
Dec 19, 2005
by
Jacek Caban
Committed by
Alexandre Julliard
Dec 19, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
urlmon: Added some tests and fixes of file protocol.
parent
97c6c634
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
17 deletions
+42
-17
file.c
dlls/urlmon/file.c
+23
-12
protocol.c
dlls/urlmon/tests/protocol.c
+19
-5
No files found.
dlls/urlmon/file.c
View file @
7458d741
...
...
@@ -110,7 +110,9 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
LARGE_INTEGER
size
;
DWORD
len
;
LPWSTR
url
,
mime
=
NULL
;
LPCWSTR
file_name
;
WCHAR
null_char
=
0
;
BOOL
first_call
=
FALSE
;
HRESULT
hres
;
static
const
WCHAR
wszFile
[]
=
{
'f'
,
'i'
,
'l'
,
'e'
,
':'
};
...
...
@@ -134,33 +136,39 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
return
hres
;
}
hres
=
FindMimeFromData
(
NULL
,
url
,
NULL
,
0
,
NULL
,
0
,
&
mime
,
0
);
if
(
SUCCEEDED
(
hres
))
IInternetProtocolSink_ReportProgress
(
pOIProtSink
,
BINDSTATUS_DIRECTBIND
,
mime
);
IInternetProtocolSink_ReportProgress
(
pOIProtSink
,
BINDSTATUS_DIRECTBIND
,
NULL
);
if
(
!
This
->
file
)
{
first_call
=
TRUE
;
IInternetProtocolSink_ReportProgress
(
pOIProtSink
,
BINDSTATUS_SENDINGREQUEST
,
&
null_char
);
This
->
file
=
CreateFileW
(
url
+
sizeof
(
wszFile
)
/
sizeof
(
WCHAR
),
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
file_name
=
url
+
sizeof
(
wszFile
)
/
sizeof
(
WCHAR
);
if
(
file_name
[
0
]
==
'/'
&&
file_name
[
1
]
==
'/'
&&
file_name
[
2
]
==
'/'
)
file_name
+=
3
;
This
->
file
=
CreateFileW
(
file_name
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
if
(
This
->
file
==
INVALID_HANDLE_VALUE
)
{
This
->
file
=
NULL
;
IInternetProtocolSink_ReportResult
(
pOIProtSink
,
INET_E_RESOURCE_NOT_FOUND
,
GetLastError
(),
NULL
);
HeapFree
(
GetProcessHeap
(),
0
,
url
);
CoTaskMemFree
(
mime
);
return
INET_E_RESOURCE_NOT_FOUND
;
}
IInternetProtocolSink_ReportProgress
(
pOIProtSink
,
BINDSTATUS_CACHEFILENAMEAVAILABLE
,
url
+
sizeof
(
wszFile
)
/
sizeof
(
WCHAR
));
if
(
mime
)
IInternetProtocolSink_ReportProgress
(
pOIProtSink
,
BINDSTATUS_MIMETYPEAVAILABLE
,
mime
);
IInternetProtocolSink_ReportResult
(
pOIProtSink
,
S_OK
,
0
,
NULL
);
IInternetProtocolSink_ReportProgress
(
pOIProtSink
,
BINDSTATUS_CACHEFILENAMEAVAILABLE
,
file_name
);
hres
=
FindMimeFromData
(
NULL
,
url
,
NULL
,
0
,
NULL
,
0
,
&
mime
,
0
);
if
(
SUCCEEDED
(
hres
))
{
IInternetProtocolSink_ReportProgress
(
pOIProtSink
,
BINDSTATUS_MIMETYPEAVAILABLE
,
mime
);
CoTaskMemFree
(
mime
);
}
}
CoTaskMemFree
(
mime
);
HeapFree
(
GetProcessHeap
(),
0
,
url
);
if
(
GetFileSizeEx
(
This
->
file
,
&
size
))
...
...
@@ -168,6 +176,9 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
BSCF_FIRSTDATANOTIFICATION
|
BSCF_LASTDATANOTIFICATION
,
size
.
u
.
LowPart
,
size
.
u
.
LowPart
);
if
(
first_call
)
IInternetProtocolSink_ReportResult
(
pOIProtSink
,
S_OK
,
0
,
NULL
);
return
S_OK
;
}
...
...
dlls/urlmon/tests/protocol.c
View file @
7458d741
...
...
@@ -91,15 +91,17 @@ static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface,
switch
(
ulStatusCode
)
{
case
BINDSTATUS_MIMETYPEAVAILABLE
:
CHECK_EXPECT
(
ReportProgress_MIMETYPEAVAILABLE
);
ok
(
szStatusText
!=
NULL
,
"szStatusText == NULL
\n
"
);
if
(
szStatusText
)
ok
(
!
lstrcmpW
(
szStatusText
,
text_html
),
"szStatusText != text/html
\n
"
);
break
;
case
BINDSTATUS_DIRECTBIND
:
CHECK_EXPECT2
(
ReportProgress_DIRECTBIND
);
if
(
szStatusText
)
ok
(
!
lstrcmpW
(
szStatusText
,
text_html
),
"szStatusText != text/html
\n
"
);
CHECK_EXPECT
(
ReportProgress_DIRECTBIND
);
ok
(
szStatusText
==
NULL
,
"szStatucText != NULL
\n
"
);
break
;
case
BINDSTATUS_CACHEFILENAMEAVAILABLE
:
CHECK_EXPECT
(
ReportProgress_CACHEFILENAMEAVAILABLE
);
ok
(
szStatusText
!=
NULL
,
"szStatusText == NULL
\n
"
);
if
(
szStatusText
)
ok
(
!
lstrcmpW
(
szStatusText
,
file_name
),
"szStatusText != file_name
\n
"
);
break
;
...
...
@@ -241,9 +243,10 @@ static void file_protocol_start(IInternetProtocol *protocol, LPCWSTR url, BOOL i
SET_EXPECT
(
ReportProgress_SENDINGREQUEST
);
SET_EXPECT
(
ReportProgress_CACHEFILENAMEAVAILABLE
);
SET_EXPECT
(
ReportProgress_MIMETYPEAVAILABLE
);
SET_EXPECT
(
ReportResult
);
}
SET_EXPECT
(
ReportData
);
if
(
is_first
)
SET_EXPECT
(
ReportResult
);
expect_hrResult
=
S_OK
;
...
...
@@ -256,9 +259,10 @@ static void file_protocol_start(IInternetProtocol *protocol, LPCWSTR url, BOOL i
CHECK_CALLED
(
ReportProgress_SENDINGREQUEST
);
CHECK_CALLED
(
ReportProgress_CACHEFILENAMEAVAILABLE
);
CHECK_CALLED
(
ReportProgress_MIMETYPEAVAILABLE
);
CHECK_CALLED
(
ReportResult
);
}
CHECK_CALLED
(
ReportData
);
if
(
is_first
)
CHECK_CALLED
(
ReportResult
);
}
static
void
test_file_protocol_url
(
LPCWSTR
url
)
...
...
@@ -365,6 +369,7 @@ static void test_file_protocol(void) {
static
const
WCHAR
index_url2
[]
=
{
'f'
,
'i'
,
'l'
,
'e'
,
':'
,
'/'
,
'/'
,
'i'
,
'n'
,
'd'
,
'e'
,
'x'
,
'.'
,
'h'
,
't'
,
'm'
,
'l'
,
0
};
static
const
WCHAR
wszFile
[]
=
{
'f'
,
'i'
,
'l'
,
'e'
,
':'
,
0
};
static
const
WCHAR
wszFile2
[]
=
{
'f'
,
'i'
,
'l'
,
'e'
,
':'
,
'/'
,
'/'
,
'/'
,
0
};
static
const
WCHAR
wszIndexHtml
[]
=
{
'i'
,
'n'
,
'd'
,
'e'
,
'x'
,
'.'
,
'h'
,
't'
,
'm'
,
'l'
,
0
};
static
const
char
html_doc
[]
=
"<HTML></HTML>"
;
...
...
@@ -388,6 +393,15 @@ static void test_file_protocol(void) {
file_name
=
buf
+
sizeof
(
wszFile
)
/
sizeof
(
WCHAR
)
-
1
;
test_file_protocol_url
(
buf
);
memcpy
(
buf
,
wszFile2
,
sizeof
(
wszFile2
));
len
=
sizeof
(
wszFile2
)
/
sizeof
(
WCHAR
)
-
1
;
len
+=
GetCurrentDirectoryW
(
sizeof
(
buf
)
/
sizeof
(
WCHAR
)
-
len
,
buf
+
len
);
buf
[
len
++
]
=
'\\'
;
memcpy
(
buf
+
len
,
wszIndexHtml
,
sizeof
(
wszIndexHtml
));
file_name
=
buf
+
sizeof
(
wszFile2
)
/
sizeof
(
WCHAR
)
-
1
;
test_file_protocol_url
(
buf
);
DeleteFileW
(
wszIndexHtml
);
hres
=
CoCreateInstance
(
&
CLSID_FileProtocol
,
NULL
,
CLSCTX_INPROC_SERVER
|
CLSCTX_INPROC_HANDLER
,
...
...
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