aboutsummaryrefslogtreecommitdiff
path: root/examples/tty_conv.c
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-02-10 16:47:05 +0800
committerYuqian Yang <crupest@crupest.life>2025-02-28 23:23:22 +0800
commit1e674b2f6ee96f7ae21bb8dc437249e404323169 (patch)
treea21af74409a345d57824f009cf84e9b764d234d4 /examples/tty_conv.c
parentcb448e6474f53e4e40bfb594597156dc6256605c (diff)
downloadpam-1e674b2f6ee96f7ae21bb8dc437249e404323169.tar.gz
pam-1e674b2f6ee96f7ae21bb8dc437249e404323169.tar.bz2
pam-1e674b2f6ee96f7ae21bb8dc437249e404323169.zip
(GNU/Hurd) port Linux-specific api.
Diffstat (limited to 'examples/tty_conv.c')
-rw-r--r--examples/tty_conv.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/examples/tty_conv.c b/examples/tty_conv.c
index 59bbb3b3..0a7af97c 100644
--- a/examples/tty_conv.c
+++ b/examples/tty_conv.c
@@ -8,7 +8,6 @@
#include <unistd.h>
#include <termios.h>
#include <security/pam_appl.h>
-#include <sys/ioctl.h>
/***************************************
* @brief echo off/on
@@ -18,7 +17,7 @@
static void echoOff(int fd, int off)
{
struct termios tty;
- if (ioctl(fd, TCGETA, &tty) < 0)
+ if (tcgetattr(fd, &tty) < 0)
{
fprintf(stderr, "TCGETA failed: %s\n", strerror(errno));
return;
@@ -27,7 +26,7 @@ static void echoOff(int fd, int off)
if (off)
{
tty.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
- if (ioctl(fd, TCSETAF, &tty) < 0)
+ if (tcsetattr(fd, TCSAFLUSH, &tty) < 0)
{
fprintf(stderr, "TCSETAF failed: %s\n", strerror(errno));
}
@@ -35,7 +34,7 @@ static void echoOff(int fd, int off)
else
{
tty.c_lflag |= (ECHO | ECHOE | ECHOK | ECHONL);
- if (ioctl(fd, TCSETAW, &tty) < 0)
+ if (tcsetattr(fd, TCSADRAIN, &tty) < 0)
{
fprintf(stderr, "TCSETAW failed: %s\n", strerror(errno));
}