2005-05-05 05:39:33 +00:00
|
|
|
/*
|
2005-09-14 20:46:50 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2005-05-05 05:39:33 +00:00
|
|
|
*
|
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
|
2005-05-07 05:33:44 +00:00
|
|
|
* Copyright (C) 2005, Russell Bryant <russelb@clemson.edu>
|
2005-05-05 05:39:33 +00:00
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2005-05-05 05:39:33 +00:00
|
|
|
* This program is free software, distributed under the terms of
|
2005-09-14 20:46:50 +00:00
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
2005-09-14 20:46:50 +00:00
|
|
|
*
|
2005-10-24 20:12:06 +00:00
|
|
|
* \brief MD5 digest related dialplan functions
|
2005-09-14 20:46:50 +00:00
|
|
|
*
|
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
|
2005-05-05 05:39:33 +00:00
|
|
|
*/
|
|
|
|
|
2005-06-06 22:12:19 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
2006-02-11 03:14:05 +00:00
|
|
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
2005-06-06 22:12:19 +00:00
|
|
|
|
2006-02-11 03:14:05 +00:00
|
|
|
#include "asterisk/module.h"
|
2005-05-05 05:39:33 +00:00
|
|
|
#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-05-05 05:39:33 +00:00
|
|
|
{
|
2005-11-08 01:55:31 +00:00
|
|
|
if (ast_strlen_zero(data)) {
|
2005-05-05 05:39:33 +00:00
|
|
|
ast_log(LOG_WARNING, "Syntax: MD5(<data>) - missing argument!\n");
|
2006-02-12 04:28:58 +00:00
|
|
|
return -1;
|
2005-05-05 05:39:33 +00:00
|
|
|
}
|
|
|
|
|
2006-02-12 04:28:58 +00:00
|
|
|
ast_md5_hash(buf, data);
|
|
|
|
buf[32] = '\0';
|
|
|
|
|
|
|
|
return 0;
|
2005-05-05 05:39:33 +00:00
|
|
|
}
|
|
|
|
|
2006-02-11 03:14:05 +00:00
|
|
|
static struct ast_custom_function md5_function = {
|
2005-05-05 05:39:33 +00:00
|
|
|
.name = "MD5",
|
2006-02-11 03:14:05 +00:00
|
|
|
.read = md5,
|
2005-05-05 05:39:33 +00:00
|
|
|
};
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int unload_module(void)
|
2006-02-11 03:14:05 +00:00
|
|
|
{
|
2006-09-21 19:35:29 +00:00
|
|
|
return ast_custom_function_unregister(&md5_function);
|
2006-02-11 03:14:05 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int load_module(void)
|
2006-02-11 03:14:05 +00:00
|
|
|
{
|
2006-09-21 19:35:29 +00:00
|
|
|
return ast_custom_function_register(&md5_function);
|
2006-02-11 03:14:05 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "MD5 digest dialplan functions");
|