ftp_client_misc.c File Reference

Helper functions for FTP client. More...

#include <stdlib.h>
#include <ctype.h>
#include "ftp/ftp_client.h"
#include "ftp/ftp_client_transport.h"
#include "ftp/ftp_client_misc.h"
#include "str.h"
#include "error.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   FTP_TRACE_LEVEL
 

Functions

void ftpClientChangeState (FtpClientContext *context, FtpClientState newState)
 Update FTP client state. More...
 
error_t ftpClientSendCommand (FtpClientContext *context)
 Send FTP command and wait for a reply. More...
 
error_t ftpClientFormatCommand (FtpClientContext *context, const char_t *command, const char_t *argument)
 Format FTP command. More...
 
error_t ftpClientFormatPortCommand (FtpClientContext *context, const IpAddr *ipAddr, uint16_t port)
 Format PORT or EPRT command. More...
 
error_t ftpClientFormatPasvCommand (FtpClientContext *context)
 Format PASV or EPSV command. More...
 
error_t ftpClientParsePasvReply (FtpClientContext *context, uint16_t *port)
 Parse PASV or EPSV response. More...
 
error_t ftpClientParsePwdReply (FtpClientContext *context, char_t *path, size_t maxLen)
 Parse PWD response. More...
 
error_t ftpClientParseDirEntry (char_t *line, FtpDirEntry *dirEntry)
 Parse directory entry. More...
 
error_t ftpClientInitDataTransfer (FtpClientContext *context, bool_t direction)
 Initiate data transfer. More...
 
error_t ftpClientTerminateDataTransfer (FtpClientContext *context)
 Terminate data transfer. More...
 
error_t ftpClientCheckTimeout (FtpClientContext *context)
 Determine whether a timeout error has occurred. More...
 

Detailed Description

Helper functions for FTP client.

License

Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.0

Definition in file ftp_client_misc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   FTP_TRACE_LEVEL

Definition at line 30 of file ftp_client_misc.c.

Function Documentation

◆ ftpClientChangeState()

void ftpClientChangeState ( FtpClientContext context,
FtpClientState  newState 
)

Update FTP client state.

Parameters
[in]contextPointer to the FTP client context
[in]newStateNew state to switch to

Definition at line 52 of file ftp_client_misc.c.

◆ ftpClientCheckTimeout()

error_t ftpClientCheckTimeout ( FtpClientContext context)

Determine whether a timeout error has occurred.

Parameters
[in]contextPointer to the FTP client context
Returns
Error code

Definition at line 1162 of file ftp_client_misc.c.

◆ ftpClientFormatCommand()

error_t ftpClientFormatCommand ( FtpClientContext context,
const char_t command,
const char_t argument 
)

Format FTP command.

Parameters
[in]contextPointer to the FTP client context
[in]commandNULL-terminated string containing the FTP command
[in]argumentNULL-terminated string containing the argument
Returns
Error code

Definition at line 178 of file ftp_client_misc.c.

◆ ftpClientFormatPasvCommand()

error_t ftpClientFormatPasvCommand ( FtpClientContext context)

Format PASV or EPSV command.

Parameters
[in]contextPointer to the FTP client context
Returns
Error code

Definition at line 293 of file ftp_client_misc.c.

◆ ftpClientFormatPortCommand()

error_t ftpClientFormatPortCommand ( FtpClientContext context,
const IpAddr ipAddr,
uint16_t  port 
)

Format PORT or EPRT command.

Parameters
[in]contextPointer to the FTP client context
[in]ipAddrHost IP address
[in]portTCP port number
Returns
Error code

Definition at line 217 of file ftp_client_misc.c.

◆ ftpClientInitDataTransfer()

error_t ftpClientInitDataTransfer ( FtpClientContext context,
bool_t  direction 
)

Initiate data transfer.

Parameters
[in]contextPointer to the FTP client context
[in]directionData transfer direction
Returns
Error code

Definition at line 709 of file ftp_client_misc.c.

◆ ftpClientParseDirEntry()

error_t ftpClientParseDirEntry ( char_t line,
FtpDirEntry dirEntry 
)

Parse directory entry.

Parameters
[in]lineNULL-terminated string
[out]dirEntryPointer to a directory entry
Returns
Error code

Definition at line 479 of file ftp_client_misc.c.

◆ ftpClientParsePasvReply()

error_t ftpClientParsePasvReply ( FtpClientContext context,
uint16_t *  port 
)

Parse PASV or EPSV response.

Parameters
[in]contextPointer to the FTP client context
[out]portThe TCP port number the server is listening on
Returns
Error code

Definition at line 350 of file ftp_client_misc.c.

◆ ftpClientParsePwdReply()

error_t ftpClientParsePwdReply ( FtpClientContext context,
char_t path,
size_t  maxLen 
)

Parse PWD response.

Parameters
[in]contextPointer to the FTP client context
[out]pathOutput buffer where to store the current directory
[in]maxLenMaximum number of characters the buffer can hold
Returns
Error code

Definition at line 436 of file ftp_client_misc.c.

◆ ftpClientSendCommand()

error_t ftpClientSendCommand ( FtpClientContext context)

Send FTP command and wait for a reply.

Parameters
[in]contextPointer to the FTP client context
Returns
Error code

Definition at line 68 of file ftp_client_misc.c.

◆ ftpClientTerminateDataTransfer()

error_t ftpClientTerminateDataTransfer ( FtpClientContext context)

Terminate data transfer.

Parameters
[in]contextPointer to the FTP client context
Returns
Error code

Definition at line 1065 of file ftp_client_misc.c.