4 * Copyright (C) 2004, 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.c,v 1.7 2007/06/19 23:47:19 tbox Exp */
24 #include <sys/types.h>
36 #include <isc/keyboard.h>
40 isc_keyboard_open(isc_keyboard_t
*keyboard
) {
43 REQUIRE(keyboard
!= NULL
);
47 return (ISC_R_IOERROR
);
51 keyboard
->result
= ISC_R_SUCCESS
;
53 return (ISC_R_SUCCESS
);
57 isc_keyboard_close(isc_keyboard_t
*keyboard
, unsigned int sleeptime
) {
58 REQUIRE(keyboard
!= NULL
);
60 if (sleeptime
> 0 && keyboard
->result
!= ISC_R_CANCELED
)
61 (void)Sleep(sleeptime
*1000);
65 return (ISC_R_SUCCESS
);
69 isc_keyboard_getchar(isc_keyboard_t
*keyboard
, unsigned char *cp
) {
73 REQUIRE(keyboard
!= NULL
);
76 cc
= read(keyboard
->fd
, &c
, 1);
78 keyboard
->result
= ISC_R_IOERROR
;
79 return (keyboard
->result
);
84 return (ISC_R_SUCCESS
);
88 isc_keyboard_canceled(isc_keyboard_t
*keyboard
) {
89 return (ISC_TF(keyboard
->result
== ISC_R_CANCELED
));