#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/options.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/logger.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, char *cmd, char *data, char *buf, size_t len) |
static int | function_realtime_write (struct ast_channel *chan, 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 | AST_MODFLAG_BUILDSUM, .description = "Read/Write 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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
ast_custom_function | realtime_function |
Definition in file func_realtime.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 177 of file func_realtime.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 177 of file func_realtime.c.
static int function_realtime_read | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 48 of file func_realtime.c.
References AST_APP_ARG, ast_autoservice_start(), ast_autoservice_stop(), ast_build_string(), ast_copy_string(), AST_DECLARE_APP_ARGS, ast_load_realtime(), ast_log(), ast_module_user_add, ast_module_user_remove, AST_STANDARD_APP_ARGS, ast_strlen_zero(), ast_variables_destroy(), ast_module_user::chan, LOG_WARNING, and var.
00049 { 00050 struct ast_variable *var, *head; 00051 struct ast_module_user *u; 00052 char *results, *result_begin; 00053 size_t resultslen = 0; 00054 AST_DECLARE_APP_ARGS(args, 00055 AST_APP_ARG(family); 00056 AST_APP_ARG(fieldmatch); 00057 AST_APP_ARG(value); 00058 AST_APP_ARG(delim1); 00059 AST_APP_ARG(delim2); 00060 ); 00061 00062 00063 if (ast_strlen_zero(data)) { 00064 ast_log(LOG_WARNING, "Syntax: REALTIME(family|fieldmatch[|value[|delim1[|delim2]]]) - missing argument!\n"); 00065 return -1; 00066 } 00067 00068 u = ast_module_user_add(chan); 00069 00070 AST_STANDARD_APP_ARGS(args, data); 00071 00072 if (!args.delim1) 00073 args.delim1 = "|"; 00074 if (!args.delim2) 00075 args.delim2 = "="; 00076 00077 if (chan) 00078 ast_autoservice_start(chan); 00079 00080 head = ast_load_realtime(args.family, args.fieldmatch, args.value, NULL); 00081 00082 if (!head) { 00083 ast_module_user_remove(u); 00084 if (chan) 00085 ast_autoservice_stop(chan); 00086 return -1; 00087 } 00088 for (var = head; var; var = var->next) 00089 resultslen += strlen(var->name) + strlen(var->value) + strlen(args.delim1) + strlen(args.delim2); 00090 00091 result_begin = results = alloca(resultslen); 00092 for (var = head; var; var = var->next) 00093 ast_build_string(&results, &resultslen, "%s%s%s%s", var->name, args.delim2, var->value, args.delim1); 00094 ast_copy_string(buf, result_begin, len); 00095 00096 ast_variables_destroy(head); 00097 00098 ast_module_user_remove(u); 00099 00100 if (chan) 00101 ast_autoservice_stop(chan); 00102 00103 return 0; 00104 }
static int function_realtime_write | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
const char * | value | |||
) | [static] |
Definition at line 106 of file func_realtime.c.
References AST_APP_ARG, ast_autoservice_start(), ast_autoservice_stop(), AST_DECLARE_APP_ARGS, ast_log(), ast_module_user_add, ast_module_user_remove, AST_STANDARD_APP_ARGS, ast_strlen_zero(), ast_update_realtime(), ast_module_user::chan, and LOG_WARNING.
00107 { 00108 struct ast_module_user *u = NULL; 00109 int res = 0; 00110 AST_DECLARE_APP_ARGS(args, 00111 AST_APP_ARG(family); 00112 AST_APP_ARG(fieldmatch); 00113 AST_APP_ARG(value); 00114 AST_APP_ARG(field); 00115 ); 00116 00117 if (ast_strlen_zero(data)) { 00118 ast_log(LOG_WARNING, "Syntax: REALTIME(family|fieldmatch|value|newcol) - missing argument!\n"); 00119 return -1; 00120 } 00121 00122 if (chan) { 00123 ast_autoservice_start(chan); 00124 u = ast_module_user_add(chan); 00125 } 00126 00127 AST_STANDARD_APP_ARGS(args, data); 00128 00129 res = ast_update_realtime(args.family, args.fieldmatch, args.value, args.field, (char *)value, NULL); 00130 00131 if (res < 0) { 00132 ast_log(LOG_WARNING, "Failed to update. Check the debug log for possible data repository related entries.\n"); 00133 } 00134 00135 if (chan) { 00136 ast_module_user_remove(u); 00137 ast_autoservice_stop(chan); 00138 } 00139 00140 return 0; 00141 }
static int load_module | ( | void | ) | [static] |
Definition at line 170 of file func_realtime.c.
References ast_custom_function_register(), and realtime_function.
00171 { 00172 int res = ast_custom_function_register(&realtime_function); 00173 00174 return res; 00175 }
static int unload_module | ( | void | ) | [static] |
Definition at line 161 of file func_realtime.c.
References ast_custom_function_unregister(), ast_module_user_hangup_all, and realtime_function.
00162 { 00163 int res = ast_custom_function_unregister(&realtime_function); 00164 00165 ast_module_user_hangup_all(); 00166 00167 return res; 00168 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Read/Write 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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 177 of file func_realtime.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 177 of file func_realtime.c.