#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <regex.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/logger.h"
#include "asterisk/options.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/astdb.h"
Go to the source code of this file.
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | function_db_delete (struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len) |
static int | function_db_exists (struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len) |
static int | function_db_read (struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len) |
static int | function_db_write (struct ast_channel *chan, char *cmd, char *parse, 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 = "Database (astdb) related dialplan functions" , .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 |
static struct ast_custom_function | db_delete_function |
static struct ast_custom_function | db_exists_function |
static struct ast_custom_function | db_function |
Definition in file func_db.c.
static int function_db_delete | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | parse, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 162 of file func_db.c.
References AST_APP_ARG, ast_db_del(), ast_db_get(), AST_DECLARE_APP_ARGS, ast_log(), AST_NONSTANDARD_APP_ARGS, ast_strlen_zero(), LOG_DEBUG, LOG_WARNING, and pbx_builtin_setvar_helper().
00164 { 00165 AST_DECLARE_APP_ARGS(args, 00166 AST_APP_ARG(family); 00167 AST_APP_ARG(key); 00168 ); 00169 00170 buf[0] = '\0'; 00171 00172 if (ast_strlen_zero(parse)) { 00173 ast_log(LOG_WARNING, "DB_DELETE requires an argument, DB_DELETE(<family>/<key>)\n"); 00174 return -1; 00175 } 00176 00177 AST_NONSTANDARD_APP_ARGS(args, parse, '/'); 00178 00179 if (args.argc < 2) { 00180 ast_log(LOG_WARNING, "DB_DELETE requires an argument, DB_DELETE(<family>/<key>)\n"); 00181 return -1; 00182 } 00183 00184 if (ast_db_get(args.family, args.key, buf, len - 1)) { 00185 ast_log(LOG_DEBUG, "DB_DELETE: %s/%s not found in database.\n", args.family, args.key); 00186 } else { 00187 if (ast_db_del(args.family, args.key)) { 00188 ast_log(LOG_DEBUG, "DB_DELETE: %s/%s could not be deleted from the database\n", 00189 args.family, args.key); 00190 } 00191 } 00192 pbx_builtin_setvar_helper(chan, "DB_RESULT", buf); 00193 00194 return 0; 00195 }
static int function_db_exists | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | parse, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 118 of file func_db.c.
References AST_APP_ARG, ast_db_get(), AST_DECLARE_APP_ARGS, ast_log(), AST_NONSTANDARD_APP_ARGS, ast_strlen_zero(), LOG_WARNING, and pbx_builtin_setvar_helper().
00120 { 00121 AST_DECLARE_APP_ARGS(args, 00122 AST_APP_ARG(family); 00123 AST_APP_ARG(key); 00124 ); 00125 00126 buf[0] = '\0'; 00127 00128 if (ast_strlen_zero(parse)) { 00129 ast_log(LOG_WARNING, "DB_EXISTS requires an argument, DB(<family>/<key>)\n"); 00130 return -1; 00131 } 00132 00133 AST_NONSTANDARD_APP_ARGS(args, parse, '/'); 00134 00135 if (args.argc < 2) { 00136 ast_log(LOG_WARNING, "DB_EXISTS requires an argument, DB(<family>/<key>)\n"); 00137 return -1; 00138 } 00139 00140 if (ast_db_get(args.family, args.key, buf, len - 1)) 00141 strcpy(buf, "0"); 00142 else { 00143 pbx_builtin_setvar_helper(chan, "DB_RESULT", buf); 00144 strcpy(buf, "1"); 00145 } 00146 00147 return 0; 00148 }
static int function_db_read | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | parse, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 47 of file func_db.c.
References AST_APP_ARG, ast_db_get(), AST_DECLARE_APP_ARGS, ast_log(), AST_NONSTANDARD_APP_ARGS, ast_strlen_zero(), LOG_DEBUG, LOG_WARNING, and pbx_builtin_setvar_helper().
00049 { 00050 AST_DECLARE_APP_ARGS(args, 00051 AST_APP_ARG(family); 00052 AST_APP_ARG(key); 00053 ); 00054 00055 buf[0] = '\0'; 00056 00057 if (ast_strlen_zero(parse)) { 00058 ast_log(LOG_WARNING, "DB requires an argument, DB(<family>/<key>)\n"); 00059 return -1; 00060 } 00061 00062 AST_NONSTANDARD_APP_ARGS(args, parse, '/'); 00063 00064 if (args.argc < 2) { 00065 ast_log(LOG_WARNING, "DB requires an argument, DB(<family>/<key>)\n"); 00066 return -1; 00067 } 00068 00069 if (ast_db_get(args.family, args.key, buf, len - 1)) { 00070 ast_log(LOG_DEBUG, "DB: %s/%s not found in database.\n", args.family, 00071 args.key); 00072 } else 00073 pbx_builtin_setvar_helper(chan, "DB_RESULT", buf); 00074 00075 return 0; 00076 }
static int function_db_write | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | parse, | |||
const char * | value | |||
) | [static] |
Definition at line 78 of file func_db.c.
References AST_APP_ARG, ast_db_put(), AST_DECLARE_APP_ARGS, ast_log(), AST_NONSTANDARD_APP_ARGS, ast_strlen_zero(), and LOG_WARNING.
00080 { 00081 AST_DECLARE_APP_ARGS(args, 00082 AST_APP_ARG(family); 00083 AST_APP_ARG(key); 00084 ); 00085 00086 if (ast_strlen_zero(parse)) { 00087 ast_log(LOG_WARNING, "DB requires an argument, DB(<family>/<key>)=<value>\n"); 00088 return -1; 00089 } 00090 00091 AST_NONSTANDARD_APP_ARGS(args, parse, '/'); 00092 00093 if (args.argc < 2) { 00094 ast_log(LOG_WARNING, "DB requires an argument, DB(<family>/<key>)=value\n"); 00095 return -1; 00096 } 00097 00098 if (ast_db_put(args.family, args.key, (char *) value)) 00099 ast_log(LOG_WARNING, "DB: Error writing value to database.\n"); 00100 00101 return 0; 00102 }
static int load_module | ( | void | ) | [static] |
Definition at line 220 of file func_db.c.
References ast_custom_function_register(), db_delete_function, db_exists_function, and db_function.
00221 { 00222 int res = 0; 00223 00224 res |= ast_custom_function_register(&db_function); 00225 res |= ast_custom_function_register(&db_exists_function); 00226 res |= ast_custom_function_register(&db_delete_function); 00227 00228 return res; 00229 }
static int unload_module | ( | void | ) | [static] |
Definition at line 209 of file func_db.c.
References ast_custom_function_unregister(), db_delete_function, db_exists_function, and db_function.
00210 { 00211 int res = 0; 00212 00213 res |= ast_custom_function_unregister(&db_function); 00214 res |= ast_custom_function_unregister(&db_exists_function); 00215 res |= ast_custom_function_unregister(&db_delete_function); 00216 00217 return res; 00218 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Database (astdb) related dialplan functions" , .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 [static] |
struct ast_custom_function db_delete_function [static] |
struct ast_custom_function db_exists_function [static] |
struct ast_custom_function db_function [static] |