From c284eb4e38721f567db15bde24ea53822d0cefb4 Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Fri, 7 Mar 2008 02:11:40 +0000 Subject: second part of win32 changes git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@143 7dcaeef0-15fb-0310-b436-a5af3365683c --- libssh/options.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'libssh/options.c') diff --git a/libssh/options.c b/libssh/options.c index 8c6c7253..04bcb553 100644 --- a/libssh/options.c +++ b/libssh/options.c @@ -23,7 +23,9 @@ MA 02111-1307, USA. */ #include #include #include +#ifndef _WIN32 #include +#endif #include #include "libssh/priv.h" @@ -176,7 +178,7 @@ void ssh_options_set_username(SSH_OPTIONS *opt, char *username){ * \param opt options structure * \param fd an opened file descriptor to use */ -void ssh_options_set_fd(SSH_OPTIONS *opt, int fd){ +void ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd){ opt->fd=fd; } @@ -289,6 +291,7 @@ int ssh_options_set_wanted_algos(SSH_OPTIONS *opt,int algo, char *list){ return 0; } +#ifndef _WIN32 static char *get_username_from_uid(SSH_OPTIONS *opt, int uid){ struct passwd *pwd; char *user; @@ -303,6 +306,7 @@ static char *get_username_from_uid(SSH_OPTIONS *opt, int uid){ ssh_set_error(opt,SSH_FATAL,"uid %d doesn't exist !",uid); return NULL; } +#endif /* this function must be called when no specific username has been asked. it has to guess it */ int ssh_options_default_username(SSH_OPTIONS *opt){ @@ -314,11 +318,23 @@ int ssh_options_default_username(SSH_OPTIONS *opt){ opt->username=strdup(user); return 0; } +#ifndef _WIN32 user=get_username_from_uid(opt,getuid()); if(user){ opt->username=user; return 0; } +#else + DWORD Size = 0; + GetUserName(NULL, &Size); //Get Size + user = malloc(Size); + if (GetUserName(user, &Size)){ + opt->username=user; + return 0; + } else { + free(user); + } +#endif return -1; } -- cgit v1.2.3