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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
46 static char *deflt
= NULL
, *error
= NULL
, *help
= NULL
, *prompt
= NULL
;
47 static int kpid
= BADPID
;
48 static int signo
, disp
;
50 static const char eusage
[] = "mWe";
51 static const char husage
[] = "mWh";
58 (void) fprintf(stderr
,
59 gettext("usage: %s [options] [-m]\n"), prog
);
60 (void) fprintf(stderr
, gettext(OPTMESG
));
61 (void) fprintf(stderr
, gettext(STDOPTS
));
65 (void) fprintf(stderr
,
66 gettext("usage: %s\n"), prog
);
70 (void) fprintf(stderr
,
71 gettext("usage: %s input\n"), prog
);
75 (void) fprintf(stderr
,
76 gettext("usage: %s [options] [-m]\n"), prog
);
77 (void) fprintf(stderr
, gettext(OPTMESG
));
78 (void) fprintf(stderr
,
79 gettext("\t-W width\n\t-h help\n"));
83 (void) fprintf(stderr
,
84 gettext("usage: %s [options] [-m]\n"), prog
);
85 (void) fprintf(stderr
, gettext(OPTMESG
));
86 (void) fprintf(stderr
,
87 gettext("\t-W width\n\t-e error\n"));
94 * Given argv[0], return a pointer to the basename of the program.
101 /* first strip trailing '/' characters (exec() allows these!) */
102 str
= arg0
+ strlen(arg0
);
103 while (str
> arg0
&& *--str
== '/')
105 if ((str
= strrchr(arg0
, '/')) != NULL
)
111 main(int argc
, char **argv
)
117 (void) setlocale(LC_ALL
, "");
119 #if !defined(TEXT_DOMAIN)
120 #define TEXT_DOMAIN "SYS_TEST"
122 (void) textdomain(TEXT_DOMAIN
);
124 prog
= prog_name(argv
[0]);
126 while ((c
= getopt(argc
, argv
, "md:p:e:h:k:s:QW:?")) != EOF
) {
127 /* check for invalid option */
128 if ((*prog
== 'v') || (*prog
== 'd'))
129 usage(); /* no valid options */
130 if ((*prog
== 'e') && !strchr(eusage
, c
))
132 if ((*prog
== 'h') && !strchr(husage
, c
))
141 ckwidth
= atoi(optarg
);
143 (void) fprintf(stderr
,
144 gettext("%s: ERROR: negative display width specified\n"),
175 signo
= atoi(optarg
);
190 if (argc
!= (optind
+1))
192 exit(ckgid_val(argv
[optind
]));
201 ckgid_err(disp
, error
);
203 } else if (*prog
== 'h') {
205 ckgid_hlp(disp
, help
);
207 } else if (*prog
== 'd') {
212 len
= strlen(deflt
) + 1;
218 gid
= (char *)malloc(len
);
220 (void) fprintf(stderr
,
221 gettext("Not enough memory\n"));
224 n
= ckgid(gid
, disp
, deflt
, error
, help
, prompt
);
227 (void) kill(kpid
, signo
);
230 (void) fputs(gid
, stdout
);