Wed Jan 8 2020 09:49:55

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"

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, const char *data)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
 
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 108 of file app_userevent.c.

static void __unreg_module ( void  )
static

Definition at line 108 of file app_userevent.c.

static int load_module ( void  )
static

Definition at line 103 of file app_userevent.c.

References ast_register_application_xml, and userevent_exec().

104 {
106 }
static char * app
Definition: app_userevent.c:61
static int userevent_exec(struct ast_channel *chan, const char *data)
Definition: app_userevent.c:63
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
static int unload_module ( void  )
static

Definition at line 98 of file app_userevent.c.

References ast_unregister_application().

99 {
101 }
static char * app
Definition: app_userevent.c:61
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705
static int userevent_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 63 of file app_userevent.c.

References args, 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().

64 {
65  char *parse;
66  int x;
68  AST_APP_ARG(eventname);
69  AST_APP_ARG(extra)[100];
70  );
71  struct ast_str *body = ast_str_create(16);
72 
73  if (ast_strlen_zero(data)) {
74  ast_log(LOG_WARNING, "UserEvent requires an argument (eventname,optional event body)\n");
75  ast_free(body);
76  return -1;
77  }
78 
79  if (!body) {
80  ast_log(LOG_WARNING, "Unable to allocate buffer\n");
81  return -1;
82  }
83 
84  parse = ast_strdupa(data);
85 
87 
88  for (x = 0; x < args.argc - 1; x++) {
89  ast_str_append(&body, 0, "%s\r\n", args.extra[x]);
90  }
91 
92  manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", args.eventname, ast_str_buffer(body));
93  ast_free(body);
94 
95  return 0;
96 }
#define LOG_WARNING
Definition: logger.h:144
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:900
struct ast_str * ast_str_create(size_t init_len)
Create a malloc&#39;ed dynamic length string.
Definition: strings.h:420
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
static struct @350 args
#define EVENT_FLAG_USER
Definition: manager.h:77
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
#define ast_free(a)
Definition: astmm.h:97
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
Definition: manager.h:219

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static

Definition at line 108 of file app_userevent.c.

char* app = "UserEvent"
static

Definition at line 61 of file app_userevent.c.

Definition at line 108 of file app_userevent.c.