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
, *prompt
= NULL
, *error
= NULL
, *help
= NULL
;
47 static int kpid
= BADPID
;
50 static const char husage
[] = "mWh";
51 static const char eusage
[] = "mWe";
58 (void) fprintf(stderr
,
59 gettext("usage: %s [options] [-m]\n"),
61 (void) fprintf(stderr
, gettext(OPTMESG
));
62 (void) fprintf(stderr
, gettext(STDOPTS
));
66 (void) fprintf(stderr
,
67 gettext("usage: %s\n"), prog
);
71 (void) fprintf(stderr
,
72 gettext("usage: %s input\n"), prog
);
76 (void) fprintf(stderr
,
77 gettext("usage: %s [options] [-m]\n"),
79 (void) fprintf(stderr
, gettext(OPTMESG
));
80 (void) fprintf(stderr
,
81 gettext("\t-W width\n\t-h help\n"));
85 (void) fprintf(stderr
,
86 gettext("usage: %s [options] [-m]\n"),
88 (void) fprintf(stderr
, gettext(OPTMESG
));
89 (void) fprintf(stderr
,
90 gettext("\t-W width\n\t-e error\n"));
97 * Given argv[0], return a pointer to the basename of the program.
100 prog_name(char *arg0
)
104 /* first strip trailing '/' characters (exec() allows these!) */
105 str
= arg0
+ strlen(arg0
);
106 while (str
> arg0
&& *--str
== '/')
108 if ((str
= strrchr(arg0
, '/')) != NULL
)
114 main(int argc
, char **argv
)
119 int disp
= 0; /* display set to no-display */
121 (void) setlocale(LC_ALL
, "");
123 #if !defined(TEXT_DOMAIN)
124 #define TEXT_DOMAIN "SYS_TEST"
126 (void) textdomain(TEXT_DOMAIN
);
128 prog
= prog_name(argv
[0]);
130 while ((c
= getopt(argc
, argv
, "md:p:e:h:k:s:QW:?")) != EOF
) {
131 /* check for invalid option */
132 if ((*prog
== 'v') || (*prog
== 'd'))
134 if ((*prog
== 'e') && !strchr(eusage
, c
))
136 if ((*prog
== 'h') && !strchr(husage
, c
))
145 ckwidth
= atoi(optarg
);
147 (void) fprintf(stderr
,
148 gettext("%s: ERROR: negative display width specified\n"),
179 signo
= atoi(optarg
);
194 if (argc
!= (optind
+1))
196 exit(ckuid_val(argv
[optind
]));
204 ckuid_err(disp
, error
);
206 } else if (*prog
== 'h') {
208 ckuid_hlp(disp
, help
);
210 } else if (*prog
== 'd') {
215 len
= strlen(deflt
) + 1;
221 strval
= (char *)malloc(len
);
223 (void) fprintf(stderr
,
224 gettext("Not enough memory\n"));
227 n
= ckuid(strval
, disp
, deflt
, error
, help
, prompt
);
230 (void) kill(kpid
, signo
);
233 (void) fputs(strval
, stdout
);