Thu Apr 28 2011 17:13:39

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

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
__MODULE_INFO_SECTION 
__mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Custom User Event Application" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, }
static char * app = "UserEvent"
static struct ast_module_infoast_module_info = &__mod_info

Detailed Description

UserEvent application -- send manager event.

Definition in file app_userevent.c.


Function Documentation

static void __reg_module ( void  ) [static]

Definition at line 104 of file app_userevent.c.

static void __unreg_module ( void  ) [static]

Definition at line 104 of file app_userevent.c.

static int load_module ( void  ) [static]
static int unload_module ( void  ) [static]

Definition at line 94 of file app_userevent.c.

References ast_unregister_application().

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().

{
   char *parse;
   int x;
   AST_DECLARE_APP_ARGS(args,
      AST_APP_ARG(eventname);
      AST_APP_ARG(extra)[100];
   );
   struct ast_str *body = ast_str_create(16);

   if (ast_strlen_zero(data)) {
      ast_log(LOG_WARNING, "UserEvent requires an argument (eventname,optional event body)\n");
      ast_free(body);
      return -1;
   }

   if (!body) {
      ast_log(LOG_WARNING, "Unable to allocate buffer\n");
      return -1;
   }

   parse = ast_strdupa(data);

   AST_STANDARD_APP_ARGS(args, parse);

   for (x = 0; x < args.argc - 1; x++) {
      ast_str_append(&body, 0, "%s\r\n", args.extra[x]);
   }

   manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", args.eventname, ast_str_buffer(body));
   ast_free(body);

   return 0;
}

Variable Documentation

struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Custom User Event Application" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static]

Definition at line 104 of file app_userevent.c.

char* app = "UserEvent" [static]

Definition at line 57 of file app_userevent.c.

Definition at line 104 of file app_userevent.c.