about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2018-09-06 20:32:08 +0200
committerMichael Vetter <jubalh@iodoru.org>2018-09-06 20:40:09 +0200
commit82f8083b857358c5dd54700fd51254ca745c30a1 (patch)
treedca5b3c68e9b5987ba2e0e40222cfb443dd9bd70 /src
parent9e021d5c8f1fbbac05ff989eca1d2bf766d8c935 (diff)
downloadprofani-tty-82f8083b857358c5dd54700fd51254ca745c30a1.tar.gz
Move p_sha1_hash() to stanza.c
Move `p_sha1_hash()` from `common.c` to	`xmpp/stanza.c` as it is only
used in this file and now depends on libstrophe so xmpp is a better
namespace folder.
Renaming it as `_stanza_create_sha1_hash()`. And making static since
only used here.

The function cannot be tested in the unit tests anymore.
Once functional tests are working again we should write a test for the
sha1 functionality.
Diffstat (limited to 'src')
-rw-r--r--src/common.c16
-rw-r--r--src/common.h2
-rw-r--r--src/xmpp/stanza.c19
3 files changed, 18 insertions, 19 deletions
diff --git a/src/common.c b/src/common.c
index a4120e9b..27482d80 100644
--- a/src/common.c
+++ b/src/common.c
@@ -55,7 +55,6 @@
 
 #include "log.h"
 #include "common.h"
-#include <strophe.h>
 
 struct curl_data_t
 {
@@ -330,21 +329,6 @@ release_is_new(char *found_version)
     }
 }
 
-char*
-p_sha1_hash(char *str)
-{
-   unsigned char *digest = (unsigned char*)malloc(XMPP_SHA1_DIGEST_SIZE);
-   assert(digest != NULL);
-
-   xmpp_sha1_digest((unsigned char*)str, strlen(str), digest);
-
-   char *b64 = g_base64_encode(digest, XMPP_SHA1_DIGEST_SIZE);
-   assert(b64 != NULL);
-   free(digest);
-
-   return b64;
-}
-
 static size_t
 _data_callback(void *ptr, size_t size, size_t nmemb, void *data)
 {
diff --git a/src/common.h b/src/common.h
index b2c36c3f..328f7f5a 100644
--- a/src/common.h
+++ b/src/common.h
@@ -92,8 +92,6 @@ char* file_getline(FILE *stream);
 char* release_get_latest(void);
 gboolean release_is_new(char *found_version);
 
-char* p_sha1_hash(char *str);
-
 char* get_file_or_linked(char *loc, char *basedir);
 char* strip_arg_quotes(const char *const input);
 gboolean is_notify_enabled(void);
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 82189ddd..ed13b976 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -45,6 +45,7 @@
 #include <stdio.h>
 #include <libgen.h>
 #include <inttypes.h>
+#include <assert.h>
 
 #include <glib.h>
 
@@ -66,6 +67,7 @@
 #include "xmpp/muc.h"
 
 static void _stanza_add_unique_id(xmpp_stanza_t *stanza, char *prefix);
+static char* _stanza_create_sha1_hash(char *str);
 
 #if 0
 xmpp_stanza_t*
@@ -1143,7 +1145,7 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t *const query)
         curr = g_slist_next(curr);
     }
 
-    char *result = p_sha1_hash(s->str);
+    char *result = _stanza_create_sha1_hash(s->str);
 
     g_string_free(s, TRUE);
     g_slist_free_full(identities, g_free);
@@ -2045,3 +2047,18 @@ _stanza_add_unique_id(xmpp_stanza_t *stanza, char *prefix)
     xmpp_stanza_set_id(stanza, id);
     free(id);
 }
+
+static char*
+_stanza_create_sha1_hash(char *str)
+{
+   unsigned char *digest = (unsigned char*)malloc(XMPP_SHA1_DIGEST_SIZE);
+   assert(digest != NULL);
+
+   xmpp_sha1_digest((unsigned char*)str, strlen(str), digest);
+
+   char *b64 = g_base64_encode(digest, XMPP_SHA1_DIGEST_SIZE);
+   assert(b64 != NULL);
+   free(digest);
+
+   return b64;
+}