NAME
getstr, getstab, getsearch - ask user to type a string
SYNOPSIS
#include <stdio.h>
char *getstr
(prompt,defalt,answer);
const char *prompt;
char *defalt,*answer;
int getstab
(prompt,table,defalt);
const char *prompt,**table,*defalt;
int getsearch (prompt,table,defalt);
const char *prompt,**table,*defalt;
DESCRIPTION
Getstr will print prompt as a message to the user, and ask
for the
user to type an input string. The string is then copied into
answer. If the user types just a carriage return, then the
string
defalt is copied into answer. Answer and defalt may be the
same
string; in this case, the default value will be the original
contents of answer.
Getstab will print prompt as a
message to the user, and ask for an
input string. The string typed will be sought within the
string
table table, and, if found, the index of this string will be
returned. If the user types just a carriage return, then the
string defalt will be assumed. If nothing in the table
matches the
input string, or if more than one string matches, then an
error
message is printed and the prompt-and-response cycle is
repeated.
The string table may be declared this way:
char *table[] = {
"first string",
"second string",
...
"n-th string",
0};
Getsearch is just like getstab,
but performs a heuristic test for
the quality of each string match, and returns the index of
the best
match. If the match is not exact, the user is asked to
approve or
disapprove the choice of the matching string; if he
disapproves,
several other closely matching choices are listed.
SEE ALSO
stablk(3), stlmatch(3), getint(3), getbool(3), etc.
strarg(3), stabarg(3)
srchscore(3), stabsearch(3), searcharg(3)