SilcClientFileMonitor monitor;
void *monitor_context;
char *filepath;
+ char *path;
SilcSFTP sftp;
SilcSFTPFilesystem fs;
void *context)
{
SilcClientFtpSession session = (SilcClientFtpSession)context;
+ char path[512];
SILC_LOG_DEBUG(("Start"));
}
/* Open the actual local file */
- session->fd = silc_file_open(session->filepath,
- O_RDWR | O_CREAT | O_EXCL);
+ memset(path, 0, sizeof(path));
+ snprintf(path, sizeof(path) - 1, "%s%s", session->path ?
+ session->path : "", session->filepath);
+ session->fd = silc_file_open(path, O_RDWR | O_CREAT | O_EXCL);
if (session->fd < 0) {
/* Call monitor callback */
session->client->internal->ops->say(session->client, session->conn,
silc_sftp_open(sftp, name->filename[0], SILC_SFTP_FXF_READ, &attr,
silc_client_ftp_open_handle, session);
- /* Save the important attributes */
+ /* Save the important attributes like filename and file size */
session->filepath = strdup(name->filename[0]);
session->filesize = name->attrs[0]->size;
silc_client_ftp_session_free(session);
}
silc_dlist_del(conn->ftp_sessions, session);
- silc_dlist_uninit(conn->ftp_sessions);
}
}
SILC_LOG_DEBUG(("Free session"));
- silc_dlist_del(session->conn->ftp_sessions, session);
+ if (session->conn && session->conn->ftp_sessions)
+ silc_dlist_del(session->conn->ftp_sessions, session);
+
+ if (session->conn && session->conn->active_session == session)
+ session->conn->active_session = NULL;
if (session->sftp) {
if (session->server)
silc_free(session->hostname);
silc_free(session->filepath);
+ silc_free(session->path);
+ memset(session, 'F', sizeof(*session));
silc_free(session);
}
SilcClientConnection conn,
SilcClientFileMonitor monitor,
void *monitor_context,
+ const char *path,
SilcUInt32 session_id)
{
SilcClientFtpSession session;
session->monitor = monitor;
session->monitor_context = monitor_context;
session->conn = conn;
+ session->path = path ? strdup(path) : NULL;
/* If the hostname and port already exists then the remote client did
provide the connection point to us and we won't create listener, but
silc_dlist_start(conn->ftp_sessions);
while ((session = silc_dlist_get(conn->ftp_sessions)) != SILC_LIST_END) {
- if (session->client_entry == client_entry)
+ if (session->client_entry == client_entry && !session->server)
break;
}