Asterisk - The Open Source Telephony Project GIT-master-f36a736
func_md5.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2005-2006, Digium, Inc.
5 * Copyright (C) 2005, Olle E. Johansson, Edvina.net
6 * Copyright (C) 2005, Russell Bryant <russelb@clemson.edu>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*! \file
20 *
21 * \brief MD5 digest related dialplan functions
22 *
23 * \author Olle E. Johansson <oej@edvina.net>
24 * \author Russell Bryant <russelb@clemson.edu>
25 *
26 * \ingroup functions
27 */
28
29/*** MODULEINFO
30 <support_level>core</support_level>
31 ***/
32
33#include "asterisk.h"
34
35#include "asterisk/module.h"
36#include "asterisk/pbx.h"
37
38/*** DOCUMENTATION
39 <function name="MD5" language="en_US">
40 <synopsis>
41 Computes an MD5 digest.
42 </synopsis>
43 <syntax>
44 <parameter name="data" required="true" />
45 </syntax>
46 <description>
47 <para>Computes an MD5 digest.</para>
48 </description>
49 </function>
50 ***/
51
52static int md5(struct ast_channel *chan, const char *cmd, char *data,
53 char *buf, size_t len)
54{
55 if (ast_strlen_zero(data)) {
56 ast_log(LOG_WARNING, "Syntax: MD5(<data>) - missing argument!\n");
57 return -1;
58 }
59
60 ast_md5_hash(buf, data);
61 buf[32] = '\0';
62
63 return 0;
64}
65
67 .name = "MD5",
68 .read = md5,
69 .read_max = 33,
70};
71
72static int unload_module(void)
73{
75}
76
77static int load_module(void)
78{
80}
81
82AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "MD5 digest dialplan functions");
Asterisk main include file. File version handling, generic pbx functions.
#define ast_log
Definition: astobj2.c:42
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int md5(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
Definition: func_md5.c:52
static int load_module(void)
Definition: func_md5.c:77
static struct ast_custom_function md5_function
Definition: func_md5.c:66
static int unload_module(void)
Definition: func_md5.c:72
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define LOG_WARNING
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Definition: module.h:581
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
Core PBX routines and definitions.
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1558
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Definition: pbx.h:118
const char * name
Definition: pbx.h:119
void ast_md5_hash(char *output, const char *input)
Produces MD5 hash based on input string.
Definition: utils.c:250