FtpNormalizeUrl Function  
 
INT WINAPI FtpNormalizeUrl(
  LPCTSTR lpszUrl,  
  LPTSTR lpszNormalized,  
  INT nMaxLength  
);

The FtpNormalizeUrl function normalizes the file path and returns a canonical URL.

Parameters

lpszUrl
A null-terminated string which specifies an FTP URL. This parameter cannot be NULL.
lpszNormalized
A null-terminated string buffer which will contain the normalized URL when the function returns. The buffer must be large enough to contain the entire URL including the terminating null character. If this parameter is NULL it will be ignored and the function will return the length of the normalized URL without copying any characters.
nMaxLength
An integer value which specifies the maximum number of characters which can be copied into the string buffer. If this value is zero, the lpszNormalized parameter is ignored and the function will return the length of the normalized URL without copying any characters.

Return Value

This function returns the number of characters copied into the string buffer, not including the terminating null character. If the lpszNormalized parameter is NULL, it will return the length of the normalized URL but will not copy any characters. If the function fails, it will return FTP_ERROR. To get extended error information, call FtpGetLastError.

Remarks

This function will accept a standard FTP, FTPS or SFTP URL and return a canonical version of that URL. Normalization will remove extraneous path delimiters and collapse the path if there are references to parent directories. If non-standard port numbers are included in the URL, they will be preserved. For example, if the following URL is provided to the function:

ftps://ftp.example.com:21/file/..//data/filename.txt

It will return the following as the normalized URL:

ftpes://ftp.example.com/data/filename.txt

Because the original URL specified a secure connection on port 21, this is inferred to mean the connection will use explicit TLS and not an implicit connection. This is why the scheme is changed from ftps:// to ftpes:// and the port number is removed, since port 21 is the default port for an explicit TLS connection. In addition, the path is collapsed and the extraneous path delimiters are removed.

This function is primarily intended to normalize URLs which may be entered by a user or read from a configuration file. It is not necessary to call this function prior to calling FtpConnectUrl because it will always be normalized internally prior to the connection being established. If you wish to check a URL to ensure it is valid and the server name can be resolved to an IP address, use the FtpValidateUrl function.

If you need to normalize a remote file path, use the FtpNormalizePath function.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csftpv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also