2 * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>
3 * Copyright (C) 2010 Piotr JaroszyĆski <p.jaroszynski@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 FILE_LICENCE ( GPL2_OR_LATER
);
26 * Despite being exactly the same as strtoul() except the long long instead of
27 * long it ends up being much bigger so provide a separate implementation in a
28 * separate object so that it won't be linked in if not used.
30 unsigned long long strtoull ( const char *p
, char **endp
, int base
) {
31 unsigned long long ret
= 0;
35 while ( isspace ( *p
) )
43 base
= strtoul_base ( &p
, base
);
46 charval
= strtoul_charval ( *p
);
47 if ( charval
>= ( unsigned int ) base
)
49 ret
= ( ( ret
* base
) + charval
);