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 (c) 1997, by Sun Microsystems, Inc.
28 * All rights reserved.
31 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */
37 #include <sys/types.h>
41 match(char *strval
, char *set
[])
46 len
= (int)strlen(strval
);
49 for (i
= 0; set
[i
]; i
++) {
50 if (strncmp(set
[i
], strval
, len
) == 0) {
52 return (-1); /* not unique */
58 (void) strcpy(strval
, found
);
65 ckkeywd(char *strval
, char *keyword
[], char *defstr
, char *error
, char *help
,
69 char input
[MAX_INPUT
];
73 (void) sprintf(defmesg
, "Please enter one of the following keywords: ");
74 ept
= defmesg
+ strlen(defmesg
);
75 for (i
= 0; keyword
[i
]; ) {
77 (void) strcat(ept
, ", ");
78 (void) strcat(ept
, keyword
[i
++]);
80 (void) strcat(ept
, ckquit
? ", q." : ".");
83 prompt
= "Enter appropriate value";
86 putprmpt(stderr
, prompt
, keyword
, defstr
);
90 n
= (int)strlen(input
);
93 (void) strcpy(strval
, defstr
);
96 puterror(stderr
, defmesg
, error
);
99 if (strcmp(input
, "?") == 0) {
100 puthelp(stderr
, defmesg
, help
);
103 if (ckquit
&& (strcmp(input
, "q") == 0)) {
104 (void) strcpy(strval
, input
);
110 valid
= !match(input
, keyword
);
113 puterror(stderr
, defmesg
, error
);
116 (void) strcpy(strval
, input
);