47 #define CRL_HEADER_FORMAT "%30s %-30s\n"
54 "Usage: realtime load <family> <colmatch> <value>\n"
55 " Prints out a list of variables using the RealTime driver.\n"
56 " You must supply a family name, a column to match on, and a value to match to.\n";
66 var = ast_load_realtime_all(a->argv[2], a->argv[3], a->argv[4], SENTINEL);
69 ast_cli(a->fd, CRL_HEADER_FORMAT,
"Column Name",
"Column Value");
70 ast_cli(a->fd, CRL_HEADER_FORMAT,
"--------------------",
"--------------------");
73 ast_cli(a->fd, CRL_HEADER_FORMAT, var->
name, var->
value);
77 ast_cli(a->fd,
"No rows found matching search criteria.\n");
91 "Usage: realtime update <family> <colmatch> <valuematch> <colupdate> <newvalue>\n"
92 " Update a single variable using the RealTime driver.\n"
93 " You must supply a family name, a column to update on, a new value, column to match, and value to match.\n"
94 " Ex: realtime update sippeers name bobsphone port 4343\n"
95 " will execute SQL as UPDATE sippeers SET port = 4343 WHERE name = bobsphone\n";
102 return CLI_SHOWUSAGE;
104 res =
ast_update_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], SENTINEL);
107 ast_cli(a->fd,
"Failed to update. Check the debug log for possible SQL related entries.\n");
111 ast_cli(a->fd,
"Updated %d RealTime record%s.\n", res,
ESS(res));
122 e->
command =
"realtime update2";
124 "Usage: realtime update2 <family> <colmatch> <valuematch> [... <colmatch5> <valuematch5>] NULL <colupdate> <newvalue>\n"
125 " Update a single variable, requiring one or more fields to match using the\n"
126 " RealTime driver. You must supply a family name, a column to update, a new\n"
127 " value, and at least one column and value to match.\n"
128 " Ex: realtime update2 sippeers name bobsphone ipaddr 127.0.0.1 NULL port 4343\n"
129 " will execute SQL as\n"
130 " UPDATE sippeers SET port='4343' WHERE name='bobsphone' and ipaddr='127.0.0.1'\n";
138 if (a->argc < 8 || a->argc > 16 || a->argc % 2
139 || strcmp(a->argv[a->argc - 3],
"NULL")) {
140 return CLI_SHOWUSAGE;
145 a->argv[2], a->argv[3], a->argv[4], SENTINEL,
146 a->argv[6], a->argv[7], SENTINEL);
147 }
else if (a->argc == 10) {
149 a->argv[2], a->argv[3], a->argv[4], a->argv[5],
150 a->argv[6], SENTINEL,
151 a->argv[8], a->argv[9], SENTINEL);
152 }
else if (a->argc == 12) {
154 a->argv[2], a->argv[3], a->argv[4], a->argv[5],
155 a->argv[6], a->argv[7], a->argv[8], SENTINEL,
156 a->argv[10], a->argv[11], SENTINEL);
157 }
else if (a->argc == 14) {
159 a->argv[2], a->argv[3], a->argv[4], a->argv[5],
160 a->argv[6], a->argv[7], a->argv[8], a->argv[9],
161 a->argv[10], SENTINEL,
162 a->argv[12], a->argv[13], SENTINEL);
163 }
else if (a->argc == 16) {
165 a->argv[2], a->argv[3], a->argv[4], a->argv[5],
166 a->argv[6], a->argv[7], a->argv[8], a->argv[9],
167 a->argv[10], a->argv[11], a->argv[12], SENTINEL,
168 a->argv[14], a->argv[15], SENTINEL);
172 ast_cli(a->fd,
"Failed to update. Check the debug log for possible SQL related entries.\n");
176 ast_cli(a->fd,
"Updated %d RealTime record%s.\n", res,
ESS(res));
189 "Usage: realtime store <family> <colname1> <value1> [<colname2> <value2> [... <colname5> <value5>]]\n"
190 " Create a stored row using the RealTime driver.\n"
191 " You must supply a family name and name/value pairs (up to 5). If\n"
192 " you need to store more than 5 key/value pairs, start with the first\n"
193 " five, then use 'realtime update' or 'realtime update2' to add\n"
194 " additional columns.\n";
201 return CLI_SHOWUSAGE;
202 }
else if (a->argc == 5) {
204 }
else if (a->argc == 7) {
205 res =
ast_store_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], SENTINEL);
206 }
else if (a->argc == 9) {
207 res =
ast_store_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], a->argv[7], a->argv[8], SENTINEL);
208 }
else if (a->argc == 11) {
209 res =
ast_store_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], a->argv[7], a->argv[8], a->argv[9], a->argv[10], SENTINEL);
210 }
else if (a->argc == 13) {
211 res =
ast_store_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], a->argv[7], a->argv[8], a->argv[9], a->argv[10], a->argv[11], a->argv[12], SENTINEL);
213 return CLI_SHOWUSAGE;
217 ast_cli(a->fd,
"Failed to store record. Check the debug log for possible SQL related entries.\n");
221 ast_cli(a->fd,
"Stored RealTime record.\n");
232 e->
command =
"realtime destroy";
234 "Usage: realtime destroy <family> <colmatch1> <valuematch1> [<colmatch2> <valuematch2> [... <colmatch5> <valuematch5>]]\n"
235 " Remove a stored row using the RealTime driver.\n"
236 " You must supply a family name and name/value pairs (up to 5).\n";
243 return CLI_SHOWUSAGE;
244 }
else if (a->argc == 5) {
246 }
else if (a->argc == 7) {
247 res =
ast_destroy_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], SENTINEL);
248 }
else if (a->argc == 9) {
249 res =
ast_destroy_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], a->argv[7], a->argv[8], SENTINEL);
250 }
else if (a->argc == 11) {
251 res =
ast_destroy_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], a->argv[7], a->argv[8], a->argv[9], a->argv[10], SENTINEL);
252 }
else if (a->argc == 13) {
253 res =
ast_destroy_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], a->argv[7], a->argv[8], a->argv[9], a->argv[10], a->argv[11], a->argv[12], SENTINEL);
255 return CLI_SHOWUSAGE;
259 ast_cli(a->fd,
"Failed to remove record. Check the debug log for possible SQL related entries.\n");
263 ast_cli(a->fd,
"Removed %d RealTime record%s.\n", res,
ESS(res));
269 AST_CLI_DEFINE(cli_realtime_load,
"Used to print out RealTime variables."),
270 AST_CLI_DEFINE(cli_realtime_update,
"Used to update RealTime variables."),
271 AST_CLI_DEFINE(cli_realtime_update2,
"Used to test the RealTime update2 method"),
272 AST_CLI_DEFINE(cli_realtime_store,
"Store a new row into a RealTime database"),
273 AST_CLI_DEFINE(cli_realtime_destroy,
"Delete a row from a RealTime database"),
276 static int unload_module(
void)
282 static int load_module(
void)
struct ast_variable * next
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
descriptor for a cli entry.
Structure for variables, used for configurations and for channel variables.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_update_realtime(const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel
Update realtime configuration.
int ast_update2_realtime(const char *family,...) attribute_sentinel
Update realtime configuration.
Configuration File Parser.
int ast_store_realtime(const char *family,...) attribute_sentinel
Create realtime configuration.
General Asterisk PBX channel definitions.
Core PBX routines and definitions.
Standard Command Line Interface.
int ast_destroy_realtime(const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel
Destroy realtime configuration.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.