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
5b04d3d6
Commit
5b04d3d6
authored
Feb 16, 2007
by
Paul Vriens
Committed by
Alexandre Julliard
Feb 19, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet/ftp.c: Fix some returned error codes.
parent
bb7bc013
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
24 deletions
+53
-24
ftp.c
dlls/wininet/ftp.c
+27
-17
ftp.c
dlls/wininet/tests/ftp.c
+26
-7
No files found.
dlls/wininet/ftp.c
View file @
5b04d3d6
...
...
@@ -64,6 +64,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(wininet);
#define szCRLF "\r\n"
#define MAX_BACKLOG 5
/* Testing shows that Windows only accepts dwFlags where the last
* 3 (yes 3) bits define FTP_TRANSFER_TYPE_UNKNOWN, FTP_TRANSFER_TYPE_ASCII or FTP_TRANSFER_TYPE_BINARY.
*/
#define FTP_CONDITION_MASK 0x0007
typedef
enum
{
/* FTP commands with arguments. */
FTP_CMD_ACCT
,
...
...
@@ -201,13 +206,31 @@ BOOL WINAPI FtpPutFileW(HINTERNET hConnect, LPCWSTR lpszLocalFile,
LPWININETAPPINFOW
hIC
=
NULL
;
BOOL
r
=
FALSE
;
if
(
!
lpszLocalFile
||
!
lpszNewRemoteFile
)
{
INTERNET_SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
lpwfs
=
(
LPWININETFTPSESSIONW
)
WININET_GetObject
(
hConnect
);
if
(
NULL
==
lpwfs
||
WH_HFTPSESSION
!=
lpwfs
->
hdr
.
htype
)
if
(
!
lpwfs
)
{
INTERNET_SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
}
if
(
WH_HFTPSESSION
!=
lpwfs
->
hdr
.
htype
)
{
INTERNET_SetLastError
(
ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
goto
lend
;
}
if
((
dwFlags
&
FTP_CONDITION_MASK
)
>
FTP_TRANSFER_TYPE_BINARY
)
{
INTERNET_SetLastError
(
ERROR_INVALID_PARAMETER
);
goto
lend
;
}
hIC
=
lpwfs
->
lpAppInfo
;
if
(
hIC
->
hdr
.
dwFlags
&
INTERNET_FLAG_ASYNC
)
{
...
...
@@ -230,7 +253,6 @@ BOOL WINAPI FtpPutFileW(HINTERNET hConnect, LPCWSTR lpszLocalFile,
}
lend:
if
(
lpwfs
)
WININET_Release
(
&
lpwfs
->
hdr
);
return
r
;
...
...
@@ -256,24 +278,19 @@ BOOL WINAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
TRACE
(
" lpszLocalFile(%s) lpszNewRemoteFile(%s)
\n
"
,
debugstr_w
(
lpszLocalFile
),
debugstr_w
(
lpszNewRemoteFile
));
if
(
!
lpszLocalFile
||
!
lpszNewRemoteFile
)
{
INTERNET_SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
/* Clear any error information */
INTERNET_SetLastError
(
0
);
hIC
=
lpwfs
->
lpAppInfo
;
/* Open file to be uploaded */
if
(
INVALID_HANDLE_VALUE
==
(
hFile
=
CreateFileW
(
lpszLocalFile
,
GENERIC_READ
,
0
,
0
,
OPEN_EXISTING
,
0
,
0
)))
{
INTERNET_SetLastError
(
ERROR_FILE_NOT_FOUND
);
goto
lend
;
return
FALSE
;
}
hIC
=
lpwfs
->
lpAppInfo
;
SendAsyncCallback
(
&
lpwfs
->
hdr
,
lpwfs
->
hdr
.
dwContext
,
INTERNET_STATUS_SENDING_REQUEST
,
NULL
,
0
);
if
(
FTP_SendStore
(
lpwfs
,
lpszNewRemoteFile
,
dwFlags
))
...
...
@@ -296,7 +313,6 @@ BOOL WINAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
}
}
lend:
if
(
lpwfs
->
lstnSocket
!=
-
1
)
closesocket
(
lpwfs
->
lstnSocket
);
...
...
@@ -1193,8 +1209,6 @@ static void AsyncFtpGetFileProc(WORKREQUEST *workRequest)
HeapFree
(
GetProcessHeap
(),
0
,
req
->
lpszNewFile
);
}
#define FTP_CONDITION_MASK 0x0007
BOOL
WINAPI
FtpGetFileW
(
HINTERNET
hInternet
,
LPCWSTR
lpszRemoteFile
,
LPCWSTR
lpszNewFile
,
BOOL
fFailIfExists
,
DWORD
dwLocalFlagsAttribute
,
DWORD
dwInternetFlags
,
DWORD
dwContext
)
...
...
@@ -1222,10 +1236,6 @@ BOOL WINAPI FtpGetFileW(HINTERNET hInternet, LPCWSTR lpszRemoteFile, LPCWSTR lps
goto
lend
;
}
/* Testing shows that Windows only accepts dwInternetFlags where the last
* 3 (yes 3) bits define FTP_TRANSFER_TYPE_UNKNOWN, FTP_TRANSFER_TYPE_ASCII or FTP_TRANSFER_TYPE_BINARY.
*/
if
((
dwInternetFlags
&
FTP_CONDITION_MASK
)
>
FTP_TRANSFER_TYPE_BINARY
)
{
INTERNET_SetLastError
(
ERROR_INVALID_PARAMETER
);
...
...
dlls/wininet/tests/ftp.c
View file @
5b04d3d6
...
...
@@ -245,7 +245,7 @@ static void test_getfile(void)
* Condition flags
*/
/* Test to show
existence of local file
is tested first (together with 'remote file') */
/* Test to show
validity of 'local file' parameter
is tested first (together with 'remote file') */
SetLastError
(
0xdeadbeef
);
bRet
=
FtpGetFileA
(
NULL
,
NULL
,
"should_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpGetFileA to fail
\n
"
);
...
...
@@ -519,11 +519,25 @@ static void test_putfile(void)
HINTERNET
hInternet
,
hFtp
,
hConnect
;
HANDLE
hFile
;
/* Invalid internet handle, the rest are valid parameters */
/* The order of checking is:
*
* All parameters except 'session handle' and 'condition flags'
* Session handle
* Session handle type
* Condition flags
*/
/* Test to show validity of 'local file' parameter is tested first (together with 'remote file') */
SetLastError
(
0xdeadbeef
);
bRet
=
FtpPutFileA
(
NULL
,
"non_existing_local"
,
"non_existing_remote"
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
bRet
=
FtpPutFileA
(
NULL
,
NULL
,
"non_existing_remote"
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpPutFileA to fail
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
/* Test to show session handle is checked before 'condition flags' */
SetLastError
(
0xdeadbeef
);
bRet
=
FtpPutFileA
(
NULL
,
"non_existing_local"
,
"non_existing_remote"
,
5
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpPutFileA to fail
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
...
...
@@ -556,7 +570,6 @@ static void test_putfile(void)
SetLastError
(
0xdeadbeef
);
bRet
=
FtpPutFileA
(
hFtp
,
"non_existing_local"
,
"non_existing_remote"
,
5
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpPutFileA to fail
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
...
...
@@ -564,7 +577,6 @@ static void test_putfile(void)
SetLastError
(
0xdeadbeef
);
bRet
=
FtpPutFileA
(
hFtp
,
"non_existing_local"
,
"non_existing_remote"
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpPutFileA to fail
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"Expected ERROR_FILE_NOT_FOUND, got %d
\n
"
,
GetLastError
());
...
...
@@ -590,7 +602,14 @@ static void test_putfile(void)
hConnect
=
InternetConnect
(
hInternet
,
"www.winehq.org"
,
INTERNET_DEFAULT_HTTP_PORT
,
NULL
,
NULL
,
INTERNET_SERVICE_HTTP
,
0
,
0
);
/* One small test to show that handle type is checked before parameters */
/* Test to show validity of 'local file' parameter is tested a before 'session handle type' */
SetLastError
(
0xdeadbeef
);
bRet
=
FtpPutFileA
(
hConnect
,
NULL
,
"non_existing_remote"
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpPutFileA to fail
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
/* Test to show that 'session handle type' is checked before 'condition flags' */
SetLastError
(
0xdeadbeef
);
bRet
=
FtpPutFileA
(
hConnect
,
"non_existing_local"
,
"non_existing_remote"
,
5
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpPutFileA to fail
\n
"
);
...
...
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