kernel -- Remove unused vfscache structure.
[dragonfly.git] / lib / libc / stdlib / l64a.c
blobd3fc949af622549760e7e16ab1fa88032533d290
1 /*
2 * Written by J.T. Conklin <jtc@NetBSD.org>.
3 * Public domain.
5 * $NetBSD: l64a.c,v 1.13 2003/07/26 19:24:54 salo Exp $
6 * $FreeBSD: src/lib/libc/stdlib/l64a.c,v 1.1 2005/12/24 22:37:59 trhodes Exp $
7 */
9 #include <stdlib.h>
11 char *
12 l64a(long value)
14 static char buf[8];
16 l64a_r(value, buf, sizeof(buf));
17 return (buf);
20 int
21 l64a_r(long value, char *buffer, int buflen)
23 long v;
24 int digit;
26 v = value & (long)0xffffffff;
27 for (; v != 0 && buflen > 1; buffer++, buflen--) {
28 digit = v & 0x3f;
29 if (digit < 2)
30 *buffer = digit + '.';
31 else if (digit < 12)
32 *buffer = digit + '0' - 2;
33 else if (digit < 38)
34 *buffer = digit + 'A' - 12;
35 else
36 *buffer = digit + 'a' - 38;
37 v >>= 6;
39 return (v == 0 ? 0 : -1);