summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/l64a.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1995-10-18 08:37:01 +0000
committerderaadt <deraadt@openbsd.org>1995-10-18 08:37:01 +0000
commitdf930be708d50e9715f173caa26ffe1b7599b157 (patch)
treeaa317e49e28cb999c9cf3db7f00c20903fe6010a /lib/libc/stdlib/l64a.c
downloadwireguard-openbsd-df930be708d50e9715f173caa26ffe1b7599b157.tar.xz
wireguard-openbsd-df930be708d50e9715f173caa26ffe1b7599b157.zip
initial import of NetBSD tree
Diffstat (limited to 'lib/libc/stdlib/l64a.c')
-rw-r--r--lib/libc/stdlib/l64a.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/libc/stdlib/l64a.c b/lib/libc/stdlib/l64a.c
new file mode 100644
index 00000000000..3069b31bf67
--- /dev/null
+++ b/lib/libc/stdlib/l64a.c
@@ -0,0 +1,43 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: l64a.c,v 1.4 1995/05/11 23:04:52 jtc Exp $";
+#endif
+
+#include <stdlib.h>
+
+char *
+l64a (value)
+ long value;
+{
+ static char buf[8];
+ char *s = buf;
+ int digit;
+ int i;
+
+ if (!value)
+ return NULL;
+
+ for (i = 0; value != 0 && i < 6; i++) {
+ digit = value & 0x3f;
+
+ if (digit < 2)
+ *s = digit + '.';
+ else if (digit < 12)
+ *s = digit + '0' - 2;
+ else if (digit < 38)
+ *s = digit + 'A' - 12;
+ else
+ *s = digit + 'a' - 38;
+
+ value >>= 6;
+ s++;
+ }
+
+ *s = '\0';
+
+ return buf;
+}