Asterisk - The Open Source Telephony Project GIT-master-2de1a68
Functions | Variables
app_reload.c File Reference

Reload Asterisk modules. More...

#include "asterisk.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
Include dependency graph for app_reload.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD_EXTENDED (ASTERISK_GPL_KEY, "Reload module(s)")
 
static int load_module (void)
 
static int reload_exec (struct ast_channel *chan, const char *data)
 
static int unload_module (void)
 

Variables

static char * app = "Reload"
 

Detailed Description

Reload Asterisk modules.

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

Definition in file app_reload.c.

Function Documentation

◆ AST_MODULE_INFO_STANDARD_EXTENDED()

AST_MODULE_INFO_STANDARD_EXTENDED ( ASTERISK_GPL_KEY  ,
"Reload module(s)"   
)

◆ load_module()

static int load_module ( void  )
static

Definition at line 110 of file app_reload.c.

111{
113}
static int reload_exec(struct ast_channel *chan, const char *data)
Definition: app_reload.c:81
static char * app
Definition: app_reload.c:79
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

References app, ast_register_application_xml, and reload_exec().

◆ reload_exec()

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

Definition at line 81 of file app_reload.c.

82{
83 char *targets, *target = NULL;
85
86 targets = ast_strdupa(data);
88 if (ast_strlen_zero(targets)) { /* Reload everything */
89 res = ast_module_reload(targets);
90 } else {
91 while((target = ast_strsep(&targets, ',', AST_STRSEP_ALL))) {
92 res |= ast_module_reload(target);
93 }
94 }
96
97 if (res == AST_MODULE_RELOAD_SUCCESS) {
98 pbx_builtin_setvar_helper(chan, "RELOADSTATUS", "SUCCESS");
99 } else {
100 pbx_builtin_setvar_helper(chan, "RELOADSTATUS", "FAILURE");
101 }
102 return 0;
103}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:200
ast_module_reload_result
Possible return types for ast_module_reload.
Definition: module.h:109
@ AST_MODULE_RELOAD_SUCCESS
Definition: module.h:110
enum ast_module_reload_result ast_module_reload(const char *name)
Reload asterisk modules.
Definition: loader.c:1567
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.
#define NULL
Definition: resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
@ AST_STRSEP_ALL
Definition: strings.h:258
char * ast_strsep(char **s, const char sep, uint32_t flags)
Act like strsep but ignore separators inside quotes.
Definition: utils.c:1835

References ast_autoservice_start(), ast_autoservice_stop(), ast_module_reload(), AST_MODULE_RELOAD_SUCCESS, ast_strdupa, ast_strlen_zero(), ast_strsep(), AST_STRSEP_ALL, NULL, and pbx_builtin_setvar_helper().

Referenced by load_module().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 105 of file app_reload.c.

106{
108}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References app, and ast_unregister_application().

Variable Documentation

◆ app

char* app = "Reload"
static

Definition at line 79 of file app_reload.c.

Referenced by load_module(), and unload_module().