mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-03 12:32:47 -05:00
Revert "New vtable API for keygen progress reporting."
This reverts commit a7bdefb394
.
I had accidentally mashed it together with another commit. I did
actually want to push both of them, but I'd rather push them
separately! So I'm backing out the combined blob, and I'll re-push
them with their proper comments and explanations.
This commit is contained in:
70
cmdgen.c
70
cmdgen.c
@ -13,35 +13,36 @@
|
||||
|
||||
#include "putty.h"
|
||||
#include "ssh.h"
|
||||
#include "sshkeygen.h"
|
||||
#include "mpint.h"
|
||||
|
||||
FILE *progress_fp = NULL;
|
||||
|
||||
static void cmdgen_progress_report_attempt(ProgressReceiver *prog)
|
||||
{
|
||||
if (progress_fp) {
|
||||
fputc('+', progress_fp);
|
||||
fflush(progress_fp);
|
||||
}
|
||||
}
|
||||
static void cmdgen_progress_report_phase_complete(ProgressReceiver *prog)
|
||||
{
|
||||
if (progress_fp) {
|
||||
fputc('\n', progress_fp);
|
||||
fflush(progress_fp);
|
||||
}
|
||||
}
|
||||
|
||||
static const ProgressReceiverVtable cmdgen_progress_vt = {
|
||||
null_progress_add_probabilistic,
|
||||
null_progress_ready,
|
||||
null_progress_start_phase,
|
||||
cmdgen_progress_report_attempt,
|
||||
cmdgen_progress_report_phase_complete,
|
||||
struct progress {
|
||||
int phase, current;
|
||||
};
|
||||
|
||||
static ProgressReceiver cmdgen_progress = { .vt = &cmdgen_progress_vt };
|
||||
static void progress_update(void *param, int action, int phase, int iprogress)
|
||||
{
|
||||
struct progress *p = (struct progress *)param;
|
||||
if (action != PROGFN_PROGRESS)
|
||||
return;
|
||||
if (phase > p->phase) {
|
||||
if (p->phase >= 0)
|
||||
fputc('\n', stderr);
|
||||
p->phase = phase;
|
||||
if (iprogress >= 0)
|
||||
p->current = iprogress - 1;
|
||||
else
|
||||
p->current = iprogress;
|
||||
}
|
||||
while (p->current < iprogress) {
|
||||
fputc('+', stdout);
|
||||
p->current++;
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static void no_progress(void *param, int action, int phase, int iprogress)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Stubs to let everything else link sensibly.
|
||||
@ -183,12 +184,10 @@ int main(int argc, char **argv)
|
||||
char *ssh2alg = NULL;
|
||||
char *old_passphrase = NULL, *new_passphrase = NULL;
|
||||
bool load_encrypted;
|
||||
progfn_t progressfn = is_interactive() ? progress_update : no_progress;
|
||||
const char *random_device = NULL;
|
||||
int exit_status = 0;
|
||||
|
||||
if (is_interactive())
|
||||
progress_fp = stderr;
|
||||
|
||||
#define RETURN(status) do { exit_status = (status); goto out; } while (0)
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
@ -334,7 +333,7 @@ int main(int argc, char **argv)
|
||||
outtype = PUBLIC;
|
||||
break;
|
||||
case 'q':
|
||||
progress_fp = NULL;
|
||||
progressfn = no_progress;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -646,6 +645,10 @@ int main(int argc, char **argv)
|
||||
char *entropy;
|
||||
char default_comment[80];
|
||||
struct tm tm;
|
||||
struct progress prog;
|
||||
|
||||
prog.phase = -1;
|
||||
prog.current = -1;
|
||||
|
||||
tm = ltime();
|
||||
if (keytype == DSA)
|
||||
@ -670,25 +673,25 @@ int main(int argc, char **argv)
|
||||
|
||||
if (keytype == DSA) {
|
||||
struct dss_key *dsskey = snew(struct dss_key);
|
||||
dsa_generate(dsskey, bits, &cmdgen_progress);
|
||||
dsa_generate(dsskey, bits, progressfn, &prog);
|
||||
ssh2key = snew(ssh2_userkey);
|
||||
ssh2key->key = &dsskey->sshk;
|
||||
ssh1key = NULL;
|
||||
} else if (keytype == ECDSA) {
|
||||
struct ecdsa_key *ek = snew(struct ecdsa_key);
|
||||
ecdsa_generate(ek, bits);
|
||||
ecdsa_generate(ek, bits, progressfn, &prog);
|
||||
ssh2key = snew(ssh2_userkey);
|
||||
ssh2key->key = &ek->sshk;
|
||||
ssh1key = NULL;
|
||||
} else if (keytype == ED25519) {
|
||||
struct eddsa_key *ek = snew(struct eddsa_key);
|
||||
eddsa_generate(ek, bits);
|
||||
eddsa_generate(ek, bits, progressfn, &prog);
|
||||
ssh2key = snew(ssh2_userkey);
|
||||
ssh2key->key = &ek->sshk;
|
||||
ssh1key = NULL;
|
||||
} else {
|
||||
RSAKey *rsakey = snew(RSAKey);
|
||||
rsa_generate(rsakey, bits, &cmdgen_progress);
|
||||
rsa_generate(rsakey, bits, progressfn, &prog);
|
||||
rsakey->comment = NULL;
|
||||
if (keytype == RSA1) {
|
||||
ssh1key = rsakey;
|
||||
@ -697,6 +700,7 @@ int main(int argc, char **argv)
|
||||
ssh2key->key = &rsakey->sshk;
|
||||
}
|
||||
}
|
||||
progressfn(&prog, PROGFN_PROGRESS, INT_MAX, -1);
|
||||
|
||||
if (ssh2key)
|
||||
ssh2key->comment = dupstr(default_comment);
|
||||
|
Reference in New Issue
Block a user