45#if defined(WIZARDSTOOLKIT_HAVE_TERMIOS_H)
53# define _T_FLUSH (TCSAFLUSH | TCSASOFT)
55# define _T_FLUSH (TCSAFLUSH)
58#if !defined(_POSIX_VDISABLE) && defined(VDISABLE)
59# define _POSIX_VDISABLE VDISABLE
62#define _PATH_TTY "/dev/tty"
81static volatile sig_atomic_t
132#if defined(WIZARDSTOOLKIT_HAVE_TERMIOS_H)
170 if ((input == -1) || (output == -1))
180 (void) sigemptyset(&action.sa_mask);
183 (void) sigaction(SIGALRM,&action,&sigalrm);
184 (void) sigaction(SIGHUP,&action,&sighup);
185 (void) sigaction(SIGINT,&action,&sigint);
186 (void) sigaction(SIGPIPE,&action,&sigpipe);
187 (void) sigaction(SIGQUIT,&action,&sigquit);
188 (void) sigaction(SIGTERM,&action,&sigterm);
189 (void) sigaction(SIGTSTP,&action,&sigtstp);
190 (void) sigaction(SIGTTIN,&action,&sigttin);
191 (void) sigaction(SIGTTOU,&action,&sigttou);
192 if ((input ==
STDIN_FILENO) || (tcgetattr(input,&save_attributes) != 0))
194 (void) memset(&attributes,0,
sizeof(attributes));
195 attributes.c_lflag|=ECHO;
205 attributes.c_lflag&=(~(ECHO | ECHONL));
207 if (attributes.c_cc[VSTATUS] != _POSIX_VDISABLE)
208 attributes.c_cc[VSTATUS]=_POSIX_VDISABLE;
210 (void) tcsetattr(input,
_T_FLUSH,&attributes);
212 if (((flags &
StdinMode) == 0) && (output != -1))
213 count=write(output,prompt,strlen(prompt));
216 while (((count=read(input,&c,1)) == 1) && (c !=
'\n') && (c !=
'\r'))
223 if (isalpha((
int) c) != 0)
226 c=(char) tolower((
int) c);
228 c=(
char) toupper((
int) c);
230 *p++=(
unsigned char) c;
233 *p=(
unsigned char)
'\0';
235 if ((attributes.c_lflag & ECHO) == 0)
236 count=write(output,
"\n",1);
240 if (memcmp(&attributes,&save_attributes,
sizeof(attributes)) != 0)
241 (void) tcsetattr(input,
_T_FLUSH,&save_attributes);
242 (void) sigaction(SIGALRM,&sigalrm,(
struct sigaction *) NULL);
243 (void) sigaction(SIGHUP,&sighup,(
struct sigaction *) NULL);
244 (void) sigaction(SIGINT,&sigint,(
struct sigaction *) NULL);
245 (void) sigaction(SIGQUIT,&sigquit,(
struct sigaction *) NULL);
246 (void) sigaction(SIGPIPE,&sigpipe,(
struct sigaction *) NULL);
247 (void) sigaction(SIGTERM,&sigterm,(
struct sigaction *) NULL);
248 (void) sigaction(SIGTSTP,&sigtstp,(
struct sigaction *) NULL);
249 (void) sigaction(SIGTTIN,&sigttin,(
struct sigaction *) NULL);
251 input=close(input)-1;
264 (void) fputs(prompt,stdout);
WizardExport WizardBooleanType ThrowWizardException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *format,...)
WizardExport ssize_t FormatLocaleString(char *string, const size_t length, const char *format,...)
#define GetWizardModule()
WizardExport void * CopyWizardMemory(void *destination, const void *source, const size_t size)
static WizardBooleanType GetPhrase(const char *prompt, PassphraseMode flags, StringInfo *phrase)
static volatile sig_atomic_t signal_number
WizardExport StringInfo * GetPassphrase(ExceptionInfo *exception)
WizardExport void SetStringInfoLength(StringInfo *string_info, const size_t length)
WizardExport size_t GetStringInfoLength(const StringInfo *string_info)
WizardExport StringInfo * AcquireStringInfo(const size_t length)
WizardExport int CompareStringInfo(const StringInfo *target, const StringInfo *source)
WizardExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
WizardExport ssize_t PrintWizardString(FILE *file, const char *format,...)
WizardExport StringInfo * DestroyStringInfo(StringInfo *string_info)
static int open_utf8(const char *path, int flags, mode_t mode)
WIZARDSTOOLKIT_RETSIGTYPE SignalHandler(int)