aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/otp-data-convert.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/tests/otp-data-convert.c b/tests/otp-data-convert.c
index a10f003..528f8c6 100644
--- a/tests/otp-data-convert.c
+++ b/tests/otp-data-convert.c
@@ -122,6 +122,7 @@ main(
122 int opt_index; 122 int opt_index;
123 int method; 123 int method;
124 int val; 124 int val;
125 int pos;
125 126
126 // getopt options 127 // getopt options
127 static const char * short_opt = "hqVv"; 128 static const char * short_opt = "hqVv";
@@ -176,12 +177,6 @@ main(
176 return(1); 177 return(1);
177 }; 178 };
178 }; 179 };
179 if (argc > 3)
180 {
181 fprintf(stderr, "%s: unknown argument -- `%s'\n", PROGRAM_NAME, argv[3]);
182 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME);
183 return(1);
184 };
185 if (argc < 3) 180 if (argc < 3)
186 { 181 {
187 fprintf(stderr, "%s: missing required argument\n", PROGRAM_NAME); 182 fprintf(stderr, "%s: missing required argument\n", PROGRAM_NAME);
@@ -194,25 +189,34 @@ main(
194 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME); 189 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME);
195 return(1); 190 return(1);
196 }; 191 };
197 if ((val = otputil_skey_dict_value(argv[2])) == -1)
198 {
199 fprintf(stderr, "%s: unknown S/KEY dictionary word -- `%s'\n", PROGRAM_NAME, argv[2]);
200 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME);
201 return(1);
202 };
203 192
204 switch(method) 193 for(pos = 2; (pos < argc); pos++)
205 { 194 {
206 case OTPUTIL_MD_MD4: printf("%s\n", otputil_dict_rfc2289_md4[val]); break; 195 if ((val = otputil_skey_dict_value(argv[pos])) == -1)
207 case OTPUTIL_MD_MD5: printf("%s\n", otputil_dict_rfc2289_md5[val]); break; 196 {
208 case OTPUTIL_MD_SHA1: printf("%s\n", otputil_dict_rfc2289_sha1[val]); break; 197 if (pos > 2)
198 printf("\n");
199 fprintf(stderr, "%s: unknown S/KEY dictionary word -- `%s'\n", PROGRAM_NAME, argv[pos]);
200 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME);
201 return(1);
202 };
203 switch(method)
204 {
205 case OTPUTIL_MD_MD4: printf("%s ", otputil_dict_rfc2289_md4[val]); break;
206 case OTPUTIL_MD_MD5: printf("%s ", otputil_dict_rfc2289_md5[val]); break;
207 case OTPUTIL_MD_SHA1: printf("%s ", otputil_dict_rfc2289_sha1[val]); break;
209 208
210 default: 209 default:
211 fprintf(stderr, "%s: unknown supported hash -- `%s'\n", PROGRAM_NAME, argv[1]); 210 if (pos > 2)
212 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME); 211 printf("\n");
213 return(1); 212 fprintf(stderr, "%s: unknown supported hash -- `%s'\n", PROGRAM_NAME, argv[1]);
213 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME);
214 return(1);
215 };
214 }; 216 };
215 217
218 printf("\n");
219
216 return(0); 220 return(0);
217} 221}
218 222