~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/get_password.c

  • Committer: Stewart Smith
  • Date: 2008-06-30 05:33:25 UTC
  • mfrom: (12.2.8 drizzle)
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: stewart@flamingspork.com-20080630053325-mwrv6bjaufcpvj8n
merge my work

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <pwd.h>
33
33
#endif /* HAVE_PWD_H */
34
34
#else /* ! HAVE_GETPASS */
35
 
#ifndef __WIN__
36
 
#include <sys/ioctl.h>
37
 
#ifdef HAVE_TERMIOS_H                           /* For tty-password */
38
 
#include        <termios.h>
39
 
#define TERMIO  struct termios
40
 
#else
41
 
#ifdef HAVE_TERMIO_H                            /* For tty-password */
42
 
#include        <termio.h>
43
 
#define TERMIO  struct termio
44
 
#else
45
 
#include        <sgtty.h>
46
 
#define TERMIO  struct sgttyb
47
 
#endif
48
 
#endif
49
 
#ifdef alpha_linux_port
50
 
#include <asm/ioctls.h>                         /* QQ; Fix this in configure */
51
 
#include <asm/termiobits.h>
52
 
#endif
53
 
#else
54
 
#include <conio.h>
55
 
#endif /* __WIN__ */
 
35
 #include <sys/ioctl.h>
 
36
 #ifdef HAVE_TERMIOS_H                          /* For tty-password */
 
37
  #include      <termios.h>
 
38
  #define TERMIO        struct termios
 
39
 #else
 
40
  #ifdef HAVE_TERMIO_H                          /* For tty-password */
 
41
   #include     <termio.h>
 
42
   #define TERMIO       struct termio
 
43
  #else
 
44
   #include     <sgtty.h>
 
45
   #define TERMIO       struct sgttyb
 
46
  #endif
 
47
 #endif
 
48
 #ifdef alpha_linux_port
 
49
  #include <asm/ioctls.h>                               /* QQ; Fix this in configure */
 
50
  #include <asm/termiobits.h>
 
51
 #endif
56
52
#endif /* HAVE_GETPASS */
57
53
 
58
54
#ifdef HAVE_GETPASSPHRASE                       /* For Solaris */
59
55
#define getpass(A) getpassphrase(A)
60
56
#endif
61
57
 
62
 
#ifdef __WIN__
63
 
/* were just going to fake it here and get input from
64
 
   the keyboard */
65
 
 
66
 
char *get_tty_password(const char *opt_message)
67
 
{
68
 
  char to[80];
69
 
  char *pos=to,*end=to+sizeof(to)-1;
70
 
  int i=0;
71
 
  DBUG_ENTER("get_tty_password");
72
 
  _cputs(opt_message ? opt_message : "Enter password: ");
73
 
  for (;;)
74
 
  {
75
 
    char tmp;
76
 
    tmp=_getch();
77
 
    if (tmp == '\b' || (int) tmp == 127)
78
 
    {
79
 
      if (pos != to)
80
 
      {
81
 
        _cputs("\b \b");
82
 
        pos--;
83
 
        continue;
84
 
      }
85
 
    }
86
 
    if (tmp == '\n' || tmp == '\r' || tmp == 3)
87
 
      break;
88
 
    if (iscntrl(tmp) || pos == end)
89
 
      continue;
90
 
    _cputs("*");
91
 
    *(pos++) = tmp;
92
 
  }
93
 
  while (pos != to && isspace(pos[-1]) == ' ')
94
 
    pos--;                                      /* Allow dummy space at end */
95
 
  *pos=0;
96
 
  _cputs("\n");
97
 
  DBUG_RETURN(my_strdup(to,MYF(MY_FAE)));
98
 
}
99
 
 
100
 
#else
101
 
 
102
 
 
103
58
#ifndef HAVE_GETPASS
104
59
/*
105
60
** Can't use fgets, because readline will get confused
208
163
  DBUG_RETURN(my_strdup(buff,MYF(MY_FAE)));
209
164
}
210
165
 
211
 
#endif /*__WIN__*/