X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=clients%2Fgtk2%2Fdolcon.c;h=c71b9a1ff5d0c2b2438e2ed4179fe3b3837d7ead;hb=8af979f318c0e3d1d00a35996f6b5fecb055ac33;hp=b209370f2e267003dd019713299ed24cb2895bf5;hpb=83b38e21e5d72749817280a7a5cbbb07860bfdee;p=doldaconnect.git diff --git a/clients/gtk2/dolcon.c b/clients/gtk2/dolcon.c index b209370..c71b9a1 100644 --- a/clients/gtk2/dolcon.c +++ b/clients/gtk2/dolcon.c @@ -279,23 +279,16 @@ char *bytes2si(long long bytes) { int i; double b; - char *sd; static char ret[64]; + static char pfx[] = {'k', 'M', 'G', 'T'}; b = bytes; - for(i = 0; (b >= 1024) && (i < 4); i++) + for(i = 0; (b >= 1024) && (i < sizeof(pfx)); i++) b /= 1024; if(i == 0) - sd = "B"; - else if(i == 1) - sd = "kiB"; - else if(i == 2) - sd = "MiB"; - else if(i == 3) - sd = "GiB"; + snprintf(ret, 64, "%.1f B", b); else - sd = "TiB"; - snprintf(ret, 64, "%.1f %s", b, sd); + snprintf(ret, 64, "%.1f %ciB", b, pfx[i - 1]); return(ret); } @@ -2215,18 +2208,22 @@ int main(int argc, char **argv) textdomain(PACKAGE); gtk_init(&argc, &argv); connlocal = 0; - while((c = getopt(argc, argv, "lh")) != -1) { + while((c = getopt(argc, argv, "lhV")) != -1) { switch(c) { case 'l': connlocal = 1; break; case 'h': - printf("usage: dolcon [-hl]\n"); + printf("usage: dolcon [-hlV]\n"); printf("\t-h\tDisplay this help message\n"); printf("\t-l\tConnect to the locally running daemon\n"); + printf("\t-V\tDisplay version info and exit\n"); + exit(0); + case 'V': + printf("%s", RELEASEINFO); exit(0); default: - fprintf(stderr, "usage: dolcon [-hl]\n"); + fprintf(stderr, "usage: dolcon [-hlV]\n"); exit(1); } }