Skip to content

Commit 0f6e784

Browse files
Merge pull request #432 from embhorn/zd14588
Add WIN time support in SFTP client
2 parents 4405eba + 90625af commit 0f6e784

1 file changed

Lines changed: 28 additions & 3 deletions

File tree

examples/sftpclient/sftpclient.c

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,37 @@ static void err_msg(const char* s)
5858

5959

6060
#ifndef WOLFSSH_NO_TIMESTAMP
61-
#include <sys/time.h>
6261

63-
static char currentFile[WOLFSSH_MAX_FILENAME+1] = "";
62+
static char currentFile[WOLFSSH_MAX_FILENAME + 1] = "";
6463
static word32 startTime;
6564
#define TIMEOUT_VALUE 120
6665

6766
word32 current_time(int);
67+
#ifdef USE_WINDOWS_API
68+
#include <time.h>
69+
#define WIN32_LEAN_AND_MEAN
70+
#include <windows.h>
71+
72+
word32 current_time(int reset)
73+
{
74+
static int init = 0;
75+
static LARGE_INTEGER freq;
76+
77+
LARGE_INTEGER count;
78+
79+
(void)reset;
80+
81+
if (!init) {
82+
QueryPerformanceFrequency(&freq);
83+
init = 1;
84+
}
85+
86+
QueryPerformanceCounter(&count);
87+
88+
return (word32)(count.QuadPart / freq.QuadPart);
89+
}
90+
#else
91+
#include <sys/time.h>
6892

6993
/* return number of seconds*/
7094
word32 current_time(int reset)
@@ -76,7 +100,8 @@ static void err_msg(const char* s)
76100
gettimeofday(&tv, 0);
77101
return (word32)tv.tv_sec;
78102
}
79-
#endif
103+
#endif /* USE_WINDOWS_API */
104+
#endif /* !WOLFSSH_NO_TIMESTAMP */
80105

81106

82107
static void myStatusCb(WOLFSSH* sshIn, word32* bytes, char* name)

0 commit comments

Comments
 (0)