Include OpenSSL header files earlier so macros like OPENSSL_SYS_VMS
[openssl.git] / crypto / des / read_pwd.c
index fed49652c0d866c19e2dccfdf0a03362a873c238..542df5bb6634dcf7ac57b2f51d1203bab4d62bd1 100644 (file)
  * [including the GNU Public Licence.]
  */
 
-#if !defined(MSDOS) && !defined(VMS) && !defined(WIN32)
 #include <openssl/opensslconf.h>
-#include OPENSSL_UNISTD
+#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WIN32)
+#ifdef OPENSSL_UNISTD
+# include OPENSSL_UNISTD
+#else
+# include <unistd.h>
+#endif
 /* If unistd.h defines _POSIX_VERSION, we conclude that we
  * are on a POSIX system and have sigaction and termios. */
 #if defined(_POSIX_VERSION)
@@ -74,7 +78,7 @@
 /* #define SIGACTION */ /* Define this if you have sigaction() */
 
 #ifdef WIN16TTY
-#undef WIN16
+#undef OPENSSL_SYS_WIN16
 #undef _WINDOWS
 #include <graph.h>
 #endif
@@ -88,7 +92,7 @@
 #include <setjmp.h>
 #include <errno.h>
 
-#ifdef VMS                     /* prototypes for sys$whatever */
+#ifdef OPENSSL_SYS_VMS                 /* prototypes for sys$whatever */
 #include <starlet.h>
 #ifdef __DECC
 #pragma message disable DOLLARID
 #undef  SGTTY
 #endif
 
-#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS)
+#if !defined(TERMIO) && !defined(TERMIOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MSDOS) && !defined(MAC_OS_pre_X) && !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(MSDOS) && !defined(VMS)
+#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(MAC_OS_pre_X)
 #include <sys/ioctl.h>
 #endif
 
-#ifdef MSDOS
+#if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__)
 #include <conio.h>
 #define fgets(a,b,c) noecho_fgets(a,b,c)
 #endif
 
-#ifdef VMS
+#ifdef OPENSSL_SYS_VMS
 #include <ssdef.h>
 #include <iodef.h>
 #include <ttdef.h>
@@ -174,6 +178,15 @@ struct IOSB {
        };
 #endif
 
+#if defined(MAC_OS_pre_X) || defined(MAC_OS_GUSI_SOURCE)
+/*
+ * This one needs work. As a matter of fact the code is unoperational
+ * and this is only a trick to get it compiled.
+ *                                     <appro@fy.chalmers.se>
+ */
+#define TTY_STRUCT int
+#endif
+
 #ifndef NX509_SIG
 #define NX509_SIG 32
 #endif
@@ -182,7 +195,7 @@ static void read_till_nl(FILE *);
 static void recsig(int);
 static void pushsig(void);
 static void popsig(void);
-#if defined(MSDOS) && !defined(WIN16)
+#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
 static int noecho_fgets(char *buf, int size, FILE *tty);
 #endif
 #ifdef SIGACTION
@@ -203,7 +216,7 @@ int des_read_pw_string(char *buf, int length, const char *prompt,
        return(ret);
        }
 
-#ifndef WIN16
+#ifndef OPENSSL_SYS_WIN16
 
 static void read_till_nl(FILE *in)
        {
@@ -220,14 +233,14 @@ static void read_till_nl(FILE *in)
 int des_read_pw(char *buf, char *buff, int size, const char *prompt,
             int verify)
        {
-#ifdef VMS
+#ifdef OPENSSL_SYS_VMS
        struct IOSB iosb;
        $DESCRIPTOR(terminal,"TT");
        long tty_orig[3], tty_new[3];
        long status;
        unsigned short channel = 0;
 #else
-#ifndef MSDOS
+#ifndef OPENSSL_SYS_MSDOS
        TTY_STRUCT tty_orig,tty_new;
 #endif
 #endif
@@ -252,15 +265,19 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
        is_a_tty=1;
        tty=NULL;
 
-#ifndef MSDOS
-       if ((tty=fopen("/dev/tty","r")) == NULL)
-               tty=stdin;
-#else /* MSDOS */
+#ifdef OPENSSL_SYS_MSDOS
        if ((tty=fopen("con","r")) == NULL)
                tty=stdin;
-#endif /* MSDOS */
+#elif defined(MAC_OS_pre_X)
+       tty=stdin;
+#else
+#ifndef OPENSSL_SYS_MPE
+       if ((tty=fopen("/dev/tty","r")) == NULL)
+#endif
+               tty=stdin;
+#endif
 
-#if defined(TTY_get) && !defined(VMS)
+#if defined(TTY_get) && !defined(OPENSSL_SYS_VMS)
        if (TTY_get(fileno(tty),&tty_orig) == -1)
                {
 #ifdef ENOTTY
@@ -279,7 +296,7 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
                }
        memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig));
 #endif
-#ifdef VMS
+#ifdef OPENSSL_SYS_VMS
        status = sys$assign(&terminal,&channel,0,0);
        if (status != SS$_NORMAL)
                return(-1);
@@ -295,11 +312,15 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
        tty_new.TTY_FLAGS &= ~ECHO;
 #endif
 
-#if defined(TTY_set) && !defined(VMS)
+#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
        if (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1))
+#ifdef OPENSSL_SYS_MPE 
+               ; /* MPE lies -- echo really has been disabled */
+#else
                return(-1);
 #endif
-#ifdef VMS
+#endif
+#ifdef OPENSSL_SYS_VMS
        tty_new[0] = tty_orig[0];
        tty_new[1] = tty_orig[1] | TT$M_NOECHO;
        tty_new[2] = tty_orig[2];
@@ -349,10 +370,10 @@ error:
        perror("fgets(tty)");
 #endif
        /* What can we do if there is an error? */
-#if defined(TTY_set) && !defined(VMS)
+#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
        if (ps >= 2) TTY_set(fileno(tty),&tty_orig);
 #endif
-#ifdef VMS
+#ifdef OPENSSL_SYS_VMS
        if (ps >= 2)
                status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0
                        ,tty_orig,12,0,0,0,0);
@@ -360,13 +381,13 @@ error:
        
        if (ps >= 1) popsig();
        if (stdin != tty) fclose(tty);
-#ifdef VMS
+#ifdef OPENSSL_SYS_VMS
        status = sys$dassgn(channel);
 #endif
        return(!ok);
        }
 
-#else /* WIN16 */
+#else /* OPENSSL_SYS_WIN16 */
 
 int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify)
        { 
@@ -439,7 +460,7 @@ static void recsig(int i)
 #endif
        }
 
-#if defined(MSDOS) && !defined(WIN16)
+#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
 static int noecho_fgets(char *buf, int size, FILE *tty)
        {
        int i;