Sat Aug 6 00:39:37 2011

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"

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int load_module (void)
static int unload_module (void)
static int userevent_exec (struct ast_channel *chan, void *data)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Custom User Event Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, }
static char * app = "UserEvent"
static const struct ast_module_infoast_module_info = &__mod_info
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

static void __reg_module ( void   )  [static]

Definition at line 114 of file app_userevent.c.

static void __unreg_module ( void   )  [static]

Definition at line 114 of file app_userevent.c.

static int load_module ( void   )  [static]

Definition at line 109 of file app_userevent.c.

References app, ast_register_application(), descrip, synopsis, and userevent_exec().

00110 {
00111    return ast_register_application(app, userevent_exec, synopsis, descrip);
00112 }

static int unload_module ( void   )  [static]

Definition at line 98 of file app_userevent.c.

References app, ast_module_user_hangup_all, and ast_unregister_application().

00099 {
00100    int res;
00101 
00102    res = ast_unregister_application(app);
00103 
00104    ast_module_user_hangup_all();
00105 
00106    return res; 
00107 }

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_copy_string(), AST_DECLARE_APP_ARGS, ast_log(), ast_module_user_add, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_module_user::chan, LOG_WARNING, and parse().

Referenced by load_module().

00059 {
00060    struct ast_module_user *u;
00061    char *parse, buf[2048] = "";
00062    int x, buflen = 0, xlen;
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       /* Stop once a header comes up that exceeds our buffer. */
00081       if (sizeof(buf) <= buflen + (xlen = strlen(args.extra[x])) + 3) {
00082          ast_log(LOG_WARNING, "UserEvent exceeds our buffer length!  Truncating.\n");
00083          break;
00084       }
00085       ast_copy_string(buf + buflen, args.extra[x], sizeof(buf) - buflen - 3);
00086       buflen += xlen;
00087       ast_copy_string(buf + buflen, "\r\n", 3);
00088       buflen += 2;
00089    }
00090 
00091    manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", args.eventname, buf);
00092 
00093    ast_module_user_remove(u);
00094 
00095    return 0;
00096 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Custom User Event Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static]

Definition at line 114 of file app_userevent.c.

char* app = "UserEvent" [static]

Definition at line 42 of file app_userevent.c.

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 114 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 Sat Aug 6 00:39:37 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7