#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include "asterisk.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:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Functions | |
static char * | builtin_function_timeout_read (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static void | builtin_function_timeout_write (struct ast_channel *chan, char *cmd, char *data, const char *value) |
Variables | |
static struct ast_custom_function | timeout_function |
Definition in file func_timeout.c.
|
Definition at line 41 of file func_timeout.c. References ast_log(), ast_pbx::dtimeout, LOG_ERROR, ast_channel::pbx, ast_pbx::rtimeout, and ast_channel::whentohangup. 00042 { 00043 time_t myt; 00044 00045 if (!data) { 00046 ast_log(LOG_ERROR, "Must specify type of timeout to get."); 00047 return NULL; 00048 } 00049 00050 switch(*data) { 00051 case 'a': 00052 case 'A': 00053 if (chan->whentohangup == 0) { 00054 ast_copy_string(buf, "0", len); 00055 } else { 00056 time(&myt); 00057 snprintf(buf, len, "%d", (int) (chan->whentohangup - myt)); 00058 } 00059 break; 00060 00061 case 'r': 00062 case 'R': 00063 if (chan->pbx) { 00064 snprintf(buf, len, "%d", chan->pbx->rtimeout); 00065 } 00066 break; 00067 00068 case 'd': 00069 case 'D': 00070 if (chan->pbx) { 00071 snprintf(buf, len, "%d", chan->pbx->dtimeout); 00072 } 00073 break; 00074 00075 default: 00076 ast_log(LOG_ERROR, "Unknown timeout type specified."); 00077 break; 00078 } 00079 00080 return buf; 00081 }
|
|
Definition at line 83 of file func_timeout.c. References ast_channel_setwhentohangup(), ast_log(), ast_verbose(), LOG_ERROR, option_verbose, and VERBOSE_PREFIX_3. 00084 { 00085 int x; 00086 char timestr[64]; 00087 struct tm myt; 00088 00089 if (!data) { 00090 ast_log(LOG_ERROR, "Must specify type of timeout to set."); 00091 return; 00092 } 00093 00094 if (!value) 00095 return; 00096 00097 x = atoi(value); 00098 00099 switch(*data) { 00100 case 'a': 00101 case 'A': 00102 ast_channel_setwhentohangup(chan, x); 00103 if (option_verbose > 2) { 00104 if (chan->whentohangup) { 00105 strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S UTC", gmtime_r(&chan->whentohangup, &myt)); 00106 ast_verbose( VERBOSE_PREFIX_3 "Channel will hangup at %s.\n", timestr); 00107 } else { 00108 ast_verbose( VERBOSE_PREFIX_3 "Channel hangup cancelled.\n"); 00109 } 00110 } 00111 break; 00112 00113 case 'r': 00114 case 'R': 00115 if (chan->pbx) { 00116 chan->pbx->rtimeout = x; 00117 if (option_verbose > 2) 00118 ast_verbose( VERBOSE_PREFIX_3 "Response timeout set to %d\n", chan->pbx->rtimeout); 00119 } 00120 break; 00121 00122 case 'd': 00123 case 'D': 00124 if (chan->pbx) { 00125 chan->pbx->dtimeout = x; 00126 if (option_verbose > 2) 00127 ast_verbose( VERBOSE_PREFIX_3 "Digit timeout set to %d\n", chan->pbx->dtimeout); 00128 } 00129 break; 00130 00131 default: 00132 ast_log(LOG_ERROR, "Unknown timeout type specified."); 00133 break; 00134 } 00135 }
|
|
Definition at line 140 of file func_timeout.c. |