4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
31 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */
38 #include <sys/types.h>
41 static char *choices
[] = { "y", "n", NULL
};
42 static char *vchoices
[] = { "y", "n", "yes", "no", NULL
};
45 #define REQMSG "Input is required."
46 #define ERRMSG "Please enter yes or no."
48 "To respond in the affirmative, enter y, yes, Y, or YES. \
49 To respond in the negative, enter n, no, N, or NO."
58 for (pt
= temp
, i
= 0; *str
&& i
< TMPSIZ
; i
++) {
59 *pt
++ = tolower((unsigned char)*str
++);
62 for (i
= 0; vchoices
[i
]; ) {
63 if (strcmp(temp
, vchoices
[i
++]) == 0)
70 ckyorn_err(char *error
)
72 puterror(stdout
, ERRMSG
, error
);
76 ckyorn_hlp(char *help
)
78 puthelp(stdout
, HLPMSG
, help
);
82 ckyorn(char *yorn
, char *defstr
, char *error
, char *help
, char *prompt
)
85 char input
[MAX_INPUT
];
90 putprmpt(stderr
, prompt
, choices
, defstr
);
94 n
= (int)strlen(input
);
97 (void) strcpy(yorn
, defstr
);
100 puterror(stderr
, REQMSG
, error
);
103 if (strcmp(input
, "?") == 0) {
104 puthelp(stderr
, HLPMSG
, help
);
107 if (ckquit
&& (strcmp(input
, "q") == 0))
110 if (ckyorn_val(input
)) {
111 puterror(stderr
, ERRMSG
, error
);
114 (void) strcpy(yorn
, input
);