1 /* $NetBSD: keyboard_test.c,v 1.6 2014/12/10 04:37:53 christos Exp $ */
4 * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 2000, 2001 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: keyboard_test.c,v 1.13 2007/06/19 23:46:59 tbox Exp */
28 #include <isc/keyboard.h>
32 CHECK(const char *msg
, isc_result_t result
) {
33 if (result
!= ISC_R_SUCCESS
) {
34 printf("FAILURE: %s: %s\n", msg
, isc_result_totext(result
));
40 main(int argc
, char **argv
) {
49 printf("Type Q to exit.\n");
51 res
= isc_keyboard_open(&kbd
);
52 CHECK("isc_keyboard_open()", res
);
56 while (res
== ISC_R_SUCCESS
&& c
!= 'Q') {
57 res
= isc_keyboard_getchar(&kbd
, &c
);
65 if (res
!= ISC_R_SUCCESS
) {
66 printf("FAILURE: keyboard getchar failed: %s\r\n",
67 isc_result_totext(res
));
72 res
= isc_keyboard_close(&kbd
, 3);
73 CHECK("isc_keyboard_close()", res
);