Thu Jul 9 13:40:35 2009

Asterisk developer's documentation


func_vmcount.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (c) 2006 Tilghman Lesher.  All rights reserved.
00005  * 
00006  * Tilghman Lesher <asterisk-vmcount-func@the-tilghman.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  *
00021  * \brief VMCOUNT dialplan function
00022  *
00023  * \author Tilghman Lesher <asterisk-vmcount-func@the-tilghman.com>
00024  *
00025  * \ingroup functions
00026  */
00027 
00028 #include "asterisk.h"
00029 
00030 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 89512 $")
00031 
00032 #include <dirent.h>
00033 
00034 #include "asterisk/file.h"
00035 #include "asterisk/channel.h"
00036 #include "asterisk/pbx.h"
00037 #include "asterisk/module.h"
00038 #include "asterisk/lock.h"
00039 #include "asterisk/utils.h"
00040 #include "asterisk/app.h"
00041 
00042 static int acf_vmcount_exec(struct ast_channel *chan, const char *cmd, char *argsstr, char *buf, size_t len)
00043 {
00044    char *context;
00045    AST_DECLARE_APP_ARGS(args,
00046       AST_APP_ARG(vmbox);
00047       AST_APP_ARG(folder);
00048    );
00049 
00050    buf[0] = '\0';
00051 
00052    if (ast_strlen_zero(argsstr))
00053       return -1;
00054 
00055    AST_STANDARD_APP_ARGS(args, argsstr);
00056 
00057    if (strchr(args.vmbox, '@')) {
00058       context = args.vmbox;
00059       args.vmbox = strsep(&context, "@");
00060    } else {
00061       context = "default";
00062    }
00063 
00064    if (ast_strlen_zero(args.folder)) {
00065       args.folder = "INBOX";
00066    }
00067 
00068    snprintf(buf, len, "%d", ast_app_messagecount(context, args.vmbox, args.folder));
00069    
00070    return 0;
00071 }
00072 
00073 struct ast_custom_function acf_vmcount = {
00074    .name = "VMCOUNT",
00075    .synopsis = "Counts the voicemail in a specified mailbox",
00076    .syntax = "VMCOUNT(vmbox[@context][,folder])",
00077    .desc =
00078    "  context - defaults to \"default\"\n"
00079    "  folder  - defaults to \"INBOX\"\n",
00080    .read = acf_vmcount_exec,
00081 };
00082 
00083 static int unload_module(void)
00084 {
00085    return ast_custom_function_unregister(&acf_vmcount);
00086 }
00087 
00088 static int load_module(void)
00089 {
00090    return ast_custom_function_register(&acf_vmcount);
00091 }
00092 
00093 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Indicator for whether a voice mailbox has messages in a given folder.");

Generated on Thu Jul 9 13:40:35 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7