aboutsummaryrefslogtreecommitdiffstats
path: root/funcs/func_sha1.c
diff options
context:
space:
mode:
Diffstat (limited to 'funcs/func_sha1.c')
-rw-r--r--funcs/func_sha1.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/funcs/func_sha1.c b/funcs/func_sha1.c
index 9600d20c5..c9805d2a3 100644
--- a/funcs/func_sha1.c
+++ b/funcs/func_sha1.c
@@ -37,22 +37,26 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/utils.h"
#include "asterisk/app.h"
-static char *sha1(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int sha1(struct ast_channel *chan, char *cmd, char *data,
+ char *buf, size_t len)
{
+ *buf = '\0';
+
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Syntax: SHA1(<data>) - missing argument!\n");
- return NULL;
+ return -1;
}
if (len >= 41)
ast_sha1_hash(buf, data);
else {
- ast_log(LOG_ERROR, "Insufficient space to produce SHA1 hash result (%d < 41)\n", len);
- *buf = '\0';
+ ast_log(LOG_ERROR,
+ "Insufficient space to produce SHA1 hash result (%d < 41)\n",
+ len);
}
- return buf;
-}
+ return 0;
+}
static struct ast_custom_function sha1_function = {
.name = "SHA1",
@@ -60,21 +64,21 @@ static struct ast_custom_function sha1_function = {
.syntax = "SHA1(<data>)",
.read = sha1,
.desc = "Generate a SHA1 digest via the SHA1 algorythm.\n"
- " Example: Set(sha1hash=${SHA1(junky)})\n"
- " Sets the asterisk variable sha1hash to the string '60fa5675b9303eb62f99a9cd47f9f5837d18f9a0'\n"
- " which is known as his hash\n",
+ " Example: Set(sha1hash=${SHA1(junky)})\n"
+ " Sets the asterisk variable sha1hash to the string '60fa5675b9303eb62f99a9cd47f9f5837d18f9a0'\n"
+ " which is known as his hash\n",
};
static char *tdesc = "SHA-1 computation dialplan function";
int unload_module(void)
{
- return ast_custom_function_unregister(&sha1_function);
+ return ast_custom_function_unregister(&sha1_function);
}
int load_module(void)
{
- return ast_custom_function_register(&sha1_function);
+ return ast_custom_function_register(&sha1_function);
}
char *description(void)