lsmod: repair indentation
[oweals/busybox.git] / libbb / xgetlarg.c
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 #include <stdio.h>
9 #include <stdlib.h>
10 #include <getopt.h>
11 #include <errno.h>
12 #include <assert.h>
13 #include <ctype.h>
14
15 #include "libbb.h"
16
17 long bb_xgetlarg(const char *arg, int base, long lower, long upper)
18 {
19         long result;
20         char *endptr;
21         int errno_save = errno;
22
23         if (ENABLE_DEBUG && arg==NULL)
24                 bb_error_msg_and_die("Null in xgetlarg.");
25
26         errno = 0;
27         result = strtol(arg, &endptr, base);
28         if (errno != 0 || *endptr!='\0' || endptr==arg || result < lower || result > upper)
29                 bb_show_usage();
30         errno = errno_save;
31         return result;
32 }