#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
Go to the source code of this file.
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 | AST_MODFLAG_BUILDSUM, .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 = "f450f61f60e761b3aa089ebed76ca8a5" , .load = load_module, .unload = unload_module, } |
static char * | app = "SoftHangup" |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static char * | desc |
static char * | synopsis = "Soft Hangup Application" |
Definition in file app_softhangup.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 121 of file app_softhangup.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 121 of file app_softhangup.c.
static int load_module | ( | void | ) | [static] |
Definition at line 116 of file app_softhangup.c.
References ast_register_application(), and softhangup_exec().
00117 { 00118 return ast_register_application(app, softhangup_exec, synopsis, desc); 00119 }
static int softhangup_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 56 of file app_softhangup.c.
References AST_CHANNEL_NAME, ast_channel_walk_locked(), ast_copy_string(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_mutex_unlock(), ast_softhangup(), AST_SOFTHANGUP_EXPLICIT, ast_strdupa, ast_strlen_zero(), ast_channel::lock, LOG_WARNING, match(), ast_channel::name, name, ast_channel::tech, and ast_channel_tech::type.
Referenced by load_module().
00057 { 00058 struct ast_module_user *u; 00059 struct ast_channel *c=NULL; 00060 char *options, *cut, *cdata, *match; 00061 char name[AST_CHANNEL_NAME] = ""; 00062 int all = 0; 00063 00064 if (ast_strlen_zero(data)) { 00065 ast_log(LOG_WARNING, "SoftHangup requires an argument (Technology/resource)\n"); 00066 return 0; 00067 } 00068 00069 u = ast_module_user_add(chan); 00070 00071 cdata = ast_strdupa(data); 00072 match = strsep(&cdata, "|"); 00073 options = strsep(&cdata, "|"); 00074 all = options && strchr(options,'a'); 00075 c = ast_channel_walk_locked(NULL); 00076 while (c) { 00077 ast_copy_string(name, c->name, sizeof(name)); 00078 ast_mutex_unlock(&c->lock); 00079 /* XXX watch out, i think it is wrong to access c-> after unlocking! */ 00080 if (all) { 00081 /* CAPI is set up like CAPI[foo/bar]/clcnt */ 00082 if (!strcmp(c->tech->type, "CAPI")) 00083 cut = strrchr(name,'/'); 00084 /* Basically everything else is Foo/Bar-Z */ 00085 else 00086 cut = strchr(name,'-'); 00087 /* Get rid of what we've cut */ 00088 if (cut) 00089 *cut = 0; 00090 } 00091 if (!strcasecmp(name, match)) { 00092 ast_log(LOG_WARNING, "Soft hanging %s up.\n",c->name); 00093 ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT); 00094 if(!all) 00095 break; 00096 } 00097 c = ast_channel_walk_locked(c); 00098 } 00099 00100 ast_module_user_remove(u); 00101 00102 return 0; 00103 }
static int unload_module | ( | void | ) | [static] |
Definition at line 105 of file app_softhangup.c.
References ast_module_user_hangup_all, and ast_unregister_application().
00106 { 00107 int res; 00108 00109 res = ast_unregister_application(app); 00110 00111 ast_module_user_hangup_all(); 00112 00113 return res; 00114 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .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 = "f450f61f60e761b3aa089ebed76ca8a5" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 121 of file app_softhangup.c.
char* app = "SoftHangup" [static] |
Definition at line 53 of file app_softhangup.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 121 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' may contain the following letter:\n" " 'a' : hang up all channels on a specified device instead of a single resource\n"
Definition at line 47 of file app_softhangup.c.
char* synopsis = "Soft Hangup Application" [static] |
Definition at line 45 of file app_softhangup.c.