]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/getpass.c
Fix up abandon merge. Hallvard will holler if I get this wrong. :-)
[openldap] / libraries / liblutil / getpass.c
index 865c7d1885f7d6657cc0242179adcdc982406350..2ab791ea6e2633b778c5d7b1453e7de38bc3c308 100644 (file)
@@ -1,3 +1,8 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 /*
  * Copyright (c) 1992, 1993  Regents of the University of Michigan.
  * All rights reserved.
@@ -12,8 +17,6 @@
 
 #include "portable.h"
 
-#ifndef HAVE_GETPASS
-
 #include <stdio.h>
 
 #include <ac/stdlib.h>
@@ -25,6 +28,8 @@
 #include <ac/time.h>
 #include <ac/unistd.h>
 
+#ifdef NEED_GETPASSPHRASE
+
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
 
 #include <lber.h>
 #include <ldap.h>
-#include <ldap_defaults.h>
+
+#include "ldap_defaults.h"
 
 char *
-getpass( const char *prompt )
+lutil_getpass( const char *prompt )
 {
 #if !defined(HAVE_POSIX_TERMIOS) && !defined(HAVE_SGTTY_H)
        static char buf[256];
        int i, c;
 
+       if( prompt == NULL ) prompt = "Password: ";
+
 #ifdef DEBUG
        if (debug & D_TRACE)
                printf("->getpass(%s)\n", prompt);
 #endif
+
        printf("%s", prompt);
        i = 0;
        while ( (c = getch()) != EOF && c != '\n' && c != '\r' )
@@ -67,6 +76,8 @@ getpass( const char *prompt )
        FILE *fi;
        RETSIGTYPE (*sig)( int sig );
 
+       if( prompt == NULL ) prompt = "Password: ";
+
 #ifdef DEBUG
        if (debug & D_TRACE)
                printf("->getpass(%s)\n", prompt);
@@ -149,4 +160,4 @@ getpass( const char *prompt )
 #endif
 }
 
-#endif /* !HAVE_GETPASS */
+#endif /* !NEED_GETPASSPHRASE */