Sun Jun 12 16:37:58 2011

Asterisk developer's documentation


func_md5.c File Reference

MD5 digest related dialplan functions. More...

#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/logger.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"

Include dependency graph for func_md5.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"MD5 digest dialplan functions")
static int checkmd5 (struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len)
static int load_module (void)
static int md5 (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
static int unload_module (void)

Variables

static struct ast_custom_function checkmd5_function
static struct ast_custom_function md5_function


Detailed Description

MD5 digest related dialplan functions.

Author:
Olle E. Johansson <oej@edvina.net>

Russell Bryant <russelb@clemson.edu>

Definition in file func_md5.c.


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"MD5 digest dialplan functions"   
)

static int checkmd5 ( struct ast_channel chan,
char *  cmd,
char *  parse,
char *  buf,
size_t  len 
) [static]

Definition at line 57 of file func_md5.c.

References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), ast_md5_hash(), AST_STANDARD_APP_ARGS, ast_strlen_zero(), and LOG_WARNING.

00059 {
00060    char newmd5[33];
00061    static int deprecated = 0;
00062    AST_DECLARE_APP_ARGS(args, AST_APP_ARG(digest); AST_APP_ARG(data););
00063 
00064    if (ast_strlen_zero(parse)) {
00065       ast_log(LOG_WARNING,
00066             "Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n");
00067       return -1;
00068    }
00069 
00070    AST_STANDARD_APP_ARGS(args, parse);
00071 
00072    if (args.argc < 2) {
00073       ast_log(LOG_WARNING,
00074             "Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n");
00075       return -1;
00076    }
00077 
00078    if (!deprecated) {
00079       deprecated = 1;
00080       ast_log(LOG_WARNING, "CHECK_MD5() is deprecated in Asterisk 1.4 and later.\n");
00081    }
00082 
00083    ast_md5_hash(newmd5, args.data);
00084 
00085    if (!strcasecmp(newmd5, args.digest))  /* they match */
00086       ast_copy_string(buf, "1", len);
00087    else
00088       ast_copy_string(buf, "0", len);
00089 
00090    return 0;
00091 }

static int load_module ( void   )  [static]

Definition at line 114 of file func_md5.c.

References ast_custom_function_register().

static int md5 ( struct ast_channel chan,
char *  cmd,
char *  data,
char *  buf,
size_t  len 
) [static]

Definition at line 43 of file func_md5.c.

References ast_log(), ast_md5_hash(), ast_strlen_zero(), and LOG_WARNING.

00045 {
00046    if (ast_strlen_zero(data)) {
00047       ast_log(LOG_WARNING, "Syntax: MD5(<data>) - missing argument!\n");
00048       return -1;
00049    }
00050 
00051    ast_md5_hash(buf, data);
00052    buf[32] = '\0';
00053 
00054    return 0;
00055 }

static int unload_module ( void   )  [static]

Definition at line 108 of file func_md5.c.

References ast_custom_function_unregister().


Variable Documentation

Definition at line 100 of file func_md5.c.

Definition at line 93 of file func_md5.c.


Generated on Sun Jun 12 16:37:58 2011 for Asterisk - the Open Source PBX by  doxygen 1.5.6