app_chanisavail: Fix use of uninitialized variable.
[asterisk/asterisk.git] / apps / app_celgenuserevent.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2008, Digium, Inc
5  *
6  * See http://www.asterisk.org for more information about
7  * the Asterisk project. Please do not directly contact
8  * any of the maintainers of this project for assistance;
9  * the project provides a web site, mailing lists and IRC
10  * channels for your use.
11  *
12  * This program is free software, distributed under the terms of
13  * the GNU General Public License Version 2. See the LICENSE file
14  * at the top of the source tree.
15  */
16
17 /*! \file
18  *
19  * \brief Generate User-Defined CEL event
20  *
21  * \author Steve Murphy
22  *
23  * \ingroup applications
24  */
25
26 #include "asterisk.h"
27
28 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
29
30 #include "asterisk/module.h"
31 #include "asterisk/app.h"
32 #include "asterisk/channel.h"
33 #include "asterisk/cel.h"
34
35 /*** DOCUMENTATION
36         <application name="CELGenUserEvent" language="en_US">
37                 <synopsis>
38                         Generates a CEL User Defined Event.
39                 </synopsis>
40                 <syntax>
41                         <parameter name="event-name" required="true">
42                                 <argument name="event-name" required="true">
43                                 </argument>
44                                 <argument name="extra" required="false">
45                                         <para>Extra text to be included with the event.</para>
46                                 </argument>
47                         </parameter>
48                 </syntax>
49                 <description>
50                         <para>A CEL event will be immediately generated by this channel, with the supplied name for a type.</para>
51                 </description>
52         </application>
53  ***/
54
55 static char *app = "CELGenUserEvent";
56
57 static int celgenuserevent_exec(struct ast_channel *chan, const char *data)
58 {
59         int res = 0;
60         char *parse;
61         AST_DECLARE_APP_ARGS(args,
62                 AST_APP_ARG(event);
63                 AST_APP_ARG(extra);
64         );
65
66         if (ast_strlen_zero(data)) {
67                 return 0;
68         }
69
70         parse = ast_strdupa(data);
71         AST_STANDARD_APP_ARGS(args, parse);
72
73         ast_cel_report_event(chan, AST_CEL_USER_DEFINED, args.event, args.extra, NULL);
74         return res;
75 }
76
77 static int unload_module(void)
78 {
79         int res;
80
81         res = ast_unregister_application(app);
82
83         ast_module_user_hangup_all();
84
85         return res;
86 }
87
88 static int load_module(void)
89 {
90         int res = ast_register_application_xml(app, celgenuserevent_exec);
91         if (res) {
92                 return AST_MODULE_LOAD_DECLINE;
93         } else {
94                 return AST_MODULE_LOAD_SUCCESS;
95         }
96 }
97
98 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generate an User-Defined CEL event",
99                                 .load = load_module,
100                                 .unload = unload_module,
101         );