Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit 2190455

Browse files
committed
misc: Fix UWP compilation.
1 parent e93d31f commit 2190455

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/misc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <pwd.h>
3434
#include <sys/socket.h>
3535
#include <sys/types.h>
36-
3736
#endif /* _WIN32 */
3837

3938
#include <errno.h>
@@ -56,6 +55,9 @@
5655
# ifndef _WIN32_IE
5756
# define _WIN32_IE 0x0501 // SHGetSpecialFolderPath
5857
# endif
58+
# define WIN32_LEAN_AND_MEAN
59+
# include <windows.h>
60+
# include <iphlpapi.h>
5961
#endif
6062

6163
#include <winsock2.h> // Must be the first to include
@@ -201,7 +203,7 @@ char *ssh_get_local_username(void)
201203
return NULL;
202204
}
203205

204-
if (GetUserName(user, &size)) {
206+
if (GetUserNameA(user, &size)) {
205207
rc = ssh_check_username_syntax(user);
206208
if (rc == SSH_OK) {
207209
return user;
@@ -250,6 +252,7 @@ int ssh_is_ipaddr(const char *str)
250252
int sslen = sizeof(ss);
251253
char *network_interface = strchr(s, '%');
252254

255+
#if !defined(WINAPI_FAMILY) || !(WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP)
253256
/* link-local (IP:v6:addr%ifname). */
254257
if (network_interface != NULL) {
255258
rc = if_nametoindex(network_interface + 1);
@@ -259,6 +262,7 @@ int ssh_is_ipaddr(const char *str)
259262
}
260263
*network_interface = '\0';
261264
}
265+
#endif
262266
rc = WSAStringToAddressA((LPSTR) s,
263267
AF_INET6,
264268
NULL,

0 commit comments

Comments
 (0)