l64a.c revision 1.1
11.1Sjtc/* 21.1Sjtc * Copyright (c) 1993 Winning Strategies, Inc. 31.1Sjtc * All rights reserved. 41.1Sjtc * 51.1Sjtc * Redistribution and use in source and binary forms, with or without 61.1Sjtc * modification, are permitted provided that the following conditions 71.1Sjtc * are met: 81.1Sjtc * 1. Redistributions of source code must retain the above copyright 91.1Sjtc * notice, this list of conditions and the following disclaimer. 101.1Sjtc * 2. Redistributions in binary form must reproduce the above copyright 111.1Sjtc * notice, this list of conditions and the following disclaimer in the 121.1Sjtc * documentation and/or other materials provided with the distribution. 131.1Sjtc * 3. All advertising materials mentioning features or use of this software 141.1Sjtc * must display the following acknowledgement: 151.1Sjtc * This product includes software developed by Winning Strategies, Inc. 161.1Sjtc * 4. The name of the author may not be used to endorse or promote products 171.1Sjtc * derived from this software withough specific prior written permission 181.1Sjtc * 191.1Sjtc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 201.1Sjtc * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 211.1Sjtc * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 221.1Sjtc * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 231.1Sjtc * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 241.1Sjtc * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 251.1Sjtc * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 261.1Sjtc * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 271.1Sjtc * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 281.1Sjtc * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 291.1Sjtc */ 301.1Sjtc 311.1Sjtc#if defined(LIBC_SCCS) && !defined(lint) 321.1Sjtcstatic char *rcsid = "$Id: l64a.c,v 1.1 1993/10/22 17:26:46 jtc Exp $"; 331.1Sjtc#endif 341.1Sjtc 351.1Sjtc#include <stddef.h> 361.1Sjtc#include <stdlib.h> 371.1Sjtc 381.1Sjtcchar * 391.1Sjtcl64a (value) 401.1Sjtc long value; 411.1Sjtc{ 421.1Sjtc static char buf[8]; 431.1Sjtc char *s = buf; 441.1Sjtc int digit; 451.1Sjtc int i; 461.1Sjtc 471.1Sjtc if (!value) 481.1Sjtc return NULL; 491.1Sjtc 501.1Sjtc for (i = 0; value != 0 && i < 6; i++) { 511.1Sjtc digit = value & 0x3f; 521.1Sjtc 531.1Sjtc if (digit < 2) 541.1Sjtc *s = digit + '.'; 551.1Sjtc else if (digit < 12) 561.1Sjtc *s = digit + '0' - 2; 571.1Sjtc else if (digit < 38) 581.1Sjtc *s = digit + 'A' - 12; 591.1Sjtc else 601.1Sjtc *s = digit + 'a' - 38; 611.1Sjtc 621.1Sjtc value >>= 6; 631.1Sjtc s++; 641.1Sjtc } 651.1Sjtc 661.1Sjtc *s = '\0'; 671.1Sjtc 681.1Sjtc return buf; 691.1Sjtc} 70