extend prompt functions to take a timeout parameter
[vlock.git] / src / vlock.h
blob6cac32ce0386bcf3c1df57cf4141a66c0c5c03ba
1 /* vlock.h -- main header file for vlock, the VT locking program for linux
3 * This program is copyright (C) 2007 Frank Benkstein, and is free
4 * software which is freely distributable under the terms of the
5 * GNU General Public License version 2, included as the file COPYING in this
6 * distribution. It is NOT public domain software, and any
7 * redistribution not permitted by the GNU General Public License is
8 * expressly forbidden without prior written permission from
9 * the author.
13 /* name of the virtual console device */
14 #ifdef __FreeBSD__
15 #define CONSOLE "/dev/ttyv0"
16 #else
17 #define CONSOLE "/dev/tty0"
18 #endif
19 /* template for the device of a given virtual console */
20 #ifdef __FreeBSD__
21 #define VTNAME "/dev/ttyv%x"
22 #else
23 #define VTNAME "/dev/tty%d"
24 #endif
26 /* magic characters to clear the current terminal */
27 #define CLEAR_SCREEN "\033[H\033[J"
29 /* hard coded paths */
30 #define VLOCK_ALL PREFIX "/sbin/vlock-all"
31 #define VLOCK_CURRENT PREFIX "/sbin/vlock-current"
32 #define VLOCK_NEW PREFIX "/sbin/vlock-new"
34 /* Try to authenticate the user. When the user is successfully authenticated
35 * this function returns 1. When the authentication fails for whatever reason
36 * the function returns 0.
38 int auth(const char *user);
40 /* Prompt for a string with the given message. The string is returned if
41 * successfully read, otherwise NULL. The caller is responsible for freeing
42 * the resulting buffer. */
43 char *prompt(const char *msg, const struct timespec *timeout);
45 /* Prompt for a string with the given message without echoing input characters
46 * The string is returned if successfully read, NULL otherwise. The caller is
47 * responsible for freeing the resulting buffer. */
48 char *prompt_echo_off(const char *msg, const struct timespec *timeout);