#include "asterisk.h"
#include <stdio.h>
#include <stdlib.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"
Go to the source code of this file.
Functions | |
static int | acf_if (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Logical dialplan functions") | |
static int | exists (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | iftime (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | isnull (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | load_module (void) |
static int | set (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
static int | unload_module (void) |
Variables | |
static struct ast_custom_function | exists_function |
static struct ast_custom_function | if_function |
static struct ast_custom_function | if_time_function |
static struct ast_custom_function | isnull_function |
static struct ast_custom_function | set_function |
Definition in file func_logic.c.
static int acf_if | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 91 of file func_logic.c.
References ast_log(), ast_strip_quoted(), ast_strlen_zero(), LOG_WARNING, pbx_checkcondition(), S_OR, and strsep().
00093 { 00094 char *expr; 00095 char *iftrue; 00096 char *iffalse; 00097 00098 data = ast_strip_quoted(data, "\"", "\""); 00099 expr = strsep(&data, "?"); 00100 iftrue = strsep(&data, ":"); 00101 iffalse = data; 00102 00103 if (ast_strlen_zero(expr) || !(iftrue || iffalse)) { 00104 ast_log(LOG_WARNING, "Syntax IF(<expr>?[<true>][:<false>])\n"); 00105 return -1; 00106 } 00107 00108 expr = ast_strip(expr); 00109 if (iftrue) 00110 iftrue = ast_strip_quoted(iftrue, "\"", "\""); 00111 if (iffalse) 00112 iffalse = ast_strip_quoted(iffalse, "\"", "\""); 00113 00114 ast_copy_string(buf, pbx_checkcondition(expr) ? (S_OR(iftrue, "")) : (S_OR(iffalse, "")), len); 00115 00116 return 0; 00117 }
AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
"Logical dialplan functions" | ||||
) |
static int exists | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
static int iftime | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 57 of file func_logic.c.
References ast_build_timing(), ast_check_timing(), ast_log(), ast_strip_quoted(), ast_strlen_zero(), LOG_WARNING, and strsep().
00059 { 00060 struct ast_timing timing; 00061 char *expr; 00062 char *iftrue; 00063 char *iffalse; 00064 00065 data = ast_strip_quoted(data, "\"", "\""); 00066 expr = strsep(&data, "?"); 00067 iftrue = strsep(&data, ":"); 00068 iffalse = data; 00069 00070 if (ast_strlen_zero(expr) || !(iftrue || iffalse)) { 00071 ast_log(LOG_WARNING, 00072 "Syntax IFTIME(<timespec>?[<true>][:<false>])\n"); 00073 return -1; 00074 } 00075 00076 if (!ast_build_timing(&timing, expr)) { 00077 ast_log(LOG_WARNING, "Invalid Time Spec.\n"); 00078 return -1; 00079 } 00080 00081 if (iftrue) 00082 iftrue = ast_strip_quoted(iftrue, "\"", "\""); 00083 if (iffalse) 00084 iffalse = ast_strip_quoted(iffalse, "\"", "\""); 00085 00086 ast_copy_string(buf, ast_check_timing(&timing) ? iftrue : iffalse, len); 00087 00088 return 0; 00089 }
static int isnull | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
static int load_module | ( | void | ) | [static] |
Definition at line 191 of file func_logic.c.
References ast_custom_function_register().
00192 { 00193 int res = 0; 00194 00195 res |= ast_custom_function_register(&isnull_function); 00196 res |= ast_custom_function_register(&set_function); 00197 res |= ast_custom_function_register(&exists_function); 00198 res |= ast_custom_function_register(&if_function); 00199 res |= ast_custom_function_register(&if_time_function); 00200 00201 return res; 00202 }
static int set | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 119 of file func_logic.c.
References ast_log(), ast_strlen_zero(), len, LOG_WARNING, pbx_builtin_setvar_helper(), and strsep().
00121 { 00122 char *varname; 00123 char *val; 00124 00125 varname = strsep(&data, "="); 00126 val = data; 00127 00128 if (ast_strlen_zero(varname) || !val) { 00129 ast_log(LOG_WARNING, "Syntax SET(<varname>=[<value>])\n"); 00130 return -1; 00131 } 00132 00133 varname = ast_strip(varname); 00134 val = ast_strip(val); 00135 pbx_builtin_setvar_helper(chan, varname, val); 00136 ast_copy_string(buf, val, len); 00137 00138 return 0; 00139 }
static int unload_module | ( | void | ) | [static] |
Definition at line 178 of file func_logic.c.
References ast_custom_function_unregister().
00179 { 00180 int res = 0; 00181 00182 res |= ast_custom_function_unregister(&isnull_function); 00183 res |= ast_custom_function_unregister(&set_function); 00184 res |= ast_custom_function_unregister(&exists_function); 00185 res |= ast_custom_function_unregister(&if_function); 00186 res |= ast_custom_function_unregister(&if_time_function); 00187 00188 return res; 00189 }
struct ast_custom_function exists_function [static] |
Definition at line 155 of file func_logic.c.
struct ast_custom_function if_function [static] |
Definition at line 162 of file func_logic.c.
struct ast_custom_function if_time_function [static] |
Definition at line 170 of file func_logic.c.
struct ast_custom_function isnull_function [static] |
Definition at line 141 of file func_logic.c.
struct ast_custom_function set_function [static] |
Definition at line 148 of file func_logic.c.