2005-12-24 22:37:59 +00:00
|
|
|
/*
|
|
|
|
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
|
|
|
* Public domain.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
|
|
|
__RCSID("$NetBSD: l64a.c,v 1.13 2003/07/26 19:24:54 salo Exp $");
|
|
|
|
#endif /* not lint */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2016-05-26 20:55:15 +00:00
|
|
|
#include <stdint.h>
|
2005-12-24 22:37:59 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
char *
|
|
|
|
l64a(long value)
|
|
|
|
{
|
2016-05-26 20:55:15 +00:00
|
|
|
static char buf[7];
|
2005-12-24 22:37:59 +00:00
|
|
|
|
|
|
|
(void)l64a_r(value, buf, sizeof(buf));
|
|
|
|
return (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
l64a_r(long value, char *buffer, int buflen)
|
|
|
|
{
|
2016-05-26 20:55:15 +00:00
|
|
|
static const char chars[] =
|
|
|
|
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
|
|
uint32_t v;
|
|
|
|
|
|
|
|
v = value;
|
|
|
|
while (buflen-- > 0) {
|
|
|
|
if (v == 0) {
|
|
|
|
*buffer = '\0';
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
*buffer++ = chars[v & 0x3f];
|
2005-12-24 22:37:59 +00:00
|
|
|
v >>= 6;
|
|
|
|
}
|
2016-05-26 20:55:15 +00:00
|
|
|
return (-1);
|
2005-12-24 22:37:59 +00:00
|
|
|
}
|