+
+char *ParseQuotaString(char *quota)
+{
+ char *s, *value;
+ float ngigs, nmegs;
+ int calcvalue;
+
+ s = quota;
+ while (*s && (isdigit(*s) || (*s == '.')))
+ s++;
+
+ /* If we didn't find a unit specifier, just return the old value. */
+ if (!*s)
+ return strdup(quota);
+
+ switch (*s) {
+ case 'm':
+ case 'M':
+ /* value specified in megabytes. */
+ if (!sscanf(quota, "%f2", &nmegs))
+ return strdup(quota);
+ calcvalue = (int)(nmegs * 1000);
+ break;
+ case 'g':
+ case 'G':
+ /* value specified in gigabytes. */
+ if (!sscanf(quota, "%f2", &ngigs))
+ return strdup(quota);
+ calcvalue = (int)(ngigs * 1000 * 1000);
+ break;
+ default:
+ /* Couldn't parse it. Just return the old value. */
+ return strdup(quota);
+ }
+
+ value = malloc(BUFSIZ);
+ if (!value)
+ return NULL;
+ sprintf(value, "%d", calcvalue);
+ return value;
+}