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
;
53 static const char vusage
[] = "bul";
54 static const char husage
[] = "bulWh";
55 static const char eusage
[] = "bulWe";
57 #define USAGE "[-l lower] [-u upper] [-b base]"
64 (void) fprintf(stderr
,
65 gettext("usage: %s [options] %s\n"),
67 (void) fprintf(stderr
, gettext(OPTMESG
));
68 (void) fprintf(stderr
, gettext(STDOPTS
));
72 (void) fprintf(stderr
,
73 gettext("usage: %s %s input\n"), prog
, USAGE
);
77 (void) fprintf(stderr
,
78 gettext("usage: %s [options] %s\n"),
80 (void) fprintf(stderr
, gettext(OPTMESG
));
81 (void) fprintf(stderr
,
82 gettext("\t-W width\n\t-h help\n"));
86 (void) fprintf(stderr
,
87 gettext("usage: %s [options] %s\n"),
89 (void) fprintf(stderr
, gettext(OPTMESG
));
90 (void) fprintf(stderr
,
91 gettext("\t-W width\n\t-e error\n"));
98 * Given argv[0], return a pointer to the basename of the program.
101 prog_name(char *arg0
)
105 /* first strip trailing '/' characters (exec() allows these!) */
106 str
= arg0
+ strlen(arg0
);
107 while (str
> arg0
&& *--str
== '/')
109 if ((str
= strrchr(arg0
, '/')) != NULL
)
115 main(int argc
, char **argv
)
118 long lvalue
, uvalue
, intval
;
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
, "l:u:b:d:p:e:h:k:s:QW:?")) != EOF
) {
131 /* check for invalid option */
132 if ((*prog
== 'v') && !strchr(vusage
, c
))
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"),
156 if ((base
< 2) || (base
> 36)) {
157 (void) fprintf(stderr
,
158 gettext("%s: ERROR: base must be between 2 and 36\n"),
193 signo
= atoi(optarg
);
208 uvalue
= strtol(upper
, &ptr
, base
);
210 (void) fprintf(stderr
,
211 gettext("%s: ERROR: invalid upper value specification\n"),
218 lvalue
= strtol(lower
, &ptr
, base
);
220 (void) fprintf(stderr
,
221 gettext("%s: ERROR: invalid lower value specification\n"),
228 if (uvalue
< lvalue
) {
229 (void) fprintf(stderr
,
230 gettext("%s: ERROR: upper value is less than lower value\n"),
236 if (argc
!= (optind
+1))
238 exit(ckrange_val(lvalue
, uvalue
, base
, argv
[optind
]));
246 ckrange_err(lvalue
, uvalue
, base
, error
);
248 } else if (*prog
== 'h') {
250 ckrange_hlp(lvalue
, uvalue
, base
, help
);
254 n
= ckrange(&intval
, lvalue
, uvalue
, (short)base
,
255 deflt
, error
, help
, prompt
); /* libadm interface */
258 (void) kill(kpid
, signo
);
261 (void) printf("%ld", intval
);