#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"

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.
| static char* builtin_function_timeout_read | ( | struct ast_channel * | chan, | |
| char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
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 (!chan) 00046 return ""; 00047 00048 if (!data) { 00049 ast_log(LOG_ERROR, "Must specify type of timeout to get.\n"); 00050 return NULL; 00051 } 00052 00053 switch(*data) { 00054 case 'a': 00055 case 'A': 00056 if (chan->whentohangup == 0) { 00057 ast_copy_string(buf, "0", len); 00058 } else { 00059 time(&myt); 00060 snprintf(buf, len, "%d", (int) (chan->whentohangup - myt)); 00061 } 00062 break; 00063 00064 case 'r': 00065 case 'R': 00066 if (chan->pbx) { 00067 snprintf(buf, len, "%d", chan->pbx->rtimeout); 00068 } 00069 break; 00070 00071 case 'd': 00072 case 'D': 00073 if (chan->pbx) { 00074 snprintf(buf, len, "%d", chan->pbx->dtimeout); 00075 } 00076 break; 00077 00078 default: 00079 ast_log(LOG_ERROR, "Unknown timeout type specified.\n"); 00080 break; 00081 } 00082 00083 return buf; 00084 }
| static void builtin_function_timeout_write | ( | struct ast_channel * | chan, | |
| char * | cmd, | |||
| char * | data, | |||
| const char * | value | |||
| ) | [static] |
Definition at line 86 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.
00087 { 00088 int x; 00089 char timestr[64]; 00090 struct tm myt; 00091 00092 if (!chan) 00093 return; 00094 00095 if (!data) { 00096 ast_log(LOG_ERROR, "Must specify type of timeout to set.\n"); 00097 return; 00098 } 00099 00100 if (!value) 00101 return; 00102 00103 x = atoi(value); 00104 00105 switch(*data) { 00106 case 'a': 00107 case 'A': 00108 ast_channel_setwhentohangup(chan, x); 00109 if (option_verbose > 2) { 00110 if (chan->whentohangup) { 00111 strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S UTC", gmtime_r(&chan->whentohangup, &myt)); 00112 ast_verbose( VERBOSE_PREFIX_3 "Channel will hangup at %s.\n", timestr); 00113 } else { 00114 ast_verbose( VERBOSE_PREFIX_3 "Channel hangup cancelled.\n"); 00115 } 00116 } 00117 break; 00118 00119 case 'r': 00120 case 'R': 00121 if (chan->pbx) { 00122 chan->pbx->rtimeout = x; 00123 if (option_verbose > 2) 00124 ast_verbose( VERBOSE_PREFIX_3 "Response timeout set to %d\n", chan->pbx->rtimeout); 00125 } 00126 break; 00127 00128 case 'd': 00129 case 'D': 00130 if (chan->pbx) { 00131 chan->pbx->dtimeout = x; 00132 if (option_verbose > 2) 00133 ast_verbose( VERBOSE_PREFIX_3 "Digit timeout set to %d\n", chan->pbx->dtimeout); 00134 } 00135 break; 00136 00137 default: 00138 ast_log(LOG_ERROR, "Unknown timeout type specified.\n"); 00139 break; 00140 } 00141 }
struct ast_custom_function timeout_function [static] |
Definition at line 146 of file func_timeout.c.
1.5.6