about summary refs log tree commit diff stats
path: root/src/common.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-01-20 17:16:45 +0000
committerJames Booth <boothj5@gmail.com>2013-01-20 17:16:45 +0000
commit64d81c7c4c07f527e76a64477a5b21a1385dbfef (patch)
treea200c3a4868fcdb46245d39dd055f56e0f2ca16d /src/common.c
parent4ecb69bfab47b5c08f8b5fca97008fe10abc96ba (diff)
downloadprofani-tty-64d81c7c4c07f527e76a64477a5b21a1385dbfef.tar.gz
Started work on creating sha-1 caps hash
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c
index d79bff64..f0e14f45 100644
--- a/src/common.c
+++ b/src/common.c
@@ -167,3 +167,29 @@ prof_getline(FILE *stream)
     free(buf);
     return s;
 }
+
+int
+octet_compare(unsigned char *str1, unsigned char *str2)
+{
+    if ((strcmp((char *)str1, "") == 0) && (strcmp((char *)str2, "") == 0)) {
+        return 0;
+    }
+
+    if ((strcmp((char *)str1, "") == 0) && (strcmp((char *)str2, "") != 0)) {
+        return -1;
+    }
+
+    if ((strcmp((char *)str1, "") != 0) && (strcmp((char *)str2, "") == 0)) {
+        return 1;
+    }
+
+    if (str1[0] == str2[0]) {
+        return octet_compare(&str1[1], &str2[1]);
+    }
+
+    if (str1[0] < str2[0]) {
+        return -1;
+    }
+
+    return 1;
+}