Asterisk - The Open Source Telephony Project GIT-master-1f1c5bb
Functions | Variables
func_export.c File Reference

Set variables and functions on other channels. More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/stringfields.h"
Include dependency graph for func_export.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD_EXTENDED (ASTERISK_GPL_KEY, "Set variables and functions on other channels")
 
static int func_export_write (struct ast_channel *chan, const char *function, char *data, const char *value)
 
static int load_module (void)
 
static int unload_module (void)
 

Variables

static struct ast_custom_function export_function
 

Detailed Description

Set variables and functions on other channels.

Author
Naveen Albert aster.nosp@m.isk@.nosp@m.phrea.nosp@m.knet.nosp@m..org

Definition in file func_export.c.

Function Documentation

◆ AST_MODULE_INFO_STANDARD_EXTENDED()

AST_MODULE_INFO_STANDARD_EXTENDED ( ASTERISK_GPL_KEY  ,
"Set variables and functions on other channels  
)

◆ func_export_write()

static int func_export_write ( struct ast_channel chan,
const char *  function,
char *  data,
const char *  value 
)
static

Definition at line 63 of file func_export.c.

64{
65 struct ast_channel *ochan;
66
68 AST_APP_ARG(channel);
70 );
72
73 if (!args.channel) {
74 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", function);
75 return -1;
76 }
77 if (!args.var) {
78 ast_log(LOG_WARNING, "No variable name was provided to %s function.\n", function);
79 return -1;
80 }
81 ochan = ast_channel_get_by_name(args.channel);
82 if (!ochan) {
83 ast_log(LOG_WARNING, "Channel '%s' not found! '%s' not set.\n", args.channel, args.var);
84 return -1;
85 }
86
88 ast_channel_unref(ochan);
89 return 0;
90}
#define var
Definition: ast_expr2f.c:605
#define ast_log
Definition: astobj2.c:42
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2958
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Definition: channel.c:1454
#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.
#define LOG_WARNING
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
Main Channel structure associated with a channel.
const char * data
int value
Definition: syslog.c:37
const char * args

References args, AST_APP_ARG, ast_channel_get_by_name(), ast_channel_unref, AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_channel::data, LOG_WARNING, pbx_builtin_setvar_helper(), value, and var.

◆ load_module()

static int load_module ( void  )
static

Definition at line 102 of file func_export.c.

103{
105}
static struct ast_custom_function export_function
Definition: func_export.c:92
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1558

References ast_custom_function_register, and export_function.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 97 of file func_export.c.

98{
100}
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.

References ast_custom_function_unregister(), and export_function.

Variable Documentation

◆ export_function

struct ast_custom_function export_function
static
Initial value:
= {
.name = "EXPORT",
}
static int func_export_write(struct ast_channel *chan, const char *function, char *data, const char *value)
Definition: func_export.c:63

Definition at line 92 of file func_export.c.

Referenced by load_module(), and unload_module().