Thu Oct 8 21:57:34 2009

Asterisk developer's documentation


app_userevent.c File Reference

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

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.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"
static char * descrip
static char * synopsis = "Send an arbitrary event to the manager interface"


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 104 of file app_userevent.c.

References ast_register_application(), and userevent_exec().

00105 {
00106    return ast_register_application(app, userevent_exec, synopsis, descrip);
00107 }

static int unload_module ( void   )  [static]

Definition at line 93 of file app_userevent.c.

References ast_module_user_hangup_all, and ast_unregister_application().

00094 {
00095    int res;
00096 
00097    res = ast_unregister_application(app);
00098 
00099    ast_module_user_hangup_all();
00100 
00101    return res; 
00102 }

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

Definition at line 58 of file app_userevent.c.

References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), ast_module_user_add, ast_module_user_remove, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), EVENT_FLAG_USER, LOG_WARNING, manager_event(), and parse().

Referenced by load_module().

00059 {
00060    struct ast_module_user *u;
00061    char *parse, buf[2048] = "";
00062    int x, buflen = 0;
00063    AST_DECLARE_APP_ARGS(args,
00064       AST_APP_ARG(eventname);
00065       AST_APP_ARG(extra)[100];
00066    );
00067 
00068    if (ast_strlen_zero(data)) {
00069       ast_log(LOG_WARNING, "UserEvent requires an argument (eventname|optional event body)\n");
00070       return -1;
00071    }
00072 
00073    u = ast_module_user_add(chan);
00074 
00075    parse = ast_strdupa(data);
00076 
00077    AST_STANDARD_APP_ARGS(args, parse);
00078 
00079    for (x = 0; x < args.argc - 1; x++) {
00080       ast_copy_string(buf + buflen, args.extra[x], sizeof(buf) - buflen - 2);
00081       buflen += strlen(args.extra[x]);
00082       ast_copy_string(buf + buflen, "\r\n", 3);
00083       buflen += 2;
00084    }
00085 
00086    manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", args.eventname, buf);
00087 
00088    ast_module_user_remove(u);
00089 
00090    return 0;
00091 }


Variable Documentation

char* app = "UserEvent" [static]

Definition at line 42 of file app_userevent.c.

char* descrip [static]

Definition at line 46 of file app_userevent.c.

char* synopsis = "Send an arbitrary event to the manager interface" [static]

Definition at line 44 of file app_userevent.c.


Generated on Thu Oct 8 21:57:34 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.8