Make all configuration macros available for application by making
[openssl.git] / crypto / des / read_pwd.c
index 24e814ec76e4994e51ed1ec5c6eafb142383d483..b9d8029b8eac41664d77d9930e60936985b657b7 100644 (file)
  */
 
 #if !defined(MSDOS) && !defined(VMS) && !defined(WIN32)
-#include <unistd.h>
+#include <openssl/opensslconf.h>
+#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)
 #include "des_locl.h"
 #include "cryptlib.h"
 #include <signal.h>
+#include <stdio.h>
 #include <string.h>
 #include <setjmp.h>
 #include <errno.h>
 
+#ifdef VMS                     /* prototypes for sys$whatever */
+#include <starlet.h>
+#ifdef __DECC
+#pragma message disable DOLLARID
+#endif
+#endif
+
 #ifdef WIN_CONSOLE_BUG
 #include <windows.h>
 #include <wincon.h>
 #undef  SGTTY
 #endif
 
-#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS)
+#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(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(MSDOS) && !defined(VMS) && !defined(MAC_OS_pre_X)
 #include <sys/ioctl.h>
 #endif
 
-#ifdef MSDOS
+#if defined(MSDOS) && !defined(__CYGWIN32__)
 #include <conio.h>
 #define fgets(a,b,c) noecho_fgets(a,b,c)
 #endif
@@ -165,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
@@ -179,11 +201,7 @@ static int noecho_fgets(char *buf, int size, FILE *tty);
 #ifdef SIGACTION
  static struct sigaction savsig[NX509_SIG];
 #else
-# ifndef NOPROTO
   static void (*savsig[NX509_SIG])(int );
-# else
-  static void (*savsig[NX509_SIG])();
-# endif
 #endif
 static jmp_buf save;
 
@@ -247,13 +265,17 @@ 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 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 (TTY_get(fileno(tty),&tty_orig) == -1)
@@ -275,10 +297,10 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
        memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig));
 #endif
 #ifdef VMS
-       status = SYS$ASSIGN(&terminal,&channel,0,0);
+       status = sys$assign(&terminal,&channel,0,0);
        if (status != SS$_NORMAL)
                return(-1);
-       status=SYS$QIOW(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0);
+       status=sys$qiow(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0);
        if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
                return(-1);
 #endif
@@ -292,13 +314,17 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
 
 #if defined(TTY_set) && !defined(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
+#endif
 #ifdef VMS
        tty_new[0] = tty_orig[0];
        tty_new[1] = tty_orig[1] | TT$M_NOECHO;
        tty_new[2] = tty_orig[2];
-       status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);
+       status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);
        if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
                return(-1);
 #endif
@@ -344,19 +370,19 @@ 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(VMS)
        if (ps >= 2) TTY_set(fileno(tty),&tty_orig);
 #endif
 #ifdef VMS
        if (ps >= 2)
-               status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0
+               status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0
                        ,tty_orig,12,0,0,0,0);
 #endif
        
        if (ps >= 1) popsig();
        if (stdin != tty) fclose(tty);
 #ifdef VMS
-       status = SYS$DASSGN(channel);
+       status = sys$dassgn(channel);
 #endif
        return(!ok);
        }
@@ -468,11 +494,11 @@ static int noecho_fgets(char *buf, int size, FILE *tty)
  * usually a CR so this can be trouble. No STDIO fix seems to work but
  * flushing the console appears to do the trick.
  */
-                {
-                        HANDLE inh;
-                        inh = GetStdHandle(STD_INPUT_HANDLE);
-                        FlushConsoleInputBuffer(inh);
-                }
+               {
+                       HANDLE inh;
+                       inh = GetStdHandle(STD_INPUT_HANDLE);
+                       FlushConsoleInputBuffer(inh);
+               }
 #endif
        return(strlen(buf));
        }