00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "asterisk.h"
00032
00033 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328209 $")
00034
00035 #include "asterisk/module.h"
00036 #include "asterisk/pbx.h"
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 static int sha1(struct ast_channel *chan, const char *cmd, char *data,
00058 char *buf, size_t len)
00059 {
00060 *buf = '\0';
00061
00062 if (ast_strlen_zero(data)) {
00063 ast_log(LOG_WARNING, "Syntax: SHA1(<data>) - missing argument!\n");
00064 return -1;
00065 }
00066
00067 if (len >= 41)
00068 ast_sha1_hash(buf, data);
00069 else {
00070 ast_log(LOG_ERROR,
00071 "Insufficient space to produce SHA1 hash result (%d < 41)\n",
00072 (int) len);
00073 }
00074
00075 return 0;
00076 }
00077
00078 static struct ast_custom_function sha1_function = {
00079 .name = "SHA1",
00080 .read = sha1,
00081 .read_max = 42,
00082 };
00083
00084 static int unload_module(void)
00085 {
00086 return ast_custom_function_unregister(&sha1_function);
00087 }
00088
00089 static int load_module(void)
00090 {
00091 return ast_custom_function_register(&sha1_function);
00092 }
00093
00094 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "SHA-1 computation dialplan function");