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)
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 struct ast_app_option app_opts [128] = { [ 'a' ] = { .flag = OPTION_ALL },}
static struct ast_module_infoast_module_info = &__mod_info


Detailed Description

SoftHangup application.

Author:
Mark Spencer <markster@digium.com>

Definition in file app_softhangup.c.


Enumeration Type Documentation

anonymous enum

Enumerator:
OPTION_ALL 

Definition at line 68 of file app_softhangup.c.

00068      {
00069    OPTION_ALL = (1 << 0),
00070 };


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 149 of file app_softhangup.c.

static void __unreg_module ( void   )  [static]

Definition at line 149 of file app_softhangup.c.

static int load_module ( void   )  [static]

Definition at line 144 of file app_softhangup.c.

References ast_register_application_xml, and softhangup_exec().

00145 {
00146    return ast_register_application_xml(app, softhangup_exec);
00147 }

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

Definition at line 76 of file app_softhangup.c.

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, c, LOG_WARNING, name, NULL, OPTION_ALL, parse(), and type.

Referenced by load_module().

00077 {
00078    struct ast_channel *c = NULL;
00079    char *cut, *opts[0];
00080    char name[AST_CHANNEL_NAME] = "", *parse;
00081    struct ast_flags flags = {0};
00082    int lenmatch;
00083    AST_DECLARE_APP_ARGS(args,
00084       AST_APP_ARG(channel);
00085       AST_APP_ARG(options);
00086    );
00087    struct ast_channel_iterator *iter;
00088    
00089    if (ast_strlen_zero(data)) {
00090       ast_log(LOG_WARNING, "SoftHangup requires an argument (Technology/resource)\n");
00091       return 0;
00092    }
00093 
00094    parse = ast_strdupa(data);
00095    AST_STANDARD_APP_ARGS(args, parse);
00096 
00097    if (args.argc == 2)
00098       ast_app_parse_options(app_opts, &flags, opts, args.options);
00099    lenmatch = strlen(args.channel);
00100 
00101    if (!(iter = ast_channel_iterator_by_name_new(args.channel, lenmatch))) {
00102       return -1;
00103    }
00104 
00105    while ((c = ast_channel_iterator_next(iter))) {
00106       ast_channel_lock(c);
00107       ast_copy_string(name, ast_channel_name(c), sizeof(name));
00108       if (ast_test_flag(&flags, OPTION_ALL)) {
00109          /* CAPI is set up like CAPI[foo/bar]/clcnt */ 
00110          if (!strcmp(ast_channel_tech(c)->type, "CAPI")) {
00111             cut = strrchr(name, '/');
00112          /* Basically everything else is Foo/Bar-Z */
00113          } else {
00114             /* use strrchr() because Foo/Bar-Z could actually be Foo/B-a-r-Z */
00115             cut = strrchr(name,'-');
00116          }
00117          /* Get rid of what we've cut */
00118          if (cut)
00119             *cut = 0;
00120       }
00121       if (!strcasecmp(name, args.channel)) {
00122          ast_log(LOG_WARNING, "Soft hanging %s up.\n", ast_channel_name(c));
00123          ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
00124          if (!ast_test_flag(&flags, OPTION_ALL)) {
00125             ast_channel_unlock(c);
00126             c = ast_channel_unref(c);
00127             break;
00128          }
00129       }
00130       ast_channel_unlock(c);
00131       c = ast_channel_unref(c);
00132    }
00133 
00134    ast_channel_iterator_destroy(iter);
00135 
00136    return 0;
00137 }

static int unload_module ( void   )  [static]

Definition at line 139 of file app_softhangup.c.

References ast_unregister_application().

00140 {
00141    return ast_unregister_application(app);
00142 }


Variable Documentation

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 149 of file app_softhangup.c.

char* app = "SoftHangup" [static]

Definition at line 66 of file app_softhangup.c.

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

Definition at line 74 of file app_softhangup.c.

Definition at line 149 of file app_softhangup.c.


Generated on Thu Apr 16 06:28:44 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6