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

SoftHangup application. More...

#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/app.h"
Include dependency graph for app_softhangup.c:

Go to the source code of this file.

Enumerations

enum  { OPTION_ALL = (1 << 0) }
 

Functions

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

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Hangs up the requested channel" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static char * app = "SoftHangup"
 
static const struct ast_app_option app_opts [128] = { [ 'a' ] = { .flag = OPTION_ALL }, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

SoftHangup application.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Definition in file app_softhangup.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
OPTION_ALL 

Definition at line 69 of file app_softhangup.c.

69 {
70 OPTION_ALL = (1 << 0),
71};
@ OPTION_ALL

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 150 of file app_softhangup.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 150 of file app_softhangup.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 150 of file app_softhangup.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 145 of file app_softhangup.c.

146{
148}
static int softhangup_exec(struct ast_channel *chan, const char *data)
static char * app
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition module.h:640

References app, ast_register_application_xml, and softhangup_exec().

◆ softhangup_exec()

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

Definition at line 77 of file app_softhangup.c.

78{
79 struct ast_channel *c = NULL;
80 char *cut, *opts[0];
81 char name[AST_CHANNEL_NAME] = "", *parse;
82 struct ast_flags flags = {0};
83 int lenmatch;
85 AST_APP_ARG(channel);
87 );
88 struct ast_channel_iterator *iter;
89
90 if (ast_strlen_zero(data)) {
91 ast_log(LOG_WARNING, "SoftHangup requires an argument (Technology/resource)\n");
92 return 0;
93 }
94
95 parse = ast_strdupa(data);
97
98 if (args.argc == 2)
99 ast_app_parse_options(app_opts, &flags, opts, args.options);
100 lenmatch = strlen(args.channel);
101
102 if (!(iter = ast_channel_iterator_by_name_new(args.channel, lenmatch))) {
103 return -1;
104 }
105
106 while ((c = ast_channel_iterator_next(iter))) {
109 if (ast_test_flag(&flags, OPTION_ALL)) {
110 /* CAPI is set up like CAPI[foo/bar]/clcnt */
111 if (!strcmp(ast_channel_tech(c)->type, "CAPI")) {
112 cut = strrchr(name, '/');
113 /* Basically everything else is Foo/Bar-Z */
114 } else {
115 /* use strrchr() because Foo/Bar-Z could actually be Foo/B-a-r-Z */
116 cut = strrchr(name,'-');
117 }
118 /* Get rid of what we've cut */
119 if (cut)
120 *cut = 0;
121 }
122 if (!strcasecmp(name, args.channel)) {
123 ast_verb(4, "Soft hanging %s up.\n", ast_channel_name(c));
125 if (!ast_test_flag(&flags, OPTION_ALL)) {
128 break;
129 }
130 }
133 }
134
136
137 return 0;
138}
static const struct ast_app_option app_opts[128]
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition astmm.h:298
#define ast_log
Definition astobj2.c:42
static const char type[]
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_channel_iterator * ast_channel_iterator_by_name_new(const char *name, size_t name_len)
Create a new channel iterator based on name.
Definition channel.c:1367
struct ast_channel_iterator * ast_channel_iterator_destroy(struct ast_channel_iterator *i)
Destroy a channel iterator.
Definition channel.c:1348
#define ast_channel_lock(chan)
Definition channel.h:2982
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
Definition channel.c:1387
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
Definition channel.c:2461
#define AST_CHANNEL_NAME
Definition channel.h:173
#define ast_channel_unref(c)
Decrease channel reference count.
Definition channel.h:3018
@ AST_SOFTHANGUP_EXPLICIT
Definition channel.h:1168
#define ast_channel_unlock(chan)
Definition channel.h:2983
static const char name[]
Definition format_mp3.c:68
#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.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition main/app.c:3066
#define ast_verb(level,...)
#define LOG_WARNING
static struct @519 args
#define NULL
Definition resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition strings.h:425
Structure to describe a channel "technology", ie a channel driver See for examples:
Definition channel.h:648
Main Channel structure associated with a channel.
Structure used to handle boolean flags.
Definition utils.h:220
unsigned int flags
Definition utils.h:221
static struct test_options options
static struct test_val c
#define ast_test_flag(p, flag)
Definition utils.h:64

References app_opts, args, AST_APP_ARG, ast_app_parse_options(), ast_channel_iterator_by_name_new(), ast_channel_iterator_destroy(), ast_channel_iterator_next(), ast_channel_lock, AST_CHANNEL_NAME, ast_channel_name(), ast_channel_unlock, ast_channel_unref, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log, ast_softhangup(), AST_SOFTHANGUP_EXPLICIT, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_verb, c, ast_flags::flags, LOG_WARNING, name, NULL, OPTION_ALL, options, and type.

Referenced by load_module().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 140 of file app_softhangup.c.

141{
143}
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_LOAD_ORDER , .description = "Hangs up the requested channel" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 150 of file app_softhangup.c.

◆ app

char* app = "SoftHangup"
static

Definition at line 67 of file app_softhangup.c.

Referenced by load_module(), and unload_module().

◆ app_opts

const struct ast_app_option app_opts[128] = { [ 'a' ] = { .flag = OPTION_ALL }, }
static

Definition at line 75 of file app_softhangup.c.

Referenced by softhangup_exec().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 150 of file app_softhangup.c.