mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
major dialplan functions update
deprecate LANGUAGE() and MUSICCLASS(), in favor of CHANNEL() git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@9674 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Asterisk -- An open source telephony toolkit.
|
||||
*
|
||||
* Copyright (C) 2005, Digium, Inc.
|
||||
* Copyright (C) 2005-2006, Digium, Inc.
|
||||
* Copyright (C) 2005, Olle E. Johansson, Edvina.net
|
||||
* Copyright (C) 2005, Russell Bryant <russelb@clemson.edu>
|
||||
*
|
||||
@@ -39,44 +39,39 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
#include "asterisk/utils.h"
|
||||
#include "asterisk/app.h"
|
||||
|
||||
static char *md5(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
static int md5(struct ast_channel *chan, char *cmd, char *data,
|
||||
char *buf, size_t len)
|
||||
{
|
||||
char md5[33];
|
||||
|
||||
if (ast_strlen_zero(data)) {
|
||||
ast_log(LOG_WARNING, "Syntax: MD5(<data>) - missing argument!\n");
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ast_md5_hash(md5, data);
|
||||
ast_copy_string(buf, md5, len);
|
||||
|
||||
return buf;
|
||||
ast_md5_hash(buf, data);
|
||||
buf[32] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *checkmd5(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||
static int checkmd5(struct ast_channel *chan, char *cmd, char *parse,
|
||||
char *buf, size_t len)
|
||||
{
|
||||
char newmd5[33];
|
||||
char *parse;
|
||||
static int deprecated = 0;
|
||||
AST_DECLARE_APP_ARGS(args,
|
||||
AST_APP_ARG(digest);
|
||||
AST_APP_ARG(data);
|
||||
);
|
||||
AST_DECLARE_APP_ARGS(args, AST_APP_ARG(digest); AST_APP_ARG(data););
|
||||
|
||||
if (ast_strlen_zero(data)) {
|
||||
ast_log(LOG_WARNING, "Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n");
|
||||
return NULL;
|
||||
if (ast_strlen_zero(parse)) {
|
||||
ast_log(LOG_WARNING,
|
||||
"Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(parse = ast_strdupa(data)))
|
||||
return NULL;
|
||||
|
||||
AST_STANDARD_APP_ARGS(args, parse);
|
||||
|
||||
|
||||
if (args.argc < 2) {
|
||||
ast_log(LOG_WARNING, "Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n");
|
||||
return NULL;
|
||||
ast_log(LOG_WARNING,
|
||||
"Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!deprecated) {
|
||||
@@ -86,12 +81,12 @@ static char *checkmd5(struct ast_channel *chan, char *cmd, char *data, char *buf
|
||||
|
||||
ast_md5_hash(newmd5, args.data);
|
||||
|
||||
if (!strcasecmp(newmd5, args.digest) ) /* they match */
|
||||
if (!strcasecmp(newmd5, args.digest)) /* they match */
|
||||
ast_copy_string(buf, "1", len);
|
||||
else
|
||||
ast_copy_string(buf, "0", len);
|
||||
|
||||
return buf;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct ast_custom_function md5_function = {
|
||||
@@ -113,12 +108,14 @@ static char *tdesc = "MD5 digest dialplan functions";
|
||||
|
||||
int unload_module(void)
|
||||
{
|
||||
return ast_custom_function_unregister(&md5_function) || ast_custom_function_unregister(&checkmd5_function);
|
||||
return ast_custom_function_unregister(&md5_function) |
|
||||
ast_custom_function_unregister(&checkmd5_function);
|
||||
}
|
||||
|
||||
int load_module(void)
|
||||
{
|
||||
return ast_custom_function_register(&md5_function) || ast_custom_function_register(&checkmd5_function);
|
||||
return ast_custom_function_register(&md5_function) |
|
||||
ast_custom_function_register(&checkmd5_function);
|
||||
}
|
||||
|
||||
char *description(void)
|
||||
|
Reference in New Issue
Block a user