#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 = "6989f2ec67f8497e38c12890500c525b" , .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 175 of file func_realtime.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 175 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_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_module_user_remove(u); 00097 00098 if (chan) 00099 ast_autoservice_stop(chan); 00100 00101 return 0; 00102 }
static int function_realtime_write | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
const char * | value | |||
) | [static] |
Definition at line 104 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.
00105 { 00106 struct ast_module_user *u = NULL; 00107 int res = 0; 00108 AST_DECLARE_APP_ARGS(args, 00109 AST_APP_ARG(family); 00110 AST_APP_ARG(fieldmatch); 00111 AST_APP_ARG(value); 00112 AST_APP_ARG(field); 00113 ); 00114 00115 if (ast_strlen_zero(data)) { 00116 ast_log(LOG_WARNING, "Syntax: REALTIME(family|fieldmatch|value|newcol) - missing argument!\n"); 00117 return -1; 00118 } 00119 00120 if (chan) { 00121 ast_autoservice_start(chan); 00122 u = ast_module_user_add(chan); 00123 } 00124 00125 AST_STANDARD_APP_ARGS(args, data); 00126 00127 res = ast_update_realtime(args.family, args.fieldmatch, args.value, args.field, (char *)value, NULL); 00128 00129 if (res < 0) { 00130 ast_log(LOG_WARNING, "Failed to update. Check the debug log for possible data repository related entries.\n"); 00131 } 00132 00133 if (chan) { 00134 ast_module_user_remove(u); 00135 ast_autoservice_stop(chan); 00136 } 00137 00138 return 0; 00139 }
static int load_module | ( | void | ) | [static] |
Definition at line 168 of file func_realtime.c.
References ast_custom_function_register(), and realtime_function.
00169 { 00170 int res = ast_custom_function_register(&realtime_function); 00171 00172 return res; 00173 }
static int unload_module | ( | void | ) | [static] |
Definition at line 159 of file func_realtime.c.
References ast_custom_function_unregister(), ast_module_user_hangup_all, and realtime_function.
00160 { 00161 int res = ast_custom_function_unregister(&realtime_function); 00162 00163 ast_module_user_hangup_all(); 00164 00165 return res; 00166 }
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 = "6989f2ec67f8497e38c12890500c525b" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 175 of file func_realtime.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 175 of file func_realtime.c.