ReactOS  0.4.15-dev-2947-g59e1b78
ftp.c File Reference
#include "ws2tcpip.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wininet.h"
#include "winnls.h"
#include "winerror.h"
#include "winreg.h"
#include "winternl.h"
#include "shlwapi.h"
#include "wine/debug.h"
#include "internet.h"
Include dependency graph for ftp.c:

Go to the source code of this file.

Classes

struct  ftp_file_t
 
struct  _ftp_session_t
 
struct  FILEPROPERTIESW
 
struct  WININETFTPFINDNEXTW
 
struct  put_file_task_t
 
struct  directory_task_t
 
struct  find_first_file_task_t
 
struct  get_current_dir_task_t
 
struct  open_file_task_t
 
struct  get_file_task_t
 
struct  delete_file_task_t
 
struct  rename_file_task_t
 
struct  find_next_task_t
 

Macros

#define RESPONSE_TIMEOUT   30
 
#define DATA_PACKET_SIZE   0x2000
 
#define szCRLF   "\r\n"
 
#define MAX_BACKLOG   5
 
#define FTP_CONDITION_MASK   0x0007
 

Typedefs

typedef struct _ftp_session_t ftp_session_t
 
typedef struct FILEPROPERTIESWLPFILEPROPERTIESW
 
typedef struct WININETFTPFINDNEXTWLPWININETFTPFINDNEXTW
 

Enumerations

enum  FTP_COMMAND {
  FTP_CMD_ACCT, FTP_CMD_CWD, FTP_CMD_DELE, FTP_CMD_MKD,
  FTP_CMD_PASS, FTP_CMD_PORT, FTP_CMD_RETR, FTP_CMD_RMD,
  FTP_CMD_RNFR, FTP_CMD_RNTO, FTP_CMD_STOR, FTP_CMD_TYPE,
  FTP_CMD_USER, FTP_CMD_SIZE, FTP_CMD_ABOR, FTP_CMD_LIST,
  FTP_CMD_NLST, FTP_CMD_PASV, FTP_CMD_PWD, FTP_CMD_QUIT
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wininet)
 
static BOOL FTP_SendCommand (INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
 
static BOOL FTP_SendStore (ftp_session_t *, LPCWSTR lpszRemoteFile, DWORD dwType)
 
static BOOL FTP_GetDataSocket (ftp_session_t *, LPINT nDataSocket)
 
static BOOL FTP_SendData (ftp_session_t *, INT nDataSocket, HANDLE hFile)
 
static INT FTP_ReceiveResponse (ftp_session_t *, DWORD_PTR dwContext)
 
static BOOL FTP_SendRetrieve (ftp_session_t *, LPCWSTR lpszRemoteFile, DWORD dwType)
 
static BOOL FTP_RetrieveFileData (ftp_session_t *, INT nDataSocket, HANDLE hFile)
 
static BOOL FTP_InitListenSocket (ftp_session_t *)
 
static BOOL FTP_ConnectToHost (ftp_session_t *)
 
static BOOL FTP_SendPassword (ftp_session_t *)
 
static BOOL FTP_SendAccount (ftp_session_t *)
 
static BOOL FTP_SendType (ftp_session_t *, DWORD dwType)
 
static BOOL FTP_SendPort (ftp_session_t *)
 
static BOOL FTP_DoPassive (ftp_session_t *)
 
static BOOL FTP_SendPortOrPasv (ftp_session_t *)
 
static BOOL FTP_ParsePermission (LPCSTR lpszPermission, LPFILEPROPERTIESW lpfp)
 
static BOOL FTP_ParseNextFile (INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERTIESW fileprop)
 
static BOOL FTP_ParseDirectory (ftp_session_t *, INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERTIESW *lpafp, LPDWORD dwfp)
 
static HINTERNET FTP_ReceiveFileList (ftp_session_t *, INT nSocket, LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD_PTR dwContext)
 
static DWORD FTP_SetResponseError (DWORD dwResponse)
 
static BOOL FTP_ConvertFileProp (LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData)
 
static BOOL FTP_FtpPutFileW (ftp_session_t *, LPCWSTR lpszLocalFile, LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD_PTR dwContext)
 
static BOOL FTP_FtpSetCurrentDirectoryW (ftp_session_t *, LPCWSTR lpszDirectory)
 
static BOOL FTP_FtpCreateDirectoryW (ftp_session_t *, LPCWSTR lpszDirectory)
 
static HINTERNET FTP_FtpFindFirstFileW (ftp_session_t *, LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD_PTR dwContext)
 
static BOOL FTP_FtpGetCurrentDirectoryW (ftp_session_t *, LPWSTR lpszCurrentDirectory, LPDWORD lpdwCurrentDirectory)
 
static BOOL FTP_FtpRenameFileW (ftp_session_t *, LPCWSTR lpszSrc, LPCWSTR lpszDest)
 
static BOOL FTP_FtpRemoveDirectoryW (ftp_session_t *, LPCWSTR lpszDirectory)
 
static BOOL FTP_FtpDeleteFileW (ftp_session_t *, LPCWSTR lpszFileName)
 
static BOOL FTP_FtpGetFileW (ftp_session_t *, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile, BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags, DWORD_PTR dwContext)
 
static BOOL res_to_le (DWORD res)
 
BOOL WINAPI FtpPutFileA (HINTERNET hConnect, LPCSTR lpszLocalFile, LPCSTR lpszNewRemoteFile, DWORD dwFlags, DWORD_PTR dwContext)
 
static void AsyncFtpPutFileProc (task_header_t *hdr)
 
BOOL WINAPI FtpPutFileW (HINTERNET hConnect, LPCWSTR lpszLocalFile, LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD_PTR dwContext)
 
BOOL WINAPI FtpSetCurrentDirectoryA (HINTERNET hConnect, LPCSTR lpszDirectory)
 
static void AsyncFtpSetCurrentDirectoryProc (task_header_t *hdr)
 
BOOL WINAPI FtpSetCurrentDirectoryW (HINTERNET hConnect, LPCWSTR lpszDirectory)
 
BOOL WINAPI FtpCreateDirectoryA (HINTERNET hConnect, LPCSTR lpszDirectory)
 
static void AsyncFtpCreateDirectoryProc (task_header_t *hdr)
 
BOOL WINAPI FtpCreateDirectoryW (HINTERNET hConnect, LPCWSTR lpszDirectory)
 
HINTERNET WINAPI FtpFindFirstFileA (HINTERNET hConnect, LPCSTR lpszSearchFile, LPWIN32_FIND_DATAA lpFindFileData, DWORD dwFlags, DWORD_PTR dwContext)
 
static void AsyncFtpFindFirstFileProc (task_header_t *hdr)
 
HINTERNET WINAPI FtpFindFirstFileW (HINTERNET hConnect, LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD_PTR dwContext)
 
BOOL WINAPI FtpGetCurrentDirectoryA (HINTERNET hFtpSession, LPSTR lpszCurrentDirectory, LPDWORD lpdwCurrentDirectory)
 
static void AsyncFtpGetCurrentDirectoryProc (task_header_t *hdr)
 
BOOL WINAPI FtpGetCurrentDirectoryW (HINTERNET hFtpSession, LPWSTR lpszCurrentDirectory, LPDWORD lpdwCurrentDirectory)
 
static void FTPFILE_Destroy (object_header_t *hdr)
 
static DWORD FTPFILE_QueryOption (object_header_t *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
 
static DWORD FTPFILE_ReadFile (object_header_t *hdr, void *buffer, DWORD size, DWORD *read, DWORD flags, DWORD_PTR context)
 
static DWORD FTPFILE_WriteFile (object_header_t *hdr, const void *buffer, DWORD size, DWORD *written)
 
static void FTP_ReceiveRequestData (ftp_file_t *file, BOOL first_notif)
 
static void FTPFILE_AsyncQueryDataAvailableProc (task_header_t *task)
 
static DWORD FTPFILE_QueryDataAvailable (object_header_t *hdr, DWORD *available, DWORD flags, DWORD_PTR ctx)
 
static DWORD FTPFILE_LockRequestFile (object_header_t *hdr, req_file_t **ret)
 
static HINTERNET FTP_FtpOpenFileW (ftp_session_t *lpwfs, LPCWSTR lpszFileName, DWORD fdwAccess, DWORD dwFlags, DWORD_PTR dwContext)
 
HINTERNET WINAPI FtpOpenFileA (HINTERNET hFtpSession, LPCSTR lpszFileName, DWORD fdwAccess, DWORD dwFlags, DWORD_PTR dwContext)
 
static void AsyncFtpOpenFileProc (task_header_t *hdr)
 
HINTERNET WINAPI FtpOpenFileW (HINTERNET hFtpSession, LPCWSTR lpszFileName, DWORD fdwAccess, DWORD dwFlags, DWORD_PTR dwContext)
 
BOOL WINAPI FtpGetFileA (HINTERNET hInternet, LPCSTR lpszRemoteFile, LPCSTR lpszNewFile, BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags, DWORD_PTR dwContext)
 
static void AsyncFtpGetFileProc (task_header_t *hdr)
 
BOOL WINAPI FtpGetFileW (HINTERNET hInternet, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile, BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags, DWORD_PTR dwContext)
 
DWORD WINAPI FtpGetFileSize (HINTERNET hFile, LPDWORD lpdwFileSizeHigh)
 
BOOL WINAPI FtpDeleteFileA (HINTERNET hFtpSession, LPCSTR lpszFileName)
 
static void AsyncFtpDeleteFileProc (task_header_t *hdr)
 
BOOL WINAPI FtpDeleteFileW (HINTERNET hFtpSession, LPCWSTR lpszFileName)
 
BOOL WINAPI FtpRemoveDirectoryA (HINTERNET hFtpSession, LPCSTR lpszDirectory)
 
static void AsyncFtpRemoveDirectoryProc (task_header_t *hdr)
 
BOOL WINAPI FtpRemoveDirectoryW (HINTERNET hFtpSession, LPCWSTR lpszDirectory)
 
BOOL WINAPI FtpRenameFileA (HINTERNET hFtpSession, LPCSTR lpszSrc, LPCSTR lpszDest)
 
static void AsyncFtpRenameFileProc (task_header_t *hdr)
 
BOOL WINAPI FtpRenameFileW (HINTERNET hFtpSession, LPCWSTR lpszSrc, LPCWSTR lpszDest)
 
BOOL WINAPI FtpCommandA (HINTERNET hConnect, BOOL fExpectResponse, DWORD dwFlags, LPCSTR lpszCommand, DWORD_PTR dwContext, HINTERNET *phFtpCommand)
 
BOOL WINAPI FtpCommandW (HINTERNET hConnect, BOOL fExpectResponse, DWORD dwFlags, LPCWSTR lpszCommand, DWORD_PTR dwContext, HINTERNET *phFtpCommand)
 
static void FTPSESSION_Destroy (object_header_t *hdr)
 
static void FTPSESSION_CloseConnection (object_header_t *hdr)
 
static DWORD FTPSESSION_QueryOption (object_header_t *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
 
HINTERNET FTP_Connect (appinfo_t *hIC, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext, DWORD dwInternalFlags)
 
static LPSTR FTP_GetNextLine (INT nSocket, LPDWORD dwLen)
 
static BOOL FTP_SendCommandA (INT nSocket, FTP_COMMAND ftpCmd, LPCSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
 
static void FTPFINDNEXT_Destroy (object_header_t *hdr)
 
static DWORD FTPFINDNEXT_FindNextFileProc (WININETFTPFINDNEXTW *find, LPVOID data)
 
static void FTPFINDNEXT_AsyncFindNextFileProc (task_header_t *hdr)
 
static DWORD FTPFINDNEXT_QueryOption (object_header_t *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
 
static DWORD FTPFINDNEXT_FindNextFileW (object_header_t *hdr, void *data)
 

Variables

static const CHAR *const szFtpCommands []
 
static const CHAR szMonths [] = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"
 
static const object_vtbl_t FTPFILEVtbl
 
static const object_vtbl_t FTPSESSIONVtbl
 
static const object_vtbl_t FTPFINDNEXTVtbl
 

Macro Definition Documentation

◆ DATA_PACKET_SIZE

#define DATA_PACKET_SIZE   0x2000

Definition at line 107 of file ftp.c.

◆ FTP_CONDITION_MASK

#define FTP_CONDITION_MASK   0x0007

Definition at line 114 of file ftp.c.

◆ MAX_BACKLOG

#define MAX_BACKLOG   5

Definition at line 109 of file ftp.c.

◆ RESPONSE_TIMEOUT

#define RESPONSE_TIMEOUT   30

Definition at line 59 of file ftp.c.

◆ szCRLF

#define szCRLF   "\r\n"

Definition at line 108 of file ftp.c.

Typedef Documentation

◆ ftp_session_t

Definition at line 61 of file ftp.c.

◆ LPFILEPROPERTIESW

◆ LPWININETFTPFINDNEXTW

Enumeration Type Documentation

◆ FTP_COMMAND

Enumerator
FTP_CMD_ACCT 
FTP_CMD_CWD 
FTP_CMD_DELE 
FTP_CMD_MKD 
FTP_CMD_PASS 
FTP_CMD_PORT 
FTP_CMD_RETR 
FTP_CMD_RMD 
FTP_CMD_RNFR 
FTP_CMD_RNTO 
FTP_CMD_STOR 
FTP_CMD_TYPE 
FTP_CMD_USER 
FTP_CMD_SIZE 
FTP_CMD_ABOR 
FTP_CMD_LIST 
FTP_CMD_NLST 
FTP_CMD_PASV 
FTP_CMD_PWD 
FTP_CMD_QUIT 

Definition at line 116 of file ftp.c.

116  {
117  /* FTP commands with arguments. */
118  FTP_CMD_ACCT,
119  FTP_CMD_CWD,
120  FTP_CMD_DELE,
121  FTP_CMD_MKD,
122  FTP_CMD_PASS,
123  FTP_CMD_PORT,
124  FTP_CMD_RETR,
125  FTP_CMD_RMD,
126  FTP_CMD_RNFR,
127  FTP_CMD_RNTO,
128  FTP_CMD_STOR,
129  FTP_CMD_TYPE,
130  FTP_CMD_USER,
131  FTP_CMD_SIZE,
132 
133  /* FTP commands without arguments. */
134  FTP_CMD_ABOR,
135  FTP_CMD_LIST,
136  FTP_CMD_NLST,
137  FTP_CMD_PASV,
138  FTP_CMD_PWD,
139  FTP_CMD_QUIT,
140 } FTP_COMMAND;
FTP_COMMAND
Definition: ftp.c:116

Function Documentation

◆ AsyncFtpCreateDirectoryProc()

static void AsyncFtpCreateDirectoryProc ( task_header_t hdr)
static

Definition at line 578 of file ftp.c.

579 {
582 
583  TRACE(" %p\n", session);
584 
586  heap_free(task->directory);
587 }
char hdr[14]
Definition: iptest.cpp:33
static BOOL FTP_FtpCreateDirectoryW(ftp_session_t *, LPCWSTR lpszDirectory)
Definition: ftp.c:661
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:390
WCHAR * directory
Definition: ftp.c:432
task_header_t hdr
Definition: ftp.c:431
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FtpCreateDirectoryW().

◆ AsyncFtpDeleteFileProc()

static void AsyncFtpDeleteFileProc ( task_header_t hdr)
static

Definition at line 1793 of file ftp.c.

1794 {
1797 
1798  TRACE("%p\n", session);
1799 
1801  heap_free(task->file_name);
1802 }
char hdr[14]
Definition: iptest.cpp:33
WCHAR * file_name
Definition: ftp.c:1790
#define TRACE(s)
Definition: solgame.cpp:4
task_header_t hdr
Definition: ftp.c:1789
object_header_t * hdr
Definition: internet.h:390
static BOOL FTP_FtpDeleteFileW(ftp_session_t *, LPCWSTR lpszFileName)
Definition: ftp.c:1876
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FtpDeleteFileW().

◆ AsyncFtpFindFirstFileProc()

static void AsyncFtpFindFirstFileProc ( task_header_t hdr)
static

Definition at line 736 of file ftp.c.

737 {
740 
741  TRACE("%p\n", session);
742 
744  heap_free(task->search_file);
745 }
char hdr[14]
Definition: iptest.cpp:33
DWORD_PTR context
Definition: ftp.c:733
WIN32_FIND_DATAW * find_file_data
Definition: ftp.c:731
task_header_t hdr
Definition: ftp.c:729
WCHAR * search_file
Definition: ftp.c:730
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:390
static HINTERNET FTP_FtpFindFirstFileW(ftp_session_t *, LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD_PTR dwContext)
Definition: ftp.c:814
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FtpFindFirstFileW().

◆ AsyncFtpGetCurrentDirectoryProc()

static void AsyncFtpGetCurrentDirectoryProc ( task_header_t hdr)
static

Definition at line 951 of file ftp.c.

952 {
955 
956  TRACE("%p\n", session);
957 
959 }
char hdr[14]
Definition: iptest.cpp:33
DWORD * directory_len
Definition: ftp.c:948
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:390
task_header_t hdr
Definition: ftp.c:946
WCHAR * directory
Definition: ftp.c:947
static BOOL FTP_FtpGetCurrentDirectoryW(ftp_session_t *, LPWSTR lpszCurrentDirectory, LPDWORD lpdwCurrentDirectory)
Definition: ftp.c:1046

Referenced by FtpGetCurrentDirectoryW().

◆ AsyncFtpGetFileProc()

static void AsyncFtpGetFileProc ( task_header_t hdr)
static

Definition at line 1586 of file ftp.c.

1587 {
1590 
1591  TRACE("%p\n", session);
1592 
1594  task->local_attr, task->flags, task->context);
1595  heap_free(task->remote_file);
1596  heap_free(task->new_file);
1597 }
char hdr[14]
Definition: iptest.cpp:33
WCHAR * remote_file
Definition: ftp.c:1578
DWORD_PTR context
Definition: ftp.c:1583
WCHAR * new_file
Definition: ftp.c:1579
task_header_t hdr
Definition: ftp.c:1577
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL FTP_FtpGetFileW(ftp_session_t *, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile, BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags, DWORD_PTR dwContext)
Definition: ftp.c:1687
object_header_t * hdr
Definition: internet.h:390
DWORD local_attr
Definition: ftp.c:1581
DWORD flags
Definition: ftp.c:1582
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
BOOL fail_if_exists
Definition: ftp.c:1580

Referenced by FtpGetFileW().

◆ AsyncFtpOpenFileProc()

static void AsyncFtpOpenFileProc ( task_header_t hdr)
static

Definition at line 1464 of file ftp.c.

1465 {
1468 
1469  TRACE("%p\n", session);
1470 
1471  FTP_FtpOpenFileW(session, task->file_name, task->access, task->flags, task->context);
1472  heap_free(task->file_name);
1473 }
DWORD flags
Definition: ftp.c:1460
char hdr[14]
Definition: iptest.cpp:33
WCHAR * file_name
Definition: ftp.c:1458
DWORD_PTR context
Definition: ftp.c:1461
static HINTERNET FTP_FtpOpenFileW(ftp_session_t *lpwfs, LPCWSTR lpszFileName, DWORD fdwAccess, DWORD dwFlags, DWORD_PTR dwContext)
Definition: ftp.c:1317
task_header_t hdr
Definition: ftp.c:1457
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:390
DWORD access
Definition: ftp.c:1459
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FtpOpenFileW().

◆ AsyncFtpPutFileProc()

static void AsyncFtpPutFileProc ( task_header_t hdr)
static

Definition at line 248 of file ftp.c.

249 {
252 
253  TRACE("%p\n", session);
254 
256  task->flags, task->context);
257 
258  heap_free(task->local_file);
259  heap_free(task->remote_file);
260 }
char hdr[14]
Definition: iptest.cpp:33
WCHAR * remote_file
Definition: ftp.c:243
static BOOL FTP_FtpPutFileW(ftp_session_t *, LPCWSTR lpszLocalFile, LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD_PTR dwContext)
Definition: ftp.c:344
task_header_t hdr
Definition: ftp.c:241
DWORD_PTR context
Definition: ftp.c:245
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:390
DWORD flags
Definition: ftp.c:244
WCHAR * local_file
Definition: ftp.c:242
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FtpPutFileW().

◆ AsyncFtpRemoveDirectoryProc()

static void AsyncFtpRemoveDirectoryProc ( task_header_t hdr)
static

Definition at line 1935 of file ftp.c.

1936 {
1939 
1940  TRACE("%p\n", session);
1941 
1943  heap_free(task->directory);
1944 }
char hdr[14]
Definition: iptest.cpp:33
static BOOL FTP_FtpRemoveDirectoryW(ftp_session_t *, LPCWSTR lpszDirectory)
Definition: ftp.c:2018
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:390
WCHAR * directory
Definition: ftp.c:432
task_header_t hdr
Definition: ftp.c:431
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FtpRemoveDirectoryW().

◆ AsyncFtpRenameFileProc()

static void AsyncFtpRenameFileProc ( task_header_t hdr)
static

Definition at line 2087 of file ftp.c.

2088 {
2091 
2092  TRACE("%p\n", session);
2093 
2095  heap_free(task->src_file);
2096  heap_free(task->dst_file);
2097 }
char hdr[14]
Definition: iptest.cpp:33
WCHAR * dst_file
Definition: ftp.c:2084
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:390
WCHAR * src_file
Definition: ftp.c:2083
task_header_t hdr
Definition: ftp.c:2082
static BOOL FTP_FtpRenameFileW(ftp_session_t *, LPCWSTR lpszSrc, LPCWSTR lpszDest)
Definition: ftp.c:2172
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FtpRenameFileW().

◆ AsyncFtpSetCurrentDirectoryProc()

static void AsyncFtpSetCurrentDirectoryProc ( task_header_t hdr)
static

Definition at line 435 of file ftp.c.

436 {
439 
440  TRACE("%p\n", session);
441 
443  heap_free(task->directory);
444 }
char hdr[14]
Definition: iptest.cpp:33
static BOOL FTP_FtpSetCurrentDirectoryW(ftp_session_t *, LPCWSTR lpszDirectory)
Definition: ftp.c:516
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:390
WCHAR * directory
Definition: ftp.c:432
task_header_t hdr
Definition: ftp.c:431
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FtpSetCurrentDirectoryW().

◆ FTP_Connect()

HINTERNET FTP_Connect ( appinfo_t hIC,
LPCWSTR  lpszServerName,
INTERNET_PORT  nServerPort,
LPCWSTR  lpszUserName,
LPCWSTR  lpszPassword,
DWORD  dwFlags,
DWORD_PTR  dwContext,
DWORD  dwInternalFlags 
)

Definition at line 2428 of file ftp.c.

2432 {
2433  struct sockaddr_in socketAddr;
2434  INT nsocket = -1;
2435  socklen_t sock_namelen;
2436  BOOL bSuccess = FALSE;
2437  ftp_session_t *lpwfs = NULL;
2438  char szaddr[INET6_ADDRSTRLEN];
2439 
2440  TRACE("%p Server(%s) Port(%d) User(%s) Paswd(%s)\n",
2441  hIC, debugstr_w(lpszServerName),
2442  nServerPort, debugstr_w(lpszUserName), debugstr_w(lpszPassword));
2443 
2444  assert( hIC->hdr.htype == WH_HINIT );
2445 
2446  if ((!lpszUserName || !*lpszUserName) && lpszPassword && *lpszPassword)
2447  {
2449  return NULL;
2450  }
2451 
2452  lpwfs = alloc_object(&hIC->hdr, &FTPSESSIONVtbl, sizeof(ftp_session_t));
2453  if (NULL == lpwfs)
2454  {
2456  return NULL;
2457  }
2458 
2459  if (nServerPort == INTERNET_INVALID_PORT_NUMBER)
2461  else
2462  lpwfs->serverport = nServerPort;
2463 
2464  lpwfs->hdr.htype = WH_HFTPSESSION;
2465  lpwfs->hdr.dwFlags = dwFlags;
2466  lpwfs->hdr.dwContext = dwContext;
2467  lpwfs->hdr.dwInternalFlags |= dwInternalFlags;
2468  lpwfs->download_in_progress = NULL;
2469  lpwfs->sndSocket = -1;
2470  lpwfs->lstnSocket = -1;
2471  lpwfs->pasvSocket = -1;
2472 
2473  WININET_AddRef( &hIC->hdr );
2474  lpwfs->lpAppInfo = hIC;
2475  list_add_head( &hIC->hdr.children, &lpwfs->hdr.entry );
2476 
2477  if(hIC->proxy && hIC->accessType == INTERNET_OPEN_TYPE_PROXY) {
2478  if(wcschr(hIC->proxy, ' '))
2479  FIXME("Several proxies not implemented.\n");
2480  if(hIC->proxyBypass)
2481  FIXME("Proxy bypass is ignored.\n");
2482  }
2483  if (!lpszUserName || !lpszUserName[0]) {
2484  HKEY key;
2485  WCHAR szPassword[MAX_PATH];
2486  DWORD len = sizeof(szPassword);
2487 
2488  lpwfs->lpszUserName = heap_strdupW(L"anonymous");
2489 
2490  RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", &key);
2491  if (RegQueryValueExW(key, L"EmailName", NULL, NULL, (LPBYTE)szPassword, &len)) {
2492  /* Nothing in the registry, get the username and use that as the password */
2493  if (!GetUserNameW(szPassword, &len)) {
2494  /* Should never get here, but use an empty password as failsafe */
2495  lstrcpyW(szPassword, L"");
2496  }
2497  }
2498  RegCloseKey(key);
2499 
2500  TRACE("Password used for anonymous ftp : (%s)\n", debugstr_w(szPassword));
2501  lpwfs->lpszPassword = heap_strdupW(szPassword);
2502  }
2503  else {
2504  lpwfs->lpszUserName = heap_strdupW(lpszUserName);
2506  }
2507  lpwfs->servername = heap_strdupW(lpszServerName);
2508 
2509  /* Don't send a handle created callback if this handle was created with InternetOpenUrl */
2510  if (!(lpwfs->hdr.dwInternalFlags & INET_OPENURL))
2511  {
2513 
2514  iar.dwResult = (DWORD_PTR)lpwfs->hdr.hInternet;
2515  iar.dwError = ERROR_SUCCESS;
2516 
2517  INTERNET_SendCallback(&hIC->hdr, dwContext,
2519  sizeof(INTERNET_ASYNC_RESULT));
2520  }
2521 
2523  (LPWSTR) lpszServerName, (lstrlenW(lpszServerName)+1) * sizeof(WCHAR));
2524 
2525  sock_namelen = sizeof(socketAddr);
2526  if (!GetAddress(lpszServerName, lpwfs->serverport, (struct sockaddr *)&socketAddr, &sock_namelen, szaddr))
2527  {
2529  goto lerror;
2530  }
2531 
2532  if (socketAddr.sin_family != AF_INET)
2533  {
2534  WARN("unsupported address family %d\n", socketAddr.sin_family);
2536  goto lerror;
2537  }
2538 
2540  szaddr, strlen(szaddr)+1);
2541 
2542  init_winsock();
2543  nsocket = socket(AF_INET,SOCK_STREAM,0);
2544  if (nsocket == -1)
2545  {
2547  goto lerror;
2548  }
2549 
2551  szaddr, strlen(szaddr)+1);
2552 
2553  if (connect(nsocket, (struct sockaddr *)&socketAddr, sock_namelen) < 0)
2554  {
2555  ERR("Unable to connect (%d)\n", WSAGetLastError());
2557  closesocket(nsocket);
2558  }
2559  else
2560  {
2561  TRACE("Connected to server\n");
2562  lpwfs->sndSocket = nsocket;
2564  szaddr, strlen(szaddr)+1);
2565 
2566  sock_namelen = sizeof(lpwfs->socketAddress);
2567  getsockname(nsocket, (struct sockaddr *) &lpwfs->socketAddress, &sock_namelen);
2568 
2569  if (FTP_ConnectToHost(lpwfs))
2570  {
2571  TRACE("Successfully logged into server\n");
2572  bSuccess = TRUE;
2573  }
2574  }
2575 
2576 lerror:
2577  if (!bSuccess)
2578  {
2579  WININET_Release(&lpwfs->hdr);
2580  return NULL;
2581  }
2582 
2583  return lpwfs->hdr.hInternet;
2584 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
static BOOL FTP_ConnectToHost(ftp_session_t *)
Definition: ftp.c:2597
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
#define HKEY_CURRENT_USER
Definition: winreg.h:11
struct sockaddr_in socketAddress
Definition: ftp.c:81
LPWSTR lpszUserName
Definition: ftp.c:86
LPWSTR servername
Definition: ftp.c:83
#define WARN(fmt,...)
Definition: debug.h:112
#define INTERNET_STATUS_CONNECTING_TO_SERVER
Definition: wininet.h:885
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
struct list children
Definition: internet.h:286
#define INTERNET_OPEN_TYPE_PROXY
Definition: wininet.h:523
#define assert(x)
Definition: debug.h:53
ftp_file_t * download_in_progress
Definition: ftp.c:80
_In_opt_ LPSTR _In_opt_ LPSTR lpszPassword
Definition: winbase.h:2690
#define closesocket
Definition: ncftp.h:477
#define lstrlenW
Definition: compat.h:609
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
#define INTERNET_INVALID_PORT_NUMBER
Definition: wininet.h:36
DWORD_PTR dwContext
Definition: internet.h:278
#define ERROR_INTERNET_CANNOT_CONNECT
Definition: wininet.h:2018
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL GetAddress(const WCHAR *, INTERNET_PORT, SOCKADDR *, int *, char *) DECLSPEC_HIDDEN
Definition: utility.c:133
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
#define debugstr_w
Definition: kernel32.h:32
DWORD accessType
Definition: internet.h:297
#define FIXME(fmt,...)
Definition: debug.h:111
static DWORD_PTR
Definition: ftp.c:44
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:169
int pasvSocket
Definition: ftp.c:79
#define INTERNET_STATUS_NAME_RESOLVED
Definition: wininet.h:884
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
#define TRACE(s)
Definition: solgame.cpp:4
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
object_header_t hdr
Definition: ftp.c:75
INTERNET_PORT serverport
Definition: ftp.c:84
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPWSTR lpszPassword
Definition: ftp.c:85
struct list entry
Definition: internet.h:285
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
int socklen_t
Definition: tcp.c:35
#define ERROR_INTERNET_NAME_NOT_RESOLVED
Definition: wininet.h:1996
#define INTERNET_DEFAULT_FTP_PORT
Definition: wininet.h:38
DWORD_PTR dwResult
Definition: wininet.h:155
LPWSTR proxy
Definition: internet.h:293
static const WCHAR L[]
Definition: oid.c:1250
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
HKEY key
Definition: reg.c:42
void * alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t size)
Definition: internet.c:103
GLenum GLsizei len
Definition: glext.h:6722
#define INTERNET_STATUS_RESOLVING_NAME
Definition: wininet.h:883
HINTERNET hInternet
Definition: internet.h:275
int sndSocket
Definition: ftp.c:77
BOOL WININET_Release(object_header_t *info)
Definition: internet.c:211
#define ERR(fmt,...)
Definition: debug.h:110
object_header_t hdr
Definition: internet.h:291
DWORD dwInternalFlags
Definition: internet.h:281
#define lstrcpyW
Definition: compat.h:608
int lstnSocket
Definition: ftp.c:78
#define INET_OPENURL
Definition: internet.h:243
static const object_vtbl_t FTPSESSIONVtbl
Definition: ftp.c:2396
#define INTERNET_STATUS_CONNECTED_TO_SERVER
Definition: wininet.h:886
#define NULL
Definition: types.h:112
#define INET6_ADDRSTRLEN
Definition: ws2ipdef.h:132
#define AF_INET
Definition: tcpip.h:117
#define INTERNET_STATUS_HANDLE_CREATED
Definition: wininet.h:895
#define SOCK_STREAM
Definition: tcpip.h:118
WCHAR * LPWSTR
Definition: xmlstorage.h:184
appinfo_t * lpAppInfo
Definition: ftp.c:76
LPWSTR proxyBypass
Definition: internet.h:294
WH_TYPE htype
Definition: internet.h:273
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
void init_winsock(void) DECLSPEC_HIDDEN
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
Definition: path.c:41

Referenced by INTERNET_InternetOpenUrlW(), and InternetConnectW().

◆ FTP_ConnectToHost()

static BOOL FTP_ConnectToHost ( ftp_session_t lpwfs)
static

Definition at line 2597 of file ftp.c.

2598 {
2599  INT nResCode;
2600  BOOL bSuccess = FALSE;
2601 
2602  TRACE("\n");
2603  FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2604 
2605  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_USER, lpwfs->lpszUserName, 0, 0, 0))
2606  goto lend;
2607 
2608  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2609  if (nResCode)
2610  {
2611  /* Login successful... */
2612  if (nResCode == 230)
2613  bSuccess = TRUE;
2614  /* User name okay, need password... */
2615  else if (nResCode == 331)
2616  bSuccess = FTP_SendPassword(lpwfs);
2617  /* Need account for login... */
2618  else if (nResCode == 332)
2619  bSuccess = FTP_SendAccount(lpwfs);
2620  else
2621  FTP_SetResponseError(nResCode);
2622  }
2623 
2624  TRACE("Returning %d\n", bSuccess);
2625 lend:
2626  return bSuccess;
2627 }
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define TRUE
Definition: types.h:120
LPWSTR lpszUserName
Definition: ftp.c:86
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL FTP_SendPassword(ftp_session_t *)
Definition: ftp.c:2829
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
static BOOL FTP_SendAccount(ftp_session_t *)
Definition: ftp.c:2869
int sndSocket
Definition: ftp.c:77
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746

Referenced by FTP_Connect().

◆ FTP_ConvertFileProp()

static BOOL FTP_ConvertFileProp ( LPFILEPROPERTIESW  lpafp,
LPWIN32_FIND_DATAW  lpFindFileData 
)
static

Definition at line 3589 of file ftp.c.

3590 {
3591  BOOL bSuccess = FALSE;
3592 
3593  ZeroMemory(lpFindFileData, sizeof(WIN32_FIND_DATAW));
3594 
3595  if (lpafp)
3596  {
3597  SystemTimeToFileTime( &lpafp->tmLastModified, &lpFindFileData->ftLastAccessTime );
3598  lpFindFileData->ftLastWriteTime = lpFindFileData->ftLastAccessTime;
3599  lpFindFileData->ftCreationTime = lpFindFileData->ftLastAccessTime;
3600 
3601  /* Not all fields are filled in */
3602  lpFindFileData->nFileSizeHigh = 0; /* We do not handle files bigger than 0xFFFFFFFF bytes yet :-) */
3603  lpFindFileData->nFileSizeLow = lpafp->nSize;
3604 
3605  if (lpafp->bIsDirectory)
3606  lpFindFileData->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
3607 
3608  if (lpafp->lpszName)
3609  lstrcpynW(lpFindFileData->cFileName, lpafp->lpszName, MAX_PATH);
3610 
3611  bSuccess = TRUE;
3612  }
3613 
3614  return bSuccess;
3615 }
DWORD nFileSizeHigh
Definition: winbase.h:937
#define TRUE
Definition: types.h:120
#define ZeroMemory
Definition: winbase.h:1664
static BOOLEAN bSuccess
Definition: drive.cpp:432
#define lstrcpynW
Definition: compat.h:597
DWORD nFileSizeLow
Definition: winbase.h:938
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
SYSTEMTIME tmLastModified
Definition: ftp.c:94
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
LPWSTR lpszName
Definition: ftp.c:92
#define MAX_PATH
Definition: compat.h:34
WCHAR cFileName[MAX_PATH]
Definition: winbase.h:941
FILETIME ftLastWriteTime
Definition: winbase.h:936
DWORD nSize
Definition: ftp.c:93
FILETIME ftLastAccessTime
Definition: winbase.h:935
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
DWORD dwFileAttributes
Definition: winbase.h:933
BOOL bIsDirectory
Definition: ftp.c:91
FILETIME ftCreationTime
Definition: winbase.h:934

Referenced by FTP_ReceiveFileList(), and FTPFINDNEXT_FindNextFileProc().

◆ FTP_DoPassive()

static BOOL FTP_DoPassive ( ftp_session_t lpwfs)
static

Definition at line 3131 of file ftp.c.

3132 {
3133  INT nResCode;
3134  BOOL bSuccess = FALSE;
3135 
3136  TRACE("\n");
3137  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_PASV, NULL, 0, 0, 0))
3138  goto lend;
3139 
3140  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
3141  if (nResCode)
3142  {
3143  if (nResCode == 227)
3144  {
3145  LPSTR lpszResponseBuffer = INTERNET_GetResponseBuffer();
3146  LPSTR p;
3147  int f[6];
3148  int i;
3149  char *pAddr, *pPort;
3150  INT nsocket = -1;
3151  struct sockaddr_in dataSocketAddress;
3152 
3153  p = lpszResponseBuffer+4; /* skip status code */
3154  while (*p != '\0' && (*p < '0' || *p > '9')) p++;
3155 
3156  if (*p == '\0')
3157  {
3158  ERR("no address found in response, aborting\n");
3159  goto lend;
3160  }
3161 
3162  if (sscanf(p, "%d,%d,%d,%d,%d,%d", &f[0], &f[1], &f[2], &f[3],
3163  &f[4], &f[5]) != 6)
3164  {
3165  ERR("unknown response address format '%s', aborting\n", p);
3166  goto lend;
3167  }
3168  for (i=0; i < 6; i++)
3169  f[i] = f[i] & 0xff;
3170 
3171  dataSocketAddress = lpwfs->socketAddress;
3172  pAddr = (char *)&(dataSocketAddress.sin_addr.S_un.S_addr);
3173  pPort = (char *)&(dataSocketAddress.sin_port);
3174  pAddr[0] = f[0];
3175  pAddr[1] = f[1];
3176  pAddr[2] = f[2];
3177  pAddr[3] = f[3];
3178  pPort[0] = f[4];
3179  pPort[1] = f[5];
3180 
3181  nsocket = socket(AF_INET,SOCK_STREAM,0);
3182  if (nsocket == -1)
3183  goto lend;
3184 
3185  if (connect(nsocket, (struct sockaddr *)&dataSocketAddress, sizeof(dataSocketAddress)))
3186  {
3187  ERR("can't connect passive FTP data port.\n");
3188  closesocket(nsocket);
3189  goto lend;
3190  }
3191  lpwfs->pasvSocket = nsocket;
3192  bSuccess = TRUE;
3193  }
3194  else
3195  FTP_SetResponseError(nResCode);
3196  }
3197 
3198 lend:
3199  return bSuccess;
3200 }
PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER pAddr
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define TRUE
Definition: types.h:120
LPSTR INTERNET_GetResponseBuffer(void)
Definition: internet.c:3937
struct sockaddr_in socketAddress
Definition: ftp.c:81
#define closesocket
Definition: ncftp.h:477
char * LPSTR
Definition: xmlstorage.h:182
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
int pasvSocket
Definition: ftp.c:79
GLfloat f
Definition: glext.h:7540
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
int sndSocket
Definition: ftp.c:77
#define ERR(fmt,...)
Definition: debug.h:110
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746
#define AF_INET
Definition: tcpip.h:117
#define SOCK_STREAM
Definition: tcpip.h:118
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by FTP_SendPortOrPasv().

◆ FTP_FtpCreateDirectoryW()

static BOOL FTP_FtpCreateDirectoryW ( ftp_session_t lpwfs,
LPCWSTR  lpszDirectory 
)
static

Definition at line 661 of file ftp.c.

662 {
663  INT nResCode;
664  BOOL bSuccess = FALSE;
665  appinfo_t *hIC = NULL;
666 
667  TRACE("lpszDirectory(%s)\n", debugstr_w(lpszDirectory));
668 
669  /* Clear any error information */
671 
672  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_MKD, lpszDirectory, 0, 0, 0))
673  goto lend;
674 
675  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
676  if (nResCode)
677  {
678  if (nResCode == 257)
679  bSuccess = TRUE;
680  else
681  FTP_SetResponseError(nResCode);
682  }
683 
684 lend:
685  hIC = lpwfs->lpAppInfo;
686  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
687  {
689 
690  iar.dwResult = (DWORD)bSuccess;
693  &iar, sizeof(INTERNET_ASYNC_RESULT));
694  }
695 
696  return bSuccess;
697 }
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3858
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
int sndSocket
Definition: ftp.c:77
object_header_t hdr
Definition: internet.h:291
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define NULL
Definition: types.h:112
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746
appinfo_t * lpAppInfo
Definition: ftp.c:76
static DWORD
Definition: ftp.c:44

Referenced by AsyncFtpCreateDirectoryProc(), and FtpCreateDirectoryW().

◆ FTP_FtpDeleteFileW()

BOOL FTP_FtpDeleteFileW ( ftp_session_t lpwfs,
LPCWSTR  lpszFileName 
)
static

Definition at line 1876 of file ftp.c.

1877 {
1878  INT nResCode;
1879  BOOL bSuccess = FALSE;
1880  appinfo_t *hIC = NULL;
1881 
1882  TRACE("%p\n", lpwfs);
1883 
1884  /* Clear any error information */
1886 
1887  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_DELE, lpszFileName, 0, 0, 0))
1888  goto lend;
1889 
1890  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
1891  if (nResCode)
1892  {
1893  if (nResCode == 250)
1894  bSuccess = TRUE;
1895  else
1896  FTP_SetResponseError(nResCode);
1897  }
1898 lend:
1899  hIC = lpwfs->lpAppInfo;
1900  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
1901  {
1903 
1904  iar.dwResult = (DWORD)bSuccess;
1907  &iar, sizeof(INTERNET_ASYNC_RESULT));
1908  }
1909 
1910  return bSuccess;
1911 }
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3858
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
int sndSocket
Definition: ftp.c:77
object_header_t hdr
Definition: internet.h:291
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define NULL
Definition: types.h:112
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746
appinfo_t * lpAppInfo
Definition: ftp.c:76
static DWORD
Definition: ftp.c:44

Referenced by AsyncFtpDeleteFileProc(), and FtpDeleteFileW().

◆ FTP_FtpFindFirstFileW()

static HINTERNET FTP_FtpFindFirstFileW ( ftp_session_t lpwfs,
LPCWSTR  lpszSearchFile,
LPWIN32_FIND_DATAW  lpFindFileData,
DWORD  dwFlags,
DWORD_PTR  dwContext 
)
static

Definition at line 814 of file ftp.c.

816 {
817  INT nResCode;
818  appinfo_t *hIC = NULL;
819  HINTERNET hFindNext = NULL;
820  LPWSTR lpszSearchPath = NULL;
821 
822  TRACE("\n");
823 
824  /* Clear any error information */
826 
827  if (!FTP_InitListenSocket(lpwfs))
828  goto lend;
829 
831  goto lend;
832 
833  if (!FTP_SendPortOrPasv(lpwfs))
834  goto lend;
835 
836  /* split search path into file and path */
837  if (lpszSearchFile)
838  {
839  LPCWSTR name = lpszSearchFile, p;
840  if ((p = wcsrchr( name, '\\' ))) name = p + 1;
841  if ((p = wcsrchr( name, '/' ))) name = p + 1;
842  if (name != lpszSearchFile)
843  {
844  lpszSearchPath = heap_strndupW(lpszSearchFile, name - lpszSearchFile);
845  lpszSearchFile = name;
846  }
847  }
848 
849  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_LIST, lpszSearchPath,
850  lpwfs->hdr.lpfnStatusCB, &lpwfs->hdr, lpwfs->hdr.dwContext))
851  goto lend;
852 
853  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
854  if (nResCode)
855  {
856  if (nResCode == 125 || nResCode == 150)
857  {
858  INT nDataSocket;
859 
860  /* Get data socket to server */
861  if (FTP_GetDataSocket(lpwfs, &nDataSocket))
862  {
863  hFindNext = FTP_ReceiveFileList(lpwfs, nDataSocket, lpszSearchFile, lpFindFileData, dwContext);
864  closesocket(nDataSocket);
865  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
866  if (nResCode != 226 && nResCode != 250)
868  }
869  }
870  else
871  FTP_SetResponseError(nResCode);
872  }
873 
874 lend:
875  heap_free(lpszSearchPath);
876 
877  if (lpwfs->lstnSocket != -1)
878  {
879  closesocket(lpwfs->lstnSocket);
880  lpwfs->lstnSocket = -1;
881  }
882 
883  hIC = lpwfs->lpAppInfo;
884  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
885  {
887 
888  if (hFindNext)
889  {
890  iar.dwResult = (DWORD_PTR)hFindNext;
891  iar.dwError = ERROR_SUCCESS;
893  &iar, sizeof(INTERNET_ASYNC_RESULT));
894  }
895 
896  iar.dwResult = (DWORD_PTR)hFindNext;
897  iar.dwError = hFindNext ? ERROR_SUCCESS : INTERNET_GetLastError();
899  &iar, sizeof(INTERNET_ASYNC_RESULT));
900  }
901 
902  return hFindNext;
903 }
static BOOL FTP_SendType(ftp_session_t *, DWORD dwType)
Definition: ftp.c:3006
static LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
static BOOL FTP_InitListenSocket(ftp_session_t *)
Definition: ftp.c:2946
#define closesocket
Definition: ncftp.h:477
int32_t INT
Definition: typedefs.h:58
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3858
static DWORD_PTR
Definition: ftp.c:44
static BOOL FTP_SendPortOrPasv(ftp_session_t *)
Definition: ftp.c:3203
#define ERROR_NO_MORE_FILES
Definition: winerror.h:121
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
#define INTERNET_FLAG_TRANSFER_ASCII
Definition: wininet.h:90
static BOOL FTP_GetDataSocket(ftp_session_t *, LPINT nDataSocket)
Definition: ftp.c:3232
#define wcsrchr
Definition: compat.h:16
int sndSocket
Definition: ftp.c:77
object_header_t hdr
Definition: internet.h:291
int lstnSocket
Definition: ftp.c:78
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define NULL
Definition: types.h:112
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746
Definition: name.c:38
INTERNET_STATUS_CALLBACK lpfnStatusCB
Definition: internet.h:284
#define INTERNET_STATUS_HANDLE_CREATED
Definition: wininet.h:895
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static HINTERNET FTP_ReceiveFileList(ftp_session_t *, INT nSocket, LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD_PTR dwContext)
Definition: ftp.c:3545
appinfo_t * lpAppInfo
Definition: ftp.c:76
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by AsyncFtpFindFirstFileProc(), and FtpFindFirstFileW().

◆ FTP_FtpGetCurrentDirectoryW()

static BOOL FTP_FtpGetCurrentDirectoryW ( ftp_session_t lpwfs,
LPWSTR  lpszCurrentDirectory,
LPDWORD  lpdwCurrentDirectory 
)
static

Definition at line 1046 of file ftp.c.

1048 {
1049  INT nResCode;
1050  appinfo_t *hIC = NULL;
1051  BOOL bSuccess = FALSE;
1052 
1053  /* Clear any error information */
1055 
1056  hIC = lpwfs->lpAppInfo;
1057  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_PWD, NULL,
1058  lpwfs->hdr.lpfnStatusCB, &lpwfs->hdr, lpwfs->hdr.dwContext))
1059  goto lend;
1060 
1061  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
1062  if (nResCode)
1063  {
1064  if (nResCode == 257) /* Extract directory name */
1065  {
1066  DWORD firstpos, lastpos, len;
1067  LPWSTR lpszResponseBuffer = heap_strdupAtoW(INTERNET_GetResponseBuffer());
1068 
1069  for (firstpos = 0, lastpos = 0; lpszResponseBuffer[lastpos]; lastpos++)
1070  {
1071  if ('"' == lpszResponseBuffer[lastpos])
1072  {
1073  if (!firstpos)
1074  firstpos = lastpos;
1075  else
1076  break;
1077  }
1078  }
1079  len = lastpos - firstpos;
1080  if (*lpdwCurrentDirectory >= len)
1081  {
1082  memcpy(lpszCurrentDirectory, &lpszResponseBuffer[firstpos + 1], len * sizeof(WCHAR));
1083  lpszCurrentDirectory[len - 1] = 0;
1084  *lpdwCurrentDirectory = len;
1085  bSuccess = TRUE;
1086  }
1088 
1089  heap_free(lpszResponseBuffer);
1090  }
1091  else
1092  FTP_SetResponseError(nResCode);
1093  }
1094 
1095 lend:
1096  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
1097  {
1099 
1100  iar.dwResult = bSuccess;
1103  &iar, sizeof(INTERNET_ASYNC_RESULT));
1104  }
1105 
1106  return bSuccess;
1107 }
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define ERROR_INTERNET_EXTENDED_ERROR
Definition: wininet.h:1992
#define TRUE
Definition: types.h:120
LPSTR INTERNET_GetResponseBuffer(void)
Definition: internet.c:3937
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static WCHAR * heap_strdupAtoW(const char *str)
Definition: appwiz.h:80
object_header_t hdr
Definition: ftp.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
int sndSocket
Definition: ftp.c:77
object_header_t hdr
Definition: internet.h:291
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define NULL
Definition: types.h:112
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746
INTERNET_STATUS_CALLBACK lpfnStatusCB
Definition: internet.h:284
WCHAR * LPWSTR
Definition: xmlstorage.h:184
appinfo_t * lpAppInfo
Definition: ftp.c:76
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by AsyncFtpGetCurrentDirectoryProc(), and FtpGetCurrentDirectoryW().

◆ FTP_FtpGetFileW()

static BOOL FTP_FtpGetFileW ( ftp_session_t lpwfs,
LPCWSTR  lpszRemoteFile,
LPCWSTR  lpszNewFile,
BOOL  fFailIfExists,
DWORD  dwLocalFlagsAttribute,
DWORD  dwInternetFlags,
DWORD_PTR  dwContext 
)
static

Definition at line 1687 of file ftp.c.

1690 {
1691  BOOL bSuccess = FALSE;
1692  HANDLE hFile;
1693  appinfo_t *hIC = NULL;
1694 
1695  TRACE("lpszRemoteFile(%s) lpszNewFile(%s)\n", debugstr_w(lpszRemoteFile), debugstr_w(lpszNewFile));
1696 
1697  /* Clear any error information */
1699 
1700  /* Ensure we can write to lpszNewfile by opening it */
1701  hFile = CreateFileW(lpszNewFile, GENERIC_WRITE, 0, 0, fFailIfExists ?
1702  CREATE_NEW : CREATE_ALWAYS, dwLocalFlagsAttribute, 0);
1703  if (INVALID_HANDLE_VALUE == hFile)
1704  return FALSE;
1705 
1706  /* Set up socket to retrieve data */
1707  if (FTP_SendRetrieve(lpwfs, lpszRemoteFile, dwInternetFlags))
1708  {
1709  INT nDataSocket;
1710 
1711  /* Get data socket to server */
1712  if (FTP_GetDataSocket(lpwfs, &nDataSocket))
1713  {
1714  INT nResCode;
1715 
1716  /* Receive data */
1717  FTP_RetrieveFileData(lpwfs, nDataSocket, hFile);
1718  closesocket(nDataSocket);
1719 
1720  nResCode = FTP_ReceiveResponse(lpwfs, dwContext);
1721  if (nResCode)
1722  {
1723  if (nResCode == 226)
1724  bSuccess = TRUE;
1725  else
1726  FTP_SetResponseError(nResCode);
1727  }
1728  }
1729  }
1730 
1731  if (lpwfs->lstnSocket != -1)
1732  {
1733  closesocket(lpwfs->lstnSocket);
1734  lpwfs->lstnSocket = -1;
1735  }
1736 
1737  CloseHandle(hFile);
1738 
1739  hIC = lpwfs->lpAppInfo;
1740  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
1741  {
1743 
1744  iar.dwResult = (DWORD)bSuccess;
1747  &iar, sizeof(INTERNET_ASYNC_RESULT));
1748  }
1749 
1750  if (!bSuccess) DeleteFileW(lpszNewFile);
1751  return bSuccess;
1752 }
#define CloseHandle
Definition: compat.h:598
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define closesocket
Definition: ncftp.h:477
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
#define debugstr_w
Definition: kernel32.h:32
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3858
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
static BOOL FTP_RetrieveFileData(ftp_session_t *, INT nDataSocket, HANDLE hFile)
Definition: ftp.c:3389
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
static BOOL FTP_GetDataSocket(ftp_session_t *, LPINT nDataSocket)
Definition: ftp.c:3232
_In_ HANDLE hFile
Definition: mswsock.h:90
object_header_t hdr
Definition: internet.h:291
#define CREATE_ALWAYS
Definition: disk.h:72
int lstnSocket
Definition: ftp.c:78
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define NULL
Definition: types.h:112
#define CreateFileW
Definition: compat.h:600
#define CREATE_NEW
Definition: disk.h:69
static BOOL FTP_SendRetrieve(ftp_session_t *, LPCWSTR lpszRemoteFile, DWORD dwType)
Definition: ftp.c:3343
appinfo_t * lpAppInfo
Definition: ftp.c:76
static DWORD
Definition: ftp.c:44

Referenced by AsyncFtpGetFileProc(), and FtpGetFileW().

◆ FTP_FtpOpenFileW()

static HINTERNET FTP_FtpOpenFileW ( ftp_session_t lpwfs,
LPCWSTR  lpszFileName,
DWORD  fdwAccess,
DWORD  dwFlags,
DWORD_PTR  dwContext 
)
static

Definition at line 1317 of file ftp.c.

1320 {
1321  INT nDataSocket;
1322  BOOL bSuccess = FALSE;
1323  ftp_file_t *lpwh = NULL;
1324  appinfo_t *hIC = NULL;
1325 
1326  TRACE("\n");
1327 
1328  /* Clear any error information */
1330 
1331  if (GENERIC_READ == fdwAccess)
1332  {
1333  /* Set up socket to retrieve data */
1334  bSuccess = FTP_SendRetrieve(lpwfs, lpszFileName, dwFlags);
1335  }
1336  else if (GENERIC_WRITE == fdwAccess)
1337  {
1338  /* Set up socket to send data */
1339  bSuccess = FTP_SendStore(lpwfs, lpszFileName, dwFlags);
1340  }
1341 
1342  /* Get data socket to server */
1343  if (bSuccess && FTP_GetDataSocket(lpwfs, &nDataSocket))
1344  {
1345  lpwh = alloc_object(&lpwfs->hdr, &FTPFILEVtbl, sizeof(ftp_file_t));
1346  lpwh->hdr.htype = WH_HFILE;
1347  lpwh->hdr.dwFlags = dwFlags;
1348  lpwh->hdr.dwContext = dwContext;
1349  lpwh->nDataSocket = nDataSocket;
1350  lpwh->cache_file = NULL;
1352  lpwh->session_deleted = FALSE;
1353 
1354  WININET_AddRef( &lpwfs->hdr );
1355  lpwh->lpFtpSession = lpwfs;
1356  list_add_head( &lpwfs->hdr.children, &lpwh->hdr.entry );
1357 
1358  /* Indicate that a download is currently in progress */
1359  lpwfs->download_in_progress = lpwh;
1360  }
1361 
1362  if (lpwfs->lstnSocket != -1)
1363  {
1364  closesocket(lpwfs->lstnSocket);
1365  lpwfs->lstnSocket = -1;
1366  }
1367 
1368  if (bSuccess && fdwAccess == GENERIC_READ)
1369  {
1370  WCHAR filename[MAX_PATH + 1];
1371  URL_COMPONENTSW uc;
1372  DWORD len;
1373 
1374  memset(&uc, 0, sizeof(uc));
1375  uc.dwStructSize = sizeof(uc);
1377  uc.lpszHostName = lpwfs->servername;
1378  uc.nPort = lpwfs->serverport;
1379  uc.lpszUserName = lpwfs->lpszUserName;
1380  uc.lpszUrlPath = heap_strdupW(lpszFileName);
1381 
1383  {
1384  WCHAR *url = heap_alloc(len * sizeof(WCHAR));
1385 
1386  if (url && InternetCreateUrlW(&uc, 0, url, &len) && CreateUrlCacheEntryW(url, 0, NULL, filename, 0))
1387  {
1388  lpwh->cache_file = heap_strdupW(filename);
1392  {
1393  WARN("Could not create cache file: %u\n", GetLastError());
1394  heap_free(lpwh->cache_file);
1395  lpwh->cache_file = NULL;
1396  }
1397  }
1398  heap_free(url);
1399  }
1400  heap_free(uc.lpszUrlPath);
1401  }
1402 
1403  hIC = lpwfs->lpAppInfo;
1404  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
1405  {
1407 
1408  if (lpwh)
1409  {
1410  iar.dwResult = (DWORD_PTR)lpwh->hdr.hInternet;
1411  iar.dwError = ERROR_SUCCESS;
1413  &iar, sizeof(INTERNET_ASYNC_RESULT));
1414  }
1415 
1416  if(bSuccess) {
1418  }else {
1419  iar.dwResult = 0;
1422  &iar, sizeof(INTERNET_ASYNC_RESULT));
1423  }
1424  }
1425 
1426  if(!bSuccess)
1427  return FALSE;
1428 
1429  return lpwh->hdr.hInternet;
1430 }
BOOL WINAPI CreateUrlCacheEntryW(LPCWSTR lpszUrlName, DWORD dwExpectedFileSize, LPCWSTR lpszFileExtension, LPWSTR lpszFileName, DWORD dwReserved)
Definition: urlcache.c:2815
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
DWORD dwStructSize
Definition: wininet.h:211
#define TRUE
Definition: types.h:120
static const object_vtbl_t FTPFILEVtbl
Definition: ftp.c:1295
LPWSTR lpszUserName
Definition: ftp.c:86
LPWSTR servername
Definition: ftp.c:83
#define WARN(fmt,...)
Definition: debug.h:112
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
struct list children
Definition: internet.h:286
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
ftp_file_t * download_in_progress
Definition: ftp.c:80
#define closesocket
Definition: ncftp.h:477
const char * filename
Definition: ioapi.h:135
LPWSTR lpszHostName
Definition: wininet.h:215
static void FTP_ReceiveRequestData(ftp_file_t *file, BOOL first_notif)
Definition: ftp.c:1226
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD_PTR dwContext
Definition: internet.h:278
HANDLE cache_file_handle
Definition: ftp.c:70
Definition: ftp.c:63
static BOOL FTP_SendStore(ftp_session_t *, LPCWSTR lpszRemoteFile, DWORD dwType)
Definition: ftp.c:2899
#define FALSE
Definition: types.h:117
INTERNET_PORT nPort
Definition: wininet.h:217
unsigned int BOOL
Definition: ntddk_ex.h:94
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
#define GENERIC_WRITE
Definition: nt_native.h:90
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3858
static DWORD_PTR
Definition: ftp.c:44
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:169
ftp_session_t * lpFtpSession
Definition: ftp.c:66
#define OPEN_EXISTING
Definition: compat.h:634
object_header_t hdr
Definition: ftp.c:65
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
INTERNET_PORT serverport
Definition: ftp.c:84
int nDataSocket
Definition: ftp.c:68
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR url[]
Definition: encode.c:1432
struct list entry
Definition: internet.h:285
INTERNET_SCHEME nScheme
Definition: wininet.h:214
#define MAX_PATH
Definition: compat.h:34
BOOL session_deleted
Definition: ftp.c:67
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
LPWSTR lpszUserName
Definition: wininet.h:218
static BOOL FTP_GetDataSocket(ftp_session_t *, LPINT nDataSocket)
Definition: ftp.c:3232
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPWSTR lpszUrlPath
Definition: wininet.h:222
void * alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t size)
Definition: internet.c:103
GLenum GLsizei len
Definition: glext.h:6722
#define GENERIC_READ
Definition: compat.h:135
HINTERNET hInternet
Definition: internet.h:275
WCHAR * cache_file
Definition: ftp.c:69
object_header_t hdr
Definition: internet.h:291
BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags, LPWSTR lpszUrl, LPDWORD lpdwUrlLength)
Definition: internet.c:4425
int lstnSocket
Definition: ftp.c:78
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define NULL
Definition: types.h:112
#define CreateFileW
Definition: compat.h:600
#define INTERNET_STATUS_HANDLE_CREATED
Definition: wininet.h:895
static BOOL FTP_SendRetrieve(ftp_session_t *, LPCWSTR lpszRemoteFile, DWORD dwType)
Definition: ftp.c:3343
appinfo_t * lpAppInfo
Definition: ftp.c:76
#define memset(x, y, z)
Definition: compat.h:39
WH_TYPE htype
Definition: internet.h:273
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by AsyncFtpOpenFileProc(), and FtpOpenFileW().

◆ FTP_FtpPutFileW()

static BOOL FTP_FtpPutFileW ( ftp_session_t lpwfs,
LPCWSTR  lpszLocalFile,
LPCWSTR  lpszNewRemoteFile,
DWORD  dwFlags,
DWORD_PTR  dwContext 
)
static

Definition at line 344 of file ftp.c.

346 {
347  HANDLE hFile;
348  BOOL bSuccess = FALSE;
349  appinfo_t *hIC = NULL;
350  INT nResCode;
351 
352  TRACE(" lpszLocalFile(%s) lpszNewRemoteFile(%s)\n", debugstr_w(lpszLocalFile), debugstr_w(lpszNewRemoteFile));
353 
354  /* Clear any error information */
356 
357  /* Open file to be uploaded */
358  if (INVALID_HANDLE_VALUE ==
359  (hFile = CreateFileW(lpszLocalFile, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0)))
360  /* Let CreateFile set the appropriate error */
361  return FALSE;
362 
363  hIC = lpwfs->lpAppInfo;
364 
366 
367  if (FTP_SendStore(lpwfs, lpszNewRemoteFile, dwFlags))
368  {
369  INT nDataSocket;
370 
371  /* Get data socket to server */
372  if (FTP_GetDataSocket(lpwfs, &nDataSocket))
373  {
374  FTP_SendData(lpwfs, nDataSocket, hFile);
375  closesocket(nDataSocket);
376  nResCode = FTP_ReceiveResponse(lpwfs, dwContext);
377  if (nResCode)
378  {
379  if (nResCode == 226)
380  bSuccess = TRUE;
381  else
382  FTP_SetResponseError(nResCode);
383  }
384  }
385  }
386 
387  if (lpwfs->lstnSocket != -1)
388  {
389  closesocket(lpwfs->lstnSocket);
390  lpwfs->lstnSocket = -1;
391  }
392 
393  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
394  {
396 
397  iar.dwResult = (DWORD)bSuccess;
400  &iar, sizeof(INTERNET_ASYNC_RESULT));
401  }
402 
404 
405  return bSuccess;
406 }
#define CloseHandle
Definition: compat.h:598
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define closesocket
Definition: ncftp.h:477
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:278
static BOOL FTP_SendData(ftp_session_t *, INT nDataSocket, HANDLE hFile)
Definition: ftp.c:3263
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
static BOOL FTP_SendStore(ftp_session_t *, LPCWSTR lpszRemoteFile, DWORD dwType)
Definition: ftp.c:2899
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3858
#define OPEN_EXISTING
Definition: compat.h:634
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
static BOOL FTP_GetDataSocket(ftp_session_t *, LPINT nDataSocket)
Definition: ftp.c:3232
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define INTERNET_STATUS_SENDING_REQUEST
Definition: wininet.h:887
#define GENERIC_READ
Definition: compat.h:135
_In_ HANDLE hFile
Definition: mswsock.h:90
object_header_t hdr
Definition: internet.h:291
int lstnSocket
Definition: ftp.c:78
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define NULL
Definition: types.h:112
#define CreateFileW
Definition: compat.h:600
appinfo_t * lpAppInfo
Definition: ftp.c:76
static DWORD
Definition: ftp.c:44

Referenced by AsyncFtpPutFileProc(), and FtpPutFileW().

◆ FTP_FtpRemoveDirectoryW()

BOOL FTP_FtpRemoveDirectoryW ( ftp_session_t lpwfs,
LPCWSTR  lpszDirectory 
)
static

Definition at line 2018 of file ftp.c.

2019 {
2020  INT nResCode;
2021  BOOL bSuccess = FALSE;
2022  appinfo_t *hIC = NULL;
2023 
2024  TRACE("\n");
2025 
2026  /* Clear any error information */
2028 
2029  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_RMD, lpszDirectory, 0, 0, 0))
2030  goto lend;
2031 
2032  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2033  if (nResCode)
2034  {
2035  if (nResCode == 250)
2036  bSuccess = TRUE;
2037  else
2038  FTP_SetResponseError(nResCode);
2039  }
2040 
2041 lend:
2042  hIC = lpwfs->lpAppInfo;
2043  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
2044  {
2046 
2047  iar.dwResult = (DWORD)bSuccess;
2050  &iar, sizeof(INTERNET_ASYNC_RESULT));
2051  }
2052 
2053  return bSuccess;
2054 }
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3858
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
int sndSocket
Definition: ftp.c:77
object_header_t hdr
Definition: internet.h:291
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define NULL
Definition: types.h:112
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746
appinfo_t * lpAppInfo
Definition: ftp.c:76
static DWORD
Definition: ftp.c:44

Referenced by AsyncFtpRemoveDirectoryProc(), and FtpRemoveDirectoryW().

◆ FTP_FtpRenameFileW()

BOOL FTP_FtpRenameFileW ( ftp_session_t lpwfs,
LPCWSTR  lpszSrc,
LPCWSTR  lpszDest 
)
static

Definition at line 2172 of file ftp.c.

2173 {
2174  INT nResCode;
2175  BOOL bSuccess = FALSE;
2176  appinfo_t *hIC = NULL;
2177 
2178  TRACE("\n");
2179 
2180  /* Clear any error information */
2182 
2183  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_RNFR, lpszSrc, 0, 0, 0))
2184  goto lend;
2185 
2186  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2187  if (nResCode == 350)
2188  {
2189  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_RNTO, lpszDest, 0, 0, 0))
2190  goto lend;
2191 
2192  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2193  }
2194 
2195  if (nResCode == 250)
2196  bSuccess = TRUE;
2197  else
2198  FTP_SetResponseError(nResCode);
2199 
2200 lend:
2201  hIC = lpwfs->lpAppInfo;
2202  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
2203  {
2205 
2206  iar.dwResult = (DWORD)bSuccess;
2209  &iar, sizeof(INTERNET_ASYNC_RESULT));
2210  }
2211 
2212  return bSuccess;
2213 }
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3858
WCHAR lpszDest[260]
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
int sndSocket
Definition: ftp.c:77
object_header_t hdr
Definition: internet.h:291
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define NULL
Definition: types.h:112
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746
appinfo_t * lpAppInfo
Definition: ftp.c:76
static DWORD
Definition: ftp.c:44

Referenced by AsyncFtpRenameFileProc(), and FtpRenameFileW().

◆ FTP_FtpSetCurrentDirectoryW()

static BOOL FTP_FtpSetCurrentDirectoryW ( ftp_session_t lpwfs,
LPCWSTR  lpszDirectory 
)
static

Definition at line 516 of file ftp.c.

517 {
518  INT nResCode;
519  appinfo_t *hIC = NULL;
520  BOOL bSuccess = FALSE;
521 
522  TRACE("lpszDirectory(%s)\n", debugstr_w(lpszDirectory));
523 
524  /* Clear any error information */
526 
527  hIC = lpwfs->lpAppInfo;
528  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_CWD, lpszDirectory,
529  lpwfs->hdr.lpfnStatusCB, &lpwfs->hdr, lpwfs->hdr.dwContext))
530  goto lend;
531 
532  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
533 
534  if (nResCode)
535  {
536  if (nResCode == 250)
537  bSuccess = TRUE;
538  else
539  FTP_SetResponseError(nResCode);
540  }
541 
542 lend:
543  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
544  {
546 
547  iar.dwResult = bSuccess;
550  &iar, sizeof(INTERNET_ASYNC_RESULT));
551  }
552  return bSuccess;
553 }
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define ERROR_INTERNET_EXTENDED_ERROR
Definition: wininet.h:1992
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
int sndSocket
Definition: ftp.c:77
object_header_t hdr
Definition: internet.h:291
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define NULL
Definition: types.h:112
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746
INTERNET_STATUS_CALLBACK lpfnStatusCB
Definition: internet.h:284
appinfo_t * lpAppInfo
Definition: ftp.c:76

Referenced by AsyncFtpSetCurrentDirectoryProc(), and FtpSetCurrentDirectoryW().

◆ FTP_GetDataSocket()

static BOOL FTP_GetDataSocket ( ftp_session_t lpwfs,
LPINT  nDataSocket 
)
static

Definition at line 3232 of file ftp.c.

3233 {
3234  struct sockaddr_in saddr;
3235  socklen_t addrlen = sizeof(saddr);
3236 
3237  TRACE("\n");
3238  if (lpwfs->hdr.dwFlags & INTERNET_FLAG_PASSIVE)
3239  {
3240  *nDataSocket = lpwfs->pasvSocket;
3241  lpwfs->pasvSocket = -1;
3242  }
3243  else
3244  {
3245  *nDataSocket = accept(lpwfs->lstnSocket, (struct sockaddr *) &saddr, &addrlen);
3246  closesocket(lpwfs->lstnSocket);
3247  lpwfs->lstnSocket = -1;
3248  }
3249  return *nDataSocket != -1;
3250 }
#define closesocket
Definition: ncftp.h:477
int pasvSocket
Definition: ftp.c:79
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
int socklen_t
Definition: tcp.c:35
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
#define INTERNET_FLAG_PASSIVE
Definition: wininet.h:65
int lstnSocket
Definition: ftp.c:78

Referenced by FTP_FtpFindFirstFileW(), FTP_FtpGetFileW(), FTP_FtpOpenFileW(), and FTP_FtpPutFileW().

◆ FTP_GetNextLine()

static LPSTR FTP_GetNextLine ( INT  nSocket,
LPDWORD  dwLen 
)
static

Definition at line 2640 of file ftp.c.

2641 {
2642  struct timeval tv = {RESPONSE_TIMEOUT,0};
2643  FD_SET set;
2644  INT nRecv = 0;
2645  LPSTR lpszBuffer = INTERNET_GetResponseBuffer();
2646 
2647  TRACE("\n");
2648 
2649  FD_ZERO(&set);
2650  FD_SET(nSocket, &set);
2651 
2652  while (nRecv < MAX_REPLY_LEN)
2653  {
2654  if (select(nSocket+1, &set, NULL, NULL, &tv) > 0)
2655  {
2656  if (sock_recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
2657  {
2659  return NULL;
2660  }
2661 
2662  if (lpszBuffer[nRecv] == '\n')
2663  {
2664  lpszBuffer[nRecv] = '\0';
2665  *dwLen = nRecv - 1;
2666  TRACE(":%d %s\n", nRecv, lpszBuffer);
2667  return lpszBuffer;
2668  }
2669  if (lpszBuffer[nRecv] != '\r')
2670  nRecv++;
2671  }
2672  else
2673  {
2675  return NULL;
2676  }
2677  }
2678 
2679  return NULL;
2680 }
Definition: winsock.h:66
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
LPSTR INTERNET_GetResponseBuffer(void)
Definition: internet.c:3937
#define FD_ZERO(set)
Definition: winsock.h:96
char * LPSTR
Definition: xmlstorage.h:182
#define FD_SET(fd, set)
Definition: winsock.h:89
int32_t INT
Definition: typedefs.h:58
#define MAX_REPLY_LEN
Definition: request.c:2568
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
static UINT set(struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, struct ctab_constant *constant, const void **indata, D3DXPARAMETER_TYPE intype, UINT *size, UINT incol, D3DXPARAMETER_CLASS inclass, UINT index, BOOL is_pointer)
Definition: shader.c:1102
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_FTP_TRANSFER_IN_PROGRESS
Definition: wininet.h:2046
#define ERROR_INTERNET_TIMEOUT
Definition: wininet.h:1991
#define NULL
Definition: types.h:112
#define RESPONSE_TIMEOUT
Definition: ftp.c:59
static int sock_recv(int fd, void *msg, size_t len, int flags)
Definition: net.c:49
Definition: _set.h:46

Referenced by FTP_ParseNextFile(), and FTP_ReceiveResponse().

◆ FTP_InitListenSocket()

static BOOL FTP_InitListenSocket ( ftp_session_t lpwfs)
static

Definition at line 2946 of file ftp.c.

2947 {
2948  BOOL bSuccess = FALSE;
2949  socklen_t namelen = sizeof(lpwfs->lstnSocketAddress);
2950 
2951  TRACE("\n");
2952 
2953  init_winsock();
2954  lpwfs->lstnSocket = socket(AF_INET, SOCK_STREAM, 0);
2955  if (lpwfs->lstnSocket == -1)
2956  {
2957  TRACE("Unable to create listening socket\n");
2958  goto lend;
2959  }
2960 
2961  /* We obtain our ip addr from the name of the command channel socket */
2962  lpwfs->lstnSocketAddress = lpwfs->socketAddress;
2963 
2964  /* and get the system to assign us a port */
2965  lpwfs->lstnSocketAddress.sin_port = htons(0);
2966 
2967  if (bind(lpwfs->lstnSocket,(struct sockaddr *) &lpwfs->lstnSocketAddress, sizeof(lpwfs->lstnSocketAddress)) == -1)
2968  {
2969  TRACE("Unable to bind socket\n");
2970  goto lend;
2971  }
2972 
2973  if (listen(lpwfs->lstnSocket, MAX_BACKLOG) == -1)
2974  {
2975  TRACE("listen failed\n");
2976  goto lend;
2977  }
2978 
2979  if (getsockname(lpwfs->lstnSocket, (struct sockaddr *) &lpwfs->lstnSocketAddress, &namelen) != -1)
2980  bSuccess = TRUE;
2981 
2982 lend:
2983  if (!bSuccess && lpwfs->lstnSocket != -1)
2984  {
2985  closesocket(lpwfs->lstnSocket);
2986  lpwfs->lstnSocket = -1;
2987  }
2988 
2989  return bSuccess;
2990 }
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define TRUE
Definition: types.h:120
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
struct sockaddr_in socketAddress
Definition: ftp.c:81
#define closesocket
Definition: ncftp.h:477
GLint namelen
Definition: glext.h:7232
static BOOLEAN bSuccess
Definition: drive.cpp:432
struct sockaddr_in lstnSocketAddress
Definition: ftp.c:82
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
int socklen_t
Definition: tcp.c:35
int lstnSocket
Definition: ftp.c:78
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
#define MAX_BACKLOG
Definition: ftp.c:109
#define AF_INET
Definition: tcpip.h:117
#define SOCK_STREAM
Definition: tcpip.h:118
#define htons(x)
Definition: module.h:213
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
void init_winsock(void) DECLSPEC_HIDDEN

Referenced by FTP_FtpFindFirstFileW(), FTP_SendRetrieve(), and FTP_SendStore().

◆ FTP_ParseDirectory()

static BOOL FTP_ParseDirectory ( ftp_session_t lpwfs,
INT  nSocket,
LPCWSTR  lpszSearchFile,
LPFILEPROPERTIESW lpafp,
LPDWORD  dwfp 
)
static

Definition at line 3787 of file ftp.c.

3789 {
3790  BOOL bSuccess = TRUE;
3791  INT sizeFilePropArray = 500;/*20; */
3792  INT indexFilePropArray = -1;
3793 
3794  TRACE("\n");
3795 
3796  /* Allocate initial file properties array */
3797  *lpafp = heap_alloc_zero(sizeof(FILEPROPERTIESW)*(sizeFilePropArray));
3798  if (!*lpafp)
3799  return FALSE;
3800 
3801  do {
3802  if (indexFilePropArray+1 >= sizeFilePropArray)
3803  {
3804  LPFILEPROPERTIESW tmpafp;
3805 
3806  sizeFilePropArray *= 2;
3807  tmpafp = heap_realloc_zero(*lpafp, sizeof(FILEPROPERTIESW)*sizeFilePropArray);
3808  if (NULL == tmpafp)
3809  {
3810  bSuccess = FALSE;
3811  break;
3812  }
3813 
3814  *lpafp = tmpafp;
3815  }
3816  indexFilePropArray++;
3817  } while (FTP_ParseNextFile(nSocket, lpszSearchFile, &(*lpafp)[indexFilePropArray]));
3818 
3819  if (bSuccess && indexFilePropArray)
3820  {
3821  if (indexFilePropArray < sizeFilePropArray - 1)
3822  {
3823  LPFILEPROPERTIESW tmpafp;
3824 
3825  tmpafp = heap_realloc(*lpafp, sizeof(FILEPROPERTIESW)*indexFilePropArray);
3826  if (NULL != tmpafp)
3827  *lpafp = tmpafp;
3828  }
3829  *dwfp = indexFilePropArray;
3830  }
3831  else
3832  {
3833  heap_free(*lpafp);
3835  bSuccess = FALSE;
3836  }
3837 
3838  return bSuccess;
3839 }
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ERROR_NO_MORE_FILES
Definition: winerror.h:121
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL FTP_ParseNextFile(INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERTIESW fileprop)
Definition: ftp.c:3626
#define NULL
Definition: types.h:112
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FTP_ReceiveFileList().

◆ FTP_ParseNextFile()

static BOOL FTP_ParseNextFile ( INT  nSocket,
LPCWSTR  lpszSearchFile,
LPFILEPROPERTIESW  fileprop 
)
static

Definition at line 3626 of file ftp.c.

3627 {
3628  static const char szSpace[] = " \t";
3629  DWORD nBufLen;
3630  char *pszLine;
3631  char *pszToken;
3632  char *pszTmp;
3633  BOOL found = FALSE;
3634  int i;
3635 
3636  lpfp->lpszName = NULL;
3637  do {
3638  if(!(pszLine = FTP_GetNextLine(nSocket, &nBufLen)))
3639  return FALSE;
3640 
3641  pszToken = strtok(pszLine, szSpace);
3642  /* ls format
3643  * <Permissions> <NoLinks> <owner> <group> <size> <date> <time or year> <filename>
3644  *
3645  * For instance:
3646  * drwx--s--- 2 pcarrier ens 512 Sep 28 1995 pcarrier
3647  */
3648  if(!isdigit(pszToken[0]) && 10 == strlen(pszToken)) {
3649  if(!FTP_ParsePermission(pszToken, lpfp))
3650  lpfp->bIsDirectory = FALSE;
3651  for(i=0; i<=3; i++) {
3652  if(!(pszToken = strtok(NULL, szSpace)))
3653  break;
3654  }
3655  if(!pszToken) continue;
3656  if(lpfp->bIsDirectory) {
3657  TRACE("Is directory\n");
3658  lpfp->nSize = 0;
3659  }
3660  else {
3661  TRACE("Size: %s\n", pszToken);
3662  lpfp->nSize = atol(pszToken);
3663  }
3664 
3665  lpfp->tmLastModified.wSecond = 0;
3666  lpfp->tmLastModified.wMinute = 0;
3667  lpfp->tmLastModified.wHour = 0;
3668  lpfp->tmLastModified.wDay = 0;
3669  lpfp->tmLastModified.wMonth = 0;
3670  lpfp->tmLastModified.wYear = 0;
3671 
3672  /* Determine month */
3673  pszToken = strtok(NULL, szSpace);
3674  if(!pszToken) continue;
3675  if(strlen(pszToken) >= 3) {
3676  pszToken[3] = 0;
3677  if((pszTmp = StrStrIA(szMonths, pszToken)))
3678  lpfp->tmLastModified.wMonth = ((pszTmp - szMonths) / 3)+1;
3679  }
3680  /* Determine day */
3681  pszToken = strtok(NULL, szSpace);
3682  if(!pszToken) continue;
3683  lpfp->tmLastModified.wDay = atoi(pszToken);
3684  /* Determine time or year */
3685  pszToken = strtok(NULL, szSpace);
3686  if(!pszToken) continue;
3687  if((pszTmp = strchr(pszToken, ':'))) {
3688  SYSTEMTIME curr_time;
3689  *pszTmp = 0;
3690  pszTmp++;
3691  lpfp->tmLastModified.wMinute = atoi(pszTmp);
3692  lpfp->tmLastModified.wHour = atoi(pszToken);
3693  GetLocalTime( &curr_time );
3694  lpfp->tmLastModified.wYear = curr_time.wYear;
3695  }
3696  else {
3697  lpfp->tmLastModified.wYear = atoi(pszToken);
3698  lpfp->tmLastModified.wHour = 12;
3699  }
3700  TRACE("Mod time: %02d:%02d:%02d %04d/%02d/%02d\n",
3701  lpfp->tmLastModified.wHour, lpfp->tmLastModified.wMinute, lpfp->tmLastModified.wSecond,
3702  lpfp->tmLastModified.wYear, lpfp->tmLastModified.wMonth, lpfp->tmLastModified.wDay);
3703 
3704  pszToken = strtok(NULL, szSpace);
3705  if(!pszToken) continue;
3706  lpfp->lpszName = heap_strdupAtoW(pszToken);
3707  TRACE("File: %s\n", debugstr_w(lpfp->lpszName));
3708  }
3709  /* NT way of parsing ... :
3710 
3711  07-13-03 08:55PM <DIR> sakpatch
3712  05-09-03 06:02PM 12656686 2003-04-21bgm_cmd_e.rgz
3713  */
3714  else if(isdigit(pszToken[0]) && 8 == strlen(pszToken)) {
3715  int mon, mday, year, hour, min;
3716  lpfp->permissions = 0xFFFF; /* No idea, put full permission :-) */
3717 
3718  sscanf(pszToken, "%d-%d-%d", &mon, &mday, &year);
3719  lpfp->tmLastModified.wDay = mday;
3720  lpfp->tmLastModified.wMonth = mon;
3721  lpfp->tmLastModified.wYear = year;
3722 
3723  /* Hacky and bad Y2K protection :-) */
3724  if (lpfp->tmLastModified.wYear < 70) lpfp->tmLastModified.wYear += 2000;
3725 
3726  pszToken = strtok(NULL, szSpace);
3727  if(!pszToken) continue;
3728  sscanf(pszToken, "%d:%d", &hour, &min);
3729  lpfp->tmLastModified.wHour = hour;
3730  lpfp->tmLastModified.wMinute = min;
3731  if((pszToken[5] == 'P') && (pszToken[6] == 'M')) {
3732  lpfp->tmLastModified.wHour += 12;
3733  }
3734  lpfp->tmLastModified.wSecond = 0;
3735 
3736  TRACE("Mod time: %02d:%02d:%02d %04d/%02d/%02d\n",
3737  lpfp->tmLastModified.wHour, lpfp->tmLastModified.wMinute, lpfp->tmLastModified.wSecond,
3738  lpfp->tmLastModified.wYear, lpfp->tmLastModified.wMonth, lpfp->tmLastModified.wDay);
3739 
3740  pszToken = strtok(NULL, szSpace);
3741  if(!pszToken) continue;
3742  if(!stricmp(pszToken, "<DIR>")) {
3743  lpfp->bIsDirectory = TRUE;
3744  lpfp->nSize = 0;
3745  TRACE("Is directory\n");
3746  }
3747  else {
3748  lpfp->bIsDirectory = FALSE;
3749  lpfp->nSize = atol(pszToken);
3750  TRACE("Size: %d\n", lpfp->nSize);
3751  }
3752 
3753  pszToken = strtok(NULL, szSpace);
3754  if(!pszToken) continue;
3755  lpfp->lpszName = heap_strdupAtoW(pszToken);
3756  TRACE("Name: %s\n", debugstr_w(lpfp->lpszName));
3757  }
3758  /* EPLF format - http://cr.yp.to/ftp/list/eplf.html */
3759  else if(pszToken[0] == '+') {
3760  FIXME("EPLF Format not implemented\n");
3761  }
3762 
3763  if(lpfp->lpszName) {
3764  if((lpszSearchFile == NULL) ||
3765  (PathMatchSpecW(lpfp->lpszName, lpszSearchFile))) {
3766  found = TRUE;
3767  TRACE("Matched: %s\n", debugstr_w(lpfp->lpszName));
3768  }
3769  else {
3770  heap_free(lpfp->lpszName);
3771  lpfp->lpszName = NULL;
3772  }
3773  }
3774  } while(!found);
3775  return TRUE;
3776 }
static LPSTR FTP_GetNextLine(INT nSocket, LPDWORD dwLen)
Definition: ftp.c:2640
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
static const WCHAR szSpace[]
Definition: msipriv.h:1110
WORD wYear
Definition: winbase.h:899
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
WORD wMinute
Definition: winbase.h:904
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define isdigit(c)
Definition: acclib.h:68
static WCHAR * heap_strdupAtoW(const char *str)
Definition: appwiz.h:80
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
static const CHAR szMonths[]
Definition: ftp.c:165
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
LPSTR WINAPI StrStrIA(LPCSTR lpszStr, LPCSTR lpszSearch)
Definition: string.c:355
static BOOL FTP_ParsePermission(LPCSTR lpszPermission, LPFILEPROPERTIESW lpfp)
Definition: ftp.c:3852
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
char * strchr(const char *String, int ch)
Definition: utclib.c:501
BOOL WINAPI PathMatchSpecW(LPCWSTR lpszPath, LPCWSTR lpszMask)
Definition: path.c:1963
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FTP_ParseDirectory().

◆ FTP_ParsePermission()

static BOOL FTP_ParsePermission ( LPCSTR  lpszPermission,
LPFILEPROPERTIESW  lpfp 
)
static

Definition at line 3852 of file ftp.c.

3853 {
3854  BOOL bSuccess = TRUE;
3855  unsigned short nPermission = 0;
3856  INT nPos = 1;
3857  INT nLast = 9;
3858 
3859  TRACE("\n");
3860  if ((*lpszPermission != 'd') && (*lpszPermission != '-') && (*lpszPermission != 'l'))
3861  {
3862  bSuccess = FALSE;
3863  return bSuccess;
3864  }
3865 
3866  lpfp->bIsDirectory = (*lpszPermission == 'd');
3867  do
3868  {
3869  switch (nPos)
3870  {
3871  case 1:
3872  nPermission |= (*(lpszPermission+1) == 'r' ? 1 : 0) << 8;
3873  break;
3874  case 2:
3875  nPermission |= (*(lpszPermission+2) == 'w' ? 1 : 0) << 7;
3876  break;
3877  case 3:
3878  nPermission |= (*(lpszPermission+3) == 'x' ? 1 : 0) << 6;
3879  break;
3880  case 4:
3881  nPermission |= (*(lpszPermission+4) == 'r' ? 1 : 0) << 5;
3882  break;
3883  case 5:
3884  nPermission |= (*(lpszPermission+5) == 'w' ? 1 : 0) << 4;
3885  break;
3886  case 6:
3887  nPermission |= (*(lpszPermission+6) == 'x' ? 1 : 0) << 3;
3888  break;
3889  case 7:
3890  nPermission |= (*(lpszPermission+7) == 'r' ? 1 : 0) << 2;
3891  break;
3892  case 8:
3893  nPermission |= (*(lpszPermission+8) == 'w' ? 1 : 0) << 1;
3894  break;
3895  case 9:
3896  nPermission |= (*(lpszPermission+9) == 'x' ? 1 : 0);
3897  break;
3898  }
3899  nPos++;
3900  }while (nPos <= nLast);
3901 
3902  lpfp->permissions = nPermission;
3903  return bSuccess;
3904 }
#define TRUE
Definition: types.h:120
unsigned short permissions
Definition: ftp.c:95
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
BOOL bIsDirectory
Definition: ftp.c:91

Referenced by FTP_ParseNextFile().

◆ FTP_ReceiveFileList()

static HINTERNET FTP_ReceiveFileList ( ftp_session_t lpwfs,
INT  nSocket,
LPCWSTR  lpszSearchFile,
LPWIN32_FIND_DATAW  lpFindFileData,
DWORD_PTR  dwContext 
)
static

Definition at line 3545 of file ftp.c.

3547 {
3548  DWORD dwSize = 0;
3549  LPFILEPROPERTIESW lpafp = NULL;
3550  LPWININETFTPFINDNEXTW lpwfn = NULL;
3551 
3552  TRACE("(%p,%d,%s,%p,%08lx)\n", lpwfs, nSocket, debugstr_w(lpszSearchFile), lpFindFileData, dwContext);
3553 
3554  if (FTP_ParseDirectory(lpwfs, nSocket, lpszSearchFile, &lpafp, &dwSize))
3555  {
3556  if(lpFindFileData)
3557  FTP_ConvertFileProp(lpafp, lpFindFileData);
3558 
3559  lpwfn = alloc_object(&lpwfs->hdr, &FTPFINDNEXTVtbl, sizeof(WININETFTPFINDNEXTW));
3560  if (lpwfn)
3561  {
3562  lpwfn->hdr.htype = WH_HFTPFINDNEXT;
3563  lpwfn->hdr.dwContext = dwContext;
3564  lpwfn->index = 1; /* Next index is 1 since we return index 0 */
3565  lpwfn->size = dwSize;
3566  lpwfn->lpafp = lpafp;
3567 
3568  WININET_AddRef( &lpwfs->hdr );
3569  lpwfn->lpFtpSession = lpwfs;
3570  list_add_head( &lpwfs->hdr.children, &lpwfn->hdr.entry );
3571  }
3572  }
3573 
3574  TRACE("Matched %d files\n", dwSize);
3575  return lpwfn ? lpwfn->hdr.hInternet : NULL;
3576 }
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
struct list children
Definition: internet.h:286
LPFILEPROPERTIESW lpafp
Definition: ftp.c:104
DWORD_PTR dwContext
Definition: internet.h:278
static BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData)
Definition: ftp.c:3589
#define debugstr_w
Definition: kernel32.h:32
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:169
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
struct list entry
Definition: internet.h:285
unsigned long DWORD
Definition: ntddk_ex.h:95
void * alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t size)
Definition: internet.c:103
static BOOL FTP_ParseDirectory(ftp_session_t *, INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERTIESW *lpafp, LPDWORD dwfp)
Definition: ftp.c:3787
HINTERNET hInternet
Definition: internet.h:275
static const object_vtbl_t FTPFINDNEXTVtbl
Definition: ftp.c:3524
object_header_t hdr
Definition: ftp.c:100
#define NULL
Definition: types.h:112
WH_TYPE htype
Definition: internet.h:273
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
ftp_session_t * lpFtpSession
Definition: ftp.c:101

Referenced by FTP_FtpFindFirstFileW().

◆ FTP_ReceiveRequestData()

static void FTP_ReceiveRequestData ( ftp_file_t file,
BOOL  first_notif 
)
static

Definition at line 1226 of file ftp.c.

1227 {
1229  BYTE buffer[4096];
1230  int available;
1231 
1232  TRACE("%p\n", file);
1233 
1234  available = sock_recv(file->nDataSocket, buffer, sizeof(buffer), MSG_PEEK);
1235 
1236  if(available != -1) {
1237  iar.dwResult = (DWORD_PTR)file->hdr.hInternet;
1238  iar.dwError = first_notif ? 0 : available;
1239  }else {
1240  iar.dwResult = 0;
1242  }
1243 
1244  INTERNET_SendCallback(&file->hdr, file->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar,
1245  sizeof(INTERNET_ASYNC_RESULT));
1246 }
GLuint buffer
Definition: glext.h:5915
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3858
static DWORD_PTR
Definition: ftp.c:44
static WCHAR available[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2336
#define TRACE(s)
Definition: solgame.cpp:4
DWORD_PTR dwResult
Definition: wininet.h:155
unsigned char BYTE
Definition: xxhash.c:193
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
static int sock_recv(int fd, void *msg, size_t len, int flags)
Definition: net.c:49
Definition: fci.c:126
#define MSG_PEEK
Definition: winsock.h:222

Referenced by FTP_FtpOpenFileW(), and FTPFILE_AsyncQueryDataAvailableProc().

◆ FTP_ReceiveResponse()

INT FTP_ReceiveResponse ( ftp_session_t lpwfs,
DWORD_PTR  dwContext 
)
static

Definition at line 2766 of file ftp.c.

2767 {
2768  LPSTR lpszResponse = INTERNET_GetResponseBuffer();
2769  DWORD nRecv;
2770  INT rc = 0;
2771  char firstprefix[5];
2772  BOOL multiline = FALSE;
2773 
2774  TRACE("socket(%d)\n", lpwfs->sndSocket);
2775 
2777 
2778  while(1)
2779  {
2780  if (!FTP_GetNextLine(lpwfs->sndSocket, &nRecv))
2781  goto lerror;
2782 
2783  if (nRecv >= 3)
2784  {
2785  if(!multiline)
2786  {
2787  if(lpszResponse[3] != '-')
2788  break;
2789  else
2790  { /* Start of multiline response. Loop until we get "nnn " */
2791  multiline = TRUE;
2792  memcpy(firstprefix, lpszResponse, 3);
2793  firstprefix[3] = ' ';
2794  firstprefix[4] = '\0';
2795  }
2796  }
2797  else
2798  {
2799  if(!memcmp(firstprefix, lpszResponse, 4))
2800  break;
2801  }
2802  }
2803  }
2804 
2805  if (nRecv >= 3)
2806  {
2807  rc = atoi(lpszResponse);
2808 
2810  &nRecv, sizeof(DWORD));
2811  }
2812 
2813 lerror:
2814  TRACE("return %d\n", rc);
2815  return rc;
2816 }
static LPSTR FTP_GetNextLine(INT nSocket, LPDWORD dwLen)
Definition: ftp.c:2640
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define TRUE
Definition: types.h:120
LPSTR INTERNET_GetResponseBuffer(void)
Definition: internet.c:3937
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:58
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define INTERNET_STATUS_RECEIVING_RESPONSE
Definition: wininet.h:889
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
int sndSocket
Definition: ftp.c:77
#define NULL
Definition: types.h:112
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define INTERNET_STATUS_RESPONSE_RECEIVED
Definition: wininet.h:890

Referenced by FTP_ConnectToHost(), FTP_DoPassive(), FTP_FtpCreateDirectoryW(), FTP_FtpDeleteFileW(), FTP_FtpFindFirstFileW(), FTP_FtpGetCurrentDirectoryW(), FTP_FtpGetFileW(), FTP_FtpPutFileW(), FTP_FtpRemoveDirectoryW(), FTP_FtpRenameFileW(), FTP_FtpSetCurrentDirectoryW(), FTP_SendAccount(), FTP_SendPassword(), FTP_SendPort(), FTP_SendRetrieve(), FTP_SendStore(), FTP_SendType(), FtpCommandW(), and FTPFILE_Destroy().

◆ FTP_RetrieveFileData()

static BOOL FTP_RetrieveFileData ( ftp_session_t lpwfs,
INT  nDataSocket,
HANDLE  hFile 
)
static

Definition at line 3389 of file ftp.c.

3390 {
3391  DWORD nBytesWritten;
3392  INT nRC = 0;
3393  CHAR *lpszBuffer;
3394 
3395  TRACE("\n");
3396 
3397  lpszBuffer = heap_alloc_zero(sizeof(CHAR)*DATA_PACKET_SIZE);
3398  if (NULL == lpszBuffer)
3399  {
3401  return FALSE;
3402  }
3403 
3404  while (nRC != -1)
3405  {
3406  nRC = sock_recv(nDataSocket, lpszBuffer, DATA_PACKET_SIZE, 0);
3407  if (nRC != -1)
3408  {
3409  /* other side closed socket. */
3410  if (nRC == 0)
3411  goto recv_end;
3412  WriteFile(hFile, lpszBuffer, nRC, &nBytesWritten, NULL);
3413  }
3414  }
3415 
3416  TRACE("Data transfer complete\n");
3417 
3418 recv_end:
3419  heap_free(lpszBuffer);
3420  return (nRC != -1);
3421 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
char CHAR
Definition: xmlstorage.h:175
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ HANDLE hFile
Definition: mswsock.h:90
#define DATA_PACKET_SIZE
Definition: ftp.c:107
#define NULL
Definition: types.h:112
static int sock_recv(int fd, void *msg, size_t len, int flags)
Definition: net.c:49
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FTP_FtpGetFileW().

◆ FTP_SendAccount()

static BOOL FTP_SendAccount ( ftp_session_t lpwfs)
static

Definition at line 2869 of file ftp.c.

2870 {
2871  INT nResCode;
2872  BOOL bSuccess = FALSE;
2873 
2874  TRACE("\n");
2875  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_ACCT, L"noaccount", 0, 0, 0))
2876  goto lend;
2877 
2878  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2879  if (nResCode)
2880  bSuccess = TRUE;
2881  else
2882  FTP_SetResponseError(nResCode);
2883 
2884 lend:
2885  return bSuccess;
2886 }
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
static const WCHAR L[]
Definition: oid.c:1250
int sndSocket
Definition: ftp.c:77
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746

Referenced by FTP_ConnectToHost(), and FTP_SendPassword().

◆ FTP_SendCommand()

static BOOL FTP_SendCommand ( INT  nSocket,
FTP_COMMAND  ftpCmd,
LPCWSTR  lpszParam,
INTERNET_STATUS_CALLBACK  lpfnStatusCB,
object_header_t hdr,
DWORD_PTR  dwContext 
)
static

Definition at line 2746 of file ftp.c.

2748 {
2749  BOOL ret;
2750  LPSTR lpszParamA = heap_strdupWtoA(lpszParam);
2751  ret = FTP_SendCommandA(nSocket, ftpCmd, lpszParamA, lpfnStatusCB, hdr, dwContext);
2752  heap_free(lpszParamA);
2753  return ret;
2754 }
char hdr[14]
Definition: iptest.cpp:33
static BOOL FTP_SendCommandA(INT nSocket, FTP_COMMAND ftpCmd, LPCSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2692
char * LPSTR
Definition: xmlstorage.h:182
unsigned int BOOL
Definition: ntddk_ex.h:94
static char * heap_strdupWtoA(const WCHAR *str)
int ret
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FTP_ConnectToHost(), FTP_DoPassive(), FTP_FtpCreateDirectoryW(), FTP_FtpDeleteFileW(), FTP_FtpFindFirstFileW(), FTP_FtpGetCurrentDirectoryW(), FTP_FtpRemoveDirectoryW(), FTP_FtpRenameFileW(), FTP_FtpSetCurrentDirectoryW(), FTP_SendAccount(), FTP_SendPassword(), FTP_SendPort(), FTP_SendRetrieve(), FTP_SendStore(), and FTP_SendType().

◆ FTP_SendCommandA()

static BOOL FTP_SendCommandA ( INT  nSocket,
FTP_COMMAND  ftpCmd,
LPCSTR  lpszParam,
INTERNET_STATUS_CALLBACK  lpfnStatusCB,
object_header_t hdr,
DWORD_PTR  dwContext 
)
static

Definition at line 2692 of file ftp.c.

2694 {
2695  DWORD len;
2696  CHAR *buf;
2697  DWORD nBytesSent = 0;
2698  int nRC = 0;
2699  DWORD dwParamLen;
2700 
2701  TRACE("%d: (%s) %d\n", ftpCmd, debugstr_a(lpszParam), nSocket);
2702 
2703  if (lpfnStatusCB)
2704  {
2705  lpfnStatusCB(hdr->hInternet, dwContext, INTERNET_STATUS_SENDING_REQUEST, NULL, 0);
2706  }
2707 
2708  dwParamLen = lpszParam?strlen(lpszParam)+1:0;
2709  len = dwParamLen + strlen(szFtpCommands[ftpCmd]) + strlen(szCRLF);
2710  if (NULL == (buf = heap_alloc(len+1)))
2711  {
2713  return FALSE;
2714  }
2715  sprintf(buf, "%s%s%s%s", szFtpCommands[ftpCmd], dwParamLen ? " " : "",
2716  dwParamLen ? lpszParam : "", szCRLF);
2717 
2718  TRACE("Sending (%s) len(%d)\n", debugstr_a(buf), len);
2719  while((nBytesSent < len) && (nRC != -1))
2720  {
2721  nRC = sock_send(nSocket, buf+nBytesSent, len - nBytesSent, 0);
2722  nBytesSent += nRC;
2723  }
2724  heap_free(buf);
2725 
2726  if (lpfnStatusCB)
2727  {
2728  lpfnStatusCB(hdr->hInternet, dwContext, INTERNET_STATUS_REQUEST_SENT,
2729  &nBytesSent, sizeof(DWORD));
2730  }
2731 
2732  TRACE("Sent %d bytes\n", nBytesSent);
2733  return (nRC != -1);
2734 }
char hdr[14]
Definition: iptest.cpp:33
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define INTERNET_STATUS_REQUEST_SENT
Definition: wininet.h:888
char CHAR
Definition: xmlstorage.h:175
static const CHAR *const szFtpCommands[]
Definition: ftp.c:142
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define sprintf(buf, format,...)
Definition: sprintf.c:55
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define szCRLF
Definition: ftp.c:108
#define INTERNET_STATUS_SENDING_REQUEST
Definition: wininet.h:887
GLenum GLsizei len
Definition: glext.h:6722
static int sock_send(int fd, const void *msg, size_t len, int flags)
Definition: net.c:38
#define NULL
Definition: types.h:112
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FTP_SendCommand().

◆ FTP_SendData()

static BOOL FTP_SendData ( ftp_session_t lpwfs,
INT  nDataSocket,
HANDLE  hFile 
)
static

Definition at line 3263 of file ftp.c.

3264 {
3266  DWORD nBytesRead = 0;
3267  DWORD nBytesSent = 0;
3268  DWORD nTotalSent = 0;
3269  DWORD nBytesToSend, nLen;
3270  int nRC = 1;
3271  time_t s_long_time, e_long_time;
3272  LONG nSeconds;
3273  CHAR *lpszBuffer;
3274 
3275  TRACE("\n");
3276  lpszBuffer = heap_alloc_zero(sizeof(CHAR)*DATA_PACKET_SIZE);
3277 
3278  /* Get the size of the file. */
3280  time(&s_long_time);
3281 
3282  do
3283  {
3284  nBytesToSend = nBytesRead - nBytesSent;
3285 
3286  if (nBytesToSend <= 0)
3287  {
3288  /* Read data from file. */
3289  nBytesSent = 0;
3290  if (!ReadFile(hFile, lpszBuffer, DATA_PACKET_SIZE, &nBytesRead, 0))
3291  ERR("Failed reading from file\n");
3292 
3293  if (nBytesRead > 0)
3294  nBytesToSend = nBytesRead;
3295  else
3296  break;
3297  }
3298 
3299  nLen = DATA_PACKET_SIZE < nBytesToSend ?
3300  DATA_PACKET_SIZE : nBytesToSend;
3301  nRC = sock_send(nDataSocket, lpszBuffer, nLen, 0);
3302 
3303  if (nRC != -1)
3304  {
3305  nBytesSent += nRC;
3306  nTotalSent += nRC;
3307  }
3308 
3309  /* Do some computation to display the status. */
3310  time(&e_long_time);
3311  nSeconds = e_long_time - s_long_time;
3312  if( nSeconds / 60 > 0 )
3313  {
3314  TRACE( "%d bytes of %d bytes (%d%%) in %d min %d sec estimated remaining time %d sec\n",
3315  nTotalSent, fi.nFileSizeLow, nTotalSent*100/fi.nFileSizeLow, nSeconds / 60,
3316  nSeconds % 60, (fi.nFileSizeLow - nTotalSent) * nSeconds / nTotalSent );
3317  }
3318  else
3319  {
3320  TRACE( "%d bytes of %d bytes (%d%%) in %d sec estimated remaining time %d sec\n",
3321  nTotalSent, fi.nFileSizeLow, nTotalSent*100/fi.nFileSizeLow, nSeconds,
3322  (fi.nFileSizeLow - nTotalSent) * nSeconds / nTotalSent);
3323  }
3324  } while (nRC != -1);
3325 
3326  TRACE("file transfer complete!\n");
3327 
3328  heap_free(lpszBuffer);
3329  return nTotalSent;
3330 }
char CHAR
Definition: xmlstorage.h:175
__u16 time
Definition: mkdosfs.c:366
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
Definition: fileinfo.c:458
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ HANDLE hFile
Definition: mswsock.h:90
#define DATA_PACKET_SIZE
Definition: ftp.c:107
#define ERR(fmt,...)
Definition: debug.h:110
static int sock_send(int fd, const void *msg, size_t len, int flags)
Definition: net.c:38
__kernel_time_t time_t
Definition: linux.h:252
#define ReadFile(a, b, c, d, e)
Definition: compat.h:601
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FTP_FtpPutFileW().

◆ FTP_SendPassword()

static BOOL FTP_SendPassword ( ftp_session_t lpwfs)
static

Definition at line 2829 of file ftp.c.

2830 {
2831  INT nResCode;
2832  BOOL bSuccess = FALSE;
2833 
2834  TRACE("\n");
2835  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_PASS, lpwfs->lpszPassword, 0, 0, 0))
2836  goto lend;
2837 
2838  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2839  if (nResCode)
2840  {
2841  TRACE("Received reply code %d\n", nResCode);
2842  /* Login successful... */
2843  if (nResCode == 230)
2844  bSuccess = TRUE;
2845  /* Command not implemented, superfluous at the server site... */
2846  /* Need account for login... */
2847  else if (nResCode == 332)
2848  bSuccess = FTP_SendAccount(lpwfs);
2849  else
2850  FTP_SetResponseError(nResCode);
2851  }
2852 
2853 lend:
2854  TRACE("Returning %d\n", bSuccess);
2855  return bSuccess;
2856 }
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
LPWSTR lpszPassword
Definition: ftp.c:85
static BOOL FTP_SendAccount(ftp_session_t *)
Definition: ftp.c:2869
int sndSocket
Definition: ftp.c:77
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746

Referenced by FTP_ConnectToHost().

◆ FTP_SendPort()

static BOOL FTP_SendPort ( ftp_session_t lpwfs)
static

Definition at line 3088 of file ftp.c.

3089 {
3090  INT nResCode;
3091  WCHAR szIPAddress[64];
3092  BOOL bSuccess = FALSE;
3093  TRACE("\n");
3094 
3095  swprintf(szIPAddress, ARRAY_SIZE(szIPAddress), L"%d,%d,%d,%d,%d,%d",
3096  lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0x000000FF,
3097  (lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0x0000FF00)>>8,
3098  (lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0x00FF0000)>>16,
3099  (lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0xFF000000)>>24,
3100  lpwfs->lstnSocketAddress.sin_port & 0xFF,
3101  (lpwfs->lstnSocketAddress.sin_port & 0xFF00)>>8);
3102 
3103  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_PORT, szIPAddress, 0, 0, 0))
3104  goto lend;
3105 
3106  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
3107  if (nResCode)
3108  {
3109  if (nResCode == 200)
3110  bSuccess = TRUE;
3111  else
3112  FTP_SetResponseError(nResCode);
3113  }
3114 
3115 lend:
3116  return bSuccess;
3117 }
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define TRUE
Definition: types.h:120
#define swprintf
Definition: precomp.h:40
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
DWORD_PTR dwContext
Definition: internet.h:278
struct sockaddr_in lstnSocketAddress
Definition: ftp.c:82
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
int sndSocket
Definition: ftp.c:77
#define ARRAY_SIZE(a)
Definition: main.h:24
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746

Referenced by FTP_SendPortOrPasv().

◆ FTP_SendPortOrPasv()

static BOOL FTP_SendPortOrPasv ( ftp_session_t lpwfs)
static

Definition at line 3203 of file ftp.c.

3204 {
3205  if (lpwfs->hdr.dwFlags & INTERNET_FLAG_PASSIVE)
3206  {
3207  if (!FTP_DoPassive(lpwfs))
3208  return FALSE;
3209  }
3210  else
3211  {
3212  if (!FTP_SendPort(lpwfs))
3213  return FALSE;
3214  }
3215  return TRUE;
3216 }
static BOOL FTP_SendPort(ftp_session_t *)
Definition: ftp.c:3088
static BOOL FTP_DoPassive(ftp_session_t *)
Definition: ftp.c:3131
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
object_header_t hdr
Definition: ftp.c:75
#define INTERNET_FLAG_PASSIVE
Definition: wininet.h:65

Referenced by FTP_FtpFindFirstFileW(), FTP_SendRetrieve(), and FTP_SendStore().

◆ FTP_SendRetrieve()

static BOOL FTP_SendRetrieve ( ftp_session_t lpwfs,
LPCWSTR  lpszRemoteFile,
DWORD  dwType 
)
static

Definition at line 3343 of file ftp.c.

3344 {
3345  INT nResCode;
3346  BOOL ret;
3347 
3348  TRACE("\n");
3349  if (!(ret = FTP_InitListenSocket(lpwfs)))
3350  goto lend;
3351 
3352  if (!(ret = FTP_SendType(lpwfs, dwType)))
3353  goto lend;
3354 
3355  if (!(ret = FTP_SendPortOrPasv(lpwfs)))
3356  goto lend;
3357 
3358  if (!(ret = FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_RETR, lpszRemoteFile, 0, 0, 0)))
3359  goto lend;
3360 
3361  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
3362  if ((nResCode != 125) && (nResCode != 150)) {
3363  /* That means that we got an error getting the file. */
3364  FTP_SetResponseError(nResCode);
3365  ret = FALSE;
3366  }
3367 
3368 lend:
3369  if (!ret && lpwfs->lstnSocket != -1)
3370  {
3371  closesocket(lpwfs->lstnSocket);
3372  lpwfs->lstnSocket = -1;
3373  }
3374 
3375  return ret;
3376 }
static BOOL FTP_SendType(ftp_session_t *, DWORD dwType)
Definition: ftp.c:3006
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
static BOOL FTP_InitListenSocket(ftp_session_t *)
Definition: ftp.c:2946
#define closesocket
Definition: ncftp.h:477
int32_t INT
Definition: typedefs.h:58
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL FTP_SendPortOrPasv(ftp_session_t *)
Definition: ftp.c:3203
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
int ret
int sndSocket
Definition: ftp.c:77
int lstnSocket
Definition: ftp.c:78
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746

Referenced by FTP_FtpGetFileW(), and FTP_FtpOpenFileW().

◆ FTP_SendStore()

static BOOL FTP_SendStore ( ftp_session_t lpwfs,
LPCWSTR  lpszRemoteFile,
DWORD  dwType 
)
static

Definition at line 2899 of file ftp.c.

2900 {
2901  INT nResCode;
2902  BOOL bSuccess = FALSE;
2903 
2904  TRACE("\n");
2905  if (!FTP_InitListenSocket(lpwfs))
2906  goto lend;
2907 
2908  if (!FTP_SendType(lpwfs, dwType))
2909  goto lend;
2910 
2911  if (!FTP_SendPortOrPasv(lpwfs))
2912  goto lend;
2913 
2914  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_STOR, lpszRemoteFile, 0, 0, 0))
2915  goto lend;
2916  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2917  if (nResCode)
2918  {
2919  if (nResCode == 150 || nResCode == 125)
2920  bSuccess = TRUE;
2921  else
2922  FTP_SetResponseError(nResCode);
2923  }
2924 
2925 lend:
2926  if (!bSuccess && lpwfs->lstnSocket != -1)
2927  {
2928  closesocket(lpwfs->lstnSocket);
2929  lpwfs->lstnSocket = -1;
2930  }
2931 
2932  return bSuccess;
2933 }
static BOOL FTP_SendType(ftp_session_t *, DWORD dwType)
Definition: ftp.c:3006
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define TRUE
Definition: types.h:120
static BOOL FTP_InitListenSocket(ftp_session_t *)
Definition: ftp.c:2946
#define closesocket
Definition: ncftp.h:477
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL FTP_SendPortOrPasv(ftp_session_t *)
Definition: ftp.c:3203
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
int sndSocket
Definition: ftp.c:77
int lstnSocket
Definition: ftp.c:78
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746

Referenced by FTP_FtpOpenFileW(), and FTP_FtpPutFileW().

◆ FTP_SendType()

static BOOL FTP_SendType ( ftp_session_t lpwfs,
DWORD  dwType 
)
static

Definition at line 3006 of file ftp.c.

3007 {
3008  INT nResCode;
3009  WCHAR type[] = L"I";
3010  BOOL bSuccess = FALSE;
3011 
3012  TRACE("\n");
3013  if (dwType & INTERNET_FLAG_TRANSFER_ASCII)
3014  type[0] = 'A';
3015 
3016  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_TYPE, type, 0, 0, 0))
3017  goto lend;
3018 
3019  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext)/100;
3020  if (nResCode)
3021  {
3022  if (nResCode == 2)
3023  bSuccess = TRUE;
3024  else
3025  FTP_SetResponseError(nResCode);
3026  }
3027 
3028 lend:
3029  return bSuccess;
3030 }
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
static BOOLEAN bSuccess
Definition: drive.cpp:432
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define INTERNET_FLAG_TRANSFER_ASCII
Definition: wininet.h:90
static const WCHAR L[]
Definition: oid.c:1250
int sndSocket
Definition: ftp.c:77
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext)
Definition: ftp.c:2746
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by FTP_FtpFindFirstFileW(), FTP_SendRetrieve(), and FTP_SendStore().

◆ FTP_SetResponseError()

static DWORD FTP_SetResponseError ( DWORD  dwResponse)
static

Definition at line 3915 of file ftp.c.

3916 {
3917  DWORD dwCode = 0;
3918 
3919  switch(dwResponse)
3920  {
3921  case 425: /* Cannot open data connection. */
3923  break;
3924 
3925  case 426: /* Connection closed, transfer aborted. */
3927  break;
3928 
3929  case 530: /* Not logged in. Login incorrect. */
3931  break;
3932 
3933  case 421: /* Service not available - Server may be shutting down. */
3934  case 450: /* File action not taken. File may be busy. */
3935  case 451: /* Action aborted. Server error. */
3936  case 452: /* Action not taken. Insufficient storage space on server. */
3937  case 500: /* Syntax error. Command unrecognized. */
3938  case 501: /* Syntax error. Error in parameters or arguments. */
3939  case 502: /* Command not implemented. */
3940  case 503: /* Bad sequence of commands. */
3941  case 504: /* Command not implemented for that parameter. */
3942  case 532: /* Need account for storing files */
3943  case 550: /* File action not taken. File not found or no access. */
3944  case 551: /* Requested action aborted. Page type unknown */
3945  case 552: /* Action aborted. Exceeded storage allocation */
3946  case 553: /* Action not taken. File name not allowed. */
3947 
3948  default:
3950  break;
3951  }
3952 
3953  INTERNET_SetLastError(dwCode);
3954  return dwCode;
3955 }
#define ERROR_INTERNET_CONNECTION_ABORTED
Definition: wininet.h:2019
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
#define ERROR_INTERNET_EXTENDED_ERROR
Definition: wininet.h:1992
#define ERROR_INTERNET_CANNOT_CONNECT
Definition: wininet.h:2018
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_INTERNET_LOGIN_FAILURE
Definition: wininet.h:2004

Referenced by FTP_ConnectToHost(), FTP_DoPassive(), FTP_FtpCreateDirectoryW(), FTP_FtpDeleteFileW(), FTP_FtpFindFirstFileW(), FTP_FtpGetCurrentDirectoryW(), FTP_FtpGetFileW(), FTP_FtpPutFileW(), FTP_FtpRemoveDirectoryW(), FTP_FtpRenameFileW(), FTP_FtpSetCurrentDirectoryW(), FTP_SendAccount(), FTP_SendPassword(), FTP_SendPort(), FTP_SendRetrieve(), FTP_SendStore(), FTP_SendType(), and FtpCommandW().

◆ FtpCommandA()

BOOL WINAPI FtpCommandA ( HINTERNET  hConnect,
BOOL  fExpectResponse,
DWORD  dwFlags,
LPCSTR  lpszCommand,
DWORD_PTR  dwContext,
HINTERNET phFtpCommand 
)

Definition at line 2218 of file ftp.c.

2220 {
2221  BOOL r;
2222  WCHAR *cmdW;
2223 
2224  TRACE("%p %d 0x%08x %s 0x%08lx %p\n", hConnect, fExpectResponse, dwFlags,
2225  debugstr_a(lpszCommand), dwContext, phFtpCommand);
2226 
2227  if (fExpectResponse)
2228  {
2229  FIXME("data connection not supported\n");
2230  return FALSE;
2231  }
2232 
2233  if (!lpszCommand || !lpszCommand[0])
2234  {
2236  return FALSE;
2237  }
2238 
2239  if (!(cmdW = heap_strdupAtoW(lpszCommand)))
2240  {
2242  return FALSE;
2243  }
2244 
2245  r = FtpCommandW(hConnect, fExpectResponse, dwFlags, cmdW, dwContext, phFtpCommand);
2246 
2247  heap_free(cmdW);
2248  return r;
2249 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
static WCHAR * heap_strdupAtoW(const char *str)
Definition: appwiz.h:80
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
BOOL WINAPI FtpCommandW(HINTERNET hConnect, BOOL fExpectResponse, DWORD dwFlags, LPCWSTR lpszCommand, DWORD_PTR dwContext, HINTERNET *phFtpCommand)
Definition: ftp.c:2254
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ FtpCommandW()

BOOL WINAPI FtpCommandW ( HINTERNET  hConnect,
BOOL  fExpectResponse,
DWORD  dwFlags,
LPCWSTR  lpszCommand,
DWORD_PTR  dwContext,
HINTERNET phFtpCommand 
)

Definition at line 2254 of file ftp.c.

2256 {
2257  BOOL r = FALSE;
2258  ftp_session_t *lpwfs;
2259  LPSTR cmd = NULL;
2260  DWORD len, nBytesSent= 0;
2261  INT nResCode, nRC = 0;
2262 
2263  TRACE("%p %d 0x%08x %s 0x%08lx %p\n", hConnect, fExpectResponse, dwFlags,
2264  debugstr_w(lpszCommand), dwContext, phFtpCommand);
2265 
2266  if (!lpszCommand || !lpszCommand[0])
2267  {
2269  return FALSE;
2270  }
2271 
2272  if (fExpectResponse)
2273  {
2274  FIXME("data connection not supported\n");
2275  return FALSE;
2276  }
2277 
2278  lpwfs = (ftp_session_t*) get_handle_object( hConnect );
2279  if (!lpwfs)
2280  {
2282  return FALSE;
2283  }
2284 
2285  if (WH_HFTPSESSION != lpwfs->hdr.htype)
2286  {
2288  goto lend;
2289  }
2290 
2291  if (lpwfs->download_in_progress != NULL)
2292  {
2294  goto lend;
2295  }
2296 
2297  len = WideCharToMultiByte(CP_ACP, 0, lpszCommand, -1, NULL, 0, NULL, NULL) + strlen(szCRLF);
2298  if ((cmd = heap_alloc(len)))
2299  WideCharToMultiByte(CP_ACP, 0, lpszCommand, -1, cmd, len, NULL, NULL);
2300  else
2301  {
2303  goto lend;
2304  }
2305 
2306  strcat(cmd, szCRLF);
2307  len--;
2308 
2309  TRACE("Sending (%s) len(%d)\n", debugstr_a(cmd), len);
2310  while ((nBytesSent < len) && (nRC != -1))
2311  {
2312  nRC = sock_send(lpwfs->sndSocket, cmd + nBytesSent, len - nBytesSent, 0);
2313  if (nRC != -1)
2314  {
2315  nBytesSent += nRC;
2316  TRACE("Sent %d bytes\n", nRC);
2317  }
2318  }
2319 
2320  if (nBytesSent)
2321  {
2322  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2323  if (nResCode > 0 && nResCode < 400)
2324  r = TRUE;
2325  else
2326  FTP_SetResponseError(nResCode);
2327  }
2328 
2329 lend:
2330  WININET_Release( &lpwfs->hdr );
2331  heap_free( cmd );
2332  return r;
2333 }
#define ERROR_INTERNET_INCORRECT_HANDLE_TYPE
Definition: wininet.h:2007
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3837
#define WideCharToMultiByte
Definition: compat.h:111
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3915
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: ftp_var.h:139
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define CP_ACP
Definition: compat.h:109
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
ftp_file_t * download_in_progress
Definition: ftp.c:80
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:58
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
DWORD_PTR dwContext
Definition: internet.h:278
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2766
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:75
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_FTP_TRANSFER_IN_PROGRESS
Definition: wininet.h:2046
#define szCRLF
Definition: ftp.c:108
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLenum GLsizei len
Definition: glext.h:6722
int sndSocket
Definition: ftp.c:77
BOOL WININET_Release(object_header_t *info)
Definition: internet.c:211
static int sock_send(int fd, const void *msg, size_t len, int flags)
Definition: net.c:38
#define NULL
Definition: types.h:112
WH_TYPE htype
Definition: internet.h:273
object_header_t * get_handle_object(HINTERNET hinternet)
Definition: internet.c:176
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by FtpCommandA().

◆ FtpCreateDirectoryA()

BOOL WINAPI FtpCreateDirectoryA ( HINTERNET  hConnect,
LPCSTR  lpszDirectory 
)

Definition at line 566 of file ftp.c.

567 {
568  LPWSTR lpwzDirectory;
569  BOOL ret;
570