2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (c) 2006 Tilghman Lesher. All rights reserved.
6 * Tilghman Lesher <asterisk-vmcount-func@the-tilghman.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 * \brief VMCOUNT dialplan function
23 * \author Tilghman Lesher <asterisk-vmcount-func@the-tilghman.com>
30 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
34 #include "asterisk/file.h"
35 #include "asterisk/channel.h"
36 #include "asterisk/pbx.h"
37 #include "asterisk/module.h"
38 #include "asterisk/lock.h"
39 #include "asterisk/utils.h"
40 #include "asterisk/app.h"
42 static int acf_vmcount_exec(struct ast_channel
*chan
, const char *cmd
, char *argsstr
, char *buf
, size_t len
)
45 AST_DECLARE_APP_ARGS(args
,
52 if (ast_strlen_zero(argsstr
))
55 AST_STANDARD_APP_ARGS(args
, argsstr
);
57 if (strchr(args
.vmbox
, '@')) {
59 args
.vmbox
= strsep(&context
, "@");
64 if (ast_strlen_zero(args
.folder
)) {
65 args
.folder
= "INBOX";
68 snprintf(buf
, len
, "%d", ast_app_messagecount(context
, args
.vmbox
, args
.folder
));
73 struct ast_custom_function acf_vmcount
= {
75 .synopsis
= "Counts the voicemail in a specified mailbox",
76 .syntax
= "VMCOUNT(vmbox[@context][,folder])",
78 " context - defaults to \"default\"\n"
79 " folder - defaults to \"INBOX\"\n",
80 .read
= acf_vmcount_exec
,
83 static int unload_module(void)
85 return ast_custom_function_unregister(&acf_vmcount
);
88 static int load_module(void)
90 return ast_custom_function_register(&acf_vmcount
);
93 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "Indicator for whether a voice mailbox has messages in a given folder.");