plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

hexify.c (274B)


      1 #include <u.h>
      2 #include <libc.h>
      3 #include <bio.h>
      4 #include <mach.h>
      5 
      6 char *
      7 _hexify(char *buf, u64int p, int zeros)
      8 {
      9 	ulong d;
     10 
     11 	d = p/16;
     12 	if(d)
     13 		buf = _hexify(buf, d, zeros-1);
     14 	else
     15 		while(zeros--)
     16 			*buf++ = '0';
     17 	*buf++ = "0123456789abcdef"[p&0x0f];
     18 	return buf;
     19 }