func_md5.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2005-2006, Digium, Inc.
00005  * Copyright (C) 2005, Olle E. Johansson, Edvina.net
00006  * Copyright (C) 2005, Russell Bryant <russelb@clemson.edu> 
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  *
00021  * \brief MD5 digest related dialplan functions
00022  * 
00023  * \author Olle E. Johansson <oej@edvina.net>
00024  * \author Russell Bryant <russelb@clemson.edu>
00025  *
00026  * \ingroup functions
00027  */
00028 
00029 /*** MODULEINFO
00030    <support_level>core</support_level>
00031  ***/
00032 
00033 #include "asterisk.h"
00034 
00035 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328259 $")
00036 
00037 #include "asterisk/module.h"
00038 #include "asterisk/pbx.h"
00039 
00040 /*** DOCUMENTATION
00041    <function name="MD5" language="en_US">
00042       <synopsis>
00043          Computes an MD5 digest.
00044       </synopsis>
00045       <syntax>
00046          <parameter name="data" required="true" />
00047       </syntax>
00048       <description>
00049          <para>Computes an MD5 digest.</para>
00050       </description>
00051    </function>
00052  ***/
00053 
00054 static int md5(struct ast_channel *chan, const char *cmd, char *data,
00055           char *buf, size_t len)
00056 {
00057    if (ast_strlen_zero(data)) {
00058       ast_log(LOG_WARNING, "Syntax: MD5(<data>) - missing argument!\n");
00059       return -1;
00060    }
00061 
00062    ast_md5_hash(buf, data);
00063    buf[32] = '\0';
00064 
00065    return 0;
00066 }
00067 
00068 static struct ast_custom_function md5_function = {
00069    .name = "MD5",
00070    .read = md5,
00071    .read_max = 33,
00072 };
00073 
00074 static int unload_module(void)
00075 {
00076    return ast_custom_function_unregister(&md5_function);
00077 }
00078 
00079 static int load_module(void)
00080 {
00081    return ast_custom_function_register(&md5_function);
00082 }
00083 
00084 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "MD5 digest dialplan functions");

Generated on Thu Apr 16 06:27:35 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6