Commit fecbc792 authored by Ondřej Surý's avatar Ondřej Surý
Browse files

Remove isc_keyboard family of functions as they were not used anywhere

parent 6034664e
......@@ -28,7 +28,6 @@
#include <isc/buffer.h>
#include <isc/commandline.h>
#include <isc/file.h>
#include <isc/keyboard.h>
#include <isc/mem.h>
#include <isc/net.h>
#include <isc/print.h>
......
......@@ -20,7 +20,6 @@
#include <isc/base64.h>
#include <isc/buffer.h>
#include <isc/file.h>
#include <isc/keyboard.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/result.h>
......@@ -192,4 +191,3 @@ write_key_file(const char *keyfile, const char *user,
fatal("fclose(%s) failed\n", keyfile);
fprintf(stderr, "wrote key file \"%s\"\n", keyfile);
}
......@@ -31,7 +31,6 @@
#include <isc/buffer.h>
#include <isc/commandline.h>
#include <isc/file.h>
#include <isc/keyboard.h>
#include <isc/mem.h>
#include <isc/net.h>
#include <isc/print.h>
......
......@@ -52,7 +52,6 @@ XTARGETS = adb_test@EXEEXT@ \
hash_test@EXEEXT@ \
fsaccess_test@EXEEXT@ \
inter_test@EXEEXT@ \
keyboard_test@EXEEXT@ \
lex_test@EXEEXT@ \
lfsr_test@EXEEXT@ \
log_test@EXEEXT@ \
......@@ -83,7 +82,6 @@ XSRCS = adb_test.c \
fsaccess_test.c \
gsstest.c \
inter_test.c \
keyboard_test.c \
lex_test.c \
lfsr_test.c \
log_test.c \
......@@ -241,10 +239,6 @@ inter_test@EXEEXT@: inter_test.@O@ ${ISCDEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ inter_test.@O@ \
${ISCLIBS} ${LIBS}
keyboard_test@EXEEXT@: keyboard_test.@O@ ${ISCDEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ keyboard_test.@O@ \
${ISCLIBS} ${LIBS}
sig0_test@EXEEXT@: sig0_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ sig0_test.@O@ \
${DNSLIBS} ${ISCLIBS} ${LIBS}
......
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
/*! \file */
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <isc/keyboard.h>
#include <isc/print.h>
#include <isc/util.h>
static void
CHECK(const char *msg, isc_result_t result) {
if (result != ISC_R_SUCCESS) {
printf("FAILURE: %s: %s\n", msg, isc_result_totext(result));
exit(1);
}
}
int
main(int argc, char **argv) {
isc_keyboard_t kbd;
unsigned char c;
isc_result_t res;
unsigned int count;
UNUSED(argc);
UNUSED(argv);
printf("Type Q to exit.\n");
res = isc_keyboard_open(&kbd);
CHECK("isc_keyboard_open()", res);
c = 'x';
count = 0;
while (res == ISC_R_SUCCESS && c != 'Q') {
res = isc_keyboard_getchar(&kbd, &c);
printf(".");
fflush(stdout);
count++;
if (count % 64 == 0)
printf("\r\n");
}
printf("\r\n");
if (res != ISC_R_SUCCESS) {
printf("FAILURE: keyboard getchar failed: %s\r\n",
isc_result_totext(res));
goto errout;
}
errout:
res = isc_keyboard_close(&kbd, 3);
CHECK("isc_keyboard_close()", res);
return (0);
}
......@@ -28,7 +28,7 @@ CWARNINGS =
UNIXOBJS = unix/pk11_api.@O@ \
unix/app.@O@ unix/dir.@O@ unix/errno.@O@ \
unix/errno2result.@O@ unix/file.@O@ unix/fsaccess.@O@ \
unix/interfaceiter.@O@ unix/keyboard.@O@ unix/meminfo.@O@ \
unix/interfaceiter.@O@ unix/meminfo.@O@ \
unix/net.@O@ unix/os.@O@ unix/resource.@O@ unix/socket.@O@ \
unix/stdio.@O@ unix/stdtime.@O@ \
unix/syslog.@O@ unix/time.@O@
......
......@@ -24,14 +24,14 @@ CWARNINGS =
OBJS = pk11_api.@O@ \
app.@O@ dir.@O@ errno.@O@ errno2result.@O@ \
file.@O@ fsaccess.@O@ interfaceiter.@O@ \
keyboard.@O@ meminfo.@O@ \
meminfo.@O@ \
net.@O@ os.@O@ resource.@O@ socket.@O@ stdio.@O@ stdtime.@O@ \
syslog.@O@ time.@O@
# Alphabetically
SRCS = pk11_api.c \
app.c dir.c errno.c errno2result.c \
file.c fsaccess.c interfaceiter.c keyboard.c meminfo.c \
file.c fsaccess.c interfaceiter.c meminfo.c \
net.c os.c resource.c socket.c stdio.c stdtime.c \
syslog.c time.c
......
......@@ -13,7 +13,7 @@ top_srcdir = @top_srcdir@
VERSION=@BIND9_VERSION@
HEADERS = dir.h keyboard.h net.h netdb.h offset.h stat.h \
HEADERS = dir.h net.h netdb.h offset.h stat.h \
stdtime.h strerror.h syslog.h time.h
SUBDIRS =
......
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#ifndef ISC_KEYBOARD_H
#define ISC_KEYBOARD_H 1
/*! \file */
#include <termios.h>
#include <stdbool.h>
#include <isc/lang.h>
#include <isc/result.h>
ISC_LANG_BEGINDECLS
typedef struct {
int fd;
struct termios saved_mode;
isc_result_t result;
} isc_keyboard_t;
isc_result_t
isc_keyboard_open(isc_keyboard_t *keyboard);
isc_result_t
isc_keyboard_close(isc_keyboard_t *keyboard, unsigned int sleepseconds);
isc_result_t
isc_keyboard_getchar(isc_keyboard_t *keyboard, unsigned char *cp);
bool
isc_keyboard_canceled(isc_keyboard_t *keyboard);
ISC_LANG_ENDDECLS
#endif /* ISC_KEYBOARD_H */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#include <config.h>
#include <stdbool.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <isc/keyboard.h>
#include <isc/util.h>
isc_result_t
isc_keyboard_open(isc_keyboard_t *keyboard) {
int fd;
isc_result_t ret;
struct termios current_mode;
REQUIRE(keyboard != NULL);
fd = open("/dev/tty", O_RDONLY, 0);
if (fd < 0)
return (ISC_R_IOERROR);
keyboard->fd = fd;
if (tcgetattr(fd, &keyboard->saved_mode) < 0) {
ret = ISC_R_IOERROR;
goto errout;
}
current_mode = keyboard->saved_mode;
current_mode.c_iflag &=
~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
current_mode.c_oflag &= ~OPOST;
current_mode.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
current_mode.c_cflag &= ~(CSIZE|PARENB);
current_mode.c_cflag |= CS8;
current_mode.c_cc[VMIN] = 1;
current_mode.c_cc[VTIME] = 0;
if (tcsetattr(fd, TCSAFLUSH, &current_mode) < 0) {
ret = ISC_R_IOERROR;
goto errout;
}
keyboard->result = ISC_R_SUCCESS;
return (ISC_R_SUCCESS);
errout:
close (fd);
return (ret);
}
isc_result_t
isc_keyboard_close(isc_keyboard_t *keyboard, unsigned int sleeptime) {
REQUIRE(keyboard != NULL);
if (sleeptime > 0 && keyboard->result != ISC_R_CANCELED)
(void)sleep(sleeptime);
(void)tcsetattr(keyboard->fd, TCSAFLUSH, &keyboard->saved_mode);
(void)close(keyboard->fd);
keyboard->fd = -1;
return (ISC_R_SUCCESS);
}
isc_result_t
isc_keyboard_getchar(isc_keyboard_t *keyboard, unsigned char *cp) {
ssize_t cc;
unsigned char c;
cc_t *controlchars;
REQUIRE(keyboard != NULL);
REQUIRE(cp != NULL);
cc = read(keyboard->fd, &c, 1);
if (cc < 0) {
keyboard->result = ISC_R_IOERROR;
return (keyboard->result);
}
controlchars = keyboard->saved_mode.c_cc;
if (c == controlchars[VINTR] || c == controlchars[VQUIT]) {
keyboard->result = ISC_R_CANCELED;
return (keyboard->result);
}
*cp = c;
return (ISC_R_SUCCESS);
}
bool
isc_keyboard_canceled(isc_keyboard_t *keyboard) {
return (keyboard->result == ISC_R_CANCELED);
}
......@@ -13,7 +13,7 @@ top_srcdir = @top_srcdir@
VERSION=@BIND9_VERSION@
HEADERS = dir.h keyboard.h mutex.h net.h netdb.h once.h \
HEADERS = dir.h mutex.h net.h netdb.h once.h \
stat.h stdtime.h thread.h time.h
SUBDIRS =
......
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#ifndef ISC_KEYBOARD_H
#define ISC_KEYBOARD_H 1
#include <stdbool.h>
#include <isc/lang.h>
#include <isc/result.h>
ISC_LANG_BEGINDECLS
typedef struct {
int fd;
isc_result_t result;
} isc_keyboard_t;
isc_result_t
isc_keyboard_open(isc_keyboard_t *keyboard);
isc_result_t
isc_keyboard_close(isc_keyboard_t *keyboard, unsigned int sleepseconds);
isc_result_t
isc_keyboard_getchar(isc_keyboard_t *keyboard, unsigned char *cp);
bool
isc_keyboard_canceled(isc_keyboard_t *keyboard);
ISC_LANG_ENDDECLS
#endif /* ISC_KEYBOARD_H */
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#include <config.h>
#include <sys/types.h>
#include <windows.h>
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <io.h>
#include <isc/keyboard.h>
#include <isc/util.h>
isc_result_t
isc_keyboard_open(isc_keyboard_t *keyboard) {
int fd;
REQUIRE(keyboard != NULL);
fd = _fileno(stdin);
if (fd < 0)
return (ISC_R_IOERROR);
keyboard->fd = fd;
keyboard->result = ISC_R_SUCCESS;
return (ISC_R_SUCCESS);
}
isc_result_t
isc_keyboard_close(isc_keyboard_t *keyboard, unsigned int sleeptime) {
REQUIRE(keyboard != NULL);
if (sleeptime > 0 && keyboard->result != ISC_R_CANCELED)
(void)Sleep(sleeptime*1000);
keyboard->fd = -1;
return (ISC_R_SUCCESS);
}
isc_result_t
isc_keyboard_getchar(isc_keyboard_t *keyboard, unsigned char *cp) {
ssize_t cc;
unsigned char c;
REQUIRE(keyboard != NULL);
REQUIRE(cp != NULL);
cc = read(keyboard->fd, &c, 1);
if (cc < 0) {
keyboard->result = ISC_R_IOERROR;
return (keyboard->result);
}
*cp = c;
return (ISC_R_SUCCESS);
}
bool
isc_keyboard_canceled(isc_keyboard_t *keyboard) {
return (keyboard->result == ISC_R_CANCELED);
}
......@@ -318,10 +318,6 @@ isc_interfaceiter_next
isc_interval_iszero
isc_interval_set
isc_iterated_hash
isc_keyboard_canceled
isc_keyboard_close
isc_keyboard_getchar
isc_keyboard_open
isc_lex_close
isc_lex_create
isc_lex_destroy
......
......@@ -313,9 +313,6 @@
<ClInclude Include="include\isc\ipv6.h">
<Filter>Win32 Header Files</Filter>
</ClInclude>
<ClInclude Include="include\isc\keyboard.h">
<Filter>Win32 Header Files</Filter>
</ClInclude>
<ClInclude Include="include\isc\mutex.h">
<Filter>Win32 Header Files</Filter>
</ClInclude>
......@@ -422,9 +419,6 @@
<ClCompile Include="ipv6.c">
<Filter>Win32 Source Files</Filter>
</ClCompile>
<ClCompile Include="keyboard.c">
<Filter>Win32 Source Files</Filter>
</ClCompile>
<ClCompile Include="meminfo.c">
<Filter>Win32 Source Files</Filter>
</ClCompile>
......
......@@ -388,7 +388,6 @@ copy InstallFiles ..\Build\Release\
<ClInclude Include="include\isc\condition.h" />
<ClInclude Include="include\isc\dir.h" />
<ClInclude Include="include\isc\ipv6.h" />
<ClInclude Include="include\isc\keyboard.h" />
<ClInclude Include="include\isc\mutex.h" />
<ClInclude Include="include\isc\net.h" />
<ClInclude Include="include\isc\netdb.h" />
......@@ -488,7 +487,6 @@ copy InstallFiles ..\Build\Release\
<ClCompile Include="fsaccess.c" />
<ClCompile Include="interfaceiter.c" />
<ClCompile Include="ipv6.c" />
<ClCompile Include="keyboard.c" />
<ClCompile Include="meminfo.c" />
<ClCompile Include="net.c" />
<ClCompile Include="ntpaths.c" />
......
......@@ -314,7 +314,6 @@
./bin/tests/optional/gsstest.c C 2018
./bin/tests/optional/hash_test.c C 2000,2001,2004,2005,2006,2007,2014,2015,2016,2017,2018
./bin/tests/optional/inter_test.c C 2000,2001,2003,2004,2005,2007,2008,2015,2016,2018
./bin/tests/optional/keyboard_test.c C 2000,2001,2004,2005,2007,2015,2016,2018
./bin/tests/optional/lex_test.c C 1998,1999,2000,2001,2004,2005,2007,2015,2016,2018
./bin/tests/optional/lfsr_test.c C 1999,2000,2001,2004,2005,2007,2015,2016,2018
./bin/tests/optional/log_test.c C 1999,2000,2001,2004,2007,2011,2014,2015,2016,2018
......@@ -3497,7 +3496,6 @@
./lib/isc/unix/fsaccess.c C 2000,2001,2004,2005,2006,2007,2016,2018
./lib/isc/unix/ifiter_getifaddrs.c C 2003,2004,2005,2007,2008,2009,2014,2016,2018
./lib/isc/unix/include/isc/dir.h C 1999,2000,2001,2004,2005,2007,2016,2018
./lib/isc/unix/include/isc/keyboard.h C 2000,2001,2004,2005,2007,2016,2018
./lib/isc/unix/include/isc/net.h C 1999,2000,2001,2002,2003,2004,2005,2007,2008,2012,2013,2014,2016,2017,2018
./lib/isc/unix/include/isc/netdb.h C 1999,2000,2001,2004,2005,2007,2016,2018
./lib/isc/unix/include/isc/offset.h C 2000,2001,2004,2005,2007,2008,2016,2018
......@@ -3507,7 +3505,6 @@
./lib/isc/unix/include/isc/time.h C 1998,1999,2000,2001,2004,2005,2006,2007,2008,2009,2012,2014,2015,2016,2017,2018
./lib/isc/unix/include/pkcs11/cryptoki.h X 2014,2018
./lib/isc/unix/interfaceiter.c C 1999,2000,2001,2002,2003,2004,2005,2007,2008,2014,2016,2017,2018
./lib/isc/unix/keyboard.c C 2000,2001,2004,2007,2016,2018
./lib/isc/unix/meminfo.c C 2015,2016,2018
./lib/isc/unix/net.c C 1999,2000,2001,2002,2003,2004,2005,2007,2008,2012,2013,2014,2015,2016,2017,2018
./lib/isc/unix/os.c C 2000,2001,2004,2005,2007,2016,2018
......@@ -3536,7 +3533,6 @@
./lib/isc/win32/include/isc/condition.h C 1998,1999,2000,2001,2004,2007,2016,2018
./lib/isc/win32/include/isc/dir.h C 1999,2000,2001,2004,2007,2016,2018
./lib/isc/win32/include/isc/ipv6.h C 1999,2000,2001,2002,2004,2005,2007,2011,2012,2016,2018
./lib/isc/win32/include/isc/keyboard.h C 2000,2001,2004,2007,2016,2018
./lib/isc/win32/include/isc/mutex.h C 1998,1999,2000,2001,2004,2007,2008,2009,2016,2018
./lib/isc/win32/include/isc/net.h C 1999,2000,2001,2002,2003,2004,2005,2007,2008,2012,2013,2016,2017,2018
./lib/isc/win32/include/isc/netdb.h C 1999,2000,2001,2004,2007,2016,2018
......@@ -3555,7 +3551,6 @@
./lib/isc/win32/include/pkcs11/cryptoki.h X 2014,2018
./lib/isc/win32/interfaceiter.c C 1999,2000,2001,2004,2007,2008,2009,2013,2014,2015,2016,2018
./lib/isc/win32/ipv6.c C 1999,2000,2001,2004,2007,2016,2018
./lib/isc/win32/keyboard.c C 2000,2001,2004,2007,2016,2018
./lib/isc/win32/libgen.h C 2009,2016,2018
./lib/isc/win32/libisc.def.exclude X 2015,2017,2018
./lib/isc/win32/libisc.def.in X 2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment