// This is an implementation of getpass() that works from the Windows command // line. It was slightly adapted from: // http://www.opensc-project.org/opensc/browser/branches/alonbl/mingw/src/common/getpass.c?rev=3319 // which URL is no longer valid. The opensc project is (or was) an open source // project for support of smart card devices. This code body contains (or // contained) a GPL license notice, which would govern this as far as I can // tell. #ifdef WIN32 #include #include #include "getpass.h" char *getpass(const char *prompt) { static char buf[PASS_MAX]; size_t i; fputs(prompt, stderr); fflush(stderr); for (i = 0; i < sizeof(buf) - 1; i++) { buf[i] = _getch(); if (buf[i] == '\r') break; } buf[i] = 0; fputs("\n", stderr); return buf; } #endif