Wed Jan 8 2020 09:49:47

Asterisk developer's documentation


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 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328209 $")
36 
37 #include "asterisk/module.h"
38 #include "asterisk/pbx.h"
39 
40 /*** DOCUMENTATION
41  <function name="MD5" language="en_US">
42  <synopsis>
43  Computes an MD5 digest.
44  </synopsis>
45  <syntax>
46  <parameter name="data" required="true" />
47  </syntax>
48  <description>
49  <para>Computes an MD5 digest.</para>
50  </description>
51  </function>
52  ***/
53 
54 static int md5(struct ast_channel *chan, const char *cmd, char *data,
55  char *buf, size_t len)
56 {
57  if (ast_strlen_zero(data)) {
58  ast_log(LOG_WARNING, "Syntax: MD5(<data>) - missing argument!\n");
59  return -1;
60  }
61 
62  ast_md5_hash(buf, data);
63  buf[32] = '\0';
64 
65  return 0;
66 }
67 
69  .name = "MD5",
70  .read = md5,
71  .read_max = 33,
72 };
73 
74 static int unload_module(void)
75 {
76  return ast_custom_function_unregister(&md5_function);
77 }
78 
79 static int load_module(void)
80 {
81  return ast_custom_function_register(&md5_function);
82 }
83 
84 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "MD5 digest dialplan functions");
Main Channel structure associated with a channel.
Definition: channel.h:742
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Definition: module.h:396
Asterisk main include file. File version handling, generic pbx functions.
static int unload_module(void)
Definition: func_md5.c:74
#define LOG_WARNING
Definition: logger.h:144
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
Definition: pbx.c:3814
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
Data structure associated with a custom dialplan function.
Definition: pbx.h:95
static int load_module(void)
Definition: func_md5.c:79
Core PBX routines and definitions.
static int md5(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
Definition: func_md5.c:54
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static struct ast_custom_function md5_function
Definition: func_md5.c:68
const char * name
Definition: pbx.h:96
void ast_md5_hash(char *output, const char *input)
Produces MD5 hash based on input string.
Definition: utils.c:245
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:38
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1164
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
Definition: asterisk.h:180