Sat Aug 6 00:39:37 2011

Asterisk developer's documentation


app_softhangup.c File Reference

SoftHangup application. More...

#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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, }
static char * app = "SoftHangup"
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.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 123 of file app_softhangup.c.

static void __unreg_module ( void   )  [static]

Definition at line 123 of file app_softhangup.c.

static int load_module ( void   )  [static]

Definition at line 118 of file app_softhangup.c.

References ast_register_application(), and softhangup_exec().

00119 {
00120    return ast_register_application(app, softhangup_exec, synopsis, desc);
00121 }

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             /* use strrchr() because Foo/Bar-Z could actually be Foo/B-a-r-Z */
00087             cut = strrchr(name,'-');
00088          }
00089          /* Get rid of what we've cut */
00090          if (cut)
00091             *cut = 0;
00092       }
00093       if (!strcasecmp(name, match)) {
00094          ast_log(LOG_WARNING, "Soft hanging %s up.\n",c->name);
00095          ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
00096          if(!all)
00097             break;
00098       }
00099       c = ast_channel_walk_locked(c);
00100    }
00101    
00102    ast_module_user_remove(u);
00103 
00104    return 0;
00105 }

static int unload_module ( void   )  [static]

Definition at line 107 of file app_softhangup.c.

References ast_module_user_hangup_all, and ast_unregister_application().

00108 {
00109    int res;
00110 
00111    res = ast_unregister_application(app);
00112 
00113    ast_module_user_hangup_all();
00114 
00115    return res; 
00116 }


Variable Documentation

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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static]

Definition at line 123 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 123 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.


Generated on Sat Aug 6 00:39:37 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7