From b3a4268e444c8e7347042acdae2ee934daff65ad Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Mon, 9 Feb 2009 17:58:22 +0000 Subject: [PATCH] Remove unused file git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21921 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/promptusr.c | 161 ------------------------------------ 1 file changed, 161 deletions(-) delete mode 100644 src/lib/krb5/os/promptusr.c diff --git a/src/lib/krb5/os/promptusr.c b/src/lib/krb5/os/promptusr.c deleted file mode 100644 index 1664a481e..000000000 --- a/src/lib/krb5/os/promptusr.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * promptusr.c --- prompt user for input/output - */ - -#include "k5-int.h" -#if !defined(_WIN32) - -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include -#include -#include - -typedef struct _krb5_uio { - krb5_magic magic; - int flags; - char * prompt; - char * response; - struct _krb5_uio *next; -} *krb5_uio; - -#define KRB5_UIO_GETRESPONSE 0x0001 -#define KRB5_UIO_ECHORESPONSE 0x0002 -#define KRB5_UIO_FREE_PROMPT 0x0004 - -static jmp_buf pwd_jump; - -static krb5_sigtype -intr_routine(int signo) -{ - longjmp(pwd_jump, 1); - /*NOTREACHED*/ -} - -krb5_error_code -krb5_os_get_tty_uio(krb5_context context, krb5_uio uio) -{ - volatile krb5_error_code retval; - krb5_sigtype (*volatile ointrfunc)(); - krb5_uio p; - struct termios echo_control, save_control; - int fd; - char read_string[BUFSIZ]; - char *cp; - int ch; - - /* get the file descriptor associated with stdin */ - fd=fileno(stdin); - - if (tcgetattr(fd, &echo_control) == -1) - return errno; - - save_control = echo_control; - echo_control.c_lflag &= ~(ECHO|ECHONL); - - if (setjmp(pwd_jump)) { - retval = KRB5_LIBOS_PWDINTR; /* we were interrupted... */ - goto cleanup; - } - /* save intrfunc */ - ointrfunc = signal(SIGINT, intr_routine); - - for (p = uio; p; p = p->next) { - if (p->prompt) { - fputs(p->prompt, stdout); - fflush(stdout); - } - if ((p->flags & KRB5_UIO_GETRESPONSE) == 0) - continue; - - if ((p->flags & KRB5_UIO_ECHORESPONSE) == 0) - if (tcsetattr(fd, TCSANOW, &echo_control) == -1) - return errno; - - if (fgets(read_string, sizeof(read_string), stdin) == NULL) { - (void) putchar('\n'); - retval = KRB5_LIBOS_CANTREADPWD; - goto cleanup; - } - - /* replace newline with null */ - if ((cp = strchr(read_string, '\n'))) - *cp = '\0'; - else /* flush rest of input line */ - do { - ch = getchar(); - } while (ch != EOF && ch != '\n'); - read_string[sizeof(read_string)-1] = 0; - - if ((p->response = strdup(read_string)) == NULL) { - errno = ENOMEM; - goto cleanup; - } - - if ((p->flags & KRB5_UIO_ECHORESPONSE) == 0) { - (void) putchar('\n'); - if (tcsetattr(fd, TCSANOW, &save_control) == -1) { - retval = errno; - goto cleanup; - } - } - } - retval = 0; - - cleanup: - (void) signal(SIGINT, ointrfunc); - if (retval) { - for (p = uio; p; p = p->next) { - if (p->response) { - memset(p->response, 0, strlen(p->response)); - free(p->response); - p->response = 0; - } - } - } - memset(read_string, 0, sizeof(read_string)); - tcsetattr(fd, TCSANOW, &save_control); - return retval; -} - -void -krb5_free_uio(krb5_context context, krb5_uio uio) -{ - krb5_uio p, next; - - if (uio == NULL) - return; - for (p = uio; p; p = next) { - next = p->next; - if (p->prompt && (p->flags & KRB5_UIO_FREE_PROMPT)) - free(p->prompt); - if (p->response) - free(p->response); - free(p); - } -} - -#ifdef TEST_DRIVER - -struct _krb5_uio uio_a = { 0, KRB5_UIO_GETRESPONSE, "Password 1: " }; -struct _krb5_uio uio_b = { 0, KRB5_UIO_GETRESPONSE | - KRB5_UIO_ECHORESPONSE, "Password 2: " }; -struct _krb5_uio uio_c = { 0, KRB5_UIO_GETRESPONSE, "Password 3: " }; - - -void -main(int argc, char **argv) -{ - uio_a.next = &uio_b; - uio_b.next = &uio_c; - - krb5_os_get_tty_uio(0, &uio_a); - exit(0); -} - -#endif - -#endif /* !_MSODS */ -- 2.26.2