Files
asterisk/funcs/func_md5.c
T

83 lines
1.8 KiB
C
Raw Normal View History

/*
* Asterisk -- An open source telephony toolkit.
*
2006-02-12 04:28:58 +00:00
* Copyright (C) 2005-2006, Digium, Inc.
2005-05-05 12:48:52 +00:00
* Copyright (C) 2005, Olle E. Johansson, Edvina.net
* Copyright (C) 2005, Russell Bryant <russelb@clemson.edu>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*! \file
*
* \brief MD5 digest related dialplan functions
*
2005-12-30 21:18:06 +00:00
* \author Olle E. Johansson <oej@edvina.net>
* \author Russell Bryant <russelb@clemson.edu>
2007-01-24 09:05:29 +00:00
*
* \ingroup functions
*/
2011-07-14 20:28:54 +00:00
/*** MODULEINFO
<support_level>core</support_level>
***/
2005-06-06 22:12:19 +00:00
#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
2008-11-01 21:10:07 +00:00
/*** DOCUMENTATION
<function name="MD5" language="en_US">
<synopsis>
Computes an MD5 digest.
</synopsis>
<syntax>
<parameter name="data" required="true" />
</syntax>
<description>
<para>Computes an MD5 digest.</para>
</description>
</function>
***/
2007-01-06 00:13:33 +00:00
static int md5(struct ast_channel *chan, const char *cmd, char *data,
2006-02-12 04:28:58 +00:00
char *buf, size_t len)
{
2005-11-08 01:55:31 +00:00
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Syntax: MD5(<data>) - missing argument!\n");
2006-02-12 04:28:58 +00:00
return -1;
}
2006-02-12 04:28:58 +00:00
ast_md5_hash(buf, data);
buf[32] = '\0';
return 0;
}
static struct ast_custom_function md5_function = {
.name = "MD5",
.read = md5,
2009-04-29 18:53:01 +00:00
.read_max = 33,
};
static int unload_module(void)
{
2006-09-21 19:35:29 +00:00
return ast_custom_function_unregister(&md5_function);
}
static int load_module(void)
{
2006-09-21 19:35:29 +00:00
return ast_custom_function_register(&md5_function);
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "MD5 digest dialplan functions");