#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 292 of file func_realtime.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 292 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(), ast_variables_destroy(), 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 ast_variables_destroy(head); 00090 00091 if (chan) 00092 ast_autoservice_stop(chan); 00093 00094 return 0; 00095 }
static int function_realtime_readdestroy | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 177 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(), ast_variables_destroy(), chan, LOG_WARNING, ast_variable::next, SENTINEL, ast_str::str, and var.
00178 { 00179 struct ast_variable *var, *head; 00180 struct ast_str *out; 00181 size_t resultslen; 00182 int n; 00183 AST_DECLARE_APP_ARGS(args, 00184 AST_APP_ARG(family); 00185 AST_APP_ARG(fieldmatch); 00186 AST_APP_ARG(value); 00187 AST_APP_ARG(delim1); 00188 AST_APP_ARG(delim2); 00189 ); 00190 00191 if (ast_strlen_zero(data)) { 00192 ast_log(LOG_WARNING, "Syntax: REALTIME_DESTROY(family,fieldmatch[,value[,delim1[,delim2]]]) - missing argument!\n"); 00193 return -1; 00194 } 00195 00196 AST_STANDARD_APP_ARGS(args, data); 00197 00198 if (!args.delim1) 00199 args.delim1 = ","; 00200 if (!args.delim2) 00201 args.delim2 = "="; 00202 00203 if (chan) 00204 ast_autoservice_start(chan); 00205 00206 head = ast_load_realtime_all(args.family, args.fieldmatch, args.value, SENTINEL); 00207 00208 if (!head) { 00209 if (chan) 00210 ast_autoservice_stop(chan); 00211 return -1; 00212 } 00213 00214 resultslen = 0; 00215 n = 0; 00216 for (var = head; var; n++, var = var->next) 00217 resultslen += strlen(var->name) + strlen(var->value); 00218 /* add space for delimiters and final '\0' */ 00219 resultslen += n * (strlen(args.delim1) + strlen(args.delim2)) + 1; 00220 00221 out = ast_str_alloca(resultslen); 00222 for (var = head; var; var = var->next) { 00223 ast_str_append(&out, 0, "%s%s%s%s", var->name, args.delim2, var->value, args.delim1); 00224 } 00225 ast_copy_string(buf, out->str, len); 00226 00227 ast_destroy_realtime(args.family, args.fieldmatch, args.value, SENTINEL); 00228 ast_variables_destroy(head); 00229 00230 if (chan) 00231 ast_autoservice_stop(chan); 00232 00233 return 0; 00234 }
static int function_realtime_store | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | data, | |||
const char * | value | |||
) | [static] |
Definition at line 129 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.
00130 { 00131 int res = 0; 00132 char storeid[32]; 00133 char *valcopy; 00134 AST_DECLARE_APP_ARGS(a, 00135 AST_APP_ARG(family); 00136 AST_APP_ARG(f)[30]; /* fields */ 00137 ); 00138 00139 AST_DECLARE_APP_ARGS(v, 00140 AST_APP_ARG(v)[30]; /* values */ 00141 ); 00142 00143 if (ast_strlen_zero(data)) { 00144 ast_log(LOG_WARNING, "Syntax: REALTIME_STORE(family,field1,field2,...,field30) - missing argument!\n"); 00145 return -1; 00146 } 00147 00148 if (chan) 00149 ast_autoservice_start(chan); 00150 00151 valcopy = ast_strdupa(value); 00152 AST_STANDARD_APP_ARGS(a, data); 00153 AST_STANDARD_APP_ARGS(v, valcopy); 00154 00155 res = ast_store_realtime(a.family, 00156 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], 00157 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], 00158 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], 00159 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], 00160 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], 00161 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 00162 ); 00163 00164 if (res < 0) { 00165 ast_log(LOG_WARNING, "Failed to store. Check the debug log for possible data repository related entries.\n"); 00166 } else { 00167 snprintf(storeid, sizeof(storeid), "%d", res); 00168 pbx_builtin_setvar_helper(chan, "RTSTOREID", storeid); 00169 } 00170 00171 if (chan) 00172 ast_autoservice_stop(chan); 00173 00174 return 0; 00175 }
static int function_realtime_write | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | data, | |||
const char * | value | |||
) | [static] |
Definition at line 97 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.
00098 { 00099 int res = 0; 00100 AST_DECLARE_APP_ARGS(args, 00101 AST_APP_ARG(family); 00102 AST_APP_ARG(fieldmatch); 00103 AST_APP_ARG(value); 00104 AST_APP_ARG(field); 00105 ); 00106 00107 if (ast_strlen_zero(data)) { 00108 ast_log(LOG_WARNING, "Syntax: REALTIME(family,fieldmatch,value,newcol) - missing argument!\n"); 00109 return -1; 00110 } 00111 00112 if (chan) 00113 ast_autoservice_start(chan); 00114 00115 AST_STANDARD_APP_ARGS(args, data); 00116 00117 res = ast_update_realtime(args.family, args.fieldmatch, args.value, args.field, (char *)value, SENTINEL); 00118 00119 if (res < 0) { 00120 ast_log(LOG_WARNING, "Failed to update. Check the debug log for possible data repository related entries.\n"); 00121 } 00122 00123 if (chan) 00124 ast_autoservice_stop(chan); 00125 00126 return 0; 00127 }
static int load_module | ( | void | ) | [static] |
Definition at line 283 of file func_realtime.c.
References ast_custom_function_register, realtime_destroy_function, realtime_function, and realtime_store_function.
00284 { 00285 int res = 0; 00286 res |= ast_custom_function_register(&realtime_function); 00287 res |= ast_custom_function_register(&realtime_store_function); 00288 res |= ast_custom_function_register(&realtime_destroy_function); 00289 return res; 00290 }
static int unload_module | ( | void | ) | [static] |
Definition at line 274 of file func_realtime.c.
References ast_custom_function_unregister(), realtime_destroy_function, realtime_function, and realtime_store_function.
00275 { 00276 int res = 0; 00277 res |= ast_custom_function_unregister(&realtime_function); 00278 res |= ast_custom_function_unregister(&realtime_store_function); 00279 res |= ast_custom_function_unregister(&realtime_destroy_function); 00280 return res; 00281 }
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 292 of file func_realtime.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 292 of file func_realtime.c.