1 /* 2 * Written by J.T. Conklin <jtc@netbsd.org>. 3 * Public domain. 4 */ 5 6 #include <sys/cdefs.h> 7 #if defined(LIBC_SCCS) && !defined(lint) 8 __RCSID("$NetBSD: l64a.c,v 1.6 1997/07/21 14:08:53 jtc Exp $"); 9 #endif 10 11 #include "namespace.h" 12 #include <stdlib.h> 13 14 #ifdef __weak_alias 15 __weak_alias(l64a,_l64a); 16 #endif 17 18 char * 19 l64a (value) 20 long value; 21 { 22 static char buf[8]; 23 char *s = buf; 24 int digit; 25 int i; 26 27 if (!value) 28 return NULL; 29 30 for (i = 0; value != 0 && i < 6; i++) { 31 digit = value & 0x3f; 32 33 if (digit < 2) 34 *s = digit + '.'; 35 else if (digit < 12) 36 *s = digit + '0' - 2; 37 else if (digit < 38) 38 *s = digit + 'A' - 12; 39 else 40 *s = digit + 'a' - 38; 41 42 value >>= 6; 43 s++; 44 } 45 46 *s = '\0'; 47 48 return buf; 49 } 50