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.
37 #include <sys/types.h>
42 #define PROMPT "Enter the name of an existing group"
43 #define MESG "Please enter the name of an existing group."
44 #define ALTMESG "Please enter one of the following group names:\\n\\t"
64 msg
= calloc(m
, sizeof (char));
65 (void) strcpy(msg
, ALTMESG
);
69 while ((grpptr
= getgrent()) != NULL
) {
70 n
+= strlen(grpptr
->gr_name
) + 2;
73 msg
= reallocarray(msg
, m
, sizeof (char));
76 (void) strcat(msg
, ", ");
77 (void) strcat(msg
, grpptr
->gr_name
);
88 /* if display flag is set, then list out group file */
92 while (grpptr
= getgrent())
93 (void) printf("%s\n", grpptr
->gr_name
);
99 ckgid_val(char *grpnm
)
104 valid
= (getgrnam(grpnm
) ? 0 : 1);
110 ckgrpfile(void) /* check to see if group file there */
112 struct group
*grpptr
;
125 ckgid_err(int disp
, char *error
)
130 puterror(stdout
, msg
, error
);
136 ckgid_hlp(int disp
, char *help
)
141 puthelp(stdout
, msg
, help
);
147 ckgid(char *gid
, short disp
, char *defstr
, char *error
, char *help
,
158 putprmpt(stderr
, prompt
, NULL
, defstr
);
159 if (getinput(input
)) {
165 if (!strlen(input
)) {
169 (void) strcpy(gid
, defstr
);
173 defmesg
= setmsg(disp
);
174 puterror(stderr
, defmesg
, error
);
176 } else if (strcmp(input
, "?") == 0) {
178 defmesg
= setmsg(disp
);
179 puthelp(stderr
, defmesg
, help
);
181 } else if (ckquit
&& (strcmp(input
, "q") == 0)) {
185 } else if (ckgid_val(input
)) {
187 defmesg
= setmsg(disp
);
188 puterror(stderr
, defmesg
, error
);
191 (void) strcpy(gid
, input
);