#ifndef WH_DISPUTIL_H_4cc5f8fa_ #define WH_DISPUTIL_H_4cc5f8fa_ /* * APIs exported by disputil.c. */ /* * The possible return values of prompt_and_read(). See * prompt_and_read() for their semantics. */ typedef enum { PR_OK = 1, PR_ABORTED, } PRSTAT; /* * The return values from prompt_and_read's char approval function. * See prompt_and_read for their semantics. */ typedef enum { CHOK_OK = 1, CHOK_BAD, CHOK_TERM, CHOK_TERMNS, CHOK_ABORT, CHOK_DEL, CHOK_CLEAR, } CHOK; /* * Prompt for and accept string input. * * prompt_and_read(pstr,buf,len,flags,approval) prompts with pstr and * reads a string into buf, up to len-1 characters (one is reserved * for a trailing NUL). approval vets characters, for cases when only * certain characters are permitted. flags is zero or more of the * PRF_* flags. See the comment on prompt_and_read for more. */ extern PRSTAT prompt_and_read(const char *, char *, int, unsigned int, CHOK (*)(char)); #define PRF_NOSTD 0x00000001 /* * Ask the player to choose one of a small number of options. * * choose_one(prompt,str1,ret1,str2,ret2,...,strN,retN,(char *)0,retE) * * returns ret1 if str1 is chosen, ret2 if str2, etc; if the user * aborts the choice, retE is returned. */ extern int choose_one(const char *, ...); /* * Just like choose_one except that the list of strings is passed as a * const char * const * vector and a count, instead of multiple * arguments, and the retN values are, instead of being arbitrary, * always subscripts into that list, or -1 for the abort value. A * call looks like * * choose_one_v(prompt, strvec, nstr) */ extern int choose_one_v(const char *, const char * const *, int); /* * Get Y/N confirmation of something. Returns true if confirmed * (player replies Y), false if not (replies N or aborts). */ extern int confirm(const char *); #endif