]> git.pond.sub.org Git - empserver/blobdiff - src/client/login.c
client: Move get_password() from login.c to getpass.c
[empserver] / src / client / login.c
index 6707bc294445b275904eae9df1724d06d4f2da01..bf75bf8458a487bf6024bccd8f678b2e9af0bc91 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#ifdef _WIN32
-#include <windows.h>
-#endif
 #include "misc.h"
 #include "proto.h"
 
-static char *
-get_password(const char *prompt)
-{
-#ifdef HAVE_GETPASS
-    return getpass(prompt);
-#else
-    static char buf[128];
-    char *p;
-    size_t len;
-#ifdef _WIN32
-    DWORD mode;
-    HANDLE input_handle = GetStdHandle(STD_INPUT_HANDLE);
-
-    if (GetConsoleMode(input_handle, &mode))
-       SetConsoleMode(input_handle, mode & ~ENABLE_ECHO_INPUT);
-    else
-#endif
-       printf("Note: your input is echoed to the screen\n");
-    printf("%s", prompt);
-    fflush(stdout);
-    p = fgets(buf, sizeof(buf), stdin);
-#ifdef _WIN32
-    if (GetConsoleMode(input_handle, &mode))
-       SetConsoleMode(input_handle, mode | ENABLE_ECHO_INPUT);
-#endif
-    if (!p)
-       return NULL;
-    len = strlen(p);
-    if (p[len - 1] == '\n')
-       p[len - 1] = 0;
-    return p;
-#endif /* !HAVE_GETPASS */
-}
-
 int
 login(int s, char *uname, char *cname, char *cpass,
       int kill_proc, int utf8)