mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-22 11:19:52 +00:00
update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6224 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
a9101cb8c1
commit
20a47df18b
@ -390,7 +390,7 @@ SWITCH_STANDARD_API(db_api_function)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define DB_USAGE "<realm>/<key>/<val>"
|
#define DB_USAGE "[add|del]/<realm>/<key>/<val>"
|
||||||
#define DB_DESC "save data"
|
#define DB_DESC "save data"
|
||||||
|
|
||||||
SWITCH_STANDARD_APP(db_function)
|
SWITCH_STANDARD_APP(db_function)
|
||||||
@ -399,7 +399,7 @@ SWITCH_STANDARD_APP(db_function)
|
|||||||
int argc = 0;
|
int argc = 0;
|
||||||
char *argv[3] = { 0 };
|
char *argv[3] = { 0 };
|
||||||
char *mydata = NULL;
|
char *mydata = NULL;
|
||||||
char *sql;
|
char *sql = NULL;
|
||||||
|
|
||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
@ -409,16 +409,29 @@ SWITCH_STANDARD_APP(db_function)
|
|||||||
argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0])));
|
argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 4) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: db_insert %s\n", DB_USAGE);
|
goto error;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sql = switch_mprintf("insert into db_data values('%q','%q','%q','%q');", globals.hostname, argv[0], argv[1], argv[2]);
|
if (!strcasecmp(argv[0], "add")) {
|
||||||
assert(sql);
|
sql = switch_mprintf("insert into db_data values('%q','%q','%q','%q');", globals.hostname, argv[1], argv[2], argv[3]);
|
||||||
limit_execute_sql(sql, globals.mutex);
|
} else if (!strcasecmp(argv[0], "del")) {
|
||||||
switch_safe_free(sql);
|
sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (sql) {
|
||||||
|
limit_execute_sql(sql, globals.mutex);
|
||||||
|
switch_safe_free(sql);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
error:
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: db %s\n", DB_USAGE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user