C-Menu
0.2.9
A User Interface Toolkit
Toggle main menu visibility
Loading...
Searching...
No Matches
/usr/local/src/C-Menu/src/enterstr.c
USERNAME=$(enterstr
"Enter your username: "
)
PASSWORD=$(enterstr
"Enter your password: "
)
echo
"Username: $USERNAME"
echo
"Password: $PASSWORD"
#include <
cm.h
>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
int
main
(
int
argc,
char
**argv) {
struct
termios new_tioctl;
char
in_str
[
BUFSIZ
];
char
*in_ptr =
in_str
;
char
*msg;
char
errmsg
[128];
if
(argc < 2)
strcpy(
errmsg
,
"input:"
);
else
strcpy(
errmsg
, argv[1]);
capture_shell_tioctl
();
sig_prog_mode
();
new_tioctl =
shell_tioctl
;
new_tioctl.c_lflag |= ICANON;
tcsetattr(2, TCSAFLUSH, &new_tioctl);
while
(1) {
msg =
errmsg
;
while
(*msg)
write(2, msg++, 1);
if
(read(2,
in_str
,
BUFSIZ
) > -1)
break
;
}
while
(*in_ptr)
write(1, in_ptr++, 1);
sig_dfl_mode
();
restore_shell_tioctl
();
exit(0);
}
cm.h
Headder for C-Menu API library, libcm.so.
errmsg
char errmsg[]
Definition
futil.c:84
BUFSIZ
#define BUFSIZ
Definition
view.h:29
in_str
char in_str[BUFSIZ+1]
Definition
iloan.c:20
main
int main(int argc, char **argv)
Capture the current terminal settings for later restoration.
Definition
enterchr.c:38
shell_tioctl
struct termios shell_tioctl
Definition
scriou.c:22
capture_shell_tioctl
bool capture_shell_tioctl()
capture_shell_tioctl() - capture shell terminal settings
Definition
scriou.c:43
restore_shell_tioctl
bool restore_shell_tioctl()
restore_shell_tioctl() - restore shell terminal settings
Definition
scriou.c:56
sig_dfl_mode
void sig_dfl_mode()
Set signal handlers to default behavior.
Definition
sig.c:42
sig_prog_mode
void sig_prog_mode()
Set up signal handlers for interrupt signals.
Definition
sig.c:62
Generated by
1.17.0