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