1 /* $MirOS: src/lib/libc/stdlib/rpmatch.c,v 1.1 2007/05/22 15:46:19 tg Exp $ */
2 
3 /*-
4  * Copyright (c) 2007
5  *	Thorsten Glaser <tg@mirbsd.de>
6  *
7  * Provided that these terms and disclaimer and all copyright notices
8  * are retained or reproduced in an accompanying document, permission
9  * is granted to deal in this work without restriction, including un-
10  * limited rights to use, publicly perform, distribute, sell, modify,
11  * merge, give away, or sublicence.
12  *
13  * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
14  * the utmost extent permitted by applicable law, neither express nor
15  * implied; without malicious intent or gross negligence. In no event
16  * may a licensor, author or contributor be held liable for indirect,
17  * direct, other damage, loss, or other issues arising in any way out
18  * of dealing in the work, even if advised of the possibility of such
19  * damage or existence of a defect, except proven that it results out
20  * of said person's immediate fault when using the work as intended.
21  */
22 
23 #define _SVID_SOURCE
24 #include <errno.h>
25 #include <stdlib.h>
26 
27 int
rpmatch(const char * response)28 rpmatch(const char *response)
29 {
30 	errno = 0;
31 
32 	if (response != NULL)
33 		switch (response[0]) {
34 		case 'N':
35 		case 'n':
36 			return (0);
37 		case 'Y':
38 		case 'y':
39 			return (1);
40 		}
41 	else
42 		errno = EINVAL;
43 
44 	return (-1);
45 }
46