diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-02-11 03:14:05 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-02-11 03:14:05 +0000 |
commit | 5f90b9bebddfa06f9d08b63e9c48830071480f38 (patch) | |
tree | 47f92d29e3216d69801be7bdb5d15fef7aab9a4d /funcs/func_sha1.c | |
parent | 7acc893dad48c008eaced05bfbedb0d17735bc47 (diff) |
build function modules independently (no more pbx_functions.so)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@9469 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs/func_sha1.c')
-rw-r--r-- | funcs/func_sha1.c | 161 |
1 files changed, 93 insertions, 68 deletions
diff --git a/funcs/func_sha1.c b/funcs/func_sha1.c index 020b842ee..9600d20c5 100644 --- a/funcs/func_sha1.c +++ b/funcs/func_sha1.c @@ -1,68 +1,93 @@ -/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 2006, Digium, Inc.
- * Copyright (C) 2006, Claude Patry
- *
- * 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.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE file
- * at the top of the source tree.
- */
-
-/*! \file
- *
- * \brief SHA1 digest related dialplan functions
- *
- * \author Claude Patry <cpatry@gmail.com>
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-
-#include "asterisk.h"
-
-/* ASTERISK_FILE_VERSION(__FILE__, "$Revision: 8403 $") */
-
-#include "asterisk/channel.h"
-#include "asterisk/pbx.h"
-#include "asterisk/logger.h"
-#include "asterisk/utils.h"
-#include "asterisk/app.h"
-
-static char *builtin_function_sha1(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
-{
- if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "Syntax: SHA1(<data>) - missing argument!\n");
- return NULL;
- }
-
- if (len >= 41)
- ast_sha1_hash(buf, data);
- else {
- ast_log(LOG_ERROR, "Insufficient space to produce SHA1 hash result (%d < 41)\n", len);
- *buf = '\0';
- }
- return buf;
-}
-
-
-#ifndef BUILTIN_FUNC
-static
-#endif
-struct ast_custom_function sha1_function = {
- .name = "SHA1",
- .synopsis = "Computes a SHA1 digest",
- .syntax = "SHA1(<data>)",
- .read = builtin_function_sha1,
- .desc = "Generate a SHA1 digest via the SHA1 algorythm.\n"
- " Example: Set(sha1hash=${SHA1(junky)})\n"
- " Sets the asterisk variable sha1hash to the string '60fa5675b9303eb62f99a9cd47f9f5837d18f9a0'\n"
- " which is known as his hash\n",
-};
+/* + * Asterisk -- An open source telephony toolkit. + * + * Copyright (C) 2006, Digium, Inc. + * Copyright (C) 2006, Claude Patry + * + * 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. + * + * This program is free software, distributed under the terms of + * the GNU General Public License Version 2. See the LICENSE file + * at the top of the source tree. + */ + +/*! \file + * + * \brief SHA1 digest related dialplan functions + * + * \author Claude Patry <cpatry@gmail.com> + */ + +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> + +#include "asterisk.h" + +ASTERISK_FILE_VERSION(__FILE__, "$Revision$") + +#include "asterisk/module.h" +#include "asterisk/channel.h" +#include "asterisk/pbx.h" +#include "asterisk/logger.h" +#include "asterisk/utils.h" +#include "asterisk/app.h" + +static char *sha1(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) +{ + if (ast_strlen_zero(data)) { + ast_log(LOG_WARNING, "Syntax: SHA1(<data>) - missing argument!\n"); + return NULL; + } + + if (len >= 41) + ast_sha1_hash(buf, data); + else { + ast_log(LOG_ERROR, "Insufficient space to produce SHA1 hash result (%d < 41)\n", len); + *buf = '\0'; + } + return buf; +} + + +static struct ast_custom_function sha1_function = { + .name = "SHA1", + .synopsis = "Computes a SHA1 digest", + .syntax = "SHA1(<data>)", + .read = sha1, + .desc = "Generate a SHA1 digest via the SHA1 algorythm.\n" + " Example: Set(sha1hash=${SHA1(junky)})\n" + " Sets the asterisk variable sha1hash to the string '60fa5675b9303eb62f99a9cd47f9f5837d18f9a0'\n" + " which is known as his hash\n", +}; + +static char *tdesc = "SHA-1 computation dialplan function"; + +int unload_module(void) +{ + return ast_custom_function_unregister(&sha1_function); +} + +int load_module(void) +{ + return ast_custom_function_register(&sha1_function); +} + +char *description(void) +{ + return tdesc; +} + +int usecount(void) +{ + return 0; +} + +char *key() +{ + return ASTERISK_GPL_KEY; +} |