Asterisk - The Open Source Telephony Project  GIT-master-a24979a
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 = "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 = 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 66 of file app_softhangup.c.

66  {
67  OPTION_ALL = (1 << 0),
68 };
@ OPTION_ALL

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 147 of file app_softhangup.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 147 of file app_softhangup.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 147 of file app_softhangup.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 142 of file app_softhangup.c.

143 {
145 }
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:626

◆ softhangup_exec()

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

Definition at line 74 of file app_softhangup.c.

75 {
76  struct ast_channel *c = NULL;
77  char *cut, *opts[0];
78  char name[AST_CHANNEL_NAME] = "", *parse;
79  struct ast_flags flags = {0};
80  int lenmatch;
82  AST_APP_ARG(channel);
84  );
85  struct ast_channel_iterator *iter;
86 
87  if (ast_strlen_zero(data)) {
88  ast_log(LOG_WARNING, "SoftHangup requires an argument (Technology/resource)\n");
89  return 0;
90  }
91 
92  parse = ast_strdupa(data);
94 
95  if (args.argc == 2)
96  ast_app_parse_options(app_opts, &flags, opts, args.options);
97  lenmatch = strlen(args.channel);
98 
99  if (!(iter = ast_channel_iterator_by_name_new(args.channel, lenmatch))) {
100  return -1;
101  }
102 
103  while ((c = ast_channel_iterator_next(iter))) {
106  if (ast_test_flag(&flags, OPTION_ALL)) {
107  /* CAPI is set up like CAPI[foo/bar]/clcnt */
108  if (!strcmp(ast_channel_tech(c)->type, "CAPI")) {
109  cut = strrchr(name, '/');
110  /* Basically everything else is Foo/Bar-Z */
111  } else {
112  /* use strrchr() because Foo/Bar-Z could actually be Foo/B-a-r-Z */
113  cut = strrchr(name,'-');
114  }
115  /* Get rid of what we've cut */
116  if (cut)
117  *cut = 0;
118  }
119  if (!strcasecmp(name, args.channel)) {
120  ast_verb(4, "Soft hanging %s up.\n", ast_channel_name(c));
122  if (!ast_test_flag(&flags, OPTION_ALL)) {
124  c = ast_channel_unref(c);
125  break;
126  }
127  }
129  c = ast_channel_unref(c);
130  }
131 
133 
134  return 0;
135 }
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 void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1844
static const char type[]
Definition: chan_ooh323.c:109
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:1382
struct ast_channel_iterator * ast_channel_iterator_destroy(struct ast_channel_iterator *i)
Destroy a channel iterator.
Definition: channel.c:1354
@ AST_SOFTHANGUP_EXPLICIT
Definition: channel.h:1148
#define ast_channel_lock(chan)
Definition: channel.h:2922
const char * ast_channel_name(const struct ast_channel *chan)
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
Definition: channel.c:2470
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
Definition: channel.c:1416
#define AST_CHANNEL_NAME
Definition: channel.h:171
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2958
#define ast_channel_unlock(chan)
Definition: channel.h:2923
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
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:3126
#define ast_verb(level,...)
#define LOG_WARNING
#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:406
Main Channel structure associated with a channel.
Structure used to handle boolean flags.
Definition: utils.h:199
unsigned int flags
Definition: utils.h:200
const char * args
static struct test_options options
static struct test_val c
#define ast_test_flag(p, flag)
Definition: utils.h:63

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_tech(), 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, parse(), and type.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 137 of file app_softhangup.c.

138 {
140 }
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 = "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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 142 of file app_softhangup.c.

◆ app

char* app = "SoftHangup"
static

Definition at line 64 of file app_softhangup.c.

Referenced by unload_module().

◆ app_opts

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

Definition at line 64 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 147 of file app_softhangup.c.