X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwincons.c;h=d7b95704174fb11a14a5e1e934d1d076bcf4e7cf;hb=1de7240eb88fa24a8532ded116b4ec72dd213008;hp=0b60e1849712a879477490f8803350a65517408a;hpb=984fe3dde809681f91d72152a4f96e91d79a2855;p=PuTTY.git diff --git a/windows/wincons.c b/windows/wincons.c index 0b60e184..d7b95704 100644 --- a/windows/wincons.c +++ b/windows/wincons.c @@ -197,6 +197,53 @@ int askalg(void *frontend, const char *algtype, const char *algname, } } +int askhk(void *frontend, const char *algname, const char *betteralgs, + void (*callback)(void *ctx, int result), void *ctx) +{ + HANDLE hin; + DWORD savemode, i; + + static const char msg[] = + "The first host key type we have stored for this server\n" + "is %s, which is below the configured warning threshold.\n" + "The server also provides the following types of host key\n" + "above the threshold, which we do not have stored:\n" + "%s\n" + "Continue with connection? (y/n) "; + static const char msg_batch[] = + "The first host key type we have stored for this server\n" + "is %s, which is below the configured warning threshold.\n" + "The server also provides the following types of host key\n" + "above the threshold, which we do not have stored:\n" + "%s\n" + "Connection abandoned.\n"; + static const char abandoned[] = "Connection abandoned.\n"; + + char line[32]; + + if (console_batch_mode) { + fprintf(stderr, msg_batch, algname, betteralgs); + return 0; + } + + fprintf(stderr, msg, algname, betteralgs); + fflush(stderr); + + hin = GetStdHandle(STD_INPUT_HANDLE); + GetConsoleMode(hin, &savemode); + SetConsoleMode(hin, (savemode | ENABLE_ECHO_INPUT | + ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT)); + ReadFile(hin, line, sizeof(line) - 1, &i, NULL); + SetConsoleMode(hin, savemode); + + if (line[0] == 'y' || line[0] == 'Y') { + return 1; + } else { + fprintf(stderr, abandoned); + return 0; + } +} + /* * Ask whether to wipe a session log file before writing to it. * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).