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]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
27 * Copyright (c) 1997, by Sun Microsystems, Inc.
28 * All rights reserved.
32 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3 */
38 #include <sys/types.h>
42 setmsg(char *msg
, short base
)
44 if ((base
== 0) || (base
== 10))
45 (void) sprintf(msg
, "Please enter an integer.");
47 (void) sprintf(msg
, "Please enter a base %d integer.", base
);
51 setprmpt(char *prmpt
, short base
)
53 if ((base
== 0) || (base
== 10))
54 (void) sprintf(prmpt
, "Enter an integer.");
56 (void) sprintf(prmpt
, "Enter a base %d integer.", base
);
60 ckint_val(char *value
, short base
)
64 (void) strtol(value
, &ptr
, (int)base
);
71 ckint_err(short base
, char *error
)
75 setmsg(defmesg
, base
);
76 puterror(stdout
, defmesg
, error
);
80 ckint_hlp(short base
, char *help
)
84 setmsg(defmesg
, base
);
85 puthelp(stdout
, defmesg
, help
);
89 ckint(long *intval
, short base
, char *defstr
, char *error
, char *help
,
102 setmsg(defmesg
, base
);
105 putprmpt(stderr
, prompt
, NULL
, defstr
);
109 if (strlen(input
) == 0) {
111 *intval
= strtol(defstr
, NULL
, (int)base
);
114 puterror(stderr
, defmesg
, error
);
116 } else if (strcmp(input
, "?") == 0) {
117 puthelp(stderr
, defmesg
, help
);
119 } else if (ckquit
&& (strcmp(input
, "q") == 0))
122 value
= strtol(input
, &ptr
, (int)base
);
124 puterror(stderr
, defmesg
, error
);