Thu Jul 9 13:40:49 2009

Asterisk developer's documentation


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"

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, void *data)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .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 = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, }
static char * app = "SoftHangup"
static struct ast_app_option app_opts [128] = { [ 'a' ] = { .flag = OPTION_ALL },}
static const struct ast_module_infoast_module_info = &__mod_info
static char * desc
static char * synopsis = "Soft Hangup Application"


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

00049      {
00050    OPTION_ALL = (1 << 0),
00051 };


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 120 of file app_softhangup.c.

static void __unreg_module ( void   )  [static]

Definition at line 120 of file app_softhangup.c.

static int load_module ( void   )  [static]

Definition at line 115 of file app_softhangup.c.

References ast_register_application, and softhangup_exec().

00116 {
00117    return ast_register_application(app, softhangup_exec, synopsis, desc);
00118 }

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

Definition at line 57 of file app_softhangup.c.

References app_opts, AST_APP_ARG, ast_app_parse_options(), AST_CHANNEL_NAME, ast_channel_unlock, 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_walk_channel_by_name_prefix_locked(), ast_flags::flags, LOG_WARNING, ast_channel::name, name, OPTION_ALL, parse(), ast_channel::tech, and ast_channel_tech::type.

Referenced by load_module().

00058 {
00059    struct ast_channel *c = NULL;
00060    char *cut, *opts[0];
00061    char name[AST_CHANNEL_NAME] = "", *parse;
00062    struct ast_flags flags;
00063    int lenmatch;
00064    AST_DECLARE_APP_ARGS(args,
00065       AST_APP_ARG(channel);
00066       AST_APP_ARG(options);
00067    );
00068    
00069    if (ast_strlen_zero(data)) {
00070       ast_log(LOG_WARNING, "SoftHangup requires an argument (Technology/resource)\n");
00071       return 0;
00072    }
00073 
00074    parse = ast_strdupa(data);
00075    AST_STANDARD_APP_ARGS(args, parse);
00076 
00077    if (args.argc == 2)
00078       ast_app_parse_options(app_opts, &flags, opts, args.options);
00079    lenmatch = strlen(args.channel);
00080 
00081    for (c = ast_walk_channel_by_name_prefix_locked(NULL, args.channel, lenmatch);
00082        c;
00083        c = ast_walk_channel_by_name_prefix_locked(c, args.channel, lenmatch)) {
00084       ast_copy_string(name, c->name, sizeof(name));
00085       if (ast_test_flag(&flags, OPTION_ALL)) {
00086          /* CAPI is set up like CAPI[foo/bar]/clcnt */ 
00087          if (!strcmp(c->tech->type, "CAPI")) 
00088             cut = strrchr(name, '/');
00089          /* Basically everything else is Foo/Bar-Z */
00090          else
00091             cut = strchr(name, '-');
00092          /* Get rid of what we've cut */
00093          if (cut)
00094             *cut = 0;
00095       }
00096       if (!strcasecmp(name, args.channel)) {
00097          ast_log(LOG_WARNING, "Soft hanging %s up.\n", c->name);
00098          ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
00099          if (!ast_test_flag(&flags, OPTION_ALL)) {
00100             ast_channel_unlock(c);
00101             break;
00102          }
00103       }
00104       ast_channel_unlock(c);
00105    }
00106 
00107    return 0;
00108 }

static int unload_module ( void   )  [static]

Definition at line 110 of file app_softhangup.c.

References ast_unregister_application().

00111 {
00112    return ast_unregister_application(app);
00113 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .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 = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, } [static]

Definition at line 120 of file app_softhangup.c.

char* app = "SoftHangup" [static]

Definition at line 47 of file app_softhangup.c.

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

Definition at line 55 of file app_softhangup.c.

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 120 of file app_softhangup.c.

char* desc [static]

Initial value:

 "  SoftHangup(Technology/resource[,options]):\n"
"Hangs up the requested channel.  If there are no channels to hangup,\n"
"the application will report it.\n"
"  Options:\n"
"     'a'  - hang up all channels on a specified device instead of a single resource\n"

Definition at line 41 of file app_softhangup.c.

char* synopsis = "Soft Hangup Application" [static]

Definition at line 39 of file app_softhangup.c.


Generated on Thu Jul 9 13:40:49 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7