From 7dee4d8b3b92d22eb5cee94b4c6007708131c20f Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Sun, 6 Apr 1997 01:31:53 +0000 Subject: [PATCH] more shared code git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1552 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/otp/otp_parse.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/otp/otp_parse.c b/lib/otp/otp_parse.c index ba9ea3a09..82812a222 100644 --- a/lib/otp/otp_parse.c +++ b/lib/otp/otp_parse.c @@ -2183,12 +2183,13 @@ parse_words(unsigned wn[], return 0; } -int -otp_parse_stddict (OtpKey key, char *str) +static +otp_parse_internal (OtpKey key, char *str, OtpAlgorithm *alg, + int (*convert)(char *, void *)) { unsigned wn[6]; - if (parse_words (wn, str, get_stdword, NULL)) + if (parse_words (wn, str, convert, alg)) return -1; compress (key, wn); if (otp_checksum (key) != (wn[5] & 0x03)) @@ -2196,17 +2197,16 @@ otp_parse_stddict (OtpKey key, char *str) return 0; } +int +otp_parse_stddict (OtpKey key, char *str) +{ + return otp_parse_internal (key, str, NULL, get_stdword); +} + int otp_parse_altdict (OtpKey key, char *str, OtpAlgorithm *alg) { - unsigned wn[6]; - - if (parse_words (wn, str, get_altword, alg)) - return -1; - compress (key, wn); - if (otp_checksum (key) != (wn[5] & 0x03)) - return -1; - return 0; + return otp_parse_internal (key, str, alg, get_altword); } int