blob: ec980cadfff3e61e73125596e58da56324a01195 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include <xen/lib.h>
unsigned long long parse_size_and_unit(const char *s, const char **ps)
{
unsigned long long ret;
const char *s1;
ret = simple_strtoull(s, &s1, 0);
switch ( *s1 )
{
case 'T': case 't':
ret <<= 10;
/* fallthrough */
case 'G': case 'g':
ret <<= 10;
/* fallthrough */
case 'M': case 'm':
ret <<= 10;
/* fallthrough */
case 'K': case 'k':
ret <<= 10;
/* fallthrough */
case 'B': case 'b':
s1++;
break;
case '%':
if ( ps )
break;
/* fallthrough */
default:
ret <<= 10; /* default to kB */
break;
}
if ( ps != NULL )
*ps = s1;
return ret;
}
/*
* Local variables:
* mode: C
* c-file-style: "BSD"
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/
|