Fri Aug 17 00:17:23 2018

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

 AST_APP_OPTIONS (app_opts,{AST_APP_OPTION('a', OPTION_ALL),})
 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Hangs up the requested channel")
static int load_module (void)
static int softhangup_exec (struct ast_channel *chan, const char *data)
static int unload_module (void)

Variables

static char * app = "SoftHangup"

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

AST_APP_OPTIONS ( app_opts   ) 
AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Hangs up the requested channel"   
)
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 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_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, LOG_WARNING, name, OPTION_ALL, parse(), ast_channel::tech, and ast_channel_tech::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, c->name, sizeof(name));
00108       if (ast_test_flag(&flags, OPTION_ALL)) {
00109          /* CAPI is set up like CAPI[foo/bar]/clcnt */ 
00110          if (!strcmp(c->tech->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", c->name);
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

char* app = "SoftHangup" [static]

Definition at line 66 of file app_softhangup.c.


Generated on 17 Aug 2018 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1