Home | History | Annotate | Line # | Download | only in common
putulong.c revision 1.1
      1  1.1  cgd /* $NetBSD: putulong.c,v 1.1 1999/08/18 20:00:27 cgd Exp $ */
      2  1.1  cgd 
      3  1.1  cgd /*
      4  1.1  cgd  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
      5  1.1  cgd  *
      6  1.1  cgd  * Redistribution and use in source and binary forms, with or without
      7  1.1  cgd  * modification, are permitted provided that the following conditions
      8  1.1  cgd  * are met:
      9  1.1  cgd  * 1. Redistributions of source code must retain the above copyright
     10  1.1  cgd  *    notice, this list of conditions and the following disclaimer.
     11  1.1  cgd  * 2. The name of the author may not be used to endorse or promote products
     12  1.1  cgd  *    derived from this software without specific prior written permission
     13  1.1  cgd  *
     14  1.1  cgd  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     15  1.1  cgd  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     16  1.1  cgd  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     17  1.1  cgd  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     18  1.1  cgd  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     19  1.1  cgd  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     20  1.1  cgd  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     21  1.1  cgd  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22  1.1  cgd  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     23  1.1  cgd  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  1.1  cgd  */
     25  1.1  cgd 
     26  1.1  cgd #include <lib/libsa/stand.h>
     27  1.1  cgd #include "common.h"
     28  1.1  cgd 
     29  1.1  cgd static const char hexdigits[16] = "0123456789abcdef";
     30  1.1  cgd 
     31  1.1  cgd void
     32  1.1  cgd putulong(unsigned long ul)
     33  1.1  cgd {
     34  1.1  cgd 	char buf[sizeof (ul) * 2], *bp;
     35  1.1  cgd 
     36  1.1  cgd 	for (bp = buf; ul != 0; ul >>= 4)
     37  1.1  cgd 		*bp++ = hexdigits[ul & 0xf];
     38  1.1  cgd 	while (bp-- > buf)
     39  1.1  cgd 		putchar(*bp);
     40  1.1  cgd 	putchar('\n');
     41  1.1  cgd }
     42