Fix source where indent will not be able to cope
[oweals/openssl.git] / crypto / ui / ui_openssl.c
index 99304394c3d0413f53c1df8c1d8fc278cf232b8f..2031b66518cfa8d8b1f6d90c3897ed004796870e 100644 (file)
@@ -56,7 +56,8 @@
  *
  */
 
-/* The lowest level part of this file was previously in crypto/des/read_pwd.c,
+/*-
+ * The lowest level part of this file was previously in crypto/des/read_pwd.c,
  * Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
  * sigaction and fileno included. -pedantic would be more appropriate for
  * the intended purposes, but we can't prevent users from adding -ansi.
  */
+#if defined(OPENSSL_SYSNAME_VXWORKS)
+#include <sys/types.h>
+#endif
+
+#if !defined(_POSIX_C_SOURCE) && defined(OPENSSL_SYS_VMS)
 #ifndef _POSIX_C_SOURCE
 #define _POSIX_C_SOURCE 2
 #endif
+#endif
 #include <signal.h>
 #include <stdio.h>
 #include <string.h>
 # endif
 #endif
 
-#ifdef WIN16TTY
-# undef OPENSSL_SYS_WIN16
-# undef WIN16
-# undef _WINDOWS
-# include <graph.h>
-#endif
-
 /* 06-Apr-92 Luke Brennan    Support for VMS */
 #include "ui_locl.h"
 #include "cryptlib.h"
 # undef  SGTTY
 #endif
 
-#if !defined(TERMIO) && !defined(TERMIOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(MAC_OS_GUSI_SOURCE)
+#if !defined(TERMIO) && !defined(TERMIOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MSDOS) && !defined(MAC_OS_GUSI_SOURCE)
 # undef  TERMIOS
 # undef  TERMIO
 # define SGTTY
 # define TTY_set(tty,data)     ioctl(tty,TIOCSETP,data)
 #endif
 
-#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_SUNOS)
+#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS)
 # include <sys/ioctl.h>
 #endif
 
@@ -258,11 +258,7 @@ struct IOSB {
        };
 #endif
 
-#ifdef OPENSSL_SYS_SUNOS
-       typedef int sig_atomic_t;
-#endif
-
-#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(MAC_OS_GUSI_SOURCE) || defined(OPENSSL_SYS_NETWARE)
+#if defined(MAC_OS_GUSI_SOURCE) || defined(OPENSSL_SYS_NETWARE)
 /*
  * This one needs work. As a matter of fact the code is unoperational
  * and this is only a trick to get it compiled.
@@ -298,13 +294,13 @@ static FILE *tty_in, *tty_out;
 static int is_a_tty;
 
 /* Declare static functions */
-#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
-static void read_till_nl(FILE *);
+#if !defined(OPENSSL_SYS_WINCE)
+static int read_till_nl(FILE *);
 static void recsig(int);
 static void pushsig(void);
 static void popsig(void);
 #endif
-#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
+#if defined(OPENSSL_SYS_MSDOS)
 static int noecho_fgets(char *buf, int size, FILE *tty);
 #endif
 static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl);
@@ -390,16 +386,18 @@ static int read_string(UI *ui, UI_STRING *uis)
        }
 
 
-#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
+#if !defined(OPENSSL_SYS_WINCE)
 /* Internal functions to read a string without echoing */
-static void read_till_nl(FILE *in)
+static int read_till_nl(FILE *in)
        {
 #define SIZE 4
        char buf[SIZE+1];
 
        do      {
-               fgets(buf,SIZE,in);
+               if (!fgets(buf,SIZE,in))
+                       return 0;
                } while (strchr(buf,'\n') == NULL);
+       return 1;
        }
 
 static volatile sig_atomic_t intr_signal;
@@ -411,7 +409,7 @@ static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl)
        int ok;
        char result[BUFSIZ];
        int maxsize = BUFSIZ-1;
-#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
+#if !defined(OPENSSL_SYS_WINCE)
        char *p;
 
        intr_signal=0;
@@ -447,7 +445,8 @@ static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl)
                        *p='\0';
                }
        else
-               read_till_nl(tty_in);
+               if (!read_till_nl(tty_in))
+                       goto error;
        if (UI_set_result(ui, uis, result) >= 0)
                ok=1;
 
@@ -475,7 +474,7 @@ static int open_console(UI *ui)
        CRYPTO_w_lock(CRYPTO_LOCK_UI);
        is_a_tty = 1;
 
-#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_BEOS)
+#if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE)
        tty_in=stdin;
        tty_out=stderr;
 #else
@@ -576,7 +575,7 @@ static int close_console(UI *ui)
        }
 
 
-#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
+#if !defined(OPENSSL_SYS_WINCE)
 /* Internal functions to handle signals and act on them */
 static void pushsig(void)
        {
@@ -662,7 +661,7 @@ static void recsig(int i)
 #endif
 
 /* Internal functions specific for Windows */
-#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
+#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WINCE)
 static int noecho_fgets(char *buf, int size, FILE *tty)
        {
        int i;
@@ -677,9 +676,7 @@ static int noecho_fgets(char *buf, int size, FILE *tty)
                        break;
                        }
                size--;
-#ifdef WIN16TTY
-               i=_inchar();
-#elif defined(_WIN32)
+#if defined(_WIN32)
                i=_getch();
 #else
                i=getch();