Skip to content
13 changes: 11 additions & 2 deletions examples/sftpclient/sftpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,28 @@ static void err_msg(const char* s)

static void myStatusCb(WOLFSSH* sshIn, word32* bytes, char* name)
{
#ifndef WOLFSSH_NO_TIMESTAMP
static word32 lastOutputTime = 0;
#endif
word32 currentTime;
char buf[80];
word64 longBytes = ((word64)bytes[1] << 32) | bytes[0];

#ifndef WOLFSSH_NO_TIMESTAMP
currentTime = current_time(0);
if (currentTime == lastOutputTime) {
return;
}
lastOutputTime = currentTime;
if (WSTRNCMP(currentFile, name, WSTRLEN(name)) != 0) {
startTime = current_time(1);
lastOutputTime = 0; /* Reset timer for new file transfer */
WMEMSET(currentFile, 0, WOLFSSH_MAX_FILENAME);
WSTRNCPY(currentFile, name, WOLFSSH_MAX_FILENAME);
}
currentTime = current_time(0) - startTime;
word32 elapsedTime = currentTime - startTime;
Comment thread
JacobBarthelmeh marked this conversation as resolved.
Outdated
WSNPRINTF(buf, sizeof(buf), "Processed %8llu\t bytes in %d seconds\r",
(unsigned long long)longBytes, currentTime);
(unsigned long long)longBytes, elapsedTime);
#ifndef WOLFSSH_NO_SFTP_TIMEOUT
if (currentTime > TIMEOUT_VALUE) {
WSNPRINTF(buf, sizeof(buf), "\nProcess timed out at %d seconds, "
Expand Down