#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
Go to the source code of this file.
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | function_realtime_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
static int | function_realtime_readdestroy (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
static int | function_realtime_store (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
static int | function_realtime_write (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
static int | load_module (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Read/Write/Store/Destroy values from a RealTime repository" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } |
static struct ast_module_info * | ast_module_info = &__mod_info |
ast_custom_function | realtime_destroy_function |
ast_custom_function | realtime_function |
ast_custom_function | realtime_store_function |
Definition in file func_realtime.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 289 of file func_realtime.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 289 of file func_realtime.c.
static int function_realtime_read | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 40 of file func_realtime.c.
References AST_APP_ARG, ast_autoservice_start(), ast_autoservice_stop(), ast_copy_string(), AST_DECLARE_APP_ARGS, ast_load_realtime_all(), ast_log(), AST_STANDARD_APP_ARGS, ast_str_alloca, ast_str_append(), ast_strlen_zero(), chan, LOG_WARNING, ast_variable::next, SENTINEL, ast_str::str, and var.
00041 { 00042 struct ast_variable *var, *head; 00043 struct ast_str *out; 00044 size_t resultslen; 00045 int n; 00046 AST_DECLARE_APP_ARGS(args, 00047 AST_APP_ARG(family); 00048 AST_APP_ARG(fieldmatch); 00049 AST_APP_ARG(value); 00050 AST_APP_ARG(delim1); 00051 AST_APP_ARG(delim2); 00052 ); 00053 00054 if (ast_strlen_zero(data)) { 00055 ast_log(LOG_WARNING, "Syntax: REALTIME(family,fieldmatch[,value[,delim1[,delim2]]]) - missing argument!\n"); 00056 return -1; 00057 } 00058 00059 AST_STANDARD_APP_ARGS(args, data); 00060 00061 if (!args.delim1) 00062 args.delim1 = ","; 00063 if (!args.delim2) 00064 args.delim2 = "="; 00065 00066 if (chan) 00067 ast_autoservice_start(chan); 00068 00069 head = ast_load_realtime_all(args.family, args.fieldmatch, args.value, SENTINEL); 00070 00071 if (!head) { 00072 if (chan) 00073 ast_autoservice_stop(chan); 00074 return -1; 00075 } 00076 00077 resultslen = 0; 00078 n = 0; 00079 for (var = head; var; n++, var = var->next) 00080 resultslen += strlen(var->name) + strlen(var->value); 00081 /* add space for delimiters and final '\0' */ 00082 resultslen += n * (strlen(args.delim1) + strlen(args.delim2)) + 1; 00083 00084 out = ast_str_alloca(resultslen); 00085 for (var = head; var; var = var->next) 00086 ast_str_append(&out, 0, "%s%s%s%s", var->name, args.delim2, var->value, args.delim1); 00087 ast_copy_string(buf, out->str, len); 00088 00089 if (chan) 00090 ast_autoservice_stop(chan); 00091 00092 return 0; 00093 }
static int function_realtime_readdestroy | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 175 of file func_realtime.c.
References AST_APP_ARG, ast_autoservice_start(), ast_autoservice_stop(), ast_copy_string(), AST_DECLARE_APP_ARGS, ast_destroy_realtime(), ast_load_realtime_all(), ast_log(), AST_STANDARD_APP_ARGS, ast_str_alloca, ast_str_append(), ast_strlen_zero(), chan, LOG_WARNING, ast_variable::next, SENTINEL, ast_str::str, and var.
00176 { 00177 struct ast_variable *var, *head; 00178 struct ast_str *out; 00179 size_t resultslen; 00180 int n; 00181 AST_DECLARE_APP_ARGS(args, 00182 AST_APP_ARG(family); 00183 AST_APP_ARG(fieldmatch); 00184 AST_APP_ARG(value); 00185 AST_APP_ARG(delim1); 00186 AST_APP_ARG(delim2); 00187 ); 00188 00189 if (ast_strlen_zero(data)) { 00190 ast_log(LOG_WARNING, "Syntax: REALTIME_DESTROY(family,fieldmatch[,value[,delim1[,delim2]]]) - missing argument!\n"); 00191 return -1; 00192 } 00193 00194 AST_STANDARD_APP_ARGS(args, data); 00195 00196 if (!args.delim1) 00197 args.delim1 = ","; 00198 if (!args.delim2) 00199 args.delim2 = "="; 00200 00201 if (chan) 00202 ast_autoservice_start(chan); 00203 00204 head = ast_load_realtime_all(args.family, args.fieldmatch, args.value, SENTINEL); 00205 00206 if (!head) { 00207 if (chan) 00208 ast_autoservice_stop(chan); 00209 return -1; 00210 } 00211 00212 resultslen = 0; 00213 n = 0; 00214 for (var = head; var; n++, var = var->next) 00215 resultslen += strlen(var->name) + strlen(var->value); 00216 /* add space for delimiters and final '\0' */ 00217 resultslen += n * (strlen(args.delim1) + strlen(args.delim2)) + 1; 00218 00219 out = ast_str_alloca(resultslen); 00220 for (var = head; var; var = var->next) { 00221 ast_str_append(&out, 0, "%s%s%s%s", var->name, args.delim2, var->value, args.delim1); 00222 } 00223 ast_copy_string(buf, out->str, len); 00224 00225 ast_destroy_realtime(args.family, args.fieldmatch, args.value, SENTINEL); 00226 00227 if (chan) 00228 ast_autoservice_stop(chan); 00229 00230 return 0; 00231 }
static int function_realtime_store | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | data, | |||
const char * | value | |||
) | [static] |
Definition at line 127 of file func_realtime.c.
References AST_APP_ARG, ast_autoservice_start(), ast_autoservice_stop(), AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_store_realtime(), ast_strdupa, ast_strlen_zero(), chan, f, LOG_WARNING, pbx_builtin_setvar_helper(), and SENTINEL.
00128 { 00129 int res = 0; 00130 char storeid[32]; 00131 char *valcopy; 00132 AST_DECLARE_APP_ARGS(a, 00133 AST_APP_ARG(family); 00134 AST_APP_ARG(f)[30]; /* fields */ 00135 ); 00136 00137 AST_DECLARE_APP_ARGS(v, 00138 AST_APP_ARG(v)[30]; /* values */ 00139 ); 00140 00141 if (ast_strlen_zero(data)) { 00142 ast_log(LOG_WARNING, "Syntax: REALTIME_STORE(family,field1,field2,...,field30) - missing argument!\n"); 00143 return -1; 00144 } 00145 00146 if (chan) 00147 ast_autoservice_start(chan); 00148 00149 valcopy = ast_strdupa(value); 00150 AST_STANDARD_APP_ARGS(a, data); 00151 AST_STANDARD_APP_ARGS(v, valcopy); 00152 00153 res = ast_store_realtime(a.family, 00154 a.f[0], v.v[0], a.f[1], v.v[1], a.f[2], v.v[2], a.f[3], v.v[3], a.f[4], v.v[4], 00155 a.f[5], v.v[5], a.f[6], v.v[6], a.f[7], v.v[7], a.f[8], v.v[8], a.f[9], v.v[9], 00156 a.f[10], v.v[10], a.f[11], v.v[11], a.f[12], v.v[12], a.f[13], v.v[13], a.f[14], v.v[14], 00157 a.f[15], v.v[15], a.f[16], v.v[16], a.f[17], v.v[17], a.f[18], v.v[18], a.f[19], v.v[19], 00158 a.f[20], v.v[20], a.f[21], v.v[21], a.f[22], v.v[22], a.f[23], v.v[23], a.f[24], v.v[24], 00159 a.f[25], v.v[25], a.f[26], v.v[26], a.f[27], v.v[27], a.f[28], v.v[28], a.f[29], v.v[29], SENTINEL 00160 ); 00161 00162 if (res < 0) { 00163 ast_log(LOG_WARNING, "Failed to store. Check the debug log for possible data repository related entries.\n"); 00164 } else { 00165 snprintf(storeid, sizeof(storeid), "%d", res); 00166 pbx_builtin_setvar_helper(chan, "RTSTOREID", storeid); 00167 } 00168 00169 if (chan) 00170 ast_autoservice_stop(chan); 00171 00172 return 0; 00173 }
static int function_realtime_write | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | data, | |||
const char * | value | |||
) | [static] |
Definition at line 95 of file func_realtime.c.
References AST_APP_ARG, ast_autoservice_start(), ast_autoservice_stop(), AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strlen_zero(), ast_update_realtime(), chan, LOG_WARNING, and SENTINEL.
00096 { 00097 int res = 0; 00098 AST_DECLARE_APP_ARGS(args, 00099 AST_APP_ARG(family); 00100 AST_APP_ARG(fieldmatch); 00101 AST_APP_ARG(value); 00102 AST_APP_ARG(field); 00103 ); 00104 00105 if (ast_strlen_zero(data)) { 00106 ast_log(LOG_WARNING, "Syntax: REALTIME(family,fieldmatch,value,newcol) - missing argument!\n"); 00107 return -1; 00108 } 00109 00110 if (chan) 00111 ast_autoservice_start(chan); 00112 00113 AST_STANDARD_APP_ARGS(args, data); 00114 00115 res = ast_update_realtime(args.family, args.fieldmatch, args.value, args.field, (char *)value, SENTINEL); 00116 00117 if (res < 0) { 00118 ast_log(LOG_WARNING, "Failed to update. Check the debug log for possible data repository related entries.\n"); 00119 } 00120 00121 if (chan) 00122 ast_autoservice_stop(chan); 00123 00124 return 0; 00125 }
static int load_module | ( | void | ) | [static] |
Definition at line 280 of file func_realtime.c.
References ast_custom_function_register, realtime_destroy_function, realtime_function, and realtime_store_function.
00281 { 00282 int res = 0; 00283 res |= ast_custom_function_register(&realtime_function); 00284 res |= ast_custom_function_register(&realtime_store_function); 00285 res |= ast_custom_function_register(&realtime_destroy_function); 00286 return res; 00287 }
static int unload_module | ( | void | ) | [static] |
Definition at line 271 of file func_realtime.c.
References ast_custom_function_unregister(), realtime_destroy_function, realtime_function, and realtime_store_function.
00272 { 00273 int res = 0; 00274 res |= ast_custom_function_unregister(&realtime_function); 00275 res |= ast_custom_function_unregister(&realtime_store_function); 00276 res |= ast_custom_function_unregister(&realtime_destroy_function); 00277 return res; 00278 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Read/Write/Store/Destroy values from a RealTime repository" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 289 of file func_realtime.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 289 of file func_realtime.c.