[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS shishi/lib
From: |
shishi-commit |
Subject: |
CVS shishi/lib |
Date: |
Thu, 02 Sep 2004 21:49:20 +0200 |
Update of /home/cvs/shishi/lib
In directory dopio:/tmp/cvs-serv5677
Modified Files:
password.c
Log Message:
Use getpass.
--- /home/cvs/shishi/lib/password.c 2004/02/03 16:06:27 1.16
+++ /home/cvs/shishi/lib/password.c 2004/09/02 19:49:19 1.17
@@ -1,5 +1,5 @@
-/* password.c get passwords from user
- * Copyright (C) 2002, 2003 Simon Josefsson
+/* password.c --- Get passwords from user.
+ * Copyright (C) 2002, 2003, 2004 Simon Josefsson
*
* This file is part of Shishi.
*
@@ -23,82 +23,12 @@
#include "internal.h"
+#include "getpass.h"
+
#ifdef WITH_STRINGPREP
#include <stringprep.h>
#endif
-#if defined (HAVE_TERMIOS_H)
-
-#include <termios.h>
-
-static int
-tty_set_echo (int echo)
-{
- struct termios termios_p;
- int fd = fileno (stdin);
-
- if (tcgetattr (fd, &termios_p) != 0)
- return SHISHI_TTY_ERROR;
-
- if (echo)
- termios_p.c_lflag |= ECHO;
- else
- termios_p.c_lflag &= ~ECHO;
-
- if (tcsetattr (fd, TCSANOW, &termios_p) != 0)
- return SHISHI_TTY_ERROR;
-
- return SHISHI_OK;
-}
-
-#else
-
-mail simon @ josefsson.org and tell what system this is
-#endif
-static RETSIGTYPE
-tty_echo (int signum)
-{
- tty_set_echo (1);
-}
-
-static RETSIGTYPE
-tty_noecho (int signum)
-{
- tty_set_echo (0);
-}
-
-static int
-read_password (char **s)
-{
- char buf[BUFSIZ];
- int rc;
-
- rc = tty_set_echo (0);
- if (rc != SHISHI_OK)
- return rc;
-
-#ifdef HAVE_SIGNAL
- signal (SIGQUIT, tty_echo);
- signal (SIGCONT, tty_noecho);
-#endif
-
- fgets (buf, sizeof (buf), stdin);
- buf[strlen (buf) - 1] = '\0';
-
- *s = strdup (buf);
-
-#ifdef HAVE_SIGNAL
- signal (SIGQUIT, SIG_DFL);
- signal (SIGCONT, SIG_DFL);
-#endif
-
- rc = tty_set_echo (1);
- if (rc != SHISHI_OK)
- return rc;
-
- return SHISHI_OK;
-}
-
/**
* shishi_prompt_password:
* @handle: shishi handle as allocated by shishi_init().
@@ -133,7 +63,9 @@
fflush (stdout);
va_end (ap);
- rc = read_password (s);
+ p = getpass ("");
+
+ *s = xstrdup (p);
printf ("\n");
- CVS shishi/lib, shishi-commit, 2004/09/02
- CVS shishi/lib,
shishi-commit <=
- CVS shishi/lib, shishi-commit, 2004/09/02
- CVS shishi/lib, shishi-commit, 2004/09/06
- CVS shishi/lib, shishi-commit, 2004/09/08
- CVS shishi/lib, shishi-commit, 2004/09/08
- CVS shishi/lib, shishi-commit, 2004/09/10
- CVS shishi/lib, shishi-commit, 2004/09/10
- CVS shishi/lib, shishi-commit, 2004/09/10
- CVS shishi/lib, shishi-commit, 2004/09/10
- CVS shishi/lib, shishi-commit, 2004/09/10
- CVS shishi/lib, shishi-commit, 2004/09/10