{
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);
}
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);
}
}