diff options
author | Henryk Plötz <henryk@ploetzli.ch> | 2014-10-03 20:04:14 +0200 |
---|---|---|
committer | Henryk Plötz <henryk@ploetzli.ch> | 2014-10-03 20:04:14 +0200 |
commit | c44d8b51ffb5a413f8bbdbd9991bbc573853e397 (patch) | |
tree | e7f2e644de620879f610c909c405cbc4e44d6062 /fmt_xlong.c | |
parent | 0e5b2871ca6456b01d4bf037a6e68badf1ff1a41 (diff) | |
download | tinydnssec-c44d8b51ffb5a413f8bbdbd9991bbc573853e397.tar.gz tinydnssec-c44d8b51ffb5a413f8bbdbd9991bbc573853e397.tar.bz2 |
Apply patch djbdns-1.05-test27.diff.bz2
Source was http://www.fefe.de/dns/djbdns-1.05-test27.diff.bz2, SHA1 f0380ec1866f49c0bcf6369a923ac0a4a5095da8
Diffstat (limited to 'fmt_xlong.c')
-rw-r--r-- | fmt_xlong.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/fmt_xlong.c b/fmt_xlong.c new file mode 100644 index 0000000..332fc9a --- /dev/null +++ b/fmt_xlong.c @@ -0,0 +1,22 @@ +#include "fmt.h" + +char tohex(char num) { + if (num<10) + return num+'0'; + else if (num<16) + return num-10+'a'; + else + return -1; +} + +unsigned int fmt_xlong(register char *s,register unsigned long u) +{ + register unsigned int len; register unsigned long q; + len = 1; q = u; + while (q > 15) { ++len; q /= 16; } + if (s) { + s += len; + do { *--s = tohex(u % 16); u /= 16; } while(u); /* handles u == 0 */ + } + return len; +} |