Use new functions.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1021 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1996-11-17 07:30:26 +00:00
parent 20dc897dee
commit ba0f7a5872

View File

@@ -56,15 +56,13 @@ print (int argc,
char **argv, char **argv,
int count, int count,
OtpAlgorithm *alg, OtpAlgorithm *alg,
int hexp, void (*print_fn)(OtpKey, char *))
int extendedp)
{ {
char pw[64]; char pw[64];
OtpKey key; OtpKey key;
int n; int n;
int i; int i;
char *seed; char *seed;
char *ext;
if (argc != 2) if (argc != 2)
usage (); usage ();
@@ -73,22 +71,12 @@ print (int argc,
if (des_read_pw_string (pw, sizeof(pw), "Pass-phrase: ", 0)) if (des_read_pw_string (pw, sizeof(pw), "Pass-phrase: ", 0))
return 1; return 1;
alg->init (key, pw, seed); alg->init (key, pw, seed);
if (extendedp)
if (hexp)
ext = "hex:";
else
ext = "word:";
else
ext = "";
for (i = 0; i < n; ++i) { for (i = 0; i < n; ++i) {
char s[30]; char s[64];
alg->next (key); alg->next (key);
if (i >= n - count) { if (i >= n - count) {
if (hexp) (*print_fn)(key, s);
otp_print_hex (key, s);
else
otp_print_stddict (key, s);
printf ("%d: %s%s\n", i + 1, ext, s); printf ("%d: %s%s\n", i + 1, ext, s);
} }
} }
@@ -102,6 +90,7 @@ main (int argc, char **argv)
int count = 10; int count = 10;
int hexp = 0; int hexp = 0;
int extendedp = 0; int extendedp = 0;
void (*fn)(OtpKey, char *);
OtpAlgorithm *alg = otp_find_alg (OTP_ALG_DEFAULT); OtpAlgorithm *alg = otp_find_alg (OTP_ALG_DEFAULT);
prog = argv[0]; prog = argv[0];
@@ -132,5 +121,16 @@ main (int argc, char **argv)
argc -= optind; argc -= optind;
argv += optind; argv += optind;
return print (argc, argv, count, alg, hexp, extendedp); if (hexp)
if (extendedp)
fn = otp_print_hex_extended;
else
fn = otp_print_hex;
else
if (extendedp)
fn = otp_print_stddict_extended;
else
fn = otp_print_stddict;
return print (argc, argv, count, alg, fn);
} }