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";
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";
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")) {
147 }
else if (
a->argc == 10) {
149 a->argv[2],
a->argv[3],
a->argv[4],
a->argv[5],
152 }
else if (
a->argc == 12) {
154 a->argv[2],
a->argv[3],
a->argv[4],
a->argv[5],
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],
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],
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";
202 }
else if (
a->argc == 5) {
204 }
else if (
a->argc == 7) {
206 }
else if (
a->argc == 9) {
208 }
else if (
a->argc == 11) {
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);
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";
244 }
else if (
a->argc == 5) {
246 }
else if (
a->argc == 7) {
248 }
else if (
a->argc == 9) {
250 }
else if (
a->argc == 11) {
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);
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));
Asterisk main include file. File version handling, generic pbx functions.
General Asterisk PBX channel definitions.
Standard Command Line Interface.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Generic File Format Support. Should be included by clients of the file handling routines....
Configuration File Parser.
struct ast_variable * ast_load_realtime_all(const char *family,...) attribute_sentinel
int ast_update2_realtime(const char *family,...) attribute_sentinel
Update realtime configuration.
int ast_destroy_realtime(const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel
Destroy realtime configuration.
int ast_update_realtime(const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel
Update realtime configuration.
int ast_store_realtime(const char *family,...) attribute_sentinel
Create realtime configuration.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Asterisk locking-related definitions:
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
Core PBX routines and definitions.
#define CRL_HEADER_FORMAT
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 char * cli_realtime_destroy(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * cli_realtime_update2(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct ast_cli_entry cli_realtime[]
static int load_module(void)
static int unload_module(void)
static char * cli_realtime_store(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
descriptor for a cli entry.
Structure for variables, used for configurations and for channel variables.