Tue Aug 24 20:34:32 2010

Asterisk developer's documentation


app_userevent.c File Reference

UserEvent application -- send manager event. More...

#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/manager.h"
#include "asterisk/app.h"
Include dependency graph for app_userevent.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Custom User Event Application")
static int load_module (void)
static int unload_module (void)
static int userevent_exec (struct ast_channel *chan, void *data)

Variables

static char * app = "UserEvent"

Detailed Description

UserEvent application -- send manager event.

Definition in file app_userevent.c.


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Custom User Event Application"   
)
static int load_module ( void   )  [static]

Definition at line 99 of file app_userevent.c.

References ast_register_application_xml, and userevent_exec().

00100 {
00101    return ast_register_application_xml(app, userevent_exec);
00102 }

static int unload_module ( void   )  [static]

Definition at line 94 of file app_userevent.c.

References ast_unregister_application().

00095 {
00096    return ast_unregister_application(app);
00097 }

static int userevent_exec ( struct ast_channel *  chan,
void *  data 
) [static]

Definition at line 59 of file app_userevent.c.

References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_free, ast_log(), AST_STANDARD_APP_ARGS, ast_str_append(), ast_str_buffer(), ast_str_create(), ast_strdupa, ast_strlen_zero(), EVENT_FLAG_USER, LOG_WARNING, manager_event, and parse().

Referenced by load_module().

00060 {
00061    char *parse;
00062    int x;
00063    AST_DECLARE_APP_ARGS(args,
00064       AST_APP_ARG(eventname);
00065       AST_APP_ARG(extra)[100];
00066    );
00067    struct ast_str *body = ast_str_create(16);
00068 
00069    if (ast_strlen_zero(data)) {
00070       ast_log(LOG_WARNING, "UserEvent requires an argument (eventname,optional event body)\n");
00071       ast_free(body);
00072       return -1;
00073    }
00074 
00075    if (!body) {
00076       ast_log(LOG_WARNING, "Unable to allocate buffer\n");
00077       return -1;
00078    }
00079 
00080    parse = ast_strdupa(data);
00081 
00082    AST_STANDARD_APP_ARGS(args, parse);
00083 
00084    for (x = 0; x < args.argc - 1; x++) {
00085       ast_str_append(&body, 0, "%s\r\n", args.extra[x]);
00086    }
00087 
00088    manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", args.eventname, ast_str_buffer(body));
00089    ast_free(body);
00090 
00091    return 0;
00092 }


Variable Documentation

char* app = "UserEvent" [static]

Definition at line 57 of file app_userevent.c.


Generated on 24 Aug 2010 for Asterisk - the Open Source PBX by  doxygen 1.6.1