- switch (c) {
- default:
- break;
- case 'p':
- case 'P':
- ret *= (unsigned long long) kb_base;
- case 't':
- case 'T':
- ret *= (unsigned long long) kb_base;
- case 'g':
- case 'G':
- ret *= (unsigned long long) kb_base;
- case 'm':
- case 'M':
- ret *= (unsigned long long) kb_base;
- case 'k':
- case 'K':
- ret *= (unsigned long long) kb_base;
- break;
+ if (!p)
+ return 1;
+
+ c = strdup(p);
+
+ for (i = 0; i < strlen(c); i++)
+ c[i] = tolower(c[i]);
+
+ if (!strcmp("pib", c)) {
+ pow = 5;
+ mult = 1000;
+ } else if (!strcmp("tib", c)) {
+ pow = 4;
+ mult = 1000;
+ } else if (!strcmp("gib", c)) {
+ pow = 3;
+ mult = 1000;
+ } else if (!strcmp("mib", c)) {
+ pow = 2;
+ mult = 1000;
+ } else if (!strcmp("kib", c)) {
+ pow = 1;
+ mult = 1000;
+ } else if (!strcmp("p", c) || !strcmp("pb", c))
+ pow = 5;
+ else if (!strcmp("t", c) || !strcmp("tb", c))
+ pow = 4;
+ else if (!strcmp("g", c) || !strcmp("gb", c))
+ pow = 3;
+ else if (!strcmp("m", c) || !strcmp("mb", c))
+ pow = 2;
+ else if (!strcmp("k", c) || !strcmp("kb", c))
+ pow = 1;
+ else if (!strcmp("%", c)) {
+ *percent = 1;
+ return ret;