Call//char *ptr = (char *) malloc (sizeof (char) *);//ptr = GET_PASSWD ();//printf ("\ n");
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
int Getch ()
{
int c=0;
struct Termios org_opts, new_opts;
int res=0;
-----Store Old Settings-----------
Res=tcgetattr (Stdin_fileno, &org_opts);
ASSERT (res==0);
----Set new terminal parms--------
memcpy (&new_opts, &org_opts, sizeof (new_opts));
New_opts.c_lflag &= ~ (Icanon | ECHO | Echoe | Echok | echonl | Echoprt | Echoke | ICRNL);
Tcsetattr (Stdin_fileno, Tcsanow, &new_opts);
C=getchar ();
------Restore old Settings---------
Res=tcsetattr (Stdin_fileno, Tcsanow, &org_opts);
ASSERT (res==0);
return C;
}
Char *get_passwd ()
{
int i;
Char *PD = (char *) malloc (sizeof (CHAR) * 128);
for (i = 0;; i++)
{
Pd[i] = Getch ();
if (pd[i] = = ' \ n ')
{
Pd[i] = ' + ';
Break
}
if (pd[i] = = 127)
{
printf ("\b \b");
i = i-2;
}
Else
{
printf ("*");
}
if (i<0)
{
pd[0]= ' + ';
}
}
return PD;
}