#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/cli.h"
Go to the source code of this file.
Defines | |
#define | CRL_HEADER_FORMAT "%30s %-30s\n" |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static char * | cli_realtime_load (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | cli_realtime_update (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
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 = "Realtime Data Lookup/Rewrite" , .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 |
static struct ast_cli_entry | cli_realtime [] |
Mark Spencer <markster@digium.com>
Definition in file res_realtime.c.
#define CRL_HEADER_FORMAT "%30s %-30s\n" |
Referenced by cli_realtime_load().
static void __reg_module | ( | void | ) | [static] |
Definition at line 131 of file res_realtime.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 131 of file res_realtime.c.
static char* cli_realtime_load | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 43 of file res_realtime.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_load_realtime_all(), ast_variables_destroy(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, CRL_HEADER_FORMAT, ast_cli_args::fd, SENTINEL, ast_cli_entry::usage, and var.
00044 { 00045 #define CRL_HEADER_FORMAT "%30s %-30s\n" 00046 struct ast_variable *var = NULL, *orig_var = NULL; 00047 00048 switch (cmd) { 00049 case CLI_INIT: 00050 e->command = "realtime load"; 00051 e->usage = 00052 "Usage: realtime load <family> <colmatch> <value>\n" 00053 " Prints out a list of variables using the RealTime driver.\n" 00054 " You must supply a family name, a column to match on, and a value to match to.\n"; 00055 return NULL; 00056 case CLI_GENERATE: 00057 return NULL; 00058 } 00059 00060 00061 if (a->argc < 5) 00062 return CLI_SHOWUSAGE; 00063 00064 var = ast_load_realtime_all(a->argv[2], a->argv[3], a->argv[4], SENTINEL); 00065 00066 if (var) { 00067 ast_cli(a->fd, CRL_HEADER_FORMAT, "Column Name", "Column Value"); 00068 ast_cli(a->fd, CRL_HEADER_FORMAT, "--------------------", "--------------------"); 00069 orig_var = var; 00070 while (var) { 00071 ast_cli(a->fd, CRL_HEADER_FORMAT, var->name, var->value); 00072 var = var->next; 00073 } 00074 } else { 00075 ast_cli(a->fd, "No rows found matching search criteria.\n"); 00076 } 00077 ast_variables_destroy(orig_var); 00078 return CLI_SUCCESS; 00079 }
static char* cli_realtime_update | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 81 of file res_realtime.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_update_realtime(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ESS, ast_cli_args::fd, SENTINEL, and ast_cli_entry::usage.
00081 { 00082 int res = 0; 00083 00084 switch (cmd) { 00085 case CLI_INIT: 00086 e->command = "realtime update"; 00087 e->usage = 00088 "Usage: realtime update <family> <colmatch> <valuematch> <colupdate> <newvalue>\n" 00089 " Update a single variable using the RealTime driver.\n" 00090 " You must supply a family name, a column to update on, a new value, column to match, and value to match.\n" 00091 " Ex: realtime update sipfriends name bobsphone port 4343\n" 00092 " will execute SQL as UPDATE sipfriends SET port = 4343 WHERE name = bobsphone\n"; 00093 return NULL; 00094 case CLI_GENERATE: 00095 return NULL; 00096 } 00097 00098 00099 if (a->argc < 7) 00100 return CLI_SHOWUSAGE; 00101 00102 res = ast_update_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], SENTINEL); 00103 00104 if(res < 0) { 00105 ast_cli(a->fd, "Failed to update. Check the debug log for possible SQL related entries.\n"); 00106 return CLI_FAILURE; 00107 } 00108 00109 ast_cli(a->fd, "Updated %d RealTime record%s.\n", res, ESS(res)); 00110 00111 return CLI_SUCCESS; 00112 }
static int load_module | ( | void | ) | [static] |
Definition at line 125 of file res_realtime.c.
References ast_cli_register_multiple(), AST_MODULE_LOAD_SUCCESS, and cli_realtime.
00126 { 00127 ast_cli_register_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry)); 00128 return AST_MODULE_LOAD_SUCCESS; 00129 }
static int unload_module | ( | void | ) | [static] |
Definition at line 119 of file res_realtime.c.
References ast_cli_unregister_multiple(), and cli_realtime.
00120 { 00121 ast_cli_unregister_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry)); 00122 return 0; 00123 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Realtime Data Lookup/Rewrite" , .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 131 of file res_realtime.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 131 of file res_realtime.c.
struct ast_cli_entry cli_realtime[] [static] |
Initial value:
{ { .handler = cli_realtime_load , .summary = "Used to print out RealTime variables." ,__VA_ARGS__ }, { .handler = cli_realtime_update , .summary = "Used to update RealTime variables." ,__VA_ARGS__ }, }
Definition at line 114 of file res_realtime.c.