#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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } |
static char * | app = "SoftHangup" |
static struct ast_app_option | app_opts [128] = { [ 'a' ] = { .flag = OPTION_ALL },} |
static struct ast_module_info * | ast_module_info = &__mod_info |
static char * | desc |
static char * | synopsis = "Soft Hangup Application" |
Definition in file app_softhangup.c.
anonymous enum |
static void __reg_module | ( | void | ) | [static] |
Definition at line 122 of file app_softhangup.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 122 of file app_softhangup.c.
static int load_module | ( | void | ) | [static] |
Definition at line 117 of file app_softhangup.c.
References ast_register_application, and softhangup_exec().
00118 { 00119 return ast_register_application(app, softhangup_exec, synopsis, desc); 00120 }
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 = {0}; 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 /* use strrchr() because Foo/Bar-Z could actually be Foo/B-a-r-Z */ 00092 cut = strrchr(name,'-'); 00093 } 00094 /* Get rid of what we've cut */ 00095 if (cut) 00096 *cut = 0; 00097 } 00098 if (!strcasecmp(name, args.channel)) { 00099 ast_log(LOG_WARNING, "Soft hanging %s up.\n", c->name); 00100 ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT); 00101 if (!ast_test_flag(&flags, OPTION_ALL)) { 00102 ast_channel_unlock(c); 00103 break; 00104 } 00105 } 00106 ast_channel_unlock(c); 00107 } 00108 00109 return 0; 00110 }
static int unload_module | ( | void | ) | [static] |
Definition at line 112 of file app_softhangup.c.
References ast_unregister_application().
00113 { 00114 return ast_unregister_application(app); 00115 }
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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 122 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.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 122 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.