2 ** Copyright 2001 Double Precision, Inc.
3 ** See COPYING for distribution information.
13 static void cat_n(char *buf
, unsigned long n
)
15 char bb
[NUMBUFSIZE
+1];
16 char *p
=bb
+sizeof(bb
)-1;
21 *--p
= "0123456789"[n
% 10];
27 char *libmail_str_sizekb(unsigned long n
, char *sizebuf
)
29 /* If size is less than 1K bytes, display it as 0.xK */
33 strcpy(sizebuf
, "0.");
34 cat_n(sizebuf
, (int)(10 * n
/ 1024 ));
37 /* If size is less than 1 meg, display is as xK */
39 else if (n
< 1024 * 1024)
42 cat_n(sizebuf
, (unsigned long)(n
+512)/1024);
46 /* Otherwise, display in megabytes */
50 unsigned long nm
=(double)n
/ (1024.0 * 1024.0) * 10;
53 cat_n( sizebuf
, nm
/ 10);
55 cat_n( sizebuf
, nm
% 10);