Mon Jun 27 16:50:46 2011

Asterisk developer's documentation


app_celgenuserevent.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2008, Digium, Inc
00005  *
00006  * See http://www.asterisk.org for more information about
00007  * the Asterisk project. Please do not directly contact
00008  * any of the maintainers of this project for assistance;
00009  * the project provides a web site, mailing lists and IRC
00010  * channels for your use.
00011  *
00012  * This program is free software, distributed under the terms of
00013  * the GNU General Public License Version 2. See the LICENSE file
00014  * at the top of the source tree.
00015  */
00016 
00017 /*! \file
00018  *
00019  * \brief Generate User-Defined CEL event
00020  *
00021  * \author Steve Murphy
00022  *
00023  * \ingroup applications
00024  */
00025 
00026 #include "asterisk.h"
00027 
00028 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 282979 $")
00029 
00030 #include "asterisk/module.h"
00031 #include "asterisk/app.h"
00032 #include "asterisk/channel.h"
00033 #include "asterisk/cel.h"
00034 
00035 /*** DOCUMENTATION
00036    <application name="CELGenUserEvent" language="en_US">
00037       <synopsis>
00038          Generates a CEL User Defined Event.
00039       </synopsis>
00040       <syntax>
00041          <parameter name="event-name" required="true">
00042             <argument name="event-name" required="true">
00043             </argument>
00044             <argument name="extra" required="false">
00045                <para>Extra text to be included with the event.</para>
00046             </argument>
00047          </parameter>
00048       </syntax>
00049       <description>
00050          <para>A CEL event will be immediately generated by this channel, with the supplied name for a type.</para>
00051       </description>
00052    </application>
00053  ***/
00054 
00055 static char *app = "CELGenUserEvent";
00056 
00057 static int celgenuserevent_exec(struct ast_channel *chan, const char *data)
00058 {
00059    int res = 0;
00060    char *parse;
00061    AST_DECLARE_APP_ARGS(args,
00062       AST_APP_ARG(event);
00063       AST_APP_ARG(extra);
00064    );
00065 
00066    if (ast_strlen_zero(data)) {
00067       return 0;
00068    }
00069 
00070    parse = ast_strdupa(data);
00071    AST_STANDARD_APP_ARGS(args, parse);
00072 
00073    ast_cel_report_event(chan, AST_CEL_USER_DEFINED, args.event, args.extra, NULL);
00074    return res;
00075 }
00076 
00077 static int unload_module(void)
00078 {
00079    int res;
00080 
00081    res = ast_unregister_application(app);
00082 
00083    ast_module_user_hangup_all();
00084 
00085    return res;
00086 }
00087 
00088 static int load_module(void)
00089 {
00090    int res = ast_register_application_xml(app, celgenuserevent_exec);
00091    if (res) {
00092       return AST_MODULE_LOAD_DECLINE;
00093    } else {
00094       return AST_MODULE_LOAD_SUCCESS;
00095    }
00096 }
00097 
00098 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generate an User-Defined CEL event",
00099             .load = load_module,
00100             .unload = unload_module,
00101    );

Generated on Mon Jun 27 16:50:46 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7