#ifndef _INTERACT_H_76cf6375_ #define _INTERACT_H_76cf6375_ /* This file is in the public domain. */ #include /* * Utility routines for interacting with the user. */ /* * Prompt for and read a string from the user. * * get_with_prompt(s,l,f,fmt,...) treats fmt and the following args a * la printf, to generate the prompt. f is a bitmask holding zero or * more of the GWP_* flags; s and l receive the pointer and length to * the entered string (no terminating \0 is supplied). * * GWP_DEV_TTY says to use /dev/tty for the interaction; the default is * to read from fd 0 and write to fd 1. (These are the fds behind * stdin and stdout, but stdin and stdout themselves are not used; * this code use file descriptor calls, not stdio calls.) * * GWP_NO_ECHO says to turn echo off while reading the input. * * GWP_ESC_BLK changes the above; instead of fmt and the following args * being a printf-style format and arguments, fmt is a pointer to the * prompt string and one int follows, which is its length. This is * the processed with print_escaped (see escaped.h) to produce the * prompt. */ extern void get_with_prompt(char **, int *, unsigned int, const char *, ...) __attribute__((__format__(__printf__,4,5))); #define GWP_DEV_TTY 0x00000001 #define GWP_NO_ECHO 0x00000002 #define GWP_ESC_BLK 0x00000004 /* * Prompt the user to make a choice from a list of alternatives. * * prompted_choice(s,N,c0,c1,...,cN-1) prompts with s, then accepts a * response, which must be one of c0 through cN-1. (If it's not, the * prompt is just reissued.) If the entered string is cI, the return * value is I. */ extern int prompted_choice(const char *, int, ...); #endif