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 char **keyword
;
51 static int nkeyword
= 0;
56 (void) fprintf(stderr
,
57 gettext("usage: %s [options] keyword [...]\n"), prog
);
58 (void) fprintf(stderr
, gettext(OPTMESG
));
59 (void) fprintf(stderr
, gettext(STDOPTS
));
64 * Given argv[0], return a pointer to the basename of the program.
71 /* first strip trailing '/' characters (exec() allows these!) */
72 str
= arg0
+ strlen(arg0
);
73 while (str
> arg0
&& *--str
== '/')
75 if ((str
= strrchr(arg0
, '/')) != NULL
)
81 main(int argc
, char **argv
)
88 (void) setlocale(LC_ALL
, "");
90 #if !defined(TEXT_DOMAIN)
91 #define TEXT_DOMAIN "SYS_TEST"
93 (void) textdomain(TEXT_DOMAIN
);
95 prog
= prog_name(argv
[0]);
98 while ((c
= getopt(argc
, argv
, "d:p:e:h:k:s:QW:?")) != EOF
) {
105 ckwidth
= atoi(optarg
);
107 (void) fprintf(stderr
,
108 gettext("%s: ERROR: negative display width specified\n"),
135 signo
= atoi(optarg
);
150 usage(); /* must be at least one keyword */
152 nkeyword
= argc
- optind
;
153 keyword
= (char **)malloc(sizeof (char *) * (nkeyword
+ 1));
155 (void) fprintf(stderr
,
156 gettext("Not enough memory\n"));
159 for (i
= 0; i
< nkeyword
; i
++)
160 keyword
[i
] = argv
[optind
++];
161 keyword
[nkeyword
] = NULL
;
164 len
= strlen(deflt
) + 1;
170 strval
= (char *)malloc(len
);
172 (void) fprintf(stderr
,
173 gettext("Not enough memory\n"));
176 n
= ckkeywd(strval
, keyword
, deflt
, error
, help
, prompt
);
179 (void) kill(kpid
, signo
);
182 (void) fputs(strval
, stdout
);