Newer
Older
else {
ftp->file = conn->ppath; /* there's only a file part */
}
if(*ftp->file) {
ftp->file = curl_unescape(ftp->file, 0);
if(NULL == ftp->file) {
failf(data, "no memory");
return CURLE_OUT_OF_MEMORY;
}
ftp->file=NULL; /* instead of point to a zero byte, we make it a NULL
pointer */
ftp->urlpath = conn->ppath;
if(dirlength) {
ftp->dir = curl_unescape(ftp->urlpath, dirlength);
if(NULL == ftp->dir) {
if(ftp->file)
free(ftp->file);
failf(data, "no memory");
return CURLE_OUT_OF_MEMORY; /* failure */
}
}
else
ftp->dir = NULL;
Daniel Stenberg
committed
retcode = ftp_perform(conn);
Daniel Stenberg
committed
/* clean up here, success or error doesn't matter */
if(ftp->file)
free(ftp->file);
if(ftp->dir)
free(ftp->dir);
ftp->file = ftp->dir = NULL; /* zero */
/***********************************************************************
*
* Curl_ftpsendf()
*
* Sends the formated string as a ftp command to a ftp server
*
* NOTE: we build the command in a fixed-length buffer, which sets length
* restrictions on the command!
*/
Daniel Stenberg
committed
CURLcode Curl_ftpsendf(struct connectdata *conn,
const char *fmt, ...)
{
size_t bytes_written;
char s[256];
Daniel Stenberg
committed
size_t write_len;
va_list ap;
va_start(ap, fmt);
vsnprintf(s, 250, fmt, ap);
va_end(ap);
Daniel Stenberg
committed
if(conn->data->set.verbose)
fprintf(conn->data->set.err, "> %s\n", s);
strcat(s, "\r\n"); /* append a trailing CRLF */
Daniel Stenberg
committed
write_len = strlen(s);
Curl_write(conn, conn->firstsocket, s, write_len, &bytes_written);
Daniel Stenberg
committed
return (bytes_written==write_len)?CURLE_OK:CURLE_WRITE_ERROR;
}
/***********************************************************************
*
* Curl_ftp_disconnect()
*
* Disconnect from an FTP server. Cleanup protocol-specific per-connection
* resources
*/
CURLcode Curl_ftp_disconnect(struct connectdata *conn)
{
struct FTP *ftp= conn->proto.ftp;
Daniel Stenberg
committed
/* The FTP session may or may not have been allocated/setup at this point! */
if(ftp) {
if(ftp->entrypath)
free(ftp->entrypath);
if(ftp->cache)
free(ftp->cache);
Daniel Stenberg
committed
}
Sterling Hughes
committed
/*
* local variables:
* eval: (load-file "../curl-mode.el")
* end:
* vim600: fdm=marker
* vim: et sw=2 ts=2 sts=2 tw=78