File:  [MW Coherent from dump] / coherent / g / usr / lib / misc / yn.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:35 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * ask a question yes or no via stderr.
 */
#include <misc.h>

yn(question)
char * question;
{
	char reply[80];

	for (;;) {
		fprintf(stderr, "%r <y/n> ", &question);
		fflush(stderr);
		if (NULL == gets(reply))
			fatal("unexpected eof on stdin");
		switch (*reply) {
		case 'Y':
		case 'y':
			return (1);
		case 'n':
		case 'N':
			return (0);
		}
		printf("You must answer Y or N\n");
	}
}
#ifdef TEST
/*
 * This test is a usefull program.
 *
 * Inquire on all items in argv and then put out the approved ones.
 * An example of use is.
 * pr `yn *.[ch]`
 * This would inquire on all .c and .h files and send them through pr.
 */
main(argc, argv)
register char *argv[];
{
	register char *arg;

	while (NULL != (arg = *++argv))
		if (yn("%s", arg))
			puts(arg);
}
#endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.