Wed Jan 8 2020 09:50:13

Asterisk developer's documentation


func_realtime.c File Reference

REALTIME dialplan function. More...

#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 __init_buf1 (void)
 
static void __init_buf2 (void)
 
static void __init_buf3 (void)
 
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 function_realtime_writedestroy (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 Wrapper to execute REALTIME_DESTROY from a write operation. Allows execution even if live_dangerously is disabled. More...
 
static int load_module (void)
 
static int realtimefield_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
 
static struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_threadstorage buf1 = { .once = PTHREAD_ONCE_INIT , .key_init = __init_buf1 , .custom_init = NULL , }
 
static struct ast_threadstorage buf2 = { .once = PTHREAD_ONCE_INIT , .key_init = __init_buf2 , .custom_init = NULL , }
 
static struct ast_threadstorage buf3 = { .once = PTHREAD_ONCE_INIT , .key_init = __init_buf3 , .custom_init = NULL , }
 
static struct ast_custom_function realtime_destroy_function
 
static struct ast_custom_function realtime_function
 
static struct ast_custom_function realtime_store_function
 
static struct ast_custom_function realtimefield_function
 
static struct ast_custom_function realtimehash_function
 

Detailed Description

REALTIME dialplan function.

Author
BJ Weschke bwesc.nosp@m.hke@.nosp@m.btwte.nosp@m.ch.c.nosp@m.om

Definition in file func_realtime.c.

Function Documentation

static void __init_buf1 ( void  )
static

Definition at line 180 of file func_realtime.c.

185 {
static void __init_buf2 ( void  )
static

Definition at line 181 of file func_realtime.c.

185 {
static void __init_buf3 ( void  )
static

Definition at line 182 of file func_realtime.c.

185 {
static void __reg_module ( void  )
static

Definition at line 543 of file func_realtime.c.

static void __unreg_module ( void  )
static

Definition at line 543 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 184 of file func_realtime.c.

References args, 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_str_buffer(), ast_strlen_zero(), ast_variables_destroy(), LOG_WARNING, ast_variable::next, SENTINEL, value, and var.

185 {
186  struct ast_variable *var, *head;
187  struct ast_str *out;
188  size_t resultslen;
189  int n;
191  AST_APP_ARG(family);
192  AST_APP_ARG(fieldmatch);
194  AST_APP_ARG(delim1);
195  AST_APP_ARG(delim2);
196  );
197 
198  if (ast_strlen_zero(data)) {
199  ast_log(LOG_WARNING, "Syntax: REALTIME(family,fieldmatch[,matchvalue[,delim1[,delim2]]]) - missing argument!\n");
200  return -1;
201  }
202 
204 
205  if (!args.delim1)
206  args.delim1 = ",";
207  if (!args.delim2)
208  args.delim2 = "=";
209 
210  if (chan)
211  ast_autoservice_start(chan);
212 
213  head = ast_load_realtime_all(args.family, args.fieldmatch, args.value, SENTINEL);
214 
215  if (!head) {
216  if (chan)
217  ast_autoservice_stop(chan);
218  return -1;
219  }
220 
221  resultslen = 0;
222  n = 0;
223  for (var = head; var; n++, var = var->next)
224  resultslen += strlen(var->name) + strlen(var->value);
225  /* add space for delimiters and final '\0' */
226  resultslen += n * (strlen(args.delim1) + strlen(args.delim2)) + 1;
227 
228  if (resultslen > len) {
229  ast_log(LOG_WARNING, "Failed to fetch. Realtime data is too large: need %zu, have %zu.\n", resultslen, len);
230  return -1;
231  }
232 
233  /* len is going to be sensible, so we don't need to check for stack
234  * overflows here. */
235  out = ast_str_alloca(resultslen);
236  for (var = head; var; var = var->next)
237  ast_str_append(&out, 0, "%s%s%s%s", var->name, args.delim2, var->value, args.delim1);
238  ast_copy_string(buf, ast_str_buffer(out), len);
239 
240  ast_variables_destroy(head);
241 
242  if (chan)
243  ast_autoservice_stop(chan);
244 
245  return 0;
246 }
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:179
#define LOG_WARNING
Definition: logger.h:144
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Definition: app.h:572
struct ast_variable * ast_load_realtime_all(const char *family,...) attribute_sentinel
Definition: config.c:2536
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
#define var
Definition: ast_expr2f.c:606
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:900
#define ast_str_alloca(init_len)
Definition: strings.h:608
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: config.c:586
int value
Definition: syslog.c:39
#define SENTINEL
Definition: compiler.h:75
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:238
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
static struct @350 args
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
struct ast_variable * next
Definition: config.h:82
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
Definition: app.h:604
static int function_realtime_readdestroy ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 411 of file func_realtime.c.

References args, 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_str_buffer(), ast_strlen_zero(), ast_variables_destroy(), LOG_WARNING, ast_variable::next, SENTINEL, value, and var.

Referenced by function_realtime_writedestroy().

412 {
413  struct ast_variable *var, *head;
414  struct ast_str *out;
415  size_t resultslen;
416  int n;
418  AST_APP_ARG(family);
419  AST_APP_ARG(fieldmatch);
421  AST_APP_ARG(delim1);
422  AST_APP_ARG(delim2);
423  );
424 
425  if (ast_strlen_zero(data)) {
426  ast_log(LOG_WARNING, "Syntax: REALTIME_DESTROY(family,fieldmatch[,matchvalue[,delim1[,delim2]]]) - missing argument!\n");
427  return -1;
428  }
429 
431 
432  if (!args.delim1)
433  args.delim1 = ",";
434  if (!args.delim2)
435  args.delim2 = "=";
436 
437  if (chan)
438  ast_autoservice_start(chan);
439 
440  head = ast_load_realtime_all(args.family, args.fieldmatch, args.value, SENTINEL);
441 
442  if (!head) {
443  if (chan)
444  ast_autoservice_stop(chan);
445  return -1;
446  }
447 
448  if (len > 0) {
449  resultslen = 0;
450  n = 0;
451  for (var = head; var; n++, var = var->next) {
452  resultslen += strlen(var->name) + strlen(var->value);
453  }
454  /* add space for delimiters and final '\0' */
455  resultslen += n * (strlen(args.delim1) + strlen(args.delim2)) + 1;
456 
457  if (resultslen > len) {
458  /* Unfortunately this does mean that we cannot destroy
459  * the row anymore. But OTOH, we're not destroying
460  * someones data without giving him the chance to look
461  * at it. */
462  ast_log(LOG_WARNING, "Failed to fetch/destroy. Realtime data is too large: need %zu, have %zu.\n", resultslen, len);
463  return -1;
464  }
465 
466  /* len is going to be sensible, so we don't need to check for
467  * stack overflows here. */
468  out = ast_str_alloca(resultslen);
469  for (var = head; var; var = var->next) {
470  ast_str_append(&out, 0, "%s%s%s%s", var->name, args.delim2, var->value, args.delim1);
471  }
472  ast_copy_string(buf, ast_str_buffer(out), len);
473  }
474 
475  ast_destroy_realtime(args.family, args.fieldmatch, args.value, SENTINEL);
476  ast_variables_destroy(head);
477 
478  if (chan)
479  ast_autoservice_stop(chan);
480 
481  return 0;
482 }
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:179
#define LOG_WARNING
Definition: logger.h:144
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Definition: app.h:572
struct ast_variable * ast_load_realtime_all(const char *family,...) attribute_sentinel
Definition: config.c:2536
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
#define var
Definition: ast_expr2f.c:606
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:900
#define ast_str_alloca(init_len)
Definition: strings.h:608
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: config.c:586
int value
Definition: syslog.c:39
#define SENTINEL
Definition: compiler.h:75
int ast_destroy_realtime(const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel
Destroy realtime configuration.
Definition: config.c:2750
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:238
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
static struct @350 args
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
struct ast_variable * next
Definition: config.h:82
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
Definition: app.h:604
static int function_realtime_store ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 363 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(), f, LOG_WARNING, pbx_builtin_setvar_helper(), and SENTINEL.

364 {
365  int res = 0;
366  char storeid[32];
367  char *valcopy;
369  AST_APP_ARG(family);
370  AST_APP_ARG(f)[30]; /* fields */
371  );
372 
374  AST_APP_ARG(v)[30]; /* values */
375  );
376 
377  if (ast_strlen_zero(data)) {
378  ast_log(LOG_WARNING, "Syntax: REALTIME_STORE(family,field1,field2,...,field30) - missing argument!\n");
379  return -1;
380  }
381 
382  if (chan)
383  ast_autoservice_start(chan);
384 
385  valcopy = ast_strdupa(value);
386  AST_STANDARD_APP_ARGS(a, data);
387  AST_STANDARD_APP_ARGS(v, valcopy);
388 
389  res = ast_store_realtime(a.family,
390  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],
391  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],
392  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],
393  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],
394  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],
395  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
396  );
397 
398  if (res < 0) {
399  ast_log(LOG_WARNING, "Failed to store. Check the debug log for possible data repository related entries.\n");
400  } else {
401  snprintf(storeid, sizeof(storeid), "%d", res);
402  pbx_builtin_setvar_helper(chan, "RTSTOREID", storeid);
403  }
404 
405  if (chan)
406  ast_autoservice_stop(chan);
407 
408  return 0;
409 }
int ast_store_realtime(const char *family,...) attribute_sentinel
Create realtime configuration.
Definition: config.c:2726
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:179
#define LOG_WARNING
Definition: logger.h:144
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
int value
Definition: syslog.c:39
#define SENTINEL
Definition: compiler.h:75
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:238
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static struct ast_format f[]
Definition: format_g726.c:181
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
Definition: pbx.c:10546
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static int function_realtime_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Definition at line 248 of file func_realtime.c.

References args, 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(), LOG_WARNING, and SENTINEL.

249 {
250  int res = 0;
252  AST_APP_ARG(family);
253  AST_APP_ARG(fieldmatch);
255  AST_APP_ARG(field);
256  );
257 
258  if (ast_strlen_zero(data)) {
259  ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,matchvalue,updatecol) - missing argument!\n", cmd);
260  return -1;
261  }
262 
264 
265  if (ast_strlen_zero(args.fieldmatch) || ast_strlen_zero(args.field)) {
266  ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,matchvalue,updatecol) - missing argument!\n", cmd);
267  return -1;
268  }
269 
270  if (chan) {
271  ast_autoservice_start(chan);
272  }
273 
274  res = ast_update_realtime(args.family, args.fieldmatch, args.value, args.field, (char *)value, SENTINEL);
275 
276  if (res < 0) {
277  ast_log(LOG_WARNING, "Failed to update. Check the debug log for possible data repository related entries.\n");
278  }
279 
280  if (chan) {
281  ast_autoservice_stop(chan);
282  }
283 
284  return res;
285 }
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:179
#define LOG_WARNING
Definition: logger.h:144
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
int value
Definition: syslog.c:39
int ast_update_realtime(const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel
Update realtime configuration.
Definition: config.c:2679
#define SENTINEL
Definition: compiler.h:75
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:238
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static int function_realtime_writedestroy ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

Wrapper to execute REALTIME_DESTROY from a write operation. Allows execution even if live_dangerously is disabled.

Definition at line 488 of file func_realtime.c.

References function_realtime_readdestroy().

489 {
490  return function_realtime_readdestroy(chan, cmd, data, NULL, 0);
491 }
static int function_realtime_readdestroy(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int load_module ( void  )
static

Definition at line 532 of file func_realtime.c.

References AST_CFE_READ, ast_custom_function_register, and ast_custom_function_register_escalating.

533 {
534  int res = 0;
540  return res;
541 }
static struct ast_custom_function realtime_store_function
static struct ast_custom_function realtimehash_function
static struct ast_custom_function realtime_function
static struct ast_custom_function realtime_destroy_function
#define ast_custom_function_register_escalating(acf, escalation)
Register a custom function which requires escalated privileges.
Definition: pbx.h:1173
static struct ast_custom_function realtimefield_function
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1164
static int realtimefield_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 287 of file func_realtime.c.

References args, AST_APP_ARG, ast_autoservice_start(), ast_autoservice_stop(), ast_copy_string(), ast_debug, AST_DECLARE_APP_ARGS, ast_load_realtime_all(), ast_log(), AST_STANDARD_APP_ARGS, ast_str_append(), ast_str_buffer(), ast_str_reset(), ast_str_set_escapecommas(), ast_str_thread_get(), ast_strlen_zero(), ast_variables_destroy(), buf1, buf2, buf3, first, LOG_WARNING, ast_variable::name, ast_variable::next, pbx_builtin_setvar_helper(), SENTINEL, value, ast_variable::value, and var.

288 {
289  struct ast_variable *var, *head;
290  struct ast_str *escapebuf = ast_str_thread_get(&buf1, 16);
291  struct ast_str *fields = ast_str_thread_get(&buf2, 16);
292  struct ast_str *values = ast_str_thread_get(&buf3, 16);
293  int first = 0;
294  enum { rtfield, rthash } which;
296  AST_APP_ARG(family);
297  AST_APP_ARG(fieldmatch);
299  AST_APP_ARG(fieldname);
300  );
301 
302  if (!strcmp(cmd, "REALTIME_FIELD")) {
303  which = rtfield;
304  } else {
305  which = rthash;
306  }
307 
308  if (ast_strlen_zero(data)) {
309  ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,matchvalue%s) - missing argument!\n", cmd, which == rtfield ? ",fieldname" : "");
310  return -1;
311  }
312 
314 
315  if ((which == rtfield && args.argc != 4) || (which == rthash && args.argc != 3)) {
316  ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,matchvalue%s) - missing argument!\n", cmd, which == rtfield ? ",fieldname" : "");
317  return -1;
318  }
319 
320  if (chan) {
321  ast_autoservice_start(chan);
322  }
323 
324  if (!(head = ast_load_realtime_all(args.family, args.fieldmatch, args.value, SENTINEL))) {
325  if (chan) {
326  ast_autoservice_stop(chan);
327  }
328  return -1;
329  }
330 
331  ast_str_reset(fields);
332  ast_str_reset(values);
333 
334  for (var = head; var; var = var->next) {
335  if (which == rtfield) {
336  ast_debug(1, "Comparing %s to %s\n", var->name, args.fieldname);
337  if (!strcasecmp(var->name, args.fieldname)) {
338  ast_debug(1, "Match! Value is %s\n", var->value);
339  ast_copy_string(buf, var->value, len);
340  break;
341  }
342  } else if (which == rthash) {
343  ast_debug(1, "Setting hash key %s to value %s\n", var->name, var->value);
344  ast_str_append(&fields, 0, "%s%s", first ? "" : ",", ast_str_set_escapecommas(&escapebuf, 0, var->name, INT_MAX));
345  ast_str_append(&values, 0, "%s%s", first ? "" : ",", ast_str_set_escapecommas(&escapebuf, 0, var->value, INT_MAX));
346  first = 0;
347  }
348  }
349  ast_variables_destroy(head);
350 
351  if (which == rthash) {
352  pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", ast_str_buffer(fields));
353  ast_copy_string(buf, ast_str_buffer(values), len);
354  }
355 
356  if (chan) {
357  ast_autoservice_stop(chan);
358  }
359 
360  return 0;
361 }
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:179
#define LOG_WARNING
Definition: logger.h:144
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
struct ast_variable * ast_load_realtime_all(const char *family,...) attribute_sentinel
Definition: config.c:2536
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
#define var
Definition: ast_expr2f.c:606
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:900
static struct ast_threadstorage buf2
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: config.c:586
int value
Definition: syslog.c:39
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define SENTINEL
Definition: compiler.h:75
const char * value
Definition: config.h:79
static struct ast_threadstorage buf3
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
const char * name
Definition: config.h:77
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:238
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
static struct @350 args
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
struct sla_ringing_trunk * first
Definition: app_meetme.c:965
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static struct ast_threadstorage buf1
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
Definition: pbx.c:10546
char * ast_str_set_escapecommas(struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc)
Set a dynamic string to a non-NULL terminated substring, with escaping of commas. ...
Definition: strings.h:830
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
Definition: strings.h:436
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
struct ast_variable * next
Definition: config.h:82
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
Definition: strings.h:669
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static int unload_module ( void  )
static

Definition at line 521 of file func_realtime.c.

References ast_custom_function_unregister().

522 {
523  int res = 0;
529  return res;
530 }
static struct ast_custom_function realtime_store_function
static struct ast_custom_function realtimehash_function
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
Definition: pbx.c:3814
static struct ast_custom_function realtime_function
static struct ast_custom_function realtime_destroy_function
static struct ast_custom_function realtimefield_function

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static

Definition at line 543 of file func_realtime.c.

Definition at line 543 of file func_realtime.c.

struct ast_threadstorage buf3 = { .once = PTHREAD_ONCE_INIT , .key_init = __init_buf3 , .custom_init = NULL , }
static

Definition at line 182 of file func_realtime.c.

Referenced by realtimefield_read().

struct ast_custom_function realtime_destroy_function
static
Initial value:
= {
.name = "REALTIME_DESTROY",
}
static int function_realtime_writedestroy(struct ast_channel *chan, const char *cmd, char *data, const char *value)
Wrapper to execute REALTIME_DESTROY from a write operation. Allows execution even if live_dangerously...
static int function_realtime_readdestroy(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 515 of file func_realtime.c.

struct ast_custom_function realtime_function
static
Initial value:
= {
.name = "REALTIME",
}
static int function_realtime_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static int function_realtime_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 493 of file func_realtime.c.

struct ast_custom_function realtime_store_function
static
Initial value:
= {
.name = "REALTIME_STORE",
}
static int function_realtime_store(struct ast_channel *chan, const char *cmd, char *data, const char *value)

Definition at line 510 of file func_realtime.c.

struct ast_custom_function realtimefield_function
static
Initial value:
= {
.name = "REALTIME_FIELD",
}
static int function_realtime_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static int realtimefield_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 499 of file func_realtime.c.

struct ast_custom_function realtimehash_function
static
Initial value:
= {
.name = "REALTIME_HASH",
}
static int realtimefield_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 505 of file func_realtime.c.