diff options
author | James Booth <boothj5@gmail.com> | 2013-01-20 17:16:45 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-01-20 17:16:45 +0000 |
commit | 64d81c7c4c07f527e76a64477a5b21a1385dbfef (patch) | |
tree | a200c3a4868fcdb46245d39dd055f56e0f2ca16d /src/common.c | |
parent | 4ecb69bfab47b5c08f8b5fca97008fe10abc96ba (diff) | |
download | profani-tty-64d81c7c4c07f527e76a64477a5b21a1385dbfef.tar.gz |
Started work on creating sha-1 caps hash
Diffstat (limited to 'src/common.c')
-rw-r--r-- | src/common.c | 26 |
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; +} |