ReactOS  0.4.14-dev-49-gfb4591c
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 WCHAR szNoAccount [] = {'n','o','a','c','c','o','u','n','t','\0'}
 
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 103 of file ftp.c.

◆ FTP_CONDITION_MASK

#define FTP_CONDITION_MASK   0x0007

Definition at line 110 of file ftp.c.

◆ MAX_BACKLOG

#define MAX_BACKLOG   5

Definition at line 105 of file ftp.c.

◆ RESPONSE_TIMEOUT

#define RESPONSE_TIMEOUT   30

Definition at line 55 of file ftp.c.

◆ szCRLF

#define szCRLF   "\r\n"

Definition at line 104 of file ftp.c.

Typedef Documentation

◆ ftp_session_t

Definition at line 57 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 112 of file ftp.c.

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

Function Documentation

◆ AsyncFtpCreateDirectoryProc()

static void AsyncFtpCreateDirectoryProc ( task_header_t hdr)
static

Definition at line 575 of file ftp.c.

576 {
578  ftp_session_t *session = (ftp_session_t*)task->hdr.hdr;
579 
580  TRACE(" %p\n", session);
581 
582  FTP_FtpCreateDirectoryW(session, task->directory);
583  heap_free(task->directory);
584 }
char hdr[14]
Definition: iptest.cpp:33
static BOOL FTP_FtpCreateDirectoryW(ftp_session_t *, LPCWSTR lpszDirectory)
Definition: ftp.c:658
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:391
WCHAR * directory
Definition: ftp.c:429
task_header_t hdr
Definition: ftp.c:428
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 1790 of file ftp.c.

1791 {
1793  ftp_session_t *session = (ftp_session_t*)task->hdr.hdr;
1794 
1795  TRACE("%p\n", session);
1796 
1797  FTP_FtpDeleteFileW(session, task->file_name);
1798  heap_free(task->file_name);
1799 }
char hdr[14]
Definition: iptest.cpp:33
WCHAR * file_name
Definition: ftp.c:1787
#define TRACE(s)
Definition: solgame.cpp:4
task_header_t hdr
Definition: ftp.c:1786
object_header_t * hdr
Definition: internet.h:391
static BOOL FTP_FtpDeleteFileW(ftp_session_t *, LPCWSTR lpszFileName)
Definition: ftp.c:1873
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 733 of file ftp.c.

734 {
736  ftp_session_t *session = (ftp_session_t*)task->hdr.hdr;
737 
738  TRACE("%p\n", session);
739 
740  FTP_FtpFindFirstFileW(session, task->search_file, task->find_file_data, task->flags, task->context);
741  heap_free(task->search_file);
742 }
char hdr[14]
Definition: iptest.cpp:33
DWORD_PTR context
Definition: ftp.c:730
WIN32_FIND_DATAW * find_file_data
Definition: ftp.c:728
task_header_t hdr
Definition: ftp.c:726
WCHAR * search_file
Definition: ftp.c:727
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:391
static HINTERNET FTP_FtpFindFirstFileW(ftp_session_t *, LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD_PTR dwContext)
Definition: ftp.c:811
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 948 of file ftp.c.

949 {
951  ftp_session_t *session = (ftp_session_t*)task->hdr.hdr;
952 
953  TRACE("%p\n", session);
954 
955  FTP_FtpGetCurrentDirectoryW(session, task->directory, task->directory_len);
956 }
char hdr[14]
Definition: iptest.cpp:33
DWORD * directory_len
Definition: ftp.c:945
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:391
task_header_t hdr
Definition: ftp.c:943
WCHAR * directory
Definition: ftp.c:944
static BOOL FTP_FtpGetCurrentDirectoryW(ftp_session_t *, LPWSTR lpszCurrentDirectory, LPDWORD lpdwCurrentDirectory)
Definition: ftp.c:1043

Referenced by FtpGetCurrentDirectoryW().

◆ AsyncFtpGetFileProc()

static void AsyncFtpGetFileProc ( task_header_t hdr)
static

Definition at line 1583 of file ftp.c.

1584 {
1586  ftp_session_t *session = (ftp_session_t*)task->hdr.hdr;
1587 
1588  TRACE("%p\n", session);
1589 
1590  FTP_FtpGetFileW(session, task->remote_file, task->new_file, task->fail_if_exists,
1591  task->local_attr, task->flags, task->context);
1592  heap_free(task->remote_file);
1593  heap_free(task->new_file);
1594 }
char hdr[14]
Definition: iptest.cpp:33
WCHAR * remote_file
Definition: ftp.c:1575
DWORD_PTR context
Definition: ftp.c:1580
WCHAR * new_file
Definition: ftp.c:1576
task_header_t hdr
Definition: ftp.c:1574
#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:1684
object_header_t * hdr
Definition: internet.h:391
DWORD local_attr
Definition: ftp.c:1578
DWORD flags
Definition: ftp.c:1579
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
BOOL fail_if_exists
Definition: ftp.c:1577

Referenced by FtpGetFileW().

◆ AsyncFtpOpenFileProc()

static void AsyncFtpOpenFileProc ( task_header_t hdr)
static

Definition at line 1461 of file ftp.c.

1462 {
1464  ftp_session_t *session = (ftp_session_t*)task->hdr.hdr;
1465 
1466  TRACE("%p\n", session);
1467 
1468  FTP_FtpOpenFileW(session, task->file_name, task->access, task->flags, task->context);
1469  heap_free(task->file_name);
1470 }
DWORD flags
Definition: ftp.c:1457
char hdr[14]
Definition: iptest.cpp:33
WCHAR * file_name
Definition: ftp.c:1455
DWORD_PTR context
Definition: ftp.c:1458
static HINTERNET FTP_FtpOpenFileW(ftp_session_t *lpwfs, LPCWSTR lpszFileName, DWORD fdwAccess, DWORD dwFlags, DWORD_PTR dwContext)
Definition: ftp.c:1314
task_header_t hdr
Definition: ftp.c:1454
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:391
DWORD access
Definition: ftp.c:1456
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 245 of file ftp.c.

246 {
248  ftp_session_t *session = (ftp_session_t*)task->hdr.hdr;
249 
250  TRACE("%p\n", session);
251 
252  FTP_FtpPutFileW(session, task->local_file, task->remote_file,
253  task->flags, task->context);
254 
255  heap_free(task->local_file);
256  heap_free(task->remote_file);
257 }
char hdr[14]
Definition: iptest.cpp:33
WCHAR * remote_file
Definition: ftp.c:240
static BOOL FTP_FtpPutFileW(ftp_session_t *, LPCWSTR lpszLocalFile, LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD_PTR dwContext)
Definition: ftp.c:341
task_header_t hdr
Definition: ftp.c:238
DWORD_PTR context
Definition: ftp.c:242
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:391
DWORD flags
Definition: ftp.c:241
WCHAR * local_file
Definition: ftp.c:239
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 1932 of file ftp.c.

1933 {
1935  ftp_session_t *session = (ftp_session_t*)task->hdr.hdr;
1936 
1937  TRACE("%p\n", session);
1938 
1939  FTP_FtpRemoveDirectoryW(session, task->directory);
1940  heap_free(task->directory);
1941 }
char hdr[14]
Definition: iptest.cpp:33
static BOOL FTP_FtpRemoveDirectoryW(ftp_session_t *, LPCWSTR lpszDirectory)
Definition: ftp.c:2015
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:391
WCHAR * directory
Definition: ftp.c:429
task_header_t hdr
Definition: ftp.c:428
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 2084 of file ftp.c.

2085 {
2087  ftp_session_t *session = (ftp_session_t*)task->hdr.hdr;
2088 
2089  TRACE("%p\n", session);
2090 
2091  FTP_FtpRenameFileW(session, task->src_file, task->dst_file);
2092  heap_free(task->src_file);
2093  heap_free(task->dst_file);
2094 }
char hdr[14]
Definition: iptest.cpp:33
WCHAR * dst_file
Definition: ftp.c:2081
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:391
WCHAR * src_file
Definition: ftp.c:2080
task_header_t hdr
Definition: ftp.c:2079
static BOOL FTP_FtpRenameFileW(ftp_session_t *, LPCWSTR lpszSrc, LPCWSTR lpszDest)
Definition: ftp.c:2169
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 432 of file ftp.c.

433 {
435  ftp_session_t *session = (ftp_session_t*)task->hdr.hdr;
436 
437  TRACE("%p\n", session);
438 
439  FTP_FtpSetCurrentDirectoryW(session, task->directory);
440  heap_free(task->directory);
441 }
char hdr[14]
Definition: iptest.cpp:33
static BOOL FTP_FtpSetCurrentDirectoryW(ftp_session_t *, LPCWSTR lpszDirectory)
Definition: ftp.c:513
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:391
WCHAR * directory
Definition: ftp.c:429
task_header_t hdr
Definition: ftp.c:428
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 2425 of file ftp.c.

2429 {
2430  static const WCHAR szKey[] = {'S','o','f','t','w','a','r','e','\\',
2431  'M','i','c','r','o','s','o','f','t','\\',
2432  'W','i','n','d','o','w','s','\\',
2433  'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
2434  'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0};
2435  static const WCHAR szValue[] = {'E','m','a','i','l','N','a','m','e',0};
2436  static const WCHAR szDefaultUsername[] = {'a','n','o','n','y','m','o','u','s','\0'};
2437  static const WCHAR szEmpty[] = {'\0'};
2438  struct sockaddr_in socketAddr;
2439  INT nsocket = -1;
2440  socklen_t sock_namelen;
2441  BOOL bSuccess = FALSE;
2442  ftp_session_t *lpwfs = NULL;
2443  char szaddr[INET6_ADDRSTRLEN];
2444 
2445  TRACE("%p Server(%s) Port(%d) User(%s) Paswd(%s)\n",
2446  hIC, debugstr_w(lpszServerName),
2447  nServerPort, debugstr_w(lpszUserName), debugstr_w(lpszPassword));
2448 
2449  assert( hIC->hdr.htype == WH_HINIT );
2450 
2451  if ((!lpszUserName || !*lpszUserName) && lpszPassword && *lpszPassword)
2452  {
2454  return NULL;
2455  }
2456 
2457  lpwfs = alloc_object(&hIC->hdr, &FTPSESSIONVtbl, sizeof(ftp_session_t));
2458  if (NULL == lpwfs)
2459  {
2461  return NULL;
2462  }
2463 
2464  if (nServerPort == INTERNET_INVALID_PORT_NUMBER)
2466  else
2467  lpwfs->serverport = nServerPort;
2468 
2469  lpwfs->hdr.htype = WH_HFTPSESSION;
2470  lpwfs->hdr.dwFlags = dwFlags;
2471  lpwfs->hdr.dwContext = dwContext;
2472  lpwfs->hdr.dwInternalFlags |= dwInternalFlags;
2473  lpwfs->download_in_progress = NULL;
2474  lpwfs->sndSocket = -1;
2475  lpwfs->lstnSocket = -1;
2476  lpwfs->pasvSocket = -1;
2477 
2478  WININET_AddRef( &hIC->hdr );
2479  lpwfs->lpAppInfo = hIC;
2480  list_add_head( &hIC->hdr.children, &lpwfs->hdr.entry );
2481 
2482  if(hIC->proxy && hIC->accessType == INTERNET_OPEN_TYPE_PROXY) {
2483  if(strchrW(hIC->proxy, ' '))
2484  FIXME("Several proxies not implemented.\n");
2485  if(hIC->proxyBypass)
2486  FIXME("Proxy bypass is ignored.\n");
2487  }
2488  if (!lpszUserName || !lpszUserName[0]) {
2489  HKEY key;
2490  WCHAR szPassword[MAX_PATH];
2491  DWORD len = sizeof(szPassword);
2492 
2493  lpwfs->lpszUserName = heap_strdupW(szDefaultUsername);
2494 
2495  RegOpenKeyW(HKEY_CURRENT_USER, szKey, &key);
2496  if (RegQueryValueExW(key, szValue, NULL, NULL, (LPBYTE)szPassword, &len)) {
2497  /* Nothing in the registry, get the username and use that as the password */
2498  if (!GetUserNameW(szPassword, &len)) {
2499  /* Should never get here, but use an empty password as failsafe */
2500  strcpyW(szPassword, szEmpty);
2501  }
2502  }
2503  RegCloseKey(key);
2504 
2505  TRACE("Password used for anonymous ftp : (%s)\n", debugstr_w(szPassword));
2506  lpwfs->lpszPassword = heap_strdupW(szPassword);
2507  }
2508  else {
2509  lpwfs->lpszUserName = heap_strdupW(lpszUserName);
2511  }
2512  lpwfs->servername = heap_strdupW(lpszServerName);
2513 
2514  /* Don't send a handle created callback if this handle was created with InternetOpenUrl */
2515  if (!(lpwfs->hdr.dwInternalFlags & INET_OPENURL))
2516  {
2518 
2519  iar.dwResult = (DWORD_PTR)lpwfs->hdr.hInternet;
2520  iar.dwError = ERROR_SUCCESS;
2521 
2522  INTERNET_SendCallback(&hIC->hdr, dwContext,
2524  sizeof(INTERNET_ASYNC_RESULT));
2525  }
2526 
2528  (LPWSTR) lpszServerName, (strlenW(lpszServerName)+1) * sizeof(WCHAR));
2529 
2530  sock_namelen = sizeof(socketAddr);
2531  if (!GetAddress(lpszServerName, lpwfs->serverport, (struct sockaddr *)&socketAddr, &sock_namelen, szaddr))
2532  {
2534  goto lerror;
2535  }
2536 
2537  if (socketAddr.sin_family != AF_INET)
2538  {
2539  WARN("unsupported address family %d\n", socketAddr.sin_family);
2541  goto lerror;
2542  }
2543 
2545  szaddr, strlen(szaddr)+1);
2546 
2547  init_winsock();
2548  nsocket = socket(AF_INET,SOCK_STREAM,0);
2549  if (nsocket == -1)
2550  {
2552  goto lerror;
2553  }
2554 
2556  szaddr, strlen(szaddr)+1);
2557 
2558  if (connect(nsocket, (struct sockaddr *)&socketAddr, sock_namelen) < 0)
2559  {
2560  ERR("Unable to connect (%d)\n", WSAGetLastError());
2562  closesocket(nsocket);
2563  }
2564  else
2565  {
2566  TRACE("Connected to server\n");
2567  lpwfs->sndSocket = nsocket;
2569  szaddr, strlen(szaddr)+1);
2570 
2571  sock_namelen = sizeof(lpwfs->socketAddress);
2572  getsockname(nsocket, (struct sockaddr *) &lpwfs->socketAddress, &sock_namelen);
2573 
2574  if (FTP_ConnectToHost(lpwfs))
2575  {
2576  TRACE("Successfully logged into server\n");
2577  bSuccess = TRUE;
2578  }
2579  }
2580 
2581 lerror:
2582  if (!bSuccess)
2583  {
2584  if(lpwfs)
2585  WININET_Release( &lpwfs->hdr );
2586  return NULL;
2587  }
2588 
2589  return lpwfs->hdr.hInternet;
2590 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
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:2603
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define HKEY_CURRENT_USER
Definition: winreg.h:11
struct sockaddr_in socketAddress
Definition: ftp.c:77
LPWSTR lpszUserName
Definition: ftp.c:82
LPWSTR servername
Definition: ftp.c:79
#define WARN(fmt,...)
Definition: debug.h:111
#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
#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:76
_In_opt_ LPSTR _In_opt_ LPSTR lpszPassword
Definition: winbase.h:2651
#define INET6_ADDRSTRLEN
Definition: request.c:1491
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
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:279
#define ERROR_INTERNET_CANNOT_CONNECT
Definition: wininet.h:2018
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define closesocket
Definition: main.c:39
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:298
#define FIXME(fmt,...)
Definition: debug.h:110
static DWORD_PTR
Definition: ftp.c:44
smooth NULL
Definition: ftsmooth.c:416
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:178
int pasvSocket
Definition: ftp.c:75
#define INTERNET_STATUS_NAME_RESOLVED
Definition: wininet.h:884
static const WCHAR szEmpty[]
Definition: provider.c:47
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:71
INTERNET_PORT serverport
Definition: ftp.c:80
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:81
struct list entry
#define MAX_PATH
Definition: compat.h:26
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:294
_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:112
GLenum GLsizei len
Definition: glext.h:6722
#define INTERNET_STATUS_RESOLVING_NAME
Definition: wininet.h:883
HINTERNET hInternet
Definition: internet.h:276
int sndSocket
Definition: ftp.c:73
BOOL WININET_Release(object_header_t *info)
Definition: internet.c:220
#define ERR(fmt,...)
Definition: debug.h:109
object_header_t hdr
Definition: internet.h:292
DWORD dwInternalFlags
Definition: internet.h:282
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
int lstnSocket
Definition: ftp.c:74
#define INET_OPENURL
Definition: internet.h:244
static const object_vtbl_t FTPSESSIONVtbl
Definition: ftp.c:2393
#define INTERNET_STATUS_CONNECTED_TO_SERVER
Definition: wininet.h:886
#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:72
LPWSTR proxyBypass
Definition: internet.h:295
WH_TYPE htype
Definition: internet.h:274
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:42

Referenced by INTERNET_InternetOpenUrlW(), and InternetConnectW().

◆ FTP_ConnectToHost()

static BOOL FTP_ConnectToHost ( ftp_session_t lpwfs)
static

Definition at line 2603 of file ftp.c.

2604 {
2605  INT nResCode;
2606  BOOL bSuccess = FALSE;
2607 
2608  TRACE("\n");
2609  FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2610 
2611  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_USER, lpwfs->lpszUserName, 0, 0, 0))
2612  goto lend;
2613 
2614  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2615  if (nResCode)
2616  {
2617  /* Login successful... */
2618  if (nResCode == 230)
2619  bSuccess = TRUE;
2620  /* User name okay, need password... */
2621  else if (nResCode == 331)
2622  bSuccess = FTP_SendPassword(lpwfs);
2623  /* Need account for login... */
2624  else if (nResCode == 332)
2625  bSuccess = FTP_SendAccount(lpwfs);
2626  else
2627  FTP_SetResponseError(nResCode);
2628  }
2629 
2630  TRACE("Returning %d\n", bSuccess);
2631 lend:
2632  return bSuccess;
2633 }
#define TRUE
Definition: types.h:120
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
LPWSTR lpszUserName
Definition: ftp.c:82
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL FTP_SendPassword(ftp_session_t *)
Definition: ftp.c:2835
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
static BOOL FTP_SendAccount(ftp_session_t *)
Definition: ftp.c:2875
int sndSocket
Definition: ftp.c:73
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:2752

Referenced by FTP_Connect().

◆ FTP_ConvertFileProp()

static BOOL FTP_ConvertFileProp ( LPFILEPROPERTIESW  lpafp,
LPWIN32_FIND_DATAW  lpFindFileData 
)
static

Definition at line 3596 of file ftp.c.

3597 {
3598  BOOL bSuccess = FALSE;
3599 
3600  ZeroMemory(lpFindFileData, sizeof(WIN32_FIND_DATAW));
3601 
3602  if (lpafp)
3603  {
3604  SystemTimeToFileTime( &lpafp->tmLastModified, &lpFindFileData->ftLastAccessTime );
3605  lpFindFileData->ftLastWriteTime = lpFindFileData->ftLastAccessTime;
3606  lpFindFileData->ftCreationTime = lpFindFileData->ftLastAccessTime;
3607 
3608  /* Not all fields are filled in */
3609  lpFindFileData->nFileSizeHigh = 0; /* We do not handle files bigger than 0xFFFFFFFF bytes yet :-) */
3610  lpFindFileData->nFileSizeLow = lpafp->nSize;
3611 
3612  if (lpafp->bIsDirectory)
3613  lpFindFileData->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
3614 
3615  if (lpafp->lpszName)
3616  lstrcpynW(lpFindFileData->cFileName, lpafp->lpszName, MAX_PATH);
3617 
3618  bSuccess = TRUE;
3619  }
3620 
3621  return bSuccess;
3622 }
DWORD nFileSizeHigh
Definition: winbase.h:908
#define TRUE
Definition: types.h:120
#define ZeroMemory
Definition: winbase.h:1635
static BOOLEAN bSuccess
Definition: drive.cpp:417
#define lstrcpynW
Definition: compat.h:397
DWORD nFileSizeLow
Definition: winbase.h:909
unsigned int BOOL
Definition: ntddk_ex.h:94
SYSTEMTIME tmLastModified
Definition: ftp.c:90
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
LPWSTR lpszName
Definition: ftp.c:88
#define MAX_PATH
Definition: compat.h:26
WCHAR cFileName[MAX_PATH]
Definition: winbase.h:912
FILETIME ftLastWriteTime
Definition: winbase.h:907
DWORD nSize
Definition: ftp.c:89
FILETIME ftLastAccessTime
Definition: winbase.h:906
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:148
DWORD dwFileAttributes
Definition: winbase.h:904
BOOL bIsDirectory
Definition: ftp.c:87
FILETIME ftCreationTime
Definition: winbase.h:905

Referenced by FTP_ReceiveFileList(), and FTPFINDNEXT_FindNextFileProc().

◆ FTP_DoPassive()

static BOOL FTP_DoPassive ( ftp_session_t lpwfs)
static

Definition at line 3138 of file ftp.c.

3139 {
3140  INT nResCode;
3141  BOOL bSuccess = FALSE;
3142 
3143  TRACE("\n");
3144  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_PASV, NULL, 0, 0, 0))
3145  goto lend;
3146 
3147  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
3148  if (nResCode)
3149  {
3150  if (nResCode == 227)
3151  {
3152  LPSTR lpszResponseBuffer = INTERNET_GetResponseBuffer();
3153  LPSTR p;
3154  int f[6];
3155  int i;
3156  char *pAddr, *pPort;
3157  INT nsocket = -1;
3158  struct sockaddr_in dataSocketAddress;
3159 
3160  p = lpszResponseBuffer+4; /* skip status code */
3161  while (*p != '\0' && (*p < '0' || *p > '9')) p++;
3162 
3163  if (*p == '\0')
3164  {
3165  ERR("no address found in response, aborting\n");
3166  goto lend;
3167  }
3168 
3169  if (sscanf(p, "%d,%d,%d,%d,%d,%d", &f[0], &f[1], &f[2], &f[3],
3170  &f[4], &f[5]) != 6)
3171  {
3172  ERR("unknown response address format '%s', aborting\n", p);
3173  goto lend;
3174  }
3175  for (i=0; i < 6; i++)
3176  f[i] = f[i] & 0xff;
3177 
3178  dataSocketAddress = lpwfs->socketAddress;
3179  pAddr = (char *)&(dataSocketAddress.sin_addr.S_un.S_addr);
3180  pPort = (char *)&(dataSocketAddress.sin_port);
3181  pAddr[0] = f[0];
3182  pAddr[1] = f[1];
3183  pAddr[2] = f[2];
3184  pAddr[3] = f[3];
3185  pPort[0] = f[4];
3186  pPort[1] = f[5];
3187 
3188  nsocket = socket(AF_INET,SOCK_STREAM,0);
3189  if (nsocket == -1)
3190  goto lend;
3191 
3192  if (connect(nsocket, (struct sockaddr *)&dataSocketAddress, sizeof(dataSocketAddress)))
3193  {
3194  ERR("can't connect passive FTP data port.\n");
3195  closesocket(nsocket);
3196  goto lend;
3197  }
3198  lpwfs->pasvSocket = nsocket;
3199  bSuccess = TRUE;
3200  }
3201  else
3202  FTP_SetResponseError(nResCode);
3203  }
3204 
3205 lend:
3206  return bSuccess;
3207 }
#define TRUE
Definition: types.h:120
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:3922
LPSTR INTERNET_GetResponseBuffer(void)
Definition: internet.c:3823
struct sockaddr_in socketAddress
Definition: ftp.c:77
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:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
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 closesocket
Definition: main.c:39
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
int pasvSocket
Definition: ftp.c:75
GLfloat f
Definition: glext.h:7540
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
int sndSocket
Definition: ftp.c:73
#define ERR(fmt,...)
Definition: debug.h:109
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:2752
#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 658 of file ftp.c.

659 {
660  INT nResCode;
661  BOOL bSuccess = FALSE;
662  appinfo_t *hIC = NULL;
663 
664  TRACE("lpszDirectory(%s)\n", debugstr_w(lpszDirectory));
665 
666  /* Clear any error information */
668 
669  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_MKD, lpszDirectory, 0, 0, 0))
670  goto lend;
671 
672  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
673  if (nResCode)
674  {
675  if (nResCode == 257)
676  bSuccess = TRUE;
677  else
678  FTP_SetResponseError(nResCode);
679  }
680 
681 lend:
682  hIC = lpwfs->lpAppInfo;
683  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
684  {
686 
687  iar.dwResult = (DWORD)bSuccess;
690  &iar, sizeof(INTERNET_ASYNC_RESULT));
691  }
692 
693  return bSuccess;
694 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3744
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
int sndSocket
Definition: ftp.c:73
object_header_t hdr
Definition: internet.h:292
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
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:2752
appinfo_t * lpAppInfo
Definition: ftp.c:72
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 1873 of file ftp.c.

1874 {
1875  INT nResCode;
1876  BOOL bSuccess = FALSE;
1877  appinfo_t *hIC = NULL;
1878 
1879  TRACE("%p\n", lpwfs);
1880 
1881  /* Clear any error information */
1883 
1884  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_DELE, lpszFileName, 0, 0, 0))
1885  goto lend;
1886 
1887  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
1888  if (nResCode)
1889  {
1890  if (nResCode == 250)
1891  bSuccess = TRUE;
1892  else
1893  FTP_SetResponseError(nResCode);
1894  }
1895 lend:
1896  hIC = lpwfs->lpAppInfo;
1897  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
1898  {
1900 
1901  iar.dwResult = (DWORD)bSuccess;
1904  &iar, sizeof(INTERNET_ASYNC_RESULT));
1905  }
1906 
1907  return bSuccess;
1908 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3744
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
int sndSocket
Definition: ftp.c:73
object_header_t hdr
Definition: internet.h:292
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
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:2752
appinfo_t * lpAppInfo
Definition: ftp.c:72
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 811 of file ftp.c.

813 {
814  INT nResCode;
815  appinfo_t *hIC = NULL;
816  HINTERNET hFindNext = NULL;
817  LPWSTR lpszSearchPath = NULL;
818 
819  TRACE("\n");
820 
821  /* Clear any error information */
823 
824  if (!FTP_InitListenSocket(lpwfs))
825  goto lend;
826 
828  goto lend;
829 
830  if (!FTP_SendPortOrPasv(lpwfs))
831  goto lend;
832 
833  /* split search path into file and path */
834  if (lpszSearchFile)
835  {
836  LPCWSTR name = lpszSearchFile, p;
837  if ((p = strrchrW( name, '\\' ))) name = p + 1;
838  if ((p = strrchrW( name, '/' ))) name = p + 1;
839  if (name != lpszSearchFile)
840  {
841  lpszSearchPath = heap_strndupW(lpszSearchFile, name - lpszSearchFile);
842  lpszSearchFile = name;
843  }
844  }
845 
846  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_LIST, lpszSearchPath,
847  lpwfs->hdr.lpfnStatusCB, &lpwfs->hdr, lpwfs->hdr.dwContext))
848  goto lend;
849 
850  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
851  if (nResCode)
852  {
853  if (nResCode == 125 || nResCode == 150)
854  {
855  INT nDataSocket;
856 
857  /* Get data socket to server */
858  if (FTP_GetDataSocket(lpwfs, &nDataSocket))
859  {
860  hFindNext = FTP_ReceiveFileList(lpwfs, nDataSocket, lpszSearchFile, lpFindFileData, dwContext);
861  closesocket(nDataSocket);
862  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
863  if (nResCode != 226 && nResCode != 250)
865  }
866  }
867  else
868  FTP_SetResponseError(nResCode);
869  }
870 
871 lend:
872  heap_free(lpszSearchPath);
873 
874  if (lpwfs->lstnSocket != -1)
875  {
876  closesocket(lpwfs->lstnSocket);
877  lpwfs->lstnSocket = -1;
878  }
879 
880  hIC = lpwfs->lpAppInfo;
881  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
882  {
884 
885  if (hFindNext)
886  {
887  iar.dwResult = (DWORD_PTR)hFindNext;
888  iar.dwError = ERROR_SUCCESS;
890  &iar, sizeof(INTERNET_ASYNC_RESULT));
891  }
892 
893  iar.dwResult = (DWORD_PTR)hFindNext;
894  iar.dwError = hFindNext ? ERROR_SUCCESS : INTERNET_GetLastError();
896  &iar, sizeof(INTERNET_ASYNC_RESULT));
897  }
898 
899  return hFindNext;
900 }
static BOOL FTP_SendType(ftp_session_t *, DWORD dwType)
Definition: ftp.c:3012
static LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
static BOOL FTP_InitListenSocket(ftp_session_t *)
Definition: ftp.c:2952
int32_t INT
Definition: typedefs.h:56
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
#define closesocket
Definition: main.c:39
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3744
static DWORD_PTR
Definition: ftp.c:44
smooth NULL
Definition: ftsmooth.c:416
static BOOL FTP_SendPortOrPasv(ftp_session_t *)
Definition: ftp.c:3210
#define ERROR_NO_MORE_FILES
Definition: winerror.h:121
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
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:3239
int sndSocket
Definition: ftp.c:73
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
object_header_t hdr
Definition: internet.h:292
int lstnSocket
Definition: ftp.c:74
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
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:2752
Definition: name.c:36
INTERNET_STATUS_CALLBACK lpfnStatusCB
Definition: internet.h:285
#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:3552
appinfo_t * lpAppInfo
Definition: ftp.c:72
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 1043 of file ftp.c.

1045 {
1046  INT nResCode;
1047  appinfo_t *hIC = NULL;
1048  BOOL bSuccess = FALSE;
1049 
1050  /* Clear any error information */
1052 
1053  hIC = lpwfs->lpAppInfo;
1054  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_PWD, NULL,
1055  lpwfs->hdr.lpfnStatusCB, &lpwfs->hdr, lpwfs->hdr.dwContext))
1056  goto lend;
1057 
1058  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
1059  if (nResCode)
1060  {
1061  if (nResCode == 257) /* Extract directory name */
1062  {
1063  DWORD firstpos, lastpos, len;
1064  LPWSTR lpszResponseBuffer = heap_strdupAtoW(INTERNET_GetResponseBuffer());
1065 
1066  for (firstpos = 0, lastpos = 0; lpszResponseBuffer[lastpos]; lastpos++)
1067  {
1068  if ('"' == lpszResponseBuffer[lastpos])
1069  {
1070  if (!firstpos)
1071  firstpos = lastpos;
1072  else
1073  break;
1074  }
1075  }
1076  len = lastpos - firstpos;
1077  if (*lpdwCurrentDirectory >= len)
1078  {
1079  memcpy(lpszCurrentDirectory, &lpszResponseBuffer[firstpos + 1], len * sizeof(WCHAR));
1080  lpszCurrentDirectory[len - 1] = 0;
1081  *lpdwCurrentDirectory = len;
1082  bSuccess = TRUE;
1083  }
1085 
1086  heap_free(lpszResponseBuffer);
1087  }
1088  else
1089  FTP_SetResponseError(nResCode);
1090  }
1091 
1092 lend:
1093  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
1094  {
1096 
1097  iar.dwResult = bSuccess;
1100  &iar, sizeof(INTERNET_ASYNC_RESULT));
1101  }
1102 
1103  return bSuccess;
1104 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
#define ERROR_INTERNET_EXTENDED_ERROR
Definition: wininet.h:1992
LPSTR INTERNET_GetResponseBuffer(void)
Definition: internet.c:3823
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static WCHAR * heap_strdupAtoW(const char *str)
Definition: appwiz.h:80
object_header_t hdr
Definition: ftp.c:71
__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:73
object_header_t hdr
Definition: internet.h:292
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
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:2752
INTERNET_STATUS_CALLBACK lpfnStatusCB
Definition: internet.h:285
WCHAR * LPWSTR
Definition: xmlstorage.h:184
appinfo_t * lpAppInfo
Definition: ftp.c:72
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 1684 of file ftp.c.

1687 {
1688  BOOL bSuccess = FALSE;
1689  HANDLE hFile;
1690  appinfo_t *hIC = NULL;
1691 
1692  TRACE("lpszRemoteFile(%s) lpszNewFile(%s)\n", debugstr_w(lpszRemoteFile), debugstr_w(lpszNewFile));
1693 
1694  /* Clear any error information */
1696 
1697  /* Ensure we can write to lpszNewfile by opening it */
1698  hFile = CreateFileW(lpszNewFile, GENERIC_WRITE, 0, 0, fFailIfExists ?
1699  CREATE_NEW : CREATE_ALWAYS, dwLocalFlagsAttribute, 0);
1700  if (INVALID_HANDLE_VALUE == hFile)
1701  return FALSE;
1702 
1703  /* Set up socket to retrieve data */
1704  if (FTP_SendRetrieve(lpwfs, lpszRemoteFile, dwInternetFlags))
1705  {
1706  INT nDataSocket;
1707 
1708  /* Get data socket to server */
1709  if (FTP_GetDataSocket(lpwfs, &nDataSocket))
1710  {
1711  INT nResCode;
1712 
1713  /* Receive data */
1714  FTP_RetrieveFileData(lpwfs, nDataSocket, hFile);
1715  closesocket(nDataSocket);
1716 
1717  nResCode = FTP_ReceiveResponse(lpwfs, dwContext);
1718  if (nResCode)
1719  {
1720  if (nResCode == 226)
1721  bSuccess = TRUE;
1722  else
1723  FTP_SetResponseError(nResCode);
1724  }
1725  }
1726  }
1727 
1728  if (lpwfs->lstnSocket != -1)
1729  {
1730  closesocket(lpwfs->lstnSocket);
1731  lpwfs->lstnSocket = -1;
1732  }
1733 
1734  CloseHandle(hFile);
1735 
1736  hIC = lpwfs->lpAppInfo;
1737  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
1738  {
1740 
1741  iar.dwResult = (DWORD)bSuccess;
1744  &iar, sizeof(INTERNET_ASYNC_RESULT));
1745  }
1746 
1747  if (!bSuccess) DeleteFileW(lpszNewFile);
1748  return bSuccess;
1749 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
#define closesocket
Definition: main.c:39
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:3744
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
static BOOL FTP_RetrieveFileData(ftp_session_t *, INT nDataSocket, HANDLE hFile)
Definition: ftp.c:3396
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
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:3239
_In_ HANDLE hFile
Definition: mswsock.h:90
object_header_t hdr
Definition: internet.h:292
#define CREATE_ALWAYS
Definition: disk.h:72
int lstnSocket
Definition: ftp.c:74
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define CreateFileW
Definition: compat.h:400
#define CREATE_NEW
Definition: disk.h:69
static BOOL FTP_SendRetrieve(ftp_session_t *, LPCWSTR lpszRemoteFile, DWORD dwType)
Definition: ftp.c:3350
appinfo_t * lpAppInfo
Definition: ftp.c:72
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 1314 of file ftp.c.

1317 {
1318  INT nDataSocket;
1319  BOOL bSuccess = FALSE;
1320  ftp_file_t *lpwh = NULL;
1321  appinfo_t *hIC = NULL;
1322 
1323  TRACE("\n");
1324 
1325  /* Clear any error information */
1327 
1328  if (GENERIC_READ == fdwAccess)
1329  {
1330  /* Set up socket to retrieve data */
1331  bSuccess = FTP_SendRetrieve(lpwfs, lpszFileName, dwFlags);
1332  }
1333  else if (GENERIC_WRITE == fdwAccess)
1334  {
1335  /* Set up socket to send data */
1336  bSuccess = FTP_SendStore(lpwfs, lpszFileName, dwFlags);
1337  }
1338 
1339  /* Get data socket to server */
1340  if (bSuccess && FTP_GetDataSocket(lpwfs, &nDataSocket))
1341  {
1342  lpwh = alloc_object(&lpwfs->hdr, &FTPFILEVtbl, sizeof(ftp_file_t));
1343  lpwh->hdr.htype = WH_HFILE;
1344  lpwh->hdr.dwFlags = dwFlags;
1345  lpwh->hdr.dwContext = dwContext;
1346  lpwh->nDataSocket = nDataSocket;
1347  lpwh->cache_file = NULL;
1349  lpwh->session_deleted = FALSE;
1350 
1351  WININET_AddRef( &lpwfs->hdr );
1352  lpwh->lpFtpSession = lpwfs;
1353  list_add_head( &lpwfs->hdr.children, &lpwh->hdr.entry );
1354 
1355  /* Indicate that a download is currently in progress */
1356  lpwfs->download_in_progress = lpwh;
1357  }
1358 
1359  if (lpwfs->lstnSocket != -1)
1360  {
1361  closesocket(lpwfs->lstnSocket);
1362  lpwfs->lstnSocket = -1;
1363  }
1364 
1365  if (bSuccess && fdwAccess == GENERIC_READ)
1366  {
1367  WCHAR filename[MAX_PATH + 1];
1368  URL_COMPONENTSW uc;
1369  DWORD len;
1370 
1371  memset(&uc, 0, sizeof(uc));
1372  uc.dwStructSize = sizeof(uc);
1374  uc.lpszHostName = lpwfs->servername;
1375  uc.nPort = lpwfs->serverport;
1376  uc.lpszUserName = lpwfs->lpszUserName;
1377  uc.lpszUrlPath = heap_strdupW(lpszFileName);
1378 
1380  {
1381  WCHAR *url = heap_alloc(len * sizeof(WCHAR));
1382 
1383  if (url && InternetCreateUrlW(&uc, 0, url, &len) && CreateUrlCacheEntryW(url, 0, NULL, filename, 0))
1384  {
1385  lpwh->cache_file = heap_strdupW(filename);
1389  {
1390  WARN("Could not create cache file: %u\n", GetLastError());
1391  heap_free(lpwh->cache_file);
1392  lpwh->cache_file = NULL;
1393  }
1394  }
1395  heap_free(url);
1396  }
1397  heap_free(uc.lpszUrlPath);
1398  }
1399 
1400  hIC = lpwfs->lpAppInfo;
1401  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
1402  {
1404 
1405  if (lpwh)
1406  {
1407  iar.dwResult = (DWORD_PTR)lpwh->hdr.hInternet;
1408  iar.dwError = ERROR_SUCCESS;
1410  &iar, sizeof(INTERNET_ASYNC_RESULT));
1411  }
1412 
1413  if(bSuccess) {
1415  }else {
1416  iar.dwResult = 0;
1419  &iar, sizeof(INTERNET_ASYNC_RESULT));
1420  }
1421  }
1422 
1423  if(!bSuccess)
1424  return FALSE;
1425 
1426  return lpwh->hdr.hInternet;
1427 }
BOOL WINAPI CreateUrlCacheEntryW(LPCWSTR lpszUrlName, DWORD dwExpectedFileSize, LPCWSTR lpszFileExtension, LPWSTR lpszFileName, DWORD dwReserved)
Definition: urlcache.c:2826
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
DWORD dwStructSize
Definition: wininet.h:211
static const object_vtbl_t FTPFILEVtbl
Definition: ftp.c:1292
LPWSTR lpszUserName
Definition: ftp.c:82
LPWSTR servername
Definition: ftp.c:79
#define WARN(fmt,...)
Definition: debug.h:111
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
struct list children
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
ftp_file_t * download_in_progress
Definition: ftp.c:76
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:1223
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
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:125
DWORD_PTR dwContext
Definition: internet.h:279
HANDLE cache_file_handle
Definition: ftp.c:66
Definition: ftp.c:59
static BOOL FTP_SendStore(ftp_session_t *, LPCWSTR lpszRemoteFile, DWORD dwType)
Definition: ftp.c:2905
#define closesocket
Definition: main.c:39
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:3744
static DWORD_PTR
Definition: ftp.c:44
smooth NULL
Definition: ftsmooth.c:416
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:178
ftp_session_t * lpFtpSession
Definition: ftp.c:62
#define OPEN_EXISTING
Definition: compat.h:426
object_header_t hdr
Definition: ftp.c:61
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
INTERNET_PORT serverport
Definition: ftp.c:80
int nDataSocket
Definition: ftp.c:64
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR url[]
Definition: encode.c:1432
struct list entry
INTERNET_SCHEME nScheme
Definition: wininet.h:214
#define MAX_PATH
Definition: compat.h:26
BOOL session_deleted
Definition: ftp.c:63
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:126
LPWSTR lpszUserName
Definition: wininet.h:218
static BOOL FTP_GetDataSocket(ftp_session_t *, LPINT nDataSocket)
Definition: ftp.c:3239
_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:112
GLenum GLsizei len
Definition: glext.h:6722
#define GENERIC_READ
Definition: compat.h:124
HINTERNET hInternet
Definition: internet.h:276
WCHAR * cache_file
Definition: ftp.c:65
object_header_t hdr
Definition: internet.h:292
BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags, LPWSTR lpszUrl, LPDWORD lpdwUrlLength)
Definition: internet.c:4310
int lstnSocket
Definition: ftp.c:74
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define CreateFileW
Definition: compat.h:400
#define INTERNET_STATUS_HANDLE_CREATED
Definition: wininet.h:895
static BOOL FTP_SendRetrieve(ftp_session_t *, LPCWSTR lpszRemoteFile, DWORD dwType)
Definition: ftp.c:3350
appinfo_t * lpAppInfo
Definition: ftp.c:72
#define memset(x, y, z)
Definition: compat.h:39
WH_TYPE htype
Definition: internet.h:274
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 341 of file ftp.c.

343 {
344  HANDLE hFile;
345  BOOL bSuccess = FALSE;
346  appinfo_t *hIC = NULL;
347  INT nResCode;
348 
349  TRACE(" lpszLocalFile(%s) lpszNewRemoteFile(%s)\n", debugstr_w(lpszLocalFile), debugstr_w(lpszNewRemoteFile));
350 
351  /* Clear any error information */
353 
354  /* Open file to be uploaded */
355  if (INVALID_HANDLE_VALUE ==
356  (hFile = CreateFileW(lpszLocalFile, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0)))
357  /* Let CreateFile set the appropriate error */
358  return FALSE;
359 
360  hIC = lpwfs->lpAppInfo;
361 
363 
364  if (FTP_SendStore(lpwfs, lpszNewRemoteFile, dwFlags))
365  {
366  INT nDataSocket;
367 
368  /* Get data socket to server */
369  if (FTP_GetDataSocket(lpwfs, &nDataSocket))
370  {
371  FTP_SendData(lpwfs, nDataSocket, hFile);
372  closesocket(nDataSocket);
373  nResCode = FTP_ReceiveResponse(lpwfs, dwContext);
374  if (nResCode)
375  {
376  if (nResCode == 226)
377  bSuccess = TRUE;
378  else
379  FTP_SetResponseError(nResCode);
380  }
381  }
382  }
383 
384  if (lpwfs->lstnSocket != -1)
385  {
386  closesocket(lpwfs->lstnSocket);
387  lpwfs->lstnSocket = -1;
388  }
389 
390  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
391  {
393 
394  iar.dwResult = (DWORD)bSuccess;
397  &iar, sizeof(INTERNET_ASYNC_RESULT));
398  }
399 
401 
402  return bSuccess;
403 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:279
static BOOL FTP_SendData(ftp_session_t *, INT nDataSocket, HANDLE hFile)
Definition: ftp.c:3270
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
static BOOL FTP_SendStore(ftp_session_t *, LPCWSTR lpszRemoteFile, DWORD dwType)
Definition: ftp.c:2905
#define closesocket
Definition: main.c:39
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3744
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
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:3239
_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:124
_In_ HANDLE hFile
Definition: mswsock.h:90
object_header_t hdr
Definition: internet.h:292
int lstnSocket
Definition: ftp.c:74
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define CreateFileW
Definition: compat.h:400
appinfo_t * lpAppInfo
Definition: ftp.c:72
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 2015 of file ftp.c.

2016 {
2017  INT nResCode;
2018  BOOL bSuccess = FALSE;
2019  appinfo_t *hIC = NULL;
2020 
2021  TRACE("\n");
2022 
2023  /* Clear any error information */
2025 
2026  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_RMD, lpszDirectory, 0, 0, 0))
2027  goto lend;
2028 
2029  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2030  if (nResCode)
2031  {
2032  if (nResCode == 250)
2033  bSuccess = TRUE;
2034  else
2035  FTP_SetResponseError(nResCode);
2036  }
2037 
2038 lend:
2039  hIC = lpwfs->lpAppInfo;
2040  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
2041  {
2043 
2044  iar.dwResult = (DWORD)bSuccess;
2047  &iar, sizeof(INTERNET_ASYNC_RESULT));
2048  }
2049 
2050  return bSuccess;
2051 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3744
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
int sndSocket
Definition: ftp.c:73
object_header_t hdr
Definition: internet.h:292
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
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:2752
appinfo_t * lpAppInfo
Definition: ftp.c:72
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 2169 of file ftp.c.

2170 {
2171  INT nResCode;
2172  BOOL bSuccess = FALSE;
2173  appinfo_t *hIC = NULL;
2174 
2175  TRACE("\n");
2176 
2177  /* Clear any error information */
2179 
2180  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_RNFR, lpszSrc, 0, 0, 0))
2181  goto lend;
2182 
2183  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2184  if (nResCode == 350)
2185  {
2186  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_RNTO, lpszDest, 0, 0, 0))
2187  goto lend;
2188 
2189  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2190  }
2191 
2192  if (nResCode == 250)
2193  bSuccess = TRUE;
2194  else
2195  FTP_SetResponseError(nResCode);
2196 
2197 lend:
2198  hIC = lpwfs->lpAppInfo;
2199  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
2200  {
2202 
2203  iar.dwResult = (DWORD)bSuccess;
2206  &iar, sizeof(INTERNET_ASYNC_RESULT));
2207  }
2208 
2209  return bSuccess;
2210 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD INTERNET_GetLastError(void)
Definition: internet.c:3744
smooth NULL
Definition: ftsmooth.c:416
WCHAR lpszDest[260]
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
int sndSocket
Definition: ftp.c:73
object_header_t hdr
Definition: internet.h:292
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
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:2752
appinfo_t * lpAppInfo
Definition: ftp.c:72
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 513 of file ftp.c.

514 {
515  INT nResCode;
516  appinfo_t *hIC = NULL;
517  BOOL bSuccess = FALSE;
518 
519  TRACE("lpszDirectory(%s)\n", debugstr_w(lpszDirectory));
520 
521  /* Clear any error information */
523 
524  hIC = lpwfs->lpAppInfo;
525  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_CWD, lpszDirectory,
526  lpwfs->hdr.lpfnStatusCB, &lpwfs->hdr, lpwfs->hdr.dwContext))
527  goto lend;
528 
529  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
530 
531  if (nResCode)
532  {
533  if (nResCode == 250)
534  bSuccess = TRUE;
535  else
536  FTP_SetResponseError(nResCode);
537  }
538 
539 lend:
540  if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
541  {
543 
544  iar.dwResult = bSuccess;
547  &iar, sizeof(INTERNET_ASYNC_RESULT));
548  }
549  return bSuccess;
550 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
#define ERROR_INTERNET_EXTENDED_ERROR
Definition: wininet.h:1992
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
int sndSocket
Definition: ftp.c:73
object_header_t hdr
Definition: internet.h:292
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
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:2752
INTERNET_STATUS_CALLBACK lpfnStatusCB
Definition: internet.h:285
appinfo_t * lpAppInfo
Definition: ftp.c:72

Referenced by AsyncFtpSetCurrentDirectoryProc(), and FtpSetCurrentDirectoryW().

◆ FTP_GetDataSocket()

static BOOL FTP_GetDataSocket ( ftp_session_t lpwfs,
LPINT  nDataSocket 
)
static

Definition at line 3239 of file ftp.c.

3240 {
3241  struct sockaddr_in saddr;
3242  socklen_t addrlen = sizeof(saddr);
3243 
3244  TRACE("\n");
3245  if (lpwfs->hdr.dwFlags & INTERNET_FLAG_PASSIVE)
3246  {
3247  *nDataSocket = lpwfs->pasvSocket;
3248  lpwfs->pasvSocket = -1;
3249  }
3250  else
3251  {
3252  *nDataSocket = accept(lpwfs->lstnSocket, (struct sockaddr *) &saddr, &addrlen);
3253  closesocket(lpwfs->lstnSocket);
3254  lpwfs->lstnSocket = -1;
3255  }
3256  return *nDataSocket != -1;
3257 }
#define closesocket
Definition: main.c:39
int pasvSocket
Definition: ftp.c:75
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
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:74

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 2646 of file ftp.c.

2647 {
2648  struct timeval tv = {RESPONSE_TIMEOUT,0};
2649  FD_SET set;
2650  INT nRecv = 0;
2651  LPSTR lpszBuffer = INTERNET_GetResponseBuffer();
2652 
2653  TRACE("\n");
2654 
2655  FD_ZERO(&set);
2656  FD_SET(nSocket, &set);
2657 
2658  while (nRecv < MAX_REPLY_LEN)
2659  {
2660  if (select(nSocket+1, &set, NULL, NULL, &tv) > 0)
2661  {
2662  if (sock_recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
2663  {
2665  return NULL;
2666  }
2667 
2668  if (lpszBuffer[nRecv] == '\n')
2669  {
2670  lpszBuffer[nRecv] = '\0';
2671  *dwLen = nRecv - 1;
2672  TRACE(":%d %s\n", nRecv, lpszBuffer);
2673  return lpszBuffer;
2674  }
2675  if (lpszBuffer[nRecv] != '\r')
2676  nRecv++;
2677  }
2678  else
2679  {
2681  return NULL;
2682  }
2683  }
2684 
2685  return NULL;
2686 }
Definition: winsock.h:66
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
LPSTR INTERNET_GetResponseBuffer(void)
Definition: internet.c:3823
#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:56
#define MAX_REPLY_LEN
Definition: request.c:2386
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
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
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:1095
#define ERROR_FTP_TRANSFER_IN_PROGRESS
Definition: wininet.h:2045
#define ERROR_INTERNET_TIMEOUT
Definition: wininet.h:1991
#define RESPONSE_TIMEOUT
Definition: ftp.c:55
static int sock_recv(int fd, void *msg, size_t len, int flags)
Definition: net.c:163
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 2952 of file ftp.c.

2953 {
2954  BOOL bSuccess = FALSE;
2955  socklen_t namelen = sizeof(lpwfs->lstnSocketAddress);
2956 
2957  TRACE("\n");
2958 
2959  init_winsock();
2960  lpwfs->lstnSocket = socket(AF_INET, SOCK_STREAM, 0);
2961  if (lpwfs->lstnSocket == -1)
2962  {
2963  TRACE("Unable to create listening socket\n");
2964  goto lend;
2965  }
2966 
2967  /* We obtain our ip addr from the name of the command channel socket */
2968  lpwfs->lstnSocketAddress = lpwfs->socketAddress;
2969 
2970  /* and get the system to assign us a port */
2971  lpwfs->lstnSocketAddress.sin_port = htons(0);
2972 
2973  if (bind(lpwfs->lstnSocket,(struct sockaddr *) &lpwfs->lstnSocketAddress, sizeof(lpwfs->lstnSocketAddress)) == -1)
2974  {
2975  TRACE("Unable to bind socket\n");
2976  goto lend;
2977  }
2978 
2979  if (listen(lpwfs->lstnSocket, MAX_BACKLOG) == -1)
2980  {
2981  TRACE("listen failed\n");
2982  goto lend;
2983  }
2984 
2985  if (getsockname(lpwfs->lstnSocket, (struct sockaddr *) &lpwfs->lstnSocketAddress, &namelen) != -1)
2986  bSuccess = TRUE;
2987 
2988 lend:
2989  if (!bSuccess && lpwfs->lstnSocket != -1)
2990  {
2991  closesocket(lpwfs->lstnSocket);
2992  lpwfs->lstnSocket = -1;
2993  }
2994 
2995  return bSuccess;
2996 }
#define TRUE
Definition: types.h:120
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
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:77
GLint namelen
Definition: glext.h:7232
static BOOLEAN bSuccess
Definition: drive.cpp:417
struct sockaddr_in lstnSocketAddress
Definition: ftp.c:78
#define closesocket
Definition: main.c:39
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:74
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
#define MAX_BACKLOG
Definition: ftp.c:105
#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 3794 of file ftp.c.

3796 {
3797  BOOL bSuccess = TRUE;
3798  INT sizeFilePropArray = 500;/*20; */
3799  INT indexFilePropArray = -1;
3800 
3801  TRACE("\n");
3802 
3803  /* Allocate initial file properties array */
3804  *lpafp = heap_alloc_zero(sizeof(FILEPROPERTIESW)*(sizeFilePropArray));
3805  if (!*lpafp)
3806  return FALSE;
3807 
3808  do {
3809  if (indexFilePropArray+1 >= sizeFilePropArray)
3810  {
3811  LPFILEPROPERTIESW tmpafp;
3812 
3813  sizeFilePropArray *= 2;
3814  tmpafp = heap_realloc_zero(*lpafp, sizeof(FILEPROPERTIESW)*sizeFilePropArray);
3815  if (NULL == tmpafp)
3816  {
3817  bSuccess = FALSE;
3818  break;
3819  }
3820 
3821  *lpafp = tmpafp;
3822  }
3823  indexFilePropArray++;
3824  } while (FTP_ParseNextFile(nSocket, lpszSearchFile, &(*lpafp)[indexFilePropArray]));
3825 
3826  if (bSuccess && indexFilePropArray)
3827  {
3828  if (indexFilePropArray < sizeFilePropArray - 1)
3829  {
3830  LPFILEPROPERTIESW tmpafp;
3831 
3832  tmpafp = heap_realloc(*lpafp, sizeof(FILEPROPERTIESW)*indexFilePropArray);
3833  if (NULL != tmpafp)
3834  *lpafp = tmpafp;
3835  }
3836  *dwfp = indexFilePropArray;
3837  }
3838  else
3839  {
3840  heap_free(*lpafp);
3842  bSuccess = FALSE;
3843  }
3844 
3845  return bSuccess;
3846 }
#define TRUE
Definition: types.h:120
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#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:3633
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 3633 of file ftp.c.

3634 {
3635  static const char szSpace[] = " \t";
3636  DWORD nBufLen;
3637  char *pszLine;
3638  char *pszToken;
3639  char *pszTmp;
3640  BOOL found = FALSE;
3641  int i;
3642 
3643  lpfp->lpszName = NULL;
3644  do {
3645  if(!(pszLine = FTP_GetNextLine(nSocket, &nBufLen)))
3646  return FALSE;
3647 
3648  pszToken = strtok(pszLine, szSpace);
3649  /* ls format
3650  * <Permissions> <NoLinks> <owner> <group> <size> <date> <time or year> <filename>
3651  *
3652  * For instance:
3653  * drwx--s--- 2 pcarrier ens 512 Sep 28 1995 pcarrier
3654  */
3655  if(!isdigit(pszToken[0]) && 10 == strlen(pszToken)) {
3656  if(!FTP_ParsePermission(pszToken, lpfp))
3657  lpfp->bIsDirectory = FALSE;
3658  for(i=0; i<=3; i++) {
3659  if(!(pszToken = strtok(NULL, szSpace)))
3660  break;
3661  }
3662  if(!pszToken) continue;
3663  if(lpfp->bIsDirectory) {
3664  TRACE("Is directory\n");
3665  lpfp->nSize = 0;
3666  }
3667  else {
3668  TRACE("Size: %s\n", pszToken);
3669  lpfp->nSize = atol(pszToken);
3670  }
3671 
3672  lpfp->tmLastModified.wSecond = 0;
3673  lpfp->tmLastModified.wMinute = 0;
3674  lpfp->tmLastModified.wHour = 0;
3675  lpfp->tmLastModified.wDay = 0;
3676  lpfp->tmLastModified.wMonth = 0;
3677  lpfp->tmLastModified.wYear = 0;
3678 
3679  /* Determine month */
3680  pszToken = strtok(NULL, szSpace);
3681  if(!pszToken) continue;
3682  if(strlen(pszToken) >= 3) {
3683  pszToken[3] = 0;
3684  if((pszTmp = StrStrIA(szMonths, pszToken)))
3685  lpfp->tmLastModified.wMonth = ((pszTmp - szMonths) / 3)+1;
3686  }
3687  /* Determine day */
3688  pszToken = strtok(NULL, szSpace);
3689  if(!pszToken) continue;
3690  lpfp->tmLastModified.wDay = atoi(pszToken);
3691  /* Determine time or year */
3692  pszToken = strtok(NULL, szSpace);
3693  if(!pszToken) continue;
3694  if((pszTmp = strchr(pszToken, ':'))) {
3695  SYSTEMTIME curr_time;
3696  *pszTmp = 0;
3697  pszTmp++;
3698  lpfp->tmLastModified.wMinute = atoi(pszTmp);
3699  lpfp->tmLastModified.wHour = atoi(pszToken);
3700  GetLocalTime( &curr_time );
3701  lpfp->tmLastModified.wYear = curr_time.wYear;
3702  }
3703  else {
3704  lpfp->tmLastModified.wYear = atoi(pszToken);
3705  lpfp->tmLastModified.wHour = 12;
3706  }
3707  TRACE("Mod time: %02d:%02d:%02d %04d/%02d/%02d\n",
3708  lpfp->tmLastModified.wHour, lpfp->tmLastModified.wMinute, lpfp->tmLastModified.wSecond,
3709  lpfp->tmLastModified.wYear, lpfp->tmLastModified.wMonth, lpfp->tmLastModified.wDay);
3710 
3711  pszToken = strtok(NULL, szSpace);
3712  if(!pszToken) continue;
3713  lpfp->lpszName = heap_strdupAtoW(pszToken);
3714  TRACE("File: %s\n", debugstr_w(lpfp->lpszName));
3715  }
3716  /* NT way of parsing ... :
3717 
3718  07-13-03 08:55PM <DIR> sakpatch
3719  05-09-03 06:02PM 12656686 2003-04-21bgm_cmd_e.rgz
3720  */
3721  else if(isdigit(pszToken[0]) && 8 == strlen(pszToken)) {
3722  int mon, mday, year, hour, min;
3723  lpfp->permissions = 0xFFFF; /* No idea, put full permission :-) */
3724 
3725  sscanf(pszToken, "%d-%d-%d", &mon, &mday, &year);
3726  lpfp->tmLastModified.wDay = mday;
3727  lpfp->tmLastModified.wMonth = mon;
3728  lpfp->tmLastModified.wYear = year;
3729 
3730  /* Hacky and bad Y2K protection :-) */
3731  if (lpfp->tmLastModified.wYear < 70) lpfp->tmLastModified.wYear += 2000;
3732 
3733  pszToken = strtok(NULL, szSpace);
3734  if(!pszToken) continue;
3735  sscanf(pszToken, "%d:%d", &hour, &min);
3736  lpfp->tmLastModified.wHour = hour;
3737  lpfp->tmLastModified.wMinute = min;
3738  if((pszToken[5] == 'P') && (pszToken[6] == 'M')) {
3739  lpfp->tmLastModified.wHour += 12;
3740  }
3741  lpfp->tmLastModified.wSecond = 0;
3742 
3743  TRACE("Mod time: %02d:%02d:%02d %04d/%02d/%02d\n",
3744  lpfp->tmLastModified.wHour, lpfp->tmLastModified.wMinute, lpfp->tmLastModified.wSecond,
3745  lpfp->tmLastModified.wYear, lpfp->tmLastModified.wMonth, lpfp->tmLastModified.wDay);
3746 
3747  pszToken = strtok(NULL, szSpace);
3748  if(!pszToken) continue;
3749  if(!strcasecmp(pszToken, "<DIR>")) {
3750  lpfp->bIsDirectory = TRUE;
3751  lpfp->nSize = 0;
3752  TRACE("Is directory\n");
3753  }
3754  else {
3755  lpfp->bIsDirectory = FALSE;
3756  lpfp->nSize = atol(pszToken);
3757  TRACE("Size: %d\n", lpfp->nSize);
3758  }
3759 
3760  pszToken = strtok(NULL, szSpace);
3761  if(!pszToken) continue;
3762  lpfp->lpszName = heap_strdupAtoW(pszToken);
3763  TRACE("Name: %s\n", debugstr_w(lpfp->lpszName));
3764  }
3765  /* EPLF format - http://cr.yp.to/ftp/list/eplf.html */
3766  else if(pszToken[0] == '+') {
3767  FIXME("EPLF Format not implemented\n");
3768  }
3769 
3770  if(lpfp->lpszName) {
3771  if((lpszSearchFile == NULL) ||
3772  (PathMatchSpecW(lpfp->lpszName, lpszSearchFile))) {
3773  found = TRUE;
3774  TRACE("Matched: %s\n", debugstr_w(lpfp->lpszName));
3775  }
3776  else {
3777  heap_free(lpfp->lpszName);
3778  lpfp->lpszName = NULL;
3779  }
3780  }
3781  } while(!found);
3782  return TRUE;
3783 }
static LPSTR FTP_GetNextLine(INT nSocket, LPDWORD dwLen)
Definition: ftp.c:2646
#define TRUE
Definition: types.h:120
#define strcasecmp
Definition: fake.h:9
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static const WCHAR szSpace[]
Definition: msipriv.h:1110
WORD wYear
Definition: winbase.h:870
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
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
WORD wMinute
Definition: winbase.h:875
smooth NULL
Definition: ftsmooth.c:416
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:276
_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
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
static const CHAR szMonths[]
Definition: ftp.c:161
_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:3859
#define min(a, b)
Definition: monoChain.cc:55
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:1943
_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 3859 of file ftp.c.

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

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 3552 of file ftp.c.

3554 {
3555  DWORD dwSize = 0;
3556  LPFILEPROPERTIESW lpafp = NULL;
3557  LPWININETFTPFINDNEXTW lpwfn = NULL;
3558 
3559  TRACE("(%p,%d,%s,%p,%08lx)\n", lpwfs, nSocket, debugstr_w(lpszSearchFile), lpFindFileData, dwContext);
3560 
3561  if (FTP_ParseDirectory(lpwfs, nSocket, lpszSearchFile, &lpafp, &dwSize))
3562  {
3563  if(lpFindFileData)
3564  FTP_ConvertFileProp(lpafp, lpFindFileData);
3565 
3566  lpwfn = alloc_object(&lpwfs->hdr, &FTPFINDNEXTVtbl, sizeof(WININETFTPFINDNEXTW));
3567  if (lpwfn)
3568  {
3569  lpwfn->hdr.htype = WH_HFTPFINDNEXT;
3570  lpwfn->hdr.dwContext = dwContext;
3571  lpwfn->index = 1; /* Next index is 1 since we return index 0 */
3572  lpwfn->size = dwSize;
3573  lpwfn->lpafp = lpafp;
3574 
3575  WININET_AddRef( &lpwfs->hdr );
3576  lpwfn->lpFtpSession = lpwfs;
3577  list_add_head( &lpwfs->hdr.children, &lpwfn->hdr.entry );
3578  }
3579  }
3580 
3581  TRACE("Matched %d files\n", dwSize);
3582  return lpwfn ? lpwfn->hdr.hInternet : NULL;
3583 }
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
struct list children
LPFILEPROPERTIESW lpafp
Definition: ftp.c:100
DWORD_PTR dwContext
Definition: internet.h:279
static BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData)
Definition: ftp.c:3596
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:178
DWORD index
Definition: ftp.c:98
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
struct list entry
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:112
static BOOL FTP_ParseDirectory(ftp_session_t *, INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERTIESW *lpafp, LPDWORD dwfp)
Definition: ftp.c:3794
HINTERNET hInternet
Definition: internet.h:276
static const object_vtbl_t FTPFINDNEXTVtbl
Definition: ftp.c:3531
object_header_t hdr
Definition: ftp.c:96
DWORD size
Definition: ftp.c:99
WH_TYPE htype
Definition: internet.h:274
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
ftp_session_t * lpFtpSession
Definition: ftp.c:97

Referenced by FTP_FtpFindFirstFileW().

◆ FTP_ReceiveRequestData()

static void FTP_ReceiveRequestData ( ftp_file_t file,
BOOL  first_notif 
)
static

Definition at line 1223 of file ftp.c.

1224 {
1226  BYTE buffer[4096];
1227  int available;
1228 
1229  TRACE("%p\n", file);
1230 
1231  available = sock_recv(file->nDataSocket, buffer, sizeof(buffer), MSG_PEEK);
1232 
1233  if(available != -1) {
1234  iar.dwResult = (DWORD_PTR)file->hdr.hInternet;
1235  iar.dwError = first_notif ? 0 : available;
1236  }else {
1237  iar.dwResult = 0;
1239  }
1240 
1241  INTERNET_SendCallback(&file->hdr, file->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar,
1242  sizeof(INTERNET_ASYNC_RESULT));
1243 }
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:3744
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: mem.h:68
#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:163
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 2772 of file ftp.c.

2773 {
2774  LPSTR lpszResponse = INTERNET_GetResponseBuffer();
2775  DWORD nRecv;
2776  INT rc = 0;
2777  char firstprefix[5];
2778  BOOL multiline = FALSE;
2779 
2780  TRACE("socket(%d)\n", lpwfs->sndSocket);
2781 
2783 
2784  while(1)
2785  {
2786  if (!FTP_GetNextLine(lpwfs->sndSocket, &nRecv))
2787  goto lerror;
2788 
2789  if (nRecv >= 3)
2790  {
2791  if(!multiline)
2792  {
2793  if(lpszResponse[3] != '-')
2794  break;
2795  else
2796  { /* Start of multiline response. Loop until we get "nnn " */
2797  multiline = TRUE;
2798  memcpy(firstprefix, lpszResponse, 3);
2799  firstprefix[3] = ' ';
2800  firstprefix[4] = '\0';
2801  }
2802  }
2803  else
2804  {
2805  if(!memcmp(firstprefix, lpszResponse, 4))
2806  break;
2807  }
2808  }
2809  }
2810 
2811  if (nRecv >= 3)
2812  {
2813  rc = atoi(lpszResponse);
2814 
2816  &nRecv, sizeof(DWORD));
2817  }
2818 
2819 lerror:
2820  TRACE("return %d\n", rc);
2821  return rc;
2822 }
static LPSTR FTP_GetNextLine(INT nSocket, LPDWORD dwLen)
Definition: ftp.c:2646
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
LPSTR INTERNET_GetResponseBuffer(void)
Definition: internet.c:3823
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:56
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define INTERNET_STATUS_RECEIVING_RESPONSE
Definition: wininet.h:889
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
int sndSocket
Definition: ftp.c:73
_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 3396 of file ftp.c.

3397 {
3398  DWORD nBytesWritten;
3399  INT nRC = 0;
3400  CHAR *lpszBuffer;
3401 
3402  TRACE("\n");
3403 
3404  lpszBuffer = heap_alloc_zero(sizeof(CHAR)*DATA_PACKET_SIZE);
3405  if (NULL == lpszBuffer)
3406  {
3408  return FALSE;
3409  }
3410 
3411  while (nRC != -1)
3412  {
3413  nRC = sock_recv(nDataSocket, lpszBuffer, DATA_PACKET_SIZE, 0);
3414  if (nRC != -1)
3415  {
3416  /* other side closed socket. */
3417  if (nRC == 0)
3418  goto recv_end;
3419  WriteFile(hFile, lpszBuffer, nRC, &nBytesWritten, NULL);
3420  }
3421  }
3422 
3423  TRACE("Data transfer complete\n");
3424 
3425 recv_end:
3426  heap_free(lpszBuffer);
3427  return (nRC != -1);
3428 }
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:3723
char CHAR
Definition: xmlstorage.h:175
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
#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:103
static int sock_recv(int fd, void *msg, size_t len, int flags)
Definition: net.c:163
#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 2875 of file ftp.c.

2876 {
2877  INT nResCode;
2878  BOOL bSuccess = FALSE;
2879 
2880  TRACE("\n");
2881  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_ACCT, szNoAccount, 0, 0, 0))
2882  goto lend;
2883 
2884  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2885  if (nResCode)
2886  bSuccess = TRUE;
2887  else
2888  FTP_SetResponseError(nResCode);
2889 
2890 lend:
2891  return bSuccess;
2892 }
#define TRUE
Definition: types.h:120
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
int sndSocket
Definition: ftp.c:73
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:2752
static const WCHAR szNoAccount[]
Definition: ftp.c:162

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 2752 of file ftp.c.

2754 {
2755  BOOL ret;
2756  LPSTR lpszParamA = heap_strdupWtoA(lpszParam);
2757  ret = FTP_SendCommandA(nSocket, ftpCmd, lpszParamA, lpfnStatusCB, hdr, dwContext);
2758  heap_free(lpszParamA);
2759  return ret;
2760 }
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:2698
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 2698 of file ftp.c.

2700 {
2701  DWORD len;
2702  CHAR *buf;
2703  DWORD nBytesSent = 0;
2704  int nRC = 0;
2705  DWORD dwParamLen;
2706 
2707  TRACE("%d: (%s) %d\n", ftpCmd, debugstr_a(lpszParam), nSocket);
2708 
2709  if (lpfnStatusCB)
2710  {
2711  lpfnStatusCB(hdr->hInternet, dwContext, INTERNET_STATUS_SENDING_REQUEST, NULL, 0);
2712  }
2713 
2714  dwParamLen = lpszParam?strlen(lpszParam)+1:0;
2715  len = dwParamLen + strlen(szFtpCommands[ftpCmd]) + strlen(szCRLF);
2716  if (NULL == (buf = heap_alloc(len+1)))
2717  {
2719  return FALSE;
2720  }
2721  sprintf(buf, "%s%s%s%s", szFtpCommands[ftpCmd], dwParamLen ? " " : "",
2722  dwParamLen ? lpszParam : "", szCRLF);
2723 
2724  TRACE("Sending (%s) len(%d)\n", debugstr_a(buf), len);
2725  while((nBytesSent < len) && (nRC != -1))
2726  {
2727  nRC = sock_send(nSocket, buf+nBytesSent, len - nBytesSent, 0);
2728  nBytesSent += nRC;
2729  }
2730  heap_free(buf);
2731 
2732  if (lpfnStatusCB)
2733  {
2734  lpfnStatusCB(hdr->hInternet, dwContext, INTERNET_STATUS_REQUEST_SENT,
2735  &nBytesSent, sizeof(DWORD));
2736  }
2737 
2738  TRACE("Sent %d bytes\n", nBytesSent);
2739  return (nRC != -1);
2740 }
char hdr[14]
Definition: iptest.cpp:33
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define INTERNET_STATUS_REQUEST_SENT
Definition: wininet.h:888
char CHAR
Definition: xmlstorage.h:175
static const CHAR *const szFtpCommands[]
Definition: ftp.c:138
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define sprintf(buf, format,...)
Definition: sprintf.c:55
smooth NULL
Definition: ftsmooth.c:416
#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:104
#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:152
#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 3270 of file ftp.c.

3271 {
3273  DWORD nBytesRead = 0;
3274  DWORD nBytesSent = 0;
3275  DWORD nTotalSent = 0;
3276  DWORD nBytesToSend, nLen;
3277  int nRC = 1;
3278  time_t s_long_time, e_long_time;
3279  LONG nSeconds;
3280  CHAR *lpszBuffer;
3281 
3282  TRACE("\n");
3283  lpszBuffer = heap_alloc_zero(sizeof(CHAR)*DATA_PACKET_SIZE);
3284 
3285  /* Get the size of the file. */
3287  time(&s_long_time);
3288 
3289  do
3290  {
3291  nBytesToSend = nBytesRead - nBytesSent;
3292 
3293  if (nBytesToSend <= 0)
3294  {
3295  /* Read data from file. */
3296  nBytesSent = 0;
3297  if (!ReadFile(hFile, lpszBuffer, DATA_PACKET_SIZE, &nBytesRead, 0))
3298  ERR("Failed reading from file\n");
3299 
3300  if (nBytesRead > 0)
3301  nBytesToSend = nBytesRead;
3302  else
3303  break;
3304  }
3305 
3306  nLen = DATA_PACKET_SIZE < nBytesToSend ?
3307  DATA_PACKET_SIZE : nBytesToSend;
3308  nRC = sock_send(nDataSocket, lpszBuffer, nLen, 0);
3309 
3310  if (nRC != -1)
3311  {
3312  nBytesSent += nRC;
3313  nTotalSent += nRC;
3314  }
3315 
3316  /* Do some computation to display the status. */
3317  time(&e_long_time);
3318  nSeconds = e_long_time - s_long_time;
3319  if( nSeconds / 60 > 0 )
3320  {
3321  TRACE( "%d bytes of %d bytes (%d%%) in %d min %d sec estimated remaining time %d sec\n",
3322  nTotalSent, fi.nFileSizeLow, nTotalSent*100/fi.nFileSizeLow, nSeconds / 60,
3323  nSeconds % 60, (fi.nFileSizeLow - nTotalSent) * nSeconds / nTotalSent );
3324  }
3325  else
3326  {
3327  TRACE( "%d bytes of %d bytes (%d%%) in %d sec estimated remaining time %d sec\n",
3328  nTotalSent, fi.nFileSizeLow, nTotalSent*100/fi.nFileSizeLow, nSeconds,
3329  (fi.nFileSizeLow - nTotalSent) * nSeconds / nTotalSent);
3330  }
3331  } while (nRC != -1);
3332 
3333  TRACE("file transfer complete!\n");
3334 
3335  heap_free(lpszBuffer);
3336  return nTotalSent;
3337 }
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:608
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ HANDLE hFile
Definition: mswsock.h:90
#define DATA_PACKET_SIZE
Definition: ftp.c:103
#define ERR(fmt,...)
Definition: debug.h:109
static int sock_send(int fd, const void *msg, size_t len, int flags)
Definition: net.c:152
__kernel_time_t time_t
Definition: linux.h:252
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
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 2835 of file ftp.c.

2836 {
2837  INT nResCode;
2838  BOOL bSuccess = FALSE;
2839 
2840  TRACE("\n");
2841  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_PASS, lpwfs->lpszPassword, 0, 0, 0))
2842  goto lend;
2843 
2844  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2845  if (nResCode)
2846  {
2847  TRACE("Received reply code %d\n", nResCode);
2848  /* Login successful... */
2849  if (nResCode == 230)
2850  bSuccess = TRUE;
2851  /* Command not implemented, superfluous at the server site... */
2852  /* Need account for login... */
2853  else if (nResCode == 332)
2854  bSuccess = FTP_SendAccount(lpwfs);
2855  else
2856  FTP_SetResponseError(nResCode);
2857  }
2858 
2859 lend:
2860  TRACE("Returning %d\n", bSuccess);
2861  return bSuccess;
2862 }
#define TRUE
Definition: types.h:120
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
LPWSTR lpszPassword
Definition: ftp.c:81
static BOOL FTP_SendAccount(ftp_session_t *)
Definition: ftp.c:2875
int sndSocket
Definition: ftp.c:73
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:2752

Referenced by FTP_ConnectToHost().

◆ FTP_SendPort()

static BOOL FTP_SendPort ( ftp_session_t lpwfs)
static

Definition at line 3094 of file ftp.c.

3095 {
3096  static const WCHAR szIPFormat[] = {'%','d',',','%','d',',','%','d',',','%','d',',','%','d',',','%','d','\0'};
3097  INT nResCode;
3098  WCHAR szIPAddress[64];
3099  BOOL bSuccess = FALSE;
3100  TRACE("\n");
3101 
3102  sprintfW(szIPAddress, szIPFormat,
3103  lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0x000000FF,
3104  (lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0x0000FF00)>>8,
3105  (lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0x00FF0000)>>16,
3106  (lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0xFF000000)>>24,
3107  lpwfs->lstnSocketAddress.sin_port & 0xFF,
3108  (lpwfs->lstnSocketAddress.sin_port & 0xFF00)>>8);
3109 
3110  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_PORT, szIPAddress, 0, 0, 0))
3111  goto lend;
3112 
3113  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
3114  if (nResCode)
3115  {
3116  if (nResCode == 200)
3117  bSuccess = TRUE;
3118  else
3119  FTP_SetResponseError(nResCode);
3120  }
3121 
3122 lend:
3123  return bSuccess;
3124 }
#define TRUE
Definition: types.h:120
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
DWORD_PTR dwContext
Definition: internet.h:279
struct sockaddr_in lstnSocketAddress
Definition: ftp.c:78
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
__wchar_t WCHAR
Definition: xmlstorage.h:180
int sndSocket
Definition: ftp.c:73
#define sprintfW
Definition: unicode.h:58
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:2752

Referenced by FTP_SendPortOrPasv().

◆ FTP_SendPortOrPasv()

static BOOL FTP_SendPortOrPasv ( ftp_session_t lpwfs)
static

Definition at line 3210 of file ftp.c.

3211 {
3212  if (lpwfs->hdr.dwFlags & INTERNET_FLAG_PASSIVE)
3213  {
3214  if (!FTP_DoPassive(lpwfs))
3215  return FALSE;
3216  }
3217  else
3218  {
3219  if (!FTP_SendPort(lpwfs))
3220  return FALSE;
3221  }
3222  return TRUE;
3223 }
static BOOL FTP_SendPort(ftp_session_t *)
Definition: ftp.c:3094
static BOOL FTP_DoPassive(ftp_session_t *)
Definition: ftp.c:3138
#define TRUE
Definition: types.h:120
object_header_t hdr
Definition: ftp.c:71
#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 3350 of file ftp.c.

3351 {
3352  INT nResCode;
3353  BOOL ret;
3354 
3355  TRACE("\n");
3356  if (!(ret = FTP_InitListenSocket(lpwfs)))
3357  goto lend;
3358 
3359  if (!(ret = FTP_SendType(lpwfs, dwType)))
3360  goto lend;
3361 
3362  if (!(ret = FTP_SendPortOrPasv(lpwfs)))
3363  goto lend;
3364 
3365  if (!(ret = FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_RETR, lpszRemoteFile, 0, 0, 0)))
3366  goto lend;
3367 
3368  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
3369  if ((nResCode != 125) && (nResCode != 150)) {
3370  /* That means that we got an error getting the file. */
3371  FTP_SetResponseError(nResCode);
3372  ret = FALSE;
3373  }
3374 
3375 lend:
3376  if (!ret && lpwfs->lstnSocket != -1)
3377  {
3378  closesocket(lpwfs->lstnSocket);
3379  lpwfs->lstnSocket = -1;
3380  }
3381 
3382  return ret;
3383 }
static BOOL FTP_SendType(ftp_session_t *, DWORD dwType)
Definition: ftp.c:3012
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
static BOOL FTP_InitListenSocket(ftp_session_t *)
Definition: ftp.c:2952
int32_t INT
Definition: typedefs.h:56
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
#define closesocket
Definition: main.c:39
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL FTP_SendPortOrPasv(ftp_session_t *)
Definition: ftp.c:3210
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
int ret
int sndSocket
Definition: ftp.c:73
int lstnSocket
Definition: ftp.c:74
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:2752

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 2905 of file ftp.c.

2906 {
2907  INT nResCode;
2908  BOOL bSuccess = FALSE;
2909 
2910  TRACE("\n");
2911  if (!FTP_InitListenSocket(lpwfs))
2912  goto lend;
2913 
2914  if (!FTP_SendType(lpwfs, dwType))
2915  goto lend;
2916 
2917  if (!FTP_SendPortOrPasv(lpwfs))
2918  goto lend;
2919 
2920  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_STOR, lpszRemoteFile, 0, 0, 0))
2921  goto lend;
2922  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2923  if (nResCode)
2924  {
2925  if (nResCode == 150 || nResCode == 125)
2926  bSuccess = TRUE;
2927  else
2928  FTP_SetResponseError(nResCode);
2929  }
2930 
2931 lend:
2932  if (!bSuccess && lpwfs->lstnSocket != -1)
2933  {
2934  closesocket(lpwfs->lstnSocket);
2935  lpwfs->lstnSocket = -1;
2936  }
2937 
2938  return bSuccess;
2939 }
#define TRUE
Definition: types.h:120
static BOOL FTP_SendType(ftp_session_t *, DWORD dwType)
Definition: ftp.c:3012
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
static BOOL FTP_InitListenSocket(ftp_session_t *)
Definition: ftp.c:2952
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
#define closesocket
Definition: main.c:39
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL FTP_SendPortOrPasv(ftp_session_t *)
Definition: ftp.c:3210
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
int sndSocket
Definition: ftp.c:73
int lstnSocket
Definition: ftp.c:74
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:2752

Referenced by FTP_FtpOpenFileW(), and FTP_FtpPutFileW().

◆ FTP_SendType()

static BOOL FTP_SendType ( ftp_session_t lpwfs,
DWORD  dwType 
)
static

Definition at line 3012 of file ftp.c.

3013 {
3014  INT nResCode;
3015  WCHAR type[] = { 'I','\0' };
3016  BOOL bSuccess = FALSE;
3017 
3018  TRACE("\n");
3019  if (dwType & INTERNET_FLAG_TRANSFER_ASCII)
3020  type[0] = 'A';
3021 
3022  if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_TYPE, type, 0, 0, 0))
3023  goto lend;
3024 
3025  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext)/100;
3026  if (nResCode)
3027  {
3028  if (nResCode == 2)
3029  bSuccess = TRUE;
3030  else
3031  FTP_SetResponseError(nResCode);
3032  }
3033 
3034 lend:
3035  return bSuccess;
3036 }
#define TRUE
Definition: types.h:120
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define INTERNET_FLAG_TRANSFER_ASCII
Definition: wininet.h:90
int sndSocket
Definition: ftp.c:73
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:2752

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

◆ FTP_SetResponseError()

static DWORD FTP_SetResponseError ( DWORD  dwResponse)
static

Definition at line 3922 of file ftp.c.

3923 {
3924  DWORD dwCode = 0;
3925 
3926  switch(dwResponse)
3927  {
3928  case 425: /* Cannot open data connection. */
3930  break;
3931 
3932  case 426: /* Connection closed, transer aborted. */
3934  break;
3935 
3936  case 530: /* Not logged in. Login incorrect. */
3938  break;
3939 
3940  case 421: /* Service not available - Server may be shutting down. */
3941  case 450: /* File action not taken. File may be busy. */
3942  case 451: /* Action aborted. Server error. */
3943  case 452: /* Action not taken. Insufficient storage space on server. */
3944  case 500: /* Syntax error. Command unrecognized. */
3945  case 501: /* Syntax error. Error in parameters or arguments. */
3946  case 502: /* Command not implemented. */
3947  case 503: /* Bad sequence of commands. */
3948  case 504: /* Command not implemented for that parameter. */
3949  case 532: /* Need account for storing files */
3950  case 550: /* File action not taken. File not found or no access. */
3951  case 551: /* Requested action aborted. Page type unknown */
3952  case 552: /* Action aborted. Exceeded storage allocation */
3953  case 553: /* Action not taken. File name not allowed. */
3954 
3955  default:
3957  break;
3958  }
3959 
3960  INTERNET_SetLastError(dwCode);
3961  return dwCode;
3962 }
#define ERROR_INTERNET_CONNECTION_ABORTED
Definition: wininet.h:2019
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
#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 2215 of file ftp.c.

2217 {
2218  BOOL r;
2219  WCHAR *cmdW;
2220 
2221  TRACE("%p %d 0x%08x %s 0x%08lx %p\n", hConnect, fExpectResponse, dwFlags,
2222  debugstr_a(lpszCommand), dwContext, phFtpCommand);
2223 
2224  if (fExpectResponse)
2225  {
2226  FIXME("data connection not supported\n");
2227  return FALSE;
2228  }
2229 
2230  if (!lpszCommand || !lpszCommand[0])
2231  {
2233  return FALSE;
2234  }
2235 
2236  if (!(cmdW = heap_strdupAtoW(lpszCommand)))
2237  {
2239  return FALSE;
2240  }
2241 
2242  r = FtpCommandW(hConnect, fExpectResponse, dwFlags, cmdW, dwContext, phFtpCommand);
2243 
2244  heap_free(cmdW);
2245  return r;
2246 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
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:2251
#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 2251 of file ftp.c.

2253 {
2254  BOOL r = FALSE;
2255  ftp_session_t *lpwfs;
2256  LPSTR cmd = NULL;
2257  DWORD len, nBytesSent= 0;
2258  INT nResCode, nRC = 0;
2259 
2260  TRACE("%p %d 0x%08x %s 0x%08lx %p\n", hConnect, fExpectResponse, dwFlags,
2261  debugstr_w(lpszCommand), dwContext, phFtpCommand);
2262 
2263  if (!lpszCommand || !lpszCommand[0])
2264  {
2266  return FALSE;
2267  }
2268 
2269  if (fExpectResponse)
2270  {
2271  FIXME("data connection not supported\n");
2272  return FALSE;
2273  }
2274 
2275  lpwfs = (ftp_session_t*) get_handle_object( hConnect );
2276  if (!lpwfs)
2277  {
2279  return FALSE;
2280  }
2281 
2282  if (WH_HFTPSESSION != lpwfs->hdr.htype)
2283  {
2285  goto lend;
2286  }
2287 
2288  if (lpwfs->download_in_progress != NULL)
2289  {
2291  goto lend;
2292  }
2293 
2294  len = WideCharToMultiByte(CP_ACP, 0, lpszCommand, -1, NULL, 0, NULL, NULL) + strlen(szCRLF);
2295  if ((cmd = heap_alloc(len)))
2296  WideCharToMultiByte(CP_ACP, 0, lpszCommand, -1, cmd, len, NULL, NULL);
2297  else
2298  {
2300  goto lend;
2301  }
2302 
2303  strcat(cmd, szCRLF);
2304  len--;
2305 
2306  TRACE("Sending (%s) len(%d)\n", debugstr_a(cmd), len);
2307  while ((nBytesSent < len) && (nRC != -1))
2308  {
2309  nRC = sock_send(lpwfs->sndSocket, cmd + nBytesSent, len - nBytesSent, 0);
2310  if (nRC != -1)
2311  {
2312  nBytesSent += nRC;
2313  TRACE("Sent %d bytes\n", nRC);
2314  }
2315  }
2316 
2317  if (nBytesSent)
2318  {
2319  nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
2320  if (nResCode > 0 && nResCode < 400)
2321  r = TRUE;
2322  else
2323  FTP_SetResponseError(nResCode);
2324  }
2325 
2326 lend:
2327  WININET_Release( &lpwfs->hdr );
2328  heap_free( cmd );
2329  return r;
2330 }
#define ERROR_INTERNET_INCORRECT_HANDLE_TYPE
Definition: wininet.h:2007
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
void INTERNET_SetLastError(DWORD dwError)
Definition: internet.c:3723
#define WideCharToMultiByte
Definition: compat.h:101
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
static DWORD FTP_SetResponseError(DWORD dwResponse)
Definition: ftp.c:3922
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: ftp_var.h:139
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define CP_ACP
Definition: compat.h:99
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
ftp_file_t * download_in_progress
Definition: ftp.c:76
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:56
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
DWORD_PTR dwContext
Definition: internet.h:279
static INT FTP_ReceiveResponse(ftp_session_t *, DWORD_PTR dwContext)
Definition: ftp.c:2772
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t hdr
Definition: ftp.c:71
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_FTP_TRANSFER_IN_PROGRESS
Definition: wininet.h:2045
#define szCRLF
Definition: ftp.c:104
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLenum GLsizei len
Definition: glext.h:6722
int sndSocket
Definition: ftp.c:73
BOOL WININET_Release(object_header_t *info)
Definition: internet.c:220
static int sock_send(int fd, const void *msg, size_t len, int flags)
Definition: net.c:152
WH_TYPE htype
Definition: internet.h:274
object_header_t * get_handle_object(HINTERNET hinternet)
Definition: internet.c:185
#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 563 of file ftp.c.

564 {
565  LPWSTR lpwzDirectory;
566  BOOL ret;
567 
568  lpwzDirectory = heap_strdupAtoW(lpszDirectory);
569  ret = FtpCreateDirectoryW(hConnect, lpwzDirectory);
570  heap_free(lpwzDirectory);
571  return ret;
572 }
BOOL WINAPI FtpCreateDirectoryW(HINTERNET hConnect, LPCWSTR lpszDirectory)
Definition: ftp.c:596
unsigned int BOOL
Definition: ntddk_ex.h:94
static WCHAR * heap_strdupAtoW(const char *str)
Definition: appwiz.h:80
int ret
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by test_createdir(), and test_openfile().

◆ FtpCreateDirectoryW()

BOOL WINAPI FtpCreateDirectoryW ( HINTERNET  hConnect,