l64a.c revision 1.5
11.1Sjtc/* 21.4Sjtc * Written by J.T. Conklin <jtc@netbsd.org>. 31.4Sjtc * Public domain. 41.1Sjtc */ 51.1Sjtc 61.5Schristos#include <sys/cdefs.h> 71.1Sjtc#if defined(LIBC_SCCS) && !defined(lint) 81.5Schristos__RCSID("$NetBSD: l64a.c,v 1.5 1997/07/13 20:16:44 christos Exp $"); 91.1Sjtc#endif 101.1Sjtc 111.1Sjtc#include <stdlib.h> 121.1Sjtc 131.1Sjtcchar * 141.1Sjtcl64a (value) 151.1Sjtc long value; 161.1Sjtc{ 171.1Sjtc static char buf[8]; 181.1Sjtc char *s = buf; 191.1Sjtc int digit; 201.1Sjtc int i; 211.1Sjtc 221.1Sjtc if (!value) 231.1Sjtc return NULL; 241.1Sjtc 251.1Sjtc for (i = 0; value != 0 && i < 6; i++) { 261.1Sjtc digit = value & 0x3f; 271.1Sjtc 281.1Sjtc if (digit < 2) 291.1Sjtc *s = digit + '.'; 301.1Sjtc else if (digit < 12) 311.1Sjtc *s = digit + '0' - 2; 321.1Sjtc else if (digit < 38) 331.1Sjtc *s = digit + 'A' - 12; 341.1Sjtc else 351.1Sjtc *s = digit + 'a' - 38; 361.1Sjtc 371.1Sjtc value >>= 6; 381.1Sjtc s++; 391.1Sjtc } 401.1Sjtc 411.1Sjtc *s = '\0'; 421.1Sjtc 431.1Sjtc return buf; 441.1Sjtc} 45