Wed Jan 8 2020 09:49:39

Asterisk developer's documentation


app_celgenuserevent.c
Go to the documentation of this file.
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 /*** MODULEINFO
27  <support_level>core</support_level>
28  ***/
29 
30 #include "asterisk.h"
31 
32 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 376657 $")
33 
34 #include "asterisk/module.h"
35 #include "asterisk/app.h"
36 #include "asterisk/channel.h"
37 #include "asterisk/cel.h"
38 
39 /*** DOCUMENTATION
40  <application name="CELGenUserEvent" language="en_US">
41  <synopsis>
42  Generates a CEL User Defined Event.
43  </synopsis>
44  <syntax>
45  <parameter name="event-name" required="true">
46  <argument name="event-name" required="true">
47  </argument>
48  <argument name="extra" required="false">
49  <para>Extra text to be included with the event.</para>
50  </argument>
51  </parameter>
52  </syntax>
53  <description>
54  <para>A CEL event will be immediately generated by this channel, with the supplied name for a type.</para>
55  </description>
56  </application>
57  ***/
58 
59 static char *app = "CELGenUserEvent";
60 
61 static int celgenuserevent_exec(struct ast_channel *chan, const char *data)
62 {
63  int res = 0;
64  char *parse;
66  AST_APP_ARG(event);
67  AST_APP_ARG(extra);
68  );
69 
70  if (ast_strlen_zero(data)) {
71  return 0;
72  }
73 
74  parse = ast_strdupa(data);
76 
77  ast_cel_report_event(chan, AST_CEL_USER_DEFINED, args.event, args.extra, NULL);
78  return res;
79 }
80 
81 static int unload_module(void)
82 {
84  return 0;
85 }
86 
87 static int load_module(void)
88 {
90  if (res) {
92  } else {
94  }
95 }
96 
97 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generate an User-Defined CEL event",
98  .load = load_module,
99  .unload = unload_module,
100  );
Main Channel structure associated with a channel.
Definition: channel.h:742
static int unload_module(void)
Asterisk main include file. File version handling, generic pbx functions.
Call Event Logging API.
int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event_type, const char *userdefevname, const char *extra, struct ast_channel *peer2)
Report a channel event.
Definition: cel.c:645
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
static int celgenuserevent_exec(struct ast_channel *chan, const char *data)
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
Definition: module.h:374
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705
static char * app
General Asterisk PBX channel definitions.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static int load_module(void)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static struct @350 args
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
a user-defined event, the event name field should be set
Definition: cel.h:90
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:38
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
Definition: asterisk.h:180