fixed. Support building in one binary

This commit is contained in:
Your Name 2024-07-09 22:33:45 +03:00
parent 7d0207ace2
commit 33b89e64da
38 changed files with 285 additions and 163 deletions

22
libmu/human.c Normal file
View file

@ -0,0 +1,22 @@
#include "human.h"
char *mu_humansize(off_t n, off_t block) {
memset(mu_hs_buf, '\0', sizeof(mu_hs_buf));
char *postfixes = "BKMGTPE";
double size = n;
size_t i;
for (i = 0; i < strlen(postfixes) && size >= block; i++)
size /= block;
if (i)
snprintf(mu_hs_buf, sizeof(mu_hs_buf), "%.1f%c", size, postfixes[i]);
else
snprintf(mu_hs_buf, sizeof(mu_hs_buf), "%ju", n);
return mu_hs_buf;
}