summaryrefslogtreecommitdiff
path: root/src/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc.c')
-rw-r--r--src/misc.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/misc.c b/src/misc.c
index cf684870c..5a16bfa07 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -62,6 +62,27 @@ int tolower(char c)
/*************************************************************************/
/**
+ * Simple function to convert binary data to hex.
+ * Taken from hybrid-ircd ( http://ircd-hybrid.com/ )
+ */
+void binary_to_hex(unsigned char *bin, char *hex, int length)
+{
+ static const char trans[] = "0123456789ABCDEF";
+ int i;
+
+ for(i = 0; i < length; i++)
+ {
+ hex[i << 1] = trans[bin[i] >> 4];
+ hex[(i << 1) + 1] = trans[bin[i] & 0xf];
+ }
+
+ hex[i << 1] = '\0';
+}
+
+
+/*************************************************************************/
+
+/**
* strscpy: Copy at most len-1 characters from a string to a buffer, and
* add a null terminator after the last character copied.
* @param d Buffer to copy into