Asterisk - The Open Source Telephony Project GIT-master-27fb039
Loading...
Searching...
No Matches
Functions | Variables
app_celgenuserevent.c File Reference

Generate User-Defined CEL event. More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/channel.h"
#include "asterisk/cel.h"
Include dependency graph for app_celgenuserevent.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int celgenuserevent_exec (struct ast_channel *chan, const char *data)
 
static int load_module (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Generate an User-Defined CEL event" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "cel", }
 
static char * app = "CELGenUserEvent"
 
static const struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

Generate User-Defined CEL event.

Author
Steve Murphy

Definition in file app_celgenuserevent.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 110 of file app_celgenuserevent.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 110 of file app_celgenuserevent.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 110 of file app_celgenuserevent.c.

◆ celgenuserevent_exec()

static int celgenuserevent_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 62 of file app_celgenuserevent.c.

63{
64 int res = 0;
65 char *parse;
66 RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
69 AST_APP_ARG(extra);
70 );
71
72 if (ast_strlen_zero(data)) {
73 return 0;
74 }
75
76 parse = ast_strdupa(data);
78
79 blob = ast_json_pack("{s: s, s: {s: s}}",
80 "event", args.event,
81 "extra", "extra", S_OR(args.extra, ""));
82 if (!blob) {
83 return res;
84 }
86 return res;
87}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition astmm.h:298
void ast_cel_publish_event(struct ast_channel *chan, enum ast_cel_event_type event_type, struct ast_json *blob)
Publish a CEL event.
Definition cel.c:1735
@ AST_CEL_USER_DEFINED
a user-defined event, the event name field should be set
Definition cel.h:69
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition json.c:73
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition json.c:612
static struct @519 args
#define NULL
Definition resample.c:96
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition strings.h:80
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
Abstract JSON element (object, array, string, int, ...).
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition utils.h:981

References args, AST_APP_ARG, ast_cel_publish_event(), AST_CEL_USER_DEFINED, AST_DECLARE_APP_ARGS, ast_json_pack(), ast_json_unref(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), NULL, RAII_VAR, and S_OR.

Referenced by load_module().

◆ load_module()

static int load_module ( void  )
static

Definition at line 95 of file app_celgenuserevent.c.

96{
98 if (res) {
100 } else {
102 }
103}
static char * app
static int celgenuserevent_exec(struct ast_channel *chan, const char *data)
@ AST_MODULE_LOAD_SUCCESS
Definition module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition module.h:78
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition module.h:640

References app, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, and celgenuserevent_exec().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 89 of file app_celgenuserevent.c.

90{
92 return 0;
93}
int ast_unregister_application(const char *app)
Unregister an application.
Definition pbx_app.c:392

References app, and ast_unregister_application().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Generate an User-Defined CEL event" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "cel", }
static

Definition at line 110 of file app_celgenuserevent.c.

◆ app

char* app = "CELGenUserEvent"
static

Definition at line 60 of file app_celgenuserevent.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 110 of file app_celgenuserevent.c.