]> mj.ucw.cz Git - libucw.git/commitdiff
Config: Added support for terabyte values, for example "123T".
authorPavel Charvat <pchar@ucw.cz>
Sat, 7 Sep 2019 10:59:00 +0000 (10:59 +0000)
committerPavel Charvat <pchar@ucw.cz>
Sat, 7 Sep 2019 10:59:00 +0000 (10:59 +0000)
ucw/conf-parse.c
ucw/doc/config.txt
ucw/stkstring.c

index 490b03be979e06ee155261c2321b386b42185be6..fc18504978baa336d8658f2d21226fc6a6fb469a 100644 (file)
@@ -3,6 +3,7 @@
  *
  *     (c) 2001--2006 Robert Spalek <robert@ucw.cz>
  *     (c) 2003--2006 Martin Mares <mj@ucw.cz>
+ *     (c) 2019 Pavel Charvat <pchar@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
 
 struct unit {
   uint name;                   // one-letter name of the unit
-  uint num, den;               // fraction
+  uint den;                    // fraction
+  u64 num;
 };
 
 static const struct unit units[] = {
-  { 'd', 86400, 1 },
-  { 'h', 3600, 1 },
-  { 'k', 1000, 1 },
-  { 'm', 1000000, 1 },
-  { 'g', 1000000000, 1 },
-  { 'K', 1024, 1 },
-  { 'M', 1048576, 1 },
-  { 'G', 1073741824, 1 },
-  { '%', 1, 100 },
+  { 'd', 1, 86400 },
+  { 'h', 1, 3600 },
+  { 'k', 1, 1000 },
+  { 'm', 1, 1000000 },
+  { 'g', 1, 1000000000 },
+  { 't', 1, 1000000000000LLU },
+  { 'K', 1, 1<<10 },
+  { 'M', 1, 1<<20 },
+  { 'G', 1, 1<<30 },
+  { 'T', 1, 1LLU<<40 },
+  { '%', 100, 1 },
   { 0, 0, 0 }
 };
 
index 52598016236f22e60ad736fb4f21652f6601f0bb..6b32c5adda3e5415134e69d3d754869146ad5882 100644 (file)
@@ -72,6 +72,7 @@ supported:
        d=86400         k=1000          K=1024
        h=3600          m=1000000       M=1048576
        %=0.01          g=1000000000    G=1073741824
+                       t=1000000000000 T=1099511627776
 
 Attributes of a section or a list node can be set in two ways.  First,
 you can write the name of the section or list, open a bracket, and then
index d3c6d554af7b7657a3cc06ca3697d963dbe0e0e9..bb3b97a0c0ce2b7b80ab0abf64e766d3bae4c9d6 100644 (file)
@@ -3,7 +3,7 @@
  *
  *     (c) 2005--2007 Martin Mares <mj@ucw.cz>
  *     (c) 2005 Tomas Valla <tom@ucw.cz>
- *     (c) 2008 Pavel Charvat <pchar@ucw.cz>
+ *     (c) 2008--2019 Pavel Charvat <pchar@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
@@ -105,8 +105,12 @@ stk_fsize_internal(char *buf, u64 x)
     sprintf(buf, "%dM", (int)(x/(1<<20)));
   else if (x < (u64)10<<30)
     sprintf(buf, "%.1fG", (double)x/(1<<30));
+  else if (x < (u64)1<<40)
+    sprintf(buf, "%dG", (int)x/(1<<30));
+  else if (x < (u64)10<<40)
+    sprintf(buf, "%.1fT", (double)x/((u64)1<<40));
   else if (x != ~(u64)0)
-    sprintf(buf, "%dG", (int)(x/(1<<30)));
+    sprintf(buf, "%dT", (int)(x/((u64)1<<40)));
   else
     strcpy(buf, "unknown");
 }