diff options
Diffstat (limited to 'src/lib/libcrypto/ui/ui_openssl.c')
-rw-r--r-- | src/lib/libcrypto/ui/ui_openssl.c | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/src/lib/libcrypto/ui/ui_openssl.c b/src/lib/libcrypto/ui/ui_openssl.c index 94a999baa8..ef483352ea 100644 --- a/src/lib/libcrypto/ui/ui_openssl.c +++ b/src/lib/libcrypto/ui/ui_openssl.c | |||
@@ -114,7 +114,6 @@ | |||
114 | * [including the GNU Public Licence.] | 114 | * [including the GNU Public Licence.] |
115 | */ | 115 | */ |
116 | 116 | ||
117 | |||
118 | #include <openssl/e_os2.h> | 117 | #include <openssl/e_os2.h> |
119 | 118 | ||
120 | #include <signal.h> | 119 | #include <signal.h> |
@@ -187,18 +186,17 @@ static int read_till_nl(FILE *); | |||
187 | static void recsig(int); | 186 | static void recsig(int); |
188 | static void pushsig(void); | 187 | static void pushsig(void); |
189 | static void popsig(void); | 188 | static void popsig(void); |
190 | static int read_string_inner(UI * ui, UI_STRING * uis, int echo, int strip_nl); | 189 | static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl); |
191 | 190 | ||
192 | static int read_string(UI * ui, UI_STRING * uis); | 191 | static int read_string(UI *ui, UI_STRING *uis); |
193 | static int write_string(UI * ui, UI_STRING * uis); | 192 | static int write_string(UI *ui, UI_STRING *uis); |
194 | 193 | ||
195 | static int open_console(UI * ui); | 194 | static int open_console(UI *ui); |
196 | static int echo_console(UI * ui); | 195 | static int echo_console(UI *ui); |
197 | static int noecho_console(UI * ui); | 196 | static int noecho_console(UI *ui); |
198 | static int close_console(UI * ui); | 197 | static int close_console(UI *ui); |
199 | 198 | ||
200 | static UI_METHOD ui_openssl = | 199 | static UI_METHOD ui_openssl = { |
201 | { | ||
202 | "OpenSSL default user interface", | 200 | "OpenSSL default user interface", |
203 | open_console, | 201 | open_console, |
204 | write_string, | 202 | write_string, |
@@ -217,12 +215,12 @@ UI_OpenSSL(void) | |||
217 | 215 | ||
218 | /* The following function makes sure that info and error strings are printed | 216 | /* The following function makes sure that info and error strings are printed |
219 | before any prompt. */ | 217 | before any prompt. */ |
220 | static int | 218 | static int |
221 | write_string(UI * ui, UI_STRING * uis) | 219 | write_string(UI *ui, UI_STRING *uis) |
222 | { | 220 | { |
223 | switch (UI_get_string_type(uis)) { | 221 | switch (UI_get_string_type(uis)) { |
224 | case UIT_ERROR: | 222 | case UIT_ERROR: |
225 | case UIT_INFO: | 223 | case UIT_INFO: |
226 | fputs(UI_get0_output_string(uis), tty_out); | 224 | fputs(UI_get0_output_string(uis), tty_out); |
227 | fflush(tty_out); | 225 | fflush(tty_out); |
228 | break; | 226 | break; |
@@ -232,8 +230,8 @@ write_string(UI * ui, UI_STRING * uis) | |||
232 | return 1; | 230 | return 1; |
233 | } | 231 | } |
234 | 232 | ||
235 | static int | 233 | static int |
236 | read_string(UI * ui, UI_STRING * uis) | 234 | read_string(UI *ui, UI_STRING *uis) |
237 | { | 235 | { |
238 | int ok = 0; | 236 | int ok = 0; |
239 | 237 | ||
@@ -257,7 +255,7 @@ read_string(UI * ui, UI_STRING * uis) | |||
257 | UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1)) <= 0) | 255 | UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1)) <= 0) |
258 | return ok; | 256 | return ok; |
259 | if (strcmp(UI_get0_result_string(uis), | 257 | if (strcmp(UI_get0_result_string(uis), |
260 | UI_get0_test_string(uis)) != 0) { | 258 | UI_get0_test_string(uis)) != 0) { |
261 | fprintf(tty_out, "Verify failure\n"); | 259 | fprintf(tty_out, "Verify failure\n"); |
262 | fflush(tty_out); | 260 | fflush(tty_out); |
263 | return 0; | 261 | return 0; |
@@ -271,8 +269,8 @@ read_string(UI * ui, UI_STRING * uis) | |||
271 | 269 | ||
272 | 270 | ||
273 | /* Internal functions to read a string without echoing */ | 271 | /* Internal functions to read a string without echoing */ |
274 | static int | 272 | static int |
275 | read_till_nl(FILE * in) | 273 | read_till_nl(FILE *in) |
276 | { | 274 | { |
277 | #define SIZE 4 | 275 | #define SIZE 4 |
278 | char buf[SIZE + 1]; | 276 | char buf[SIZE + 1]; |
@@ -286,8 +284,8 @@ read_till_nl(FILE * in) | |||
286 | 284 | ||
287 | static volatile sig_atomic_t intr_signal; | 285 | static volatile sig_atomic_t intr_signal; |
288 | 286 | ||
289 | static int | 287 | static int |
290 | read_string_inner(UI * ui, UI_STRING * uis, int echo, int strip_nl) | 288 | read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl) |
291 | { | 289 | { |
292 | static int ps; | 290 | static int ps; |
293 | int ok; | 291 | int ok; |
@@ -339,8 +337,8 @@ error: | |||
339 | 337 | ||
340 | 338 | ||
341 | /* Internal functions to open, handle and close a channel to the console. */ | 339 | /* Internal functions to open, handle and close a channel to the console. */ |
342 | static int | 340 | static int |
343 | open_console(UI * ui) | 341 | open_console(UI *ui) |
344 | { | 342 | { |
345 | CRYPTO_w_lock(CRYPTO_LOCK_UI); | 343 | CRYPTO_w_lock(CRYPTO_LOCK_UI); |
346 | is_a_tty = 1; | 344 | is_a_tty = 1; |
@@ -361,8 +359,8 @@ open_console(UI * ui) | |||
361 | * solaris can return EINVAL instead. This should be | 359 | * solaris can return EINVAL instead. This should be |
362 | * ok | 360 | * ok |
363 | */ | 361 | */ |
364 | if (errno == EINVAL) | 362 | if (errno == EINVAL) |
365 | is_a_tty = 0; | 363 | is_a_tty = 0; |
366 | else | 364 | else |
367 | return 0; | 365 | return 0; |
368 | } | 366 | } |
@@ -370,8 +368,8 @@ open_console(UI * ui) | |||
370 | return 1; | 368 | return 1; |
371 | } | 369 | } |
372 | 370 | ||
373 | static int | 371 | static int |
374 | noecho_console(UI * ui) | 372 | noecho_console(UI *ui) |
375 | { | 373 | { |
376 | #ifdef TTY_FLAGS | 374 | #ifdef TTY_FLAGS |
377 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); | 375 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); |
@@ -385,8 +383,8 @@ noecho_console(UI * ui) | |||
385 | return 1; | 383 | return 1; |
386 | } | 384 | } |
387 | 385 | ||
388 | static int | 386 | static int |
389 | echo_console(UI * ui) | 387 | echo_console(UI *ui) |
390 | { | 388 | { |
391 | #if defined(TTY_set) | 389 | #if defined(TTY_set) |
392 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); | 390 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); |
@@ -400,8 +398,8 @@ echo_console(UI * ui) | |||
400 | return 1; | 398 | return 1; |
401 | } | 399 | } |
402 | 400 | ||
403 | static int | 401 | static int |
404 | close_console(UI * ui) | 402 | close_console(UI *ui) |
405 | { | 403 | { |
406 | if (tty_in != stdin) | 404 | if (tty_in != stdin) |
407 | fclose(tty_in); | 405 | fclose(tty_in); |
@@ -414,7 +412,7 @@ close_console(UI * ui) | |||
414 | 412 | ||
415 | 413 | ||
416 | /* Internal functions to handle signals and act on them */ | 414 | /* Internal functions to handle signals and act on them */ |
417 | static void | 415 | static void |
418 | pushsig(void) | 416 | pushsig(void) |
419 | { | 417 | { |
420 | int i; | 418 | int i; |
@@ -450,7 +448,7 @@ pushsig(void) | |||
450 | #endif | 448 | #endif |
451 | } | 449 | } |
452 | 450 | ||
453 | static void | 451 | static void |
454 | popsig(void) | 452 | popsig(void) |
455 | { | 453 | { |
456 | int i; | 454 | int i; |
@@ -467,7 +465,7 @@ popsig(void) | |||
467 | } | 465 | } |
468 | } | 466 | } |
469 | 467 | ||
470 | static void | 468 | static void |
471 | recsig(int i) | 469 | recsig(int i) |
472 | { | 470 | { |
473 | intr_signal = i; | 471 | intr_signal = i; |