#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/logger.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/options.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 | timeout_read (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | timeout_write (struct ast_channel *chan, char *cmd, char *data, const char *value) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Channel timeout dialplan functions" , .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 const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_custom_function | timeout_function |
Definition in file func_timeout.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 194 of file func_timeout.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 194 of file func_timeout.c.
static int load_module | ( | void | ) | [static] |
Definition at line 189 of file func_timeout.c.
References ast_custom_function_register(), and timeout_function.
00190 { 00191 return ast_custom_function_register(&timeout_function); 00192 }
static int timeout_read | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 43 of file func_timeout.c.
References ast_copy_string(), ast_log(), ast_pbx::dtimeout, LOG_ERROR, ast_channel::pbx, ast_pbx::rtimeout, and ast_channel::whentohangup.
00045 { 00046 time_t myt; 00047 00048 if (!chan) 00049 return -1; 00050 00051 if (!data) { 00052 ast_log(LOG_ERROR, "Must specify type of timeout to get.\n"); 00053 return -1; 00054 } 00055 00056 switch (*data) { 00057 case 'a': 00058 case 'A': 00059 if (chan->whentohangup == 0) { 00060 ast_copy_string(buf, "0", len); 00061 } else { 00062 time(&myt); 00063 snprintf(buf, len, "%d", (int) (chan->whentohangup - myt)); 00064 } 00065 break; 00066 00067 case 'r': 00068 case 'R': 00069 if (chan->pbx) { 00070 snprintf(buf, len, "%d", chan->pbx->rtimeout); 00071 } 00072 break; 00073 00074 case 'd': 00075 case 'D': 00076 if (chan->pbx) { 00077 snprintf(buf, len, "%d", chan->pbx->dtimeout); 00078 } 00079 break; 00080 00081 default: 00082 ast_log(LOG_ERROR, "Unknown timeout type specified.\n"); 00083 return -1; 00084 } 00085 00086 return 0; 00087 }
static int timeout_write | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
const char * | value | |||
) | [static] |
Definition at line 89 of file func_timeout.c.
References ast_channel_setwhentohangup(), ast_log(), ast_verbose(), LOG_ERROR, option_verbose, and VERBOSE_PREFIX_3.
00091 { 00092 int x; 00093 char timestr[64]; 00094 struct tm myt; 00095 00096 if (!chan) 00097 return -1; 00098 00099 if (!data) { 00100 ast_log(LOG_ERROR, "Must specify type of timeout to set.\n"); 00101 return -1; 00102 } 00103 00104 if (!value) 00105 return -1; 00106 00107 x = atoi(value); 00108 if (x < 0) 00109 x = 0; 00110 00111 switch (*data) { 00112 case 'a': 00113 case 'A': 00114 ast_channel_setwhentohangup(chan, x); 00115 if (option_verbose > 2) { 00116 if (chan->whentohangup) { 00117 strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S UTC", 00118 gmtime_r(&chan->whentohangup, &myt)); 00119 ast_verbose(VERBOSE_PREFIX_3 "Channel will hangup at %s.\n", 00120 timestr); 00121 } else { 00122 ast_verbose(VERBOSE_PREFIX_3 "Channel hangup cancelled.\n"); 00123 } 00124 } 00125 break; 00126 00127 case 'r': 00128 case 'R': 00129 if (chan->pbx) { 00130 chan->pbx->rtimeout = x; 00131 if (option_verbose > 2) 00132 ast_verbose(VERBOSE_PREFIX_3 "Response timeout set to %d\n", 00133 chan->pbx->rtimeout); 00134 } 00135 break; 00136 00137 case 'd': 00138 case 'D': 00139 if (chan->pbx) { 00140 chan->pbx->dtimeout = x; 00141 if (option_verbose > 2) 00142 ast_verbose(VERBOSE_PREFIX_3 "Digit timeout set to %d\n", 00143 chan->pbx->dtimeout); 00144 } 00145 break; 00146 00147 default: 00148 ast_log(LOG_ERROR, "Unknown timeout type specified.\n"); 00149 break; 00150 } 00151 00152 return 0; 00153 }
static int unload_module | ( | void | ) | [static] |
Definition at line 184 of file func_timeout.c.
References ast_custom_function_unregister(), and timeout_function.
00185 { 00186 return ast_custom_function_unregister(&timeout_function); 00187 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Channel timeout dialplan functions" , .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 194 of file func_timeout.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 194 of file func_timeout.c.
struct ast_custom_function timeout_function [static] |