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
, *prompt
, *error
, *help
;
47 static int kpid
= BADPID
;
50 static const char husage
[] = "Wh";
51 static const char eusage
[] = "We";
58 (void) fprintf(stderr
,
59 gettext("usage: %s [options]\n"), prog
);
60 (void) fprintf(stderr
, gettext(OPTMESG
));
61 (void) fprintf(stderr
, gettext(STDOPTS
));
65 (void) fprintf(stderr
,
66 gettext("usage: %s input\n"), prog
);
70 (void) fprintf(stderr
,
71 gettext("usage: %s [options]\n"), prog
);
72 (void) fprintf(stderr
, gettext(OPTMESG
));
73 (void) fprintf(stderr
,
74 gettext("\t-W width\n\t-h help\n"));
78 (void) fprintf(stderr
,
79 gettext("usage: %s [options]\n"), prog
);
80 (void) fprintf(stderr
, gettext(OPTMESG
));
81 (void) fprintf(stderr
,
82 gettext("\t-W width\n\t-e error\n"));
89 * Given argv[0], return a pointer to the basename of the program.
96 /* first strip trailing '/' characters (exec() allows these!) */
97 str
= arg0
+ strlen(arg0
);
98 while (str
> arg0
&& *--str
== '/')
100 if ((str
= strrchr(arg0
, '/')) != NULL
)
106 main(int argc
, char **argv
)
112 (void) setlocale(LC_ALL
, "");
114 #if !defined(TEXT_DOMAIN)
115 #define TEXT_DOMAIN "SYS_TEST"
117 (void) textdomain(TEXT_DOMAIN
);
119 prog
= prog_name(argv
[0]);
121 while ((c
= getopt(argc
, argv
, "d:p:e:h:k:s:QW:?")) != EOF
) {
122 /* check for invalid option */
125 if ((*prog
== 'e') && !strchr(eusage
, c
))
127 if ((*prog
== 'h') && !strchr(husage
, c
))
136 ckwidth
= atoi(optarg
);
138 (void) fprintf(stderr
,
139 gettext("%s: ERROR: negative display width specified\n"),
166 signo
= atoi(optarg
);
181 if (argc
!= (optind
+ 1))
183 if (ckyorn_val(argv
[optind
]))
196 } else if (*prog
== 'h') {
203 len
= strlen(deflt
) + 1;
209 ynval
= (char *)malloc(len
);
211 (void) fprintf(stderr
,
212 gettext("Not enough memory\n"));
215 n
= ckyorn(ynval
, deflt
, error
, help
, prompt
);
218 if (kill(kpid
, signo
)) {
219 (void) fprintf(stderr
,
220 gettext("Failed to send signal %d to process %d\n"),
226 (void) fputs(ynval
, stdout
);