source: MondoRescue/branches/stable/mindi-busybox/libbb/xgetlarg.c@ 821

Last change on this file since 821 was 821, checked in by Bruno Cornec, 18 years ago

Addition of busybox 1.2.1 as a mindi-busybox new package
This should avoid delivering binary files in mindi not built there (Fedora and Debian are quite serious about that)

File size: 829 bytes
RevLine 
[821]1/* vi: set sw=4 ts=4: */
2/*
3 * Copyright (C) 2003-2004 Erik Andersen <andersen@codepoet.org>
4 *
5 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
6 */
7
8
9#include <stdio.h>
10#include <stdlib.h>
11#include <getopt.h>
12#include <errno.h>
13#include <assert.h>
14#include <ctype.h>
15
16#include "libbb.h"
17
18long bb_xgetlarg(const char *arg, int base, long lower, long upper)
19{
20 long result;
21 char *endptr;
22 int errno_save = errno;
23
24 assert(arg!=NULL);
25
26 /* Don't allow leading whitespace.
27 * Wrap isspace in () to make sure we call the
28 * function rather than the macro. */
29 if ((isspace)(*arg)) {
30 bb_show_usage();
31 }
32
33 errno = 0;
34 result = strtol(arg, &endptr, base);
35 if (errno != 0 || *endptr!='\0' || endptr==arg || result < lower || result > upper)
36 bb_show_usage();
37 errno = errno_save;
38 return result;
39}
Note: See TracBrowser for help on using the repository browser.