summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ui/ui_openssl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/ui/ui_openssl.c')
-rw-r--r--src/lib/libcrypto/ui/ui_openssl.c66
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 *);
187static void recsig(int); 186static void recsig(int);
188static void pushsig(void); 187static void pushsig(void);
189static void popsig(void); 188static void popsig(void);
190static int read_string_inner(UI * ui, UI_STRING * uis, int echo, int strip_nl); 189static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl);
191 190
192static int read_string(UI * ui, UI_STRING * uis); 191static int read_string(UI *ui, UI_STRING *uis);
193static int write_string(UI * ui, UI_STRING * uis); 192static int write_string(UI *ui, UI_STRING *uis);
194 193
195static int open_console(UI * ui); 194static int open_console(UI *ui);
196static int echo_console(UI * ui); 195static int echo_console(UI *ui);
197static int noecho_console(UI * ui); 196static int noecho_console(UI *ui);
198static int close_console(UI * ui); 197static int close_console(UI *ui);
199 198
200static UI_METHOD ui_openssl = 199static 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. */
220static int 218static int
221write_string(UI * ui, UI_STRING * uis) 219write_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
235static int 233static int
236read_string(UI * ui, UI_STRING * uis) 234read_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 */
274static int 272static int
275read_till_nl(FILE * in) 273read_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
287static volatile sig_atomic_t intr_signal; 285static volatile sig_atomic_t intr_signal;
288 286
289static int 287static int
290read_string_inner(UI * ui, UI_STRING * uis, int echo, int strip_nl) 288read_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. */
342static int 340static int
343open_console(UI * ui) 341open_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
373static int 371static int
374noecho_console(UI * ui) 372noecho_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
388static int 386static int
389echo_console(UI * ui) 387echo_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
403static int 401static int
404close_console(UI * ui) 402close_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 */
417static void 415static void
418pushsig(void) 416pushsig(void)
419{ 417{
420 int i; 418 int i;
@@ -450,7 +448,7 @@ pushsig(void)
450#endif 448#endif
451} 449}
452 450
453static void 451static void
454popsig(void) 452popsig(void)
455{ 453{
456 int i; 454 int i;
@@ -467,7 +465,7 @@ popsig(void)
467 } 465 }
468} 466}
469 467
470static void 468static void
471recsig(int i) 469recsig(int i)
472{ 470{
473 intr_signal = i; 471 intr_signal = i;