#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 | |
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 187 of file func_timeout.c.
References ast_custom_function_register().
00188 { 00189 return ast_custom_function_register(&timeout_function); 00190 }
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_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 break; 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(), ast_pbx::dtimeout, LOG_ERROR, option_verbose, ast_channel::pbx, ast_pbx::rtimeout, VERBOSE_PREFIX_3, and ast_channel::whentohangup.
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 00109 switch (*data) { 00110 case 'a': 00111 case 'A': 00112 ast_channel_setwhentohangup(chan, x); 00113 if (option_verbose > 2) { 00114 if (chan->whentohangup) { 00115 strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S UTC", 00116 gmtime_r(&chan->whentohangup, &myt)); 00117 ast_verbose(VERBOSE_PREFIX_3 "Channel will hangup at %s.\n", 00118 timestr); 00119 } else { 00120 ast_verbose(VERBOSE_PREFIX_3 "Channel hangup cancelled.\n"); 00121 } 00122 } 00123 break; 00124 00125 case 'r': 00126 case 'R': 00127 if (chan->pbx) { 00128 chan->pbx->rtimeout = x; 00129 if (option_verbose > 2) 00130 ast_verbose(VERBOSE_PREFIX_3 "Response timeout set to %d\n", 00131 chan->pbx->rtimeout); 00132 } 00133 break; 00134 00135 case 'd': 00136 case 'D': 00137 if (chan->pbx) { 00138 chan->pbx->dtimeout = x; 00139 if (option_verbose > 2) 00140 ast_verbose(VERBOSE_PREFIX_3 "Digit timeout set to %d\n", 00141 chan->pbx->dtimeout); 00142 } 00143 break; 00144 00145 default: 00146 ast_log(LOG_ERROR, "Unknown timeout type specified.\n"); 00147 break; 00148 } 00149 00150 return 0; 00151 }
static int unload_module | ( | void | ) | [static] |
Definition at line 182 of file func_timeout.c.
References ast_custom_function_unregister().
00183 { 00184 return ast_custom_function_unregister(&timeout_function); 00185 }
struct ast_custom_function timeout_function [static] |
Definition at line 153 of file func_timeout.c.