mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-27 13:44:16 +00:00
Merge remote branch 'origin/master'
This commit is contained in:
commit
0d37261888
168 files changed
+16987
-2477
No files matched your search
@@ -1,5 +1,6 @@
|
||||
/Makefile
|
||||
/Makefile.in
|
||||
/applications/mod_blacklist/Makefile
|
||||
/applications/mod_commands/Makefile
|
||||
/applications/mod_conference/Makefile
|
||||
/applications/mod_db/Makefile
|
||||
@@ -14,6 +15,7 @@
|
||||
/applications/mod_fifo/Makefile
|
||||
/applications/mod_fsv/Makefile
|
||||
/applications/mod_limit/Makefile
|
||||
/applications/mod_sms/Makefile
|
||||
/applications/mod_spandsp/Makefile
|
||||
/applications/mod_spandsp/Makefile.in
|
||||
/applications/mod_spandsp/mod_spandsp.log
|
||||
|
||||
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Mathieu Rene <mrene@avgs.ca>
|
||||
* Raymond Chandler <intralanman@freeswitch.org>
|
||||
*
|
||||
* mod_blacklist.c -- Blacklist module
|
||||
*
|
||||
*/
|
||||
#include <switch.h>
|
||||
|
||||
/* Prototypes */
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_blacklist_shutdown);
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_blacklist_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_blacklist_load);
|
||||
|
||||
|
||||
SWITCH_MODULE_DEFINITION(mod_blacklist, mod_blacklist_load, mod_blacklist_shutdown, NULL);
|
||||
|
||||
typedef struct {
|
||||
switch_hash_t *list;
|
||||
switch_mutex_t *list_mutex;
|
||||
switch_memory_pool_t *pool;
|
||||
} blacklist_t;
|
||||
|
||||
static struct {
|
||||
switch_hash_t *files;
|
||||
switch_hash_t *lists;
|
||||
switch_mutex_t *files_mutex;
|
||||
switch_mutex_t *lists_mutex;
|
||||
switch_memory_pool_t *pool;
|
||||
} globals;
|
||||
|
||||
blacklist_t *blacklist_create(const char *name)
|
||||
{
|
||||
switch_memory_pool_t *pool = NULL;
|
||||
blacklist_t *bl = NULL;
|
||||
|
||||
switch_core_new_memory_pool(&pool);
|
||||
bl = switch_core_alloc(pool, sizeof(*bl));
|
||||
switch_assert(bl);
|
||||
bl->pool = pool;
|
||||
|
||||
switch_core_hash_init(&bl->list, pool);
|
||||
switch_mutex_init(&bl->list_mutex, SWITCH_MUTEX_NESTED, pool);
|
||||
|
||||
return bl;
|
||||
}
|
||||
|
||||
void blacklist_free(blacklist_t *bl)
|
||||
{
|
||||
switch_core_destroy_memory_pool(&bl->pool);
|
||||
}
|
||||
|
||||
|
||||
void trim(char *string)
|
||||
{
|
||||
char *p;
|
||||
if ((p = strchr(string, '\n'))) {
|
||||
*p = '\0';
|
||||
}
|
||||
if ((p = strchr(string, '\r'))) {
|
||||
*p = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
static switch_status_t load_list(const char *name, const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
if ((f = fopen(filename, "r"))) {
|
||||
char buf[1024] = {0};
|
||||
blacklist_t *bl = blacklist_create(name); /* Create a hashtable + mutex for that list */
|
||||
|
||||
while (fgets(buf, 1024, f)) {
|
||||
trim(buf);
|
||||
switch_core_hash_insert(bl->list, buf, (void *)SWITCH_TRUE);
|
||||
}
|
||||
|
||||
switch_core_hash_insert(globals.files, name, filename);
|
||||
switch_core_hash_insert(globals.lists, name, bl);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Loaded list [%s]\n", name);
|
||||
|
||||
fclose(f);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't open [%s] to load list [%s]\n", filename, name);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t do_config(switch_bool_t reload)
|
||||
{
|
||||
/* Load up blacklists */
|
||||
switch_xml_t xml, cfg, lists, list;
|
||||
switch_hash_index_t *hi;
|
||||
|
||||
if (!(xml = switch_xml_open_cfg("mod_blacklist.conf", &cfg, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't load configuration section\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
switch_mutex_lock(globals.lists_mutex);
|
||||
|
||||
/* Destroy any active lists */
|
||||
while ((hi = switch_hash_first(NULL, globals.lists))) {
|
||||
const void *key;
|
||||
void *val;
|
||||
switch_hash_this(hi, &key, NULL, &val);
|
||||
blacklist_free((blacklist_t*)val);
|
||||
switch_core_hash_delete(globals.lists, (const char*)key);
|
||||
}
|
||||
|
||||
if ((lists = switch_xml_child(cfg, "lists"))) {
|
||||
for (list = switch_xml_child(lists, "list"); list; list = list->next) {
|
||||
const char *name = switch_xml_attr_soft(list, "name");
|
||||
const char *filename = switch_xml_attr_soft(list, "filename");
|
||||
|
||||
if (zstr(name)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "list has no name\n");
|
||||
continue;
|
||||
}
|
||||
if (zstr(filename)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "list [%s] has no filename\n", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
load_list(name, filename);
|
||||
}
|
||||
}
|
||||
|
||||
switch_mutex_unlock(globals.lists_mutex);
|
||||
|
||||
if (xml) {
|
||||
switch_xml_free(xml);
|
||||
xml = NULL;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#define BLACKLIST_API_SYNTAX \
|
||||
"blacklist check <listname> <item>\n" \
|
||||
"blacklist add <listname> <item>\n" \
|
||||
"blacklist del <listname> <item>\n" \
|
||||
"blacklist reload\n" \
|
||||
"blacklist help\n"
|
||||
|
||||
SWITCH_STANDARD_API(blacklist_api_function)
|
||||
{
|
||||
char *data;
|
||||
int argc;
|
||||
char *argv[3];
|
||||
|
||||
data = strdup(cmd);
|
||||
trim(data);
|
||||
if (!(argc = switch_separate_string(data, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid usage\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!strcasecmp(argv[0], "check")) {
|
||||
blacklist_t *bl = NULL;
|
||||
switch_bool_t result;
|
||||
|
||||
if (argc < 2 || zstr(argv[1]) || zstr(argv[2])) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Wrong syntax");
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch_mutex_lock(globals.lists_mutex);
|
||||
bl = switch_core_hash_find(globals.lists, argv[1]);
|
||||
switch_mutex_unlock(globals.lists_mutex);
|
||||
|
||||
if (!bl) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown blacklist [%s]\n", argv[1]);
|
||||
stream->write_function(stream, "false");
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch_mutex_lock(bl->list_mutex);
|
||||
result = (switch_bool_t)(intptr_t)switch_core_hash_find(bl->list, argv[2]);
|
||||
stream->write_function(stream, "%s", result ? "true" : "false");
|
||||
switch_mutex_unlock(bl->list_mutex);
|
||||
} else if (!strcasecmp(argv[0], "add")) {
|
||||
blacklist_t *bl = NULL;
|
||||
if (argc < 2 || zstr(argv[1]) || zstr(argv[2])) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Wrong syntax");
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch_mutex_lock(globals.lists_mutex);
|
||||
bl = switch_core_hash_find(globals.lists, argv[1]);
|
||||
switch_mutex_unlock(globals.lists_mutex);
|
||||
|
||||
if (!bl) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown blacklist [%s]\n", argv[1]);
|
||||
stream->write_function(stream, "-ERR Unknown blacklist\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch_mutex_lock(bl->list_mutex);
|
||||
switch_core_hash_insert(bl->list, argv[2], (void*)SWITCH_TRUE);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added [%s] to list [%s]\n", argv[2], argv[1]);
|
||||
switch_mutex_unlock(bl->list_mutex);
|
||||
stream->write_function(stream, "+OK\n");
|
||||
} else if (!strcasecmp(argv[0], "del")) {
|
||||
blacklist_t *bl = NULL;
|
||||
if (argc < 2 || zstr(argv[1]) || zstr(argv[2])) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Wrong syntax");
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch_mutex_lock(globals.lists_mutex);
|
||||
bl = switch_core_hash_find(globals.lists, argv[1]);
|
||||
switch_mutex_unlock(globals.lists_mutex);
|
||||
|
||||
if (!bl) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown blacklist [%s]\n", argv[1]);
|
||||
stream->write_function(stream, "-ERR Unknown blacklist\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch_mutex_lock(bl->list_mutex);
|
||||
switch_core_hash_insert(bl->list, argv[2], NULL);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Removed [%s] from list [%s]\n", argv[2], argv[1]);
|
||||
switch_mutex_unlock(bl->list_mutex);
|
||||
stream->write_function(stream, "+OK\n");
|
||||
} else if (!strcasecmp(argv[0], "dump")) {
|
||||
switch_hash_index_t *hi;
|
||||
void *val;
|
||||
const void *var;
|
||||
blacklist_t *bl = NULL;
|
||||
char *filename = NULL;
|
||||
switch_file_t *fd;
|
||||
|
||||
if (argc < 1 || zstr(argv[1])) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Missing blacklist name");
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch_mutex_lock(globals.lists_mutex);
|
||||
bl = switch_core_hash_find(globals.lists, argv[1]);
|
||||
switch_mutex_unlock(globals.lists_mutex);
|
||||
|
||||
switch_mutex_lock(globals.files_mutex);
|
||||
filename = switch_core_hash_find(globals.files, argv[1]);
|
||||
switch_mutex_unlock(globals.files_mutex);
|
||||
|
||||
if (!bl) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown blacklist [%s]\n", argv[1]);
|
||||
stream->write_function(stream, "-ERR Unknown blacklist\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Dumping %s to %s\n", argv[1], filename);
|
||||
|
||||
switch_mutex_lock(globals.lists_mutex);
|
||||
if (switch_file_open(&fd, filename, SWITCH_FOPEN_WRITE, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, globals.pool) == SWITCH_STATUS_SUCCESS) {
|
||||
for (hi = switch_hash_first(NULL, bl->list); hi; hi = switch_hash_next(hi)) {
|
||||
switch_hash_this(hi, &var, NULL, &val);
|
||||
switch_file_printf(fd, "%s\n", (char *)var);
|
||||
}
|
||||
stream->write_function(stream, "+OK\n");
|
||||
}
|
||||
switch_mutex_unlock(globals.lists_mutex);
|
||||
} else if (!strcasecmp(argv[0], "reload")) {
|
||||
do_config(SWITCH_TRUE);
|
||||
stream->write_function(stream, "+OK\n");
|
||||
} else if (!strcasecmp(argv[0], "help")) {
|
||||
stream->write_function(stream, BLACKLIST_API_SYNTAX "+OK\n");
|
||||
} else if (!zstr(argv[0])) {
|
||||
stream->write_function(stream, "-ERR: No such command: %s (see 'blacklist help')\n", argv[0]);
|
||||
}
|
||||
|
||||
done:
|
||||
switch_safe_free(data);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_blacklist_load)
|
||||
{
|
||||
switch_api_interface_t *api_interface;
|
||||
//switch_application_interface_t *app_interface;
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
globals.pool = pool;
|
||||
|
||||
switch_core_hash_init(&globals.files, globals.pool);
|
||||
switch_mutex_init(&globals.files_mutex, SWITCH_MUTEX_NESTED, globals.pool);
|
||||
|
||||
switch_core_hash_init(&globals.lists, globals.pool);
|
||||
switch_mutex_init(&globals.lists_mutex, SWITCH_MUTEX_NESTED, globals.pool);
|
||||
|
||||
do_config(SWITCH_FALSE);
|
||||
|
||||
SWITCH_ADD_API(api_interface, "blacklist", "Control blacklists", blacklist_api_function, "");
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_blacklist_shutdown)
|
||||
{
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:t
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4
|
||||
*/
|
||||
@@ -1840,6 +1840,15 @@ SWITCH_STANDARD_API(ctl_function)
|
||||
switch_core_session_ctl(SCSC_VERBOSE_EVENTS, &arg);
|
||||
|
||||
stream->write_function(stream, "+OK verbose_events is %s \n", arg ? "on" : "off");
|
||||
} else if (!strcasecmp(argv[0], "threaded_system_exec")) {
|
||||
arg = -1;
|
||||
if (argv[1]) {
|
||||
arg = switch_true(argv[1]);
|
||||
}
|
||||
|
||||
switch_core_session_ctl(SCSC_THREADED_SYSTEM_EXEC, &arg);
|
||||
|
||||
stream->write_function(stream, "+OK threaded_system_exec is %s \n", arg ? "true" : "false");
|
||||
|
||||
} else if (!strcasecmp(argv[0], "save_history")) {
|
||||
switch_core_session_ctl(SCSC_SAVE_HISTORY, NULL);
|
||||
@@ -4020,12 +4029,12 @@ SWITCH_STANDARD_API(show_function)
|
||||
}
|
||||
if (strchr(argv[2], '%')) {
|
||||
sprintf(sql,
|
||||
"select * from channels where hostname='%s' and uuid like '%s' or name like '%s' or cid_name like '%s' or cid_num like '%s' order by created_epoch",
|
||||
hostname, argv[2], argv[2], argv[2], argv[2]);
|
||||
"select * from channels where hostname='%s' and uuid like '%s' or name like '%s' or cid_name like '%s' or cid_num like '%s' or presence_data like '%s' order by created_epoch",
|
||||
hostname, argv[2], argv[2], argv[2], argv[2], argv[2]);
|
||||
} else {
|
||||
sprintf(sql,
|
||||
"select * from channels where hostname='%s' and uuid like '%%%s%%' or name like '%%%s%%' or cid_name like '%%%s%%' or cid_num like '%%%s%%' order by created_epoch",
|
||||
hostname, argv[2], argv[2], argv[2], argv[2]);
|
||||
"select * from channels where hostname='%s' and uuid like '%%%s%%' or name like '%%%s%%' or cid_name like '%%%s%%' or cid_num like '%%%s%%' or presence_data like '%%%s%%' order by created_epoch",
|
||||
hostname, argv[2], argv[2], argv[2], argv[2], argv[2]);
|
||||
|
||||
}
|
||||
|
||||
@@ -4069,11 +4078,11 @@ SWITCH_STANDARD_API(show_function)
|
||||
holder.print_title = 0;
|
||||
if ((cmdname = strchr(command, ' ')) && strcasecmp(cmdname, "as")) {
|
||||
*cmdname++ = '\0';
|
||||
switch_snprintf(sql, sizeof(sql) - 1,
|
||||
"select name, syntax, description, ikey from interfaces where hostname='%s' and type = 'api' and name = '%s' order by name",
|
||||
switch_snprintfv(sql, sizeof(sql),
|
||||
"select name, syntax, description, ikey from interfaces where hostname='%s' and type = 'api' and name = '%q' order by name",
|
||||
hostname, cmdname);
|
||||
} else {
|
||||
switch_snprintf(sql, sizeof(sql) - 1, "select name, syntax, description, ikey from interfaces where hostname='%s' and type = 'api' order by name", hostname);
|
||||
switch_snprintfv(sql, sizeof(sql), "select name, syntax, description, ikey from interfaces where hostname='%q' and type = 'api' order by name", hostname);
|
||||
}
|
||||
} else if (!strcasecmp(command, "nat_map")) {
|
||||
switch_snprintf(sql, sizeof(sql) - 1,
|
||||
@@ -4262,6 +4271,21 @@ SWITCH_STANDARD_API(uuid_flush_dtmf_function)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(uuid_zombie_exec_function)
|
||||
{
|
||||
switch_core_session_t *fsession;
|
||||
|
||||
if (!zstr(cmd) && (fsession = switch_core_session_locate(cmd))) {
|
||||
switch_channel_set_flag(switch_core_session_get_channel(fsession), CF_ZOMBIE_EXEC);
|
||||
switch_core_session_rwunlock(fsession);
|
||||
stream->write_function(stream, "+OK MMM Brains...\n");
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR no such session\n");
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#define SETVAR_SYNTAX "<uuid> <var> [value]"
|
||||
SWITCH_STANDARD_API(uuid_setvar_function)
|
||||
{
|
||||
@@ -5322,6 +5346,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
|
||||
SWITCH_ADD_API(commands_api_interface, "uuid_simplify", "Try to cut out of a call path / attended xfer", uuid_simplify_function, SIMPLIFY_SYNTAX);
|
||||
SWITCH_ADD_API(commands_api_interface, "uuid_jitterbuffer", "Try to cut out of a call path / attended xfer",
|
||||
uuid_jitterbuffer_function, JITTERBUFFER_SYNTAX);
|
||||
SWITCH_ADD_API(commands_api_interface, "uuid_zombie_exec", "Set zombie_exec flag on the specified uuid", uuid_zombie_exec_function, "<uuid>");
|
||||
SWITCH_ADD_API(commands_api_interface, "xml_flush_cache", "clear xml cache", xml_flush_function, "<id> <key> <val>");
|
||||
SWITCH_ADD_API(commands_api_interface, "xml_locate", "find some xml", xml_locate_function, "[root | <section> <tag> <tag_attr_name> <tag_attr_val>]");
|
||||
SWITCH_ADD_API(commands_api_interface, "xml_wrap", "Wrap another api command in xml", xml_wrap_api_function, "<command> <args>");
|
||||
@@ -5389,7 +5414,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
|
||||
switch_console_set_complete("add show codec");
|
||||
switch_console_set_complete("add show complete");
|
||||
switch_console_set_complete("add show dialplan");
|
||||
switch_console_set_complete("add show distinct_channels");
|
||||
switch_console_set_complete("add show detailed_calls");
|
||||
switch_console_set_complete("add show bridged_calls");
|
||||
switch_console_set_complete("add show detailed_bridged_calls");
|
||||
switch_console_set_complete("add show endpoint");
|
||||
switch_console_set_complete("add show file");
|
||||
switch_console_set_complete("add show interfaces");
|
||||
|
||||
@@ -436,8 +436,8 @@ static switch_status_t conference_member_play_file(conference_member_t *member,
|
||||
static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin);
|
||||
static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop);
|
||||
static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_core_session_t *session, switch_memory_pool_t *pool);
|
||||
static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject,
|
||||
const char *body, const char *type, const char *hint);
|
||||
static switch_status_t chat_send(switch_event_t *message_event);
|
||||
|
||||
|
||||
static void launch_conference_record_thread(conference_obj_t *conference, char *path);
|
||||
static void launch_conference_video_bridge_thread(conference_member_t *member_a, conference_member_t *member_b);
|
||||
@@ -2705,19 +2705,16 @@ static void conference_loop_output(conference_member_t *member)
|
||||
if (event->event_id == SWITCH_EVENT_MESSAGE) {
|
||||
char *from = switch_event_get_header(event, "from");
|
||||
char *to = switch_event_get_header(event, "to");
|
||||
char *proto = switch_event_get_header(event, "proto");
|
||||
char *subject = switch_event_get_header(event, "subject");
|
||||
char *hint = switch_event_get_header(event, "hint");
|
||||
char *body = switch_event_get_body(event);
|
||||
char *p, *freeme = NULL;
|
||||
char *p;
|
||||
|
||||
if (to && from && body) {
|
||||
if ((p = strchr(to, '+')) && strncmp(to, CONF_CHAT_PROTO, strlen(CONF_CHAT_PROTO))) {
|
||||
freeme = switch_mprintf("%s+%s@%s", CONF_CHAT_PROTO, member->conference->name, member->conference->domain);
|
||||
to = freeme;
|
||||
switch_event_del_header(event, "to");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM,
|
||||
"to", "%s+%s@%s", CONF_CHAT_PROTO, member->conference->name, member->conference->domain);
|
||||
}
|
||||
chat_send(proto, from, to, subject, body, NULL, hint);
|
||||
switch_safe_free(freeme);
|
||||
chat_send(event);
|
||||
}
|
||||
}
|
||||
switch_event_destroy(&event);
|
||||
@@ -6379,12 +6376,26 @@ static void launch_conference_record_thread(conference_obj_t *conference, char *
|
||||
switch_thread_create(&thread, thd_attr, conference_record_thread_run, rec, rec->pool);
|
||||
}
|
||||
|
||||
static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject,
|
||||
const char *body, const char *type, const char *hint)
|
||||
static switch_status_t chat_send(switch_event_t *message_event)
|
||||
{
|
||||
char name[512] = "", *p, *lbuf = NULL;
|
||||
conference_obj_t *conference = NULL;
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
const char *proto;
|
||||
const char *from;
|
||||
const char *to;
|
||||
//const char *subject;
|
||||
const char *body;
|
||||
//const char *type;
|
||||
const char *hint;
|
||||
|
||||
proto = switch_event_get_header(message_event, "proto");
|
||||
from = switch_event_get_header(message_event, "from");
|
||||
to = switch_event_get_header(message_event, "to");
|
||||
//subject = switch_event_get_header(message_event, "subject");
|
||||
body = switch_event_get_body(message_event);
|
||||
//type = switch_event_get_header(message_event, "type");
|
||||
hint = switch_event_get_header(message_event, "hint");
|
||||
|
||||
if ((p = strchr(to, '+'))) {
|
||||
to = ++p;
|
||||
@@ -6401,7 +6412,7 @@ static switch_status_t chat_send(const char *proto, const char *from, const char
|
||||
}
|
||||
|
||||
if (!(conference = conference_find(name))) {
|
||||
switch_core_chat_send(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", "Conference not active.", NULL, NULL);
|
||||
switch_core_chat_send_args(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", "Conference not active.", NULL, NULL);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
@@ -6419,7 +6430,7 @@ static switch_status_t chat_send(const char *proto, const char *from, const char
|
||||
|
||||
switch_safe_free(lbuf);
|
||||
|
||||
switch_core_chat_send(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", stream.data, NULL, NULL);
|
||||
switch_core_chat_send_args(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", stream.data, NULL, NULL);
|
||||
switch_safe_free(stream.data);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
@@ -622,8 +622,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_db_load)
|
||||
/* register limit interfaces */
|
||||
SWITCH_ADD_LIMIT(limit_interface, "db", limit_incr_db, limit_release_db, limit_usage_db, limit_reset_db, limit_status_db, NULL);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "db", "Insert to the db", DB_DESC, db_function, DB_USAGE, SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "group", "Manage a group", GROUP_DESC, group_function, GROUP_USAGE, SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "db", "Insert to the db", DB_DESC, db_function, DB_USAGE, SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "group", "Manage a group", GROUP_DESC, group_function, GROUP_USAGE, SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_API(commands_api_interface, "db", "db get/set", db_api_function, "[insert|delete|select]/<realm>/<key>/<value>");
|
||||
switch_console_set_complete("add db insert");
|
||||
switch_console_set_complete("add db delete");
|
||||
|
||||
@@ -102,37 +102,50 @@ struct action_binding {
|
||||
char *input;
|
||||
char *string;
|
||||
char *value;
|
||||
switch_digit_action_target_t target;
|
||||
switch_core_session_t *session;
|
||||
};
|
||||
|
||||
static switch_status_t digit_nomatch_action_callback(switch_ivr_dmachine_match_t *match)
|
||||
{
|
||||
switch_core_session_t *session = (switch_core_session_t *) match->user_data;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
char str[DMACHINE_MAX_DIGIT_LEN + 2];
|
||||
switch_channel_t *channel;
|
||||
switch_event_t *event;
|
||||
switch_status_t status;
|
||||
switch_core_session_t *use_session = session;
|
||||
|
||||
if (switch_ivr_dmachine_get_target(match->dmachine) == DIGIT_TARGET_PEER) {
|
||||
if (switch_core_session_get_partner(session, &use_session) != SWITCH_STATUS_SUCCESS) {
|
||||
use_session = session;
|
||||
}
|
||||
}
|
||||
|
||||
channel = switch_core_session_get_channel(use_session);
|
||||
|
||||
|
||||
switch_channel_set_variable(channel, "last_non_matching_digits", match->match_digits);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Digit NOT match binding [%s]\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_DEBUG, "%s Digit NOT match binding [%s]\n",
|
||||
switch_channel_get_name(channel), match->match_digits);
|
||||
|
||||
if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "digits", match->match_digits);
|
||||
|
||||
if ((status = switch_core_session_queue_event(session, &event)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = switch_core_session_queue_event(use_session, &event)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_destroy(&event);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s event queue faiure.\n",
|
||||
switch_core_session_get_name(session));
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_WARNING, "%s event queue failure.\n",
|
||||
switch_core_session_get_name(use_session));
|
||||
}
|
||||
}
|
||||
|
||||
/* send it back around flagged to skip the dmachine */
|
||||
switch_snprintf(str, sizeof(str), "!%s", match->match_digits);
|
||||
|
||||
switch_channel_queue_dtmf_string(channel, str);
|
||||
/* send it back around and skip the dmachine */
|
||||
switch_channel_queue_dtmf_string(channel, match->match_digits);
|
||||
|
||||
if (use_session != session) {
|
||||
switch_core_session_rwunlock(use_session);
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -143,9 +156,25 @@ static switch_status_t digit_action_callback(switch_ivr_dmachine_match_t *match)
|
||||
switch_status_t status;
|
||||
int exec = 0;
|
||||
char *string = act->string;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(act->session);
|
||||
switch_channel_t *channel;
|
||||
switch_core_session_t *use_session = act->session;
|
||||
int x = 0;
|
||||
if (switch_ivr_dmachine_get_target(match->dmachine) == DIGIT_TARGET_PEER || act->target == DIGIT_TARGET_PEER || act->target == DIGIT_TARGET_BOTH) {
|
||||
if (switch_core_session_get_partner(act->session, &use_session) != SWITCH_STATUS_SUCCESS) {
|
||||
use_session = act->session;
|
||||
}
|
||||
}
|
||||
|
||||
top:
|
||||
x++;
|
||||
|
||||
string = act->string;
|
||||
exec = 0;
|
||||
|
||||
channel = switch_core_session_get_channel(use_session);
|
||||
|
||||
switch_channel_set_variable(channel, "last_matching_digits", match->match_digits);
|
||||
|
||||
|
||||
if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s]\n",
|
||||
@@ -163,31 +192,62 @@ static switch_status_t digit_action_callback(switch_ivr_dmachine_match_t *match)
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "execute", exec == 2 ? "non-blocking" : "blocking");
|
||||
}
|
||||
|
||||
if ((status = switch_core_session_queue_event(act->session, &event)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = switch_core_session_queue_event(use_session, &event)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_destroy(&event);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session), SWITCH_LOG_WARNING, "%s event queue faiure.\n",
|
||||
switch_core_session_get_name(act->session));
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_WARNING, "%s event queue faiure.\n",
|
||||
switch_core_session_get_name(use_session));
|
||||
}
|
||||
}
|
||||
|
||||
if (exec) {
|
||||
char *cmd = switch_core_session_sprintf(act->session, "%s::%s", string, act->value);
|
||||
switch_ivr_broadcast_in_thread(act->session, cmd, SMF_ECHO_ALEG|SMF_HOLD_BLEG);
|
||||
char *cmd = switch_core_session_sprintf(use_session, "%s::%s", string, act->value);
|
||||
switch_ivr_broadcast_in_thread(use_session, cmd, SMF_ECHO_ALEG | (act->target == DIGIT_TARGET_BOTH ? 0 : SMF_HOLD_BLEG));
|
||||
}
|
||||
|
||||
|
||||
if (use_session != act->session) {
|
||||
switch_core_session_rwunlock(use_session);
|
||||
|
||||
if (act->target == DIGIT_TARGET_BOTH) {
|
||||
use_session = act->session;
|
||||
goto top;
|
||||
}
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#define CLEAR_DIGIT_ACTION_USAGE "<realm>|all"
|
||||
static switch_digit_action_target_t str2target(const char *target_str)
|
||||
{
|
||||
if (!strcasecmp(target_str, "peer")) {
|
||||
return DIGIT_TARGET_PEER;
|
||||
}
|
||||
|
||||
if (!strcasecmp(target_str, "both")) {
|
||||
return DIGIT_TARGET_BOTH;
|
||||
}
|
||||
|
||||
return DIGIT_TARGET_SELF;
|
||||
}
|
||||
|
||||
#define CLEAR_DIGIT_ACTION_USAGE "<realm>|all[,target]"
|
||||
SWITCH_STANDARD_APP(clear_digit_action_function)
|
||||
{
|
||||
//switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_ivr_dmachine_t *dmachine;
|
||||
char *realm = (char *) data;
|
||||
char *realm = switch_core_session_strdup(session, data);
|
||||
char *target_str;
|
||||
switch_digit_action_target_t target = DIGIT_TARGET_SELF;
|
||||
|
||||
if ((dmachine = switch_core_session_get_dmachine(session))) {
|
||||
if ((target_str = strchr(realm, ','))) {
|
||||
*target_str++ = '\0';
|
||||
target = str2target(target_str);
|
||||
}
|
||||
|
||||
|
||||
if ((dmachine = switch_core_session_get_dmachine(session, target))) {
|
||||
if (zstr(realm) || !strcasecmp(realm, "all")) {
|
||||
switch_core_session_set_dmachine(session, NULL);
|
||||
switch_core_session_set_dmachine(session, NULL, target);
|
||||
switch_ivr_dmachine_destroy(&dmachine);
|
||||
} else {
|
||||
switch_ivr_dmachine_clear_realm(dmachine, realm);
|
||||
@@ -195,49 +255,41 @@ SWITCH_STANDARD_APP(clear_digit_action_function)
|
||||
}
|
||||
}
|
||||
|
||||
#define DIGIT_ACTION_SET_REALM_USAGE "<realm>"
|
||||
#define DIGIT_ACTION_SET_REALM_USAGE "<realm>[,<target>]"
|
||||
SWITCH_STANDARD_APP(digit_action_set_realm_function)
|
||||
{
|
||||
switch_ivr_dmachine_t *dmachine;
|
||||
char *realm = (char *) data;
|
||||
char *realm = switch_core_session_strdup(session, data);
|
||||
char *target_str;
|
||||
switch_digit_action_target_t target = DIGIT_TARGET_SELF;
|
||||
|
||||
if ((target_str = strchr(realm, ','))) {
|
||||
*target_str++ = '\0';
|
||||
target = str2target(target_str);
|
||||
}
|
||||
|
||||
if (zstr(data)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Syntax Error, USAGE %s\n", DIGIT_ACTION_SET_REALM_USAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ((dmachine = switch_core_session_get_dmachine(session))) {
|
||||
if ((dmachine = switch_core_session_get_dmachine(session, target))) {
|
||||
switch_ivr_dmachine_set_realm(dmachine, realm);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#define BIND_DIGIT_ACTION_USAGE "<realm>,<digits|~regex>,<string>,<value>"
|
||||
SWITCH_STANDARD_APP(bind_digit_action_function)
|
||||
|
||||
static void bind_to_session(switch_core_session_t *session,
|
||||
const char *arg0, const char *arg1, const char *arg2, const char *arg3,
|
||||
switch_digit_action_target_t target, switch_digit_action_target_t bind_target)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_ivr_dmachine_t *dmachine;
|
||||
char *mydata;
|
||||
int argc = 0;
|
||||
char *argv[4] = { 0 };
|
||||
struct action_binding *act;
|
||||
switch_ivr_dmachine_t *dmachine;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
if (zstr(data)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Syntax Error, USAGE %s\n", BIND_DIGIT_ACTION_USAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
mydata = switch_core_session_strdup(session, data);
|
||||
|
||||
argc = switch_separate_string(mydata, ',', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (argc < 4 || zstr(argv[0]) || zstr(argv[1]) || zstr(argv[2]) || zstr(argv[3])) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Syntax Error, USAGE %s\n", BIND_DIGIT_ACTION_USAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!(dmachine = switch_core_session_get_dmachine(session))) {
|
||||
if (!(dmachine = switch_core_session_get_dmachine(session, target))) {
|
||||
uint32_t digit_timeout = 1500;
|
||||
uint32_t input_timeout = 0;
|
||||
const char *var;
|
||||
@@ -256,20 +308,69 @@ SWITCH_STANDARD_APP(bind_digit_action_function)
|
||||
}
|
||||
|
||||
switch_ivr_dmachine_create(&dmachine, "DPTOOLS", NULL, digit_timeout, input_timeout, NULL, digit_nomatch_action_callback, session);
|
||||
switch_core_session_set_dmachine(session, dmachine);
|
||||
switch_core_session_set_dmachine(session, dmachine, target);
|
||||
}
|
||||
|
||||
|
||||
act = switch_core_session_alloc(session, sizeof(*act));
|
||||
act->realm = argv[0];
|
||||
act->input = argv[1];
|
||||
act->string = argv[2];
|
||||
act->value = argv[3];
|
||||
act->realm = switch_core_session_strdup(session, arg0);
|
||||
act->input = switch_core_session_strdup(session, arg1);
|
||||
act->string = switch_core_session_strdup(session, arg2);
|
||||
act->value = switch_core_session_strdup(session, arg3);
|
||||
act->target = bind_target;
|
||||
act->session = session;
|
||||
|
||||
switch_ivr_dmachine_bind(dmachine, act->realm, act->input, 0, digit_action_callback, act);
|
||||
}
|
||||
|
||||
#define BIND_DIGIT_ACTION_USAGE "<realm>,<digits|~regex>,<string>,<value>[,<dtmf target leg>][,<event target leg>]"
|
||||
SWITCH_STANDARD_APP(bind_digit_action_function)
|
||||
{
|
||||
|
||||
char *mydata;
|
||||
int argc = 0;
|
||||
char *argv[6] = { 0 };
|
||||
switch_digit_action_target_t target, bind_target;
|
||||
char *target_str = "self", *bind_target_str = "self";
|
||||
|
||||
if (zstr(data)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Syntax Error, USAGE %s\n", BIND_DIGIT_ACTION_USAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
mydata = switch_core_session_strdup(session, data);
|
||||
|
||||
argc = switch_separate_string(mydata, ',', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (argc < 4 || zstr(argv[0]) || zstr(argv[1]) || zstr(argv[2]) || zstr(argv[3])) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Syntax Error, USAGE %s\n", BIND_DIGIT_ACTION_USAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (argv[4]) {
|
||||
target_str = argv[4];
|
||||
}
|
||||
|
||||
if (argv[5]) {
|
||||
bind_target_str = argv[5];
|
||||
}
|
||||
|
||||
target = str2target(target_str);
|
||||
bind_target = str2target(bind_target_str);
|
||||
|
||||
|
||||
switch(target) {
|
||||
case DIGIT_TARGET_PEER:
|
||||
bind_to_session(session, argv[0], argv[1], argv[2], argv[3], DIGIT_TARGET_PEER, bind_target);
|
||||
break;
|
||||
case DIGIT_TARGET_BOTH:
|
||||
bind_to_session(session, argv[0], argv[1], argv[2], argv[3], DIGIT_TARGET_PEER, bind_target);
|
||||
bind_to_session(session, argv[0], argv[1], argv[2], argv[3], DIGIT_TARGET_SELF, bind_target);
|
||||
break;
|
||||
default:
|
||||
bind_to_session(session, argv[0], argv[1], argv[2], argv[3], DIGIT_TARGET_SELF, bind_target);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define DETECT_SPEECH_SYNTAX "<mod_name> <gram_name> <gram_path> [<addr>] OR grammar <gram_name> [<path>] OR nogrammar <gram_name> OR grammaron/grammaroff <gram_name> OR grammarsalloff OR pause OR resume OR start_input_timers OR stop OR param <name> <value>"
|
||||
SWITCH_STANDARD_APP(detect_speech_function)
|
||||
@@ -904,6 +1005,18 @@ SWITCH_STANDARD_APP(eval_function)
|
||||
return;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_APP(zombie_function)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
if (switch_channel_up(channel)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s MMM Brains....\n", switch_channel_get_name(channel));
|
||||
switch_channel_set_flag(channel, CF_ZOMBIE_EXEC);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SWITCH_STANDARD_APP(hangup_function)
|
||||
{
|
||||
@@ -1271,6 +1384,7 @@ SWITCH_STANDARD_APP(event_function)
|
||||
switch_assert(new);
|
||||
memcpy(new, val, len);
|
||||
event->subclass_name = new;
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, var, val);
|
||||
} else {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, var, val);
|
||||
}
|
||||
@@ -1447,7 +1561,7 @@ SWITCH_STANDARD_API(chat_api_function)
|
||||
if (!zstr(cmd) && (lbuf = strdup(cmd))
|
||||
&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) >= 4) {
|
||||
|
||||
if (switch_core_chat_send(argv[0], "dp", argv[1], argv[2], "", argv[3], !zstr(argv[4]) ? argv[4] : NULL, "") == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_chat_send_args(argv[0], "dp", argv[1], argv[2], "", argv[3], !zstr(argv[4]) ? argv[4] : NULL, "") == SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "Sent");
|
||||
} else {
|
||||
stream->write_function(stream, "Error! Message Not Sent");
|
||||
@@ -3270,44 +3384,51 @@ SWITCH_STANDARD_APP(wait_for_silence_function)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", WAIT_FOR_SILENCE_SYNTAX);
|
||||
}
|
||||
|
||||
static switch_status_t event_chat_send(const char *proto, const char *from, const char *to, const char *subject,
|
||||
const char *body, const char *type, const char *hint)
|
||||
static switch_status_t event_chat_send(switch_event_t *message_event)
|
||||
|
||||
{
|
||||
switch_event_t *event;
|
||||
const char *to;
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_RECV_MESSAGE) == SWITCH_STATUS_SUCCESS) {
|
||||
if (proto)
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Proto", proto);
|
||||
if (from)
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "From", from);
|
||||
if (subject)
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Subject", subject);
|
||||
if (hint)
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Hint", hint);
|
||||
if (body)
|
||||
switch_event_add_body(event, "%s", body);
|
||||
if (to) {
|
||||
char *v;
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "To", to);
|
||||
if ((v = switch_core_get_variable_dup(to))) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Command", v);
|
||||
free(v);
|
||||
}
|
||||
switch_event_dup(&event, message_event);
|
||||
event->event_id = SWITCH_EVENT_RECV_MESSAGE;
|
||||
|
||||
if ((to = switch_event_get_header(event, "to"))) {
|
||||
char *v;
|
||||
if ((v = switch_core_get_variable_dup(to))) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Command", v);
|
||||
free(v);
|
||||
}
|
||||
|
||||
if (switch_event_fire(&event) == SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
switch_event_destroy(&event);
|
||||
}
|
||||
|
||||
if (switch_event_fire(&event) == SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
switch_event_destroy(&event);
|
||||
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
|
||||
static switch_status_t api_chat_send(const char *proto, const char *from, const char *to, const char *subject,
|
||||
const char *body, const char *type, const char *hint)
|
||||
static switch_status_t api_chat_send(switch_event_t *message_event)
|
||||
{
|
||||
const char *proto;
|
||||
const char *from;
|
||||
const char *to;
|
||||
//const char *subject;
|
||||
//const char *body;
|
||||
const char *type;
|
||||
const char *hint;
|
||||
|
||||
proto = switch_event_get_header(message_event, "proto");
|
||||
from = switch_event_get_header(message_event, "from");
|
||||
to = switch_event_get_header(message_event, "to");
|
||||
//subject = switch_event_get_header(message_event, "subject");
|
||||
//body = switch_event_get_body(message_event);
|
||||
type = switch_event_get_header(message_event, "type");
|
||||
hint = switch_event_get_header(message_event, "hint");
|
||||
|
||||
|
||||
if (to) {
|
||||
char *v = NULL;
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
@@ -3330,7 +3451,7 @@ static switch_status_t api_chat_send(const char *proto, const char *from, const
|
||||
switch_api_execute(cmd, arg, NULL, &stream);
|
||||
|
||||
if (proto) {
|
||||
switch_core_chat_send(proto, "api", to, hint && strchr(hint, '/') ? hint : from, !zstr(type) ? type : NULL, (char *) stream.data, NULL, NULL);
|
||||
switch_core_chat_send_args(proto, "api", to, hint && strchr(hint, '/') ? hint : from, !zstr(type) ? type : NULL, (char *) stream.data, NULL, NULL);
|
||||
}
|
||||
|
||||
switch_safe_free(stream.data);
|
||||
@@ -3788,7 +3909,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "digit_action_set_realm", "change binding realm", "",
|
||||
digit_action_set_realm_function, DIGIT_ACTION_SET_REALM_USAGE, SAF_SUPPORT_NOMEDIA);
|
||||
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "privacy", "Set privacy on calls", "Set caller privacy on calls.", privacy_function, "off|on|name|full|number",
|
||||
SAF_SUPPORT_NOMEDIA);
|
||||
@@ -3812,7 +3932,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
||||
SWITCH_ADD_APP(app_interface, "delay_echo", "echo audio at a specified delay", "Delay n ms", delay_function, "<delay ms>", SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "strftime", "strftime", "strftime", strftime_function, "[<epoch>|]<format string>", SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "phrase", "Say a Phrase", "Say a Phrase", phrase_function, "<macro_name>,<data>", SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "eval", "Do Nothing", "Do Nothing", eval_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "eval", "Do Nothing", "Do Nothing", eval_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "stop", "Do Nothing", "Do Nothing", eval_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "set_zombie_exec", "Enable Zombie Execution", "Enable Zombie Execution",
|
||||
zombie_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "pre_answer", "Pre-Answer the call", "Pre-Answer the call for a channel.", pre_answer_function, "", SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "answer", "Answer the call", "Answer the call for a channel.", answer_function, "", SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "hangup", "Hangup the call", "Hangup the call for a channel.", hangup_function, "[<cause>]", SAF_SUPPORT_NOMEDIA);
|
||||
@@ -3820,29 +3943,29 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
||||
SWITCH_ADD_APP(app_interface, "presence", "Send Presence", "Send Presence.", presence_function, "<rpid> <status> [<id>]",
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "log", "Logs to the logger", LOG_LONG_DESC, log_function, "<log_level> <log_string>",
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "info", "Display Call Info", "Display Call Info", info_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "event", "Fire an event", "Fire an event", event_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "info", "Display Call Info", "Display Call Info", info_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "event", "Fire an event", "Fire an event", event_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "sound_test", "Analyze Audio", "Analyze Audio", sound_test_function, "", SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "export", "Export a channel variable across a bridge", EXPORT_LONG_DESC, export_function, "<varname>=<value>",
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "bridge_export", "Export a channel variable across a bridge", EXPORT_LONG_DESC, bridge_export_function, "<varname>=<value>",
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "set", "Set a channel variable", SET_LONG_DESC, set_function, "<varname>=<value>",
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "push", "Set a channel variable", SET_LONG_DESC, push_function, "<varname>=<value>",
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "unshift", "Set a channel variable", SET_LONG_DESC, unshift_function, "<varname>=<value>",
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "set_global", "Set a global variable", SET_GLOBAL_LONG_DESC, set_global_function, "<varname>=<value>",
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "set_profile_var", "Set a caller profile variable", SET_PROFILE_VAR_LONG_DESC, set_profile_var_function,
|
||||
"<varname>=<value>", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
"<varname>=<value>", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "unset", "Unset a channel variable", UNSET_LONG_DESC, unset_function, "<varname>",
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "ring_ready", "Indicate Ring_Ready", "Indicate Ring_Ready on a channel.", ring_ready_function, "", SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "remove_bugs", "Remove media bugs", "Remove all media bugs from a channel.", remove_bugs_function, "", SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "break", "Break", "Set the break flag.", break_function, "", SAF_SUPPORT_NOMEDIA);
|
||||
|
||||
@@ -1329,7 +1329,7 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da
|
||||
if (digit_str[0]) {
|
||||
char *p = digit_str;
|
||||
while (p && *p) {
|
||||
switch_dtmf_t dtmf;
|
||||
switch_dtmf_t dtmf = {0};
|
||||
dtmf.digit = *p;
|
||||
dtmf.duration = switch_core_default_dtmf_duration(0);
|
||||
switch_channel_queue_dtmf(channel, &dtmf);
|
||||
|
||||
@@ -1264,8 +1264,9 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
|
||||
if (timeout < h->timeout) timeout = h->timeout;
|
||||
|
||||
if (use_ent) {
|
||||
stream.write_function(&stream, "{ignore_early_media=true,outbound_redirect_fatal=true,leg_timeout=%d,fifo_outbound_uuid=%s,fifo_name=%s}%s:_:",
|
||||
h->timeout, h->uuid, node->name, parsed ? parsed : h->originate_string);
|
||||
stream.write_function(&stream, "{ignore_early_media=true,outbound_redirect_fatal=true,leg_timeout=%d,fifo_outbound_uuid=%s,fifo_name=%s}%s%s",
|
||||
h->timeout, h->uuid, node->name,
|
||||
parsed ? parsed : h->originate_string, (i == cbh->rowcount - 1) ? "" : SWITCH_ENT_ORIGINATE_DELIM);
|
||||
} else {
|
||||
stream.write_function(&stream, "[leg_timeout=%d,fifo_outbound_uuid=%s,fifo_name=%s]%s,",
|
||||
h->timeout, h->uuid, node->name, parsed ? parsed : h->originate_string);
|
||||
@@ -1278,10 +1279,6 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
|
||||
|
||||
originate_string = (char *) stream.data;
|
||||
|
||||
if (originate_string) {
|
||||
end_of(originate_string) = '\0';
|
||||
}
|
||||
|
||||
uuid_list = (char *) stream2.data;
|
||||
|
||||
if (uuid_list) {
|
||||
@@ -2537,7 +2534,10 @@ SWITCH_STANDARD_APP(fifo_function)
|
||||
if (orbit_ann) {
|
||||
switch_ivr_play_file(session, NULL, orbit_ann, NULL);
|
||||
}
|
||||
switch_ivr_session_transfer(session, cd.orbit_exten, cd.orbit_dialplan, cd.orbit_context);
|
||||
|
||||
if (strcmp(cd.orbit_exten, "_continue_")) {
|
||||
switch_ivr_session_transfer(session, cd.orbit_exten, cd.orbit_dialplan, cd.orbit_context);
|
||||
}
|
||||
}
|
||||
|
||||
check_ocancel(session);
|
||||
@@ -2971,6 +2971,9 @@ SWITCH_STANDARD_APP(fifo_function)
|
||||
switch_safe_free(sql);
|
||||
|
||||
|
||||
switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(other_session));
|
||||
switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(session));
|
||||
|
||||
switch_ivr_multi_threaded_bridge(session, other_session, on_dtmf, other_session, session);
|
||||
|
||||
if (outbound_id) {
|
||||
@@ -3677,7 +3680,6 @@ void node_dump(switch_stream_handle_t *stream)
|
||||
#define FIFO_API_SYNTAX "list|list_verbose|count|debug|status|importance [<fifo name>]|reparse [del_all]"
|
||||
SWITCH_STANDARD_API(fifo_api_function)
|
||||
{
|
||||
int len = 0;
|
||||
fifo_node_t *node;
|
||||
char *data = NULL;
|
||||
int argc = 0;
|
||||
@@ -3772,9 +3774,8 @@ SWITCH_STANDARD_API(fifo_api_function)
|
||||
for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
|
||||
switch_hash_this(hi, &var, NULL, &val);
|
||||
node = (fifo_node_t *) val;
|
||||
len = node_caller_count(node);
|
||||
switch_mutex_lock(node->update_mutex);
|
||||
stream->write_function(stream, "%s:%d:%d:%d\n", (char *) var, node->consumer_count, node_caller_count(node), len);
|
||||
stream->write_function(stream, "%s:%d:%d\n", (char *) var, node->consumer_count, node_caller_count(node));
|
||||
switch_mutex_unlock(node->update_mutex);
|
||||
x++;
|
||||
}
|
||||
@@ -3783,9 +3784,8 @@ SWITCH_STANDARD_API(fifo_api_function)
|
||||
stream->write_function(stream, "none\n");
|
||||
}
|
||||
} else if ((node = switch_core_hash_find(globals.fifo_hash, argv[1]))) {
|
||||
len = node_caller_count(node);
|
||||
switch_mutex_lock(node->update_mutex);
|
||||
stream->write_function(stream, "%s:%d:%d:%d\n", argv[1], node->consumer_count, node_caller_count(node), len);
|
||||
stream->write_function(stream, "%s:%d:%d\n", argv[1], node->consumer_count, node_caller_count(node));
|
||||
switch_mutex_unlock(node->update_mutex);
|
||||
} else {
|
||||
stream->write_function(stream, "none\n");
|
||||
@@ -3795,7 +3795,6 @@ SWITCH_STANDARD_API(fifo_api_function)
|
||||
for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
|
||||
switch_hash_this(hi, &var, NULL, &val);
|
||||
node = (fifo_node_t *) val;
|
||||
len = node_caller_count(node);
|
||||
switch_mutex_lock(node->update_mutex);
|
||||
stream->write_function(stream, "%s:%d\n", (char *) var, node->has_outbound);
|
||||
switch_mutex_unlock(node->update_mutex);
|
||||
@@ -3806,7 +3805,6 @@ SWITCH_STANDARD_API(fifo_api_function)
|
||||
stream->write_function(stream, "none\n");
|
||||
}
|
||||
} else if ((node = switch_core_hash_find(globals.fifo_hash, argv[1]))) {
|
||||
len = node_caller_count(node);
|
||||
switch_mutex_lock(node->update_mutex);
|
||||
stream->write_function(stream, "%s:%d\n", argv[1], node->has_outbound);
|
||||
switch_mutex_unlock(node->update_mutex);
|
||||
|
||||
@@ -945,7 +945,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_hash_load)
|
||||
switch_scheduler_add_task(switch_epoch_time_now(NULL) + LIMIT_HASH_CLEANUP_INTERVAL, limit_hash_cleanup_callback, "limit_hash_cleanup", "mod_hash", 0, NULL,
|
||||
SSHF_NONE);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "hash", "Insert into the hashtable", HASH_DESC, hash_function, HASH_USAGE, SAF_SUPPORT_NOMEDIA)
|
||||
SWITCH_ADD_APP(app_interface, "hash", "Insert into the hashtable", HASH_DESC, hash_function, HASH_USAGE, SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC)
|
||||
SWITCH_ADD_API(commands_api_interface, "hash", "hash get/set", hash_api_function, "[insert|delete|select]/<realm>/<key>/<value>");
|
||||
SWITCH_ADD_API(commands_api_interface, "hash_dump", "dump hash/limit_hash data (used for synchronization)", hash_dump_function, HASH_DUMP_SYNTAX);
|
||||
SWITCH_ADD_API(commands_api_interface, "hash_remote", "hash remote", hash_remote_function, HASH_REMOTE_SYNTAX);
|
||||
|
||||
@@ -605,6 +605,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
||||
char *key = NULL;
|
||||
int i = 0;
|
||||
int r = 0;
|
||||
switch_bool_t lcr_skipped = SWITCH_TRUE; /* assume we'll throw it away, paranoid about leak */
|
||||
|
||||
switch_memory_pool_t *pool = cbt->pool;
|
||||
|
||||
@@ -669,6 +670,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
||||
r = -1; goto end;
|
||||
}
|
||||
lcr_skipped = SWITCH_FALSE;
|
||||
r = 0; goto end;
|
||||
}
|
||||
|
||||
@@ -698,6 +700,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
||||
r = -1; goto end;
|
||||
}
|
||||
lcr_skipped = SWITCH_FALSE;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -719,6 +722,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
||||
r = -1; goto end;
|
||||
}
|
||||
lcr_skipped = SWITCH_FALSE;
|
||||
break;
|
||||
} else if (current->next == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "adding %s to end of list after %s\n",
|
||||
@@ -729,6 +733,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
||||
r = -1; goto end;
|
||||
}
|
||||
lcr_skipped = SWITCH_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -736,8 +741,13 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
||||
|
||||
end:
|
||||
|
||||
/* event is freed in lcr_destroy() switch_event_destroy(&additional->fields); */
|
||||
|
||||
/* lcr was not added to any lists, so destroy lcr object here */
|
||||
if (lcr_skipped == SWITCH_TRUE) {
|
||||
/* ensure we didn't accidentally add additional to the list */
|
||||
switch_assert(additional->prev == NULL && current->next != additional);
|
||||
lcr_destroy(additional);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ static struct {
|
||||
SWITCH_STANDARD_API(mongo_mapreduce_function)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
DBClientConnection *conn = NULL;
|
||||
DBClientBase *conn = NULL;
|
||||
char *ns = NULL, *json_query = NULL;
|
||||
|
||||
ns = strdup(cmd);
|
||||
@@ -88,7 +88,7 @@ SWITCH_STANDARD_API(mongo_find_one_function)
|
||||
|
||||
if (!zstr(ns) && !zstr(json_query) && !zstr(json_fields)) {
|
||||
|
||||
DBClientConnection *conn = NULL;
|
||||
DBClientBase *conn = NULL;
|
||||
|
||||
try {
|
||||
BSONObj query = fromjson(json_query);
|
||||
@@ -124,7 +124,7 @@ static switch_status_t config(void)
|
||||
const char *cf = "mongo.conf";
|
||||
switch_xml_t cfg, xml, settings, param;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
const char *host = "127.0.0.1";
|
||||
const char *conn_str = "127.0.0.1";
|
||||
switch_size_t min_connections = 1, max_connections = 1;
|
||||
|
||||
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
|
||||
@@ -139,7 +139,10 @@ static switch_status_t config(void)
|
||||
int tmp;
|
||||
|
||||
if (!strcmp(var, "host")) {
|
||||
host = val;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "'host' is deprecated. use 'connection-string'\n");
|
||||
conn_str = val;
|
||||
} else if (!strcmp(var, "connection-string")) {
|
||||
conn_str = val;
|
||||
} else if (!strcmp(var, "min-connections")) {
|
||||
if ((tmp = atoi(val)) > 0) {
|
||||
min_connections = tmp;
|
||||
@@ -158,11 +161,11 @@ static switch_status_t config(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (mongo_connection_pool_create(&globals.conn_pool, min_connections, max_connections, host) != SWITCH_STATUS_SUCCESS) {
|
||||
if (mongo_connection_pool_create(&globals.conn_pool, min_connections, max_connections, conn_str) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Can't create connection pool\n");
|
||||
status = SWITCH_STATUS_GENERR;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Mongo connection pool created [%s %d/%d]\n", host, (int)min_connections, (int)max_connections);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Mongo connection pool created [%s %d/%d]\n", conn_str, (int)min_connections, (int)max_connections);
|
||||
}
|
||||
|
||||
switch_xml_free(xml);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef MOD_MONGO_H
|
||||
#define MOD_MONGO_H
|
||||
|
||||
|
||||
#include <client/dbclient.h>
|
||||
#include <client/connpool.h>
|
||||
#include <db/json.h>
|
||||
@@ -10,7 +9,7 @@
|
||||
using namespace mongo;
|
||||
|
||||
typedef struct {
|
||||
char *host;
|
||||
char *conn_str;
|
||||
|
||||
switch_size_t min_connections;
|
||||
switch_size_t max_connections;
|
||||
@@ -22,16 +21,16 @@ typedef struct {
|
||||
} mongo_connection_pool_t;
|
||||
|
||||
|
||||
switch_status_t mongo_connection_create(DBClientConnection **connection, const char *host);
|
||||
void mongo_connection_destroy(DBClientConnection **conn);
|
||||
switch_status_t mongo_connection_create(DBClientBase **connection, const char *conn_str);
|
||||
void mongo_connection_destroy(DBClientBase **conn);
|
||||
|
||||
switch_status_t mongo_connection_pool_create(mongo_connection_pool_t **conn_pool, switch_size_t min_connections, switch_size_t max_connections,
|
||||
const char *host);
|
||||
const char *conn_str);
|
||||
void mongo_connection_pool_destroy(mongo_connection_pool_t **conn_pool);
|
||||
|
||||
|
||||
DBClientConnection *mongo_connection_pool_get(mongo_connection_pool_t *conn_pool);
|
||||
switch_status_t mongo_connection_pool_put(mongo_connection_pool_t *conn_pool, DBClientConnection *conn);
|
||||
DBClientBase *mongo_connection_pool_get(mongo_connection_pool_t *conn_pool);
|
||||
switch_status_t mongo_connection_pool_put(mongo_connection_pool_t *conn_pool, DBClientBase *conn);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,24 +10,31 @@
|
||||
scoped_conn.done();
|
||||
*/
|
||||
|
||||
switch_status_t mongo_connection_create(DBClientConnection **connection, const char *host)
|
||||
switch_status_t mongo_connection_create(DBClientBase **connection, const char *conn_str)
|
||||
{
|
||||
DBClientConnection *conn = new DBClientConnection();
|
||||
DBClientBase *conn = NULL;
|
||||
string conn_string(conn_str), err_msg;
|
||||
ConnectionString cs = ConnectionString::parse(conn_string, err_msg);
|
||||
|
||||
if (!cs.isValid()) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't parse url: %s\n", err_msg.c_str());
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
try {
|
||||
conn->connect(host);
|
||||
conn = cs.connect(err_msg);
|
||||
} catch (DBException &e) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't connect to mongo [%s]\n", host);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't connect to mongo [%s]: %s\n", conn_str, err_msg.c_str());
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
*connection = conn;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected to mongo [%s]\n", host);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected to mongo [%s]\n", conn_str);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void mongo_connection_destroy(DBClientConnection **conn)
|
||||
void mongo_connection_destroy(DBClientBase **conn)
|
||||
{
|
||||
switch_assert(*conn != NULL);
|
||||
delete *conn;
|
||||
@@ -36,12 +43,12 @@ void mongo_connection_destroy(DBClientConnection **conn)
|
||||
}
|
||||
|
||||
switch_status_t mongo_connection_pool_create(mongo_connection_pool_t **conn_pool, switch_size_t min_connections, switch_size_t max_connections,
|
||||
const char *host)
|
||||
const char *conn_str)
|
||||
{
|
||||
switch_memory_pool_t *pool = NULL;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
mongo_connection_pool_t *cpool = NULL;
|
||||
DBClientConnection *conn = NULL;
|
||||
DBClientBase *conn = NULL;
|
||||
|
||||
if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
@@ -61,13 +68,13 @@ switch_status_t mongo_connection_pool_create(mongo_connection_pool_t **conn_pool
|
||||
|
||||
cpool->min_connections = min_connections;
|
||||
cpool->max_connections = max_connections;
|
||||
cpool->host = switch_core_strdup(pool, host);
|
||||
cpool->conn_str = switch_core_strdup(pool, conn_str);
|
||||
|
||||
cpool->pool = pool;
|
||||
|
||||
for (cpool->size = 0; cpool->size < min_connections; cpool->size++) {
|
||||
|
||||
if (mongo_connection_create(&conn, host) == SWITCH_STATUS_SUCCESS) {
|
||||
if (mongo_connection_create(&conn, conn_str) == SWITCH_STATUS_SUCCESS) {
|
||||
mongo_connection_pool_put(cpool, conn);
|
||||
} else {
|
||||
break;
|
||||
@@ -94,7 +101,7 @@ void mongo_connection_pool_destroy(mongo_connection_pool_t **conn_pool)
|
||||
switch_assert(cpool != NULL);
|
||||
|
||||
while (switch_queue_trypop(cpool->connections, &data) == SWITCH_STATUS_SUCCESS) {
|
||||
mongo_connection_destroy((DBClientConnection **)&data);
|
||||
mongo_connection_destroy((DBClientBase **)&data);
|
||||
}
|
||||
|
||||
switch_mutex_destroy(cpool->mutex);
|
||||
@@ -104,9 +111,9 @@ void mongo_connection_pool_destroy(mongo_connection_pool_t **conn_pool)
|
||||
}
|
||||
|
||||
|
||||
DBClientConnection *mongo_connection_pool_get(mongo_connection_pool_t *conn_pool)
|
||||
DBClientBase *mongo_connection_pool_get(mongo_connection_pool_t *conn_pool)
|
||||
{
|
||||
DBClientConnection *conn = NULL;
|
||||
DBClientBase *conn = NULL;
|
||||
void *data = NULL;
|
||||
|
||||
switch_assert(conn_pool != NULL);
|
||||
@@ -114,8 +121,8 @@ DBClientConnection *mongo_connection_pool_get(mongo_connection_pool_t *conn_pool
|
||||
switch_mutex_lock(conn_pool->mutex);
|
||||
|
||||
if (switch_queue_trypop(conn_pool->connections, &data) == SWITCH_STATUS_SUCCESS) {
|
||||
conn = (DBClientConnection *) data;
|
||||
} else if (mongo_connection_create(&conn, conn_pool->host) == SWITCH_STATUS_SUCCESS) {
|
||||
conn = (DBClientBase *) data;
|
||||
} else if (mongo_connection_create(&conn, conn_pool->conn_str) == SWITCH_STATUS_SUCCESS) {
|
||||
if (++conn_pool->size > conn_pool->max_connections) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Connection pool is empty. You may want to increase 'max-connections'\n");
|
||||
}
|
||||
@@ -130,7 +137,7 @@ DBClientConnection *mongo_connection_pool_get(mongo_connection_pool_t *conn_pool
|
||||
return conn;
|
||||
}
|
||||
|
||||
switch_status_t mongo_connection_pool_put(mongo_connection_pool_t *conn_pool, DBClientConnection *conn)
|
||||
switch_status_t mongo_connection_pool_put(mongo_connection_pool_t *conn_pool, DBClientBase *conn)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
|
||||
@@ -0,0 +1,287 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="mod_sms"
|
||||
ProjectGUID="{11C9BC3D-45E9-46E3-BE84-B8CEE4685E39}"
|
||||
RootNamespace="mod_sms"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(SolutionDir)$(PlatformName)\$(ConfigurationName)/mod/$(ProjectName).dll"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(SolutionDir)$(PlatformName)\$(ConfigurationName)/mod/$(ProjectName).dll"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\mod_sms.c"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>mod_sms</ProjectName>
|
||||
<ProjectGuid>{11C9BC3D-45E9-46E3-BE84-B8CEE4685E39}</ProjectGuid>
|
||||
<RootNamespace>mod_sms</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\w32\module_release.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\w32\module_debug.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\w32\module_release.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\w32\module_debug.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="mod_sms.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\w32\Library\FreeSwitchCore.2010.vcxproj">
|
||||
<Project>{202d7a4e-760d-4d0e-afa1-d7459ced30ff}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,508 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* mod_sms.c -- Abstract SMS
|
||||
*
|
||||
*/
|
||||
#include <switch.h>
|
||||
#define SMS_CHAT_PROTO "GLOBAL_SMS"
|
||||
#define MY_EVENT_SEND_MESSAGE "SMS::SEND_MESSAGE"
|
||||
|
||||
/* Prototypes */
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sms_shutdown);
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_sms_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_sms_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_sms, mod_sms_load, mod_sms_shutdown, NULL);
|
||||
|
||||
|
||||
static void event_handler(switch_event_t *event)
|
||||
{
|
||||
const char *dest_proto = switch_event_get_header(event, "dest_proto");
|
||||
switch_core_chat_send(dest_proto, event);
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
BREAK_ON_TRUE,
|
||||
BREAK_ON_FALSE,
|
||||
BREAK_ALWAYS,
|
||||
BREAK_NEVER
|
||||
} break_t;
|
||||
|
||||
|
||||
|
||||
static int parse_exten(switch_event_t *event, switch_xml_t xexten, switch_event_t **extension)
|
||||
{
|
||||
switch_xml_t xcond, xaction, xexpression;
|
||||
char *exten_name = (char *) switch_xml_attr(xexten, "name");
|
||||
int proceed = 0;
|
||||
char *expression_expanded = NULL, *field_expanded = NULL;
|
||||
switch_regex_t *re = NULL;
|
||||
const char *to = switch_event_get_header(event, "to");
|
||||
|
||||
if (!to) {
|
||||
to = "nobody";
|
||||
}
|
||||
|
||||
if (!exten_name) {
|
||||
exten_name = "_anon_";
|
||||
}
|
||||
|
||||
for (xcond = switch_xml_child(xexten, "condition"); xcond; xcond = xcond->next) {
|
||||
char *field = NULL;
|
||||
char *do_break_a = NULL;
|
||||
char *expression = NULL;
|
||||
const char *field_data = NULL;
|
||||
int ovector[30];
|
||||
switch_bool_t anti_action = SWITCH_TRUE;
|
||||
break_t do_break_i = BREAK_ON_FALSE;
|
||||
|
||||
int time_match = switch_xml_std_datetime_check(xcond);
|
||||
|
||||
switch_safe_free(field_expanded);
|
||||
switch_safe_free(expression_expanded);
|
||||
|
||||
if (switch_xml_child(xcond, "condition")) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Nested conditions are not allowed!\n");
|
||||
proceed = 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
field = (char *) switch_xml_attr(xcond, "field");
|
||||
|
||||
if ((xexpression = switch_xml_child(xcond, "expression"))) {
|
||||
expression = switch_str_nil(xexpression->txt);
|
||||
} else {
|
||||
expression = (char *) switch_xml_attr_soft(xcond, "expression");
|
||||
}
|
||||
|
||||
if ((expression_expanded = switch_event_expand_headers(event, expression)) == expression) {
|
||||
expression_expanded = NULL;
|
||||
} else {
|
||||
expression = expression_expanded;
|
||||
}
|
||||
|
||||
if ((do_break_a = (char *) switch_xml_attr(xcond, "break"))) {
|
||||
if (!strcasecmp(do_break_a, "on-true")) {
|
||||
do_break_i = BREAK_ON_TRUE;
|
||||
} else if (!strcasecmp(do_break_a, "on-false")) {
|
||||
do_break_i = BREAK_ON_FALSE;
|
||||
} else if (!strcasecmp(do_break_a, "always")) {
|
||||
do_break_i = BREAK_ALWAYS;
|
||||
} else if (!strcasecmp(do_break_a, "never")) {
|
||||
do_break_i = BREAK_NEVER;
|
||||
} else {
|
||||
do_break_a = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (time_match == 1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
|
||||
"Chatplan: %s Date/Time Match (PASS) [%s] break=%s\n",
|
||||
to, exten_name, do_break_a ? do_break_a : "on-false");
|
||||
anti_action = SWITCH_FALSE;
|
||||
} else if (time_match == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
|
||||
"Chatplan: %s Date/Time Match (FAIL) [%s] break=%s\n",
|
||||
to, exten_name, do_break_a ? do_break_a : "on-false");
|
||||
}
|
||||
|
||||
if (field) {
|
||||
if (strchr(field, '$')) {
|
||||
if ((field_expanded = switch_event_expand_headers(event, field)) == field) {
|
||||
field_expanded = NULL;
|
||||
field_data = field;
|
||||
} else {
|
||||
field_data = field_expanded;
|
||||
}
|
||||
} else {
|
||||
field_data = switch_event_get_header(event, field);
|
||||
}
|
||||
if (!field_data) {
|
||||
field_data = "";
|
||||
}
|
||||
|
||||
if ((proceed = switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
|
||||
"Chatplan: %s Regex (PASS) [%s] %s(%s) =~ /%s/ break=%s\n",
|
||||
to, exten_name, field, field_data, expression, do_break_a ? do_break_a : "on-false");
|
||||
anti_action = SWITCH_FALSE;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
|
||||
"Chatplan: %s Regex (FAIL) [%s] %s(%s) =~ /%s/ break=%s\n",
|
||||
to, exten_name, field, field_data, expression, do_break_a ? do_break_a : "on-false");
|
||||
}
|
||||
} else if (time_match == -1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
|
||||
"Chatplan: %s Absolute Condition [%s]\n", to, exten_name);
|
||||
anti_action = SWITCH_FALSE;
|
||||
}
|
||||
|
||||
if (anti_action) {
|
||||
for (xaction = switch_xml_child(xcond, "anti-action"); xaction; xaction = xaction->next) {
|
||||
const char *application = switch_xml_attr_soft(xaction, "application");
|
||||
const char *loop = switch_xml_attr(xaction, "loop");
|
||||
const char *data;
|
||||
const char *inline_ = switch_xml_attr_soft(xaction, "inline");
|
||||
int xinline = switch_true(inline_);
|
||||
int loop_count = 1;
|
||||
|
||||
if (!zstr(xaction->txt)) {
|
||||
data = xaction->txt;
|
||||
} else {
|
||||
data = (char *) switch_xml_attr_soft(xaction, "data");
|
||||
}
|
||||
|
||||
if (!*extension) {
|
||||
if ((switch_event_create(extension, SWITCH_EVENT_CLONE)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
if (loop) {
|
||||
loop_count = atoi(loop);
|
||||
}
|
||||
|
||||
for (;loop_count > 0; loop_count--) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
|
||||
"Chatplan: %s ANTI-Action %s(%s) %s\n", to, application, data, xinline ? "INLINE" : "");
|
||||
|
||||
if (xinline) {
|
||||
switch_core_execute_chat_app(event, application, data);
|
||||
} else {
|
||||
switch_event_add_header_string(*extension, SWITCH_STACK_BOTTOM, application, zstr(data) ? "__undef" : data);
|
||||
}
|
||||
}
|
||||
proceed = 1;
|
||||
}
|
||||
} else {
|
||||
if (field && strchr(expression, '(')) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "DP_MATCH", NULL);
|
||||
switch_capture_regex(re, proceed, field_data, ovector, "DP_MATCH", switch_regex_set_event_header_callback, event);
|
||||
}
|
||||
|
||||
for (xaction = switch_xml_child(xcond, "action"); xaction; xaction = xaction->next) {
|
||||
char *application = (char *) switch_xml_attr_soft(xaction, "application");
|
||||
const char *loop = switch_xml_attr(xaction, "loop");
|
||||
char *data = NULL;
|
||||
char *substituted = NULL;
|
||||
uint32_t len = 0;
|
||||
char *app_data = NULL;
|
||||
const char *inline_ = switch_xml_attr_soft(xaction, "inline");
|
||||
int xinline = switch_true(inline_);
|
||||
int loop_count = 1;
|
||||
|
||||
if (!zstr(xaction->txt)) {
|
||||
data = xaction->txt;
|
||||
} else {
|
||||
data = (char *) switch_xml_attr_soft(xaction, "data");
|
||||
}
|
||||
|
||||
if (field && strchr(expression, '(')) {
|
||||
len = (uint32_t) (strlen(data) + strlen(field_data) + 10) * proceed;
|
||||
if (!(substituted = malloc(len))) {
|
||||
abort();
|
||||
}
|
||||
memset(substituted, 0, len);
|
||||
switch_perform_substitution(re, proceed, data, field_data, substituted, len, ovector);
|
||||
app_data = substituted;
|
||||
} else {
|
||||
app_data = data;
|
||||
}
|
||||
|
||||
if (!*extension) {
|
||||
if ((switch_event_create(extension, SWITCH_EVENT_CLONE)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
if (loop) {
|
||||
loop_count = atoi(loop);
|
||||
}
|
||||
for (;loop_count > 0; loop_count--) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
|
||||
"Chatplan: %s Action %s(%s) %s\n", to, application, app_data, xinline ? "INLINE" : "");
|
||||
|
||||
if (xinline) {
|
||||
switch_core_execute_chat_app(event, application, app_data);
|
||||
} else {
|
||||
switch_event_add_header_string(*extension, SWITCH_STACK_BOTTOM, application, zstr(data) ? "__undef" : data);
|
||||
}
|
||||
}
|
||||
switch_safe_free(substituted);
|
||||
}
|
||||
}
|
||||
switch_regex_safe_free(re);
|
||||
|
||||
if (((anti_action == SWITCH_FALSE && do_break_i == BREAK_ON_TRUE) ||
|
||||
(anti_action == SWITCH_TRUE && do_break_i == BREAK_ON_FALSE)) || do_break_i == BREAK_ALWAYS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
switch_regex_safe_free(re);
|
||||
switch_safe_free(field_expanded);
|
||||
switch_safe_free(expression_expanded);
|
||||
return proceed;
|
||||
}
|
||||
|
||||
|
||||
static switch_event_t *chatplan_hunt(switch_event_t *event)
|
||||
{
|
||||
switch_event_t *extension = NULL;
|
||||
switch_xml_t alt_root = NULL, cfg, xml = NULL, xcontext, xexten = NULL;
|
||||
const char *alt_path;
|
||||
const char *context;
|
||||
const char *from;
|
||||
const char *to;
|
||||
|
||||
if (!(context = switch_event_get_header(event, "context"))) {
|
||||
context = "default";
|
||||
}
|
||||
|
||||
if (!(from = switch_event_get_header(event, "from_user"))) {
|
||||
from = switch_event_get_header(event, "from");
|
||||
}
|
||||
|
||||
if (!(to = switch_event_get_header(event, "to_user"))) {
|
||||
to = switch_event_get_header(event, "to");
|
||||
}
|
||||
|
||||
alt_path = switch_event_get_header(event, "alt_path");
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Processing text message %s->%s in context %s\n", from, to, context);
|
||||
|
||||
/* get our handle to the "chatplan" section of the config */
|
||||
|
||||
if (!zstr(alt_path)) {
|
||||
switch_xml_t conf = NULL, tag = NULL;
|
||||
if (!(alt_root = switch_xml_parse_file_simple(alt_path))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of [%s] failed\n", alt_path);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((conf = switch_xml_find_child(alt_root, "section", "name", "chatplan")) && (tag = switch_xml_find_child(conf, "chatplan", NULL, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Getting chatplan from alternate path: %s\n", alt_path);
|
||||
xml = alt_root;
|
||||
cfg = tag;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of chatplan failed\n");
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
if (switch_xml_locate("chatplan", NULL, NULL, NULL, &xml, &cfg, event, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of chatplan failed\n");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/* get a handle to the context tag */
|
||||
if (!(xcontext = switch_xml_find_child(cfg, "context", "name", context))) {
|
||||
if (!(xcontext = switch_xml_find_child(cfg, "context", "name", "global"))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Context %s not found\n", context);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
xexten = switch_xml_child(xcontext, "extension");
|
||||
|
||||
while (xexten) {
|
||||
int proceed = 0;
|
||||
const char *cont = switch_xml_attr(xexten, "continue");
|
||||
const char *exten_name = switch_xml_attr(xexten, "name");
|
||||
|
||||
if (!exten_name) {
|
||||
exten_name = "UNKNOWN";
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
|
||||
"Chatplan: %s parsing [%s->%s] continue=%s\n",
|
||||
to, context, exten_name, cont ? cont : "false");
|
||||
|
||||
proceed = parse_exten(event, xexten, &extension);
|
||||
|
||||
if (proceed && !switch_true(cont)) {
|
||||
break;
|
||||
}
|
||||
|
||||
xexten = xexten->next;
|
||||
}
|
||||
|
||||
switch_xml_free(xml);
|
||||
xml = NULL;
|
||||
|
||||
done:
|
||||
switch_xml_free(xml);
|
||||
return extension;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t chat_send(switch_event_t *message_event)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_event_t *exten;
|
||||
|
||||
if ((exten = chatplan_hunt(message_event))) {
|
||||
switch_event_header_t *hp;
|
||||
|
||||
for (hp = exten->headers; hp; hp = hp->next) {
|
||||
status = switch_core_execute_chat_app(message_event, hp->name, hp->value);
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch_event_destroy(&exten);
|
||||
status = SWITCH_STATUS_BREAK;
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_CHAT_APP(stop_function)
|
||||
{
|
||||
switch_set_flag(message, EF_NO_CHAT_EXEC);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_CHAT_APP(send_function)
|
||||
{
|
||||
const char *dest_proto = data;
|
||||
|
||||
if (zstr(dest_proto)) {
|
||||
dest_proto = switch_event_get_header(message, "dest_proto");
|
||||
}
|
||||
|
||||
switch_core_chat_send(dest_proto, message);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_CHAT_APP(set_function)
|
||||
{
|
||||
char *var, *val;
|
||||
|
||||
if (data) {
|
||||
var = strdup(data);
|
||||
if ((val = strchr(var, '='))) {
|
||||
*val++ = '\0';
|
||||
}
|
||||
|
||||
if (zstr(val)) {
|
||||
switch_event_del_header(message, var);
|
||||
} else {
|
||||
switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, var, val);
|
||||
}
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_CHAT_APP(fire_function)
|
||||
{
|
||||
switch_event_t *fireme;
|
||||
|
||||
switch_event_dup(&fireme, message);
|
||||
switch_event_fire(&fireme);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_CHAT_APP(reply_function)
|
||||
{
|
||||
switch_event_t *reply;
|
||||
const char *proto = switch_event_get_header(message, "proto");
|
||||
|
||||
if (proto) {
|
||||
switch_ivr_create_message_reply(&reply, message, SMS_CHAT_PROTO);
|
||||
|
||||
if (!zstr(data)) {
|
||||
switch_event_set_body(reply, data);
|
||||
}
|
||||
|
||||
switch_core_chat_deliver(proto, &reply);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* Macro expands to: switch_status_t mod_sms_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_sms_load)
|
||||
{
|
||||
switch_chat_interface_t *chat_interface;
|
||||
switch_chat_application_interface_t *chat_app_interface;
|
||||
|
||||
|
||||
if (switch_event_bind(modname, SWITCH_EVENT_CUSTOM, MY_EVENT_SEND_MESSAGE, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
SWITCH_ADD_CHAT(chat_interface, SMS_CHAT_PROTO, chat_send);
|
||||
|
||||
SWITCH_ADD_CHAT_APP(chat_app_interface, "reply", "reply to a message", "reply to a message", reply_function, "", SCAF_NONE);
|
||||
SWITCH_ADD_CHAT_APP(chat_app_interface, "stop", "stop execution", "stop execution", stop_function, "", SCAF_NONE);
|
||||
SWITCH_ADD_CHAT_APP(chat_app_interface, "set", "set a variable", "set a variable", set_function, "", SCAF_NONE);
|
||||
SWITCH_ADD_CHAT_APP(chat_app_interface, "send", "send the message as-is", "send the message as-is", send_function, "", SCAF_NONE);
|
||||
SWITCH_ADD_CHAT_APP(chat_app_interface, "fire", "fire the message", "fire the message", fire_function, "", SCAF_NONE);
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
Called when the system shuts down
|
||||
Macro expands to: switch_status_t mod_sms_shutdown() */
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sms_shutdown)
|
||||
{
|
||||
switch_event_unbind_callback(event_handler);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:t
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4
|
||||
*/
|
||||
@@ -12,8 +12,8 @@ SPANDSP_LA=$(SPANDSP_BUILDDIR)/src/libspandsp.la
|
||||
mod_LTLIBRARIES = mod_spandsp.la
|
||||
mod_spandsp_la_SOURCES = mod_spandsp.c udptl.c mod_spandsp_fax.c mod_spandsp_dsp.c mod_spandsp_codecs.c
|
||||
mod_spandsp_la_CFLAGS = $(AM_CFLAGS) -I$(SPANDSP_DIR)/src -I$(TIFF_DIR)/libtiff -I$(SPANDSP_BUILDDIR)/src -I$(TIFF_BUILDDIR)/libtiff -I.
|
||||
mod_spandsp_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(SPANDSP_LA) $(TIFF_LA)
|
||||
mod_spandsp_la_LDFLAGS = -avoid-version -module -no-undefined -shared -ljpeg
|
||||
mod_spandsp_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(SPANDSP_LA) $(TIFF_LA) -ljpeg -lz
|
||||
mod_spandsp_la_LDFLAGS = -avoid-version -module -no-undefined -shared
|
||||
|
||||
$(SPANDSP_LA): $(TIFF_LA) $(SPANDSP_DIR) $(SPANDSP_DIR)/.update
|
||||
cd $(SPANDSP_BUILDDIR) && $(MAKE) -j1
|
||||
|
||||
@@ -52,7 +52,7 @@ static void spandsp_dtmf_rx_realtime_callback(void *user_data, int code, int lev
|
||||
if (digit) {
|
||||
/* prevent duplicate DTMF */
|
||||
if (digit != pvt->last_digit || (pvt->samples - pvt->last_digit_end) > pvt->min_dup_digit_spacing) {
|
||||
switch_dtmf_t dtmf;
|
||||
switch_dtmf_t dtmf = {0};
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "DTMF BEGIN DETECTED: [%c]\n", digit);
|
||||
pvt->last_digit = digit;
|
||||
dtmf.digit = digit;
|
||||
|
||||
@@ -806,7 +806,9 @@ static t38_mode_t negotiate_t38(pvt_t *pvt)
|
||||
switch_channel_set_private(channel, "t38_options", NULL);
|
||||
} else {
|
||||
pvt->t38_mode = T38_MODE_NEGOTIATED;
|
||||
|
||||
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_NEGOTIATED);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38 SDP Origin = %s\n", t38_options->sdp_o_line);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxVersion = %d\n", t38_options->T38FaxVersion);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38MaxBitRate = %d\n", t38_options->T38MaxBitRate);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "T38FaxFillBitRemoval = %d\n", t38_options->T38FaxFillBitRemoval);
|
||||
@@ -827,7 +829,12 @@ static t38_mode_t negotiate_t38(pvt_t *pvt)
|
||||
t38_options->T38FaxVersion = 3;
|
||||
}
|
||||
t38_options->T38MaxBitRate = (pvt->disable_v17) ? 9600 : 14400;
|
||||
t38_options->T38FaxFillBitRemoval = 1;
|
||||
|
||||
/* cisco gets mad when we set this to one in a response where they set it to 0, are we allowed to hardcode this to 1 on responses? */
|
||||
if (!zstr(t38_options->sdp_o_line) && !switch_stristr("cisco", t38_options->sdp_o_line)) {
|
||||
t38_options->T38FaxFillBitRemoval = 1;
|
||||
}
|
||||
|
||||
t38_options->T38FaxTranscodingMMR = 0;
|
||||
t38_options->T38FaxTranscodingJBIG = 0;
|
||||
t38_options->T38FaxRateManagement = "transferredTCF";
|
||||
@@ -1204,6 +1211,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat
|
||||
} else if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) {
|
||||
switch_core_session_message_t msg = { 0 };
|
||||
pvt->t38_mode = T38_MODE_NEGOTIATED;
|
||||
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_NEGOTIATED);
|
||||
spanfax_init(pvt, T38_MODE);
|
||||
configure_t38(pvt);
|
||||
|
||||
@@ -1486,13 +1494,14 @@ static switch_status_t t38_gateway_on_soft_execute(switch_core_session_t *sessio
|
||||
spanfax_init(pvt, T38_GATEWAY_MODE);
|
||||
configure_t38(pvt);
|
||||
pvt->t38_mode = T38_MODE_NEGOTIATED;
|
||||
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_NEGOTIATED);
|
||||
} else {
|
||||
if (negotiate_t38(pvt) != T38_MODE_NEGOTIATED) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Could not negotiate T38\n", switch_channel_get_name(channel));
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
goto end_unlock;
|
||||
}
|
||||
|
||||
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_NEGOTIATED);
|
||||
spanfax_init(pvt, T38_GATEWAY_MODE);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_valet_parking_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_valet_parking, mod_valet_parking_load, NULL, NULL);
|
||||
|
||||
typedef struct {
|
||||
char ext[256];
|
||||
char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||
time_t timeout;
|
||||
} valet_token_t;
|
||||
@@ -47,6 +48,7 @@ typedef struct {
|
||||
switch_hash_t *hash;
|
||||
switch_mutex_t *mutex;
|
||||
switch_memory_pool_t *pool;
|
||||
time_t last_timeout_check;
|
||||
} valet_lot_t;
|
||||
|
||||
static valet_lot_t globals = { 0 };
|
||||
@@ -92,46 +94,61 @@ static void check_timeouts(void)
|
||||
void *val;
|
||||
time_t now;
|
||||
valet_lot_t *lot;
|
||||
switch_console_callback_match_t *matches = NULL;
|
||||
switch_console_callback_match_node_t *m;
|
||||
switch_hash_index_t *i_hi;
|
||||
const void *i_var;
|
||||
void *i_val;
|
||||
char *i_ext;
|
||||
valet_token_t *token;
|
||||
|
||||
now = switch_epoch_time_now(NULL);
|
||||
|
||||
switch_mutex_lock(globals.mutex);
|
||||
if (now - globals.last_timeout_check < 30) {
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
globals.last_timeout_check = now;
|
||||
for (hi = switch_hash_first(NULL, globals.hash); hi; hi = switch_hash_next(hi)) {
|
||||
switch_hash_index_t *i_hi;
|
||||
const void *i_var;
|
||||
void *i_val;
|
||||
char *i_ext;
|
||||
valet_token_t *token;
|
||||
|
||||
switch_hash_this(hi, &var, NULL, &val);
|
||||
lot = (valet_lot_t *) val;
|
||||
|
||||
switch_mutex_lock(lot->mutex);
|
||||
|
||||
top:
|
||||
|
||||
for (i_hi = switch_hash_first(NULL, lot->hash); i_hi; i_hi = switch_hash_next(i_hi)) {
|
||||
switch_hash_this(i_hi, &i_var, NULL, &i_val);
|
||||
i_ext = (char *) i_var;
|
||||
token = (valet_token_t *) i_val;
|
||||
if (token->timeout > 0 && (token->timeout < now || token->timeout == 1)) {
|
||||
switch_core_hash_delete(lot->hash, i_ext);
|
||||
switch_safe_free(token);
|
||||
goto top;
|
||||
}
|
||||
}
|
||||
|
||||
switch_mutex_unlock(lot->mutex);
|
||||
switch_console_push_match(&matches, (const char *) var);
|
||||
}
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
|
||||
|
||||
if (matches) {
|
||||
for (m = matches->head; m; m = m->next) {
|
||||
|
||||
lot = valet_find_lot(m->val);
|
||||
switch_mutex_lock(lot->mutex);
|
||||
|
||||
top:
|
||||
|
||||
for (i_hi = switch_hash_first(NULL, lot->hash); i_hi; i_hi = switch_hash_next(i_hi)) {
|
||||
switch_hash_this(i_hi, &i_var, NULL, &i_val);
|
||||
i_ext = (char *) i_var;
|
||||
token = (valet_token_t *) i_val;
|
||||
if (token->timeout > 0 && (token->timeout < now || token->timeout == 1)) {
|
||||
switch_core_hash_delete(lot->hash, i_ext);
|
||||
switch_safe_free(token);
|
||||
goto top;
|
||||
}
|
||||
}
|
||||
|
||||
switch_mutex_unlock(lot->mutex);
|
||||
}
|
||||
|
||||
switch_console_free_matches(&matches);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int next_id(valet_lot_t *lot, int min, int max, int in)
|
||||
static valet_token_t *next_id(switch_core_session_t *session, valet_lot_t *lot, int min, int max, int in)
|
||||
{
|
||||
int i, r = 0;
|
||||
char buf[128] = "";
|
||||
char buf[256] = "";
|
||||
valet_token_t *token;
|
||||
|
||||
if (!min) {
|
||||
@@ -148,9 +165,20 @@ static int next_id(valet_lot_t *lot, int min, int max, int in)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
token = NULL;
|
||||
|
||||
if (r) {
|
||||
switch_snprintf(buf, sizeof(buf), "%d", r);
|
||||
switch_zmalloc(token, sizeof(*token));
|
||||
switch_set_string(token->uuid, switch_core_session_get_uuid(session));
|
||||
switch_set_string(token->ext, buf);
|
||||
switch_core_hash_insert(lot->hash, buf, token);
|
||||
}
|
||||
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
|
||||
return r;
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
@@ -166,12 +194,13 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
const char *var;
|
||||
valet_token_t *token = NULL;
|
||||
|
||||
|
||||
check_timeouts();
|
||||
|
||||
if ((var = switch_channel_get_variable(channel, "valet_announce_slot"))) {
|
||||
play_announce = switch_true(var);
|
||||
}
|
||||
|
||||
check_timeouts();
|
||||
|
||||
if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))
|
||||
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) {
|
||||
char *lot_name = argv[0];
|
||||
@@ -192,7 +221,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
const char *io = argv[2];
|
||||
const char *min = argv[3];
|
||||
const char *max = argv[4];
|
||||
int min_i, max_i, id, in = -1;
|
||||
int min_i, max_i, in = -1;
|
||||
|
||||
if (argc < 5) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", VALET_APP_SYNTAX);
|
||||
@@ -217,13 +246,13 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
min_i = atoi(min);
|
||||
max_i = atoi(max);
|
||||
|
||||
if (!(id = next_id(lot, min_i, max_i, in))) {
|
||||
if (!(token = next_id(session, lot, min_i, max_i, in))) {
|
||||
switch_ivr_phrase_macro(session, in ? "valet_lot_full" : "valet_lot_empty", "", NULL, NULL);
|
||||
switch_mutex_unlock(lot->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
switch_snprintf(dtmf_buf, sizeof(dtmf_buf), "%d", id);
|
||||
switch_snprintf(dtmf_buf, sizeof(dtmf_buf), "%s", token->ext);
|
||||
ext = dtmf_buf;
|
||||
} else if (!strcasecmp(ext, "ask")) {
|
||||
const char *prompt = "ivr/ivr-enter_ext_pound.wav";
|
||||
@@ -269,60 +298,63 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
}
|
||||
}
|
||||
|
||||
switch_mutex_lock(lot->mutex);
|
||||
if ((token = (valet_token_t *) switch_core_hash_find(lot->hash, ext))) {
|
||||
switch_core_session_t *b_session;
|
||||
if (!token) {
|
||||
switch_mutex_lock(lot->mutex);
|
||||
if ((token = (valet_token_t *) switch_core_hash_find(lot->hash, ext))) {
|
||||
switch_core_session_t *b_session;
|
||||
|
||||
if (token->timeout) {
|
||||
const char *var = switch_channel_get_variable(channel, "valet_ticket");
|
||||
if (token->timeout) {
|
||||
const char *var = switch_channel_get_variable(channel, "valet_ticket");
|
||||
|
||||
if (!zstr(var)) {
|
||||
if (!strcmp(var, token->uuid)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Valet ticket %s accepted.\n", var);
|
||||
if (!zstr(var)) {
|
||||
if (!strcmp(var, token->uuid)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Valet ticket %s accepted.\n", var);
|
||||
token->timeout = 0;
|
||||
switch_channel_set_variable(channel, "valet_ticket", NULL);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid token %s\n", token->uuid);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!zstr(token->uuid) && (b_session = switch_core_session_locate(token->uuid))) {
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, VALET_EVENT) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Valet-Lot-Name", lot_name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Valet-Extension", ext);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "bridge");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-To-UUID", switch_core_session_get_uuid(session));
|
||||
switch_channel_event_set_data(switch_core_session_get_channel(b_session), event);
|
||||
switch_event_fire(&event);
|
||||
switch_core_session_rwunlock(b_session);
|
||||
token->timeout = 0;
|
||||
switch_channel_set_variable(channel, "valet_ticket", NULL);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid token %s\n", token->uuid);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), token->uuid);
|
||||
switch_mutex_unlock(lot->mutex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!zstr(token->uuid) && (b_session = switch_core_session_locate(token->uuid))) {
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, VALET_EVENT) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Valet-Lot-Name", lot_name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Valet-Extension", ext);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "bridge");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-To-UUID", switch_core_session_get_uuid(session));
|
||||
switch_channel_event_set_data(switch_core_session_get_channel(b_session), event);
|
||||
switch_event_fire(&event);
|
||||
switch_core_session_rwunlock(b_session);
|
||||
token->timeout = 0;
|
||||
switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), token->uuid);
|
||||
switch_mutex_unlock(lot->mutex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
token = NULL;
|
||||
|
||||
switch_zmalloc(token, sizeof(*token));
|
||||
switch_set_string(token->uuid, switch_core_session_get_uuid(session));
|
||||
switch_core_hash_insert(lot->hash, ext, token);
|
||||
}
|
||||
|
||||
|
||||
token = NULL;
|
||||
|
||||
if (!(tmp = switch_channel_get_variable(channel, "valet_hold_music"))) {
|
||||
tmp = switch_channel_get_hold_music(channel);
|
||||
}
|
||||
if (tmp)
|
||||
|
||||
if (tmp) {
|
||||
music = tmp;
|
||||
}
|
||||
|
||||
if (!strcasecmp(music, "silence")) {
|
||||
music = "silence_stream://-1";
|
||||
}
|
||||
|
||||
switch_zmalloc(token, sizeof(*token));
|
||||
switch_set_string(token->uuid, switch_core_session_get_uuid(session));
|
||||
switch_core_hash_insert(lot->hash, ext, token);
|
||||
|
||||
|
||||
dest = switch_core_session_sprintf(session, "set:valet_ticket=%s,set:valet_hold_music=%s,sleep:1000,valet_park:%s %s",
|
||||
token->uuid, music, lot_name, ext);
|
||||
switch_channel_set_variable(channel, "inline_destination", dest);
|
||||
@@ -337,6 +369,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
if ((b_session = switch_core_session_locate(uuid))) {
|
||||
token->timeout = switch_epoch_time_now(NULL) + 10;
|
||||
if (play_announce) {
|
||||
switch_ivr_sleep(session, 1500, SWITCH_TRUE, NULL);
|
||||
switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL);
|
||||
}
|
||||
switch_ivr_session_transfer(b_session, dest, "inline", NULL);
|
||||
@@ -348,6 +381,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
}
|
||||
|
||||
if (play_announce) {
|
||||
switch_ivr_sleep(session, 1500, SWITCH_TRUE, NULL);
|
||||
switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL);
|
||||
}
|
||||
}
|
||||
@@ -452,6 +486,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_valet_parking_load)
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
|
||||
globals.pool = pool;
|
||||
switch_core_hash_init(&globals.hash, NULL);
|
||||
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
|
||||
|
||||
@@ -853,6 +853,7 @@ struct call_control {
|
||||
switch_file_handle_t *fh;
|
||||
char buf[4];
|
||||
int noexit;
|
||||
int playback_controls_active;
|
||||
};
|
||||
typedef struct call_control cc_t;
|
||||
|
||||
@@ -871,7 +872,13 @@ static switch_status_t control_playback(switch_core_session_t *session, void *in
|
||||
|| dtmf->digit == *cc->profile->prev_msg_key || dtmf->digit == *cc->profile->next_msg_key
|
||||
|| dtmf->digit == *cc->profile->repeat_msg_key
|
||||
|| dtmf->digit == *cc->profile->terminator_key || dtmf->digit == *cc->profile->skip_info_key
|
||||
|| dtmf->digit == *cc->profile->email_key || dtmf->digit == *cc->profile->forward_key)) {
|
||||
|| dtmf->digit == *cc->profile->forward_key)) {
|
||||
*cc->buf = dtmf->digit;
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
|
||||
if (!cc->playback_controls_active
|
||||
&& (dtmf->digit == *cc->profile->email_key)) {
|
||||
*cc->buf = dtmf->digit;
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
@@ -907,10 +914,6 @@ static switch_status_t control_playback(switch_core_session_t *session, void *in
|
||||
switch_core_file_seek(fh, &pos, samps, SEEK_CUR);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
if (!cc->noexit && dtmf->digit == *cc->profile->terminator_key) {
|
||||
*cc->buf = dtmf->digit;
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -1535,6 +1538,9 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t
|
||||
msg.from = __FILE__;
|
||||
msg.string_arg = cid_buf;
|
||||
msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sending display update [%s] to %s\n",
|
||||
cid_buf, switch_channel_get_name(channel));
|
||||
switch_core_session_receive_message(session, &msg);
|
||||
|
||||
if (!zstr(cbt->cid_number) && (vm_announce_cid = switch_channel_get_variable(channel, "vm_announce_cid"))) {
|
||||
@@ -1568,11 +1574,11 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t
|
||||
*cc.buf = '\0';
|
||||
memset(&fh, 0, sizeof(fh));
|
||||
cc.fh = &fh;
|
||||
cc.noexit = 1;
|
||||
cc.playback_controls_active = 1;
|
||||
if (switch_file_exists(cbt->file_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
TRY_CODE(switch_ivr_play_file(session, &fh, cbt->file_path, &args));
|
||||
}
|
||||
cc.noexit = 0;
|
||||
cc.playback_controls_active = 0;
|
||||
}
|
||||
|
||||
if (!*cc.buf && (profile->play_date_announcement == VM_DATE_LAST)) {
|
||||
@@ -2010,10 +2016,10 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
|
||||
"username='%s' and domain='%s' and flags='save'",
|
||||
(long) switch_epoch_time_now(NULL), myid, domain_name);
|
||||
vm_execute_sql(profile, sql, profile->mutex);
|
||||
switch_snprintf(sql, sizeof(sql), "select file_path from voicemail_msgs where username='%s' and domain='%s' and flags='delete'", myid,
|
||||
switch_snprintfv(sql, sizeof(sql), "select file_path from voicemail_msgs where username='%q' and domain='%q' and flags='delete'", myid,
|
||||
domain_name);
|
||||
vm_execute_sql_callback(profile, profile->mutex, sql, unlink_callback, NULL);
|
||||
switch_snprintf(sql, sizeof(sql), "delete from voicemail_msgs where username='%s' and domain='%s' and flags='delete'", myid, domain_name);
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from voicemail_msgs where username='%q' and domain='%q' and flags='delete'", myid, domain_name);
|
||||
vm_execute_sql(profile, sql, profile->mutex);
|
||||
vm_check_state = VM_CHECK_FOLDER_SUMMARY;
|
||||
|
||||
@@ -2299,7 +2305,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
|
||||
}
|
||||
|
||||
thepass = thehash = NULL;
|
||||
switch_snprintf(sql, sizeof(sql), "select * from voicemail_prefs where username='%s' and domain='%s'", myid, domain_name);
|
||||
switch_snprintfv(sql, sizeof(sql), "select * from voicemail_prefs where username='%q' and domain='%q'", myid, domain_name);
|
||||
vm_execute_sql_callback(profile, profile->mutex, sql, prefs_callback, &cbt);
|
||||
|
||||
x_params = switch_xml_child(x_user, "variables");
|
||||
@@ -2773,6 +2779,10 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
|
||||
|
||||
|
||||
if (send_notify) {
|
||||
if (zstr(vm_notify_email)) {
|
||||
vm_notify_email = vm_email;
|
||||
}
|
||||
|
||||
if (zstr(profile->notify_email_headers)) {
|
||||
headers = switch_mprintf("From: FreeSWITCH mod_voicemail <%s@%s>\n"
|
||||
"Subject: Voicemail from %s %s\nX-Priority: %d", myid, domain_name, caller_id_name, caller_id_number, priority);
|
||||
@@ -2841,7 +2851,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
|
||||
|
||||
failed:
|
||||
|
||||
if (del_file && file_path) {
|
||||
if (del_file && file_path && switch_file_exists(file_path, pool)) {
|
||||
if (unlink(file_path) != 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to delete file [%s]\n", file_path);
|
||||
}
|
||||
@@ -3215,7 +3225,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
|
||||
goto end;
|
||||
}
|
||||
|
||||
switch_snprintf(sql, sizeof(sql), "select * from voicemail_prefs where username='%s' and domain='%s'", id, domain_name);
|
||||
switch_snprintfv(sql, sizeof(sql), "select * from voicemail_prefs where username='%q' and domain='%q'", id, domain_name);
|
||||
vm_execute_sql_callback(profile, profile->mutex, sql, prefs_callback, &cbt);
|
||||
|
||||
if (!vm_ext) {
|
||||
@@ -3317,7 +3327,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
|
||||
callback.buf = disk_usage;
|
||||
callback.len = sizeof(disk_usage);
|
||||
|
||||
switch_snprintf(sqlstmt, sizeof(sqlstmt), "select sum(message_len) from voicemail_msgs where username='%s' and domain='%s'", id, domain_name);
|
||||
switch_snprintfv(sqlstmt, sizeof(sqlstmt), "select sum(message_len) from voicemail_msgs where username='%q' and domain='%q'", id, domain_name);
|
||||
vm_execute_sql_callback(profile, profile->mutex, sqlstmt, sql2str_callback, &callback);
|
||||
|
||||
if (atoi(disk_usage) >= disk_quota) {
|
||||
@@ -3623,7 +3633,7 @@ SWITCH_STANDARD_API(prefs_api_function)
|
||||
|
||||
}
|
||||
|
||||
switch_snprintf(sql, sizeof(sql), "select * from voicemail_prefs where username='%s' and domain='%s'", id, domain);
|
||||
switch_snprintfv(sql, sizeof(sql), "select * from voicemail_prefs where username='%q' and domain='%q'", id, domain);
|
||||
vm_execute_sql_callback(profile, profile->mutex, sql, prefs_callback, &cbt);
|
||||
|
||||
if (!strcasecmp(how, "greeting_path")) {
|
||||
|
||||
@@ -489,11 +489,21 @@ static void pres_event_handler(switch_event_t *event)
|
||||
switch_safe_free(sql);
|
||||
}
|
||||
|
||||
static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject,
|
||||
const char *body, const char *type, const char *hint)
|
||||
static switch_status_t chat_send(switch_event_t *message_event)
|
||||
{
|
||||
char *user, *host, *f_user = NULL, *ffrom = NULL, *f_host = NULL, *f_resource = NULL;
|
||||
mdl_profile_t *profile = NULL;
|
||||
const char *proto;
|
||||
const char *from;
|
||||
const char *to;
|
||||
const char *body;
|
||||
const char *hint;
|
||||
|
||||
proto = switch_event_get_header(message_event, "proto");
|
||||
from = switch_event_get_header(message_event, "from");
|
||||
to = switch_event_get_header(message_event, "to");
|
||||
body = switch_event_get_body(message_event);
|
||||
hint = switch_event_get_header(message_event, "hint");
|
||||
|
||||
switch_assert(proto != NULL);
|
||||
|
||||
@@ -2876,6 +2886,8 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||
char *proto = MDL_CHAT_PROTO;
|
||||
char *pproto = NULL, *ffrom = NULL;
|
||||
char *hint;
|
||||
switch_event_t *event;
|
||||
char *from_user, *from_host;
|
||||
#ifdef AUTO_REPLY
|
||||
if (profile->auto_reply) {
|
||||
ldl_handle_send_msg(handle,
|
||||
@@ -2902,10 +2914,41 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||
from = ffrom;
|
||||
}
|
||||
|
||||
if (strcasecmp(proto, MDL_CHAT_PROTO)) { /* yes no ! on purpose */
|
||||
switch_core_chat_send(proto, MDL_CHAT_PROTO, from, to, subject, switch_str_nil(msg), NULL, hint);
|
||||
from_user = strdup(from);
|
||||
if ((from_host = strchr(from_user, '@'))) {
|
||||
*from_host++ = '\0';
|
||||
}
|
||||
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", from);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", from_user);
|
||||
if (from_host) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", from_host);
|
||||
}
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", to);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", subject);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "text/plain");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", hint);
|
||||
|
||||
if (msg) {
|
||||
switch_event_add_body(event, "%s", msg);
|
||||
}
|
||||
} else {
|
||||
abort();
|
||||
}
|
||||
|
||||
switch_safe_free(from_user);
|
||||
|
||||
if (strcasecmp(proto, MDL_CHAT_PROTO)) { /* yes no ! on purpose */
|
||||
switch_core_chat_send(proto, event);
|
||||
}
|
||||
|
||||
switch_core_chat_send("GLOBAL", event);
|
||||
|
||||
switch_event_destroy(&event);
|
||||
|
||||
switch_safe_free(pproto);
|
||||
switch_safe_free(ffrom);
|
||||
}
|
||||
|
||||
@@ -928,7 +928,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
while (p && *p) {
|
||||
switch_dtmf_t dtmf;
|
||||
switch_dtmf_t dtmf = {0};
|
||||
dtmf.digit = *p;
|
||||
dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
|
||||
switch_channel_queue_dtmf(channel, &dtmf);
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
moves the switch_rtp_request_port() call from the contructor to FSH323Connection::CreateRealTimeLogicalChannel() - fix
|
||||
rtp port leak. tnx to Peter Olsson.
|
||||
fix log printing
|
||||
fix small interoperability issues if remote endpoint send progress twice
|
||||
make sure dtmfinband gets initialized
|
||||
make gk-identifier and gk-interface settings optional (documentation sayed that about gk-identifier already)
|
||||
|
||||
@@ -413,7 +413,7 @@ bool FSH323EndPoint::Initialise(switch_loadable_module_interface_t *iface)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (m_fax_old_asn) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "--->fax_old_asn\n");
|
||||
SetT38_IFP_PRE();
|
||||
@@ -714,6 +714,7 @@ FSH323Connection::FSH323Connection(FSH323EndPoint& endpoint, H323Transport* tran
|
||||
, m_rtp_resetting(0)
|
||||
, m_isRequst_fax(false)
|
||||
, m_channel_hangup(false)
|
||||
, m_RTPlocalPort(0)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::FSH323Connection [%p]\n",this);
|
||||
|
||||
@@ -739,8 +740,6 @@ FSH323Connection::FSH323Connection(FSH323EndPoint& endpoint, H323Transport* tran
|
||||
|
||||
switch_channel_set_state(m_fsChannel, CS_INIT);
|
||||
}
|
||||
|
||||
m_RTPlocalPort = switch_rtp_request_port((const char *)m_RTPlocalIP.AsString());
|
||||
}
|
||||
|
||||
FSH323Connection::~FSH323Connection()
|
||||
@@ -974,6 +973,9 @@ H323Channel* FSH323Connection::CreateRealTimeLogicalChannel(const H323Capability
|
||||
|
||||
H323TransportAddress m_h323transportadd = GetSignallingChannel()->GetLocalAddress();
|
||||
m_h323transportadd.GetIpAddress(m_RTPlocalIP);
|
||||
if (!m_RTPlocalPort) {
|
||||
m_RTPlocalPort = switch_rtp_request_port((const char *)m_RTPlocalIP.AsString());
|
||||
}
|
||||
|
||||
return new FSH323_ExternalRTPChannel(*this, capability, dir, sessionID,m_RTPlocalIP,m_RTPlocalPort);
|
||||
}
|
||||
@@ -2044,7 +2046,7 @@ PBoolean FSH323_ExternalRTPChannel::Start()
|
||||
, GetMainTypes[m_capability->GetMainType()],(const char*)(m_capability->GetFormatName()),this);
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"%s initialise %s codec %s for connection [%p]\n",switch_channel_get_name(m_fsChannel),((GetDirection() == IsReceiver)? " read" : " write")
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"%s Unsupported ptime of %u on %s %s codec %s for connection [%p]\n",switch_channel_get_name(m_fsChannel),((GetDirection() == IsReceiver)? " read" : " write")
|
||||
, GetMainTypes[m_capability->GetMainType()],(const char*)(m_capability->GetFormatName()),this);
|
||||
|
||||
if (GetDirection() == IsReceiver) {
|
||||
|
||||
@@ -188,9 +188,14 @@ switch_status_t rtmp_check_auth(rtmp_session_t *rsession, const char *user, cons
|
||||
switch_xml_t xml = NULL, x_param, x_params;
|
||||
switch_bool_t allow_empty_password = SWITCH_FALSE;
|
||||
const char *passwd = NULL;
|
||||
switch_event_t *locate_params;
|
||||
|
||||
switch_event_create(&locate_params, SWITCH_EVENT_GENERAL);
|
||||
switch_assert(locate_params);
|
||||
switch_event_add_header_string(locate_params, SWITCH_STACK_BOTTOM, "source", "mod_rtmp");
|
||||
|
||||
/* Locate user */
|
||||
if (switch_xml_locate_user_merged("id", user, domain, NULL, &xml, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_xml_locate_user_merged("id", user, domain, NULL, &xml, locate_params) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(rsession->uuid), SWITCH_LOG_WARNING, "Authentication failed. No such user %s@%s\n", user, domain);
|
||||
goto done;
|
||||
}
|
||||
@@ -231,6 +236,9 @@ done:
|
||||
if (xml) {
|
||||
switch_xml_free(xml);
|
||||
}
|
||||
|
||||
switch_event_destroy(&locate_params);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#include "skypopen.h"
|
||||
#define MDL_CHAT_PROTO "skype"
|
||||
#define SKYPE_CHAT_PROTO "skype"
|
||||
|
||||
#ifdef WIN32
|
||||
/***************/
|
||||
@@ -943,7 +943,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
if(channel){
|
||||
|
||||
while (p && *p) {
|
||||
switch_dtmf_t dtmf;
|
||||
switch_dtmf_t dtmf = {0};
|
||||
dtmf.digit = *p;
|
||||
dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
|
||||
switch_channel_queue_dtmf(channel, &dtmf);
|
||||
@@ -1858,17 +1858,35 @@ static switch_status_t load_config(int reload_type)
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject, const char *body, const char *type,
|
||||
const char *hint)
|
||||
static switch_status_t chat_send(switch_event_t *message_event)
|
||||
|
||||
{
|
||||
char *user = NULL, *host, *f_user = NULL, *f_host = NULL, *f_resource = NULL;
|
||||
private_t *tech_pvt = NULL;
|
||||
int i = 0, found = 0, tried = 0;
|
||||
char skype_msg[1024];
|
||||
|
||||
const char *proto;
|
||||
const char *from;
|
||||
const char *to;
|
||||
const char *subject;
|
||||
const char *body;
|
||||
//const char *type;
|
||||
const char *hint;
|
||||
|
||||
proto = switch_event_get_header(message_event, "proto");
|
||||
from = switch_event_get_header(message_event, "from");
|
||||
to = switch_event_get_header(message_event, "to");
|
||||
subject = switch_event_get_header(message_event, "subject");
|
||||
body = switch_event_get_body(message_event);
|
||||
//type = switch_event_get_header(message_event, "type");
|
||||
hint = switch_event_get_header(message_event, "hint");
|
||||
|
||||
switch_assert(proto != NULL);
|
||||
|
||||
DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, type,
|
||||
//DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, type,
|
||||
// hint ? hint : "NULL");
|
||||
DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body,
|
||||
hint ? hint : "NULL");
|
||||
|
||||
if (!to || !strlen(to)) {
|
||||
@@ -1895,7 +1913,9 @@ static switch_status_t chat_send(const char *proto, const char *from, const char
|
||||
*host++ = '\0';
|
||||
}
|
||||
|
||||
DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, type,
|
||||
//DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, type,
|
||||
// hint ? hint : "NULL");
|
||||
DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body,
|
||||
hint ? hint : "NULL");
|
||||
if (hint && strlen(hint)) {
|
||||
//in hint we receive the interface name to use
|
||||
@@ -1998,7 +2018,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypopen_load)
|
||||
SWITCH_ADD_API(commands_api_interface, "skypopen", "Skypopen interface commands", skypopen_function, SKYPOPEN_SYNTAX);
|
||||
SWITCH_ADD_API(commands_api_interface, "skypopen_chat", "Skypopen_chat interface remote_skypename TEXT", skypopen_chat_function,
|
||||
SKYPOPEN_CHAT_SYNTAX);
|
||||
SWITCH_ADD_CHAT(chat_interface, MDL_CHAT_PROTO, chat_send);
|
||||
SWITCH_ADD_CHAT(chat_interface, SKYPE_CHAT_PROTO, chat_send);
|
||||
|
||||
if (switch_event_reserve_subclass(MY_EVENT_INCOMING_CHATMESSAGE) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!\n");
|
||||
@@ -2944,7 +2964,7 @@ int incoming_chatmessage(private_t *tech_pvt, int which)
|
||||
session = switch_core_session_locate(tech_pvt->session_uuid_str);
|
||||
}
|
||||
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SKYPE_CHAT_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", tech_pvt->name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->chatmessages[which].from_dispname);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->chatmessages[which].from_handle);
|
||||
@@ -2971,7 +2991,7 @@ int incoming_chatmessage(private_t *tech_pvt, int which)
|
||||
if (!event_sent_to_esl) {
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SKYPE_CHAT_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", tech_pvt->name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->chatmessages[which].from_dispname);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->chatmessages[which].from_handle);
|
||||
@@ -2997,6 +3017,33 @@ int incoming_chatmessage(private_t *tech_pvt, int which)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static switch_status_t compat_chat_send(const char *proto, const char *from, const char *to,
|
||||
const char *subject, const char *body, const char *type, const char *hint)
|
||||
{
|
||||
switch_event_t *message_event;
|
||||
switch_status_t status;
|
||||
|
||||
if (switch_event_create(&message_event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "proto", proto);
|
||||
switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "from", from);
|
||||
switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "to", to);
|
||||
switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "subject", subject);
|
||||
switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "type", type);
|
||||
switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "hint", hint);
|
||||
|
||||
if (body) {
|
||||
switch_event_add_body(message_event, "%s", body);
|
||||
}
|
||||
} else {
|
||||
abort();
|
||||
}
|
||||
|
||||
status = chat_send(message_event);
|
||||
switch_event_destroy(&message_event);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(skypopen_chat_function)
|
||||
{
|
||||
@@ -3037,11 +3084,11 @@ SWITCH_STANDARD_API(skypopen_chat_function)
|
||||
goto end;
|
||||
} else {
|
||||
|
||||
NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", SKYPOPEN_P_LOG, MDL_CHAT_PROTO, tech_pvt->skype_user,
|
||||
NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", SKYPOPEN_P_LOG, SKYPE_CHAT_PROTO, tech_pvt->skype_user,
|
||||
argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), tech_pvt->name);
|
||||
|
||||
chat_send(MDL_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE",
|
||||
switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, tech_pvt->name);
|
||||
compat_chat_send(SKYPE_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE",
|
||||
switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, tech_pvt->name);
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -282,6 +282,8 @@ char *generate_pai_str(private_object_t *tech_pvt)
|
||||
header = (tech_pvt->cid_type == CID_TYPE_RPID && !switch_stristr("aastra", ua)) ? "Remote-Party-ID" : "P-Asserted-Identity";
|
||||
|
||||
if (!zstr(callee_name) && !zstr(callee_number)) {
|
||||
check_decode(callee_name, tech_pvt->session);
|
||||
|
||||
if (switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote)) {
|
||||
pai = switch_core_session_sprintf(tech_pvt->session, "%s: \"%s\" <%s>%s\n"
|
||||
"X-FS-Display-Name: %s\nX-FS-Display-Number: %s\n",
|
||||
@@ -1981,12 +1983,15 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
char message[256] = "";
|
||||
const char *ua = switch_channel_get_variable(tech_pvt->channel, "sip_user_agent");
|
||||
switch_event_t *event;
|
||||
|
||||
|
||||
if (zstr(number)) {
|
||||
number = tech_pvt->caller_profile->destination_number;
|
||||
}
|
||||
|
||||
if (!sofia_test_flag(tech_pvt, TFLAG_UPDATING_DISPLAY)) {
|
||||
if (sofia_test_flag(tech_pvt, TFLAG_UPDATING_DISPLAY)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR,
|
||||
"Cannot send display update to %s Did not receive reply to last update\n", switch_channel_get_name(tech_pvt->channel));
|
||||
} else {
|
||||
if (zstr(tech_pvt->last_sent_callee_id_name) || strcmp(tech_pvt->last_sent_callee_id_name, name) ||
|
||||
zstr(tech_pvt->last_sent_callee_id_number) || strcmp(tech_pvt->last_sent_callee_id_number, number)) {
|
||||
|
||||
@@ -2047,7 +2052,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
switch_channel_set_variable(channel, "last_sent_callee_id_name", name);
|
||||
switch_channel_set_variable(channel, "last_sent_callee_id_number", number);
|
||||
|
||||
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
|
||||
const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "SEND");
|
||||
@@ -3616,12 +3621,12 @@ SWITCH_STANDARD_API(sofia_count_reg_function)
|
||||
if (zstr(user)) {
|
||||
sql = switch_mprintf("select count(*) "
|
||||
"from sip_registrations where (sip_host='%q' or presence_hosts like '%%%q%%')",
|
||||
(concat != NULL) ? concat : "", domain, domain);
|
||||
domain, domain);
|
||||
|
||||
} else {
|
||||
sql = switch_mprintf("select count(*) "
|
||||
"from sip_registrations where (sip_user='%q' or dir_user='%q') and (sip_host='%q' or presence_hosts like '%%%q%%')",
|
||||
(concat != NULL) ? concat : "", user, user, domain, domain);
|
||||
"from sip_registrations where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')",
|
||||
user, domain, domain);
|
||||
}
|
||||
switch_assert(sql);
|
||||
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sql2str_callback, &cb);
|
||||
|
||||
@@ -98,6 +98,7 @@ typedef struct private_object private_object_t;
|
||||
#define SOFIA_SIP_RESPONSE_HEADER_PREFIX "sip_rh_"
|
||||
#define SOFIA_SIP_RESPONSE_HEADER_PREFIX_T "~sip_rh_"
|
||||
#define SOFIA_SIP_BYE_HEADER_PREFIX "sip_bye_h_"
|
||||
#define SOFIA_SIP_BYE_HEADER_PREFIX_T "~sip_bye_h_"
|
||||
#define SOFIA_SIP_PROGRESS_HEADER_PREFIX "sip_ph_"
|
||||
#define SOFIA_SIP_PROGRESS_HEADER_PREFIX_T "~sip_ph_"
|
||||
#define SOFIA_SIP_HEADER_PREFIX_T "~sip_h_"
|
||||
@@ -251,6 +252,7 @@ typedef enum {
|
||||
PFLAG_LIBERAL_DTMF,
|
||||
PFLAG_AUTO_ASSIGN_PORT,
|
||||
PFLAG_AUTO_ASSIGN_TLS_PORT,
|
||||
PFLAG_SHUTDOWN,
|
||||
/* No new flags below this line */
|
||||
PFLAG_MAX
|
||||
} PFLAGS;
|
||||
@@ -871,8 +873,8 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
||||
|
||||
void launch_sofia_profile_thread(sofia_profile_t *profile);
|
||||
|
||||
switch_status_t sofia_presence_chat_send(const char *proto, const char *from, const char *to, const char *subject,
|
||||
const char *body, const char *type, const char *hint);
|
||||
switch_status_t sofia_presence_chat_send(switch_event_t *message_event);
|
||||
|
||||
void sofia_glue_tech_absorb_sdp(private_object_t *tech_pvt);
|
||||
|
||||
/*
|
||||
|
||||
@@ -506,6 +506,7 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
|
||||
private_object_t *tech_pvt;
|
||||
char *extra_headers;
|
||||
const char *call_info = NULL;
|
||||
const char *vval = NULL;
|
||||
#ifdef MANUAL_BYE
|
||||
int cause;
|
||||
char st[80] = "";
|
||||
@@ -557,6 +558,18 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
|
||||
extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_BYE_HEADER_PREFIX);
|
||||
sofia_glue_set_extra_headers(channel, sip, SOFIA_SIP_BYE_HEADER_PREFIX);
|
||||
|
||||
if (!(vval = switch_channel_get_variable(channel, "sip_copy_custom_headers")) || switch_true(vval)) {
|
||||
switch_core_session_t *nsession = NULL;
|
||||
|
||||
switch_core_session_get_partner(session, &nsession);
|
||||
|
||||
if (nsession) {
|
||||
switch_ivr_transfer_variable(session, nsession, SOFIA_SIP_BYE_HEADER_PREFIX_T);
|
||||
switch_core_session_rwunlock(nsession);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_channel_hangup(channel, cause);
|
||||
nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS_MSG(de->data->e_msg),
|
||||
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
|
||||
@@ -682,6 +695,7 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
|
||||
|
||||
if ((val = sofia_glue_get_unknown_header(sip, "X-FS-Display-Name"))) {
|
||||
name = (char *) val;
|
||||
check_decode(name, session);
|
||||
fs++;
|
||||
}
|
||||
|
||||
@@ -959,6 +973,7 @@ static void our_sofia_event_callback(nua_event_t event,
|
||||
break;
|
||||
case nua_r_shutdown:
|
||||
if (status >= 200) {
|
||||
sofia_set_pflag(profile, PFLAG_SHUTDOWN);
|
||||
su_root_break(profile->s_root);
|
||||
}
|
||||
break;
|
||||
@@ -1955,9 +1970,17 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
||||
switch_thread_rwlock_wrlock(profile->rwlock);
|
||||
sofia_reg_unregister(profile);
|
||||
nua_shutdown(profile->nua);
|
||||
su_root_run(profile->s_root);
|
||||
|
||||
sanity = 10;
|
||||
while (!sofia_test_pflag(profile, PFLAG_SHUTDOWN)) {
|
||||
su_root_step(profile->s_root, 1000);
|
||||
if (!--sanity) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sofia_clear_pflag_locked(profile, PFLAG_RUNNING);
|
||||
sofia_clear_pflag_locked(profile, PFLAG_SHUTDOWN);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Waiting for worker thread\n");
|
||||
|
||||
switch_thread_join(&st, worker_thread);
|
||||
@@ -2197,7 +2220,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
|
||||
}
|
||||
|
||||
switch_mutex_lock(mod_sofia_globals.hash_mutex);
|
||||
if ((gp = switch_core_hash_find(mod_sofia_globals.gateway_hash, name)) && (gp = switch_core_hash_find(mod_sofia_globals.gateway_hash, pkey))) {
|
||||
if ((gp = switch_core_hash_find(mod_sofia_globals.gateway_hash, name)) && (gp = switch_core_hash_find(mod_sofia_globals.gateway_hash, pkey)) && !gp->deleted) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate gateway '%s'\n", name);
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
free(pkey);
|
||||
@@ -2561,7 +2584,7 @@ static void parse_domain_tag(sofia_profile_t *profile, switch_xml_t x_domain_tag
|
||||
if (sofia_glue_add_profile(switch_core_strdup(profile->pool, dname), profile) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Alias [%s] for profile [%s]\n", dname, profile->name);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Alias [%s] for profile [%s] (already exists)\n", dname, profile->name);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Alias [%s] for profile [%s] (already exists)\n", dname, profile->name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4181,10 +4204,14 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
||||
}
|
||||
} else if (!strcasecmp(var, "alias")) {
|
||||
sip_alias_node_t *node;
|
||||
if ((node = switch_core_alloc(profile->pool, sizeof(*node)))) {
|
||||
if ((node->url = switch_core_strdup(profile->pool, val))) {
|
||||
node->next = profile->aliases;
|
||||
profile->aliases = node;
|
||||
if (zstr(val)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Alias Param has no data...\n");
|
||||
} else {
|
||||
if ((node = switch_core_alloc(profile->pool, sizeof(*node)))) {
|
||||
if ((node->url = switch_core_strdup(profile->pool, val))) {
|
||||
node->next = profile->aliases;
|
||||
profile->aliases = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!strcasecmp(var, "dialplan")) {
|
||||
@@ -5272,6 +5299,9 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
break;
|
||||
case nua_callstate_completing:
|
||||
{
|
||||
const char *invite_full_from = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_from");
|
||||
const char *invite_full_to = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_to");
|
||||
|
||||
if (r_sdp && sofia_test_flag(tech_pvt, TFLAG_3PCC_INVITE) && !sofia_test_flag(tech_pvt, TFLAG_SDP)) {
|
||||
sofia_set_flag(tech_pvt, TFLAG_SDP);
|
||||
|
||||
@@ -5295,12 +5325,18 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
const char *invite_route_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_route_uri");
|
||||
|
||||
nua_ack(nh,
|
||||
TAG_IF(!zstr(invite_full_via), SIPTAG_VIA_STR(invite_full_via)),
|
||||
TAG_IF(!zstr(invite_route_uri), SIPTAG_ROUTE_STR(invite_route_uri)),
|
||||
TAG_END());
|
||||
TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
|
||||
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
|
||||
TAG_IF(!zstr(invite_full_via), SIPTAG_VIA_STR(invite_full_via)),
|
||||
TAG_IF(!zstr(invite_route_uri), SIPTAG_ROUTE_STR(invite_route_uri)),
|
||||
TAG_END());
|
||||
|
||||
} else {
|
||||
nua_ack(nh, TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
|
||||
nua_ack(nh,
|
||||
TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
|
||||
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
|
||||
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
|
||||
TAG_END());
|
||||
}
|
||||
}
|
||||
goto done;
|
||||
@@ -5587,6 +5623,12 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
}
|
||||
goto done;
|
||||
} else {
|
||||
|
||||
if (switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_NEGOTIATED)) {
|
||||
nua_respond(tech_pvt->nh, SIP_200_OK, TAG_END());
|
||||
goto done;
|
||||
}
|
||||
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
|
||||
|
||||
if (tech_pvt->num_codecs) {
|
||||
@@ -5602,6 +5644,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
if (sofia_glue_tech_choose_port(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
|
||||
|
||||
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -7691,6 +7734,12 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
}
|
||||
}
|
||||
|
||||
check_decode(displayname, session);
|
||||
tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
from_user,
|
||||
dialplan,
|
||||
displayname, from_user, network_ip, from_user, aniii, NULL, MODNAME, context, destination_number);
|
||||
|
||||
if (!bnh && sip->sip_replaces) {
|
||||
if (!(bnh = nua_handle_by_replaces(nua, sip->sip_replaces))) {
|
||||
if (!(bnh = nua_handle_by_call_id(nua, sip->sip_replaces->rp_call_id))) {
|
||||
@@ -7711,10 +7760,32 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
private_object_t *b_tech_pvt = NULL;
|
||||
const char *app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
|
||||
const char *data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE);
|
||||
switch_caller_profile_t *orig_cp;
|
||||
const char *sent_name, *sent_number;
|
||||
orig_cp = switch_channel_get_caller_profile(b_channel);
|
||||
|
||||
sent_name = switch_channel_get_variable(b_channel, "last_sent_callee_id_name");
|
||||
sent_number = switch_channel_get_variable(b_channel, "last_sent_callee_id_number");
|
||||
|
||||
if (!zstr(sent_name) && !zstr(sent_number)) {
|
||||
tech_pvt->caller_profile->callee_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, sent_name);
|
||||
tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, sent_number);
|
||||
} else {
|
||||
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) {
|
||||
tech_pvt->caller_profile->callee_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_name);
|
||||
tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_number);
|
||||
} else {
|
||||
tech_pvt->caller_profile->callee_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_name);
|
||||
tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_number);
|
||||
}
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Setting NAT mode based on %s\n", is_nat);
|
||||
|
||||
|
||||
if (app && data && !strcasecmp(app, "conference")) {
|
||||
destination_number = switch_core_session_sprintf(session, "answer,conference:%s", data);
|
||||
dialplan = "inline";
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,conference:%s", data);
|
||||
tech_pvt->caller_profile->dialplan = "inline";
|
||||
} else {
|
||||
if (switch_core_session_check_interface(b_session, sofia_endpoint_interface)) {
|
||||
b_tech_pvt = switch_core_session_get_private(b_session);
|
||||
@@ -7744,7 +7815,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
if (switch_core_session_check_interface(c_session, sofia_endpoint_interface)) {
|
||||
c_tech_pvt = switch_core_session_get_private(c_session);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!one_leg &&
|
||||
(!b_tech_pvt || !sofia_test_flag(b_tech_pvt, TFLAG_SIP_HOLD)) &&
|
||||
@@ -7761,21 +7832,25 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
}
|
||||
|
||||
if (do_conf) {
|
||||
destination_number = switch_core_session_sprintf(session, "answer,conference:%s@sla+flags{mintwo}", uuid);
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool,
|
||||
"answer,conference:%s@sla+flags{mintwo}", uuid);
|
||||
} else {
|
||||
if (one_leg && c_app) {
|
||||
if (c_data) {
|
||||
destination_number = switch_core_session_sprintf(session, "answer,%s:%s", c_app, c_data);
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool,
|
||||
"answer,%s:%s", c_app, c_data);
|
||||
} else {
|
||||
destination_number = switch_core_session_sprintf(session, "answer,%s", c_app);
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool,
|
||||
"answer,%s", c_app);
|
||||
}
|
||||
} else {
|
||||
switch_channel_mark_hold(b_channel, SWITCH_FALSE);
|
||||
destination_number = switch_core_session_sprintf(session, "answer,intercept:%s", uuid);
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool,
|
||||
"answer,intercept:%s", uuid);
|
||||
}
|
||||
}
|
||||
|
||||
dialplan = "inline";
|
||||
tech_pvt->caller_profile->dialplan = "inline";
|
||||
}
|
||||
}
|
||||
switch_core_session_rwunlock(b_session);
|
||||
@@ -7784,11 +7859,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
nua_handle_unref(bnh);
|
||||
}
|
||||
|
||||
check_decode(displayname, session);
|
||||
tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
from_user,
|
||||
dialplan,
|
||||
displayname, from_user, network_ip, from_user, aniii, NULL, MODNAME, context, destination_number);
|
||||
|
||||
|
||||
if (tech_pvt->caller_profile) {
|
||||
|
||||
|
||||
@@ -48,12 +48,23 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
|
||||
uint32_t port = t38_options->local_port;
|
||||
const char *family = "IP4";
|
||||
const char *username = tech_pvt->profile->username;
|
||||
char MMR[32] = "";
|
||||
char JBIG[32] = "";
|
||||
char FILLBIT[32] = "";
|
||||
const char *bit_removal_on = "a=T38FaxFillBitRemoval\n";
|
||||
const char *bit_removal_off = "";
|
||||
|
||||
const char *mmr_on = "a=T38FaxTranscodingMMR\n";
|
||||
const char *mmr_off = "";
|
||||
|
||||
const char *jbig_on = "a=T38FaxTranscodingJBIG\n";
|
||||
const char *jbig_off = "";
|
||||
const char *var;
|
||||
int broken_boolean;
|
||||
|
||||
//sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA);
|
||||
|
||||
var = switch_channel_get_variable(tech_pvt->channel, "t38_broken_boolean");
|
||||
|
||||
broken_boolean = switch_true(var);
|
||||
|
||||
if (!ip) {
|
||||
if (!(ip = tech_pvt->adv_sdp_audio_ip)) {
|
||||
ip = tech_pvt->proxy_sdp_audio_ip;
|
||||
@@ -94,48 +105,6 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
|
||||
"o=%s %010u %010u IN %s %s\n"
|
||||
"s=%s\n" "c=IN %s %s\n" "t=0 0\n", username, tech_pvt->owner_id, tech_pvt->session_id, family, ip, username, family, ip);
|
||||
|
||||
if(t38_options->T38FaxFillBitRemoval) {
|
||||
if (switch_true(switch_channel_get_variable(tech_pvt->channel, "broken_T38FaxFillBitRemoval"))) {
|
||||
switch_snprintf(FILLBIT, sizeof(FILLBIT), "a=T38FaxFillBitRemoval:1\n");
|
||||
} else {
|
||||
switch_set_string(FILLBIT, "a=T38FaxFillBitRemoval\n");
|
||||
}
|
||||
} else {
|
||||
if (switch_true(switch_channel_get_variable(tech_pvt->channel, "broken_T38FaxFillBitRemoval"))) {
|
||||
switch_snprintf(FILLBIT, sizeof(FILLBIT), "a=T38FaxFillBitRemoval:0\n");
|
||||
} else {
|
||||
switch_set_string(FILLBIT, "");
|
||||
}
|
||||
}
|
||||
|
||||
if( t38_options->T38FaxTranscodingMMR) {
|
||||
if (switch_true(switch_channel_get_variable(tech_pvt->channel, "broken_T38FaxTranscodingMMR"))) {
|
||||
switch_snprintf(MMR, sizeof(MMR), "a=T38FaxTranscodingMMR:1\n");
|
||||
} else {
|
||||
switch_set_string(MMR, "a=T38FaxTranscodingMMR\n");
|
||||
}
|
||||
} else {
|
||||
if (switch_true(switch_channel_get_variable(tech_pvt->channel, "broken_T38FaxTranscodingMMR"))) {
|
||||
switch_snprintf(MMR, sizeof(MMR), "a=T38FaxTranscodingMMR:0\n");
|
||||
} else {
|
||||
switch_set_string(MMR, "");
|
||||
}
|
||||
}
|
||||
|
||||
if( t38_options->T38FaxTranscodingJBIG) {
|
||||
if (switch_true(switch_channel_get_variable(tech_pvt->channel, "broken_T38FaxTranscodingJBIG"))) {
|
||||
switch_snprintf(JBIG, sizeof(JBIG), "a=T38FaxTranscodingJBIG:1\n");
|
||||
} else {
|
||||
switch_set_string(JBIG, "a=T38FaxTranscodingJBIG\n");
|
||||
}
|
||||
} else {
|
||||
if (switch_true(switch_channel_get_variable(tech_pvt->channel, "broken_T38FaxTranscodingJBIG"))) {
|
||||
switch_snprintf(JBIG, sizeof(JBIG), "a=T38FaxTranscodingJBIG:0\n");
|
||||
} else {
|
||||
switch_set_string(JBIG, "");
|
||||
}
|
||||
}
|
||||
|
||||
if (t38_options->T38FaxMaxBuffer) {
|
||||
switch_snprintf(max_buf, sizeof(max_buf), "a=T38FaxMaxBuffer:%d\n", t38_options->T38FaxMaxBuffer);
|
||||
};
|
||||
@@ -145,6 +114,21 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
if (broken_boolean) {
|
||||
bit_removal_on = "a=T38FaxFillBitRemoval:1\n";
|
||||
bit_removal_off = "a=T38FaxFillBitRemoval:0\n";
|
||||
|
||||
mmr_on = "a=T38FaxTranscodingMMR:1\n";
|
||||
mmr_off = "a=T38FaxTranscodingMMR:0\n";
|
||||
|
||||
jbig_on = "a=T38FaxTranscodingJBIG:1\n";
|
||||
jbig_off = "a=T38FaxTranscodingJBIG:0\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
|
||||
"m=image %d udptl t38\n"
|
||||
"a=T38FaxVersion:%d\n"
|
||||
@@ -160,9 +144,9 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
|
||||
port,
|
||||
t38_options->T38FaxVersion,
|
||||
t38_options->T38MaxBitRate,
|
||||
FILLBIT,
|
||||
MMR,
|
||||
JBIG,
|
||||
t38_options->T38FaxFillBitRemoval ? bit_removal_on : bit_removal_off,
|
||||
t38_options->T38FaxTranscodingMMR ? mmr_on : mmr_off,
|
||||
t38_options->T38FaxTranscodingJBIG ? jbig_on : jbig_off,
|
||||
t38_options->T38FaxRateManagement,
|
||||
max_buf,
|
||||
max_data,
|
||||
@@ -201,7 +185,12 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen,
|
||||
|
||||
for (i = 0; i < tech_pvt->num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
|
||||
|
||||
int this_ptime = (imp->microseconds_per_packet / 1000);
|
||||
|
||||
if (!strcasecmp(imp->iananame, "ilbc")) {
|
||||
this_ptime = 20;
|
||||
}
|
||||
|
||||
if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO) {
|
||||
continue;
|
||||
}
|
||||
@@ -210,12 +199,12 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen,
|
||||
if (!cur_ptime) {
|
||||
#if 0
|
||||
if (ptime) {
|
||||
if (ptime != imp->microseconds_per_packet / 1000) {
|
||||
if (ptime != this_ptime) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"Codec %s payload %d added to sdp wanting ptime %d but it's already %d (%s:%d:%d), disabling ptime.\n",
|
||||
imp->iananame,
|
||||
tech_pvt->ianacodes[i],
|
||||
imp->microseconds_per_packet / 1000,
|
||||
this_ptime,
|
||||
ptime,
|
||||
tech_pvt->codecs[0]->iananame,
|
||||
tech_pvt->codecs[0]->ianacode,
|
||||
@@ -224,15 +213,15 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen,
|
||||
noptime = 1;
|
||||
}
|
||||
} else {
|
||||
ptime = imp->microseconds_per_packet / 1000;
|
||||
ptime = this_ptime;
|
||||
}
|
||||
#else
|
||||
if (!ptime) {
|
||||
ptime = imp->microseconds_per_packet / 1000;
|
||||
ptime = this_ptime;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if ((imp->microseconds_per_packet / 1000) != cur_ptime) {
|
||||
if (this_ptime != cur_ptime) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -266,18 +255,23 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen,
|
||||
for (i = 0; i < tech_pvt->num_codecs; i++) {
|
||||
const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
|
||||
char *fmtp = imp->fmtp;
|
||||
|
||||
int this_ptime = imp->microseconds_per_packet / 1000;
|
||||
|
||||
if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcasecmp(imp->iananame, "ilbc")) {
|
||||
this_ptime = 20;
|
||||
}
|
||||
|
||||
if (!noptime) {
|
||||
if (!cur_ptime) {
|
||||
if (!ptime) {
|
||||
ptime = imp->microseconds_per_packet / 1000;
|
||||
ptime = this_ptime;
|
||||
}
|
||||
} else {
|
||||
if ((imp->microseconds_per_packet / 1000) != cur_ptime) {
|
||||
if (this_ptime != cur_ptime) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -583,6 +577,10 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
|
||||
|
||||
this_ptime = imp->microseconds_per_packet / 1000;
|
||||
|
||||
if (!strcasecmp(imp->iananame, "ilbc")) {
|
||||
this_ptime = 20;
|
||||
}
|
||||
|
||||
if (cur_ptime != this_ptime) {
|
||||
char *bp = buf;
|
||||
cur_ptime = this_ptime;
|
||||
@@ -1058,8 +1056,9 @@ switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt, int forc
|
||||
tech_pvt->adv_sdp_audio_port = sdp_port;
|
||||
tech_pvt->adv_sdp_audio_ip = tech_pvt->extrtpip = switch_core_session_strdup(tech_pvt->session, use_ip);
|
||||
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->local_sdp_audio_ip);
|
||||
switch_channel_set_variable_printf(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, "%d", sdp_port);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_ADVERTISED_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -1910,7 +1909,7 @@ void sofia_glue_set_extra_headers(switch_channel_t *channel, sip_t const *sip, c
|
||||
}
|
||||
|
||||
for (un = sip->sip_unknown; un; un = un->un_next) {
|
||||
if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2)) {
|
||||
if ((!strncasecmp(un->un_name, "X-", 2) && strncasecmp(un->un_name, "X-FS-", 5)) || !strncasecmp(un->un_name, "P-", 2)) {
|
||||
if (!zstr(un->un_value)) {
|
||||
switch_snprintf(name, sizeof(name), "%s%s", prefix, un->un_name);
|
||||
switch_channel_set_variable(channel, name, un->un_value);
|
||||
@@ -2271,6 +2270,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
use_number = tech_pvt->caller_profile->caller_id_number;
|
||||
}
|
||||
|
||||
check_decode(use_name, session);
|
||||
|
||||
switch (cid_type) {
|
||||
case CID_TYPE_PID:
|
||||
@@ -3034,7 +3034,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
|
||||
}
|
||||
|
||||
if (!(sofia_test_pflag(tech_pvt->profile, PFLAG_REWRITE_TIMESTAMPS) ||
|
||||
((val = switch_channel_get_variable(tech_pvt->channel, "rtp_rewrite_timestamps")) && !switch_true(val)))) {
|
||||
((val = switch_channel_get_variable(tech_pvt->channel, "rtp_rewrite_timestamps")) && switch_true(val)))) {
|
||||
flags |= SWITCH_RTP_FLAG_RAW_WRITE;
|
||||
}
|
||||
|
||||
@@ -3114,8 +3114,9 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
|
||||
}
|
||||
|
||||
switch_snprintf(tmp, sizeof(tmp), "%d", tech_pvt->local_sdp_audio_port);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->local_sdp_audio_ip);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_ADVERTISED_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
|
||||
|
||||
if (tech_pvt->rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
|
||||
const char *rport = NULL;
|
||||
@@ -3355,11 +3356,13 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
|
||||
if (tech_pvt->te) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Set 2833 dtmf send payload to %u\n", tech_pvt->te);
|
||||
switch_rtp_set_telephony_event(tech_pvt->rtp_session, tech_pvt->te);
|
||||
switch_channel_set_variable_printf(tech_pvt->channel, "sip_2833_send_payload", "%d", tech_pvt->te);
|
||||
}
|
||||
|
||||
if (tech_pvt->recv_te) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Set 2833 dtmf receive payload to %u\n", tech_pvt->recv_te);
|
||||
switch_rtp_set_telephony_recv_event(tech_pvt->rtp_session, tech_pvt->recv_te);
|
||||
switch_channel_set_variable_printf(tech_pvt->channel, "sip_2833_recv_payload", "%d", tech_pvt->recv_te);
|
||||
}
|
||||
|
||||
if (tech_pvt->audio_recv_pt != tech_pvt->agreed_pt) {
|
||||
@@ -3988,6 +3991,7 @@ void sofia_glue_copy_t38_options(switch_t38_options_t *t38_options, switch_core_
|
||||
switch_channel_set_private(channel, "t38_options", local_t38_options);
|
||||
|
||||
}
|
||||
|
||||
static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_session_t *sdp, sdp_media_t *m)
|
||||
{
|
||||
switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options");
|
||||
@@ -4007,6 +4011,12 @@ static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_
|
||||
|
||||
t38_options->remote_port = (switch_port_t)m->m_port;
|
||||
|
||||
if (sdp->sdp_origin) {
|
||||
t38_options->sdp_o_line = switch_core_session_strdup(tech_pvt->session, sdp->sdp_origin->o_username);
|
||||
} else {
|
||||
t38_options->sdp_o_line = "unknown";
|
||||
}
|
||||
|
||||
if (m->m_connections && m->m_connections->c_address) {
|
||||
t38_options->remote_ip = switch_core_session_strdup(tech_pvt->session, m->m_connections->c_address);
|
||||
} else if (sdp && sdp->sdp_connection && sdp->sdp_connection->c_address) {
|
||||
@@ -4019,41 +4029,11 @@ static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_
|
||||
} else if (!strcasecmp(attr->a_name, "T38MaxBitRate") && attr->a_value) {
|
||||
t38_options->T38MaxBitRate = (uint32_t) atoi(attr->a_value);
|
||||
} else if (!strcasecmp(attr->a_name, "T38FaxFillBitRemoval")) {
|
||||
if (switch_stristr("T38FaxFillBitRemoval:", tech_pvt->remote_sdp_str)) {
|
||||
switch_channel_set_variable(tech_pvt->channel, "broken_T38FaxFillBitRemoval", "true");
|
||||
if (atoi(attr->a_value) == 0) {
|
||||
t38_options->T38FaxFillBitRemoval = SWITCH_FALSE;
|
||||
} else {
|
||||
t38_options->T38FaxFillBitRemoval = SWITCH_TRUE;
|
||||
}
|
||||
} else {
|
||||
switch_channel_set_variable(tech_pvt->channel, "broken_T38FaxFillBitRemoval", "false");
|
||||
t38_options->T38FaxFillBitRemoval = SWITCH_TRUE;
|
||||
}
|
||||
t38_options->T38FaxFillBitRemoval = switch_safe_atoi(attr->a_value, 1);
|
||||
} else if (!strcasecmp(attr->a_name, "T38FaxTranscodingMMR")) {
|
||||
if (switch_stristr("T38FaxTranscodingMMR:", tech_pvt->remote_sdp_str)) {
|
||||
switch_channel_set_variable(tech_pvt->channel, "broken_T38FaxTranscodingMMR", "true");
|
||||
if (atoi(attr->a_value) == 0) {
|
||||
t38_options->T38FaxTranscodingMMR = SWITCH_FALSE;
|
||||
} else {
|
||||
t38_options->T38FaxTranscodingMMR = SWITCH_TRUE;
|
||||
}
|
||||
} else {
|
||||
switch_channel_set_variable(tech_pvt->channel, "broken_T38FaxTranscodingMMR", "false");
|
||||
t38_options->T38FaxTranscodingMMR = SWITCH_TRUE;
|
||||
}
|
||||
t38_options->T38FaxTranscodingMMR = switch_safe_atoi(attr->a_value, 1);
|
||||
} else if (!strcasecmp(attr->a_name, "T38FaxTranscodingJBIG")) {
|
||||
if (switch_stristr("T38FaxTranscodingJBIG:", tech_pvt->remote_sdp_str)) {
|
||||
switch_channel_set_variable(tech_pvt->channel, "broken_T38FaxTranscodingJBIG", "true");
|
||||
if (atoi(attr->a_value) == 0) {
|
||||
t38_options->T38FaxTranscodingJBIG = SWITCH_FALSE;
|
||||
} else {
|
||||
t38_options->T38FaxTranscodingJBIG = SWITCH_TRUE;
|
||||
}
|
||||
} else {
|
||||
switch_channel_set_variable(tech_pvt->channel, "broken_T38FaxTranscodingJBIG", "false");
|
||||
t38_options->T38FaxTranscodingJBIG = SWITCH_TRUE;
|
||||
}
|
||||
t38_options->T38FaxTranscodingJBIG = switch_safe_atoi(attr->a_value, 1);
|
||||
} else if (!strcasecmp(attr->a_name, "T38FaxRateManagement") && attr->a_value) {
|
||||
t38_options->T38FaxRateManagement = switch_core_session_strdup(tech_pvt->session, attr->a_value);
|
||||
} else if (!strcasecmp(attr->a_name, "T38FaxMaxBuffer") && attr->a_value) {
|
||||
@@ -4331,7 +4311,9 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
||||
}
|
||||
}
|
||||
|
||||
if ((m = sdp->sdp_media) && (m->m_mode == sdp_sendonly || m->m_mode == sdp_inactive)) {
|
||||
if ((m = sdp->sdp_media) &&
|
||||
(m->m_mode == sdp_sendonly || m->m_mode == sdp_inactive ||
|
||||
(m->m_connections && m->m_connections->c_address && !strcmp(m->m_connections->c_address, "0.0.0.0")))) {
|
||||
sendonly = 2; /* global sendonly always wins */
|
||||
}
|
||||
|
||||
@@ -4400,6 +4382,11 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
||||
total_codecs = tech_pvt->num_negotiated_codecs;
|
||||
}
|
||||
|
||||
if (switch_stristr("T38FaxFillBitRemoval:", r_sdp) || switch_stristr("T38FaxTranscodingMMR:", r_sdp) ||
|
||||
switch_stristr("T38FaxTranscodingJBIG:", r_sdp)) {
|
||||
switch_channel_set_variable(tech_pvt->channel, "t38_broken_boolean", "true");
|
||||
}
|
||||
|
||||
for (m = sdp->sdp_media; m; m = m->m_next) {
|
||||
sdp_connection_t *connection;
|
||||
switch_core_session_t *other_session;
|
||||
@@ -4418,6 +4405,11 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
||||
if (got_udptl && m->m_type == sdp_media_image && m->m_port) {
|
||||
switch_t38_options_t *t38_options = tech_process_udptl(tech_pvt, sdp, m);
|
||||
|
||||
if (switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_NEGOTIATED)) {
|
||||
match = 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38)) {
|
||||
sofia_set_flag(tech_pvt, TFLAG_NOREPLY);
|
||||
}
|
||||
@@ -4434,10 +4426,12 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
||||
pass = switch_true(var);
|
||||
}
|
||||
|
||||
/* can't remember if this is necessary but its causing a bug so i'll leave this comment here to remind me
|
||||
if (sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU)) {
|
||||
pass = 0;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) ||
|
||||
switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA) || !switch_rtp_ready(tech_pvt->rtp_session)) {
|
||||
pass = 0;
|
||||
@@ -4835,13 +4829,16 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set 2833 dtmf send payload to %u\n", best_te);
|
||||
if (tech_pvt->rtp_session) {
|
||||
switch_rtp_set_telephony_event(tech_pvt->rtp_session, (switch_payload_t) best_te);
|
||||
switch_channel_set_variable_printf(tech_pvt->channel, "sip_2833_send_payload", "%d", best_te);
|
||||
}
|
||||
} else {
|
||||
te = tech_pvt->recv_te = tech_pvt->te = (switch_payload_t) best_te;
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set 2833 dtmf send/recv payload to %u\n", te);
|
||||
if (tech_pvt->rtp_session) {
|
||||
switch_rtp_set_telephony_event(tech_pvt->rtp_session, te);
|
||||
switch_channel_set_variable_printf(tech_pvt->channel, "sip_2833_send_payload", "%d", te);
|
||||
switch_rtp_set_telephony_recv_event(tech_pvt->rtp_session, te);
|
||||
switch_channel_set_variable_printf(tech_pvt->channel, "sip_2833_recv_payload", "%d", te);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -5384,9 +5381,19 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
|
||||
tech_pvt->remote_port = atoi(switch_str_nil(switch_channel_get_variable(channel, "sip_network_port")));
|
||||
tech_pvt->caller_profile = switch_channel_get_caller_profile(channel);
|
||||
|
||||
if ((tmp = switch_channel_get_variable(tech_pvt->channel, "sip_2833_send_payload"))) {
|
||||
int te = atoi(tmp);
|
||||
if (te > 64) {
|
||||
tech_pvt->te = te;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ((tmp = switch_channel_get_variable(tech_pvt->channel, "sip_2833_recv_payload"))) {
|
||||
int te = atoi(tmp);
|
||||
if (te > 64) {
|
||||
tech_pvt->recv_te = te;
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
|
||||
tech_pvt->dest = switch_core_session_sprintf(session, "sip:%s", switch_channel_get_variable(channel, "sip_req_uri"));
|
||||
@@ -5440,6 +5447,7 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
|
||||
if (session) {
|
||||
switch_caller_extension_t *extension = NULL;
|
||||
const char *ip = switch_channel_get_variable(channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE);
|
||||
const char *a_ip = switch_channel_get_variable(channel, SWITCH_ADVERTISED_MEDIA_IP_VARIABLE);
|
||||
const char *port = switch_channel_get_variable(channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE);
|
||||
const char *r_ip = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE);
|
||||
const char *r_port = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE);
|
||||
@@ -5479,11 +5487,15 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
|
||||
tech_pvt->adv_sdp_audio_ip = tech_pvt->extrtpip = (char *) ip;
|
||||
tech_pvt->adv_sdp_audio_port = tech_pvt->local_sdp_audio_port = (switch_port_t)atoi(port);
|
||||
|
||||
if ((tmp = switch_channel_get_variable(channel, "local_media_ip"))) {
|
||||
tech_pvt->local_sdp_audio_ip = switch_core_session_strdup(session, tmp);
|
||||
if (!zstr(ip)) {
|
||||
tech_pvt->local_sdp_audio_ip = switch_core_session_strdup(session, ip);
|
||||
tech_pvt->rtpip = tech_pvt->local_sdp_audio_ip;
|
||||
}
|
||||
|
||||
if (!zstr(a_ip)) {
|
||||
tech_pvt->adv_sdp_audio_ip = switch_core_session_strdup(session, a_ip);
|
||||
}
|
||||
|
||||
if (r_ip && r_port) {
|
||||
tech_pvt->remote_sdp_audio_ip = (char *) r_ip;
|
||||
tech_pvt->remote_sdp_audio_port = (switch_port_t)atoi(r_port);
|
||||
@@ -5541,6 +5553,14 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
|
||||
}
|
||||
}
|
||||
|
||||
if (tech_pvt->te) {
|
||||
switch_rtp_set_telephony_event(tech_pvt->rtp_session, tech_pvt->te);
|
||||
}
|
||||
|
||||
if (tech_pvt->recv_te) {
|
||||
switch_rtp_set_telephony_recv_event(tech_pvt->rtp_session, tech_pvt->recv_te);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) {
|
||||
@@ -6550,12 +6570,12 @@ void sofia_glue_parse_rtp_bugs(switch_rtp_bug_flag_t *flag_pole, const char *str
|
||||
*flag_pole &= ~RTP_BUG_IGNORE_DTMF_DURATION;
|
||||
}
|
||||
|
||||
if (switch_stristr("PAUSE_BETWEEN_DTMF", str)) {
|
||||
*flag_pole |= RTP_BUG_PAUSE_BETWEEN_DTMF;
|
||||
if (switch_stristr("ACCEPT_ANY_PACKETS", str)) {
|
||||
*flag_pole |= RTP_BUG_ACCEPT_ANY_PACKETS;
|
||||
}
|
||||
|
||||
if (switch_stristr("~PAUSE_BETWEEN_DTMF", str)) {
|
||||
*flag_pole &= ~RTP_BUG_PAUSE_BETWEEN_DTMF;
|
||||
if (switch_stristr("~ACCEPT_ANY_PACKETS", str)) {
|
||||
*flag_pole &= ~RTP_BUG_ACCEPT_ANY_PACKETS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@ struct presence_helper {
|
||||
char last_uuid[512];
|
||||
};
|
||||
|
||||
switch_status_t sofia_presence_chat_send(const char *proto, const char *from, const char *to, const char *subject,
|
||||
const char *body, const char *type, const char *hint)
|
||||
switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
|
||||
|
||||
{
|
||||
char *prof = NULL, *user = NULL, *host = NULL;
|
||||
sofia_profile_t *profile = NULL;
|
||||
@@ -93,6 +93,27 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
|
||||
char *dup_dest = NULL;
|
||||
char *p = NULL;
|
||||
char *remote_host = NULL;
|
||||
const char *proto;
|
||||
const char *from;
|
||||
const char *to;
|
||||
//const char *subject;
|
||||
const char *body;
|
||||
const char *type;
|
||||
const char *from_full;
|
||||
char header[256] = "";
|
||||
char *route_uri = NULL;
|
||||
const char *network_ip = NULL, *network_port = NULL;
|
||||
|
||||
proto = switch_event_get_header(message_event, "proto");
|
||||
from = switch_event_get_header(message_event, "from");
|
||||
to = switch_event_get_header(message_event, "to");
|
||||
//subject = switch_event_get_header(message_event, "subject");
|
||||
body = switch_event_get_body(message_event);
|
||||
type = switch_event_get_header(message_event, "type");
|
||||
from_full = switch_event_get_header(message_event, "from_full");
|
||||
|
||||
network_ip = switch_event_get_header(message_event, "to_sip_ip");
|
||||
network_port = switch_event_get_header(message_event, "to_sip_port");
|
||||
|
||||
if (!to) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To: header.\n");
|
||||
@@ -114,6 +135,10 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
|
||||
user = prof;
|
||||
prof = NULL;
|
||||
}
|
||||
|
||||
if (!prof) {
|
||||
prof = switch_event_get_header(message_event, "sip_profile");
|
||||
}
|
||||
|
||||
if (!strncasecmp(user, "sip:", 4)) {
|
||||
to_uri = user;
|
||||
@@ -125,13 +150,14 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
|
||||
} else {
|
||||
host++;
|
||||
}
|
||||
if (!prof)
|
||||
if (!prof) {
|
||||
prof = host;
|
||||
}
|
||||
}
|
||||
|
||||
if (!prof || !(profile = sofia_glue_find_profile(prof))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"Chat proto [%s]\nfrom [%s]\nto [%s]\n%s\nInvalid Profile %s\n", proto, from, to,
|
||||
"Chat proto [%s]\nfrom [%s]\nto [%s]\n%s\nInvalid Profile %s\n", proto, from, to,
|
||||
body ? body : "[no body]", prof ? prof : "NULL");
|
||||
goto end;
|
||||
}
|
||||
@@ -143,24 +169,34 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (to_uri) {
|
||||
switch_console_push_match(&list, to_uri);
|
||||
} else if (!(list = sofia_reg_find_reg_url_multi(profile, user, host))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find registered user %s@%s\n", user, host);
|
||||
goto end;
|
||||
sofia_profile_t *test;
|
||||
|
||||
if ((test = sofia_glue_find_profile(host))) {
|
||||
sofia_glue_release_profile(test);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Not sending to local box for %s@%s\n", user, host);
|
||||
/* our box let's not send it */
|
||||
} else {
|
||||
char *tmp;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Can't find registered user %s@%s\n", user, host);
|
||||
tmp = switch_mprintf("sip:%s@%s", user, host);
|
||||
switch_console_push_match(&list, tmp);
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!strcasecmp(proto, SOFIA_CHAT_PROTO)) {
|
||||
from = hint;
|
||||
from = from_full;
|
||||
} else {
|
||||
char *fp, *p = NULL;
|
||||
|
||||
fp = strdup(from);
|
||||
switch_assert(fp);
|
||||
|
||||
if (!fp) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((p = strchr(fp, '@'))) {
|
||||
*p++ = '\0';
|
||||
@@ -173,12 +209,23 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
|
||||
}
|
||||
}
|
||||
|
||||
ffrom = switch_mprintf("\"%s\" <sip:%s+%s@%s>", fp, proto, fp, p);
|
||||
if (switch_stristr("global", proto)) {
|
||||
ffrom = switch_mprintf("\"%s\" <sip:%s@%s>", fp, fp, p);
|
||||
} else {
|
||||
ffrom = switch_mprintf("\"%s\" <sip:%s+%s@%s>", fp, proto, fp, p);
|
||||
}
|
||||
|
||||
from = ffrom;
|
||||
switch_safe_free(fp);
|
||||
}
|
||||
|
||||
if (!list) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"Chat proto [%s]\nfrom [%s]\nto [%s]\n%s\nNobody to send to: Profile %s\n", proto, from, to,
|
||||
body ? body : "[no body]", prof ? prof : "NULL");
|
||||
goto end;
|
||||
}
|
||||
|
||||
for (m = list->head; m; m = m->next) {
|
||||
|
||||
if (!(dst = sofia_glue_get_destination(m->val))) {
|
||||
@@ -233,22 +280,35 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
|
||||
}
|
||||
|
||||
/* if this cries, add contact here too, change the 1 to 0 and omit the safe_free */
|
||||
|
||||
|
||||
//printf("DEBUG To: [%s] From: [%s] Contact: [%s] RURI [%s] ip [%s] port [%s]\n", to, from, contact, dst->route_uri, network_ip, network_port);
|
||||
|
||||
//DUMP_EVENT(message_event);
|
||||
|
||||
if (zstr(dst->route_uri) && !zstr(user) && !zstr(network_ip) && (zstr(host) || strcmp(network_ip, host))) {
|
||||
route_uri = switch_mprintf("sip:%s@%s:%s", user, network_ip, network_port);
|
||||
}
|
||||
|
||||
msg_nh = nua_handle(profile->nua, NULL,
|
||||
TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)),
|
||||
TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
|
||||
SIPTAG_FROM_STR(from),
|
||||
TAG_IF(contact, NUTAG_URL(contact)),
|
||||
SIPTAG_TO_STR(dup_dest),
|
||||
SIPTAG_CONTACT_STR(contact_str),
|
||||
TAG_END());
|
||||
|
||||
nua_handle_bind(msg_nh, &mod_sofia_globals.destroy_private);
|
||||
|
||||
switch_snprintf(header, sizeof(header), "X-FS-Sending-Message: %s", switch_core_get_uuid());
|
||||
|
||||
nua_message(msg_nh,
|
||||
TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)),
|
||||
TAG_IF(route_uri, NUTAG_PROXY(route_uri)),
|
||||
TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
|
||||
SIPTAG_FROM_STR(from),
|
||||
TAG_IF(contact, NUTAG_URL(contact)),
|
||||
SIPTAG_TO_STR(dup_dest),
|
||||
SIPTAG_CONTACT_STR(contact_str),
|
||||
|
||||
TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
|
||||
SIPTAG_CONTENT_TYPE_STR(ct),
|
||||
SIPTAG_PAYLOAD_STR(body),
|
||||
SIPTAG_HEADER_STR(header),
|
||||
TAG_END());
|
||||
|
||||
sofia_glue_free_destination(dst);
|
||||
@@ -261,6 +321,7 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
|
||||
end:
|
||||
|
||||
switch_safe_free(contact);
|
||||
switch_safe_free(route_uri);
|
||||
switch_safe_free(ffrom);
|
||||
switch_safe_free(dup);
|
||||
|
||||
@@ -702,7 +763,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||
"from sip_registrations "
|
||||
|
||||
"left join sip_dialogs on "
|
||||
"sip_dialogs.presence_id = sip_registrations.sip_user || '@' || sip_registrations.sip_host "
|
||||
"sip_dialogs.presence_id = sip_registrations.sip_user %q '@' %q sip_registrations.sip_host "
|
||||
"or (sip_dialogs.sip_from_user = sip_registrations.sip_user "
|
||||
"and sip_dialogs.sip_from_host = sip_registrations.sip_host) "
|
||||
|
||||
@@ -713,6 +774,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||
"(sip_registrations.orig_server_host='%q' or sip_registrations.sip_host='%q' "
|
||||
"or sip_registrations.presence_hosts like '%%%q%%'))",
|
||||
dh.status, dh.rpid,
|
||||
switch_sql_concat(), switch_sql_concat(),
|
||||
probe_euser, probe_host, probe_euser, probe_host, probe_host, probe_host);
|
||||
switch_assert(sql);
|
||||
|
||||
@@ -1983,14 +2045,21 @@ static int broadsoft_sla_gather_state_callback(void *pArg, int argc, char **argv
|
||||
if (uuid && (session = switch_core_session_locate(uuid))) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
if (zstr((callee_name = switch_channel_get_variable(channel, "effective_callee_id_name"))) &&
|
||||
zstr((callee_name = switch_channel_get_variable(channel, "sip_callee_id_name")))) {
|
||||
callee_name = switch_channel_get_variable(channel, "callee_id_name");
|
||||
}
|
||||
|
||||
if (zstr((callee_number = switch_channel_get_variable(channel, "effective_callee_id_number"))) &&
|
||||
zstr((callee_number = switch_channel_get_variable(channel, "sip_callee_id_number")))) {
|
||||
callee_number = switch_channel_get_variable(channel, "destination_number");
|
||||
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) {
|
||||
|
||||
if (zstr((callee_name = switch_channel_get_variable(channel, "effective_callee_id_name"))) &&
|
||||
zstr((callee_name = switch_channel_get_variable(channel, "sip_callee_id_name")))) {
|
||||
callee_name = switch_channel_get_variable(channel, "callee_id_name");
|
||||
}
|
||||
|
||||
if (zstr((callee_number = switch_channel_get_variable(channel, "effective_callee_id_number"))) &&
|
||||
zstr((callee_number = switch_channel_get_variable(channel, "sip_callee_id_number"))) &&
|
||||
zstr((callee_number = switch_channel_get_variable(channel, "callee_id_number")))) {
|
||||
callee_number = switch_channel_get_variable(channel, "destination_number");
|
||||
}
|
||||
} else {
|
||||
callee_name = switch_channel_get_variable(channel, "caller_id_name");
|
||||
callee_number = switch_channel_get_variable(channel, "caller_id_number");
|
||||
}
|
||||
|
||||
if (zstr(callee_name) && !zstr(callee_number)) {
|
||||
@@ -2849,13 +2918,25 @@ void sofia_presence_handle_sip_i_message(int status,
|
||||
const char *to_host = NULL;
|
||||
sip_payload_t *payload = sip->sip_payload;
|
||||
char *msg = NULL;
|
||||
const char *us;
|
||||
char network_ip[80];
|
||||
int network_port = 0;
|
||||
|
||||
if ((us = sofia_glue_get_unknown_header(sip, "X-FS-Sending-Message")) && !strcmp(us, switch_core_get_uuid())) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Not sending message to ourselves!\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (sip->sip_content_type && sip->sip_content_type->c_subtype) {
|
||||
if (strstr(sip->sip_content_type->c_subtype, "composing")) {
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), &network_port);
|
||||
|
||||
|
||||
if (from) {
|
||||
from_user = from->a_url->url_user;
|
||||
from_host = from->a_url->url_host;
|
||||
@@ -2867,7 +2948,7 @@ void sofia_presence_handle_sip_i_message(int status,
|
||||
}
|
||||
|
||||
if (!to_user) {
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (payload) {
|
||||
@@ -2906,33 +2987,56 @@ void sofia_presence_handle_sip_i_message(int status,
|
||||
sofia_presence_set_hash_key(hash_key, sizeof(hash_key), sip);
|
||||
}
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_IN_DIALOG_CHAT) && (tech_pvt = (private_object_t *) switch_core_hash_find(profile->chat_hash, hash_key))) {
|
||||
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", profile->url);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", from_addr);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", full_from);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", to_addr);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE");
|
||||
if (msg) {
|
||||
switch_event_add_body(event, "%s", msg);
|
||||
}
|
||||
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", profile->url);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", from_addr);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", from_user);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", from_host);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", to_user);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", to_host);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_sip_ip", network_ip);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from_sip_port", "%d", network_port);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", to_addr);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE");
|
||||
|
||||
if (switch_core_session_queue_event(tech_pvt->session, &event) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "delivery-failure", "true");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
if (sip->sip_content_type && sip->sip_content_type->c_subtype) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", sip->sip_content_type->c_type);
|
||||
} else {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "text/plain");
|
||||
}
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", full_from);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sip_profile", profile->name);
|
||||
|
||||
if (msg) {
|
||||
switch_event_add_body(event, "%s", msg);
|
||||
}
|
||||
} else {
|
||||
switch_core_chat_send(proto, SOFIA_CHAT_PROTO, from_addr, to_addr, "", msg, NULL, full_from);
|
||||
abort();
|
||||
}
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_IN_DIALOG_CHAT) && (tech_pvt = (private_object_t *) switch_core_hash_find(profile->chat_hash, hash_key))) {
|
||||
switch_core_session_queue_event(tech_pvt->session, &event);
|
||||
} else {
|
||||
switch_core_chat_send(proto, event);
|
||||
switch_event_destroy(&event);
|
||||
}
|
||||
|
||||
switch_safe_free(to_addr);
|
||||
switch_safe_free(from_addr);
|
||||
|
||||
if (full_from) {
|
||||
su_free(nh->nh_home, full_from);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
|
||||
|
||||
}
|
||||
|
||||
void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip)
|
||||
|
||||
@@ -241,37 +241,41 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now)
|
||||
|
||||
void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
||||
{
|
||||
sofia_gateway_t *gateway_ptr, *last = NULL;
|
||||
sofia_gateway_t *check, *gateway_ptr, *last = NULL;
|
||||
switch_event_t *event;
|
||||
char *pkey;
|
||||
|
||||
switch_mutex_lock(profile->gw_mutex);
|
||||
for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
|
||||
if (gateway_ptr->deleted && gateway_ptr->state == REG_STATE_NOREG) {
|
||||
if (last) {
|
||||
last->next = gateway_ptr->next;
|
||||
} else {
|
||||
profile->gateways = gateway_ptr->next;
|
||||
if (gateway_ptr->deleted) {
|
||||
if ((check = switch_core_hash_find(mod_sofia_globals.gateway_hash, gateway_ptr->name)) && check == gateway_ptr) {
|
||||
char *pkey = switch_mprintf("%s::%s", profile->name, gateway_ptr->name);
|
||||
switch_assert(pkey);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Removing gateway %s from hash.\n", pkey);
|
||||
switch_core_hash_delete(mod_sofia_globals.gateway_hash, pkey);
|
||||
switch_core_hash_delete(mod_sofia_globals.gateway_hash, gateway_ptr->name);
|
||||
free(pkey);
|
||||
}
|
||||
|
||||
pkey = switch_mprintf("%s::%s", profile->name, gateway_ptr->name);
|
||||
if (gateway_ptr->state == REG_STATE_NOREG) {
|
||||
|
||||
switch_core_hash_delete(mod_sofia_globals.gateway_hash, pkey);
|
||||
switch_core_hash_delete(mod_sofia_globals.gateway_hash, gateway_ptr->name);
|
||||
|
||||
free(pkey);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deleted gateway %s\n", gateway_ptr->name);
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_GATEWAY_DEL) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile-name", gateway_ptr->profile->name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Gateway", gateway_ptr->name);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
if (gateway_ptr->ob_vars) {
|
||||
switch_event_destroy(&gateway_ptr->ob_vars);
|
||||
}
|
||||
if (gateway_ptr->ib_vars) {
|
||||
switch_event_destroy(&gateway_ptr->ib_vars);
|
||||
if (last) {
|
||||
last->next = gateway_ptr->next;
|
||||
} else {
|
||||
profile->gateways = gateway_ptr->next;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deleted gateway %s\n", gateway_ptr->name);
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_GATEWAY_DEL) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile-name", gateway_ptr->profile->name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Gateway", gateway_ptr->name);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
if (gateway_ptr->ob_vars) {
|
||||
switch_event_destroy(&gateway_ptr->ob_vars);
|
||||
}
|
||||
if (gateway_ptr->ib_vars) {
|
||||
switch_event_destroy(&gateway_ptr->ib_vars);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
last = gateway_ptr;
|
||||
@@ -672,10 +676,10 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
|
||||
|
||||
sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_del_callback, profile);
|
||||
if (now) {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires <= %ld and hostname='%s'",
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires <= %ld and hostname='%q'",
|
||||
(long) now, mod_sofia_globals.hostname);
|
||||
} else {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and hostname='%s'", mod_sofia_globals.hostname);
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
|
||||
}
|
||||
|
||||
sofia_glue_actually_execute_sql(profile, sql, NULL);
|
||||
@@ -683,11 +687,11 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
|
||||
|
||||
|
||||
if (now) {
|
||||
switch_snprintf(sql, sizeof(sql), "select call_id from sip_shared_appearance_dialogs where hostname='%s' "
|
||||
switch_snprintfv(sql, sizeof(sql), "select call_id from sip_shared_appearance_dialogs where hostname='%q' "
|
||||
"and profile_name='%s' and expires <= %ld", mod_sofia_globals.hostname, profile->name, (long) now);
|
||||
|
||||
sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_sla_dialog_del_callback, profile);
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_shared_appearance_dialogs where expires > 0 and hostname='%s' and expires <= %ld",
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_shared_appearance_dialogs where expires > 0 and hostname='%q' and expires <= %ld",
|
||||
mod_sofia_globals.hostname, (long) now);
|
||||
|
||||
|
||||
@@ -696,19 +700,19 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
|
||||
|
||||
|
||||
if (now) {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_presence where expires > 0 and expires <= %ld and hostname='%s'",
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_presence where expires > 0 and expires <= %ld and hostname='%q'",
|
||||
(long) now, mod_sofia_globals.hostname);
|
||||
} else {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_presence where expires > 0 and hostname='%s'", mod_sofia_globals.hostname);
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_presence where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
|
||||
}
|
||||
|
||||
sofia_glue_actually_execute_sql(profile, sql, NULL);
|
||||
|
||||
if (now) {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires <= %ld and hostname='%s'",
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires <= %ld and hostname='%q'",
|
||||
(long) now, mod_sofia_globals.hostname);
|
||||
} else {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and hostname='%s'", mod_sofia_globals.hostname);
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
|
||||
}
|
||||
|
||||
sofia_glue_actually_execute_sql(profile, sql, NULL);
|
||||
@@ -718,27 +722,27 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
|
||||
"select call_id from sip_subscriptions where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%s'", (long) now,
|
||||
mod_sofia_globals.hostname);
|
||||
} else {
|
||||
switch_snprintf(sql, sizeof(sql), "select sub_to_user,sub_to_host,call_id from sip_subscriptions where expires >= -1 and hostname='%s'",
|
||||
switch_snprintfv(sql, sizeof(sql), "select sub_to_user,sub_to_host,call_id from sip_subscriptions where expires >= -1 and hostname='%q'",
|
||||
mod_sofia_globals.hostname);
|
||||
}
|
||||
|
||||
sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_sub_del_callback, profile);
|
||||
|
||||
if (now) {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_subscriptions where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%s'",
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_subscriptions where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%q'",
|
||||
(long) now, mod_sofia_globals.hostname);
|
||||
} else {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_subscriptions where expires >= -1 and hostname='%s'", mod_sofia_globals.hostname);
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_subscriptions where expires >= -1 and hostname='%q'", mod_sofia_globals.hostname);
|
||||
}
|
||||
|
||||
sofia_glue_actually_execute_sql(profile, sql, NULL);
|
||||
|
||||
|
||||
if (now) {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_dialogs where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%s'",
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_dialogs where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%q'",
|
||||
(long) now, mod_sofia_globals.hostname);
|
||||
} else {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_dialogs where expires >= -1 and hostname='%s'", mod_sofia_globals.hostname);
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_dialogs where expires >= -1 and hostname='%q'", mod_sofia_globals.hostname);
|
||||
}
|
||||
|
||||
sofia_glue_actually_execute_sql(profile, sql, NULL);
|
||||
@@ -829,24 +833,24 @@ void sofia_reg_check_sync(sofia_profile_t *profile)
|
||||
|
||||
|
||||
sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_del_callback, profile);
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and hostname='%s'", mod_sofia_globals.hostname);
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
|
||||
sofia_glue_actually_execute_sql(profile, sql, NULL);
|
||||
|
||||
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_presence where expires > 0 and hostname='%s'", mod_sofia_globals.hostname);
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_presence where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
|
||||
sofia_glue_actually_execute_sql(profile, sql, NULL);
|
||||
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and hostname='%s'", mod_sofia_globals.hostname);
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
|
||||
sofia_glue_actually_execute_sql(profile, sql, NULL);
|
||||
|
||||
switch_snprintf(sql, sizeof(sql), "select sub_to_user,sub_to_host,call_id from sip_subscriptions where expires >= -1 and hostname='%s'",
|
||||
switch_snprintfv(sql, sizeof(sql), "select sub_to_user,sub_to_host,call_id from sip_subscriptions where expires >= -1 and hostname='%q'",
|
||||
mod_sofia_globals.hostname);
|
||||
sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_sub_del_callback, profile);
|
||||
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_subscriptions where expires >= -1 and hostname='%s'", mod_sofia_globals.hostname);
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_subscriptions where expires >= -1 and hostname='%q'", mod_sofia_globals.hostname);
|
||||
sofia_glue_actually_execute_sql(profile, sql, NULL);
|
||||
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_dialogs where expires >= -1 and hostname='%s'", mod_sofia_globals.hostname);
|
||||
switch_snprintfv(sql, sizeof(sql), "delete from sip_dialogs where expires >= -1 and hostname='%q'", mod_sofia_globals.hostname);
|
||||
sofia_glue_actually_execute_sql(profile, sql, NULL);
|
||||
|
||||
switch_mutex_unlock(profile->ireg_mutex);
|
||||
@@ -867,10 +871,10 @@ char *sofia_reg_find_reg_url(sofia_profile_t *profile, const char *user, const c
|
||||
cbt.len = len;
|
||||
|
||||
if (host) {
|
||||
switch_snprintf(sql, sizeof(sql), "select contact from sip_registrations where sip_user='%s' and (sip_host='%s' or presence_hosts like '%%%s%%')",
|
||||
switch_snprintfv(sql, sizeof(sql), "select contact from sip_registrations where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')",
|
||||
user, host, host);
|
||||
} else {
|
||||
switch_snprintf(sql, sizeof(sql), "select contact from sip_registrations where sip_user='%s'", user);
|
||||
switch_snprintfv(sql, sizeof(sql), "select contact from sip_registrations where sip_user='%q'", user);
|
||||
}
|
||||
|
||||
|
||||
@@ -896,10 +900,10 @@ switch_console_callback_match_t *sofia_reg_find_reg_url_multi(sofia_profile_t *p
|
||||
}
|
||||
|
||||
if (host) {
|
||||
switch_snprintf(sql, sizeof(sql), "select contact from sip_registrations where sip_user='%s' and (sip_host='%s' or presence_hosts like '%%%s%%')",
|
||||
switch_snprintfv(sql, sizeof(sql), "select contact from sip_registrations where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')",
|
||||
user, host, host);
|
||||
} else {
|
||||
switch_snprintf(sql, sizeof(sql), "select contact from sip_registrations where sip_user='%s'", user);
|
||||
switch_snprintfv(sql, sizeof(sql), "select contact from sip_registrations where sip_user='%q'", user);
|
||||
}
|
||||
|
||||
|
||||
@@ -920,10 +924,10 @@ switch_console_callback_match_t *sofia_reg_find_reg_url_with_positive_expires_mu
|
||||
}
|
||||
|
||||
if (host) {
|
||||
switch_snprintf(sql, sizeof(sql), "select contact,expires from sip_registrations where sip_user='%s' and (sip_host='%s' or presence_hosts like '%%%s%%')",
|
||||
switch_snprintfv(sql, sizeof(sql), "select contact,expires from sip_registrations where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')",
|
||||
user, host, host);
|
||||
} else {
|
||||
switch_snprintf(sql, sizeof(sql), "select contact,expires from sip_registrations where sip_user='%s'", user);
|
||||
switch_snprintfv(sql, sizeof(sql), "select contact,expires from sip_registrations where sip_user='%q'", user);
|
||||
}
|
||||
|
||||
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_reg_find_reg_with_positive_expires_callback, &cbt);
|
||||
@@ -1397,7 +1401,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||
}
|
||||
/* Log line added to support Fail2Ban */
|
||||
if (sofia_test_pflag(profile, PFLAG_LOG_AUTH_FAIL)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SIP auth challenge (%s) on sofia profile '%s' "
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "SIP auth challenge (%s) on sofia profile '%s' "
|
||||
"for [%s@%s] from ip %s\n", (regtype == REG_INVITE) ? "INVITE" : "REGISTER",
|
||||
profile->name, to_user, to_host, network_ip);
|
||||
}
|
||||
@@ -1708,10 +1712,16 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const char *username = "unknown";
|
||||
if (auth_params) {
|
||||
username = switch_event_get_header(auth_params, "sip_auth_username");
|
||||
}
|
||||
|
||||
switch_core_del_registration(to_user, reg_host, call_id);
|
||||
|
||||
if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_UNREGISTER) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile-name", profile->name);
|
||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "username", username);
|
||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "from-user", to_user);
|
||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "from-host", reg_host);
|
||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "contact", contact_str);
|
||||
@@ -2809,7 +2819,7 @@ sofia_gateway_t *sofia_reg_find_gateway_by_realm__(const char *file, const char
|
||||
switch_mutex_lock(mod_sofia_globals.hash_mutex);
|
||||
for (hi = switch_hash_first(NULL, mod_sofia_globals.gateway_hash); hi; hi = switch_hash_next(hi)) {
|
||||
switch_hash_this(hi, &var, NULL, &val);
|
||||
if (key && (gateway = (sofia_gateway_t *) val) && gateway->register_realm && !strcasecmp(gateway->register_realm, key)) {
|
||||
if (key && (gateway = (sofia_gateway_t *) val) && !gateway->deleted && gateway->register_realm && !strcasecmp(gateway->register_realm, key)) {
|
||||
break;
|
||||
} else {
|
||||
gateway = NULL;
|
||||
@@ -2863,6 +2873,7 @@ switch_status_t sofia_reg_add_gateway(sofia_profile_t *profile, const char *key,
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
char *pkey = switch_mprintf("%s::%s", profile->name, key);
|
||||
sofia_gateway_t *gp;
|
||||
|
||||
switch_mutex_lock(profile->gw_mutex);
|
||||
|
||||
@@ -2872,12 +2883,21 @@ switch_status_t sofia_reg_add_gateway(sofia_profile_t *profile, const char *key,
|
||||
switch_mutex_unlock(profile->gw_mutex);
|
||||
|
||||
switch_mutex_lock(mod_sofia_globals.hash_mutex);
|
||||
if (!switch_core_hash_find(mod_sofia_globals.gateway_hash, key)) {
|
||||
status = switch_core_hash_insert(mod_sofia_globals.gateway_hash, key, gateway);
|
||||
|
||||
if ((gp = switch_core_hash_find(mod_sofia_globals.gateway_hash, key))) {
|
||||
if (gp->deleted) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Removing deleted gateway from hash.\n");
|
||||
switch_core_hash_delete(mod_sofia_globals.gateway_hash, gp->name);
|
||||
switch_core_hash_delete(mod_sofia_globals.gateway_hash, pkey);
|
||||
switch_core_hash_delete(mod_sofia_globals.gateway_hash, key);
|
||||
}
|
||||
}
|
||||
|
||||
if (!switch_core_hash_find(mod_sofia_globals.gateway_hash, pkey)) {
|
||||
if (!switch_core_hash_find(mod_sofia_globals.gateway_hash, key) && !switch_core_hash_find(mod_sofia_globals.gateway_hash, pkey)) {
|
||||
status = switch_core_hash_insert(mod_sofia_globals.gateway_hash, key, gateway);
|
||||
status = switch_core_hash_insert(mod_sofia_globals.gateway_hash, pkey, gateway);
|
||||
} else {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
include ../../../../build/modmake.rules
|
||||
|
||||
MONGODB_DRIVER=./driver/src
|
||||
LOCAL_CFLAGS=-I$(MONGODB_DRIVER)
|
||||
LOCAL_OBJS=$(MONGODB_DRIVER)/md5.o \
|
||||
$(MONGODB_DRIVER)/mongo.o $(MONGODB_DRIVER)/net.o \
|
||||
$(MONGODB_DRIVER)/bson.o $(MONGODB_DRIVER)/numbers.o $(MONGODB_DRIVER)/encoding.o \
|
||||
|
||||
local_depend: $(LOCAL_OBJS)
|
||||
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,139 @@
|
||||
# MongoDB C Driver History
|
||||
|
||||
## 0.4
|
||||
|
||||
THIS RELEASE INCLUDES NUMEROUS BACKWARD-BREAKING CHANGES.
|
||||
These changes have been made for extensibility, consistency,
|
||||
and ease of use. Please read the following release notes
|
||||
carefully, and study the updated tutorial.
|
||||
|
||||
API Principles:
|
||||
|
||||
1. Present a consistent interface for all objects: connections,
|
||||
cursors, bson objects, and bson iterators.
|
||||
2. Require no knowledge of an object's implementation to use the API.
|
||||
3. Allow users to allocate objects on the stack or on the heap.
|
||||
4. Integrate API with new error reporting strategy.
|
||||
5. Be concise, except where it impairs clarity.
|
||||
|
||||
Changes:
|
||||
|
||||
* mongo_replset_init_conn has been renamed to mongo_replset_init.
|
||||
* bson_buffer has been removed. All functions for building bson
|
||||
objects now take objects of type bson. The new pattern looks like this:
|
||||
|
||||
Example:
|
||||
|
||||
bson b[1];
|
||||
bson_init( b );
|
||||
bson_append_int( b, "foo", 1 );
|
||||
bson_finish( b );
|
||||
/* The object is ready to use.
|
||||
When finished, destroy it. */
|
||||
bson_destroy( b );
|
||||
|
||||
* mongo_connection has been renamed to mongo.
|
||||
|
||||
Example:
|
||||
|
||||
mongo conn[1];
|
||||
mongo_connect( conn, '127.0.0.1', 27017 );
|
||||
/* Connection is ready. Destroy when down. */
|
||||
mongo_destroy( conn );
|
||||
|
||||
* New cursor builder API for clearer code:
|
||||
|
||||
Example:
|
||||
|
||||
mongo_cursor cursor[1];
|
||||
mongo_cursor_init( cursor, conn, "test.foo" );
|
||||
|
||||
bson query[1];
|
||||
|
||||
bson_init( query );
|
||||
bson_append_int( query, "bar", 1 );
|
||||
bson_finish( query );
|
||||
|
||||
bson fields[1];
|
||||
|
||||
bson_init( fields );
|
||||
bson_append_int( fields, "baz", 1 );
|
||||
bson_finish( fields );
|
||||
|
||||
mongo_cursor_set_query( cursor, query );
|
||||
mongo_cursor_set_fields( cursor, fields );
|
||||
mongo_cursor_set_limit( cursor, 10 );
|
||||
mongo_cursor_set_skip( cursor, 10 );
|
||||
|
||||
while( mongo_cursor_next( cursor ) == MONGO_OK )
|
||||
bson_print( mongo_cursor_bson( cursor ) );
|
||||
|
||||
* bson_iterator_init now takes a (bson*) instead of a (const char*). This is consistent
|
||||
with bson_find, which also takes a (bson*). If you want to initiate a bson iterator
|
||||
with a buffer, use the new function bson_iterator_from_buffer.
|
||||
* With the addition of the mongo_cursor_bson function, it's now no
|
||||
longer necessary to know how bson and mongo_cursor objects are implemented.
|
||||
|
||||
Example:
|
||||
|
||||
bson b[1];
|
||||
bson_iterator i[1];
|
||||
|
||||
bson_iterator_init( i, b );
|
||||
|
||||
/* With a cursor */
|
||||
bson_iterator_init( i, mongo_cursor_bson( cursor ) );
|
||||
|
||||
* Added mongo_cursor_data and bson_data functions, which return the
|
||||
raw bson buffer as a (const char *).
|
||||
* All constants that were once lower case are now
|
||||
upper case. These include: MONGO_OP_MSG, MONGO_OP_UPDATE, MONGO_OP_INSERT,
|
||||
MONGO_OP_QUERY, MONGO_OP_GET_MORE, MONGO_OP_DELETE, MONGO_OP_KILL_CURSORS
|
||||
BSON_EOO, BSON_DOUBLE, BSON_STRING, BSON_OBJECT, BSON_ARRAY, BSON_BINDATA,
|
||||
BSON_UNDEFINED, BSON_OID, BSON_BOOL, BSON_DATE, BSON_NULL, BSON_REGEX, BSON_DBREF,
|
||||
BSON_CODE, BSON_SYMBOL, BSON_CODEWSCOPE, BSON_INT, BSON_TIMESTAMP, BSON_LONG,
|
||||
MONGO_CONN_SUCCESS, MONGO_CONN_BAD_ARG, MONGO_CONN_NO_SOCKET, MONGO_CONN_FAIL,
|
||||
MONGO_CONN_NOT_MASTER, MONGO_CONN_BAD_SET_NAME, MONGO_CONN_CANNOT_FIND_PRIMARY
|
||||
If your programs use any of these constants, you must convert them to their
|
||||
upper case forms, or you will see compile errors.
|
||||
* The error handling strategy has been changed. Exceptions are not longer being used.
|
||||
* Functions taking a mongo_connection object now return either MONGO_OK or MONGO_ERROR.
|
||||
In case of an error, an error code of type mongo_error_t will be indicated on the
|
||||
mongo_connection->err field.
|
||||
* Functions taking a bson object now return either BSON_OK or BSON_ERROR.
|
||||
In case of an error, an error code of type bson_validity_t will be indicated on the
|
||||
bson->err or bson_buffer->err field.
|
||||
* Calls to mongo_cmd_get_last_error store the error status on the
|
||||
mongo->lasterrcode and mongo->lasterrstr fields.
|
||||
* bson_print now prints all types.
|
||||
* Users may now set custom malloc, realloc, free, printf, sprintf, and fprintf fields.
|
||||
* Groundwork for modules for supporting platform-specific features (e.g., socket timeouts).
|
||||
* Added mongo_set_op_timeout for setting socket timeout. To take advantage of this, you must
|
||||
compile with --use-platform=LINUX. The compiles with platform/linux/net.h instead of the
|
||||
top-level net.h.
|
||||
* Fixed tailable cursors.
|
||||
* GridFS API is now in-line with the new driver API. In particular, all of the
|
||||
following functions now return MONGO_OK or MONGO_ERROR: gridfs_init,
|
||||
gridfile_init, gridfile_writer_done, gridfs_store_buffer, gridfs_store_file,
|
||||
and gridfs_find_query.
|
||||
* Fixed a few memory leaks.
|
||||
|
||||
## 0.3
|
||||
2011-4-14
|
||||
|
||||
* Support replica sets.
|
||||
* Better standard connection API.
|
||||
* GridFS write buffers iteratively.
|
||||
* Fixes for working with large GridFS files (> 3GB)
|
||||
* bson_append_string_n and family (Gergely Nagy)
|
||||
|
||||
## 0.2
|
||||
2011-2-11
|
||||
|
||||
* GridFS support (Chris Triolo).
|
||||
* BSON Timestamp type support.
|
||||
|
||||
## 0.1
|
||||
2009-11-30
|
||||
|
||||
* Initial release.
|
||||
@@ -0,0 +1,60 @@
|
||||
# MongoDB C Driver
|
||||
|
||||
This is then 10gen-supported MongoDB C driver. There are two goals for this driver.
|
||||
The first is to provide a strict, default compilation option for ultimate portability,
|
||||
no dependencies, and generic embeddability.
|
||||
|
||||
The second is to support more advanced, platform-specific features, like socket timeout,
|
||||
by providing an interface for platform-specific modules.
|
||||
|
||||
Until the 1.0 release, this driver should be considered alpha. Keep in mind that the API will be in flux until then.
|
||||
|
||||
# Building
|
||||
|
||||
First check out the version you want to build. *Always build from a particular tag, since HEAD may be
|
||||
a work in progress.* For example, to build version 0.4, run:
|
||||
|
||||
git checkout v0.4
|
||||
|
||||
You can then build the driver with scons:
|
||||
|
||||
scons
|
||||
|
||||
## Running the tests
|
||||
Make sure that you're running mongod on 127.0.0.1 on the default port (27017). The replica set
|
||||
test assumes a replica set with at least three nodes running at 127.0.0.1 and starting at port
|
||||
30000. Note that the driver does not recognize 'localhost' as a valid host name.
|
||||
|
||||
To compile and run the tests:
|
||||
|
||||
scons test
|
||||
|
||||
# Error Handling
|
||||
Most functions return MONGO_OK or BSON_OK on success and MONGO_ERROR or BSON_ERROR on failure.
|
||||
Specific error codes and error strings are then stored in the `err` and `errstr` fields of the
|
||||
`mongo` and `bson` objects. It is the client's responsibility to check for errors and handle
|
||||
them appropriately.
|
||||
|
||||
# Docs
|
||||
The docs are built using Sphinx and Doxygen. If you have these tools installed, then
|
||||
you can build the docs with scons:
|
||||
|
||||
scons docs
|
||||
|
||||
The html docs will appear in docs/html.
|
||||
|
||||
# ISSUES
|
||||
|
||||
You can report bugs, request new features, and view this driver's roadmap
|
||||
using [JIRA](http://jira.mongodb.org/browse/CDRIVER).
|
||||
|
||||
# CREDITS
|
||||
|
||||
* Gergely Nagy - Non-null-terminated string support.
|
||||
* Josh Rotenberg - Initial Doxygen setup and a significant chunk of documentation.
|
||||
|
||||
# LICENSE
|
||||
|
||||
Unless otherwise specified in a source file, sources in this
|
||||
repository are published under the terms of the Apache License version
|
||||
2.0, a copy of which is in this repository as APACHE-2.0.txt.
|
||||
@@ -0,0 +1,178 @@
|
||||
# -*- mode: python; -*-
|
||||
|
||||
VERSION = "0.4"
|
||||
|
||||
# --- options ----
|
||||
AddOption('--test-server',
|
||||
dest='test_server',
|
||||
default='127.0.0.1',
|
||||
type='string',
|
||||
nargs=1,
|
||||
action='store',
|
||||
help='IP address of server to use for testing')
|
||||
|
||||
AddOption('--seed-start-port',
|
||||
dest='seed_start_port',
|
||||
default=30000,
|
||||
type='int',
|
||||
nargs=1,
|
||||
action='store',
|
||||
help='IP address of server to use for testing')
|
||||
|
||||
AddOption('--c99',
|
||||
dest='use_c99',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='Compile with c99 (recommended for gcc)')
|
||||
|
||||
AddOption('--d',
|
||||
dest='optimize',
|
||||
default=True,
|
||||
action='store_false',
|
||||
help='disable optimizations')
|
||||
|
||||
AddOption('--use-platform',
|
||||
dest='compile_platform',
|
||||
default='GENERIC',
|
||||
type='string',
|
||||
nargs=1,
|
||||
action='store',
|
||||
help='Compile for a specific platform to take advantage '
|
||||
' of particular system features. For the moment, this include timeouts only.'
|
||||
' Current options include LINUX, '
|
||||
' GENERIC, and CUSTOM. If you specific CUSTOM, you must place a'
|
||||
' system-specific implementation of net.h and net.c in src/platform/custom/')
|
||||
|
||||
import os, sys
|
||||
|
||||
env = Environment( ENV=os.environ )
|
||||
|
||||
# ---- Docs ----
|
||||
def build_docs(env, target, source):
|
||||
buildscript_path = os.path.join(os.path.abspath("docs"))
|
||||
sys.path.insert(0, buildscript_path)
|
||||
import buildscripts
|
||||
from buildscripts import docs
|
||||
docs.main()
|
||||
|
||||
env.Alias("docs", [], [build_docs])
|
||||
env.AlwaysBuild("docs")
|
||||
|
||||
# ---- Platforms ----
|
||||
PLATFORM_TEST_DIR = None
|
||||
if "LINUX" == GetOption('compile_platform'):
|
||||
env.Append( CPPFLAGS=" -D_MONGO_USE_LINUX_SYSTEM" )
|
||||
NET_LIB = "src/platform/linux/net.c"
|
||||
PLATFORM_TEST_DIR = "test/platform/linux/"
|
||||
PLATFORM_TESTS = [ "timeouts" ]
|
||||
elif "CUSTOM" == GetOption('compile_platform'):
|
||||
env.Append( CPPFLAGS=" -D_MONGO_USE_CUSTOM_SYSTEM" )
|
||||
NET_LIB = "src/platform/custom/net.c"
|
||||
else:
|
||||
NET_LIB = "src/net.c"
|
||||
|
||||
# ---- Libraries ----
|
||||
if os.sys.platform in ["darwin", "linux2"]:
|
||||
env.Append( CPPFLAGS=" -pedantic -Wall -ggdb -DMONGO_HAVE_STDINT" )
|
||||
env.Append( CPPPATH=["/opt/local/include/"] )
|
||||
env.Append( LIBPATH=["/opt/local/lib/"] )
|
||||
|
||||
if GetOption('use_c99'):
|
||||
env.Append( CFLAGS=" -std=c99 " )
|
||||
env.Append( CXXDEFINES="MONGO_HAVE_STDINT" )
|
||||
else:
|
||||
env.Append( CFLAGS=" -ansi " )
|
||||
|
||||
if GetOption('optimize'):
|
||||
env.Append( CPPFLAGS=" -O3 " )
|
||||
# -O3 benchmarks *significantly* faster than -O2 when disabling networking
|
||||
elif 'win32' == os.sys.platform:
|
||||
env.Append( LIBS='ws2_32' )
|
||||
|
||||
#we shouldn't need these options in c99 mode
|
||||
if not GetOption('use_c99'):
|
||||
conf = Configure(env)
|
||||
|
||||
if not conf.CheckType('int64_t'):
|
||||
if conf.CheckType('int64_t', '#include <stdint.h>\n'):
|
||||
conf.env.Append( CPPDEFINES="MONGO_HAVE_STDINT" )
|
||||
elif conf.CheckType('int64_t', '#include <unistd.h>\n'):
|
||||
conf.env.Append( CPPDEFINES="MONGO_HAVE_UNISTD" )
|
||||
elif conf.CheckType('__int64'):
|
||||
conf.env.Append( CPPDEFINES="MONGO_USE__INT64" )
|
||||
elif conf.CheckType('long long int'):
|
||||
conf.env.Append( CPPDEFINES="MONGO_USE_LONG_LONG_INT" )
|
||||
else:
|
||||
print "*** what is your 64 bit int type? ****"
|
||||
Exit(1)
|
||||
|
||||
env = conf.Finish()
|
||||
|
||||
have_libjson = False
|
||||
conf = Configure(env)
|
||||
if conf.CheckLib('json'):
|
||||
have_libjson = True
|
||||
env = conf.Finish()
|
||||
|
||||
if sys.byteorder == 'big':
|
||||
env.Append( CPPDEFINES="MONGO_BIG_ENDIAN" )
|
||||
|
||||
env.Append( CPPPATH=["src/"] )
|
||||
|
||||
coreFiles = ["src/md5.c" ]
|
||||
mFiles = [ "src/mongo.c", NET_LIB, "src/gridfs.c"]
|
||||
bFiles = [ "src/bson.c", "src/numbers.c", "src/encoding.c"]
|
||||
mLibFiles = coreFiles + mFiles + bFiles
|
||||
bLibFiles = coreFiles + bFiles
|
||||
m = env.Library( "mongoc" , mLibFiles )
|
||||
b = env.Library( "bson" , bLibFiles )
|
||||
env.Default( env.Alias( "lib" , [ m[0] , b[0] ] ) )
|
||||
|
||||
if os.sys.platform == "linux2":
|
||||
env.Append( SHLINKFLAGS="-shared -Wl,-soname,libmongoc.so." + VERSION )
|
||||
env.Append( SHLINKFLAGS = "-shared -Wl,-soname,libbson.so." + VERSION )
|
||||
|
||||
dynm = env.SharedLibrary( "mongoc" , mLibFiles )
|
||||
dynb = env.SharedLibrary( "bson" , bLibFiles )
|
||||
env.Default( env.Alias( "sharedlib" , [ dynm[0] , dynb[0] ] ) )
|
||||
|
||||
|
||||
|
||||
# ---- Benchmarking ----
|
||||
benchmarkEnv = env.Clone()
|
||||
benchmarkEnv.Append( CPPDEFINES=[('TEST_SERVER', r'\"%s\"'%GetOption('test_server')),
|
||||
('SEED_START_PORT', r'%d'%GetOption('seed_start_port'))] )
|
||||
benchmarkEnv.Append( LIBS=[m, b] )
|
||||
benchmarkEnv.Prepend( LIBPATH=["."] )
|
||||
benchmarkEnv.Program( "benchmark" , [ "test/benchmark.c"] )
|
||||
|
||||
# ---- Tests ----
|
||||
testEnv = benchmarkEnv.Clone()
|
||||
testCoreFiles = [ ]
|
||||
|
||||
def run_tests( root, tests ):
|
||||
for name in tests:
|
||||
filename = "%s/%s.c" % (root, name)
|
||||
exe = "test_" + name
|
||||
test = testEnv.Program( exe , testCoreFiles + [filename] )
|
||||
test_alias = testEnv.Alias('test', [test], test[0].abspath + ' 2> ' + os.path.devnull)
|
||||
AlwaysBuild(test_alias)
|
||||
|
||||
tests = Split("sizes resize endian_swap bson bson_subobject simple update errors "
|
||||
"count_delete auth gridfs validate examples helpers oid functions cursors replica_set")
|
||||
|
||||
# Run standard tests
|
||||
run_tests("test", tests)
|
||||
|
||||
# Run platform tests
|
||||
if not PLATFORM_TEST_DIR is None:
|
||||
run_tests( PLATFORM_TEST_DIR, PLATFORM_TESTS )
|
||||
|
||||
if have_libjson:
|
||||
tests.append('json')
|
||||
testEnv.Append( LIBS=["json"] )
|
||||
|
||||
# special case for cpptest
|
||||
test = testEnv.Program( 'test_cpp' , testCoreFiles + ['test/cpptest.cpp'] )
|
||||
test_alias = testEnv.Alias('test', [test], test[0].abspath + ' 2> '+ os.path.devnull)
|
||||
AlwaysBuild(test_alias)
|
||||
@@ -0,0 +1,978 @@
|
||||
/* bson.c */
|
||||
|
||||
/* Copyright 2009, 2010 10gen Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "bson.h"
|
||||
#include "encoding.h"
|
||||
|
||||
const int initialBufferSize = 128;
|
||||
|
||||
/* only need one of these */
|
||||
static const int zero = 0;
|
||||
|
||||
/* Custom standard function pointers. */
|
||||
void *( *bson_malloc_func )( size_t ) = malloc;
|
||||
void *( *bson_realloc_func )( void *, size_t ) = realloc;
|
||||
void ( *bson_free )( void * ) = free;
|
||||
bson_printf_func bson_printf = printf;
|
||||
bson_fprintf_func bson_fprintf = fprintf;
|
||||
bson_sprintf_func bson_sprintf = sprintf;
|
||||
|
||||
static int _bson_errprintf( const char *, ... );
|
||||
bson_printf_func bson_errprintf = _bson_errprintf;
|
||||
|
||||
/* ObjectId fuzz functions. */
|
||||
static int ( *oid_fuzz_func )( void ) = NULL;
|
||||
static int ( *oid_inc_func )( void ) = NULL;
|
||||
|
||||
/* ----------------------------
|
||||
READING
|
||||
------------------------------ */
|
||||
|
||||
bson *bson_empty( bson *obj ) {
|
||||
static char *data = "\005\0\0\0\0";
|
||||
bson_init_data( obj, data );
|
||||
obj->finished = 1;
|
||||
obj->err = 0;
|
||||
obj->stackPos = 0;
|
||||
return obj;
|
||||
}
|
||||
|
||||
void bson_copy_basic( bson *out, const bson *in ) {
|
||||
if ( !out ) return;
|
||||
bson_init_size( out, bson_size( in ) );
|
||||
memcpy( out->data, in->data, bson_size( in ) );
|
||||
}
|
||||
|
||||
void bson_copy( bson *out, const bson *in ) {
|
||||
int i;
|
||||
|
||||
if ( !out ) return;
|
||||
bson_copy_basic( out, in );
|
||||
out->cur = out->data + ( in->cur - in->data );
|
||||
out->dataSize = in->dataSize;
|
||||
out->finished = in->finished;
|
||||
out->stackPos = in->stackPos;
|
||||
out->err = in->err;
|
||||
for( i=0; i<out->stackPos; i++ )
|
||||
out->stack[i] = in->stack[i];
|
||||
}
|
||||
|
||||
int bson_init_data( bson *b, char *data ) {
|
||||
b->data = data;
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
static void _bson_reset( bson *b ) {
|
||||
b->finished = 0;
|
||||
b->stackPos = 0;
|
||||
b->err = 0;
|
||||
b->errstr = NULL;
|
||||
}
|
||||
|
||||
int bson_size( const bson *b ) {
|
||||
int i;
|
||||
if ( ! b || ! b->data )
|
||||
return 0;
|
||||
bson_little_endian32( &i, b->data );
|
||||
return i;
|
||||
}
|
||||
|
||||
const char *bson_data( bson *b ) {
|
||||
return (const char *)b->data;
|
||||
}
|
||||
|
||||
static char hexbyte( char hex ) {
|
||||
switch ( hex ) {
|
||||
case '0':
|
||||
return 0x0;
|
||||
case '1':
|
||||
return 0x1;
|
||||
case '2':
|
||||
return 0x2;
|
||||
case '3':
|
||||
return 0x3;
|
||||
case '4':
|
||||
return 0x4;
|
||||
case '5':
|
||||
return 0x5;
|
||||
case '6':
|
||||
return 0x6;
|
||||
case '7':
|
||||
return 0x7;
|
||||
case '8':
|
||||
return 0x8;
|
||||
case '9':
|
||||
return 0x9;
|
||||
case 'a':
|
||||
case 'A':
|
||||
return 0xa;
|
||||
case 'b':
|
||||
case 'B':
|
||||
return 0xb;
|
||||
case 'c':
|
||||
case 'C':
|
||||
return 0xc;
|
||||
case 'd':
|
||||
case 'D':
|
||||
return 0xd;
|
||||
case 'e':
|
||||
case 'E':
|
||||
return 0xe;
|
||||
case 'f':
|
||||
case 'F':
|
||||
return 0xf;
|
||||
default:
|
||||
return 0x0; /* something smarter? */
|
||||
}
|
||||
}
|
||||
|
||||
void bson_oid_from_string( bson_oid_t *oid, const char *str ) {
|
||||
int i;
|
||||
for ( i=0; i<12; i++ ) {
|
||||
oid->bytes[i] = ( hexbyte( str[2*i] ) << 4 ) | hexbyte( str[2*i + 1] );
|
||||
}
|
||||
}
|
||||
|
||||
void bson_oid_to_string( const bson_oid_t *oid, char *str ) {
|
||||
static const char hex[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
|
||||
int i;
|
||||
for ( i=0; i<12; i++ ) {
|
||||
str[2*i] = hex[( oid->bytes[i] & 0xf0 ) >> 4];
|
||||
str[2*i + 1] = hex[ oid->bytes[i] & 0x0f ];
|
||||
}
|
||||
str[24] = '\0';
|
||||
}
|
||||
|
||||
void bson_set_oid_fuzz( int ( *func )( void ) ) {
|
||||
oid_fuzz_func = func;
|
||||
}
|
||||
|
||||
void bson_set_oid_inc( int ( *func )( void ) ) {
|
||||
oid_inc_func = func;
|
||||
}
|
||||
|
||||
void bson_oid_gen( bson_oid_t *oid ) {
|
||||
static int incr = 0;
|
||||
static int fuzz = 0;
|
||||
int i;
|
||||
int t = time( NULL );
|
||||
|
||||
if( oid_inc_func )
|
||||
i = oid_inc_func();
|
||||
else
|
||||
i = incr++;
|
||||
|
||||
if ( !fuzz ) {
|
||||
if ( oid_fuzz_func )
|
||||
fuzz = oid_fuzz_func();
|
||||
else {
|
||||
srand( t );
|
||||
fuzz = rand();
|
||||
}
|
||||
}
|
||||
|
||||
bson_big_endian32( &oid->ints[0], &t );
|
||||
oid->ints[1] = fuzz;
|
||||
bson_big_endian32( &oid->ints[2], &i );
|
||||
}
|
||||
|
||||
time_t bson_oid_generated_time( bson_oid_t *oid ) {
|
||||
time_t out;
|
||||
bson_big_endian32( &out, &oid->ints[0] );
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void bson_print( bson *b ) {
|
||||
bson_print_raw( b->data , 0 );
|
||||
}
|
||||
|
||||
void bson_print_raw( const char *data , int depth ) {
|
||||
bson_iterator i;
|
||||
const char *key;
|
||||
int temp;
|
||||
bson_timestamp_t ts;
|
||||
char oidhex[25];
|
||||
bson scope;
|
||||
bson_iterator_from_buffer( &i, data );
|
||||
|
||||
while ( bson_iterator_next( &i ) ) {
|
||||
bson_type t = bson_iterator_type( &i );
|
||||
if ( t == 0 )
|
||||
break;
|
||||
key = bson_iterator_key( &i );
|
||||
|
||||
for ( temp=0; temp<=depth; temp++ )
|
||||
printf( "\t" );
|
||||
bson_printf( "%s : %d \t " , key , t );
|
||||
switch ( t ) {
|
||||
case BSON_DOUBLE:
|
||||
printf( "%f" , bson_iterator_double( &i ) );
|
||||
break;
|
||||
case BSON_STRING:
|
||||
printf( "%s" , bson_iterator_string( &i ) );
|
||||
break;
|
||||
case BSON_SYMBOL:
|
||||
printf( "SYMBOL: %s" , bson_iterator_string( &i ) );
|
||||
break;
|
||||
case BSON_OID:
|
||||
bson_oid_to_string( bson_iterator_oid( &i ), oidhex );
|
||||
printf( "%s" , oidhex );
|
||||
break;
|
||||
case BSON_BOOL:
|
||||
printf( "%s" , bson_iterator_bool( &i ) ? "true" : "false" );
|
||||
break;
|
||||
case BSON_DATE:
|
||||
printf( "%ld" , ( long int )bson_iterator_date( &i ) );
|
||||
break;
|
||||
case BSON_BINDATA:
|
||||
printf( "BSON_BINDATA" );
|
||||
break;
|
||||
case BSON_UNDEFINED:
|
||||
printf( "BSON_UNDEFINED" );
|
||||
break;
|
||||
case BSON_NULL:
|
||||
printf( "BSON_NULL" );
|
||||
break;
|
||||
case BSON_REGEX:
|
||||
printf( "BSON_REGEX: %s", bson_iterator_regex( &i ) );
|
||||
break;
|
||||
case BSON_CODE:
|
||||
printf( "BSON_CODE: %s", bson_iterator_code( &i ) );
|
||||
break;
|
||||
case BSON_CODEWSCOPE:
|
||||
printf( "BSON_CODE_W_SCOPE: %s", bson_iterator_code( &i ) );
|
||||
bson_init( &scope );
|
||||
bson_iterator_code_scope( &i, &scope );
|
||||
printf( "\n\t SCOPE: " );
|
||||
bson_print( &scope );
|
||||
break;
|
||||
case BSON_INT:
|
||||
printf( "%d" , bson_iterator_int( &i ) );
|
||||
break;
|
||||
case BSON_LONG:
|
||||
printf( "%lld" , ( long long int )bson_iterator_long( &i ) );
|
||||
break;
|
||||
case BSON_TIMESTAMP:
|
||||
ts = bson_iterator_timestamp( &i );
|
||||
printf( "i: %d, t: %d", ts.i, ts.t );
|
||||
break;
|
||||
case BSON_OBJECT:
|
||||
case BSON_ARRAY:
|
||||
printf( "\n" );
|
||||
bson_print_raw( bson_iterator_value( &i ) , depth + 1 );
|
||||
break;
|
||||
default:
|
||||
bson_errprintf( "can't print type : %d\n" , t );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
ITERATOR
|
||||
------------------------------ */
|
||||
|
||||
void bson_iterator_init( bson_iterator *i, const bson *b ) {
|
||||
i->cur = b->data + 4;
|
||||
i->first = 1;
|
||||
}
|
||||
|
||||
void bson_iterator_from_buffer( bson_iterator *i, const char *buffer ) {
|
||||
i->cur = buffer + 4;
|
||||
i->first = 1;
|
||||
}
|
||||
|
||||
bson_type bson_find( bson_iterator *it, const bson *obj, const char *name ) {
|
||||
bson_iterator_init( it, (bson *)obj );
|
||||
while( bson_iterator_next( it ) ) {
|
||||
if ( strcmp( name, bson_iterator_key( it ) ) == 0 )
|
||||
break;
|
||||
}
|
||||
return bson_iterator_type( it );
|
||||
}
|
||||
|
||||
bson_bool_t bson_iterator_more( const bson_iterator *i ) {
|
||||
return *( i->cur );
|
||||
}
|
||||
|
||||
bson_type bson_iterator_next( bson_iterator *i ) {
|
||||
int ds;
|
||||
|
||||
if ( i->first ) {
|
||||
i->first = 0;
|
||||
return ( bson_type )( *i->cur );
|
||||
}
|
||||
|
||||
switch ( bson_iterator_type( i ) ) {
|
||||
case BSON_EOO:
|
||||
return BSON_EOO; /* don't advance */
|
||||
case BSON_UNDEFINED:
|
||||
case BSON_NULL:
|
||||
ds = 0;
|
||||
break;
|
||||
case BSON_BOOL:
|
||||
ds = 1;
|
||||
break;
|
||||
case BSON_INT:
|
||||
ds = 4;
|
||||
break;
|
||||
case BSON_LONG:
|
||||
case BSON_DOUBLE:
|
||||
case BSON_TIMESTAMP:
|
||||
case BSON_DATE:
|
||||
ds = 8;
|
||||
break;
|
||||
case BSON_OID:
|
||||
ds = 12;
|
||||
break;
|
||||
case BSON_STRING:
|
||||
case BSON_SYMBOL:
|
||||
case BSON_CODE:
|
||||
ds = 4 + bson_iterator_int_raw( i );
|
||||
break;
|
||||
case BSON_BINDATA:
|
||||
ds = 5 + bson_iterator_int_raw( i );
|
||||
break;
|
||||
case BSON_OBJECT:
|
||||
case BSON_ARRAY:
|
||||
case BSON_CODEWSCOPE:
|
||||
ds = bson_iterator_int_raw( i );
|
||||
break;
|
||||
case BSON_DBREF:
|
||||
ds = 4+12 + bson_iterator_int_raw( i );
|
||||
break;
|
||||
case BSON_REGEX: {
|
||||
const char *s = bson_iterator_value( i );
|
||||
const char *p = s;
|
||||
p += strlen( p )+1;
|
||||
p += strlen( p )+1;
|
||||
ds = p-s;
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
char msg[] = "unknown type: 000000000000";
|
||||
bson_numstr( msg+14, ( unsigned )( i->cur[0] ) );
|
||||
bson_fatal_msg( 0, msg );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
i->cur += 1 + strlen( i->cur + 1 ) + 1 + ds;
|
||||
|
||||
return ( bson_type )( *i->cur );
|
||||
}
|
||||
|
||||
bson_type bson_iterator_type( const bson_iterator *i ) {
|
||||
return ( bson_type )i->cur[0];
|
||||
}
|
||||
|
||||
const char *bson_iterator_key( const bson_iterator *i ) {
|
||||
return i->cur + 1;
|
||||
}
|
||||
|
||||
const char *bson_iterator_value( const bson_iterator *i ) {
|
||||
const char *t = i->cur + 1;
|
||||
t += strlen( t ) + 1;
|
||||
return t;
|
||||
}
|
||||
|
||||
/* types */
|
||||
|
||||
int bson_iterator_int_raw( const bson_iterator *i ) {
|
||||
int out;
|
||||
bson_little_endian32( &out, bson_iterator_value( i ) );
|
||||
return out;
|
||||
}
|
||||
|
||||
double bson_iterator_double_raw( const bson_iterator *i ) {
|
||||
double out;
|
||||
bson_little_endian64( &out, bson_iterator_value( i ) );
|
||||
return out;
|
||||
}
|
||||
|
||||
int64_t bson_iterator_long_raw( const bson_iterator *i ) {
|
||||
int64_t out;
|
||||
bson_little_endian64( &out, bson_iterator_value( i ) );
|
||||
return out;
|
||||
}
|
||||
|
||||
bson_bool_t bson_iterator_bool_raw( const bson_iterator *i ) {
|
||||
return bson_iterator_value( i )[0];
|
||||
}
|
||||
|
||||
bson_oid_t *bson_iterator_oid( const bson_iterator *i ) {
|
||||
return ( bson_oid_t * )bson_iterator_value( i );
|
||||
}
|
||||
|
||||
int bson_iterator_int( const bson_iterator *i ) {
|
||||
switch ( bson_iterator_type( i ) ) {
|
||||
case BSON_INT:
|
||||
return bson_iterator_int_raw( i );
|
||||
case BSON_LONG:
|
||||
return bson_iterator_long_raw( i );
|
||||
case BSON_DOUBLE:
|
||||
return bson_iterator_double_raw( i );
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
double bson_iterator_double( const bson_iterator *i ) {
|
||||
switch ( bson_iterator_type( i ) ) {
|
||||
case BSON_INT:
|
||||
return bson_iterator_int_raw( i );
|
||||
case BSON_LONG:
|
||||
return bson_iterator_long_raw( i );
|
||||
case BSON_DOUBLE:
|
||||
return bson_iterator_double_raw( i );
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int64_t bson_iterator_long( const bson_iterator *i ) {
|
||||
switch ( bson_iterator_type( i ) ) {
|
||||
case BSON_INT:
|
||||
return bson_iterator_int_raw( i );
|
||||
case BSON_LONG:
|
||||
return bson_iterator_long_raw( i );
|
||||
case BSON_DOUBLE:
|
||||
return bson_iterator_double_raw( i );
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bson_timestamp_t bson_iterator_timestamp( const bson_iterator *i ) {
|
||||
bson_timestamp_t ts;
|
||||
bson_little_endian32( &( ts.i ), bson_iterator_value( i ) );
|
||||
bson_little_endian32( &( ts.t ), bson_iterator_value( i ) + 4 );
|
||||
return ts;
|
||||
}
|
||||
|
||||
bson_bool_t bson_iterator_bool( const bson_iterator *i ) {
|
||||
switch ( bson_iterator_type( i ) ) {
|
||||
case BSON_BOOL:
|
||||
return bson_iterator_bool_raw( i );
|
||||
case BSON_INT:
|
||||
return bson_iterator_int_raw( i ) != 0;
|
||||
case BSON_LONG:
|
||||
return bson_iterator_long_raw( i ) != 0;
|
||||
case BSON_DOUBLE:
|
||||
return bson_iterator_double_raw( i ) != 0;
|
||||
case BSON_EOO:
|
||||
case BSON_NULL:
|
||||
return 0;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
const char *bson_iterator_string( const bson_iterator *i ) {
|
||||
return bson_iterator_value( i ) + 4;
|
||||
}
|
||||
|
||||
int bson_iterator_string_len( const bson_iterator *i ) {
|
||||
return bson_iterator_int_raw( i );
|
||||
}
|
||||
|
||||
const char *bson_iterator_code( const bson_iterator *i ) {
|
||||
switch ( bson_iterator_type( i ) ) {
|
||||
case BSON_STRING:
|
||||
case BSON_CODE:
|
||||
return bson_iterator_value( i ) + 4;
|
||||
case BSON_CODEWSCOPE:
|
||||
return bson_iterator_value( i ) + 8;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void bson_iterator_code_scope( const bson_iterator *i, bson *scope ) {
|
||||
if ( bson_iterator_type( i ) == BSON_CODEWSCOPE ) {
|
||||
int code_len;
|
||||
bson_little_endian32( &code_len, bson_iterator_value( i )+4 );
|
||||
bson_init_data( scope, ( void * )( bson_iterator_value( i )+8+code_len ) );
|
||||
} else {
|
||||
bson_empty( scope );
|
||||
}
|
||||
}
|
||||
|
||||
bson_date_t bson_iterator_date( const bson_iterator *i ) {
|
||||
return bson_iterator_long_raw( i );
|
||||
}
|
||||
|
||||
time_t bson_iterator_time_t( const bson_iterator *i ) {
|
||||
return bson_iterator_date( i ) / 1000;
|
||||
}
|
||||
|
||||
int bson_iterator_bin_len( const bson_iterator *i ) {
|
||||
return ( bson_iterator_bin_type( i ) == BSON_BIN_BINARY_OLD )
|
||||
? bson_iterator_int_raw( i ) - 4
|
||||
: bson_iterator_int_raw( i );
|
||||
}
|
||||
|
||||
char bson_iterator_bin_type( const bson_iterator *i ) {
|
||||
return bson_iterator_value( i )[4];
|
||||
}
|
||||
|
||||
const char *bson_iterator_bin_data( const bson_iterator *i ) {
|
||||
return ( bson_iterator_bin_type( i ) == BSON_BIN_BINARY_OLD )
|
||||
? bson_iterator_value( i ) + 9
|
||||
: bson_iterator_value( i ) + 5;
|
||||
}
|
||||
|
||||
const char *bson_iterator_regex( const bson_iterator *i ) {
|
||||
return bson_iterator_value( i );
|
||||
}
|
||||
|
||||
const char *bson_iterator_regex_opts( const bson_iterator *i ) {
|
||||
const char *p = bson_iterator_value( i );
|
||||
return p + strlen( p ) + 1;
|
||||
|
||||
}
|
||||
|
||||
void bson_iterator_subobject( const bson_iterator *i, bson *sub ) {
|
||||
bson_init_data( sub, ( char * )bson_iterator_value( i ) );
|
||||
_bson_reset( sub );
|
||||
sub->finished = 1;
|
||||
}
|
||||
|
||||
void bson_iterator_subiterator( const bson_iterator *i, bson_iterator *sub ) {
|
||||
bson_iterator_from_buffer( sub, bson_iterator_value( i ) );
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
BUILDING
|
||||
------------------------------ */
|
||||
|
||||
static void _bson_init_size( bson *b, int size ) {
|
||||
if( size == 0 )
|
||||
b->data = NULL;
|
||||
else
|
||||
b->data = ( char * )bson_malloc( size );
|
||||
b->dataSize = size;
|
||||
b->cur = b->data + 4;
|
||||
_bson_reset( b );
|
||||
}
|
||||
|
||||
void bson_init( bson *b ) {
|
||||
_bson_init_size( b, initialBufferSize );
|
||||
}
|
||||
|
||||
void bson_init_size( bson *b, int size ) {
|
||||
_bson_init_size( b, size );
|
||||
}
|
||||
|
||||
void bson_append_byte( bson *b, char c ) {
|
||||
b->cur[0] = c;
|
||||
b->cur++;
|
||||
}
|
||||
|
||||
void bson_append( bson *b, const void *data, int len ) {
|
||||
memcpy( b->cur , data , len );
|
||||
b->cur += len;
|
||||
}
|
||||
|
||||
void bson_append32( bson *b, const void *data ) {
|
||||
bson_little_endian32( b->cur, data );
|
||||
b->cur += 4;
|
||||
}
|
||||
|
||||
void bson_append64( bson *b, const void *data ) {
|
||||
bson_little_endian64( b->cur, data );
|
||||
b->cur += 8;
|
||||
}
|
||||
|
||||
int bson_ensure_space( bson *b, const int bytesNeeded ) {
|
||||
int pos = b->cur - b->data;
|
||||
char *orig = b->data;
|
||||
int new_size;
|
||||
|
||||
if ( pos + bytesNeeded <= b->dataSize )
|
||||
return BSON_OK;
|
||||
|
||||
new_size = 1.5 * ( b->dataSize + bytesNeeded );
|
||||
|
||||
if( new_size < b->dataSize ) {
|
||||
if( ( b->dataSize + bytesNeeded ) < INT_MAX )
|
||||
new_size = INT_MAX;
|
||||
else {
|
||||
b->err = BSON_SIZE_OVERFLOW;
|
||||
return BSON_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
b->data = bson_realloc( b->data, new_size );
|
||||
if ( !b->data )
|
||||
bson_fatal_msg( !!b->data, "realloc() failed" );
|
||||
|
||||
b->dataSize = new_size;
|
||||
b->cur += b->data - orig;
|
||||
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_finish( bson *b ) {
|
||||
int i;
|
||||
|
||||
if( b->err & BSON_NOT_UTF8 )
|
||||
return BSON_ERROR;
|
||||
|
||||
if ( ! b->finished ) {
|
||||
if ( bson_ensure_space( b, 1 ) == BSON_ERROR ) return BSON_ERROR;
|
||||
bson_append_byte( b, 0 );
|
||||
i = b->cur - b->data;
|
||||
bson_little_endian32( b->data, &i );
|
||||
b->finished = 1;
|
||||
}
|
||||
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
void bson_destroy( bson *b ) {
|
||||
bson_free( b->data );
|
||||
b->err = 0;
|
||||
b->data = 0;
|
||||
b->cur = 0;
|
||||
b->finished = 1;
|
||||
}
|
||||
|
||||
static int bson_append_estart( bson *b, int type, const char *name, const int dataSize ) {
|
||||
const int len = strlen( name ) + 1;
|
||||
|
||||
if ( b->finished ) {
|
||||
b->err |= BSON_ALREADY_FINISHED;
|
||||
return BSON_ERROR;
|
||||
}
|
||||
|
||||
if ( bson_ensure_space( b, 1 + len + dataSize ) == BSON_ERROR ) {
|
||||
return BSON_ERROR;
|
||||
}
|
||||
|
||||
if( bson_check_field_name( b, ( const char * )name, len - 1 ) == BSON_ERROR ) {
|
||||
bson_builder_error( b );
|
||||
return BSON_ERROR;
|
||||
}
|
||||
|
||||
bson_append_byte( b, ( char )type );
|
||||
bson_append( b, name, len );
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
BUILDING TYPES
|
||||
------------------------------ */
|
||||
|
||||
int bson_append_int( bson *b, const char *name, const int i ) {
|
||||
if ( bson_append_estart( b, BSON_INT, name, 4 ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
bson_append32( b , &i );
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_long( bson *b, const char *name, const int64_t i ) {
|
||||
if ( bson_append_estart( b , BSON_LONG, name, 8 ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
bson_append64( b , &i );
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_double( bson *b, const char *name, const double d ) {
|
||||
if ( bson_append_estart( b, BSON_DOUBLE, name, 8 ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
bson_append64( b , &d );
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_bool( bson *b, const char *name, const bson_bool_t i ) {
|
||||
if ( bson_append_estart( b, BSON_BOOL, name, 1 ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
bson_append_byte( b , i != 0 );
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_null( bson *b, const char *name ) {
|
||||
if ( bson_append_estart( b , BSON_NULL, name, 0 ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_undefined( bson *b, const char *name ) {
|
||||
if ( bson_append_estart( b, BSON_UNDEFINED, name, 0 ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_string_base( bson *b, const char *name,
|
||||
const char *value, int len, bson_type type ) {
|
||||
|
||||
int sl = len + 1;
|
||||
if ( bson_check_string( b, ( const char * )value, sl - 1 ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
if ( bson_append_estart( b, type, name, 4 + sl ) == BSON_ERROR ) {
|
||||
return BSON_ERROR;
|
||||
}
|
||||
bson_append32( b , &sl );
|
||||
bson_append( b , value , sl - 1 );
|
||||
bson_append( b , "\0" , 1 );
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_string( bson *b, const char *name, const char *value ) {
|
||||
return bson_append_string_base( b, name, value, strlen ( value ), BSON_STRING );
|
||||
}
|
||||
|
||||
int bson_append_symbol( bson *b, const char *name, const char *value ) {
|
||||
return bson_append_string_base( b, name, value, strlen ( value ), BSON_SYMBOL );
|
||||
}
|
||||
|
||||
int bson_append_code( bson *b, const char *name, const char *value ) {
|
||||
return bson_append_string_base( b, name, value, strlen ( value ), BSON_CODE );
|
||||
}
|
||||
|
||||
int bson_append_string_n( bson *b, const char *name, const char *value, int len ) {
|
||||
return bson_append_string_base( b, name, value, len, BSON_STRING );
|
||||
}
|
||||
|
||||
int bson_append_symbol_n( bson *b, const char *name, const char *value, int len ) {
|
||||
return bson_append_string_base( b, name, value, len, BSON_SYMBOL );
|
||||
}
|
||||
|
||||
int bson_append_code_n( bson *b, const char *name, const char *value, int len ) {
|
||||
return bson_append_string_base( b, name, value, len, BSON_CODE );
|
||||
}
|
||||
|
||||
int bson_append_code_w_scope_n( bson *b, const char *name,
|
||||
const char *code, int len, const bson *scope ) {
|
||||
|
||||
int sl = len + 1;
|
||||
int size = 4 + 4 + sl + bson_size( scope );
|
||||
if ( bson_append_estart( b, BSON_CODEWSCOPE, name, size ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
bson_append32( b, &size );
|
||||
bson_append32( b, &sl );
|
||||
bson_append( b, code, sl );
|
||||
bson_append( b, scope->data, bson_size( scope ) );
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_code_w_scope( bson *b, const char *name, const char *code, const bson *scope ) {
|
||||
return bson_append_code_w_scope_n( b, name, code, strlen ( code ), scope );
|
||||
}
|
||||
|
||||
int bson_append_binary( bson *b, const char *name, char type, const char *str, int len ) {
|
||||
if ( type == BSON_BIN_BINARY_OLD ) {
|
||||
int subtwolen = len + 4;
|
||||
if ( bson_append_estart( b, BSON_BINDATA, name, 4+1+4+len ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
bson_append32( b, &subtwolen );
|
||||
bson_append_byte( b, type );
|
||||
bson_append32( b, &len );
|
||||
bson_append( b, str, len );
|
||||
} else {
|
||||
if ( bson_append_estart( b, BSON_BINDATA, name, 4+1+len ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
bson_append32( b, &len );
|
||||
bson_append_byte( b, type );
|
||||
bson_append( b, str, len );
|
||||
}
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_oid( bson *b, const char *name, const bson_oid_t *oid ) {
|
||||
if ( bson_append_estart( b, BSON_OID, name, 12 ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
bson_append( b , oid , 12 );
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_new_oid( bson *b, const char *name ) {
|
||||
bson_oid_t oid;
|
||||
bson_oid_gen( &oid );
|
||||
return bson_append_oid( b, name, &oid );
|
||||
}
|
||||
|
||||
int bson_append_regex( bson *b, const char *name, const char *pattern, const char *opts ) {
|
||||
const int plen = strlen( pattern )+1;
|
||||
const int olen = strlen( opts )+1;
|
||||
if ( bson_append_estart( b, BSON_REGEX, name, plen + olen ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
if ( bson_check_string( b, pattern, plen - 1 ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
bson_append( b , pattern , plen );
|
||||
bson_append( b , opts , olen );
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_bson( bson *b, const char *name, const bson *bson ) {
|
||||
if ( bson_append_estart( b, BSON_OBJECT, name, bson_size( bson ) ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
bson_append( b , bson->data , bson_size( bson ) );
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_element( bson *b, const char *name_or_null, const bson_iterator *elem ) {
|
||||
bson_iterator next = *elem;
|
||||
int size;
|
||||
|
||||
bson_iterator_next( &next );
|
||||
size = next.cur - elem->cur;
|
||||
|
||||
if ( name_or_null == NULL ) {
|
||||
if( bson_ensure_space( b, size ) == BSON_ERROR )
|
||||
return BSON_ERROR;
|
||||
bson_append( b, elem->cur, size );
|
||||
} else {
|
||||
int data_size = size - 2 - strlen( bson_iterator_key( elem ) );
|
||||
bson_append_estart( b, elem->cur[0], name_or_null, data_size );
|
||||
bson_append( b, bson_iterator_value( elem ), data_size );
|
||||
}
|
||||
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_timestamp( bson *b, const char *name, bson_timestamp_t *ts ) {
|
||||
if ( bson_append_estart( b, BSON_TIMESTAMP, name, 8 ) == BSON_ERROR ) return BSON_ERROR;
|
||||
|
||||
bson_append32( b , &( ts->i ) );
|
||||
bson_append32( b , &( ts->t ) );
|
||||
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_date( bson *b, const char *name, bson_date_t millis ) {
|
||||
if ( bson_append_estart( b, BSON_DATE, name, 8 ) == BSON_ERROR ) return BSON_ERROR;
|
||||
bson_append64( b , &millis );
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_time_t( bson *b, const char *name, time_t secs ) {
|
||||
return bson_append_date( b, name, ( bson_date_t )secs * 1000 );
|
||||
}
|
||||
|
||||
int bson_append_start_object( bson *b, const char *name ) {
|
||||
if ( bson_append_estart( b, BSON_OBJECT, name, 5 ) == BSON_ERROR ) return BSON_ERROR;
|
||||
b->stack[ b->stackPos++ ] = b->cur - b->data;
|
||||
bson_append32( b , &zero );
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_start_array( bson *b, const char *name ) {
|
||||
if ( bson_append_estart( b, BSON_ARRAY, name, 5 ) == BSON_ERROR ) return BSON_ERROR;
|
||||
b->stack[ b->stackPos++ ] = b->cur - b->data;
|
||||
bson_append32( b , &zero );
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_finish_object( bson *b ) {
|
||||
char *start;
|
||||
int i;
|
||||
if ( bson_ensure_space( b, 1 ) == BSON_ERROR ) return BSON_ERROR;
|
||||
bson_append_byte( b , 0 );
|
||||
|
||||
start = b->data + b->stack[ --b->stackPos ];
|
||||
i = b->cur - start;
|
||||
bson_little_endian32( start, &i );
|
||||
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
int bson_append_finish_array( bson *b ) {
|
||||
return bson_append_finish_object( b );
|
||||
}
|
||||
|
||||
|
||||
/* Error handling and allocators. */
|
||||
|
||||
static bson_err_handler err_handler = NULL;
|
||||
|
||||
bson_err_handler set_bson_err_handler( bson_err_handler func ) {
|
||||
bson_err_handler old = err_handler;
|
||||
err_handler = func;
|
||||
return old;
|
||||
}
|
||||
|
||||
void *bson_malloc( int size ) {
|
||||
void *p;
|
||||
p = bson_malloc_func( size );
|
||||
bson_fatal_msg( !!p, "malloc() failed" );
|
||||
return p;
|
||||
}
|
||||
|
||||
void *bson_realloc( void *ptr, int size ) {
|
||||
void *p;
|
||||
p = bson_realloc_func( ptr, size );
|
||||
bson_fatal_msg( !!p, "realloc() failed" );
|
||||
return p;
|
||||
}
|
||||
|
||||
int _bson_errprintf( const char *format, ... ) {
|
||||
va_list ap;
|
||||
int ret;
|
||||
va_start( ap, format );
|
||||
ret = vfprintf( stderr, format, ap );
|
||||
va_end( ap );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is invoked when a non-fatal bson error is encountered.
|
||||
* Calls the error handler if available.
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
void bson_builder_error( bson *b ) {
|
||||
if( err_handler )
|
||||
err_handler( "BSON error." );
|
||||
}
|
||||
|
||||
void bson_fatal( int ok ) {
|
||||
bson_fatal_msg( ok, "" );
|
||||
}
|
||||
|
||||
void bson_fatal_msg( int ok , const char *msg ) {
|
||||
if ( ok )
|
||||
return;
|
||||
|
||||
if ( err_handler ) {
|
||||
err_handler( msg );
|
||||
}
|
||||
|
||||
bson_errprintf( "error: %s\n" , msg );
|
||||
exit( -5 );
|
||||
}
|
||||
|
||||
|
||||
/* Efficiently copy an integer to a string. */
|
||||
extern const char bson_numstrs[1000][4];
|
||||
|
||||
void bson_numstr( char *str, int i ) {
|
||||
if( i < 1000 )
|
||||
memcpy( str, bson_numstrs[i], 4 );
|
||||
else
|
||||
bson_sprintf( str,"%d", i );
|
||||
}
|
||||
@@ -0,0 +1,975 @@
|
||||
/**
|
||||
* @file bson.h
|
||||
* @brief BSON Declarations
|
||||
*/
|
||||
|
||||
/* Copyright 2009-2011 10gen Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _BSON_H_
|
||||
#define _BSON_H_
|
||||
|
||||
#include "platform.h"
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
MONGO_EXTERN_C_START
|
||||
|
||||
#define BSON_OK 0
|
||||
#define BSON_ERROR -1
|
||||
|
||||
enum bson_error_t {
|
||||
BSON_SIZE_OVERFLOW = 1 /**< Trying to create a BSON object larger than INT_MAX. */
|
||||
};
|
||||
|
||||
enum bson_validity_t {
|
||||
BSON_VALID = 0, /**< BSON is valid and UTF-8 compliant. */
|
||||
BSON_NOT_UTF8 = ( 1<<1 ), /**< A key or a string is not valid UTF-8. */
|
||||
BSON_FIELD_HAS_DOT = ( 1<<2 ), /**< Warning: key contains '.' character. */
|
||||
BSON_FIELD_INIT_DOLLAR = ( 1<<3 ), /**< Warning: key starts with '$' character. */
|
||||
BSON_ALREADY_FINISHED = ( 1<<4 ) /**< Trying to modify a finished BSON object. */
|
||||
};
|
||||
|
||||
enum bson_binary_subtype_t {
|
||||
BSON_BIN_BINARY = 0,
|
||||
BSON_BIN_FUNC = 1,
|
||||
BSON_BIN_BINARY_OLD = 2,
|
||||
BSON_BIN_UUID = 3,
|
||||
BSON_BIN_MD5 = 5,
|
||||
BSON_BIN_USER = 128
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
BSON_EOO = 0,
|
||||
BSON_DOUBLE = 1,
|
||||
BSON_STRING = 2,
|
||||
BSON_OBJECT = 3,
|
||||
BSON_ARRAY = 4,
|
||||
BSON_BINDATA = 5,
|
||||
BSON_UNDEFINED = 6,
|
||||
BSON_OID = 7,
|
||||
BSON_BOOL = 8,
|
||||
BSON_DATE = 9,
|
||||
BSON_NULL = 10,
|
||||
BSON_REGEX = 11,
|
||||
BSON_DBREF = 12, /**< Deprecated. */
|
||||
BSON_CODE = 13,
|
||||
BSON_SYMBOL = 14,
|
||||
BSON_CODEWSCOPE = 15,
|
||||
BSON_INT = 16,
|
||||
BSON_TIMESTAMP = 17,
|
||||
BSON_LONG = 18
|
||||
} bson_type;
|
||||
|
||||
typedef int bson_bool_t;
|
||||
|
||||
typedef struct {
|
||||
const char *cur;
|
||||
bson_bool_t first;
|
||||
} bson_iterator;
|
||||
|
||||
typedef struct {
|
||||
char *data;
|
||||
char *cur;
|
||||
int dataSize;
|
||||
bson_bool_t finished;
|
||||
int stack[32];
|
||||
int stackPos;
|
||||
int err; /**< Bitfield representing errors or warnings on this buffer */
|
||||
char *errstr; /**< A string representation of the most recent error or warning. */
|
||||
} bson;
|
||||
|
||||
#pragma pack(1)
|
||||
typedef union {
|
||||
char bytes[12];
|
||||
int ints[3];
|
||||
} bson_oid_t;
|
||||
#pragma pack()
|
||||
|
||||
typedef int64_t bson_date_t; /* milliseconds since epoch UTC */
|
||||
|
||||
typedef struct {
|
||||
int i; /* increment */
|
||||
int t; /* time in seconds */
|
||||
} bson_timestamp_t;
|
||||
|
||||
/* ----------------------------
|
||||
READING
|
||||
------------------------------ */
|
||||
|
||||
/**
|
||||
* Size of a BSON object.
|
||||
*
|
||||
* @param b the BSON object.
|
||||
*
|
||||
* @return the size.
|
||||
*/
|
||||
int bson_size( const bson *b );
|
||||
|
||||
/**
|
||||
* Print a string representation of a BSON object.
|
||||
*
|
||||
* @param b the BSON object to print.
|
||||
*/
|
||||
void bson_print( bson *b );
|
||||
|
||||
/**
|
||||
* Return a pointer to the raw buffer stored by this bson object.
|
||||
*
|
||||
* @param b a BSON object
|
||||
*/
|
||||
const char *bson_data( bson *b );
|
||||
|
||||
/**
|
||||
* Print a string representation of a BSON object.
|
||||
*
|
||||
* @param bson the raw data to print.
|
||||
* @param depth the depth to recurse the object.x
|
||||
*/
|
||||
void bson_print_raw( const char *bson , int depth );
|
||||
|
||||
/**
|
||||
* Advance a bson_iterator to the named field.
|
||||
*
|
||||
* @param it the bson_iterator to use.
|
||||
* @param obj the BSON object to use.
|
||||
* @param name the name of the field to find.
|
||||
*
|
||||
* @return the type of the found object or BSON_EOO if it is not found.
|
||||
*/
|
||||
bson_type bson_find( bson_iterator *it, const bson *obj, const char *name );
|
||||
|
||||
/**
|
||||
* Initialize a bson_iterator.
|
||||
*
|
||||
* @param i the bson_iterator to initialize.
|
||||
* @param bson the BSON object to associate with the iterator.
|
||||
*/
|
||||
void bson_iterator_init( bson_iterator *i , const bson *b );
|
||||
|
||||
/**
|
||||
* Initialize a bson iterator from a const char* buffer. Note
|
||||
* that this is mostly used internally.
|
||||
*
|
||||
* @param i the bson_iterator to initialize.
|
||||
* @param buffer the buffer to point to.
|
||||
*/
|
||||
void bson_iterator_from_buffer( bson_iterator *i, const char *buffer );
|
||||
|
||||
/* more returns true for eoo. best to loop with bson_iterator_next(&it) */
|
||||
/**
|
||||
* Check to see if the bson_iterator has more data.
|
||||
*
|
||||
* @param i the iterator.
|
||||
*
|
||||
* @return returns true if there is more data.
|
||||
*/
|
||||
bson_bool_t bson_iterator_more( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Point the iterator at the next BSON object.
|
||||
*
|
||||
* @param i the bson_iterator.
|
||||
*
|
||||
* @return the type of the next BSON object.
|
||||
*/
|
||||
bson_type bson_iterator_next( bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the type of the BSON object currently pointed to by the iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the type of the current BSON object.
|
||||
*/
|
||||
bson_type bson_iterator_type( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the key of the BSON object currently pointed to by the iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the key of the current BSON object.
|
||||
*/
|
||||
const char *bson_iterator_key( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the value of the BSON object currently pointed to by the iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON object.
|
||||
*/
|
||||
const char *bson_iterator_value( const bson_iterator *i );
|
||||
|
||||
/* these convert to the right type (return 0 if non-numeric) */
|
||||
/**
|
||||
* Get the double value of the BSON object currently pointed to by the
|
||||
* iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON object.
|
||||
*/
|
||||
double bson_iterator_double( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the int value of the BSON object currently pointed to by the iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON object.
|
||||
*/
|
||||
int bson_iterator_int( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the long value of the BSON object currently pointed to by the iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON object.
|
||||
*/
|
||||
int64_t bson_iterator_long( const bson_iterator *i );
|
||||
|
||||
/* return the bson timestamp as a whole or in parts */
|
||||
/**
|
||||
* Get the timestamp value of the BSON object currently pointed to by
|
||||
* the iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON object.
|
||||
*/
|
||||
bson_timestamp_t bson_iterator_timestamp( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the boolean value of the BSON object currently pointed to by
|
||||
* the iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON object.
|
||||
*/
|
||||
/* false: boolean false, 0 in any type, or null */
|
||||
/* true: anything else (even empty strings and objects) */
|
||||
bson_bool_t bson_iterator_bool( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the double value of the BSON object currently pointed to by the
|
||||
* iterator. Assumes the correct type is used.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON object.
|
||||
*/
|
||||
/* these assume you are using the right type */
|
||||
double bson_iterator_double_raw( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the int value of the BSON object currently pointed to by the
|
||||
* iterator. Assumes the correct type is used.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON object.
|
||||
*/
|
||||
int bson_iterator_int_raw( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the long value of the BSON object currently pointed to by the
|
||||
* iterator. Assumes the correct type is used.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON object.
|
||||
*/
|
||||
int64_t bson_iterator_long_raw( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the bson_bool_t value of the BSON object currently pointed to by the
|
||||
* iterator. Assumes the correct type is used.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON object.
|
||||
*/
|
||||
bson_bool_t bson_iterator_bool_raw( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the bson_oid_t value of the BSON object currently pointed to by the
|
||||
* iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON object.
|
||||
*/
|
||||
bson_oid_t *bson_iterator_oid( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the string value of the BSON object currently pointed to by the
|
||||
* iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON object.
|
||||
*/
|
||||
/* these can also be used with bson_code and bson_symbol*/
|
||||
const char *bson_iterator_string( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the string length of the BSON object currently pointed to by the
|
||||
* iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the length of the current BSON object.
|
||||
*/
|
||||
int bson_iterator_string_len( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the code value of the BSON object currently pointed to by the
|
||||
* iterator. Works with bson_code, bson_codewscope, and BSON_STRING
|
||||
* returns NULL for everything else.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the code value of the current BSON object.
|
||||
*/
|
||||
/* works with bson_code, bson_codewscope, and BSON_STRING */
|
||||
/* returns NULL for everything else */
|
||||
const char *bson_iterator_code( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Calls bson_empty on scope if not a bson_codewscope
|
||||
*
|
||||
* @param i the bson_iterator.
|
||||
* @param scope the bson scope.
|
||||
*/
|
||||
/* calls bson_empty on scope if not a bson_codewscope */
|
||||
void bson_iterator_code_scope( const bson_iterator *i, bson *scope );
|
||||
|
||||
/**
|
||||
* Get the date value of the BSON object currently pointed to by the
|
||||
* iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the date value of the current BSON object.
|
||||
*/
|
||||
/* both of these only work with bson_date */
|
||||
bson_date_t bson_iterator_date( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the time value of the BSON object currently pointed to by the
|
||||
* iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the time value of the current BSON object.
|
||||
*/
|
||||
time_t bson_iterator_time_t( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the length of the BSON binary object currently pointed to by the
|
||||
* iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the length of the current BSON binary object.
|
||||
*/
|
||||
int bson_iterator_bin_len( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the type of the BSON binary object currently pointed to by the
|
||||
* iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the type of the current BSON binary object.
|
||||
*/
|
||||
char bson_iterator_bin_type( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the value of the BSON binary object currently pointed to by the
|
||||
* iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON binary object.
|
||||
*/
|
||||
const char *bson_iterator_bin_data( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the value of the BSON regex object currently pointed to by the
|
||||
* iterator.
|
||||
*
|
||||
* @param i the bson_iterator
|
||||
*
|
||||
* @return the value of the current BSON regex object.
|
||||
*/
|
||||
const char *bson_iterator_regex( const bson_iterator *i );
|
||||
|
||||
/**
|
||||
* Get the options of the BSON regex object currently pointed to by the
|
||||
* iterator.
|
||||
*
|
||||
* @param i the bson_iterator.
|
||||
*
|
||||
* @return the options of the current BSON regex object.
|
||||
*/
|
||||
const char *bson_iterator_regex_opts( const bson_iterator *i );
|
||||
|
||||
/* these work with BSON_OBJECT and BSON_ARRAY */
|
||||
/**
|
||||
* Get the BSON subobject currently pointed to by the
|
||||
* iterator.
|
||||
*
|
||||
* @param i the bson_iterator.
|
||||
* @param sub the BSON subobject destination.
|
||||
*/
|
||||
void bson_iterator_subobject( const bson_iterator *i, bson *sub );
|
||||
|
||||
/**
|
||||
* Get a bson_iterator that on the BSON subobject.
|
||||
*
|
||||
* @param i the bson_iterator.
|
||||
* @param sub the iterator to point at the BSON subobject.
|
||||
*/
|
||||
void bson_iterator_subiterator( const bson_iterator *i, bson_iterator *sub );
|
||||
|
||||
/* str must be at least 24 hex chars + null byte */
|
||||
/**
|
||||
* Create a bson_oid_t from a string.
|
||||
*
|
||||
* @param oid the bson_oid_t destination.
|
||||
* @param str a null terminated string comprised of at least 24 hex chars.
|
||||
*/
|
||||
void bson_oid_from_string( bson_oid_t *oid, const char *str );
|
||||
|
||||
/**
|
||||
* Create a string representation of the bson_oid_t.
|
||||
*
|
||||
* @param oid the bson_oid_t source.
|
||||
* @param str the string representation destination.
|
||||
*/
|
||||
void bson_oid_to_string( const bson_oid_t *oid, char *str );
|
||||
|
||||
/**
|
||||
* Create a bson_oid object.
|
||||
*
|
||||
* @param oid the destination for the newly created bson_oid_t.
|
||||
*/
|
||||
void bson_oid_gen( bson_oid_t *oid );
|
||||
|
||||
/**
|
||||
* Set a function to be used to generate the second four bytes
|
||||
* of an object id.
|
||||
*
|
||||
* @param func a pointer to a function that returns an int.
|
||||
*/
|
||||
void bson_set_oid_fuzz( int ( *func )( void ) );
|
||||
|
||||
/**
|
||||
* Set a function to be used to generate the incrementing part
|
||||
* of an object id (last four bytes). If you need thread-safety
|
||||
* in generating object ids, you should set this function.
|
||||
*
|
||||
* @param func a pointer to a function that returns an int.
|
||||
*/
|
||||
void bson_set_oid_inc( int ( *func )( void ) );
|
||||
|
||||
/**
|
||||
* Get the time a bson_oid_t was created.
|
||||
*
|
||||
* @param oid the bson_oid_t.
|
||||
*/
|
||||
time_t bson_oid_generated_time( bson_oid_t *oid ); /* Gives the time the OID was created */
|
||||
|
||||
/* ----------------------------
|
||||
BUILDING
|
||||
------------------------------ */
|
||||
|
||||
/**
|
||||
* Initialize a new bson object. If not created
|
||||
* with bson_new, you must initialize each new bson
|
||||
* object using this function.
|
||||
*
|
||||
* @note When finished, you must pass the bson object to
|
||||
* bson_destroy( ).
|
||||
*/
|
||||
void bson_init( bson *b );
|
||||
|
||||
/**
|
||||
* Initialize a BSON object, and point its data
|
||||
* pointer to the provided char*.
|
||||
*
|
||||
* @param b the BSON object to initialize.
|
||||
* @param data the raw BSON data.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_init_data( bson *b , char *data );
|
||||
|
||||
/**
|
||||
* Initialize a BSON object, and set its
|
||||
* buffer to the given size.
|
||||
*
|
||||
* @param b the BSON object to initialize.
|
||||
* @param size the initial size of the buffer.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
void bson_init_size( bson *b, int size );
|
||||
|
||||
/**
|
||||
* Grow a bson object.
|
||||
*
|
||||
* @param b the bson to grow.
|
||||
* @param bytesNeeded the additional number of bytes needed.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR with the bson error object set.
|
||||
* Exits if allocation fails.
|
||||
*/
|
||||
int bson_ensure_space( bson *b, const int bytesNeeded );
|
||||
|
||||
/**
|
||||
* Finalize a bson object.
|
||||
*
|
||||
* @param b the bson object to finalize.
|
||||
*
|
||||
* @return the standard error code. To deallocate memory,
|
||||
* call bson_destroy on the bson object.
|
||||
*/
|
||||
int bson_finish( bson *b );
|
||||
|
||||
/**
|
||||
* Destroy a bson object.
|
||||
*
|
||||
* @param b the bson object to destroy.
|
||||
*
|
||||
*/
|
||||
void bson_destroy( bson *b );
|
||||
|
||||
/**
|
||||
* Returns a pointer to a static empty BSON object.
|
||||
*
|
||||
* @param obj the BSON object to initialize.
|
||||
*
|
||||
* @return the empty initialized BSON object.
|
||||
*/
|
||||
/* returns pointer to static empty bson object */
|
||||
bson *bson_empty( bson *obj );
|
||||
|
||||
/**
|
||||
* Copy BSON data only from one object to another.
|
||||
*
|
||||
* @param out the copy destination BSON object.
|
||||
* @param in the copy source BSON object.
|
||||
*/
|
||||
void bson_copy_basic( bson *out, const bson *in );
|
||||
|
||||
/**
|
||||
* Make a complete copy of the a BSON object.
|
||||
*
|
||||
* @param out the copy destination BSON object.
|
||||
* @param in the copy source BSON object.
|
||||
*/
|
||||
void bson_copy( bson *out, const bson *in ); /* puts data in new buffer. NOOP if out==NULL */
|
||||
|
||||
/**
|
||||
* Append a previously created bson_oid_t to a bson object.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the bson_oid_t.
|
||||
* @param oid the bson_oid_t to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_oid( bson *b, const char *name, const bson_oid_t *oid );
|
||||
|
||||
/**
|
||||
* Append a bson_oid_t to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the bson_oid_t.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_new_oid( bson *b, const char *name );
|
||||
|
||||
/**
|
||||
* Append an int to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the int.
|
||||
* @param i the int to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_int( bson *b, const char *name, const int i );
|
||||
|
||||
/**
|
||||
* Append an long to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the long.
|
||||
* @param i the long to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_long( bson *b, const char *name, const int64_t i );
|
||||
|
||||
/**
|
||||
* Append an double to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the double.
|
||||
* @param d the double to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_double( bson *b, const char *name, const double d );
|
||||
|
||||
/**
|
||||
* Append a string to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the string.
|
||||
* @param str the string to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_string( bson *b, const char *name, const char *str );
|
||||
|
||||
/**
|
||||
* Append len bytes of a string to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the string.
|
||||
* @param str the string to append.
|
||||
* @param len the number of bytes from str to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_string_n( bson *b, const char *name, const char *str, int len );
|
||||
|
||||
/**
|
||||
* Append a symbol to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the symbol.
|
||||
* @param str the symbol to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_symbol( bson *b, const char *name, const char *str );
|
||||
|
||||
/**
|
||||
* Append len bytes of a symbol to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the symbol.
|
||||
* @param str the symbol to append.
|
||||
* @param len the number of bytes from str to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_symbol_n( bson *b, const char *name, const char *str, int len );
|
||||
|
||||
/**
|
||||
* Append code to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the code.
|
||||
* @param str the code to append.
|
||||
* @param len the number of bytes from str to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_code( bson *b, const char *name, const char *str );
|
||||
|
||||
/**
|
||||
* Append len bytes of code to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the code.
|
||||
* @param str the code to append.
|
||||
* @param len the number of bytes from str to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_code_n( bson *b, const char *name, const char *str, int len );
|
||||
|
||||
/**
|
||||
* Append code to a bson with scope.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the code.
|
||||
* @param str the string to append.
|
||||
* @param scope a BSON object containing the scope.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_code_w_scope( bson *b, const char *name, const char *code, const bson *scope );
|
||||
|
||||
/**
|
||||
* Append len bytes of code to a bson with scope.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the code.
|
||||
* @param str the string to append.
|
||||
* @param len the number of bytes from str to append.
|
||||
* @param scope a BSON object containing the scope.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_code_w_scope_n( bson *b, const char *name, const char *code, int size, const bson *scope );
|
||||
|
||||
/**
|
||||
* Append binary data to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the data.
|
||||
* @param type the binary data type.
|
||||
* @param str the binary data.
|
||||
* @param len the length of the data.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_binary( bson *b, const char *name, char type, const char *str, int len );
|
||||
|
||||
/**
|
||||
* Append a bson_bool_t to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the boolean value.
|
||||
* @param v the bson_bool_t to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_bool( bson *b, const char *name, const bson_bool_t v );
|
||||
|
||||
/**
|
||||
* Append a null value to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the null value.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_null( bson *b, const char *name );
|
||||
|
||||
/**
|
||||
* Append an undefined value to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the undefined value.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_undefined( bson *b, const char *name );
|
||||
|
||||
/**
|
||||
* Append a regex value to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the regex value.
|
||||
* @param pattern the regex pattern to append.
|
||||
* @param the regex options.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_regex( bson *b, const char *name, const char *pattern, const char *opts );
|
||||
|
||||
/**
|
||||
* Append bson data to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the bson data.
|
||||
* @param bson the bson object to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_bson( bson *b, const char *name, const bson *bson );
|
||||
|
||||
/**
|
||||
* Append a BSON element to a bson from the current point of an iterator.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name_or_null the key for the BSON element, or NULL.
|
||||
* @param elem the bson_iterator.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_element( bson *b, const char *name_or_null, const bson_iterator *elem );
|
||||
|
||||
/**
|
||||
* Append a bson_timestamp_t value to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the timestampe value.
|
||||
* @param ts the bson_timestamp_t value to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_timestamp( bson *b, const char *name, bson_timestamp_t *ts );
|
||||
|
||||
/* these both append a bson_date */
|
||||
/**
|
||||
* Append a bson_date_t value to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the date value.
|
||||
* @param millis the bson_date_t to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_date( bson *b, const char *name, bson_date_t millis );
|
||||
|
||||
/**
|
||||
* Append a time_t value to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the key for the date value.
|
||||
* @param secs the time_t to append.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_time_t( bson *b, const char *name, time_t secs );
|
||||
|
||||
/**
|
||||
* Start appending a new object to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the name of the new object.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_start_object( bson *b, const char *name );
|
||||
|
||||
/**
|
||||
* Start appending a new array to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
* @param name the name of the new array.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_start_array( bson *b, const char *name );
|
||||
|
||||
/**
|
||||
* Finish appending a new object or array to a bson.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_finish_object( bson *b );
|
||||
|
||||
/**
|
||||
* Finish appending a new object or array to a bson. This
|
||||
* is simply an alias for bson_append_finish_object.
|
||||
*
|
||||
* @param b the bson to append to.
|
||||
*
|
||||
* @return BSON_OK or BSON_ERROR.
|
||||
*/
|
||||
int bson_append_finish_array( bson *b );
|
||||
|
||||
void bson_numstr( char *str, int i );
|
||||
|
||||
void bson_incnumstr( char *str );
|
||||
|
||||
/* Error handling and stadard library function over-riding. */
|
||||
/* -------------------------------------------------------- */
|
||||
|
||||
/* bson_err_handlers shouldn't return!!! */
|
||||
typedef void( *bson_err_handler )( const char *errmsg );
|
||||
|
||||
typedef int (*bson_printf_func)( const char *, ... );
|
||||
typedef int (*bson_fprintf_func)( FILE *, const char *, ... );
|
||||
typedef int (*bson_sprintf_func)( char *, const char *, ... );
|
||||
|
||||
extern void *( *bson_malloc_func )( size_t );
|
||||
extern void *( *bson_realloc_func )( void *, size_t );
|
||||
extern void ( *bson_free )( void * );
|
||||
|
||||
extern bson_printf_func bson_printf;
|
||||
extern bson_fprintf_func bson_fprintf;
|
||||
extern bson_sprintf_func bson_sprintf;
|
||||
|
||||
extern bson_printf_func bson_errprintf;
|
||||
|
||||
/**
|
||||
* Allocates memory and checks return value, exiting fatally if malloc() fails.
|
||||
*
|
||||
* @param size bytes to allocate.
|
||||
*
|
||||
* @return a pointer to the allocated memory.
|
||||
*
|
||||
* @sa malloc(3)
|
||||
*/
|
||||
void *bson_malloc( int size );
|
||||
|
||||
/**
|
||||
* Changes the size of allocated memory and checks return value,
|
||||
* exiting fatally if realloc() fails.
|
||||
*
|
||||
* @param ptr pointer to the space to reallocate.
|
||||
* @param size bytes to allocate.
|
||||
*
|
||||
* @return a pointer to the allocated memory.
|
||||
*
|
||||
* @sa realloc()
|
||||
*/
|
||||
void *bson_realloc( void *ptr, int size );
|
||||
|
||||
/**
|
||||
* Set a function for error handling.
|
||||
*
|
||||
* @param func a bson_err_handler function.
|
||||
*
|
||||
* @return the old error handling function, or NULL.
|
||||
*/
|
||||
bson_err_handler set_bson_err_handler( bson_err_handler func );
|
||||
|
||||
/* does nothing if ok != 0 */
|
||||
/**
|
||||
* Exit fatally.
|
||||
*
|
||||
* @param ok exits if ok is equal to 0.
|
||||
*/
|
||||
void bson_fatal( int ok );
|
||||
|
||||
/**
|
||||
* Exit fatally with an error message.
|
||||
*
|
||||
* @param ok exits if ok is equal to 0.
|
||||
* @param msg prints to stderr before exiting.
|
||||
*/
|
||||
void bson_fatal_msg( int ok, const char *msg );
|
||||
|
||||
/**
|
||||
* Invoke the error handler, but do not exit.
|
||||
*
|
||||
* @param b the buffer object.
|
||||
*/
|
||||
void bson_builder_error( bson *b );
|
||||
|
||||
MONGO_EXTERN_C_END
|
||||
#endif
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright 2009-2011 10gen, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright 2001 Unicode, Inc.
|
||||
*
|
||||
* Disclaimer
|
||||
*
|
||||
* This source code is provided as is by Unicode, Inc. No claims are
|
||||
* made as to fitness for any particular purpose. No warranties of any
|
||||
* kind are expressed or implied. The recipient agrees to determine
|
||||
* applicability of information provided. If this file has been
|
||||
* purchased on magnetic or optical media from Unicode, Inc., the
|
||||
* sole remedy for any claim will be exchange of defective media
|
||||
* within 90 days of receipt.
|
||||
*
|
||||
* Limitations on Rights to Redistribute This Code
|
||||
*
|
||||
* Unicode, Inc. hereby grants the right to freely use the information
|
||||
* supplied in this file in the creation of products supporting the
|
||||
* Unicode Standard, and to make copies of this file in any form
|
||||
* for internal or external distribution as long as this notice
|
||||
* remains attached.
|
||||
*/
|
||||
|
||||
|
||||
#include "bson.h"
|
||||
#include "encoding.h"
|
||||
|
||||
/*
|
||||
* Index into the table below with the first byte of a UTF-8 sequence to
|
||||
* get the number of trailing bytes that are supposed to follow it.
|
||||
*/
|
||||
static const char trailingBytesForUTF8[256] = {
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Utility routine to tell whether a sequence of bytes is legal UTF-8.
|
||||
* This must be called with the length pre-determined by the first byte.
|
||||
* The length can be set by:
|
||||
* length = trailingBytesForUTF8[*source]+1;
|
||||
* and the sequence is illegal right away if there aren't that many bytes
|
||||
* available.
|
||||
* If presented with a length > 4, this returns 0. The Unicode
|
||||
* definition of UTF-8 goes up to 4-byte sequences.
|
||||
*/
|
||||
static int isLegalUTF8( const unsigned char *source, int length ) {
|
||||
unsigned char a;
|
||||
const unsigned char *srcptr = source + length;
|
||||
switch ( length ) {
|
||||
default:
|
||||
return 0;
|
||||
/* Everything else falls through when "true"... */
|
||||
case 4:
|
||||
if ( ( a = ( *--srcptr ) ) < 0x80 || a > 0xBF ) return 0;
|
||||
case 3:
|
||||
if ( ( a = ( *--srcptr ) ) < 0x80 || a > 0xBF ) return 0;
|
||||
case 2:
|
||||
if ( ( a = ( *--srcptr ) ) > 0xBF ) return 0;
|
||||
switch ( *source ) {
|
||||
/* no fall-through in this inner switch */
|
||||
case 0xE0:
|
||||
if ( a < 0xA0 ) return 0;
|
||||
break;
|
||||
case 0xF0:
|
||||
if ( a < 0x90 ) return 0;
|
||||
break;
|
||||
case 0xF4:
|
||||
if ( a > 0x8F ) return 0;
|
||||
break;
|
||||
default:
|
||||
if ( a < 0x80 ) return 0;
|
||||
}
|
||||
case 1:
|
||||
if ( *source >= 0x80 && *source < 0xC2 ) return 0;
|
||||
if ( *source > 0xF4 ) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int bson_validate_string( bson *b, const unsigned char *string,
|
||||
const int length, const char check_utf8, const char check_dot,
|
||||
const char check_dollar ) {
|
||||
|
||||
int position = 0;
|
||||
int sequence_length = 1;
|
||||
|
||||
if( check_dollar && string[0] == '$' ) {
|
||||
b->err |= BSON_FIELD_INIT_DOLLAR;
|
||||
}
|
||||
|
||||
while ( position < length ) {
|
||||
if ( check_dot && *( string + position ) == '.' ) {
|
||||
b->err |= BSON_FIELD_HAS_DOT;
|
||||
}
|
||||
|
||||
if ( check_utf8 ) {
|
||||
sequence_length = trailingBytesForUTF8[*( string + position )] + 1;
|
||||
if ( ( position + sequence_length ) > length ) {
|
||||
b->err |= BSON_NOT_UTF8;
|
||||
return BSON_ERROR;
|
||||
}
|
||||
if ( !isLegalUTF8( string + position, sequence_length ) ) {
|
||||
b->err |= BSON_NOT_UTF8;
|
||||
return BSON_ERROR;
|
||||
}
|
||||
}
|
||||
position += sequence_length;
|
||||
}
|
||||
|
||||
return BSON_OK;
|
||||
}
|
||||
|
||||
|
||||
int bson_check_string( bson *b, const char *string,
|
||||
const int length ) {
|
||||
|
||||
return bson_validate_string( b, ( const unsigned char * )string, length, 1, 0, 0 );
|
||||
}
|
||||
|
||||
int bson_check_field_name( bson *b, const char *string,
|
||||
const int length ) {
|
||||
|
||||
return bson_validate_string( b, ( const unsigned char * )string, length, 1, 1, 1 );
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2009-2011 10gen, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _BSON_ENCODING_H_
|
||||
#define _BSON_ENCODING_H_
|
||||
|
||||
MONGO_EXTERN_C_START
|
||||
|
||||
/**
|
||||
* Check that a field name is valid UTF8, does not start with a '$',
|
||||
* and contains no '.' characters. Set bson bit field appropriately.
|
||||
* Note that we don't need to check for '\0' because we're using
|
||||
* strlen(3), which stops at '\0'.
|
||||
*
|
||||
* @param b The bson object to which field name will be appended.
|
||||
* @param string The field name as char*.
|
||||
* @param length The length of the field name.
|
||||
*
|
||||
* @return BSON_OK if valid UTF8 and BSON_ERROR if not. All BSON strings must be
|
||||
* valid UTF8. This function will also check whether the string
|
||||
* contains '.' or starts with '$', since the validity of this depends on context.
|
||||
* Set the value of b->err appropriately.
|
||||
*/
|
||||
int bson_check_field_name( bson *b, const char *string,
|
||||
const int length );
|
||||
|
||||
/**
|
||||
* Check that a string is valid UTF8. Sets the buffer bit field appropriately.
|
||||
*
|
||||
* @param b The bson object to which string will be appended.
|
||||
* @param string The string to check.
|
||||
* @param length The length of the string.
|
||||
*
|
||||
* @return BSON_OK if valid UTF-8; otherwise, BSON_ERROR.
|
||||
* Sets b->err on error.
|
||||
*/
|
||||
bson_bool_t bson_check_string( bson *b, const char *string,
|
||||
const int length );
|
||||
|
||||
MONGO_EXTERN_C_END
|
||||
#endif
|
||||
@@ -0,0 +1,685 @@
|
||||
/* gridfs.c */
|
||||
|
||||
/* Copyright 2009-2011 10gen Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "gridfs.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
static bson *chunk_new( bson_oid_t id, int chunkNumber,
|
||||
const char *data, int len ) {
|
||||
bson *b = bson_malloc( sizeof( bson ) );
|
||||
|
||||
bson_init( b );
|
||||
bson_append_oid( b, "files_id", &id );
|
||||
bson_append_int( b, "n", chunkNumber );
|
||||
bson_append_binary( b, "data", BSON_BIN_BINARY, data, len );
|
||||
bson_finish( b );
|
||||
return b;
|
||||
}
|
||||
|
||||
static void chunk_free( bson *oChunk ) {
|
||||
bson_destroy( oChunk );
|
||||
bson_free( oChunk );
|
||||
}
|
||||
|
||||
int gridfs_init( mongo *client, const char *dbname, const char *prefix,
|
||||
gridfs *gfs ) {
|
||||
|
||||
int options;
|
||||
bson b;
|
||||
bson_bool_t success;
|
||||
|
||||
gfs->client = client;
|
||||
|
||||
/* Allocate space to own the dbname */
|
||||
gfs->dbname = ( const char * )bson_malloc( strlen( dbname )+1 );
|
||||
strcpy( ( char * )gfs->dbname, dbname );
|
||||
|
||||
/* Allocate space to own the prefix */
|
||||
if ( prefix == NULL ) prefix = "fs";
|
||||
gfs->prefix = ( const char * )bson_malloc( strlen( prefix )+1 );
|
||||
strcpy( ( char * )gfs->prefix, prefix );
|
||||
|
||||
/* Allocate space to own files_ns */
|
||||
gfs->files_ns =
|
||||
( const char * ) bson_malloc ( strlen( prefix )+strlen( dbname )+strlen( ".files" )+2 );
|
||||
strcpy( ( char * )gfs->files_ns, dbname );
|
||||
strcat( ( char * )gfs->files_ns, "." );
|
||||
strcat( ( char * )gfs->files_ns, prefix );
|
||||
strcat( ( char * )gfs->files_ns, ".files" );
|
||||
|
||||
/* Allocate space to own chunks_ns */
|
||||
gfs->chunks_ns = ( const char * ) bson_malloc( strlen( prefix ) + strlen( dbname )
|
||||
+ strlen( ".chunks" ) + 2 );
|
||||
strcpy( ( char * )gfs->chunks_ns, dbname );
|
||||
strcat( ( char * )gfs->chunks_ns, "." );
|
||||
strcat( ( char * )gfs->chunks_ns, prefix );
|
||||
strcat( ( char * )gfs->chunks_ns, ".chunks" );
|
||||
|
||||
bson_init( &b );
|
||||
bson_append_int( &b, "filename", 1 );
|
||||
bson_finish( &b );
|
||||
options = 0;
|
||||
success = ( mongo_create_index( gfs->client, gfs->files_ns, &b, options, NULL ) == MONGO_OK );
|
||||
bson_destroy( &b );
|
||||
if ( !success ) {
|
||||
bson_free( ( char * )gfs->dbname );
|
||||
bson_free( ( char * )gfs->prefix );
|
||||
bson_free( ( char * )gfs->files_ns );
|
||||
bson_free( ( char * )gfs->chunks_ns );
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
|
||||
bson_init( &b );
|
||||
bson_append_int( &b, "files_id", 1 );
|
||||
bson_append_int( &b, "n", 1 );
|
||||
bson_finish( &b );
|
||||
options = MONGO_INDEX_UNIQUE;
|
||||
success = ( mongo_create_index( gfs->client, gfs->chunks_ns, &b, options, NULL ) == MONGO_OK );
|
||||
bson_destroy( &b );
|
||||
if ( !success ) {
|
||||
bson_free( ( char * )gfs->dbname );
|
||||
bson_free( ( char * )gfs->prefix );
|
||||
bson_free( ( char * )gfs->files_ns );
|
||||
bson_free( ( char * )gfs->chunks_ns );
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
|
||||
return MONGO_OK;
|
||||
}
|
||||
|
||||
void gridfs_destroy( gridfs *gfs ) {
|
||||
if ( gfs == NULL ) return;
|
||||
if ( gfs->dbname ) bson_free( ( char * )gfs->dbname );
|
||||
if ( gfs->prefix ) bson_free( ( char * )gfs->prefix );
|
||||
if ( gfs->files_ns ) bson_free( ( char * )gfs->files_ns );
|
||||
if ( gfs->chunks_ns ) bson_free( ( char * )gfs->chunks_ns );
|
||||
}
|
||||
|
||||
static int gridfs_insert_file( gridfs *gfs, const char *name,
|
||||
const bson_oid_t id, gridfs_offset length,
|
||||
const char *contenttype ) {
|
||||
bson command;
|
||||
bson ret;
|
||||
bson res;
|
||||
bson_iterator it;
|
||||
int result;
|
||||
|
||||
/* Check run md5 */
|
||||
bson_init( &command );
|
||||
bson_append_oid( &command, "filemd5", &id );
|
||||
bson_append_string( &command, "root", gfs->prefix );
|
||||
bson_finish( &command );
|
||||
assert( mongo_run_command( gfs->client, gfs->dbname, &command, &res ) == MONGO_OK );
|
||||
bson_destroy( &command );
|
||||
|
||||
/* Create and insert BSON for file metadata */
|
||||
bson_init( &ret );
|
||||
bson_append_oid( &ret, "_id", &id );
|
||||
if ( name != NULL && *name != '\0' ) {
|
||||
bson_append_string( &ret, "filename", name );
|
||||
}
|
||||
bson_append_long( &ret, "length", length );
|
||||
bson_append_int( &ret, "chunkSize", DEFAULT_CHUNK_SIZE );
|
||||
bson_append_date( &ret, "uploadDate", ( bson_date_t )1000*time( NULL ) );
|
||||
bson_find( &it, &res, "md5" );
|
||||
bson_append_string( &ret, "md5", bson_iterator_string( &it ) );
|
||||
bson_destroy( &res );
|
||||
if ( contenttype != NULL && *contenttype != '\0' ) {
|
||||
bson_append_string( &ret, "contentType", contenttype );
|
||||
}
|
||||
bson_finish( &ret );
|
||||
result = mongo_insert( gfs->client, gfs->files_ns, &ret );
|
||||
bson_destroy( &ret );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int gridfs_store_buffer( gridfs *gfs, const char *data,
|
||||
gridfs_offset length, const char *remotename,
|
||||
const char *contenttype ) {
|
||||
|
||||
char const *end = data + length;
|
||||
const char *data_ptr = data;
|
||||
bson_oid_t id;
|
||||
int chunkNumber = 0;
|
||||
int chunkLen;
|
||||
bson *oChunk;
|
||||
|
||||
/* Large files Assertion */
|
||||
assert( length <= 0xffffffff );
|
||||
|
||||
/* Generate and append an oid*/
|
||||
bson_oid_gen( &id );
|
||||
|
||||
/* Insert the file's data chunk by chunk */
|
||||
while ( data_ptr < end ) {
|
||||
chunkLen = DEFAULT_CHUNK_SIZE < ( unsigned int )( end - data_ptr ) ?
|
||||
DEFAULT_CHUNK_SIZE : ( unsigned int )( end - data_ptr );
|
||||
oChunk = chunk_new( id, chunkNumber, data_ptr, chunkLen );
|
||||
mongo_insert( gfs->client, gfs->chunks_ns, oChunk );
|
||||
chunk_free( oChunk );
|
||||
chunkNumber++;
|
||||
data_ptr += chunkLen;
|
||||
}
|
||||
|
||||
/* Inserts file's metadata */
|
||||
return gridfs_insert_file( gfs, remotename, id, length, contenttype );
|
||||
}
|
||||
|
||||
void gridfile_writer_init( gridfile *gfile, gridfs *gfs,
|
||||
const char *remote_name, const char *content_type ) {
|
||||
gfile->gfs = gfs;
|
||||
|
||||
bson_oid_gen( &( gfile->id ) );
|
||||
gfile->chunk_num = 0;
|
||||
gfile->length = 0;
|
||||
gfile->pending_len = 0;
|
||||
gfile->pending_data = NULL;
|
||||
|
||||
gfile->remote_name = ( char * )bson_malloc( strlen( remote_name ) + 1 );
|
||||
strcpy( ( char * )gfile->remote_name, remote_name );
|
||||
|
||||
gfile->content_type = ( char * )bson_malloc( strlen( content_type ) + 1 );
|
||||
strcpy( ( char * )gfile->content_type, content_type );
|
||||
}
|
||||
|
||||
void gridfile_write_buffer( gridfile *gfile, const char *data,
|
||||
gridfs_offset length ) {
|
||||
|
||||
int bytes_left = 0;
|
||||
int data_partial_len = 0;
|
||||
int chunks_to_write = 0;
|
||||
char *buffer;
|
||||
bson *oChunk;
|
||||
gridfs_offset to_write = length + gfile->pending_len;
|
||||
|
||||
if ( to_write < DEFAULT_CHUNK_SIZE ) { /* Less than one chunk to write */
|
||||
if( gfile->pending_data ) {
|
||||
gfile->pending_data = ( char * )bson_realloc( ( void * )gfile->pending_data, gfile->pending_len + to_write );
|
||||
memcpy( gfile->pending_data + gfile->pending_len, data, length );
|
||||
} else if ( to_write > 0 ) {
|
||||
gfile->pending_data = ( char * )bson_malloc( to_write );
|
||||
memcpy( gfile->pending_data, data, length );
|
||||
}
|
||||
gfile->pending_len += length;
|
||||
|
||||
} else { /* At least one chunk of data to write */
|
||||
|
||||
/* If there's a pending chunk to be written, we need to combine
|
||||
* the buffer provided up to DEFAULT_CHUNK_SIZE.
|
||||
*/
|
||||
if ( gfile->pending_len > 0 ) {
|
||||
chunks_to_write = to_write / DEFAULT_CHUNK_SIZE;
|
||||
bytes_left = to_write % DEFAULT_CHUNK_SIZE;
|
||||
|
||||
data_partial_len = DEFAULT_CHUNK_SIZE - gfile->pending_len;
|
||||
buffer = ( char * )bson_malloc( DEFAULT_CHUNK_SIZE );
|
||||
memcpy( buffer, gfile->pending_data, gfile->pending_len );
|
||||
memcpy( buffer + gfile->pending_len, data, data_partial_len );
|
||||
|
||||
oChunk = chunk_new( gfile->id, gfile->chunk_num, buffer, DEFAULT_CHUNK_SIZE );
|
||||
mongo_insert( gfile->gfs->client, gfile->gfs->chunks_ns, oChunk );
|
||||
chunk_free( oChunk );
|
||||
gfile->chunk_num++;
|
||||
gfile->length += DEFAULT_CHUNK_SIZE;
|
||||
data += data_partial_len;
|
||||
|
||||
chunks_to_write--;
|
||||
|
||||
bson_free( buffer );
|
||||
}
|
||||
|
||||
while( chunks_to_write > 0 ) {
|
||||
oChunk = chunk_new( gfile->id, gfile->chunk_num, data, DEFAULT_CHUNK_SIZE );
|
||||
mongo_insert( gfile->gfs->client, gfile->gfs->chunks_ns, oChunk );
|
||||
chunk_free( oChunk );
|
||||
gfile->chunk_num++;
|
||||
chunks_to_write--;
|
||||
gfile->length += DEFAULT_CHUNK_SIZE;
|
||||
data += DEFAULT_CHUNK_SIZE;
|
||||
}
|
||||
|
||||
bson_free( gfile->pending_data );
|
||||
|
||||
/* If there are any leftover bytes, store them as pending data. */
|
||||
if( bytes_left == 0 )
|
||||
gfile->pending_data = NULL;
|
||||
else {
|
||||
gfile->pending_data = ( char * )bson_malloc( bytes_left );
|
||||
memcpy( gfile->pending_data, data, bytes_left );
|
||||
}
|
||||
|
||||
gfile->pending_len = bytes_left;
|
||||
}
|
||||
}
|
||||
|
||||
int gridfile_writer_done( gridfile *gfile ) {
|
||||
|
||||
/* write any remaining pending chunk data.
|
||||
* pending data will always take up less than one chunk */
|
||||
bson *oChunk;
|
||||
int response;
|
||||
if( gfile->pending_data ) {
|
||||
oChunk = chunk_new( gfile->id, gfile->chunk_num, gfile->pending_data, gfile->pending_len );
|
||||
mongo_insert( gfile->gfs->client, gfile->gfs->chunks_ns, oChunk );
|
||||
chunk_free( oChunk );
|
||||
bson_free( gfile->pending_data );
|
||||
gfile->length += gfile->pending_len;
|
||||
}
|
||||
|
||||
/* insert into files collection */
|
||||
response = gridfs_insert_file( gfile->gfs, gfile->remote_name, gfile->id,
|
||||
gfile->length, gfile->content_type );
|
||||
|
||||
bson_free( gfile->remote_name );
|
||||
bson_free( gfile->content_type );
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
int gridfs_store_file( gridfs *gfs, const char *filename,
|
||||
const char *remotename, const char *contenttype ) {
|
||||
|
||||
char buffer[DEFAULT_CHUNK_SIZE];
|
||||
FILE *fd;
|
||||
bson_oid_t id;
|
||||
int chunkNumber = 0;
|
||||
gridfs_offset length = 0;
|
||||
gridfs_offset chunkLen = 0;
|
||||
bson *oChunk;
|
||||
|
||||
/* Open the file and the correct stream */
|
||||
if ( strcmp( filename, "-" ) == 0 ) fd = stdin;
|
||||
else fd = fopen( filename, "rb" );
|
||||
assert( fd != NULL ); /* No such file */
|
||||
|
||||
/* Generate and append an oid*/
|
||||
bson_oid_gen( &id );
|
||||
|
||||
/* Insert the file chunk by chunk */
|
||||
chunkLen = fread( buffer, 1, DEFAULT_CHUNK_SIZE, fd );
|
||||
do {
|
||||
oChunk = chunk_new( id, chunkNumber, buffer, chunkLen );
|
||||
mongo_insert( gfs->client, gfs->chunks_ns, oChunk );
|
||||
chunk_free( oChunk );
|
||||
length += chunkLen;
|
||||
chunkNumber++;
|
||||
chunkLen = fread( buffer, 1, DEFAULT_CHUNK_SIZE, fd );
|
||||
} while ( chunkLen != 0 );
|
||||
|
||||
/* Close the file stream */
|
||||
if ( fd != stdin ) fclose( fd );
|
||||
|
||||
/* Large files Assertion */
|
||||
/* assert(length <= 0xffffffff); */
|
||||
|
||||
/* Optional Remote Name */
|
||||
if ( remotename == NULL || *remotename == '\0' ) {
|
||||
remotename = filename;
|
||||
}
|
||||
|
||||
/* Inserts file's metadata */
|
||||
return gridfs_insert_file( gfs, remotename, id, length, contenttype );
|
||||
}
|
||||
|
||||
void gridfs_remove_filename( gridfs *gfs, const char *filename ) {
|
||||
bson query;
|
||||
mongo_cursor *files;
|
||||
bson file;
|
||||
bson_iterator it;
|
||||
bson_oid_t id;
|
||||
bson b;
|
||||
|
||||
bson_init( &query );
|
||||
bson_append_string( &query, "filename", filename );
|
||||
bson_finish( &query );
|
||||
files = mongo_find( gfs->client, gfs->files_ns, &query, NULL, 0, 0, 0 );
|
||||
bson_destroy( &query );
|
||||
|
||||
/* Remove each file and it's chunks from files named filename */
|
||||
while ( mongo_cursor_next( files ) == MONGO_OK ) {
|
||||
file = files->current;
|
||||
bson_find( &it, &file, "_id" );
|
||||
id = *bson_iterator_oid( &it );
|
||||
|
||||
/* Remove the file with the specified id */
|
||||
bson_init( &b );
|
||||
bson_append_oid( &b, "_id", &id );
|
||||
bson_finish( &b );
|
||||
mongo_remove( gfs->client, gfs->files_ns, &b );
|
||||
bson_destroy( &b );
|
||||
|
||||
/* Remove all chunks from the file with the specified id */
|
||||
bson_init( &b );
|
||||
bson_append_oid( &b, "files_id", &id );
|
||||
bson_finish( &b );
|
||||
mongo_remove( gfs->client, gfs->chunks_ns, &b );
|
||||
bson_destroy( &b );
|
||||
}
|
||||
|
||||
mongo_cursor_destroy( files );
|
||||
}
|
||||
|
||||
int gridfs_find_query( gridfs *gfs, bson *query,
|
||||
gridfile *gfile ) {
|
||||
|
||||
bson uploadDate;
|
||||
bson finalQuery;
|
||||
bson out;
|
||||
int i;
|
||||
|
||||
bson_init( &uploadDate );
|
||||
bson_append_int( &uploadDate, "uploadDate", -1 );
|
||||
bson_finish( &uploadDate );
|
||||
|
||||
bson_init( &finalQuery );
|
||||
bson_append_bson( &finalQuery, "query", query );
|
||||
bson_append_bson( &finalQuery, "orderby", &uploadDate );
|
||||
bson_finish( &finalQuery );
|
||||
|
||||
i = ( mongo_find_one( gfs->client, gfs->files_ns,
|
||||
&finalQuery, NULL, &out ) == MONGO_OK );
|
||||
bson_destroy( &uploadDate );
|
||||
bson_destroy( &finalQuery );
|
||||
if ( !i )
|
||||
return MONGO_ERROR;
|
||||
else {
|
||||
gridfile_init( gfs, &out, gfile );
|
||||
bson_destroy( &out );
|
||||
return MONGO_OK;
|
||||
}
|
||||
}
|
||||
|
||||
int gridfs_find_filename( gridfs *gfs, const char *filename,
|
||||
gridfile *gfile )
|
||||
|
||||
{
|
||||
bson query;
|
||||
int i;
|
||||
|
||||
bson_init( &query );
|
||||
bson_append_string( &query, "filename", filename );
|
||||
bson_finish( &query );
|
||||
i = gridfs_find_query( gfs, &query, gfile );
|
||||
bson_destroy( &query );
|
||||
return i;
|
||||
}
|
||||
|
||||
int gridfile_init( gridfs *gfs, bson *meta, gridfile *gfile )
|
||||
|
||||
{
|
||||
gfile->gfs = gfs;
|
||||
gfile->pos = 0;
|
||||
gfile->meta = ( bson * )bson_malloc( sizeof( bson ) );
|
||||
if ( gfile->meta == NULL ) return MONGO_ERROR;
|
||||
bson_copy( gfile->meta, meta );
|
||||
return MONGO_OK;
|
||||
}
|
||||
|
||||
void gridfile_destroy( gridfile *gfile )
|
||||
|
||||
{
|
||||
bson_destroy( gfile->meta );
|
||||
bson_free( gfile->meta );
|
||||
}
|
||||
|
||||
bson_bool_t gridfile_exists( gridfile *gfile ) {
|
||||
return ( bson_bool_t )( gfile != NULL || gfile->meta == NULL );
|
||||
}
|
||||
|
||||
const char *gridfile_get_filename( gridfile *gfile ) {
|
||||
bson_iterator it;
|
||||
|
||||
bson_find( &it, gfile->meta, "filename" );
|
||||
return bson_iterator_string( &it );
|
||||
}
|
||||
|
||||
int gridfile_get_chunksize( gridfile *gfile ) {
|
||||
bson_iterator it;
|
||||
|
||||
bson_find( &it, gfile->meta, "chunkSize" );
|
||||
return bson_iterator_int( &it );
|
||||
}
|
||||
|
||||
gridfs_offset gridfile_get_contentlength( gridfile *gfile ) {
|
||||
bson_iterator it;
|
||||
|
||||
bson_find( &it, gfile->meta, "length" );
|
||||
|
||||
if( bson_iterator_type( &it ) == BSON_INT )
|
||||
return ( gridfs_offset )bson_iterator_int( &it );
|
||||
else
|
||||
return ( gridfs_offset )bson_iterator_long( &it );
|
||||
}
|
||||
|
||||
const char *gridfile_get_contenttype( gridfile *gfile ) {
|
||||
bson_iterator it;
|
||||
|
||||
if ( bson_find( &it, gfile->meta, "contentType" ) )
|
||||
return bson_iterator_string( &it );
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
bson_date_t gridfile_get_uploaddate( gridfile *gfile ) {
|
||||
bson_iterator it;
|
||||
|
||||
bson_find( &it, gfile->meta, "uploadDate" );
|
||||
return bson_iterator_date( &it );
|
||||
}
|
||||
|
||||
const char *gridfile_get_md5( gridfile *gfile ) {
|
||||
bson_iterator it;
|
||||
|
||||
bson_find( &it, gfile->meta, "md5" );
|
||||
return bson_iterator_string( &it );
|
||||
}
|
||||
|
||||
const char *gridfile_get_field( gridfile *gfile, const char *name ) {
|
||||
bson_iterator it;
|
||||
|
||||
bson_find( &it, gfile->meta, name );
|
||||
return bson_iterator_value( &it );
|
||||
}
|
||||
|
||||
bson_bool_t gridfile_get_boolean( gridfile *gfile, const char *name ) {
|
||||
bson_iterator it;
|
||||
|
||||
bson_find( &it, gfile->meta, name );
|
||||
return bson_iterator_bool( &it );
|
||||
}
|
||||
|
||||
bson gridfile_get_metadata( gridfile *gfile ) {
|
||||
bson sub;
|
||||
bson_iterator it;
|
||||
|
||||
if ( bson_find( &it, gfile->meta, "metadata" ) ) {
|
||||
bson_iterator_subobject( &it, &sub );
|
||||
return sub;
|
||||
} else {
|
||||
bson_empty( &sub );
|
||||
return sub;
|
||||
}
|
||||
}
|
||||
|
||||
int gridfile_get_numchunks( gridfile *gfile ) {
|
||||
bson_iterator it;
|
||||
gridfs_offset length;
|
||||
gridfs_offset chunkSize;
|
||||
double numchunks;
|
||||
|
||||
bson_find( &it, gfile->meta, "length" );
|
||||
|
||||
if( bson_iterator_type( &it ) == BSON_INT )
|
||||
length = ( gridfs_offset )bson_iterator_int( &it );
|
||||
else
|
||||
length = ( gridfs_offset )bson_iterator_long( &it );
|
||||
|
||||
bson_find( &it, gfile->meta, "chunkSize" );
|
||||
chunkSize = bson_iterator_int( &it );
|
||||
numchunks = ( ( double )length/( double )chunkSize );
|
||||
return ( numchunks - ( int )numchunks > 0 )
|
||||
? ( int )( numchunks+1 )
|
||||
: ( int )( numchunks );
|
||||
}
|
||||
|
||||
bson gridfile_get_chunk( gridfile *gfile, int n ) {
|
||||
bson query;
|
||||
bson out;
|
||||
bson_iterator it;
|
||||
bson_oid_t id;
|
||||
|
||||
bson_init( &query );
|
||||
bson_find( &it, gfile->meta, "_id" );
|
||||
id = *bson_iterator_oid( &it );
|
||||
bson_append_oid( &query, "files_id", &id );
|
||||
bson_append_int( &query, "n", n );
|
||||
bson_finish( &query );
|
||||
|
||||
assert( mongo_find_one( gfile->gfs->client,
|
||||
gfile->gfs->chunks_ns,
|
||||
&query, NULL, &out ) == MONGO_OK );
|
||||
|
||||
bson_destroy( &query );
|
||||
return out;
|
||||
}
|
||||
|
||||
mongo_cursor *gridfile_get_chunks( gridfile *gfile, int start, int size ) {
|
||||
bson_iterator it;
|
||||
bson_oid_t id;
|
||||
bson gte;
|
||||
bson query;
|
||||
bson orderby;
|
||||
bson command;
|
||||
mongo_cursor *cursor;
|
||||
|
||||
bson_find( &it, gfile->meta, "_id" );
|
||||
id = *bson_iterator_oid( &it );
|
||||
|
||||
bson_init( &query );
|
||||
bson_append_oid( &query, "files_id", &id );
|
||||
if ( size == 1 ) {
|
||||
bson_append_int( &query, "n", start );
|
||||
} else {
|
||||
bson_init( >e );
|
||||
bson_append_int( >e, "$gte", start );
|
||||
bson_finish( >e );
|
||||
bson_append_bson( &query, "n", >e );
|
||||
bson_destroy( >e );
|
||||
}
|
||||
bson_finish( &query );
|
||||
|
||||
bson_init( &orderby );
|
||||
bson_append_int( &orderby, "n", 1 );
|
||||
bson_finish( &orderby );
|
||||
|
||||
bson_init( &command );
|
||||
bson_append_bson( &command, "query", &query );
|
||||
bson_append_bson( &command, "orderby", &orderby );
|
||||
bson_finish( &command );
|
||||
|
||||
cursor = mongo_find( gfile->gfs->client, gfile->gfs->chunks_ns,
|
||||
&command, NULL, size, 0, 0 );
|
||||
|
||||
bson_destroy( &command );
|
||||
bson_destroy( &query );
|
||||
bson_destroy( &orderby );
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
gridfs_offset gridfile_write_file( gridfile *gfile, FILE *stream ) {
|
||||
int i;
|
||||
size_t len;
|
||||
bson chunk;
|
||||
bson_iterator it;
|
||||
const char *data;
|
||||
const int num = gridfile_get_numchunks( gfile );
|
||||
|
||||
for ( i=0; i<num; i++ ) {
|
||||
chunk = gridfile_get_chunk( gfile, i );
|
||||
bson_find( &it, &chunk, "data" );
|
||||
len = bson_iterator_bin_len( &it );
|
||||
data = bson_iterator_bin_data( &it );
|
||||
fwrite( data , sizeof( char ), len, stream );
|
||||
bson_destroy( &chunk );
|
||||
}
|
||||
|
||||
return gridfile_get_contentlength( gfile );
|
||||
}
|
||||
|
||||
gridfs_offset gridfile_read( gridfile *gfile, gridfs_offset size, char *buf ) {
|
||||
mongo_cursor *chunks;
|
||||
bson chunk;
|
||||
|
||||
int first_chunk;
|
||||
int last_chunk;
|
||||
int total_chunks;
|
||||
gridfs_offset chunksize;
|
||||
gridfs_offset contentlength;
|
||||
gridfs_offset bytes_left;
|
||||
int i;
|
||||
bson_iterator it;
|
||||
gridfs_offset chunk_len;
|
||||
const char *chunk_data;
|
||||
|
||||
contentlength = gridfile_get_contentlength( gfile );
|
||||
chunksize = gridfile_get_chunksize( gfile );
|
||||
size = ( contentlength - gfile->pos < size )
|
||||
? contentlength - gfile->pos
|
||||
: size;
|
||||
bytes_left = size;
|
||||
|
||||
first_chunk = ( gfile->pos )/chunksize;
|
||||
last_chunk = ( gfile->pos+size-1 )/chunksize;
|
||||
total_chunks = last_chunk - first_chunk + 1;
|
||||
chunks = gridfile_get_chunks( gfile, first_chunk, total_chunks );
|
||||
|
||||
for ( i = 0; i < total_chunks; i++ ) {
|
||||
mongo_cursor_next( chunks );
|
||||
chunk = chunks->current;
|
||||
bson_find( &it, &chunk, "data" );
|
||||
chunk_len = bson_iterator_bin_len( &it );
|
||||
chunk_data = bson_iterator_bin_data( &it );
|
||||
if ( i == 0 ) {
|
||||
chunk_data += ( gfile->pos )%chunksize;
|
||||
chunk_len -= ( gfile->pos )%chunksize;
|
||||
}
|
||||
if ( bytes_left > chunk_len ) {
|
||||
memcpy( buf, chunk_data, chunk_len );
|
||||
bytes_left -= chunk_len;
|
||||
buf += chunk_len;
|
||||
} else {
|
||||
memcpy( buf, chunk_data, bytes_left );
|
||||
}
|
||||
}
|
||||
|
||||
mongo_cursor_destroy( chunks );
|
||||
gfile->pos = gfile->pos + size;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
gridfs_offset gridfile_seek( gridfile *gfile, gridfs_offset offset ) {
|
||||
gridfs_offset length;
|
||||
|
||||
length = gridfile_get_contentlength( gfile );
|
||||
gfile->pos = length < offset ? length : offset;
|
||||
return gfile->pos;
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
/** @file gridfs.h
|
||||
*
|
||||
* @brief GridFS declarations
|
||||
*
|
||||
* */
|
||||
|
||||
/* Copyright 2009-2011 10gen Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "mongo.h"
|
||||
|
||||
#ifndef GRIDFS_INCLUDED
|
||||
#define GRIDFS_INCLUDED
|
||||
|
||||
enum {DEFAULT_CHUNK_SIZE = 256 * 1024};
|
||||
|
||||
typedef uint64_t gridfs_offset;
|
||||
|
||||
/* A GridFS represents a single collection of GridFS files in the database. */
|
||||
typedef struct {
|
||||
mongo *client; /**> The client to db-connection. */
|
||||
const char *dbname; /**> The root database name */
|
||||
const char *prefix; /**> The prefix of the GridFS's collections, default is NULL */
|
||||
const char *files_ns; /**> The namespace where the file's metadata is stored */
|
||||
const char *chunks_ns; /**. The namespace where the files's data is stored in chunks */
|
||||
} gridfs;
|
||||
|
||||
/* A GridFile is a single GridFS file. */
|
||||
typedef struct {
|
||||
gridfs *gfs; /**> The GridFS where the GridFile is located */
|
||||
bson *meta; /**> The GridFile's bson object where all its metadata is located */
|
||||
gridfs_offset pos; /**> The position is the offset in the file */
|
||||
bson_oid_t id; /**> The files_id of the gridfile */
|
||||
char *remote_name; /**> The name of the gridfile as a string */
|
||||
char *content_type; /**> The gridfile's content type */
|
||||
gridfs_offset length; /**> The length of this gridfile */
|
||||
int chunk_num; /**> The number of the current chunk being written to */
|
||||
char *pending_data; /**> A buffer storing data still to be written to chunks */
|
||||
int pending_len; /**> Length of pending_data buffer */
|
||||
} gridfile;
|
||||
|
||||
/**
|
||||
* Initializes a GridFS object
|
||||
* @param client - db connection
|
||||
* @param dbname - database name
|
||||
* @param prefix - collection prefix, default is fs if NULL or empty
|
||||
* @param gfs - the GridFS object to initialize
|
||||
*
|
||||
* @return - MONGO_OK or MONGO_ERROR.
|
||||
*/
|
||||
int gridfs_init( mongo *client, const char *dbname,
|
||||
const char *prefix, gridfs *gfs );
|
||||
|
||||
/**
|
||||
* Destroys a GridFS object. Call this when finished with
|
||||
* the object..
|
||||
*
|
||||
* @param gfs a grid
|
||||
*/
|
||||
void gridfs_destroy( gridfs *gfs );
|
||||
|
||||
/**
|
||||
* Initializes a gridfile for writing incrementally with gridfs_write_buffer.
|
||||
* Once initialized, you can write any number of buffers with gridfs_write_buffer.
|
||||
* When done, you must call gridfs_writer_done to save the file metadata.
|
||||
*
|
||||
*/
|
||||
void gridfile_writer_init( gridfile *gfile, gridfs *gfs, const char *remote_name,
|
||||
const char *content_type );
|
||||
|
||||
/**
|
||||
* Write to a GridFS file incrementally. You can call this function any number
|
||||
* of times with a new buffer each time. This allows you to effectively
|
||||
* stream to a GridFS file. When finished, be sure to call gridfs_writer_done.
|
||||
*
|
||||
*/
|
||||
void gridfile_write_buffer( gridfile *gfile, const char *data,
|
||||
gridfs_offset length );
|
||||
|
||||
/**
|
||||
* Signal that writing of this gridfile is complete by
|
||||
* writing any buffered chunks along with the entry in the
|
||||
* files collection.
|
||||
*
|
||||
* @return - MONGO_OK or MONGO_ERROR.
|
||||
*/
|
||||
int gridfile_writer_done( gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Store a buffer as a GridFS file.
|
||||
* @param gfs - the working GridFS
|
||||
* @param data - pointer to buffer to store in GridFS
|
||||
* @param length - length of the buffer
|
||||
* @param remotename - filename for use in the database
|
||||
* @param contenttype - optional MIME type for this object
|
||||
*
|
||||
* @return - MONGO_OK or MONGO_ERROR.
|
||||
*/
|
||||
int gridfs_store_buffer( gridfs *gfs, const char *data, gridfs_offset length,
|
||||
const char *remotename,
|
||||
const char *contenttype );
|
||||
|
||||
/**
|
||||
* Open the file referenced by filename and store it as a GridFS file.
|
||||
* @param gfs - the working GridFS
|
||||
* @param filename - local filename relative to the process
|
||||
* @param remotename - optional filename for use in the database
|
||||
* @param contenttype - optional MIME type for this object
|
||||
*
|
||||
* @return - MONGO_OK or MONGO_ERROR.
|
||||
*/
|
||||
int gridfs_store_file( gridfs *gfs, const char *filename,
|
||||
const char *remotename, const char *contenttype );
|
||||
|
||||
/**
|
||||
* Removes the files referenced by filename from the db
|
||||
* @param gfs - the working GridFS
|
||||
* @param filename - the filename of the file/s to be removed
|
||||
*/
|
||||
void gridfs_remove_filename( gridfs *gfs, const char *filename );
|
||||
|
||||
/**
|
||||
* Find the first file matching the provided query within the
|
||||
* GridFS files collection, and return the file as a GridFile.
|
||||
*
|
||||
* @param gfs - the working GridFS
|
||||
* @param query - a pointer to the bson with the query data
|
||||
* @param gfile - the output GridFile to be initialized
|
||||
*
|
||||
* @return MONGO_OK if successful, MONGO_ERROR otherwise
|
||||
*/
|
||||
int gridfs_find_query( gridfs *gfs, bson *query, gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Find the first file referenced by filename within the GridFS
|
||||
* and return it as a GridFile
|
||||
* @param gfs - the working GridFS
|
||||
* @param filename - filename of the file to find
|
||||
* @param gfile - the output GridFile to be intialized
|
||||
*
|
||||
* @return MONGO_OK or MONGO_ERROR.
|
||||
*/
|
||||
int gridfs_find_filename( gridfs *gfs, const char *filename, gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Initializes a GridFile containing the GridFS and file bson
|
||||
* @param gfs - the GridFS where the GridFile is located
|
||||
* @param meta - the file object
|
||||
* @param gfile - the output GridFile that is being initialized
|
||||
*
|
||||
* @return - MONGO_OK or MONGO_ERROR.
|
||||
*/
|
||||
int gridfile_init( gridfs *gfs, bson *meta, gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Destroys the GridFile
|
||||
*
|
||||
* @param oGridFIle - the GridFile being destroyed
|
||||
*/
|
||||
void gridfile_destroy( gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Returns whether or not the GridFile exists
|
||||
* @param gfile - the GridFile being examined
|
||||
*/
|
||||
bson_bool_t gridfile_exists( gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Returns the filename of GridFile
|
||||
* @param gfile - the working GridFile
|
||||
*
|
||||
* @return - the filename of the Gridfile
|
||||
*/
|
||||
const char *gridfile_get_filename( gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Returns the size of the chunks of the GridFile
|
||||
* @param gfile - the working GridFile
|
||||
*
|
||||
* @return - the size of the chunks of the Gridfile
|
||||
*/
|
||||
int gridfile_get_chunksize( gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Returns the length of GridFile's data
|
||||
*
|
||||
* @param gfile - the working GridFile
|
||||
*
|
||||
* @return - the length of the Gridfile's data
|
||||
*/
|
||||
gridfs_offset gridfile_get_contentlength( gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Returns the MIME type of the GridFile
|
||||
*
|
||||
* @param gfile - the working GridFile
|
||||
*
|
||||
* @return - the MIME type of the Gridfile
|
||||
* (NULL if no type specified)
|
||||
*/
|
||||
const char *gridfile_get_contenttype( gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Returns the upload date of GridFile
|
||||
*
|
||||
* @param gfile - the working GridFile
|
||||
*
|
||||
* @return - the upload date of the Gridfile
|
||||
*/
|
||||
bson_date_t gridfile_get_uploaddate( gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Returns the MD5 of GridFile
|
||||
*
|
||||
* @param gfile - the working GridFile
|
||||
*
|
||||
* @return - the MD5 of the Gridfile
|
||||
*/
|
||||
const char *gridfile_get_md5( gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Returns the field in GridFile specified by name
|
||||
*
|
||||
* @param gfile - the working GridFile
|
||||
* @param name - the name of the field to be returned
|
||||
*
|
||||
* @return - the data of the field specified
|
||||
* (NULL if none exists)
|
||||
*/
|
||||
const char *gridfile_get_field( gridfile *gfile,
|
||||
const char *name );
|
||||
|
||||
/**
|
||||
* Returns a boolean field in GridFile specified by name
|
||||
* @param gfile - the working GridFile
|
||||
* @param name - the name of the field to be returned
|
||||
*
|
||||
* @return - the boolean of the field specified
|
||||
* (NULL if none exists)
|
||||
*/
|
||||
bson_bool_t gridfile_get_boolean( gridfile *gfile,
|
||||
const char *name );
|
||||
|
||||
/**
|
||||
* Returns the metadata of GridFile
|
||||
* @param gfile - the working GridFile
|
||||
*
|
||||
* @return - the metadata of the Gridfile in a bson object
|
||||
* (an empty bson is returned if none exists)
|
||||
*/
|
||||
bson gridfile_get_metadata( gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Returns the number of chunks in the GridFile
|
||||
* @param gfile - the working GridFile
|
||||
*
|
||||
* @return - the number of chunks in the Gridfile
|
||||
*/
|
||||
int gridfile_get_numchunks( gridfile *gfile );
|
||||
|
||||
/**
|
||||
* Returns chunk n of GridFile
|
||||
* @param gfile - the working GridFile
|
||||
*
|
||||
* @return - the nth chunk of the Gridfile
|
||||
*/
|
||||
bson gridfile_get_chunk( gridfile *gfile, int n );
|
||||
|
||||
/**
|
||||
* Returns a mongo_cursor of *size* chunks starting with chunk *start*
|
||||
*
|
||||
* @param gfile - the working GridFile
|
||||
* @param start - the first chunk in the cursor
|
||||
* @param size - the number of chunks to be returned
|
||||
*
|
||||
* @return - mongo_cursor of the chunks (must be destroyed after use)
|
||||
*/
|
||||
mongo_cursor *gridfile_get_chunks( gridfile *gfile, int start, int size );
|
||||
|
||||
/**
|
||||
* Writes the GridFile to a stream
|
||||
*
|
||||
* @param gfile - the working GridFile
|
||||
* @param stream - the file stream to write to
|
||||
*/
|
||||
gridfs_offset gridfile_write_file( gridfile *gfile, FILE *stream );
|
||||
|
||||
/**
|
||||
* Reads length bytes from the GridFile to a buffer
|
||||
* and updates the position in the file.
|
||||
* (assumes the buffer is large enough)
|
||||
* (if size is greater than EOF gridfile_read reads until EOF)
|
||||
*
|
||||
* @param gfile - the working GridFile
|
||||
* @param size - the amount of bytes to be read
|
||||
* @param buf - the buffer to read to
|
||||
*
|
||||
* @return - the number of bytes read
|
||||
*/
|
||||
gridfs_offset gridfile_read( gridfile *gfile, gridfs_offset size, char *buf );
|
||||
|
||||
/**
|
||||
* Updates the position in the file
|
||||
* (If the offset goes beyond the contentlength,
|
||||
* the position is updated to the end of the file.)
|
||||
*
|
||||
* @param gfile - the working GridFile
|
||||
* @param offset - the position to update to
|
||||
*
|
||||
* @return - resulting offset location
|
||||
*/
|
||||
gridfs_offset gridfile_seek( gridfile *gfile, gridfs_offset offset );
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,381 @@
|
||||
/*
|
||||
Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
L. Peter Deutsch
|
||||
ghost@aladdin.com
|
||||
|
||||
*/
|
||||
/* $Id: md5.c,v 1.6 2002/04/13 19:20:28 lpd Exp $ */
|
||||
/*
|
||||
Independent implementation of MD5 (RFC 1321).
|
||||
|
||||
This code implements the MD5 Algorithm defined in RFC 1321, whose
|
||||
text is available at
|
||||
http://www.ietf.org/rfc/rfc1321.txt
|
||||
The code is derived from the text of the RFC, including the test suite
|
||||
(section A.5) but excluding the rest of Appendix A. It does not include
|
||||
any code or documentation that is identified in the RFC as being
|
||||
copyrighted.
|
||||
|
||||
The original and principal author of md5.c is L. Peter Deutsch
|
||||
<ghost@aladdin.com>. Other authors are noted in the change history
|
||||
that follows (in reverse chronological order):
|
||||
|
||||
2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order
|
||||
either statically or dynamically; added missing #include <string.h>
|
||||
in library.
|
||||
2002-03-11 lpd Corrected argument list for main(), and added int return
|
||||
type, in test program and T value program.
|
||||
2002-02-21 lpd Added missing #include <stdio.h> in test program.
|
||||
2000-07-03 lpd Patched to eliminate warnings about "constant is
|
||||
unsigned in ANSI C, signed in traditional"; made test program
|
||||
self-checking.
|
||||
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
|
||||
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5).
|
||||
1999-05-03 lpd Original version.
|
||||
*/
|
||||
|
||||
#include "md5.h"
|
||||
#include <string.h>
|
||||
|
||||
#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
|
||||
#ifdef MONGO_BIG_ENDIAN
|
||||
# define BYTE_ORDER 1
|
||||
#else
|
||||
# define BYTE_ORDER -1
|
||||
#endif
|
||||
|
||||
#define T_MASK ((mongo_md5_word_t)~0)
|
||||
#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87)
|
||||
#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9)
|
||||
#define T3 0x242070db
|
||||
#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111)
|
||||
#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050)
|
||||
#define T6 0x4787c62a
|
||||
#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec)
|
||||
#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe)
|
||||
#define T9 0x698098d8
|
||||
#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850)
|
||||
#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e)
|
||||
#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841)
|
||||
#define T13 0x6b901122
|
||||
#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c)
|
||||
#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71)
|
||||
#define T16 0x49b40821
|
||||
#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d)
|
||||
#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf)
|
||||
#define T19 0x265e5a51
|
||||
#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855)
|
||||
#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2)
|
||||
#define T22 0x02441453
|
||||
#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e)
|
||||
#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437)
|
||||
#define T25 0x21e1cde6
|
||||
#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829)
|
||||
#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278)
|
||||
#define T28 0x455a14ed
|
||||
#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa)
|
||||
#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07)
|
||||
#define T31 0x676f02d9
|
||||
#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375)
|
||||
#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd)
|
||||
#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e)
|
||||
#define T35 0x6d9d6122
|
||||
#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3)
|
||||
#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb)
|
||||
#define T38 0x4bdecfa9
|
||||
#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f)
|
||||
#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f)
|
||||
#define T41 0x289b7ec6
|
||||
#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805)
|
||||
#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a)
|
||||
#define T44 0x04881d05
|
||||
#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6)
|
||||
#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a)
|
||||
#define T47 0x1fa27cf8
|
||||
#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a)
|
||||
#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb)
|
||||
#define T50 0x432aff97
|
||||
#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58)
|
||||
#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6)
|
||||
#define T53 0x655b59c3
|
||||
#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d)
|
||||
#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82)
|
||||
#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e)
|
||||
#define T57 0x6fa87e4f
|
||||
#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f)
|
||||
#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb)
|
||||
#define T60 0x4e0811a1
|
||||
#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d)
|
||||
#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca)
|
||||
#define T63 0x2ad7d2bb
|
||||
#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e)
|
||||
|
||||
|
||||
static void
|
||||
mongo_md5_process(mongo_md5_state_t *pms, const mongo_md5_byte_t *data /*[64]*/)
|
||||
{
|
||||
mongo_md5_word_t
|
||||
a = pms->abcd[0], b = pms->abcd[1],
|
||||
c = pms->abcd[2], d = pms->abcd[3];
|
||||
mongo_md5_word_t t;
|
||||
#if BYTE_ORDER > 0
|
||||
/* Define storage only for big-endian CPUs. */
|
||||
mongo_md5_word_t X[16];
|
||||
#else
|
||||
/* Define storage for little-endian or both types of CPUs. */
|
||||
mongo_md5_word_t xbuf[16];
|
||||
const mongo_md5_word_t *X;
|
||||
#endif
|
||||
|
||||
{
|
||||
#if BYTE_ORDER == 0
|
||||
/*
|
||||
* Determine dynamically whether this is a big-endian or
|
||||
* little-endian machine, since we can use a more efficient
|
||||
* algorithm on the latter.
|
||||
*/
|
||||
static const int w = 1;
|
||||
|
||||
if (*((const mongo_md5_byte_t *)&w)) /* dynamic little-endian */
|
||||
#endif
|
||||
#if BYTE_ORDER <= 0 /* little-endian */
|
||||
{
|
||||
/*
|
||||
* On little-endian machines, we can process properly aligned
|
||||
* data without copying it.
|
||||
*/
|
||||
if (!((data - (const mongo_md5_byte_t *)0) & 3)) {
|
||||
/* data are properly aligned */
|
||||
X = (const mongo_md5_word_t *)data;
|
||||
} else {
|
||||
/* not aligned */
|
||||
memcpy(xbuf, data, 64);
|
||||
X = xbuf;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if BYTE_ORDER == 0
|
||||
else /* dynamic big-endian */
|
||||
#endif
|
||||
#if BYTE_ORDER >= 0 /* big-endian */
|
||||
{
|
||||
/*
|
||||
* On big-endian machines, we must arrange the bytes in the
|
||||
* right order.
|
||||
*/
|
||||
const mongo_md5_byte_t *xp = data;
|
||||
int i;
|
||||
|
||||
# if BYTE_ORDER == 0
|
||||
X = xbuf; /* (dynamic only) */
|
||||
# else
|
||||
# define xbuf X /* (static only) */
|
||||
# endif
|
||||
for (i = 0; i < 16; ++i, xp += 4)
|
||||
xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
|
||||
|
||||
/* Round 1. */
|
||||
/* Let [abcd k s i] denote the operation
|
||||
a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
|
||||
#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
|
||||
#define SET(a, b, c, d, k, s, Ti)\
|
||||
t = a + F(b,c,d) + X[k] + Ti;\
|
||||
a = ROTATE_LEFT(t, s) + b
|
||||
/* Do the following 16 operations. */
|
||||
SET(a, b, c, d, 0, 7, T1);
|
||||
SET(d, a, b, c, 1, 12, T2);
|
||||
SET(c, d, a, b, 2, 17, T3);
|
||||
SET(b, c, d, a, 3, 22, T4);
|
||||
SET(a, b, c, d, 4, 7, T5);
|
||||
SET(d, a, b, c, 5, 12, T6);
|
||||
SET(c, d, a, b, 6, 17, T7);
|
||||
SET(b, c, d, a, 7, 22, T8);
|
||||
SET(a, b, c, d, 8, 7, T9);
|
||||
SET(d, a, b, c, 9, 12, T10);
|
||||
SET(c, d, a, b, 10, 17, T11);
|
||||
SET(b, c, d, a, 11, 22, T12);
|
||||
SET(a, b, c, d, 12, 7, T13);
|
||||
SET(d, a, b, c, 13, 12, T14);
|
||||
SET(c, d, a, b, 14, 17, T15);
|
||||
SET(b, c, d, a, 15, 22, T16);
|
||||
#undef SET
|
||||
|
||||
/* Round 2. */
|
||||
/* Let [abcd k s i] denote the operation
|
||||
a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
|
||||
#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
|
||||
#define SET(a, b, c, d, k, s, Ti)\
|
||||
t = a + G(b,c,d) + X[k] + Ti;\
|
||||
a = ROTATE_LEFT(t, s) + b
|
||||
/* Do the following 16 operations. */
|
||||
SET(a, b, c, d, 1, 5, T17);
|
||||
SET(d, a, b, c, 6, 9, T18);
|
||||
SET(c, d, a, b, 11, 14, T19);
|
||||
SET(b, c, d, a, 0, 20, T20);
|
||||
SET(a, b, c, d, 5, 5, T21);
|
||||
SET(d, a, b, c, 10, 9, T22);
|
||||
SET(c, d, a, b, 15, 14, T23);
|
||||
SET(b, c, d, a, 4, 20, T24);
|
||||
SET(a, b, c, d, 9, 5, T25);
|
||||
SET(d, a, b, c, 14, 9, T26);
|
||||
SET(c, d, a, b, 3, 14, T27);
|
||||
SET(b, c, d, a, 8, 20, T28);
|
||||
SET(a, b, c, d, 13, 5, T29);
|
||||
SET(d, a, b, c, 2, 9, T30);
|
||||
SET(c, d, a, b, 7, 14, T31);
|
||||
SET(b, c, d, a, 12, 20, T32);
|
||||
#undef SET
|
||||
|
||||
/* Round 3. */
|
||||
/* Let [abcd k s t] denote the operation
|
||||
a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
|
||||
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
||||
#define SET(a, b, c, d, k, s, Ti)\
|
||||
t = a + H(b,c,d) + X[k] + Ti;\
|
||||
a = ROTATE_LEFT(t, s) + b
|
||||
/* Do the following 16 operations. */
|
||||
SET(a, b, c, d, 5, 4, T33);
|
||||
SET(d, a, b, c, 8, 11, T34);
|
||||
SET(c, d, a, b, 11, 16, T35);
|
||||
SET(b, c, d, a, 14, 23, T36);
|
||||
SET(a, b, c, d, 1, 4, T37);
|
||||
SET(d, a, b, c, 4, 11, T38);
|
||||
SET(c, d, a, b, 7, 16, T39);
|
||||
SET(b, c, d, a, 10, 23, T40);
|
||||
SET(a, b, c, d, 13, 4, T41);
|
||||
SET(d, a, b, c, 0, 11, T42);
|
||||
SET(c, d, a, b, 3, 16, T43);
|
||||
SET(b, c, d, a, 6, 23, T44);
|
||||
SET(a, b, c, d, 9, 4, T45);
|
||||
SET(d, a, b, c, 12, 11, T46);
|
||||
SET(c, d, a, b, 15, 16, T47);
|
||||
SET(b, c, d, a, 2, 23, T48);
|
||||
#undef SET
|
||||
|
||||
/* Round 4. */
|
||||
/* Let [abcd k s t] denote the operation
|
||||
a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
|
||||
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
|
||||
#define SET(a, b, c, d, k, s, Ti)\
|
||||
t = a + I(b,c,d) + X[k] + Ti;\
|
||||
a = ROTATE_LEFT(t, s) + b
|
||||
/* Do the following 16 operations. */
|
||||
SET(a, b, c, d, 0, 6, T49);
|
||||
SET(d, a, b, c, 7, 10, T50);
|
||||
SET(c, d, a, b, 14, 15, T51);
|
||||
SET(b, c, d, a, 5, 21, T52);
|
||||
SET(a, b, c, d, 12, 6, T53);
|
||||
SET(d, a, b, c, 3, 10, T54);
|
||||
SET(c, d, a, b, 10, 15, T55);
|
||||
SET(b, c, d, a, 1, 21, T56);
|
||||
SET(a, b, c, d, 8, 6, T57);
|
||||
SET(d, a, b, c, 15, 10, T58);
|
||||
SET(c, d, a, b, 6, 15, T59);
|
||||
SET(b, c, d, a, 13, 21, T60);
|
||||
SET(a, b, c, d, 4, 6, T61);
|
||||
SET(d, a, b, c, 11, 10, T62);
|
||||
SET(c, d, a, b, 2, 15, T63);
|
||||
SET(b, c, d, a, 9, 21, T64);
|
||||
#undef SET
|
||||
|
||||
/* Then perform the following additions. (That is increment each
|
||||
of the four registers by the value it had before this block
|
||||
was started.) */
|
||||
pms->abcd[0] += a;
|
||||
pms->abcd[1] += b;
|
||||
pms->abcd[2] += c;
|
||||
pms->abcd[3] += d;
|
||||
}
|
||||
|
||||
void
|
||||
mongo_md5_init(mongo_md5_state_t *pms)
|
||||
{
|
||||
pms->count[0] = pms->count[1] = 0;
|
||||
pms->abcd[0] = 0x67452301;
|
||||
pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
|
||||
pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
|
||||
pms->abcd[3] = 0x10325476;
|
||||
}
|
||||
|
||||
void
|
||||
mongo_md5_append(mongo_md5_state_t *pms, const mongo_md5_byte_t *data, int nbytes)
|
||||
{
|
||||
const mongo_md5_byte_t *p = data;
|
||||
int left = nbytes;
|
||||
int offset = (pms->count[0] >> 3) & 63;
|
||||
mongo_md5_word_t nbits = (mongo_md5_word_t)(nbytes << 3);
|
||||
|
||||
if (nbytes <= 0)
|
||||
return;
|
||||
|
||||
/* Update the message length. */
|
||||
pms->count[1] += nbytes >> 29;
|
||||
pms->count[0] += nbits;
|
||||
if (pms->count[0] < nbits)
|
||||
pms->count[1]++;
|
||||
|
||||
/* Process an initial partial block. */
|
||||
if (offset) {
|
||||
int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
|
||||
|
||||
memcpy(pms->buf + offset, p, copy);
|
||||
if (offset + copy < 64)
|
||||
return;
|
||||
p += copy;
|
||||
left -= copy;
|
||||
mongo_md5_process(pms, pms->buf);
|
||||
}
|
||||
|
||||
/* Process full blocks. */
|
||||
for (; left >= 64; p += 64, left -= 64)
|
||||
mongo_md5_process(pms, p);
|
||||
|
||||
/* Process a final partial block. */
|
||||
if (left)
|
||||
memcpy(pms->buf, p, left);
|
||||
}
|
||||
|
||||
void
|
||||
mongo_md5_finish(mongo_md5_state_t *pms, mongo_md5_byte_t digest[16])
|
||||
{
|
||||
static const mongo_md5_byte_t pad[64] = {
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
mongo_md5_byte_t data[8];
|
||||
int i;
|
||||
|
||||
/* Save the length before padding. */
|
||||
for (i = 0; i < 8; ++i)
|
||||
data[i] = (mongo_md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
|
||||
/* Pad to 56 bytes mod 64. */
|
||||
mongo_md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
|
||||
/* Append the length. */
|
||||
mongo_md5_append(pms, data, 8);
|
||||
for (i = 0; i < 16; ++i)
|
||||
digest[i] = (mongo_md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
L. Peter Deutsch
|
||||
ghost@aladdin.com
|
||||
|
||||
*/
|
||||
/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
|
||||
/*
|
||||
Independent implementation of MD5 (RFC 1321).
|
||||
|
||||
This code implements the MD5 Algorithm defined in RFC 1321, whose
|
||||
text is available at
|
||||
http://www.ietf.org/rfc/rfc1321.txt
|
||||
The code is derived from the text of the RFC, including the test suite
|
||||
(section A.5) but excluding the rest of Appendix A. It does not include
|
||||
any code or documentation that is identified in the RFC as being
|
||||
copyrighted.
|
||||
|
||||
The original and principal author of md5.h is L. Peter Deutsch
|
||||
<ghost@aladdin.com>. Other authors are noted in the change history
|
||||
that follows (in reverse chronological order):
|
||||
|
||||
2002-04-13 lpd Removed support for non-ANSI compilers; removed
|
||||
references to Ghostscript; clarified derivation from RFC 1321;
|
||||
now handles byte order either statically or dynamically.
|
||||
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
|
||||
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
|
||||
added conditionalization for C++ compilation from Martin
|
||||
Purschke <purschke@bnl.gov>.
|
||||
1999-05-03 lpd Original version.
|
||||
*/
|
||||
|
||||
#ifndef md5_INCLUDED
|
||||
# define md5_INCLUDED
|
||||
|
||||
/*
|
||||
* This package supports both compile-time and run-time determination of CPU
|
||||
* byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
|
||||
* compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is
|
||||
* defined as non-zero, the code will be compiled to run only on big-endian
|
||||
* CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to
|
||||
* run on either big- or little-endian CPUs, but will run slightly less
|
||||
* efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
|
||||
*/
|
||||
|
||||
typedef unsigned char mongo_md5_byte_t; /* 8-bit byte */
|
||||
typedef unsigned int mongo_md5_word_t; /* 32-bit word */
|
||||
|
||||
/* Define the state of the MD5 Algorithm. */
|
||||
typedef struct mongo_md5_state_s {
|
||||
mongo_md5_word_t count[2]; /* message length in bits, lsw first */
|
||||
mongo_md5_word_t abcd[4]; /* digest buffer */
|
||||
mongo_md5_byte_t buf[64]; /* accumulate block */
|
||||
} mongo_md5_state_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Initialize the algorithm. */
|
||||
void mongo_md5_init(mongo_md5_state_t *pms);
|
||||
|
||||
/* Append a string to the message. */
|
||||
void mongo_md5_append(mongo_md5_state_t *pms, const mongo_md5_byte_t *data, int nbytes);
|
||||
|
||||
/* Finish the message and return the digest. */
|
||||
void mongo_md5_finish(mongo_md5_state_t *pms, mongo_md5_byte_t digest[16]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* md5_INCLUDED */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,648 @@
|
||||
/**
|
||||
* @file mongo.h
|
||||
* @brief Main MongoDB Declarations
|
||||
*/
|
||||
|
||||
/* Copyright 2009-2011 10gen Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _MONGO_H_
|
||||
#define _MONGO_H_
|
||||
|
||||
#include "bson.h"
|
||||
|
||||
MONGO_EXTERN_C_START
|
||||
|
||||
#define MONGO_MAJOR 0
|
||||
#define MONGO_MINOR 4
|
||||
#define MONGO_PATCH 0
|
||||
|
||||
#define MONGO_OK 0
|
||||
#define MONGO_ERROR -1
|
||||
|
||||
#define MONGO_DEFAULT_PORT 27017
|
||||
|
||||
typedef enum mongo_error_t {
|
||||
MONGO_CONN_SUCCESS = 0, /**< Connection success! */
|
||||
MONGO_CONN_NO_SOCKET, /**< Could not create a socket. */
|
||||
MONGO_CONN_FAIL, /**< An error occured while calling connect(). */
|
||||
MONGO_CONN_ADDR_FAIL, /**< An error occured while calling getaddrinfo(). */
|
||||
MONGO_CONN_NOT_MASTER, /**< Warning: connected to a non-master node (read-only). */
|
||||
MONGO_CONN_BAD_SET_NAME, /**< Given rs name doesn't match this replica set. */
|
||||
MONGO_CONN_NO_PRIMARY, /**< Can't find primary in replica set. Connection closed. */
|
||||
|
||||
MONGO_IO_ERROR, /**< An error occurred while reading or writing on socket. */
|
||||
MONGO_READ_SIZE_ERROR, /**< The response is not the expected length. */
|
||||
MONGO_COMMAND_FAILED, /**< The command returned with 'ok' value of 0. */
|
||||
MONGO_CURSOR_EXHAUSTED, /**< The cursor has no more results. */
|
||||
MONGO_CURSOR_INVALID, /**< The cursor has timed out or is not recognized. */
|
||||
MONGO_CURSOR_PENDING, /**< Tailable cursor still alive but no data. */
|
||||
MONGO_BSON_INVALID, /**< BSON not valid for the specified op. */
|
||||
MONGO_BSON_NOT_FINISHED /**< BSON object has not been finished. */
|
||||
} mongo_error_t;
|
||||
|
||||
enum mongo_cursor_flags {
|
||||
MONGO_CURSOR_MUST_FREE = 1, /**< mongo_cursor_destroy should free cursor. */
|
||||
MONGO_CURSOR_QUERY_SENT = ( 1<<1 ) /**< Initial query has been sent. */
|
||||
};
|
||||
|
||||
enum mongo_index_opts {
|
||||
MONGO_INDEX_UNIQUE = ( 1<<0 ),
|
||||
MONGO_INDEX_DROP_DUPS = ( 1<<2 ),
|
||||
MONGO_INDEX_BACKGROUND = ( 1<<3 ),
|
||||
MONGO_INDEX_SPARSE = ( 1<<4 )
|
||||
};
|
||||
|
||||
enum mongo_update_opts {
|
||||
MONGO_UPDATE_UPSERT = 0x1,
|
||||
MONGO_UPDATE_MULTI = 0x2,
|
||||
MONGO_UPDATE_BASIC = 0x4
|
||||
};
|
||||
|
||||
enum mongo_cursor_opts {
|
||||
MONGO_TAILABLE = ( 1<<1 ), /**< Create a tailable cursor. */
|
||||
MONGO_SLAVE_OK = ( 1<<2 ), /**< Allow queries on a non-primary node. */
|
||||
MONGO_NO_CURSOR_TIMEOUT = ( 1<<4 ), /**< Disable cursor timeouts. */
|
||||
MONGO_AWAIT_DATA = ( 1<<5 ), /**< Momentarily block for more data. */
|
||||
MONGO_EXHAUST = ( 1<<6 ), /**< Stream in multiple 'more' packages. */
|
||||
MONGO_PARTIAL = ( 1<<7 ) /**< Allow reads even if a shard is down. */
|
||||
};
|
||||
|
||||
enum mongo_operations {
|
||||
MONGO_OP_MSG = 1000,
|
||||
MONGO_OP_UPDATE = 2001,
|
||||
MONGO_OP_INSERT = 2002,
|
||||
MONGO_OP_QUERY = 2004,
|
||||
MONGO_OP_GET_MORE = 2005,
|
||||
MONGO_OP_DELETE = 2006,
|
||||
MONGO_OP_KILL_CURSORS = 2007
|
||||
};
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
int len;
|
||||
int id;
|
||||
int responseTo;
|
||||
int op;
|
||||
} mongo_header;
|
||||
|
||||
typedef struct {
|
||||
mongo_header head;
|
||||
char data;
|
||||
} mongo_message;
|
||||
|
||||
typedef struct {
|
||||
int flag; /* FIX THIS COMMENT non-zero on failure */
|
||||
int64_t cursorID;
|
||||
int start;
|
||||
int num;
|
||||
} mongo_reply_fields;
|
||||
|
||||
typedef struct {
|
||||
mongo_header head;
|
||||
mongo_reply_fields fields;
|
||||
char objs;
|
||||
} mongo_reply;
|
||||
#pragma pack()
|
||||
|
||||
typedef struct mongo_host_port {
|
||||
char host[255];
|
||||
int port;
|
||||
struct mongo_host_port *next;
|
||||
} mongo_host_port;
|
||||
|
||||
typedef struct {
|
||||
mongo_host_port *seeds; /**< List of seeds provided by the user. */
|
||||
mongo_host_port *hosts; /**< List of host/ports given by the replica set */
|
||||
char *name; /**< Name of the replica set. */
|
||||
bson_bool_t primary_connected; /**< Primary node connection status. */
|
||||
} mongo_replset;
|
||||
|
||||
typedef struct mongo {
|
||||
mongo_host_port *primary; /**< Primary connection info. */
|
||||
mongo_replset *replset; /**< replset object if connected to a replica set. */
|
||||
int sock; /**< Socket file descriptor. */
|
||||
int flags; /**< Flags on this connection object. */
|
||||
int conn_timeout_ms; /**< Connection timeout in milliseconds. */
|
||||
int op_timeout_ms; /**< Read and write timeout in milliseconds. */
|
||||
bson_bool_t connected; /**< Connection status. */
|
||||
|
||||
mongo_error_t err; /**< Most recent driver error code. */
|
||||
char *errstr; /**< String version of most recent driver error code. */
|
||||
int lasterrcode; /**< getlasterror given by the server on calls. */
|
||||
char *lasterrstr; /**< getlasterror string generated by server. */
|
||||
} mongo;
|
||||
|
||||
typedef struct {
|
||||
mongo_reply *reply; /**< reply is owned by cursor */
|
||||
mongo *conn; /**< connection is *not* owned by cursor */
|
||||
const char *ns; /**< owned by cursor */
|
||||
int flags; /**< Flags used internally by this drivers. */
|
||||
int seen; /**< Number returned so far. */
|
||||
bson current; /**< This cursor's current bson object. */
|
||||
mongo_error_t err; /**< Errors on this cursor. */
|
||||
bson *query; /**< Bitfield containing cursor options. */
|
||||
bson *fields; /**< Bitfield containing cursor options. */
|
||||
int options; /**< Bitfield containing cursor options. */
|
||||
int limit; /**< Bitfield containing cursor options. */
|
||||
int skip; /**< Bitfield containing cursor options. */
|
||||
} mongo_cursor;
|
||||
|
||||
/* Connection API */
|
||||
|
||||
/** Initialize a new mongo connection object. If not created
|
||||
* with mongo_new, you must initialize each mongo
|
||||
* object using this function.
|
||||
*
|
||||
* @note When finished, you must pass this object to
|
||||
* mongo_destroy( ).
|
||||
*
|
||||
* @param conn a mongo connection object allocated on the stack
|
||||
* or heap.
|
||||
*/
|
||||
void mongo_init( mongo *conn );
|
||||
|
||||
/**
|
||||
* Connect to a single MongoDB server.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param host a numerical network address or a network hostname.
|
||||
* @param port the port to connect to.
|
||||
*
|
||||
* @return MONGO_OK or MONGO_ERROR on failure. On failure, a constant of type
|
||||
* mongo_conn_return_t will be set on the conn->err field.
|
||||
*/
|
||||
int mongo_connect( mongo *conn , const char *host, int port );
|
||||
|
||||
/**
|
||||
* Set up this connection object for connecting to a replica set.
|
||||
* To connect, pass the object to mongo_replset_connect().
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param name the name of the replica set to connect to.
|
||||
* */
|
||||
void mongo_replset_init( mongo *conn, const char *name );
|
||||
|
||||
/**
|
||||
* Add a seed node to the replica set connection object.
|
||||
*
|
||||
* You must specify at least one seed node before connecting to a replica set.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param host a numerical network address or a network hostname.
|
||||
* @param port the port to connect to.
|
||||
*/
|
||||
void mongo_replset_add_seed( mongo *conn, const char *host, int port );
|
||||
|
||||
/**
|
||||
* Utility function for converting a host-port string to a mongo_host_port.
|
||||
*
|
||||
* @param host_string a string containing either a host or a host and port separated
|
||||
* by a colon.
|
||||
* @param host_port the mongo_host_port object to write the result to.
|
||||
*/
|
||||
void mongo_parse_host( const char *host_string, mongo_host_port *host_port );
|
||||
|
||||
/**
|
||||
* Connect to a replica set.
|
||||
*
|
||||
* Before passing a connection object to this function, you must already have called
|
||||
* mongo_set_replset and mongo_replset_add_seed.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
*
|
||||
* @return MONGO_OK or MONGO_ERROR on failure. On failure, a constant of type
|
||||
* mongo_conn_return_t will be set on the conn->err field.
|
||||
*/
|
||||
int mongo_replset_connect( mongo *conn );
|
||||
|
||||
/** Set a timeout for operations on this connection. This
|
||||
* is a platform-specific feature, and only work on *nix
|
||||
* system. You must also compile for linux to support this.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param millis timeout time in milliseconds.
|
||||
*
|
||||
* @return MONGO_OK. On error, return MONGO_ERROR and
|
||||
* set the conn->err field.
|
||||
*/
|
||||
int mongo_set_op_timeout( mongo *conn, int millis );
|
||||
|
||||
/**
|
||||
* Ensure that this connection is healthy by performing
|
||||
* a round-trip to the server.
|
||||
*
|
||||
* @param conn a mongo connection
|
||||
*
|
||||
* @return MONGO_OK if connected; otherwise, MONGO_ERROR.
|
||||
*/
|
||||
int mongo_check_connection( mongo *conn );
|
||||
|
||||
/**
|
||||
* Try reconnecting to the server using the existing connection settings.
|
||||
*
|
||||
* This function will disconnect the current socket. If you've authenticated,
|
||||
* you'll need to re-authenticate after calling this function.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
*
|
||||
* @return MONGO_OK or MONGO_ERROR and
|
||||
* set the conn->err field.
|
||||
*/
|
||||
int mongo_reconnect( mongo *conn );
|
||||
|
||||
/**
|
||||
* Close the current connection to the server. After calling
|
||||
* this function, you may call mongo_reconnect with the same
|
||||
* connection object.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
*/
|
||||
void mongo_disconnect( mongo *conn );
|
||||
|
||||
/**
|
||||
* Close any existing connection to the server and free all allocated
|
||||
* memory associated with the conn object.
|
||||
*
|
||||
* You must always call this function when finished with the connection object.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
*/
|
||||
void mongo_destroy( mongo *conn );
|
||||
|
||||
/**
|
||||
* Insert a BSON document into a MongoDB server. This function
|
||||
* will fail if the supplied BSON struct is not UTF-8 or if
|
||||
* the keys are invalid for insert (contain '.' or start with '$').
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param ns the namespace.
|
||||
* @param data the bson data.
|
||||
*
|
||||
* @return MONGO_OK or MONGO_ERROR. If the conn->err
|
||||
* field is MONGO_BSON_INVALID, check the err field
|
||||
* on the bson struct for the reason.
|
||||
*/
|
||||
int mongo_insert( mongo *conn, const char *ns, bson *data );
|
||||
|
||||
/**
|
||||
* Insert a batch of BSON documents into a MongoDB server. This function
|
||||
* will fail if any of the documents to be inserted is invalid.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param ns the namespace.
|
||||
* @param data the bson data.
|
||||
* @param num the number of documents in data.
|
||||
*
|
||||
* @return MONGO_OK or MONGO_ERROR.
|
||||
*
|
||||
*/
|
||||
int mongo_insert_batch( mongo *conn , const char *ns ,
|
||||
bson **data , int num );
|
||||
|
||||
/**
|
||||
* Update a document in a MongoDB server.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param ns the namespace.
|
||||
* @param cond the bson update query.
|
||||
* @param op the bson update data.
|
||||
* @param flags flags for the update.
|
||||
*
|
||||
* @return MONGO_OK or MONGO_ERROR with error stored in conn object.
|
||||
*
|
||||
*/
|
||||
int mongo_update( mongo *conn, const char *ns, const bson *cond,
|
||||
const bson *op, int flags );
|
||||
|
||||
/**
|
||||
* Remove a document from a MongoDB server.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param ns the namespace.
|
||||
* @param cond the bson query.
|
||||
*
|
||||
* @return MONGO_OK or MONGO_ERROR with error stored in conn object.
|
||||
*/
|
||||
int mongo_remove( mongo *conn, const char *ns, const bson *cond );
|
||||
|
||||
/**
|
||||
* Find documents in a MongoDB server.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param ns the namespace.
|
||||
* @param query the bson query.
|
||||
* @param fields a bson document of fields to be returned.
|
||||
* @param limit the maximum number of documents to retrun.
|
||||
* @param skip the number of documents to skip.
|
||||
* @param options A bitfield containing cursor options.
|
||||
*
|
||||
* @return A cursor object allocated on the heap or NULL if
|
||||
* an error has occurred. For finer-grained error checking,
|
||||
* use the cursor builder API instead.
|
||||
*/
|
||||
mongo_cursor *mongo_find( mongo *conn, const char *ns, bson *query,
|
||||
bson *fields, int limit, int skip, int options );
|
||||
|
||||
/**
|
||||
* Initalize a new cursor object.
|
||||
*
|
||||
* @param cursor
|
||||
* @param ns the namespace, represented as the the database
|
||||
* name and collection name separated by a dot. e.g., "test.users"
|
||||
*/
|
||||
void mongo_cursor_init( mongo_cursor *cursor, mongo *conn, const char *ns );
|
||||
|
||||
/**
|
||||
* Set the bson object specifying this cursor's query spec. If
|
||||
* your query is the empty bson object "{}", then you need not
|
||||
* set this value.
|
||||
*
|
||||
* @param cursor
|
||||
* @param query a bson object representing the query spec. This may
|
||||
* be either a simple query spec or a complex spec storing values for
|
||||
* $query, $orderby, $hint, and/or $explain. See
|
||||
* http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol for details.
|
||||
*/
|
||||
void mongo_cursor_set_query( mongo_cursor *cursor, bson *query );
|
||||
|
||||
/**
|
||||
* Set the fields to return for this cursor. If you want to return
|
||||
* all fields, you need not set this value.
|
||||
*
|
||||
* @param cursor
|
||||
* @param fields a bson object representing the fields to return.
|
||||
* See http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields.
|
||||
*/
|
||||
void mongo_cursor_set_fields( mongo_cursor *cursor, bson *fields );
|
||||
|
||||
/**
|
||||
* Set the number of documents to skip.
|
||||
*
|
||||
* @param cursor
|
||||
* @param skip
|
||||
*/
|
||||
void mongo_cursor_set_skip( mongo_cursor *cursor, int skip );
|
||||
|
||||
/**
|
||||
* Set the number of documents to return.
|
||||
*
|
||||
* @param cursor
|
||||
* @param limit
|
||||
*/
|
||||
void mongo_cursor_set_limit( mongo_cursor *cursor, int limit );
|
||||
|
||||
/**
|
||||
* Set any of the available query options (e.g., MONGO_TAILABLE).
|
||||
*
|
||||
* @param cursor
|
||||
* @param options a bitfield storing query options. See
|
||||
* mongo_cursor_bitfield_t for available constants.
|
||||
*/
|
||||
void mongo_cursor_set_options( mongo_cursor *cursor, int options );
|
||||
|
||||
/**
|
||||
* Return the current BSON object data as a const char*. This is useful
|
||||
* for creating bson iterators with bson_iterator_init.
|
||||
*
|
||||
* @param cursor
|
||||
*/
|
||||
const char *mongo_cursor_data( mongo_cursor *cursor );
|
||||
|
||||
/**
|
||||
* Return the current BSON object data as a const char*. This is useful
|
||||
* for creating bson iterators with bson_iterator_init.
|
||||
*
|
||||
* @param cursor
|
||||
*/
|
||||
const bson *mongo_cursor_bson( mongo_cursor *cursor );
|
||||
|
||||
/**
|
||||
* Iterate the cursor, returning the next item. When successful,
|
||||
* the returned object will be stored in cursor->current;
|
||||
*
|
||||
* @param cursor
|
||||
*
|
||||
* @return MONGO_OK. On error, returns MONGO_ERROR and sets
|
||||
* cursor->err with a value of mongo_error_t.
|
||||
*/
|
||||
int mongo_cursor_next( mongo_cursor *cursor );
|
||||
|
||||
/**
|
||||
* Destroy a cursor object. When finished with a cursor, you
|
||||
* must pass it to this function.
|
||||
*
|
||||
* @param cursor the cursor to destroy.
|
||||
*
|
||||
* @return MONGO_OK or an error code. On error, check cursor->conn->err
|
||||
* for errors.
|
||||
*/
|
||||
int mongo_cursor_destroy( mongo_cursor *cursor );
|
||||
|
||||
/**
|
||||
* Find a single document in a MongoDB server.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param ns the namespace.
|
||||
* @param query the bson query.
|
||||
* @param fields a bson document of the fields to be returned.
|
||||
* @param out a bson document in which to put the query result.
|
||||
*
|
||||
*/
|
||||
/* out can be NULL if you don't care about results. useful for commands */
|
||||
bson_bool_t mongo_find_one( mongo *conn, const char *ns, bson *query,
|
||||
bson *fields, bson *out );
|
||||
|
||||
/* MongoDB Helper Functions */
|
||||
|
||||
/**
|
||||
* Count the number of documents in a collection matching a query.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param db the db name.
|
||||
* @param coll the collection name.
|
||||
* @param query the BSON query.
|
||||
*
|
||||
* @return the number of matching documents. If the command fails,
|
||||
* MONGO_ERROR is returned.
|
||||
*/
|
||||
int64_t mongo_count( mongo *conn, const char *db, const char *coll,
|
||||
bson *query );
|
||||
|
||||
/**
|
||||
* Create a compouned index.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param ns the namespace.
|
||||
* @param data the bson index data.
|
||||
* @param options a bitfield for setting index options. Possibilities include
|
||||
* MONGO_INDEX_UNIQUE, MONGO_INDEX_DROP_DUPS, MONGO_INDEX_BACKGROUND,
|
||||
* and MONGO_INDEX_SPARSE.
|
||||
* @param out a bson document containing errors, if any.
|
||||
*
|
||||
* @return MONGO_OK if index is created successfully; otherwise, MONGO_ERROR.
|
||||
*/
|
||||
int mongo_create_index( mongo *conn, const char *ns, bson *key, int options, bson *out );
|
||||
|
||||
/**
|
||||
* Create an index with a single key.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param ns the namespace.
|
||||
* @param field the index key.
|
||||
* @param options index options.
|
||||
* @param out a BSON document containing errors, if any.
|
||||
*
|
||||
* @return true if the index was created.
|
||||
*/
|
||||
bson_bool_t mongo_create_simple_index( mongo *conn, const char *ns, const char *field, int options, bson *out );
|
||||
|
||||
/* ----------------------------
|
||||
COMMANDS
|
||||
------------------------------ */
|
||||
|
||||
/**
|
||||
* Run a command on a MongoDB server.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param db the name of the database.
|
||||
* @param command the BSON command to run.
|
||||
* @param out the BSON result of the command.
|
||||
*
|
||||
* @return true if the command ran without error.
|
||||
*/
|
||||
bson_bool_t mongo_run_command( mongo *conn, const char *db, bson *command, bson *out );
|
||||
|
||||
/**
|
||||
* Run a command that accepts a simple string key and integer value.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param db the name of the database.
|
||||
* @param cmd the command to run.
|
||||
* @param arg the integer argument to the command.
|
||||
* @param out the BSON result of the command.
|
||||
*
|
||||
* @return MONGO_OK or an error code.
|
||||
*
|
||||
*/
|
||||
int mongo_simple_int_command( mongo *conn, const char *db,
|
||||
const char *cmd, int arg, bson *out );
|
||||
|
||||
/**
|
||||
* Run a command that accepts a simple string key and value.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param db the name of the database.
|
||||
* @param cmd the command to run.
|
||||
* @param arg the string argument to the command.
|
||||
* @param out the BSON result of the command.
|
||||
*
|
||||
* @return true if the command ran without error.
|
||||
*
|
||||
*/
|
||||
bson_bool_t mongo_simple_str_command( mongo *conn, const char *db, const char *cmd, const char *arg, bson *out );
|
||||
|
||||
/**
|
||||
* Drop a database.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param db the name of the database to drop.
|
||||
*
|
||||
* @return MONGO_OK or an error code.
|
||||
*/
|
||||
int mongo_cmd_drop_db( mongo *conn, const char *db );
|
||||
|
||||
/**
|
||||
* Drop a collection.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param db the name of the database.
|
||||
* @param collection the name of the collection to drop.
|
||||
* @param out a BSON document containing the result of the command.
|
||||
*
|
||||
* @return true if the collection drop was successful.
|
||||
*/
|
||||
bson_bool_t mongo_cmd_drop_collection( mongo *conn, const char *db, const char *collection, bson *out );
|
||||
|
||||
/**
|
||||
* Add a database user.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param db the database in which to add the user.
|
||||
* @param user the user name
|
||||
* @param pass the user password
|
||||
*
|
||||
* @return MONGO_OK or MONGO_ERROR.
|
||||
*/
|
||||
int mongo_cmd_add_user( mongo *conn, const char *db, const char *user, const char *pass );
|
||||
|
||||
/**
|
||||
* Authenticate a user.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param db the database to authenticate against.
|
||||
* @param user the user name to authenticate.
|
||||
* @param pass the user's password.
|
||||
*
|
||||
* @return MONGO_OK on sucess and MONGO_ERROR on failure.
|
||||
*/
|
||||
int mongo_cmd_authenticate( mongo *conn, const char *db, const char *user, const char *pass );
|
||||
|
||||
/**
|
||||
* Check if the current server is a master.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param out a BSON result of the command.
|
||||
*
|
||||
* @return true if the server is a master.
|
||||
*/
|
||||
/* return value is master status */
|
||||
bson_bool_t mongo_cmd_ismaster( mongo *conn, bson *out );
|
||||
|
||||
/**
|
||||
* Get the error for the last command with the current connection.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param db the name of the database.
|
||||
* @param out a BSON object containing the error details.
|
||||
*
|
||||
* @return MONGO_OK if no error and MONGO_ERROR on error. On error, check the values
|
||||
* of conn->lasterrcode and conn->lasterrstr for the error status.
|
||||
*/
|
||||
int mongo_cmd_get_last_error( mongo *conn, const char *db, bson *out );
|
||||
|
||||
/**
|
||||
* Get the most recent error with the current connection.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param db the name of the database.
|
||||
* @param out a BSON object containing the error details.
|
||||
*
|
||||
* @return MONGO_OK if no error and MONGO_ERROR on error. On error, check the values
|
||||
* of conn->lasterrcode and conn->lasterrstr for the error status.
|
||||
*/
|
||||
int mongo_cmd_get_prev_error( mongo *conn, const char *db, bson *out );
|
||||
|
||||
/**
|
||||
* Reset the error state for the connection.
|
||||
*
|
||||
* @param conn a mongo object.
|
||||
* @param db the name of the database.
|
||||
*/
|
||||
void mongo_cmd_reset_error( mongo *conn, const char *db );
|
||||
|
||||
MONGO_EXTERN_C_END
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,98 @@
|
||||
/* net.c */
|
||||
|
||||
/* Copyright 2009-2011 10gen Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* Implementation for generic version of net.h */
|
||||
#include "net.h"
|
||||
#include <string.h>
|
||||
|
||||
int mongo_write_socket( mongo *conn, const void *buf, int len ) {
|
||||
const char *cbuf = buf;
|
||||
while ( len ) {
|
||||
int sent = send( conn->sock, cbuf, len, 0 );
|
||||
if ( sent == -1 ) {
|
||||
conn->err = MONGO_IO_ERROR;
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
cbuf += sent;
|
||||
len -= sent;
|
||||
}
|
||||
|
||||
return MONGO_OK;
|
||||
}
|
||||
|
||||
int mongo_read_socket( mongo *conn, void *buf, int len ) {
|
||||
char *cbuf = buf;
|
||||
while ( len ) {
|
||||
int sent = recv( conn->sock, cbuf, len, 0 );
|
||||
if ( sent == 0 || sent == -1 ) {
|
||||
conn->err = MONGO_IO_ERROR;
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
cbuf += sent;
|
||||
len -= sent;
|
||||
}
|
||||
|
||||
return MONGO_OK;
|
||||
}
|
||||
|
||||
/* This is a no-op in the generic implementation. */
|
||||
int mongo_set_socket_op_timeout( mongo *conn, int millis ) {
|
||||
return MONGO_OK;
|
||||
}
|
||||
|
||||
static int mongo_create_socket( mongo *conn ) {
|
||||
int fd;
|
||||
|
||||
if( ( fd = socket( AF_INET, SOCK_STREAM, 0 ) ) == -1 ) {
|
||||
conn->err = MONGO_CONN_NO_SOCKET;
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
conn->sock = fd;
|
||||
|
||||
return MONGO_OK;
|
||||
}
|
||||
|
||||
int mongo_socket_connect( mongo *conn, const char *host, int port ) {
|
||||
struct sockaddr_in sa;
|
||||
socklen_t addressSize;
|
||||
int flag = 1;
|
||||
|
||||
if( mongo_create_socket( conn ) != MONGO_OK )
|
||||
return MONGO_ERROR;
|
||||
|
||||
memset( sa.sin_zero , 0 , sizeof( sa.sin_zero ) );
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons( port );
|
||||
sa.sin_addr.s_addr = inet_addr( host );
|
||||
addressSize = sizeof( sa );
|
||||
|
||||
if ( connect( conn->sock, ( struct sockaddr * )&sa, addressSize ) == -1 ) {
|
||||
mongo_close_socket( conn->sock );
|
||||
conn->connected = 0;
|
||||
conn->sock = 0;
|
||||
conn->err = MONGO_CONN_FAIL;
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
|
||||
setsockopt( conn->sock, IPPROTO_TCP, TCP_NODELAY, ( char * ) &flag, sizeof( flag ) );
|
||||
if( conn->op_timeout_ms > 0 )
|
||||
mongo_set_socket_op_timeout( conn, conn->op_timeout_ms );
|
||||
|
||||
conn->connected = 1;
|
||||
|
||||
return MONGO_OK;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/** @file net.h */
|
||||
|
||||
/* Copyright 2009-2011 10gen Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* Header for generic net.h */
|
||||
#ifndef _MONGO_NET_H_
|
||||
#define _MONGO_NET_H_
|
||||
|
||||
#include "mongo.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <winsock.h>
|
||||
#define mongo_close_socket(sock) ( closesocket(sock) )
|
||||
typedef int socklen_t;
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <fcntl.h>
|
||||
#define mongo_close_socket(sock) ( close(sock) )
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE) || _POSIX_C_SOURCE >= 1
|
||||
#define _MONGO_USE_GETADDRINFO
|
||||
#endif
|
||||
|
||||
MONGO_EXTERN_C_START
|
||||
|
||||
/* This is a no-op in the generic implementation. */
|
||||
int mongo_set_socket_op_timeout( mongo *conn, int millis );
|
||||
int mongo_read_socket( mongo *conn, void *buf, int len );
|
||||
int mongo_write_socket( mongo *conn, const void *buf, int len );
|
||||
int mongo_socket_connect( mongo *conn, const char *host, int port );
|
||||
|
||||
MONGO_EXTERN_C_END
|
||||
#endif
|
||||
@@ -0,0 +1,127 @@
|
||||
/* Copyright 2009-2011 10gen Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* all the numbers that fit in a 4 byte string */
|
||||
const char bson_numstrs[1000][4] = {
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||
"10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
|
||||
"20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
|
||||
"30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
|
||||
"40", "41", "42", "43", "44", "45", "46", "47", "48", "49",
|
||||
"50", "51", "52", "53", "54", "55", "56", "57", "58", "59",
|
||||
"60", "61", "62", "63", "64", "65", "66", "67", "68", "69",
|
||||
"70", "71", "72", "73", "74", "75", "76", "77", "78", "79",
|
||||
"80", "81", "82", "83", "84", "85", "86", "87", "88", "89",
|
||||
"90", "91", "92", "93", "94", "95", "96", "97", "98", "99",
|
||||
|
||||
"100", "101", "102", "103", "104", "105", "106", "107", "108", "109",
|
||||
"110", "111", "112", "113", "114", "115", "116", "117", "118", "119",
|
||||
"120", "121", "122", "123", "124", "125", "126", "127", "128", "129",
|
||||
"130", "131", "132", "133", "134", "135", "136", "137", "138", "139",
|
||||
"140", "141", "142", "143", "144", "145", "146", "147", "148", "149",
|
||||
"150", "151", "152", "153", "154", "155", "156", "157", "158", "159",
|
||||
"160", "161", "162", "163", "164", "165", "166", "167", "168", "169",
|
||||
"170", "171", "172", "173", "174", "175", "176", "177", "178", "179",
|
||||
"180", "181", "182", "183", "184", "185", "186", "187", "188", "189",
|
||||
"190", "191", "192", "193", "194", "195", "196", "197", "198", "199",
|
||||
|
||||
"200", "201", "202", "203", "204", "205", "206", "207", "208", "209",
|
||||
"210", "211", "212", "213", "214", "215", "216", "217", "218", "219",
|
||||
"220", "221", "222", "223", "224", "225", "226", "227", "228", "229",
|
||||
"230", "231", "232", "233", "234", "235", "236", "237", "238", "239",
|
||||
"240", "241", "242", "243", "244", "245", "246", "247", "248", "249",
|
||||
"250", "251", "252", "253", "254", "255", "256", "257", "258", "259",
|
||||
"260", "261", "262", "263", "264", "265", "266", "267", "268", "269",
|
||||
"270", "271", "272", "273", "274", "275", "276", "277", "278", "279",
|
||||
"280", "281", "282", "283", "284", "285", "286", "287", "288", "289",
|
||||
"290", "291", "292", "293", "294", "295", "296", "297", "298", "299",
|
||||
|
||||
"300", "301", "302", "303", "304", "305", "306", "307", "308", "309",
|
||||
"310", "311", "312", "313", "314", "315", "316", "317", "318", "319",
|
||||
"320", "321", "322", "323", "324", "325", "326", "327", "328", "329",
|
||||
"330", "331", "332", "333", "334", "335", "336", "337", "338", "339",
|
||||
"340", "341", "342", "343", "344", "345", "346", "347", "348", "349",
|
||||
"350", "351", "352", "353", "354", "355", "356", "357", "358", "359",
|
||||
"360", "361", "362", "363", "364", "365", "366", "367", "368", "369",
|
||||
"370", "371", "372", "373", "374", "375", "376", "377", "378", "379",
|
||||
"380", "381", "382", "383", "384", "385", "386", "387", "388", "389",
|
||||
"390", "391", "392", "393", "394", "395", "396", "397", "398", "399",
|
||||
|
||||
"400", "401", "402", "403", "404", "405", "406", "407", "408", "409",
|
||||
"410", "411", "412", "413", "414", "415", "416", "417", "418", "419",
|
||||
"420", "421", "422", "423", "424", "425", "426", "427", "428", "429",
|
||||
"430", "431", "432", "433", "434", "435", "436", "437", "438", "439",
|
||||
"440", "441", "442", "443", "444", "445", "446", "447", "448", "449",
|
||||
"450", "451", "452", "453", "454", "455", "456", "457", "458", "459",
|
||||
"460", "461", "462", "463", "464", "465", "466", "467", "468", "469",
|
||||
"470", "471", "472", "473", "474", "475", "476", "477", "478", "479",
|
||||
"480", "481", "482", "483", "484", "485", "486", "487", "488", "489",
|
||||
"490", "491", "492", "493", "494", "495", "496", "497", "498", "499",
|
||||
|
||||
"500", "501", "502", "503", "504", "505", "506", "507", "508", "509",
|
||||
"510", "511", "512", "513", "514", "515", "516", "517", "518", "519",
|
||||
"520", "521", "522", "523", "524", "525", "526", "527", "528", "529",
|
||||
"530", "531", "532", "533", "534", "535", "536", "537", "538", "539",
|
||||
"540", "541", "542", "543", "544", "545", "546", "547", "548", "549",
|
||||
"550", "551", "552", "553", "554", "555", "556", "557", "558", "559",
|
||||
"560", "561", "562", "563", "564", "565", "566", "567", "568", "569",
|
||||
"570", "571", "572", "573", "574", "575", "576", "577", "578", "579",
|
||||
"580", "581", "582", "583", "584", "585", "586", "587", "588", "589",
|
||||
"590", "591", "592", "593", "594", "595", "596", "597", "598", "599",
|
||||
|
||||
"600", "601", "602", "603", "604", "605", "606", "607", "608", "609",
|
||||
"610", "611", "612", "613", "614", "615", "616", "617", "618", "619",
|
||||
"620", "621", "622", "623", "624", "625", "626", "627", "628", "629",
|
||||
"630", "631", "632", "633", "634", "635", "636", "637", "638", "639",
|
||||
"640", "641", "642", "643", "644", "645", "646", "647", "648", "649",
|
||||
"650", "651", "652", "653", "654", "655", "656", "657", "658", "659",
|
||||
"660", "661", "662", "663", "664", "665", "666", "667", "668", "669",
|
||||
"670", "671", "672", "673", "674", "675", "676", "677", "678", "679",
|
||||
"680", "681", "682", "683", "684", "685", "686", "687", "688", "689",
|
||||
"690", "691", "692", "693", "694", "695", "696", "697", "698", "699",
|
||||
|
||||
"700", "701", "702", "703", "704", "705", "706", "707", "708", "709",
|
||||
"710", "711", "712", "713", "714", "715", "716", "717", "718", "719",
|
||||
"720", "721", "722", "723", "724", "725", "726", "727", "728", "729",
|
||||
"730", "731", "732", "733", "734", "735", "736", "737", "738", "739",
|
||||
"740", "741", "742", "743", "744", "745", "746", "747", "748", "749",
|
||||
"750", "751", "752", "753", "754", "755", "756", "757", "758", "759",
|
||||
"760", "761", "762", "763", "764", "765", "766", "767", "768", "769",
|
||||
"770", "771", "772", "773", "774", "775", "776", "777", "778", "779",
|
||||
"780", "781", "782", "783", "784", "785", "786", "787", "788", "789",
|
||||
"790", "791", "792", "793", "794", "795", "796", "797", "798", "799",
|
||||
|
||||
"800", "801", "802", "803", "804", "805", "806", "807", "808", "809",
|
||||
"810", "811", "812", "813", "814", "815", "816", "817", "818", "819",
|
||||
"820", "821", "822", "823", "824", "825", "826", "827", "828", "829",
|
||||
"830", "831", "832", "833", "834", "835", "836", "837", "838", "839",
|
||||
"840", "841", "842", "843", "844", "845", "846", "847", "848", "849",
|
||||
"850", "851", "852", "853", "854", "855", "856", "857", "858", "859",
|
||||
"860", "861", "862", "863", "864", "865", "866", "867", "868", "869",
|
||||
"870", "871", "872", "873", "874", "875", "876", "877", "878", "879",
|
||||
"880", "881", "882", "883", "884", "885", "886", "887", "888", "889",
|
||||
"890", "891", "892", "893", "894", "895", "896", "897", "898", "899",
|
||||
|
||||
"900", "901", "902", "903", "904", "905", "906", "907", "908", "909",
|
||||
"910", "911", "912", "913", "914", "915", "916", "917", "918", "919",
|
||||
"920", "921", "922", "923", "924", "925", "926", "927", "928", "929",
|
||||
"930", "931", "932", "933", "934", "935", "936", "937", "938", "939",
|
||||
"940", "941", "942", "943", "944", "945", "946", "947", "948", "949",
|
||||
"950", "951", "952", "953", "954", "955", "956", "957", "958", "959",
|
||||
"960", "961", "962", "963", "964", "965", "966", "967", "968", "969",
|
||||
"970", "971", "972", "973", "974", "975", "976", "977", "978", "979",
|
||||
"980", "981", "982", "983", "984", "985", "986", "987", "988", "989",
|
||||
"990", "991", "992", "993", "994", "995", "996", "997", "998", "999",
|
||||
};
|
||||
@@ -0,0 +1,94 @@
|
||||
/** @file platform.h */
|
||||
|
||||
/** Copyright 2009-2011 10gen Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
/* all platform-specific ifdefs should go here */
|
||||
|
||||
#ifndef _PLATFORM_HACKS_H_
|
||||
#define _PLATFORM_HACKS_H_
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define MONGO_INLINE static __inline__
|
||||
#else
|
||||
#define MONGO_INLINE static
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define MONGO_EXTERN_C_START extern "C" {
|
||||
#define MONGO_EXTERN_C_END }
|
||||
#else
|
||||
#define MONGO_EXTERN_C_START
|
||||
#define MONGO_EXTERN_C_END
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(MONGO_HAVE_STDINT) || __STDC_VERSION__ >= 199901L
|
||||
#include <stdint.h>
|
||||
#elif defined(MONGO_HAVE_UNISTD)
|
||||
#include <unistd.h>
|
||||
#elif defined(MONGO_USE__INT64)
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#elif defined(MONGO_USE_LONG_LONG_INT)
|
||||
typedef long long int int64_t;
|
||||
typedef unsigned long long int uint64_t;
|
||||
#else
|
||||
#error must have a 64bit int type
|
||||
#endif
|
||||
|
||||
/* big endian is only used for OID generation. little is used everywhere else */
|
||||
#ifdef MONGO_BIG_ENDIAN
|
||||
#define bson_little_endian64(out, in) ( bson_swap_endian64(out, in) )
|
||||
#define bson_little_endian32(out, in) ( bson_swap_endian32(out, in) )
|
||||
#define bson_big_endian64(out, in) ( memcpy(out, in, 8) )
|
||||
#define bson_big_endian32(out, in) ( memcpy(out, in, 4) )
|
||||
#else
|
||||
#define bson_little_endian64(out, in) ( memcpy(out, in, 8) )
|
||||
#define bson_little_endian32(out, in) ( memcpy(out, in, 4) )
|
||||
#define bson_big_endian64(out, in) ( bson_swap_endian64(out, in) )
|
||||
#define bson_big_endian32(out, in) ( bson_swap_endian32(out, in) )
|
||||
#endif
|
||||
|
||||
MONGO_EXTERN_C_START
|
||||
|
||||
MONGO_INLINE void bson_swap_endian64( void *outp, const void *inp ) {
|
||||
const char *in = ( const char * )inp;
|
||||
char *out = ( char * )outp;
|
||||
|
||||
out[0] = in[7];
|
||||
out[1] = in[6];
|
||||
out[2] = in[5];
|
||||
out[3] = in[4];
|
||||
out[4] = in[3];
|
||||
out[5] = in[2];
|
||||
out[6] = in[1];
|
||||
out[7] = in[0];
|
||||
|
||||
}
|
||||
MONGO_INLINE void bson_swap_endian32( void *outp, const void *inp ) {
|
||||
const char *in = ( const char * )inp;
|
||||
char *out = ( char * )outp;
|
||||
|
||||
out[0] = in[3];
|
||||
out[1] = in[2];
|
||||
out[2] = in[1];
|
||||
out[3] = in[0];
|
||||
}
|
||||
|
||||
MONGO_EXTERN_C_END
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,183 @@
|
||||
/* net.c */
|
||||
|
||||
/* Copyright 2009-2011 10gen Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* Implementation for Linux version of net.h */
|
||||
#include "net.h"
|
||||
#include <string.h>
|
||||
|
||||
int mongo_write_socket( mongo *conn, const void *buf, int len ) {
|
||||
const char *cbuf = buf;
|
||||
while ( len ) {
|
||||
int sent = send( conn->sock, cbuf, len, 0 );
|
||||
if ( sent == -1 ) {
|
||||
conn->err = MONGO_IO_ERROR;
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
cbuf += sent;
|
||||
len -= sent;
|
||||
}
|
||||
|
||||
return MONGO_OK;
|
||||
}
|
||||
|
||||
int mongo_read_socket( mongo *conn, void *buf, int len ) {
|
||||
char *cbuf = buf;
|
||||
while ( len ) {
|
||||
int sent = recv( conn->sock, cbuf, len, 0 );
|
||||
if ( sent == 0 || sent == -1 ) {
|
||||
conn->err = MONGO_IO_ERROR;
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
cbuf += sent;
|
||||
len -= sent;
|
||||
}
|
||||
|
||||
return MONGO_OK;
|
||||
}
|
||||
|
||||
static int mongo_create_socket( mongo *conn ) {
|
||||
int fd;
|
||||
|
||||
if( ( fd = socket( AF_INET, SOCK_STREAM, 0 ) ) == -1 ) {
|
||||
conn->err = MONGO_CONN_NO_SOCKET;
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
conn->sock = fd;
|
||||
|
||||
return MONGO_OK;
|
||||
}
|
||||
|
||||
static int mongo_set_blocking_status( mongo *conn ) {
|
||||
int flags;
|
||||
int blocking;
|
||||
|
||||
blocking = ( conn->conn_timeout_ms == 0 );
|
||||
if( blocking )
|
||||
return MONGO_OK;
|
||||
else {
|
||||
if( ( flags = fcntl( conn->sock, F_GETFL ) ) == -1 ) {
|
||||
conn->err = MONGO_IO_ERROR;
|
||||
mongo_close_socket( conn->sock );
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
|
||||
flags |= O_NONBLOCK;
|
||||
|
||||
if( ( flags = fcntl( conn->sock, F_SETFL, flags ) ) == -1 ) {
|
||||
conn->err = MONGO_IO_ERROR;
|
||||
mongo_close_socket( conn->sock );
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return MONGO_OK;
|
||||
}
|
||||
|
||||
int mongo_set_socket_op_timeout( mongo *conn, int millis ) {
|
||||
struct timeval tv;
|
||||
tv.tv_sec = millis / 1000;
|
||||
tv.tv_usec = ( millis % 1000 ) * 1000;
|
||||
|
||||
if ( setsockopt( conn->sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof( tv ) ) == -1 ) {
|
||||
conn->err = MONGO_IO_ERROR;
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
|
||||
if ( setsockopt( conn->sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof( tv ) ) == -1 ) {
|
||||
conn->err = MONGO_IO_ERROR;
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
|
||||
return MONGO_OK;
|
||||
}
|
||||
|
||||
#ifdef _MONGO_USE_GETADDRINFO
|
||||
int mongo_socket_connect( mongo *conn, const char *host, int port ) {
|
||||
|
||||
struct addrinfo *addrs = NULL;
|
||||
struct addrinfo hints;
|
||||
int flag = 1;
|
||||
char port_str[12];
|
||||
int ret;
|
||||
|
||||
conn->sock = 0;
|
||||
conn->connected = 0;
|
||||
|
||||
memset( &hints, 0, sizeof( hints ) );
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
sprintf( port_str, "%d", port );
|
||||
|
||||
if( mongo_create_socket( conn ) != MONGO_OK )
|
||||
return MONGO_ERROR;
|
||||
|
||||
if( getaddrinfo( host, port_str, &hints, &addrs ) != 0 ) {
|
||||
bson_errprintf( "getaddrinfo failed: %s", gai_strerror( ret ) );
|
||||
conn->err = MONGO_CONN_ADDR_FAIL;
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
|
||||
if ( connect( conn->sock, addrs->ai_addr, addrs->ai_addrlen ) == -1 ) {
|
||||
mongo_close_socket( conn->sock );
|
||||
freeaddrinfo( addrs );
|
||||
conn->err = MONGO_CONN_FAIL;
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
|
||||
setsockopt( conn->sock, IPPROTO_TCP, TCP_NODELAY, ( char * )&flag, sizeof( flag ) );
|
||||
if( conn->op_timeout_ms > 0 )
|
||||
mongo_set_socket_op_timeout( conn, conn->op_timeout_ms );
|
||||
|
||||
conn->connected = 1;
|
||||
freeaddrinfo( addrs );
|
||||
|
||||
return MONGO_OK;
|
||||
}
|
||||
#else
|
||||
int mongo_socket_connect( mongo *conn, const char *host, int port ) {
|
||||
struct sockaddr_in sa;
|
||||
socklen_t addressSize;
|
||||
int flag = 1;
|
||||
|
||||
if( mongo_create_socket( conn ) != MONGO_OK )
|
||||
return MONGO_ERROR;
|
||||
|
||||
memset( sa.sin_zero , 0 , sizeof( sa.sin_zero ) );
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons( port );
|
||||
sa.sin_addr.s_addr = inet_addr( host );
|
||||
addressSize = sizeof( sa );
|
||||
|
||||
if ( connect( conn->sock, ( struct sockaddr * )&sa, addressSize ) == -1 ) {
|
||||
mongo_close_socket( conn->sock );
|
||||
conn->connected = 0;
|
||||
conn->sock = 0;
|
||||
conn->err = MONGO_CONN_FAIL;
|
||||
return MONGO_ERROR;
|
||||
}
|
||||
|
||||
setsockopt( conn->sock, IPPROTO_TCP, TCP_NODELAY, ( char * ) &flag, sizeof( flag ) );
|
||||
|
||||
if( conn->op_timeout_ms > 0 )
|
||||
mongo_set_socket_op_timeout( conn, conn->op_timeout_ms );
|
||||
|
||||
conn->connected = 1;
|
||||
|
||||
return MONGO_OK;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @file net.h
|
||||
* @brief Networking.
|
||||
*/
|
||||
|
||||
/* Copyright 2009-2011 10gen Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* Header for Linux net.h */
|
||||
#ifndef _MONGO_NET_H_
|
||||
#define _MONGO_NET_H_
|
||||
|
||||
#include "mongo.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#define mongo_close_socket(sock) ( close(sock) )
|
||||
|
||||
#if defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE) || _POSIX_C_SOURCE >= 1
|
||||
#define _MONGO_USE_GETADDRINFO
|
||||
#endif
|
||||
|
||||
MONGO_EXTERN_C_START
|
||||
|
||||
int mongo_set_socket_op_timeout( mongo *conn, int millis );
|
||||
int mongo_read_socket( mongo *conn, void *buf, int len );
|
||||
int mongo_write_socket( mongo *conn, const void *buf, int len );
|
||||
int mongo_socket_connect( mongo *conn, const char *host, int port );
|
||||
|
||||
MONGO_EXTERN_C_END
|
||||
#endif
|
||||
@@ -0,0 +1,413 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Daniel Swarbrick <daniel.swarbrick@seventhsignal.de>
|
||||
*
|
||||
* mod_cdr_mongodb.c -- MongoDB CDR Module
|
||||
*
|
||||
* Derived from:
|
||||
* mod_xml_cdr.c -- XML CDR Module to files or curl
|
||||
*
|
||||
*/
|
||||
#include <switch.h>
|
||||
#include <mongo.h>
|
||||
|
||||
static struct {
|
||||
switch_memory_pool_t *pool;
|
||||
int shutdown;
|
||||
char *mongo_host;
|
||||
uint32_t mongo_port;
|
||||
char *mongo_namespace;
|
||||
mongo mongo_conn[1];
|
||||
switch_mutex_t *mongo_mutex;
|
||||
switch_bool_t log_b;
|
||||
} globals;
|
||||
|
||||
static switch_xml_config_item_t config_settings[] = {
|
||||
/* key, flags, ptr, default_value, syntax, helptext */
|
||||
SWITCH_CONFIG_ITEM_STRING_STRDUP("host", CONFIG_REQUIRED, &globals.mongo_host, "127.0.0.1", NULL, "MongoDB server host address"),
|
||||
SWITCH_CONFIG_ITEM_STRING_STRDUP("namespace", CONFIG_REQUIRED, &globals.mongo_namespace, NULL, "database.collection", "MongoDB namespace"),
|
||||
|
||||
/* key, type, flags, ptr, default_value, data, syntax, helptext */
|
||||
SWITCH_CONFIG_ITEM("port", SWITCH_CONFIG_INT, CONFIG_REQUIRED, &globals.mongo_port, 27017, NULL, NULL, "MongoDB server TCP port"),
|
||||
SWITCH_CONFIG_ITEM("log-b-leg", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.log_b, SWITCH_TRUE, NULL, NULL, "Log B-leg in addition to A-leg"),
|
||||
|
||||
SWITCH_CONFIG_ITEM_END()
|
||||
};
|
||||
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_mongodb_load);
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_mongodb_shutdown);
|
||||
SWITCH_MODULE_DEFINITION(mod_cdr_mongodb, mod_cdr_mongodb_load, mod_cdr_mongodb_shutdown, NULL);
|
||||
|
||||
static void set_bson_profile_data(bson *b, switch_caller_profile_t *caller_profile)
|
||||
{
|
||||
bson_append_string(b, "username", caller_profile->username);
|
||||
bson_append_string(b, "dialplan", caller_profile->dialplan);
|
||||
bson_append_string(b, "caller_id_name", caller_profile->caller_id_name);
|
||||
bson_append_string(b, "ani", caller_profile->ani);
|
||||
bson_append_string(b, "aniii", caller_profile->aniii);
|
||||
bson_append_string(b, "caller_id_number", caller_profile->caller_id_number);
|
||||
bson_append_string(b, "network_addr", caller_profile->network_addr);
|
||||
bson_append_string(b, "rdnis", caller_profile->rdnis);
|
||||
bson_append_string(b, "destination_number", caller_profile->destination_number);
|
||||
bson_append_string(b, "uuid", caller_profile->uuid);
|
||||
bson_append_string(b, "source", caller_profile->source);
|
||||
bson_append_string(b, "context", caller_profile->context);
|
||||
bson_append_string(b, "chan_name", caller_profile->chan_name);
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t my_on_reporting(switch_core_session_t *session)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_event_header_t *hi;
|
||||
switch_caller_profile_t *caller_profile;
|
||||
switch_app_log_t *app_log;
|
||||
bson cdr;
|
||||
int is_b;
|
||||
char *tmp;
|
||||
|
||||
if (globals.shutdown) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
is_b = channel && switch_channel_get_originator_caller_profile(channel);
|
||||
if (!globals.log_b && is_b) {
|
||||
const char *force_cdr = switch_channel_get_variable(channel, SWITCH_FORCE_PROCESS_CDR_VARIABLE);
|
||||
if (!switch_true(force_cdr)) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
bson_init(&cdr);
|
||||
|
||||
/* Channel data */
|
||||
bson_append_start_object(&cdr, "channel_data");
|
||||
bson_append_string(&cdr, "state", switch_channel_state_name(switch_channel_get_state(channel)));
|
||||
bson_append_string(&cdr, "direction", switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound");
|
||||
bson_append_int(&cdr, "state_number", switch_channel_get_state(channel));
|
||||
|
||||
if ((tmp = switch_channel_get_flag_string(channel))) {
|
||||
bson_append_string(&cdr, "flags", tmp);
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
if ((tmp = switch_channel_get_cap_string(channel))) {
|
||||
bson_append_string(&cdr, "caps", tmp);
|
||||
free(tmp);
|
||||
}
|
||||
bson_append_finish_object(&cdr); /* channel_data */
|
||||
|
||||
|
||||
/* Channel variables */
|
||||
bson_append_start_object(&cdr, "variables");
|
||||
for (hi = switch_channel_variable_first(channel); hi; hi = hi->next) {
|
||||
if (!zstr(hi->name) && !zstr(hi->value)) {
|
||||
bson_append_string(&cdr, hi->name, hi->value);
|
||||
}
|
||||
}
|
||||
bson_append_finish_object(&cdr); /* variables */
|
||||
|
||||
|
||||
/* App log */
|
||||
if ((app_log = switch_core_session_get_app_log(session))) {
|
||||
switch_app_log_t *ap;
|
||||
|
||||
bson_append_start_object(&cdr, "app_log");
|
||||
for (ap = app_log; ap; ap = ap->next) {
|
||||
bson_append_start_object(&cdr, "application");
|
||||
bson_append_string(&cdr, "app_name", ap->app);
|
||||
bson_append_string(&cdr, "app_data", ap->arg);
|
||||
bson_append_long(&cdr, "app_stamp", ap->stamp);
|
||||
bson_append_finish_object(&cdr); /* application */
|
||||
}
|
||||
|
||||
bson_append_finish_object(&cdr); /* app_log */
|
||||
}
|
||||
|
||||
|
||||
/* Callflow */
|
||||
caller_profile = switch_channel_get_caller_profile(channel);
|
||||
|
||||
while (caller_profile) {
|
||||
bson_append_start_object(&cdr, "callflow");
|
||||
|
||||
if (!zstr(caller_profile->dialplan)) {
|
||||
bson_append_string(&cdr, "dialplan", caller_profile->dialplan);
|
||||
}
|
||||
|
||||
if (!zstr(caller_profile->profile_index)) {
|
||||
bson_append_string(&cdr, "profile_index", caller_profile->profile_index);
|
||||
}
|
||||
|
||||
if (caller_profile->caller_extension) {
|
||||
switch_caller_application_t *ap;
|
||||
|
||||
bson_append_start_object(&cdr, "extension");
|
||||
|
||||
bson_append_string(&cdr, "name", caller_profile->caller_extension->extension_name);
|
||||
bson_append_string(&cdr, "number", caller_profile->caller_extension->extension_number);
|
||||
|
||||
if (caller_profile->caller_extension->current_application) {
|
||||
bson_append_string(&cdr, "current_app", caller_profile->caller_extension->current_application->application_name);
|
||||
}
|
||||
|
||||
for (ap = caller_profile->caller_extension->applications; ap; ap = ap->next) {
|
||||
bson_append_start_object(&cdr, "application");
|
||||
if (ap == caller_profile->caller_extension->current_application) {
|
||||
bson_append_bool(&cdr, "last_executed", 1);
|
||||
}
|
||||
bson_append_string(&cdr, "app_name", ap->application_name);
|
||||
bson_append_string(&cdr, "app_data", ap->application_data);
|
||||
bson_append_finish_object(&cdr);
|
||||
}
|
||||
|
||||
if (caller_profile->caller_extension->children) {
|
||||
switch_caller_profile_t *cp = NULL;
|
||||
|
||||
for (cp = caller_profile->caller_extension->children; cp; cp = cp->next) {
|
||||
|
||||
if (!cp->caller_extension) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bson_append_start_object(&cdr, "sub_extensions");
|
||||
bson_append_start_object(&cdr, "extension");
|
||||
|
||||
bson_append_string(&cdr, "name", cp->caller_extension->extension_name);
|
||||
bson_append_string(&cdr, "number", cp->caller_extension->extension_number);
|
||||
bson_append_string(&cdr, "dialplan", cp->dialplan);
|
||||
if (cp->caller_extension->current_application) {
|
||||
bson_append_string(&cdr, "current_app", cp->caller_extension->current_application->application_name);
|
||||
}
|
||||
|
||||
for (ap = cp->caller_extension->applications; ap; ap = ap->next) {
|
||||
bson_append_start_object(&cdr, "application");
|
||||
if (ap == cp->caller_extension->current_application) {
|
||||
bson_append_bool(&cdr, "last_executed", 1);
|
||||
}
|
||||
bson_append_string(&cdr, "app_name", ap->application_name);
|
||||
bson_append_string(&cdr, "app_data", ap->application_data);
|
||||
bson_append_finish_object(&cdr);
|
||||
}
|
||||
|
||||
bson_append_finish_object(&cdr); /* extension */
|
||||
bson_append_finish_object(&cdr); /* sub_extensions */
|
||||
}
|
||||
}
|
||||
|
||||
bson_append_finish_object(&cdr); /* extension */
|
||||
}
|
||||
|
||||
bson_append_start_object(&cdr, "caller_profile");
|
||||
set_bson_profile_data(&cdr, caller_profile);
|
||||
|
||||
if (caller_profile->origination_caller_profile) {
|
||||
switch_caller_profile_t *cp = NULL;
|
||||
|
||||
bson_append_start_object(&cdr, "origination");
|
||||
for (cp = caller_profile->origination_caller_profile; cp; cp = cp->next) {
|
||||
bson_append_start_object(&cdr, "origination_caller_profile");
|
||||
set_bson_profile_data(&cdr, cp);
|
||||
bson_append_finish_object(&cdr);
|
||||
}
|
||||
bson_append_finish_object(&cdr); /* origination */
|
||||
}
|
||||
|
||||
if (caller_profile->originator_caller_profile) {
|
||||
switch_caller_profile_t *cp = NULL;
|
||||
|
||||
bson_append_start_object(&cdr, "originator");
|
||||
for (cp = caller_profile->originator_caller_profile; cp; cp = cp->next) {
|
||||
bson_append_start_object(&cdr, "originator_caller_profile");
|
||||
set_bson_profile_data(&cdr, cp);
|
||||
bson_append_finish_object(&cdr);
|
||||
}
|
||||
bson_append_finish_object(&cdr); /* originator */
|
||||
}
|
||||
|
||||
if (caller_profile->originatee_caller_profile) {
|
||||
switch_caller_profile_t *cp = NULL;
|
||||
|
||||
bson_append_start_object(&cdr, "originatee");
|
||||
for (cp = caller_profile->originatee_caller_profile; cp; cp = cp->next) {
|
||||
bson_append_start_object(&cdr, "originatee_caller_profile");
|
||||
set_bson_profile_data(&cdr, cp);
|
||||
bson_append_finish_object(&cdr);
|
||||
}
|
||||
bson_append_finish_object(&cdr); /* originatee */
|
||||
}
|
||||
|
||||
bson_append_finish_object(&cdr); /* caller_profile */
|
||||
|
||||
/* Timestamps */
|
||||
if (caller_profile->times) {
|
||||
bson_append_start_object(&cdr, "times");
|
||||
|
||||
/* Insert timestamps as long ints (microseconds) to preserve accuracy */
|
||||
bson_append_long(&cdr, "created_time", caller_profile->times->created);
|
||||
bson_append_long(&cdr, "profile_created_time", caller_profile->times->profile_created);
|
||||
bson_append_long(&cdr, "progress_time", caller_profile->times->progress);
|
||||
bson_append_long(&cdr, "progress_media_time", caller_profile->times->progress_media);
|
||||
bson_append_long(&cdr, "answered_time", caller_profile->times->answered);
|
||||
bson_append_long(&cdr, "bridged_time", caller_profile->times->bridged);
|
||||
bson_append_long(&cdr, "last_hold_time", caller_profile->times->last_hold);
|
||||
bson_append_long(&cdr, "hold_accum_time", caller_profile->times->hold_accum);
|
||||
bson_append_long(&cdr, "hangup_time", caller_profile->times->hungup);
|
||||
bson_append_long(&cdr, "resurrect_time", caller_profile->times->resurrected);
|
||||
bson_append_long(&cdr, "transfer_time", caller_profile->times->transferred);
|
||||
bson_append_finish_object(&cdr); /* times */
|
||||
}
|
||||
|
||||
bson_append_finish_object(&cdr); /* callflow */
|
||||
caller_profile = caller_profile->next;
|
||||
}
|
||||
|
||||
bson_finish(&cdr);
|
||||
|
||||
switch_mutex_lock(globals.mongo_mutex);
|
||||
|
||||
if (mongo_insert(globals.mongo_conn, globals.mongo_namespace, &cdr) != MONGO_OK) {
|
||||
if (globals.mongo_conn->err == MONGO_IO_ERROR) {
|
||||
mongo_error_t db_status;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "MongoDB connection failed; attempting reconnect...\n");
|
||||
db_status = mongo_reconnect(globals.mongo_conn);
|
||||
|
||||
if (db_status != MONGO_OK) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MongoDB reconnect failed with error code %d\n", db_status);
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "MongoDB connection re-established.\n");
|
||||
if (mongo_insert(globals.mongo_conn, globals.mongo_namespace, &cdr) != MONGO_OK) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mongo_insert: error code %d\n", globals.mongo_conn->err);
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mongo_insert: error code %d\n", globals.mongo_conn->err);
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
switch_mutex_unlock(globals.mongo_mutex);
|
||||
bson_destroy(&cdr);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static switch_state_handler_table_t state_handlers = {
|
||||
/*.on_init */ NULL,
|
||||
/*.on_routing */ NULL,
|
||||
/*.on_execute */ NULL,
|
||||
/*.on_hangup */ NULL,
|
||||
/*.on_exchange_media */ NULL,
|
||||
/*.on_soft_execute */ NULL,
|
||||
/*.on_consume_media */ NULL,
|
||||
/*.on_hibernate */ NULL,
|
||||
/*.on_reset */ NULL,
|
||||
/*.on_park */ NULL,
|
||||
/*.on_reporting */ my_on_reporting
|
||||
};
|
||||
|
||||
|
||||
static switch_status_t load_config(switch_memory_pool_t *pool)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
if (switch_xml_config_parse_module_settings("cdr_mongodb.conf", SWITCH_FALSE, config_settings) != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_mongodb_load)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
mongo_error_t db_status;
|
||||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
globals.pool = pool;
|
||||
if (load_config(pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Unable to load or parse config!\n");
|
||||
}
|
||||
|
||||
db_status = mongo_connect(globals.mongo_conn, globals.mongo_host, globals.mongo_port);
|
||||
|
||||
if (db_status != MONGO_OK) {
|
||||
switch (globals.mongo_conn->err) {
|
||||
case MONGO_CONN_NO_SOCKET:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mongo_connect: no socket\n");
|
||||
break;
|
||||
case MONGO_CONN_FAIL:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mongo_connect: connection failed\n");
|
||||
break;
|
||||
case MONGO_CONN_NOT_MASTER:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mongo_connect: not master\n");
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mongo_connect: unknown error %d\n", db_status);
|
||||
}
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected to MongoDB server %s:%d\n", globals.mongo_host, globals.mongo_port);
|
||||
}
|
||||
|
||||
switch_mutex_init(&globals.mongo_mutex, SWITCH_MUTEX_NESTED, pool);
|
||||
|
||||
switch_core_add_state_handler(&state_handlers);
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_mongodb_shutdown)
|
||||
{
|
||||
globals.shutdown = 1;
|
||||
switch_core_remove_state_handler(&state_handlers);
|
||||
switch_mutex_destroy(globals.mongo_mutex);
|
||||
|
||||
mongo_destroy(globals.mongo_conn);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:t
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
||||
*/
|
||||
@@ -184,7 +184,7 @@ static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_l
|
||||
} else {
|
||||
switch_log_node_free(&dnode);
|
||||
if (++l->lost_logs > MAX_MISSED) {
|
||||
kill_listener(l, "Disconnected due to log queue failure.\n");
|
||||
kill_listener(l, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,7 +384,7 @@ static void event_handler(switch_event_t *event)
|
||||
}
|
||||
} else {
|
||||
if (++l->lost_events > MAX_MISSED) {
|
||||
kill_listener(l, "Disconnected due to event queue failure.\n");
|
||||
kill_listener(l, NULL);
|
||||
}
|
||||
switch_event_destroy(&clone);
|
||||
}
|
||||
@@ -1180,7 +1180,6 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
|
||||
}
|
||||
}
|
||||
if (var && val) {
|
||||
switch_event_del_header(*event, var);
|
||||
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, var, val);
|
||||
if (!strcasecmp(var, "content-length")) {
|
||||
clen = atoi(val);
|
||||
@@ -1884,11 +1883,30 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||
char *uuid;
|
||||
|
||||
if ((uuid = cmd + 9)) {
|
||||
char *fmt;
|
||||
strip_cr(uuid);
|
||||
|
||||
|
||||
if ((fmt = strchr(uuid, ' '))) {
|
||||
*fmt++ = '\0';
|
||||
}
|
||||
|
||||
if (!(listener->session = switch_core_session_locate(uuid))) {
|
||||
switch_snprintf(reply, reply_len, "-ERR invalid uuid");
|
||||
goto done;
|
||||
if (fmt) {
|
||||
switch_snprintf(reply, reply_len, "-ERR invalid uuid");
|
||||
goto done;
|
||||
} else {
|
||||
fmt = uuid;
|
||||
}
|
||||
}
|
||||
|
||||
if ((fmt = strchr(uuid, ' '))) {
|
||||
if (!strcasecmp(fmt, "xml")) {
|
||||
listener->format = EVENT_FORMAT_XML;
|
||||
} else if (!strcasecmp(fmt, "plain")) {
|
||||
listener->format = EVENT_FORMAT_PLAIN;
|
||||
} else if (!strcasecmp(fmt, "json")) {
|
||||
listener->format = EVENT_FORMAT_JSON;
|
||||
}
|
||||
}
|
||||
|
||||
switch_set_flag_locked(listener, LFLAG_SESSION);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
BASE=../../../..
|
||||
|
||||
ZMQ=zeromq-2.1.7
|
||||
ZMQ=zeromq-2.1.9
|
||||
|
||||
ZMQ_BASEURL=http://download.zeromq.org
|
||||
ZMQ_BASEURL_ALT=http://download.zeromq.org/historic
|
||||
|
||||
@@ -66,6 +66,14 @@ public class Event {
|
||||
this(freeswitchJNI.new_Event__SWIG_1(SWIGTYPE_p_switch_event_t.getCPtr(wrap_me), free_me), true);
|
||||
}
|
||||
|
||||
public int chat_execute(String app, String data) {
|
||||
return freeswitchJNI.Event_chat_execute(swigCPtr, this, app, data);
|
||||
}
|
||||
|
||||
public int chat_send(String dest_proto) {
|
||||
return freeswitchJNI.Event_chat_send(swigCPtr, this, dest_proto);
|
||||
}
|
||||
|
||||
public String serialize(String format) {
|
||||
return freeswitchJNI.Event_serialize(swigCPtr, this, format);
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ class freeswitchJNI {
|
||||
public final static native long new_Event__SWIG_0(String jarg1, String jarg2);
|
||||
public final static native long new_Event__SWIG_1(long jarg1, int jarg2);
|
||||
public final static native void delete_Event(long jarg1);
|
||||
public final static native int Event_chat_execute(long jarg1, Event jarg1_, String jarg2, String jarg3);
|
||||
public final static native int Event_chat_send(long jarg1, Event jarg1_, String jarg2);
|
||||
public final static native String Event_serialize(long jarg1, Event jarg1_, String jarg2);
|
||||
public final static native boolean Event_setPriority(long jarg1, Event jarg1_, long jarg2);
|
||||
public final static native String Event_getHeader(long jarg1, Event jarg1_, String jarg2);
|
||||
|
||||
@@ -1054,6 +1054,57 @@ SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_delete_1Event(JNI
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1chat_1execute(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3) {
|
||||
jint jresult = 0 ;
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) NULL ;
|
||||
int result;
|
||||
|
||||
(void)jenv;
|
||||
(void)jcls;
|
||||
(void)jarg1_;
|
||||
arg1 = *(Event **)&jarg1;
|
||||
arg2 = 0;
|
||||
if (jarg2) {
|
||||
arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
|
||||
if (!arg2) return 0;
|
||||
}
|
||||
arg3 = 0;
|
||||
if (jarg3) {
|
||||
arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0);
|
||||
if (!arg3) return 0;
|
||||
}
|
||||
result = (int)(arg1)->chat_execute((char const *)arg2,(char const *)arg3);
|
||||
jresult = (jint)result;
|
||||
if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
|
||||
if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3);
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1chat_1send(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
|
||||
jint jresult = 0 ;
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
char *arg2 = (char *) NULL ;
|
||||
int result;
|
||||
|
||||
(void)jenv;
|
||||
(void)jcls;
|
||||
(void)jarg1_;
|
||||
arg1 = *(Event **)&jarg1;
|
||||
arg2 = 0;
|
||||
if (jarg2) {
|
||||
arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
|
||||
if (!arg2) return 0;
|
||||
}
|
||||
result = (int)(arg1)->chat_send((char const *)arg2);
|
||||
jresult = (jint)result;
|
||||
if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1serialize(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
|
||||
jstring jresult = 0 ;
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
|
||||
@@ -430,6 +430,24 @@ SWITCH_STANDARD_API(luarun_api_function)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_CHAT_APP(lua_chat_function)
|
||||
{
|
||||
lua_State *L = lua_init();
|
||||
char *dup = NULL;
|
||||
|
||||
if (data) {
|
||||
dup = strdup(data);
|
||||
}
|
||||
|
||||
mod_lua_conjure_event(L, message, "message", 1);
|
||||
lua_parse_and_execute(L, (char *)dup);
|
||||
lua_uninit(L);
|
||||
|
||||
switch_safe_free(dup);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(lua_api_function)
|
||||
{
|
||||
@@ -591,6 +609,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load)
|
||||
switch_api_interface_t *api_interface;
|
||||
switch_application_interface_t *app_interface;
|
||||
switch_dialplan_interface_t *dp_interface;
|
||||
switch_chat_application_interface_t *chat_app_interface;
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
@@ -600,6 +619,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load)
|
||||
SWITCH_ADD_APP(app_interface, "lua", "Launch LUA ivr", "Run a lua ivr on a channel", lua_function, "<script>", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SWITCH_ADD_DIALPLAN(dp_interface, "LUA", lua_dialplan_hunt);
|
||||
|
||||
SWITCH_ADD_CHAT_APP(chat_app_interface, "lua", "execute a lua script", "execute a lua script", lua_chat_function, "<script>", SCAF_NONE);
|
||||
|
||||
|
||||
globals.pool = pool;
|
||||
|
||||
@@ -2890,6 +2890,69 @@ fail:
|
||||
}
|
||||
|
||||
|
||||
static int _wrap_Event_chat_execute(lua_State* L) {
|
||||
int SWIG_arg = -1;
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) NULL ;
|
||||
int result;
|
||||
|
||||
SWIG_check_num_args("chat_execute",2,3)
|
||||
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("chat_execute",1,"Event *");
|
||||
if(!lua_isstring(L,2)) SWIG_fail_arg("chat_execute",2,"char const *");
|
||||
if(lua_gettop(L)>=3 && !lua_isstring(L,3)) SWIG_fail_arg("chat_execute",3,"char const *");
|
||||
|
||||
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
|
||||
SWIG_fail_ptr("Event_chat_execute",1,SWIGTYPE_p_Event);
|
||||
}
|
||||
|
||||
arg2 = (char *)lua_tostring(L, 2);
|
||||
if(lua_gettop(L)>=3){
|
||||
arg3 = (char *)lua_tostring(L, 3);
|
||||
}
|
||||
result = (int)(arg1)->chat_execute((char const *)arg2,(char const *)arg3);
|
||||
SWIG_arg=0;
|
||||
lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
|
||||
return SWIG_arg;
|
||||
|
||||
if(0) SWIG_fail;
|
||||
|
||||
fail:
|
||||
lua_error(L);
|
||||
return SWIG_arg;
|
||||
}
|
||||
|
||||
|
||||
static int _wrap_Event_chat_send(lua_State* L) {
|
||||
int SWIG_arg = -1;
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
char *arg2 = (char *) NULL ;
|
||||
int result;
|
||||
|
||||
SWIG_check_num_args("chat_send",1,2)
|
||||
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("chat_send",1,"Event *");
|
||||
if(lua_gettop(L)>=2 && !lua_isstring(L,2)) SWIG_fail_arg("chat_send",2,"char const *");
|
||||
|
||||
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
|
||||
SWIG_fail_ptr("Event_chat_send",1,SWIGTYPE_p_Event);
|
||||
}
|
||||
|
||||
if(lua_gettop(L)>=2){
|
||||
arg2 = (char *)lua_tostring(L, 2);
|
||||
}
|
||||
result = (int)(arg1)->chat_send((char const *)arg2);
|
||||
SWIG_arg=0;
|
||||
lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
|
||||
return SWIG_arg;
|
||||
|
||||
if(0) SWIG_fail;
|
||||
|
||||
fail:
|
||||
lua_error(L);
|
||||
return SWIG_arg;
|
||||
}
|
||||
|
||||
|
||||
static int _wrap_Event_serialize(lua_State* L) {
|
||||
int SWIG_arg = -1;
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
@@ -3149,6 +3212,8 @@ Event *arg1 = (Event *) obj;
|
||||
delete arg1;
|
||||
}
|
||||
static swig_lua_method swig_Event_methods[] = {
|
||||
{"chat_execute", _wrap_Event_chat_execute},
|
||||
{"chat_send", _wrap_Event_chat_send},
|
||||
{"serialize", _wrap_Event_serialize},
|
||||
{"setPriority", _wrap_Event_setPriority},
|
||||
{"getHeader", _wrap_Event_getHeader},
|
||||
|
||||
@@ -1551,6 +1551,16 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_LOCAL_MEDIA_PORT_VARIABLE_get() {
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ADVERTISED_MEDIA_IP_VARIABLE_get() {
|
||||
char * jresult ;
|
||||
char *result = 0 ;
|
||||
|
||||
result = (char *)("advertised_media_ip");
|
||||
jresult = SWIG_csharp_string_callback((const char *)result);
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_REMOTE_MEDIA_IP_VARIABLE_get() {
|
||||
char * jresult ;
|
||||
char *result = 0 ;
|
||||
@@ -1797,6 +1807,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_dtmf_t_flags_get(void * jarg1) {
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_dtmf_t_source_set(void * jarg1, int jarg2) {
|
||||
switch_dtmf_t *arg1 = (switch_dtmf_t *) 0 ;
|
||||
switch_dtmf_source_t arg2 ;
|
||||
|
||||
arg1 = (switch_dtmf_t *)jarg1;
|
||||
arg2 = (switch_dtmf_source_t)jarg2;
|
||||
if (arg1) (arg1)->source = arg2;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_dtmf_t_source_get(void * jarg1) {
|
||||
int jresult ;
|
||||
switch_dtmf_t *arg1 = (switch_dtmf_t *) 0 ;
|
||||
switch_dtmf_source_t result;
|
||||
|
||||
arg1 = (switch_dtmf_t *)jarg1;
|
||||
result = (switch_dtmf_source_t) ((arg1)->source);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_dtmf_t() {
|
||||
void * jresult ;
|
||||
switch_dtmf_t *result = 0 ;
|
||||
@@ -5120,6 +5152,16 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_DONE_get() {
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_sql_concat() {
|
||||
char * jresult ;
|
||||
char *result = 0 ;
|
||||
|
||||
result = (char *)switch_sql_concat();
|
||||
jresult = SWIG_csharp_string_callback((const char *)result);
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_regex_compile(char * jarg1, int jarg2, void * jarg3, void * jarg4, void * jarg5) {
|
||||
void * jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
@@ -7253,11 +7295,15 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_channel(void * jarg
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_wake_session_thread(void * jarg1) {
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_wake_session_thread(void * jarg1) {
|
||||
int jresult ;
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (switch_core_session_t *)jarg1;
|
||||
switch_core_session_wake_session_thread(arg1);
|
||||
result = (switch_status_t)switch_core_session_wake_session_thread(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
@@ -7325,28 +7371,54 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_soft_unlock(void * jarg1)
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_set_dmachine(void * jarg1, void * jarg2) {
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_set_dmachine(void * jarg1, void * jarg2, int jarg3) {
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
switch_ivr_dmachine_t *arg2 = (switch_ivr_dmachine_t *) 0 ;
|
||||
switch_digit_action_target_t arg3 ;
|
||||
|
||||
arg1 = (switch_core_session_t *)jarg1;
|
||||
arg2 = (switch_ivr_dmachine_t *)jarg2;
|
||||
switch_core_session_set_dmachine(arg1,arg2);
|
||||
arg3 = (switch_digit_action_target_t)jarg3;
|
||||
switch_core_session_set_dmachine(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_dmachine(void * jarg1) {
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_dmachine(void * jarg1, int jarg2) {
|
||||
void * jresult ;
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
switch_digit_action_target_t arg2 ;
|
||||
switch_ivr_dmachine_t *result = 0 ;
|
||||
|
||||
arg1 = (switch_core_session_t *)jarg1;
|
||||
result = (switch_ivr_dmachine_t *)switch_core_session_get_dmachine(arg1);
|
||||
arg2 = (switch_digit_action_target_t)jarg2;
|
||||
result = (switch_ivr_dmachine_t *)switch_core_session_get_dmachine(arg1,arg2);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_dmachine_get_target(void * jarg1) {
|
||||
int jresult ;
|
||||
switch_ivr_dmachine_t *arg1 = (switch_ivr_dmachine_t *) 0 ;
|
||||
switch_digit_action_target_t result;
|
||||
|
||||
arg1 = (switch_ivr_dmachine_t *)jarg1;
|
||||
result = (switch_digit_action_target_t)switch_ivr_dmachine_get_target(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_ivr_dmachine_set_target(void * jarg1, int jarg2) {
|
||||
switch_ivr_dmachine_t *arg1 = (switch_ivr_dmachine_t *) 0 ;
|
||||
switch_digit_action_target_t arg2 ;
|
||||
|
||||
arg1 = (switch_ivr_dmachine_t *)jarg1;
|
||||
arg2 = (switch_digit_action_target_t)jarg2;
|
||||
switch_ivr_dmachine_set_target(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_set_codec_slin(void * jarg1, void * jarg2) {
|
||||
int jresult ;
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
@@ -9618,16 +9690,6 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_management_exec(char * jarg1, int
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_set_high_priority() {
|
||||
int jresult ;
|
||||
int32_t result;
|
||||
|
||||
result = (int32_t)set_high_priority();
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_set_normal_priority() {
|
||||
int jresult ;
|
||||
int32_t result;
|
||||
@@ -9638,6 +9700,36 @@ SWIGEXPORT int SWIGSTDCALL CSharp_set_normal_priority() {
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_set_auto_priority() {
|
||||
int jresult ;
|
||||
int32_t result;
|
||||
|
||||
result = (int32_t)set_auto_priority();
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_set_realtime_priority() {
|
||||
int jresult ;
|
||||
int32_t result;
|
||||
|
||||
result = (int32_t)set_realtime_priority();
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_set_low_priority() {
|
||||
int jresult ;
|
||||
int32_t result;
|
||||
|
||||
result = (int32_t)set_low_priority();
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_change_user_group(char * jarg1, char * jarg2) {
|
||||
int jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
@@ -10108,7 +10200,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cond_next() {
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send(char * jarg1, char * jarg2, char * jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7, char * jarg8) {
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send_args(char * jarg1, char * jarg2, char * jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7, char * jarg8) {
|
||||
int jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
@@ -10128,7 +10220,21 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send(char * jarg1, char * jar
|
||||
arg6 = (char *)jarg6;
|
||||
arg7 = (char *)jarg7;
|
||||
arg8 = (char *)jarg8;
|
||||
result = (switch_status_t)switch_core_chat_send((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8);
|
||||
result = (switch_status_t)switch_core_chat_send_args((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send(char * jarg1, void * jarg2) {
|
||||
int jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
switch_event_t *arg2 = (switch_event_t *) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (char *)jarg1;
|
||||
arg2 = (switch_event_t *)jarg2;
|
||||
result = (switch_status_t)switch_core_chat_send((char const *)arg1,arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
@@ -20086,10 +20192,10 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_chat_interface_interface_name_get(vo
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_interface_chat_send_set(void * jarg1, void * jarg2) {
|
||||
switch_chat_interface *arg1 = (switch_chat_interface *) 0 ;
|
||||
switch_status_t (*arg2)(char const *,char const *,char const *,char const *,char const *,char const *,char const *) = (switch_status_t (*)(char const *,char const *,char const *,char const *,char const *,char const *,char const *)) 0 ;
|
||||
switch_status_t (*arg2)(switch_event_t *) = (switch_status_t (*)(switch_event_t *)) 0 ;
|
||||
|
||||
arg1 = (switch_chat_interface *)jarg1;
|
||||
arg2 = (switch_status_t (*)(char const *,char const *,char const *,char const *,char const *,char const *,char const *))jarg2;
|
||||
arg2 = (switch_status_t (*)(switch_event_t *))jarg2;
|
||||
if (arg1) (arg1)->chat_send = arg2;
|
||||
}
|
||||
|
||||
@@ -20097,10 +20203,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_interface_chat_send_set(void * ja
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_chat_interface_chat_send_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_chat_interface *arg1 = (switch_chat_interface *) 0 ;
|
||||
switch_status_t (*result)(char const *,char const *,char const *,char const *,char const *,char const *,char const *) = 0 ;
|
||||
switch_status_t (*result)(switch_event_t *) = 0 ;
|
||||
|
||||
arg1 = (switch_chat_interface *)jarg1;
|
||||
result = (switch_status_t (*)(char const *,char const *,char const *,char const *,char const *,char const *,char const *)) ((arg1)->chat_send);
|
||||
result = (switch_status_t (*)(switch_event_t *)) ((arg1)->chat_send);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
@@ -24735,6 +24841,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_api_on(void * jarg1, char * jar
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_get_queued_extension(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_channel_t *arg1 = (switch_channel_t *) 0 ;
|
||||
switch_caller_extension_t *result = 0 ;
|
||||
|
||||
arg1 = (switch_channel_t *)jarg1;
|
||||
result = (switch_caller_extension_t *)switch_channel_get_queued_extension(arg1);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_transfer_to_extension(void * jarg1, void * jarg2) {
|
||||
switch_channel_t *arg1 = (switch_channel_t *) 0 ;
|
||||
switch_caller_extension_t *arg2 = (switch_caller_extension_t *) 0 ;
|
||||
|
||||
arg1 = (switch_channel_t *)jarg1;
|
||||
arg2 = (switch_caller_extension_t *)jarg2;
|
||||
switch_channel_transfer_to_extension(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_buffer_create(void * jarg1, void * jarg2, void * jarg3) {
|
||||
int jresult ;
|
||||
switch_memory_pool_t *arg1 = (switch_memory_pool_t *) 0 ;
|
||||
@@ -26993,6 +27121,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_parse_all_signal_data(void * jarg1)
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_process_indications(void * jarg1, void * jarg2) {
|
||||
int jresult ;
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
switch_core_session_message_t *arg2 = (switch_core_session_message_t *) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (switch_core_session_t *)jarg1;
|
||||
arg2 = (switch_core_session_message_t *)jarg2;
|
||||
result = (switch_status_t)switch_ivr_process_indications(arg1,arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_sleep(void * jarg1, unsigned long jarg2, int jarg3, void * jarg4) {
|
||||
int jresult ;
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
@@ -27657,7 +27799,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_originate(void * jarg1, void * jarg
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_enterprise_originate(void * jarg1, void * jarg2, void * jarg3, char * jarg4, unsigned long jarg5, void * jarg6, char * jarg7, char * jarg8, void * jarg9, void * jarg10, unsigned long jarg11) {
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_enterprise_originate(void * jarg1, void * jarg2, void * jarg3, char * jarg4, unsigned long jarg5, void * jarg6, char * jarg7, char * jarg8, void * jarg9, void * jarg10, unsigned long jarg11, void * jarg12) {
|
||||
int jresult ;
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
switch_core_session_t **arg2 = (switch_core_session_t **) 0 ;
|
||||
@@ -27670,6 +27812,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_enterprise_originate(void * jarg1,
|
||||
switch_caller_profile_t *arg9 = (switch_caller_profile_t *) 0 ;
|
||||
switch_event_t *arg10 = (switch_event_t *) 0 ;
|
||||
switch_originate_flag_t arg11 ;
|
||||
switch_call_cause_t *arg12 = (switch_call_cause_t *) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (switch_core_session_t *)jarg1;
|
||||
@@ -27683,7 +27826,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_enterprise_originate(void * jarg1,
|
||||
arg9 = (switch_caller_profile_t *)jarg9;
|
||||
arg10 = (switch_event_t *)jarg10;
|
||||
arg11 = (switch_originate_flag_t)jarg11;
|
||||
result = (switch_status_t)switch_ivr_enterprise_originate(arg1,arg2,arg3,(char const *)arg4,arg5,(switch_state_handler_table const *)arg6,(char const *)arg7,(char const *)arg8,arg9,arg10,arg11);
|
||||
arg12 = (switch_call_cause_t *)jarg12;
|
||||
result = (switch_status_t)switch_ivr_enterprise_originate(arg1,arg2,arg3,(char const *)arg4,arg5,(switch_state_handler_table const *)arg6,(char const *)arg7,(char const *)arg8,arg9,arg10,arg11,arg12);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
@@ -1664,6 +1664,17 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_LOCAL_MEDIA_PORT_VARIABLE_get() {
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_ADVERTISED_MEDIA_IP_VARIABLE_get() {
|
||||
char * jresult ;
|
||||
char *result = 0 ;
|
||||
|
||||
result = (char *) "advertised_media_ip";
|
||||
|
||||
jresult = SWIG_csharp_string_callback((const char *)result);
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_REMOTE_MEDIA_IP_VARIABLE_get() {
|
||||
char * jresult ;
|
||||
char *result = 0 ;
|
||||
@@ -5411,6 +5422,16 @@ SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_CORE_DB_DONE_get() {
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_sql_concat() {
|
||||
char * jresult ;
|
||||
char *result = 0 ;
|
||||
|
||||
result = (char *)switch_sql_concat();
|
||||
jresult = SWIG_csharp_string_callback((const char *)result);
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_regex_compile(char * jarg1, int jarg2, void * jarg3, void * jarg4, void * jarg5) {
|
||||
void * jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
@@ -5569,6 +5590,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_regex_set_var_callback(char * jarg1, c
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_regex_set_event_header_callback(char * jarg1, char * jarg2, void * jarg3) {
|
||||
char *arg1 = (char *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
void *arg3 = (void *) 0 ;
|
||||
|
||||
arg1 = (char *)jarg1;
|
||||
arg2 = (char *)jarg2;
|
||||
arg3 = (void *)jarg3;
|
||||
switch_regex_set_event_header_callback((char const *)arg1,(char const *)arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_CORE_THREAD_SESSION_OBJS_get() {
|
||||
int jresult ;
|
||||
int result;
|
||||
@@ -7652,28 +7685,54 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_soft_unlock(void * jarg1)
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_set_dmachine(void * jarg1, void * jarg2) {
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_set_dmachine(void * jarg1, void * jarg2, int jarg3) {
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
switch_ivr_dmachine_t *arg2 = (switch_ivr_dmachine_t *) 0 ;
|
||||
switch_digit_action_target_t arg3 ;
|
||||
|
||||
arg1 = (switch_core_session_t *)jarg1;
|
||||
arg2 = (switch_ivr_dmachine_t *)jarg2;
|
||||
switch_core_session_set_dmachine(arg1,arg2);
|
||||
arg3 = (switch_digit_action_target_t)jarg3;
|
||||
switch_core_session_set_dmachine(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_dmachine(void * jarg1) {
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_session_get_dmachine(void * jarg1, int jarg2) {
|
||||
void * jresult ;
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
switch_digit_action_target_t arg2 ;
|
||||
switch_ivr_dmachine_t *result = 0 ;
|
||||
|
||||
arg1 = (switch_core_session_t *)jarg1;
|
||||
result = (switch_ivr_dmachine_t *)switch_core_session_get_dmachine(arg1);
|
||||
arg2 = (switch_digit_action_target_t)jarg2;
|
||||
result = (switch_ivr_dmachine_t *)switch_core_session_get_dmachine(arg1,arg2);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_dmachine_get_target(void * jarg1) {
|
||||
int jresult ;
|
||||
switch_ivr_dmachine_t *arg1 = (switch_ivr_dmachine_t *) 0 ;
|
||||
switch_digit_action_target_t result;
|
||||
|
||||
arg1 = (switch_ivr_dmachine_t *)jarg1;
|
||||
result = (switch_digit_action_target_t)switch_ivr_dmachine_get_target(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_ivr_dmachine_set_target(void * jarg1, int jarg2) {
|
||||
switch_ivr_dmachine_t *arg1 = (switch_ivr_dmachine_t *) 0 ;
|
||||
switch_digit_action_target_t arg2 ;
|
||||
|
||||
arg1 = (switch_ivr_dmachine_t *)jarg1;
|
||||
arg2 = (switch_digit_action_target_t)jarg2;
|
||||
switch_ivr_dmachine_set_target(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_set_codec_slin(void * jarg1, void * jarg2) {
|
||||
int jresult ;
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
@@ -9945,16 +10004,6 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_management_exec(char * jarg1, int
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_set_high_priority() {
|
||||
int jresult ;
|
||||
int32_t result;
|
||||
|
||||
result = (int32_t)set_high_priority();
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_set_normal_priority() {
|
||||
int jresult ;
|
||||
int32_t result;
|
||||
@@ -9965,6 +10014,36 @@ SWIGEXPORT int SWIGSTDCALL CSharp_set_normal_priority() {
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_set_auto_priority() {
|
||||
int jresult ;
|
||||
int32_t result;
|
||||
|
||||
result = (int32_t)set_auto_priority();
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_set_realtime_priority() {
|
||||
int jresult ;
|
||||
int32_t result;
|
||||
|
||||
result = (int32_t)set_realtime_priority();
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_set_low_priority() {
|
||||
int jresult ;
|
||||
int32_t result;
|
||||
|
||||
result = (int32_t)set_low_priority();
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_change_user_group(char * jarg1, char * jarg2) {
|
||||
int jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
@@ -10435,7 +10514,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cond_next() {
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send(char * jarg1, char * jarg2, char * jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7, char * jarg8) {
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send_args(char * jarg1, char * jarg2, char * jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7, char * jarg8) {
|
||||
int jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
@@ -10455,7 +10534,35 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send(char * jarg1, char * jar
|
||||
arg6 = (char *)jarg6;
|
||||
arg7 = (char *)jarg7;
|
||||
arg8 = (char *)jarg8;
|
||||
result = (switch_status_t)switch_core_chat_send((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8);
|
||||
result = (switch_status_t)switch_core_chat_send_args((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send(char * jarg1, void * jarg2) {
|
||||
int jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
switch_event_t *arg2 = (switch_event_t *) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (char *)jarg1;
|
||||
arg2 = (switch_event_t *)jarg2;
|
||||
result = (switch_status_t)switch_core_chat_send((char const *)arg1,arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_deliver(char * jarg1, void * jarg2) {
|
||||
int jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
switch_event_t **arg2 = (switch_event_t **) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (char *)jarg1;
|
||||
arg2 = (switch_event_t **)jarg2;
|
||||
result = (switch_status_t)switch_core_chat_deliver((char const *)arg1,arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
@@ -11307,6 +11414,29 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_applicatio
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_chat_application_interface_set(void * jarg1, void * jarg2) {
|
||||
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
|
||||
switch_chat_application_interface_t *arg2 = (switch_chat_application_interface_t *) 0 ;
|
||||
|
||||
arg1 = (switch_loadable_module_interface *)jarg1;
|
||||
arg2 = (switch_chat_application_interface_t *)jarg2;
|
||||
if (arg1) (arg1)->chat_application_interface = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_chat_application_interface_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
|
||||
switch_chat_application_interface_t *result = 0 ;
|
||||
|
||||
arg1 = (switch_loadable_module_interface *)jarg1;
|
||||
result = (switch_chat_application_interface_t *) ((arg1)->chat_application_interface);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_api_interface_set(void * jarg1, void * jarg2) {
|
||||
switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
|
||||
switch_api_interface_t *arg2 = (switch_api_interface_t *) 0 ;
|
||||
@@ -11729,6 +11859,34 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_application_inte
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_chat_application_interface(char * jarg1) {
|
||||
void * jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
switch_chat_application_interface_t *result = 0 ;
|
||||
|
||||
arg1 = (char *)jarg1;
|
||||
result = (switch_chat_application_interface_t *)switch_loadable_module_get_chat_application_interface((char const *)arg1);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_execute_chat_app(void * jarg1, char * jarg2, char * jarg3) {
|
||||
int jresult ;
|
||||
switch_event_t *arg1 = (switch_event_t *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (switch_event_t *)jarg1;
|
||||
arg2 = (char *)jarg2;
|
||||
arg3 = (char *)jarg3;
|
||||
result = (switch_status_t)switch_core_execute_chat_app(arg1,(char const *)arg2,(char const *)arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_api_interface(char * jarg1) {
|
||||
void * jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
@@ -20678,10 +20836,10 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_chat_interface_interface_name_get(vo
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_interface_chat_send_set(void * jarg1, void * jarg2) {
|
||||
switch_chat_interface *arg1 = (switch_chat_interface *) 0 ;
|
||||
switch_status_t (*arg2)(char const *,char const *,char const *,char const *,char const *,char const *,char const *) = (switch_status_t (*)(char const *,char const *,char const *,char const *,char const *,char const *,char const *)) 0 ;
|
||||
switch_status_t (*arg2)(switch_event_t *) = (switch_status_t (*)(switch_event_t *)) 0 ;
|
||||
|
||||
arg1 = (switch_chat_interface *)jarg1;
|
||||
arg2 = (switch_status_t (*)(char const *,char const *,char const *,char const *,char const *,char const *,char const *))jarg2;
|
||||
arg2 = (switch_status_t (*)(switch_event_t *))jarg2;
|
||||
if (arg1) (arg1)->chat_send = arg2;
|
||||
|
||||
}
|
||||
@@ -20690,10 +20848,10 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_interface_chat_send_set(void * ja
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_chat_interface_chat_send_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_chat_interface *arg1 = (switch_chat_interface *) 0 ;
|
||||
switch_status_t (*result)(char const *,char const *,char const *,char const *,char const *,char const *,char const *) = 0 ;
|
||||
switch_status_t (*result)(switch_event_t *) = 0 ;
|
||||
|
||||
arg1 = (switch_chat_interface *)jarg1;
|
||||
result = (switch_status_t (*)(char const *,char const *,char const *,char const *,char const *,char const *,char const *)) ((arg1)->chat_send);
|
||||
result = (switch_status_t (*)(switch_event_t *)) ((arg1)->chat_send);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
@@ -23146,6 +23304,302 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_application_interface(void * ja
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_interface_name_set(void * jarg1, char * jarg2) {
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
arg2 = (char *)jarg2;
|
||||
{
|
||||
if (arg2) {
|
||||
arg1->interface_name = (char const *) (new char[strlen((const char *)arg2)+1]);
|
||||
strcpy((char *)arg1->interface_name, (const char *)arg2);
|
||||
} else {
|
||||
arg1->interface_name = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_chat_application_interface_interface_name_get(void * jarg1) {
|
||||
char * jresult ;
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
char *result = 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
result = (char *) ((arg1)->interface_name);
|
||||
jresult = SWIG_csharp_string_callback((const char *)result);
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_chat_application_function_set(void * jarg1, void * jarg2) {
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
switch_chat_application_function_t arg2 = (switch_chat_application_function_t) 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
arg2 = (switch_chat_application_function_t)jarg2;
|
||||
if (arg1) (arg1)->chat_application_function = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_chat_application_interface_chat_application_function_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
switch_chat_application_function_t result;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
result = (switch_chat_application_function_t) ((arg1)->chat_application_function);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_long_desc_set(void * jarg1, char * jarg2) {
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
arg2 = (char *)jarg2;
|
||||
{
|
||||
if (arg2) {
|
||||
arg1->long_desc = (char const *) (new char[strlen((const char *)arg2)+1]);
|
||||
strcpy((char *)arg1->long_desc, (const char *)arg2);
|
||||
} else {
|
||||
arg1->long_desc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_chat_application_interface_long_desc_get(void * jarg1) {
|
||||
char * jresult ;
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
char *result = 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
result = (char *) ((arg1)->long_desc);
|
||||
jresult = SWIG_csharp_string_callback((const char *)result);
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_short_desc_set(void * jarg1, char * jarg2) {
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
arg2 = (char *)jarg2;
|
||||
{
|
||||
if (arg2) {
|
||||
arg1->short_desc = (char const *) (new char[strlen((const char *)arg2)+1]);
|
||||
strcpy((char *)arg1->short_desc, (const char *)arg2);
|
||||
} else {
|
||||
arg1->short_desc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_chat_application_interface_short_desc_get(void * jarg1) {
|
||||
char * jresult ;
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
char *result = 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
result = (char *) ((arg1)->short_desc);
|
||||
jresult = SWIG_csharp_string_callback((const char *)result);
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_syntax_set(void * jarg1, char * jarg2) {
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
arg2 = (char *)jarg2;
|
||||
{
|
||||
if (arg2) {
|
||||
arg1->syntax = (char const *) (new char[strlen((const char *)arg2)+1]);
|
||||
strcpy((char *)arg1->syntax, (const char *)arg2);
|
||||
} else {
|
||||
arg1->syntax = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_chat_application_interface_syntax_get(void * jarg1) {
|
||||
char * jresult ;
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
char *result = 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
result = (char *) ((arg1)->syntax);
|
||||
jresult = SWIG_csharp_string_callback((const char *)result);
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_flags_set(void * jarg1, unsigned long jarg2) {
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
uint32_t arg2 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
arg2 = (uint32_t)jarg2;
|
||||
if (arg1) (arg1)->flags = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_chat_application_interface_flags_get(void * jarg1) {
|
||||
unsigned long jresult ;
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
uint32_t result;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
result = (uint32_t) ((arg1)->flags);
|
||||
jresult = (unsigned long)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_rwlock_set(void * jarg1, void * jarg2) {
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
switch_thread_rwlock_t *arg2 = (switch_thread_rwlock_t *) 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
arg2 = (switch_thread_rwlock_t *)jarg2;
|
||||
if (arg1) (arg1)->rwlock = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_chat_application_interface_rwlock_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
switch_thread_rwlock_t *result = 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
result = (switch_thread_rwlock_t *) ((arg1)->rwlock);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_refs_set(void * jarg1, int jarg2) {
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
int arg2 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
if (arg1) (arg1)->refs = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_chat_application_interface_refs_get(void * jarg1) {
|
||||
int jresult ;
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
result = (int) ((arg1)->refs);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_reflock_set(void * jarg1, void * jarg2) {
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
switch_mutex_t *arg2 = (switch_mutex_t *) 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
arg2 = (switch_mutex_t *)jarg2;
|
||||
if (arg1) (arg1)->reflock = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_chat_application_interface_reflock_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
switch_mutex_t *result = 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
result = (switch_mutex_t *) ((arg1)->reflock);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_parent_set(void * jarg1, void * jarg2) {
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
switch_loadable_module_interface_t *arg2 = (switch_loadable_module_interface_t *) 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
arg2 = (switch_loadable_module_interface_t *)jarg2;
|
||||
if (arg1) (arg1)->parent = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_chat_application_interface_parent_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
switch_loadable_module_interface_t *result = 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
result = (switch_loadable_module_interface_t *) ((arg1)->parent);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_next_set(void * jarg1, void * jarg2) {
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
switch_chat_application_interface *arg2 = (switch_chat_application_interface *) 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
arg2 = (switch_chat_application_interface *)jarg2;
|
||||
if (arg1) (arg1)->next = arg2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_chat_application_interface_next_get(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
switch_chat_application_interface *result = 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
result = (switch_chat_application_interface *) ((arg1)->next);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_chat_application_interface() {
|
||||
void * jresult ;
|
||||
switch_chat_application_interface *result = 0 ;
|
||||
|
||||
result = (switch_chat_application_interface *)new switch_chat_application_interface();
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_chat_application_interface(void * jarg1) {
|
||||
switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
|
||||
|
||||
arg1 = (switch_chat_application_interface *)jarg1;
|
||||
delete arg1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_api_interface_interface_name_set(void * jarg1, char * jarg2) {
|
||||
switch_api_interface *arg1 = (switch_api_interface *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
@@ -25441,6 +25895,28 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_api_on(void * jarg1, char * jar
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_channel_get_queued_extension(void * jarg1) {
|
||||
void * jresult ;
|
||||
switch_channel_t *arg1 = (switch_channel_t *) 0 ;
|
||||
switch_caller_extension_t *result = 0 ;
|
||||
|
||||
arg1 = (switch_channel_t *)jarg1;
|
||||
result = (switch_caller_extension_t *)switch_channel_get_queued_extension(arg1);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_transfer_to_extension(void * jarg1, void * jarg2) {
|
||||
switch_channel_t *arg1 = (switch_channel_t *) 0 ;
|
||||
switch_caller_extension_t *arg2 = (switch_caller_extension_t *) 0 ;
|
||||
|
||||
arg1 = (switch_channel_t *)jarg1;
|
||||
arg2 = (switch_caller_extension_t *)jarg2;
|
||||
switch_channel_transfer_to_extension(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_buffer_create(void * jarg1, void * jarg2, void * jarg3) {
|
||||
int jresult ;
|
||||
switch_memory_pool_t *arg1 = (switch_memory_pool_t *) 0 ;
|
||||
@@ -26340,6 +26816,22 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_event_get_header_idx(void * jarg1, c
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_rename_header(void * jarg1, char * jarg2, char * jarg3) {
|
||||
int jresult ;
|
||||
switch_event_t *arg1 = (switch_event_t *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (switch_event_t *)jarg1;
|
||||
arg2 = (char *)jarg2;
|
||||
arg3 = (char *)jarg3;
|
||||
result = (switch_status_t)switch_event_rename_header(arg1,(char const *)arg2,(char const *)arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_event_get_body(void * jarg1) {
|
||||
char * jresult ;
|
||||
switch_event_t *arg1 = (switch_event_t *) 0 ;
|
||||
@@ -26448,6 +26940,20 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_merge(void * jarg1, void * jarg2
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_dup_reply(void * jarg1, void * jarg2) {
|
||||
int jresult ;
|
||||
switch_event_t **arg1 = (switch_event_t **) 0 ;
|
||||
switch_event_t *arg2 = (switch_event_t *) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (switch_event_t **)jarg1;
|
||||
arg2 = (switch_event_t *)jarg2;
|
||||
result = (switch_status_t)switch_event_dup_reply(arg1,arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_fire_detailed(char * jarg1, char * jarg2, int jarg3, void * jarg4, void * jarg5) {
|
||||
int jresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
@@ -26680,6 +27186,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_running() {
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_set_body(void * jarg1, char * jarg2) {
|
||||
int jresult ;
|
||||
switch_event_t *arg1 = (switch_event_t *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (switch_event_t *)jarg1;
|
||||
arg2 = (char *)jarg2;
|
||||
result = (switch_status_t)switch_event_set_body(arg1,(char const *)arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_event_expand_headers(void * jarg1, char * jarg2) {
|
||||
char * jresult ;
|
||||
switch_event_t *arg1 = (switch_event_t *) 0 ;
|
||||
@@ -28416,7 +28936,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_originate(void * jarg1, void * jarg
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_enterprise_originate(void * jarg1, void * jarg2, void * jarg3, char * jarg4, unsigned long jarg5, void * jarg6, char * jarg7, char * jarg8, void * jarg9, void * jarg10, unsigned long jarg11) {
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_enterprise_originate(void * jarg1, void * jarg2, void * jarg3, char * jarg4, unsigned long jarg5, void * jarg6, char * jarg7, char * jarg8, void * jarg9, void * jarg10, unsigned long jarg11, void * jarg12) {
|
||||
int jresult ;
|
||||
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
|
||||
switch_core_session_t **arg2 = (switch_core_session_t **) 0 ;
|
||||
@@ -28429,6 +28949,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_enterprise_originate(void * jarg1,
|
||||
switch_caller_profile_t *arg9 = (switch_caller_profile_t *) 0 ;
|
||||
switch_event_t *arg10 = (switch_event_t *) 0 ;
|
||||
switch_originate_flag_t arg11 ;
|
||||
switch_call_cause_t *arg12 = (switch_call_cause_t *) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (switch_core_session_t *)jarg1;
|
||||
@@ -28442,7 +28963,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_enterprise_originate(void * jarg1,
|
||||
arg9 = (switch_caller_profile_t *)jarg9;
|
||||
arg10 = (switch_event_t *)jarg10;
|
||||
arg11 = (switch_originate_flag_t)jarg11;
|
||||
result = (switch_status_t)switch_ivr_enterprise_originate(arg1,arg2,arg3,(char const *)arg4,arg5,(switch_state_handler_table const *)arg6,(char const *)arg7,(char const *)arg8,arg9,arg10,arg11);
|
||||
arg12 = (switch_call_cause_t *)jarg12;
|
||||
result = (switch_status_t)switch_ivr_enterprise_originate(arg1,arg2,arg3,(char const *)arg4,arg5,(switch_state_handler_table const *)arg6,(char const *)arg7,(char const *)arg8,arg9,arg10,arg11,arg12);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
@@ -29658,6 +30180,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_insert_file(void * jarg1, char * ja
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_create_message_reply(void * jarg1, void * jarg2, char * jarg3) {
|
||||
int jresult ;
|
||||
switch_event_t **arg1 = (switch_event_t **) 0 ;
|
||||
switch_event_t *arg2 = (switch_event_t *) 0 ;
|
||||
char *arg3 = (char *) 0 ;
|
||||
switch_status_t result;
|
||||
|
||||
arg1 = (switch_event_t **)jarg1;
|
||||
arg2 = (switch_event_t *)jarg2;
|
||||
arg3 = (char *)jarg3;
|
||||
result = (switch_status_t)switch_ivr_create_message_reply(arg1,arg2,(char const *)arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_MAX_BUF_LEN_get() {
|
||||
int jresult ;
|
||||
int result;
|
||||
@@ -34767,6 +35305,36 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_Event(void * jarg1) {
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_Event_chat_execute(void * jarg1, char * jarg2, char * jarg3) {
|
||||
int jresult ;
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) NULL ;
|
||||
int result;
|
||||
|
||||
arg1 = (Event *)jarg1;
|
||||
arg2 = (char *)jarg2;
|
||||
arg3 = (char *)jarg3;
|
||||
result = (int)(arg1)->chat_execute((char const *)arg2,(char const *)arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_Event_chat_send(void * jarg1, char * jarg2) {
|
||||
int jresult ;
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
char *arg2 = (char *) NULL ;
|
||||
int result;
|
||||
|
||||
arg1 = (Event *)jarg1;
|
||||
arg2 = (char *)jarg2;
|
||||
result = (int)(arg1)->chat_send((char const *)arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_Event_Serialize(void * jarg1, char * jarg2) {
|
||||
char * jresult ;
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
|
||||
@@ -919,6 +919,11 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static string switch_sql_concat() {
|
||||
string ret = freeswitchPINVOKE.switch_sql_concat();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static SWIGTYPE_p_real_pcre switch_regex_compile(string pattern, int options, ref string errorptr, SWIGTYPE_p_int erroroffset, SWIGTYPE_p_unsigned_char tables) {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_regex_compile(pattern, options, ref errorptr, SWIGTYPE_p_int.getCPtr(erroroffset), SWIGTYPE_p_unsigned_char.getCPtr(tables));
|
||||
SWIGTYPE_p_real_pcre ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_real_pcre(cPtr, false);
|
||||
@@ -1349,8 +1354,9 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void switch_core_session_wake_session_thread(SWIGTYPE_p_switch_core_session session) {
|
||||
freeswitchPINVOKE.switch_core_session_wake_session_thread(SWIGTYPE_p_switch_core_session.getCPtr(session));
|
||||
public static switch_status_t switch_core_session_wake_session_thread(SWIGTYPE_p_switch_core_session session) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_wake_session_thread(SWIGTYPE_p_switch_core_session.getCPtr(session));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void switch_core_session_signal_state_change(SWIGTYPE_p_switch_core_session session) {
|
||||
@@ -1380,16 +1386,25 @@ public class freeswitch {
|
||||
freeswitchPINVOKE.switch_core_session_soft_unlock(SWIGTYPE_p_switch_core_session.getCPtr(session));
|
||||
}
|
||||
|
||||
public static void switch_core_session_set_dmachine(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_switch_ivr_dmachine dmachine) {
|
||||
freeswitchPINVOKE.switch_core_session_set_dmachine(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_switch_ivr_dmachine.getCPtr(dmachine));
|
||||
public static void switch_core_session_set_dmachine(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_switch_ivr_dmachine dmachine, switch_digit_action_target_t target) {
|
||||
freeswitchPINVOKE.switch_core_session_set_dmachine(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_switch_ivr_dmachine.getCPtr(dmachine), (int)target);
|
||||
}
|
||||
|
||||
public static SWIGTYPE_p_switch_ivr_dmachine switch_core_session_get_dmachine(SWIGTYPE_p_switch_core_session session) {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_core_session_get_dmachine(SWIGTYPE_p_switch_core_session.getCPtr(session));
|
||||
public static SWIGTYPE_p_switch_ivr_dmachine switch_core_session_get_dmachine(SWIGTYPE_p_switch_core_session session, switch_digit_action_target_t target) {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_core_session_get_dmachine(SWIGTYPE_p_switch_core_session.getCPtr(session), (int)target);
|
||||
SWIGTYPE_p_switch_ivr_dmachine ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_ivr_dmachine(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_digit_action_target_t switch_ivr_dmachine_get_target(SWIGTYPE_p_switch_ivr_dmachine dmachine) {
|
||||
switch_digit_action_target_t ret = (switch_digit_action_target_t)freeswitchPINVOKE.switch_ivr_dmachine_get_target(SWIGTYPE_p_switch_ivr_dmachine.getCPtr(dmachine));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void switch_ivr_dmachine_set_target(SWIGTYPE_p_switch_ivr_dmachine dmachine, switch_digit_action_target_t target) {
|
||||
freeswitchPINVOKE.switch_ivr_dmachine_set_target(SWIGTYPE_p_switch_ivr_dmachine.getCPtr(dmachine), (int)target);
|
||||
}
|
||||
|
||||
public static switch_status_t switch_core_session_set_codec_slin(SWIGTYPE_p_switch_core_session session, switch_slin_data data) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_set_codec_slin(SWIGTYPE_p_switch_core_session.getCPtr(session), switch_slin_data.getCPtr(data));
|
||||
return ret;
|
||||
@@ -2183,13 +2198,23 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int set_high_priority() {
|
||||
int ret = freeswitchPINVOKE.set_high_priority();
|
||||
public static int set_normal_priority() {
|
||||
int ret = freeswitchPINVOKE.set_normal_priority();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int set_normal_priority() {
|
||||
int ret = freeswitchPINVOKE.set_normal_priority();
|
||||
public static int set_auto_priority() {
|
||||
int ret = freeswitchPINVOKE.set_auto_priority();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int set_realtime_priority() {
|
||||
int ret = freeswitchPINVOKE.set_realtime_priority();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int set_low_priority() {
|
||||
int ret = freeswitchPINVOKE.set_low_priority();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2399,8 +2424,13 @@ public class freeswitch {
|
||||
freeswitchPINVOKE.switch_cond_next();
|
||||
}
|
||||
|
||||
public static switch_status_t switch_core_chat_send(string name, string proto, string from, string to, string subject, string body, string type, string hint) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_chat_send(name, proto, from, to, subject, body, type, hint);
|
||||
public static switch_status_t switch_core_chat_send_args(string dest_proto, string proto, string from, string to, string subject, string body, string type, string hint) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_chat_send_args(dest_proto, proto, from, to, subject, body, type, hint);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_core_chat_send(string dest_proto, switch_event message_event) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_chat_send(dest_proto, switch_event.getCPtr(message_event));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -3863,6 +3893,16 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_caller_extension switch_channel_get_queued_extension(SWIGTYPE_p_switch_channel channel) {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_channel_get_queued_extension(SWIGTYPE_p_switch_channel.getCPtr(channel));
|
||||
switch_caller_extension ret = (cPtr == IntPtr.Zero) ? null : new switch_caller_extension(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void switch_channel_transfer_to_extension(SWIGTYPE_p_switch_channel channel, switch_caller_extension caller_extension) {
|
||||
freeswitchPINVOKE.switch_channel_transfer_to_extension(SWIGTYPE_p_switch_channel.getCPtr(channel), switch_caller_extension.getCPtr(caller_extension));
|
||||
}
|
||||
|
||||
public static switch_status_t switch_buffer_create(SWIGTYPE_p_apr_pool_t pool, SWIGTYPE_p_p_switch_buffer buffer, SWIGTYPE_p_switch_size_t max_len) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_buffer_create(SWIGTYPE_p_apr_pool_t.getCPtr(pool), SWIGTYPE_p_p_switch_buffer.getCPtr(buffer), SWIGTYPE_p_switch_size_t.getCPtr(max_len));
|
||||
if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve();
|
||||
@@ -4244,6 +4284,11 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_ivr_process_indications(SWIGTYPE_p_switch_core_session session, switch_core_session_message message) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_process_indications(SWIGTYPE_p_switch_core_session.getCPtr(session), switch_core_session_message.getCPtr(message));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_ivr_sleep(SWIGTYPE_p_switch_core_session session, uint ms, switch_bool_t sync, switch_input_args_t args) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_sleep(SWIGTYPE_p_switch_core_session.getCPtr(session), ms, (int)sync, switch_input_args_t.getCPtr(args));
|
||||
return ret;
|
||||
@@ -4434,8 +4479,8 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_ivr_enterprise_originate(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_core_session bleg, SWIGTYPE_p_switch_call_cause_t cause, string bridgeto, uint timelimit_sec, switch_state_handler_table table, string cid_name_override, string cid_num_override, switch_caller_profile caller_profile_override, switch_event ovars, uint flags) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_enterprise_originate(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_core_session.getCPtr(bleg), SWIGTYPE_p_switch_call_cause_t.getCPtr(cause), bridgeto, timelimit_sec, switch_state_handler_table.getCPtr(table), cid_name_override, cid_num_override, switch_caller_profile.getCPtr(caller_profile_override), switch_event.getCPtr(ovars), flags);
|
||||
public static switch_status_t switch_ivr_enterprise_originate(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_core_session bleg, SWIGTYPE_p_switch_call_cause_t cause, string bridgeto, uint timelimit_sec, switch_state_handler_table table, string cid_name_override, string cid_num_override, switch_caller_profile caller_profile_override, switch_event ovars, uint flags, SWIGTYPE_p_switch_call_cause_t cancel_cause) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_enterprise_originate(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_core_session.getCPtr(bleg), SWIGTYPE_p_switch_call_cause_t.getCPtr(cause), bridgeto, timelimit_sec, switch_state_handler_table.getCPtr(table), cid_name_override, cid_num_override, switch_caller_profile.getCPtr(caller_profile_override), switch_event.getCPtr(ovars), flags, SWIGTYPE_p_switch_call_cause_t.getCPtr(cancel_cause));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -5764,6 +5809,7 @@ public class freeswitch {
|
||||
public static readonly string SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE = freeswitchPINVOKE.SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE_get();
|
||||
public static readonly string SWITCH_LOCAL_MEDIA_IP_VARIABLE = freeswitchPINVOKE.SWITCH_LOCAL_MEDIA_IP_VARIABLE_get();
|
||||
public static readonly string SWITCH_LOCAL_MEDIA_PORT_VARIABLE = freeswitchPINVOKE.SWITCH_LOCAL_MEDIA_PORT_VARIABLE_get();
|
||||
public static readonly string SWITCH_ADVERTISED_MEDIA_IP_VARIABLE = freeswitchPINVOKE.SWITCH_ADVERTISED_MEDIA_IP_VARIABLE_get();
|
||||
public static readonly string SWITCH_REMOTE_MEDIA_IP_VARIABLE = freeswitchPINVOKE.SWITCH_REMOTE_MEDIA_IP_VARIABLE_get();
|
||||
public static readonly string SWITCH_REMOTE_MEDIA_PORT_VARIABLE = freeswitchPINVOKE.SWITCH_REMOTE_MEDIA_PORT_VARIABLE_get();
|
||||
public static readonly string SWITCH_REMOTE_VIDEO_IP_VARIABLE = freeswitchPINVOKE.SWITCH_REMOTE_VIDEO_IP_VARIABLE_get();
|
||||
@@ -6408,6 +6454,9 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_LOCAL_MEDIA_PORT_VARIABLE_get")]
|
||||
public static extern string SWITCH_LOCAL_MEDIA_PORT_VARIABLE_get();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_ADVERTISED_MEDIA_IP_VARIABLE_get")]
|
||||
public static extern string SWITCH_ADVERTISED_MEDIA_IP_VARIABLE_get();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_REMOTE_MEDIA_IP_VARIABLE_get")]
|
||||
public static extern string SWITCH_REMOTE_MEDIA_IP_VARIABLE_get();
|
||||
|
||||
@@ -6480,6 +6529,12 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_dtmf_t_flags_get")]
|
||||
public static extern int switch_dtmf_t_flags_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_dtmf_t_source_set")]
|
||||
public static extern void switch_dtmf_t_source_set(HandleRef jarg1, int jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_dtmf_t_source_get")]
|
||||
public static extern int switch_dtmf_t_source_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_new_switch_dtmf_t")]
|
||||
public static extern IntPtr new_switch_dtmf_t();
|
||||
|
||||
@@ -7338,6 +7393,9 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CORE_DB_DONE_get")]
|
||||
public static extern int SWITCH_CORE_DB_DONE_get();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_sql_concat")]
|
||||
public static extern string switch_sql_concat();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_regex_compile")]
|
||||
public static extern IntPtr switch_regex_compile(string jarg1, int jarg2, ref string jarg3, HandleRef jarg4, HandleRef jarg5);
|
||||
|
||||
@@ -7837,7 +7895,7 @@ class freeswitchPINVOKE {
|
||||
public static extern IntPtr switch_core_session_get_channel(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_wake_session_thread")]
|
||||
public static extern void switch_core_session_wake_session_thread(HandleRef jarg1);
|
||||
public static extern int switch_core_session_wake_session_thread(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_signal_state_change")]
|
||||
public static extern void switch_core_session_signal_state_change(HandleRef jarg1);
|
||||
@@ -7858,10 +7916,16 @@ class freeswitchPINVOKE {
|
||||
public static extern void switch_core_session_soft_unlock(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_set_dmachine")]
|
||||
public static extern void switch_core_session_set_dmachine(HandleRef jarg1, HandleRef jarg2);
|
||||
public static extern void switch_core_session_set_dmachine(HandleRef jarg1, HandleRef jarg2, int jarg3);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_dmachine")]
|
||||
public static extern IntPtr switch_core_session_get_dmachine(HandleRef jarg1);
|
||||
public static extern IntPtr switch_core_session_get_dmachine(HandleRef jarg1, int jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_dmachine_get_target")]
|
||||
public static extern int switch_ivr_dmachine_get_target(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_dmachine_set_target")]
|
||||
public static extern void switch_ivr_dmachine_set_target(HandleRef jarg1, int jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_set_codec_slin")]
|
||||
public static extern int switch_core_session_set_codec_slin(HandleRef jarg1, HandleRef jarg2);
|
||||
@@ -8343,12 +8407,18 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_management_exec")]
|
||||
public static extern int switch_core_management_exec(string jarg1, int jarg2, string jarg3, HandleRef jarg4);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_set_high_priority")]
|
||||
public static extern int set_high_priority();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_set_normal_priority")]
|
||||
public static extern int set_normal_priority();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_set_auto_priority")]
|
||||
public static extern int set_auto_priority();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_set_realtime_priority")]
|
||||
public static extern int set_realtime_priority();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_set_low_priority")]
|
||||
public static extern int set_low_priority();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_change_user_group")]
|
||||
public static extern int change_user_group(string jarg1, string jarg2);
|
||||
|
||||
@@ -8478,8 +8548,11 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_cond_next")]
|
||||
public static extern void switch_cond_next();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_chat_send_args")]
|
||||
public static extern int switch_core_chat_send_args(string jarg1, string jarg2, string jarg3, string jarg4, string jarg5, string jarg6, string jarg7, string jarg8);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_chat_send")]
|
||||
public static extern int switch_core_chat_send(string jarg1, string jarg2, string jarg3, string jarg4, string jarg5, string jarg6, string jarg7, string jarg8);
|
||||
public static extern int switch_core_chat_send(string jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_preprocess_session")]
|
||||
public static extern int switch_ivr_preprocess_session(HandleRef jarg1, string jarg2);
|
||||
@@ -12081,6 +12154,12 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_channel_api_on")]
|
||||
public static extern int switch_channel_api_on(HandleRef jarg1, string jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_channel_get_queued_extension")]
|
||||
public static extern IntPtr switch_channel_get_queued_extension(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_channel_transfer_to_extension")]
|
||||
public static extern void switch_channel_transfer_to_extension(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_buffer_create")]
|
||||
public static extern int switch_buffer_create(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3);
|
||||
|
||||
@@ -12591,6 +12670,9 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_parse_all_signal_data")]
|
||||
public static extern int switch_ivr_parse_all_signal_data(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_process_indications")]
|
||||
public static extern int switch_ivr_process_indications(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_sleep")]
|
||||
public static extern int switch_ivr_sleep(HandleRef jarg1, uint jarg2, int jarg3, HandleRef jarg4);
|
||||
|
||||
@@ -12706,7 +12788,7 @@ class freeswitchPINVOKE {
|
||||
public static extern int switch_ivr_originate(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3, string jarg4, uint jarg5, HandleRef jarg6, string jarg7, string jarg8, HandleRef jarg9, HandleRef jarg10, uint jarg11, HandleRef jarg12);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_enterprise_originate")]
|
||||
public static extern int switch_ivr_enterprise_originate(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3, string jarg4, uint jarg5, HandleRef jarg6, string jarg7, string jarg8, HandleRef jarg9, HandleRef jarg10, uint jarg11);
|
||||
public static extern int switch_ivr_enterprise_originate(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3, string jarg4, uint jarg5, HandleRef jarg6, string jarg7, string jarg8, HandleRef jarg9, HandleRef jarg10, uint jarg11, HandleRef jarg12);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_bridge_display")]
|
||||
public static extern void switch_ivr_bridge_display(HandleRef jarg1, HandleRef jarg2);
|
||||
@@ -15117,36 +15199,6 @@ namespace FreeSWITCH.Native {
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t {
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
internal SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t(IntPtr cPtr, bool futureUse) {
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
protected SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t() {
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr(SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t obj) {
|
||||
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_switch_event_t_p_void__p_switch_xml {
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
@@ -16497,6 +16549,36 @@ namespace FreeSWITCH.Native {
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class SWIGTYPE_p_f_p_switch_event__switch_status_t {
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
internal SWIGTYPE_p_f_p_switch_event__switch_status_t(IntPtr cPtr, bool futureUse) {
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
protected SWIGTYPE_p_f_p_switch_event__switch_status_t() {
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_event__switch_status_t obj) {
|
||||
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class SWIGTYPE_p_f_p_switch_event__void {
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
@@ -20143,7 +20225,8 @@ namespace FreeSWITCH.Native {
|
||||
SAF_NONE = 0,
|
||||
SAF_SUPPORT_NOMEDIA = (1 << 0),
|
||||
SAF_ROUTING_EXEC = (1 << 1),
|
||||
SAF_MEDIA_TAP = (1 << 2)
|
||||
SAF_MEDIA_TAP = (1 << 2),
|
||||
SAF_ZOMBIE_EXEC = (1 << 3)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22337,6 +22420,7 @@ public enum switch_channel_cap_t {
|
||||
CC_PROXY_MEDIA,
|
||||
CC_JITTERBUFFER,
|
||||
CC_FS_RTP,
|
||||
CC_QUEUEABLE_DTMF_DELAY,
|
||||
CC_FLAG_MAX
|
||||
}
|
||||
|
||||
@@ -22415,6 +22499,7 @@ public enum switch_channel_flag_t {
|
||||
CF_LAZY_ATTENDED_TRANSFER,
|
||||
CF_SIGNAL_DATA,
|
||||
CF_SIMPLIFY,
|
||||
CF_ZOMBIE_EXEC,
|
||||
CF_FLAG_MAX
|
||||
}
|
||||
|
||||
@@ -22692,13 +22777,13 @@ public class switch_chat_interface : IDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t chat_send {
|
||||
public SWIGTYPE_p_f_p_switch_event__switch_status_t chat_send {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_chat_interface_chat_send_set(swigCPtr, SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t.getCPtr(value));
|
||||
freeswitchPINVOKE.switch_chat_interface_chat_send_set(swigCPtr, SWIGTYPE_p_f_p_switch_event__switch_status_t.getCPtr(value));
|
||||
}
|
||||
get {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_chat_interface_chat_send_get(swigCPtr);
|
||||
SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t(cPtr, false);
|
||||
SWIGTYPE_p_f_p_switch_event__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_event__switch_status_t(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -23835,7 +23920,9 @@ namespace FreeSWITCH.Native {
|
||||
SCF_USE_WIN32_MONOTONIC = (1 << 12),
|
||||
SCF_AUTO_SCHEMAS = (1 << 13),
|
||||
SCF_MINIMAL = (1 << 14),
|
||||
SCF_USE_NAT_MAPPING = (1 << 15)
|
||||
SCF_USE_NAT_MAPPING = (1 << 15),
|
||||
SCF_CLEAR_SQL = (1 << 16),
|
||||
SCF_THREADED_SYSTEM_EXEC = (1 << 17)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24504,6 +24591,23 @@ public class switch_dialplan_interface : IDisposable {
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
public enum switch_digit_action_target_t {
|
||||
DIGIT_TARGET_SELF,
|
||||
DIGIT_TARGET_PEER,
|
||||
DIGIT_TARGET_BOTH
|
||||
}
|
||||
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -24974,6 +25078,25 @@ public enum switch_dtmf_direction_t {
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
public enum switch_dtmf_source_t {
|
||||
SWITCH_DTMF_UNKNOWN,
|
||||
SWITCH_DTMF_INBAND_AUDIO,
|
||||
SWITCH_DTMF_RTP,
|
||||
SWITCH_DTMF_ENDPOINT,
|
||||
SWITCH_DTMF_APP
|
||||
}
|
||||
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -25037,6 +25160,16 @@ public class switch_dtmf_t : IDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
public switch_dtmf_source_t source {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_dtmf_t_source_set(swigCPtr, (int)value);
|
||||
}
|
||||
get {
|
||||
switch_dtmf_source_t ret = (switch_dtmf_source_t)freeswitchPINVOKE.switch_dtmf_t_source_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public switch_dtmf_t() : this(freeswitchPINVOKE.new_switch_dtmf_t(), true) {
|
||||
}
|
||||
|
||||
@@ -26537,7 +26670,8 @@ namespace FreeSWITCH.Native {
|
||||
SFF_PROXY_PACKET = (1 << 5),
|
||||
SFF_DYNAMIC = (1 << 6),
|
||||
SFF_ZRTP = (1 << 7),
|
||||
SFF_UDPTL_PACKET = (1 << 8)
|
||||
SFF_UDPTL_PACKET = (1 << 8),
|
||||
SFF_NOT_AUDIO = (1 << 9)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29367,7 +29501,8 @@ public enum switch_rtp_bug_flag_t {
|
||||
RTP_BUG_SEND_LINEAR_TIMESTAMPS = (1 << 3),
|
||||
RTP_BUG_START_SEQ_AT_ZERO = (1 << 4),
|
||||
RTP_BUG_NEVER_SEND_MARKER = (1 << 5),
|
||||
RTP_BUG_IGNORE_DTMF_DURATION = (1 << 6)
|
||||
RTP_BUG_IGNORE_DTMF_DURATION = (1 << 6),
|
||||
RTP_BUG_ACCEPT_ANY_PACKETS = (1 << 7)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30419,7 +30554,8 @@ public enum switch_session_ctl_t {
|
||||
SCSC_VERBOSE_EVENTS,
|
||||
SCSC_SHUTDOWN_CHECK,
|
||||
SCSC_PAUSE_CHECK,
|
||||
SCSC_READY_CHECK
|
||||
SCSC_READY_CHECK,
|
||||
SCSC_THREADED_SYSTEM_EXEC
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -737,6 +737,16 @@ public partial class Event : IDisposable {
|
||||
public Event(switch_event wrap_me, int free_me) : this(freeswitchPINVOKE.new_Event__SWIG_1(switch_event.getCPtr(wrap_me), free_me), true) {
|
||||
}
|
||||
|
||||
public int chat_execute(string app, string data) {
|
||||
int ret = freeswitchPINVOKE.Event_chat_execute(swigCPtr, app, data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int chat_send(string dest_proto) {
|
||||
int ret = freeswitchPINVOKE.Event_chat_send(swigCPtr, dest_proto);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public string Serialize(string format) {
|
||||
string ret = freeswitchPINVOKE.Event_Serialize(swigCPtr, format);
|
||||
return ret;
|
||||
@@ -909,6 +919,11 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static string switch_sql_concat() {
|
||||
string ret = freeswitchPINVOKE.switch_sql_concat();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static SWIGTYPE_p_real_pcre switch_regex_compile(string pattern, int options, ref string errorptr, SWIGTYPE_p_int erroroffset, SWIGTYPE_p_unsigned_char tables) {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_regex_compile(pattern, options, ref errorptr, SWIGTYPE_p_int.getCPtr(erroroffset), SWIGTYPE_p_unsigned_char.getCPtr(tables));
|
||||
SWIGTYPE_p_real_pcre ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_real_pcre(cPtr, false);
|
||||
@@ -952,6 +967,10 @@ public class freeswitch {
|
||||
freeswitchPINVOKE.switch_regex_set_var_callback(var, val, SWIGTYPE_p_void.getCPtr(user_data));
|
||||
}
|
||||
|
||||
public static void switch_regex_set_event_header_callback(string var, string val, SWIGTYPE_p_void user_data) {
|
||||
freeswitchPINVOKE.switch_regex_set_event_header_callback(var, val, SWIGTYPE_p_void.getCPtr(user_data));
|
||||
}
|
||||
|
||||
public static void switch_core_session_sched_heartbeat(SWIGTYPE_p_switch_core_session session, uint seconds) {
|
||||
freeswitchPINVOKE.switch_core_session_sched_heartbeat(SWIGTYPE_p_switch_core_session.getCPtr(session), seconds);
|
||||
}
|
||||
@@ -1371,16 +1390,25 @@ public class freeswitch {
|
||||
freeswitchPINVOKE.switch_core_session_soft_unlock(SWIGTYPE_p_switch_core_session.getCPtr(session));
|
||||
}
|
||||
|
||||
public static void switch_core_session_set_dmachine(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_switch_ivr_dmachine dmachine) {
|
||||
freeswitchPINVOKE.switch_core_session_set_dmachine(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_switch_ivr_dmachine.getCPtr(dmachine));
|
||||
public static void switch_core_session_set_dmachine(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_switch_ivr_dmachine dmachine, switch_digit_action_target_t target) {
|
||||
freeswitchPINVOKE.switch_core_session_set_dmachine(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_switch_ivr_dmachine.getCPtr(dmachine), (int)target);
|
||||
}
|
||||
|
||||
public static SWIGTYPE_p_switch_ivr_dmachine switch_core_session_get_dmachine(SWIGTYPE_p_switch_core_session session) {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_core_session_get_dmachine(SWIGTYPE_p_switch_core_session.getCPtr(session));
|
||||
public static SWIGTYPE_p_switch_ivr_dmachine switch_core_session_get_dmachine(SWIGTYPE_p_switch_core_session session, switch_digit_action_target_t target) {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_core_session_get_dmachine(SWIGTYPE_p_switch_core_session.getCPtr(session), (int)target);
|
||||
SWIGTYPE_p_switch_ivr_dmachine ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_ivr_dmachine(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_digit_action_target_t switch_ivr_dmachine_get_target(SWIGTYPE_p_switch_ivr_dmachine dmachine) {
|
||||
switch_digit_action_target_t ret = (switch_digit_action_target_t)freeswitchPINVOKE.switch_ivr_dmachine_get_target(SWIGTYPE_p_switch_ivr_dmachine.getCPtr(dmachine));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void switch_ivr_dmachine_set_target(SWIGTYPE_p_switch_ivr_dmachine dmachine, switch_digit_action_target_t target) {
|
||||
freeswitchPINVOKE.switch_ivr_dmachine_set_target(SWIGTYPE_p_switch_ivr_dmachine.getCPtr(dmachine), (int)target);
|
||||
}
|
||||
|
||||
public static switch_status_t switch_core_session_set_codec_slin(SWIGTYPE_p_switch_core_session session, switch_slin_data data) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_set_codec_slin(SWIGTYPE_p_switch_core_session.getCPtr(session), switch_slin_data.getCPtr(data));
|
||||
return ret;
|
||||
@@ -2174,13 +2202,23 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int set_high_priority() {
|
||||
int ret = freeswitchPINVOKE.set_high_priority();
|
||||
public static int set_normal_priority() {
|
||||
int ret = freeswitchPINVOKE.set_normal_priority();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int set_normal_priority() {
|
||||
int ret = freeswitchPINVOKE.set_normal_priority();
|
||||
public static int set_auto_priority() {
|
||||
int ret = freeswitchPINVOKE.set_auto_priority();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int set_realtime_priority() {
|
||||
int ret = freeswitchPINVOKE.set_realtime_priority();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int set_low_priority() {
|
||||
int ret = freeswitchPINVOKE.set_low_priority();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2390,8 +2428,18 @@ public class freeswitch {
|
||||
freeswitchPINVOKE.switch_cond_next();
|
||||
}
|
||||
|
||||
public static switch_status_t switch_core_chat_send(string name, string proto, string from, string to, string subject, string body, string type, string hint) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_chat_send(name, proto, from, to, subject, body, type, hint);
|
||||
public static switch_status_t switch_core_chat_send_args(string dest_proto, string proto, string from, string to, string subject, string body, string type, string hint) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_chat_send_args(dest_proto, proto, from, to, subject, body, type, hint);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_core_chat_send(string dest_proto, switch_event message_event) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_chat_send(dest_proto, switch_event.getCPtr(message_event));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_core_chat_deliver(string dest_proto, SWIGTYPE_p_p_switch_event message_event) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_chat_deliver(dest_proto, SWIGTYPE_p_p_switch_event.getCPtr(message_event));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2592,6 +2640,17 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_chat_application_interface switch_loadable_module_get_chat_application_interface(string name) {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_get_chat_application_interface(name);
|
||||
switch_chat_application_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_chat_application_interface(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_core_execute_chat_app(switch_event message, string app, string data) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_execute_chat_app(switch_event.getCPtr(message), app, data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_api_interface switch_loadable_module_get_api_interface(string name) {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_get_api_interface(name);
|
||||
switch_api_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_api_interface(cPtr, false);
|
||||
@@ -3854,6 +3913,16 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_caller_extension switch_channel_get_queued_extension(SWIGTYPE_p_switch_channel channel) {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_channel_get_queued_extension(SWIGTYPE_p_switch_channel.getCPtr(channel));
|
||||
switch_caller_extension ret = (cPtr == IntPtr.Zero) ? null : new switch_caller_extension(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void switch_channel_transfer_to_extension(SWIGTYPE_p_switch_channel channel, switch_caller_extension caller_extension) {
|
||||
freeswitchPINVOKE.switch_channel_transfer_to_extension(SWIGTYPE_p_switch_channel.getCPtr(channel), switch_caller_extension.getCPtr(caller_extension));
|
||||
}
|
||||
|
||||
public static switch_status_t switch_buffer_create(SWIGTYPE_p_apr_pool_t pool, SWIGTYPE_p_p_switch_buffer buffer, SWIGTYPE_p_switch_size_t max_len) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_buffer_create(SWIGTYPE_p_apr_pool_t.getCPtr(pool), SWIGTYPE_p_p_switch_buffer.getCPtr(buffer), SWIGTYPE_p_switch_size_t.getCPtr(max_len));
|
||||
if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve();
|
||||
@@ -3988,6 +4057,11 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_event_rename_header(switch_event arg0, string header_name, string new_header_name) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_rename_header(switch_event.getCPtr(arg0), header_name, new_header_name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static string switch_event_get_body(switch_event arg0) {
|
||||
string ret = freeswitchPINVOKE.switch_event_get_body(switch_event.getCPtr(arg0));
|
||||
return ret;
|
||||
@@ -4026,6 +4100,11 @@ public class freeswitch {
|
||||
freeswitchPINVOKE.switch_event_merge(switch_event.getCPtr(arg0), switch_event.getCPtr(tomerge));
|
||||
}
|
||||
|
||||
public static switch_status_t switch_event_dup_reply(SWIGTYPE_p_p_switch_event arg0, switch_event todup) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_dup_reply(SWIGTYPE_p_p_switch_event.getCPtr(arg0), switch_event.getCPtr(todup));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_event_fire_detailed(string file, string func, int line, SWIGTYPE_p_p_switch_event arg3, SWIGTYPE_p_void user_data) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_fire_detailed(file, func, line, SWIGTYPE_p_p_switch_event.getCPtr(arg3), SWIGTYPE_p_void.getCPtr(user_data));
|
||||
return ret;
|
||||
@@ -4100,6 +4179,11 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_event_set_body(switch_event arg0, string body) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_set_body(switch_event.getCPtr(arg0), body);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static string switch_event_expand_headers(switch_event arg0, string arg1) {
|
||||
string ret = freeswitchPINVOKE.switch_event_expand_headers(switch_event.getCPtr(arg0), arg1);
|
||||
return ret;
|
||||
@@ -4430,8 +4514,8 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_ivr_enterprise_originate(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_core_session bleg, SWIGTYPE_p_switch_call_cause_t cause, string bridgeto, uint timelimit_sec, switch_state_handler_table table, string cid_name_override, string cid_num_override, switch_caller_profile caller_profile_override, switch_event ovars, uint flags) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_enterprise_originate(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_core_session.getCPtr(bleg), SWIGTYPE_p_switch_call_cause_t.getCPtr(cause), bridgeto, timelimit_sec, switch_state_handler_table.getCPtr(table), cid_name_override, cid_num_override, switch_caller_profile.getCPtr(caller_profile_override), switch_event.getCPtr(ovars), flags);
|
||||
public static switch_status_t switch_ivr_enterprise_originate(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_core_session bleg, SWIGTYPE_p_switch_call_cause_t cause, string bridgeto, uint timelimit_sec, switch_state_handler_table table, string cid_name_override, string cid_num_override, switch_caller_profile caller_profile_override, switch_event ovars, uint flags, SWIGTYPE_p_switch_call_cause_t cancel_cause) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_enterprise_originate(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_core_session.getCPtr(bleg), SWIGTYPE_p_switch_call_cause_t.getCPtr(cause), bridgeto, timelimit_sec, switch_state_handler_table.getCPtr(table), cid_name_override, cid_num_override, switch_caller_profile.getCPtr(caller_profile_override), switch_event.getCPtr(ovars), flags, SWIGTYPE_p_switch_call_cause_t.getCPtr(cancel_cause));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -4812,6 +4896,11 @@ public class freeswitch {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_ivr_create_message_reply(SWIGTYPE_p_p_switch_event reply, switch_event message, string new_proto) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_create_message_reply(SWIGTYPE_p_p_switch_event.getCPtr(reply), switch_event.getCPtr(message), new_proto);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static switch_status_t switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp rtp_session, switch_rtp_crypto_direction_t direction, uint index, switch_rtp_crypto_key_type_t type, SWIGTYPE_p_unsigned_char key, SWIGTYPE_p_switch_size_t keylen) {
|
||||
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)direction, index, (int)type, SWIGTYPE_p_unsigned_char.getCPtr(key), SWIGTYPE_p_switch_size_t.getCPtr(keylen));
|
||||
if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve();
|
||||
@@ -5760,6 +5849,7 @@ public class freeswitch {
|
||||
public static readonly string SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE = freeswitchPINVOKE.SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE_get();
|
||||
public static readonly string SWITCH_LOCAL_MEDIA_IP_VARIABLE = freeswitchPINVOKE.SWITCH_LOCAL_MEDIA_IP_VARIABLE_get();
|
||||
public static readonly string SWITCH_LOCAL_MEDIA_PORT_VARIABLE = freeswitchPINVOKE.SWITCH_LOCAL_MEDIA_PORT_VARIABLE_get();
|
||||
public static readonly string SWITCH_ADVERTISED_MEDIA_IP_VARIABLE = freeswitchPINVOKE.SWITCH_ADVERTISED_MEDIA_IP_VARIABLE_get();
|
||||
public static readonly string SWITCH_REMOTE_MEDIA_IP_VARIABLE = freeswitchPINVOKE.SWITCH_REMOTE_MEDIA_IP_VARIABLE_get();
|
||||
public static readonly string SWITCH_REMOTE_MEDIA_PORT_VARIABLE = freeswitchPINVOKE.SWITCH_REMOTE_MEDIA_PORT_VARIABLE_get();
|
||||
public static readonly string SWITCH_REMOTE_VIDEO_IP_VARIABLE = freeswitchPINVOKE.SWITCH_REMOTE_VIDEO_IP_VARIABLE_get();
|
||||
@@ -6400,6 +6490,9 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_LOCAL_MEDIA_PORT_VARIABLE_get")]
|
||||
public static extern string SWITCH_LOCAL_MEDIA_PORT_VARIABLE_get();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_ADVERTISED_MEDIA_IP_VARIABLE_get")]
|
||||
public static extern string SWITCH_ADVERTISED_MEDIA_IP_VARIABLE_get();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_REMOTE_MEDIA_IP_VARIABLE_get")]
|
||||
public static extern string SWITCH_REMOTE_MEDIA_IP_VARIABLE_get();
|
||||
|
||||
@@ -7336,6 +7429,9 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CORE_DB_DONE_get")]
|
||||
public static extern int SWITCH_CORE_DB_DONE_get();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_sql_concat")]
|
||||
public static extern string switch_sql_concat();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_regex_compile")]
|
||||
public static extern IntPtr switch_regex_compile(string jarg1, int jarg2, ref string jarg3, HandleRef jarg4, HandleRef jarg5);
|
||||
|
||||
@@ -7363,6 +7459,9 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_regex_set_var_callback")]
|
||||
public static extern void switch_regex_set_var_callback(string jarg1, string jarg2, HandleRef jarg3);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_regex_set_event_header_callback")]
|
||||
public static extern void switch_regex_set_event_header_callback(string jarg1, string jarg2, HandleRef jarg3);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_MAX_CORE_THREAD_SESSION_OBJS_get")]
|
||||
public static extern int SWITCH_MAX_CORE_THREAD_SESSION_OBJS_get();
|
||||
|
||||
@@ -7856,10 +7955,16 @@ class freeswitchPINVOKE {
|
||||
public static extern void switch_core_session_soft_unlock(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_set_dmachine")]
|
||||
public static extern void switch_core_session_set_dmachine(HandleRef jarg1, HandleRef jarg2);
|
||||
public static extern void switch_core_session_set_dmachine(HandleRef jarg1, HandleRef jarg2, int jarg3);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_dmachine")]
|
||||
public static extern IntPtr switch_core_session_get_dmachine(HandleRef jarg1);
|
||||
public static extern IntPtr switch_core_session_get_dmachine(HandleRef jarg1, int jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_dmachine_get_target")]
|
||||
public static extern int switch_ivr_dmachine_get_target(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_dmachine_set_target")]
|
||||
public static extern void switch_ivr_dmachine_set_target(HandleRef jarg1, int jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_set_codec_slin")]
|
||||
public static extern int switch_core_session_set_codec_slin(HandleRef jarg1, HandleRef jarg2);
|
||||
@@ -8341,12 +8446,18 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_management_exec")]
|
||||
public static extern int switch_core_management_exec(string jarg1, int jarg2, string jarg3, HandleRef jarg4);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_set_high_priority")]
|
||||
public static extern int set_high_priority();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_set_normal_priority")]
|
||||
public static extern int set_normal_priority();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_set_auto_priority")]
|
||||
public static extern int set_auto_priority();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_set_realtime_priority")]
|
||||
public static extern int set_realtime_priority();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_set_low_priority")]
|
||||
public static extern int set_low_priority();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_change_user_group")]
|
||||
public static extern int change_user_group(string jarg1, string jarg2);
|
||||
|
||||
@@ -8476,8 +8587,14 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_cond_next")]
|
||||
public static extern void switch_cond_next();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_chat_send_args")]
|
||||
public static extern int switch_core_chat_send_args(string jarg1, string jarg2, string jarg3, string jarg4, string jarg5, string jarg6, string jarg7, string jarg8);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_chat_send")]
|
||||
public static extern int switch_core_chat_send(string jarg1, string jarg2, string jarg3, string jarg4, string jarg5, string jarg6, string jarg7, string jarg8);
|
||||
public static extern int switch_core_chat_send(string jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_chat_deliver")]
|
||||
public static extern int switch_core_chat_deliver(string jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_preprocess_session")]
|
||||
public static extern int switch_ivr_preprocess_session(HandleRef jarg1, string jarg2);
|
||||
@@ -8680,6 +8797,12 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_application_interface_get")]
|
||||
public static extern IntPtr switch_loadable_module_interface_application_interface_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_chat_application_interface_set")]
|
||||
public static extern void switch_loadable_module_interface_chat_application_interface_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_chat_application_interface_get")]
|
||||
public static extern IntPtr switch_loadable_module_interface_chat_application_interface_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_api_interface_set")]
|
||||
public static extern void switch_loadable_module_interface_api_interface_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
@@ -8788,6 +8911,12 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_application_interface")]
|
||||
public static extern IntPtr switch_loadable_module_get_application_interface(string jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_chat_application_interface")]
|
||||
public static extern IntPtr switch_loadable_module_get_chat_application_interface(string jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_execute_chat_app")]
|
||||
public static extern int switch_core_execute_chat_app(HandleRef jarg1, string jarg2, string jarg3);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_api_interface")]
|
||||
public static extern IntPtr switch_loadable_module_get_api_interface(string jarg1);
|
||||
|
||||
@@ -11557,6 +11686,78 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_delete_switch_application_interface")]
|
||||
public static extern void delete_switch_application_interface(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_interface_name_set")]
|
||||
public static extern void switch_chat_application_interface_interface_name_set(HandleRef jarg1, string jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_interface_name_get")]
|
||||
public static extern string switch_chat_application_interface_interface_name_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_chat_application_function_set")]
|
||||
public static extern void switch_chat_application_interface_chat_application_function_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_chat_application_function_get")]
|
||||
public static extern IntPtr switch_chat_application_interface_chat_application_function_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_long_desc_set")]
|
||||
public static extern void switch_chat_application_interface_long_desc_set(HandleRef jarg1, string jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_long_desc_get")]
|
||||
public static extern string switch_chat_application_interface_long_desc_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_short_desc_set")]
|
||||
public static extern void switch_chat_application_interface_short_desc_set(HandleRef jarg1, string jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_short_desc_get")]
|
||||
public static extern string switch_chat_application_interface_short_desc_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_syntax_set")]
|
||||
public static extern void switch_chat_application_interface_syntax_set(HandleRef jarg1, string jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_syntax_get")]
|
||||
public static extern string switch_chat_application_interface_syntax_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_flags_set")]
|
||||
public static extern void switch_chat_application_interface_flags_set(HandleRef jarg1, uint jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_flags_get")]
|
||||
public static extern uint switch_chat_application_interface_flags_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_rwlock_set")]
|
||||
public static extern void switch_chat_application_interface_rwlock_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_rwlock_get")]
|
||||
public static extern IntPtr switch_chat_application_interface_rwlock_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_refs_set")]
|
||||
public static extern void switch_chat_application_interface_refs_set(HandleRef jarg1, int jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_refs_get")]
|
||||
public static extern int switch_chat_application_interface_refs_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_reflock_set")]
|
||||
public static extern void switch_chat_application_interface_reflock_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_reflock_get")]
|
||||
public static extern IntPtr switch_chat_application_interface_reflock_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_parent_set")]
|
||||
public static extern void switch_chat_application_interface_parent_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_parent_get")]
|
||||
public static extern IntPtr switch_chat_application_interface_parent_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_next_set")]
|
||||
public static extern void switch_chat_application_interface_next_set(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_next_get")]
|
||||
public static extern IntPtr switch_chat_application_interface_next_get(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_new_switch_chat_application_interface")]
|
||||
public static extern IntPtr new_switch_chat_application_interface();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_delete_switch_chat_application_interface")]
|
||||
public static extern void delete_switch_chat_application_interface(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_interface_name_set")]
|
||||
public static extern void switch_api_interface_interface_name_set(HandleRef jarg1, string jarg2);
|
||||
|
||||
@@ -12079,6 +12280,12 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_channel_api_on")]
|
||||
public static extern int switch_channel_api_on(HandleRef jarg1, string jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_channel_get_queued_extension")]
|
||||
public static extern IntPtr switch_channel_get_queued_extension(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_channel_transfer_to_extension")]
|
||||
public static extern void switch_channel_transfer_to_extension(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_buffer_create")]
|
||||
public static extern int switch_buffer_create(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3);
|
||||
|
||||
@@ -12277,6 +12484,9 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_event_get_header_idx")]
|
||||
public static extern string switch_event_get_header_idx(HandleRef jarg1, string jarg2, int jarg3);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_event_rename_header")]
|
||||
public static extern int switch_event_rename_header(HandleRef jarg1, string jarg2, string jarg3);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_event_get_body")]
|
||||
public static extern string switch_event_get_body(HandleRef jarg1);
|
||||
|
||||
@@ -12301,6 +12511,9 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_event_merge")]
|
||||
public static extern void switch_event_merge(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_event_dup_reply")]
|
||||
public static extern int switch_event_dup_reply(HandleRef jarg1, HandleRef jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_event_fire_detailed")]
|
||||
public static extern int switch_event_fire_detailed(string jarg1, string jarg2, int jarg3, HandleRef jarg4, HandleRef jarg5);
|
||||
|
||||
@@ -12346,6 +12559,9 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_event_running")]
|
||||
public static extern int switch_event_running();
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_event_set_body")]
|
||||
public static extern int switch_event_set_body(HandleRef jarg1, string jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_event_expand_headers")]
|
||||
public static extern string switch_event_expand_headers(HandleRef jarg1, string jarg2);
|
||||
|
||||
@@ -12707,7 +12923,7 @@ class freeswitchPINVOKE {
|
||||
public static extern int switch_ivr_originate(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3, string jarg4, uint jarg5, HandleRef jarg6, string jarg7, string jarg8, HandleRef jarg9, HandleRef jarg10, uint jarg11, HandleRef jarg12);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_enterprise_originate")]
|
||||
public static extern int switch_ivr_enterprise_originate(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3, string jarg4, uint jarg5, HandleRef jarg6, string jarg7, string jarg8, HandleRef jarg9, HandleRef jarg10, uint jarg11);
|
||||
public static extern int switch_ivr_enterprise_originate(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3, string jarg4, uint jarg5, HandleRef jarg6, string jarg7, string jarg8, HandleRef jarg9, HandleRef jarg10, uint jarg11, HandleRef jarg12);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_bridge_display")]
|
||||
public static extern void switch_ivr_bridge_display(HandleRef jarg1, HandleRef jarg2);
|
||||
@@ -12937,6 +13153,9 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_insert_file")]
|
||||
public static extern int switch_ivr_insert_file(HandleRef jarg1, string jarg2, string jarg3, HandleRef jarg4);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_create_message_reply")]
|
||||
public static extern int switch_ivr_create_message_reply(HandleRef jarg1, HandleRef jarg2, string jarg3);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RTP_MAX_BUF_LEN_get")]
|
||||
public static extern int SWITCH_RTP_MAX_BUF_LEN_get();
|
||||
|
||||
@@ -14152,6 +14371,12 @@ class freeswitchPINVOKE {
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_delete_Event")]
|
||||
public static extern void delete_Event(HandleRef jarg1);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_Event_chat_execute")]
|
||||
public static extern int Event_chat_execute(HandleRef jarg1, string jarg2, string jarg3);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_Event_chat_send")]
|
||||
public static extern int Event_chat_send(HandleRef jarg1, string jarg2);
|
||||
|
||||
[DllImport("mod_managed", EntryPoint="CSharp_Event_Serialize")]
|
||||
public static extern string Event_Serialize(HandleRef jarg1, string jarg2);
|
||||
|
||||
@@ -15106,36 +15331,6 @@ namespace FreeSWITCH.Native {
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t {
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
internal SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t(IntPtr cPtr, bool futureUse) {
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
protected SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t() {
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr(SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t obj) {
|
||||
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.35
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_switch_event_t_p_void__p_switch_xml {
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
@@ -16486,6 +16681,66 @@ namespace FreeSWITCH.Native {
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t {
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
internal SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t(IntPtr cPtr, bool futureUse) {
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
protected SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t() {
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t obj) {
|
||||
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.35
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class SWIGTYPE_p_f_p_switch_event__switch_status_t {
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
internal SWIGTYPE_p_f_p_switch_event__switch_status_t(IntPtr cPtr, bool futureUse) {
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
protected SWIGTYPE_p_f_p_switch_event__switch_status_t() {
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_event__switch_status_t obj) {
|
||||
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.35
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class SWIGTYPE_p_f_p_switch_event__void {
|
||||
private HandleRef swigCPtr;
|
||||
|
||||
@@ -20130,7 +20385,8 @@ namespace FreeSWITCH.Native {
|
||||
SAF_NONE = 0,
|
||||
SAF_SUPPORT_NOMEDIA = (1 << 0),
|
||||
SAF_ROUTING_EXEC = (1 << 1),
|
||||
SAF_MEDIA_TAP = (1 << 2)
|
||||
SAF_MEDIA_TAP = (1 << 2),
|
||||
SAF_ZOMBIE_EXEC = (1 << 3)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22298,6 +22554,7 @@ public enum switch_channel_cap_t {
|
||||
CC_PROXY_MEDIA,
|
||||
CC_JITTERBUFFER,
|
||||
CC_FS_RTP,
|
||||
CC_QUEUEABLE_DTMF_DELAY,
|
||||
CC_FLAG_MAX
|
||||
}
|
||||
|
||||
@@ -22376,6 +22633,7 @@ public enum switch_channel_flag_t {
|
||||
CF_LAZY_ATTENDED_TRANSFER,
|
||||
CF_SIGNAL_DATA,
|
||||
CF_SIMPLIFY,
|
||||
CF_ZOMBIE_EXEC,
|
||||
CF_FLAG_MAX
|
||||
}
|
||||
|
||||
@@ -22608,6 +22866,183 @@ public class switch_channel_timetable : IDisposable {
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
public enum switch_chat_application_flag_enum_t {
|
||||
SCAF_NONE = 0
|
||||
}
|
||||
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.35
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class switch_chat_application_interface : IDisposable {
|
||||
private HandleRef swigCPtr;
|
||||
protected bool swigCMemOwn;
|
||||
|
||||
internal switch_chat_application_interface(IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = new HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
internal static HandleRef getCPtr(switch_chat_application_interface obj) {
|
||||
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
|
||||
~switch_chat_application_interface() {
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public virtual void Dispose() {
|
||||
lock(this) {
|
||||
if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
freeswitchPINVOKE.delete_switch_chat_application_interface(swigCPtr);
|
||||
}
|
||||
swigCPtr = new HandleRef(null, IntPtr.Zero);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
public string interface_name {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_chat_application_interface_interface_name_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
string ret = freeswitchPINVOKE.switch_chat_application_interface_interface_name_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t chat_application_function {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_chat_application_interface_chat_application_function_set(swigCPtr, SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t.getCPtr(value));
|
||||
}
|
||||
get {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_chat_application_interface_chat_application_function_get(swigCPtr);
|
||||
SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public string long_desc {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_chat_application_interface_long_desc_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
string ret = freeswitchPINVOKE.switch_chat_application_interface_long_desc_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public string short_desc {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_chat_application_interface_short_desc_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
string ret = freeswitchPINVOKE.switch_chat_application_interface_short_desc_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public string syntax {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_chat_application_interface_syntax_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
string ret = freeswitchPINVOKE.switch_chat_application_interface_syntax_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public uint flags {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_chat_application_interface_flags_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
uint ret = freeswitchPINVOKE.switch_chat_application_interface_flags_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_switch_thread_rwlock_t rwlock {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_chat_application_interface_rwlock_set(swigCPtr, SWIGTYPE_p_switch_thread_rwlock_t.getCPtr(value));
|
||||
}
|
||||
get {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_chat_application_interface_rwlock_get(swigCPtr);
|
||||
SWIGTYPE_p_switch_thread_rwlock_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_thread_rwlock_t(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public int refs {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_chat_application_interface_refs_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
int ret = freeswitchPINVOKE.switch_chat_application_interface_refs_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_switch_mutex_t reflock {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_chat_application_interface_reflock_set(swigCPtr, SWIGTYPE_p_switch_mutex_t.getCPtr(value));
|
||||
}
|
||||
get {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_chat_application_interface_reflock_get(swigCPtr);
|
||||
SWIGTYPE_p_switch_mutex_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_mutex_t(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public switch_loadable_module_interface parent {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_chat_application_interface_parent_set(swigCPtr, switch_loadable_module_interface.getCPtr(value));
|
||||
}
|
||||
get {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_chat_application_interface_parent_get(swigCPtr);
|
||||
switch_loadable_module_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_loadable_module_interface(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public switch_chat_application_interface next {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_chat_application_interface_next_set(swigCPtr, switch_chat_application_interface.getCPtr(value));
|
||||
}
|
||||
get {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_chat_application_interface_next_get(swigCPtr);
|
||||
switch_chat_application_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_chat_application_interface(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public switch_chat_application_interface() : this(freeswitchPINVOKE.new_switch_chat_application_interface(), true) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.35
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -22649,13 +23084,13 @@ public class switch_chat_interface : IDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
public SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t chat_send {
|
||||
public SWIGTYPE_p_f_p_switch_event__switch_status_t chat_send {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_chat_interface_chat_send_set(swigCPtr, SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t.getCPtr(value));
|
||||
freeswitchPINVOKE.switch_chat_interface_chat_send_set(swigCPtr, SWIGTYPE_p_f_p_switch_event__switch_status_t.getCPtr(value));
|
||||
}
|
||||
get {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_chat_interface_chat_send_get(swigCPtr);
|
||||
SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__switch_status_t(cPtr, false);
|
||||
SWIGTYPE_p_f_p_switch_event__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_event__switch_status_t(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -23777,7 +24212,8 @@ namespace FreeSWITCH.Native {
|
||||
SCF_AUTO_SCHEMAS = (1 << 13),
|
||||
SCF_MINIMAL = (1 << 14),
|
||||
SCF_USE_NAT_MAPPING = (1 << 15),
|
||||
SCF_CLEAR_SQL = (1 << 16)
|
||||
SCF_CLEAR_SQL = (1 << 16),
|
||||
SCF_THREADED_SYSTEM_EXEC = (1 << 17)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24438,6 +24874,23 @@ public class switch_dialplan_interface : IDisposable {
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
public enum switch_digit_action_target_t {
|
||||
DIGIT_TARGET_SELF,
|
||||
DIGIT_TARGET_PEER,
|
||||
DIGIT_TARGET_BOTH
|
||||
}
|
||||
|
||||
}
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.35
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -25343,7 +25796,8 @@ public class switch_event : IDisposable {
|
||||
namespace FreeSWITCH.Native {
|
||||
|
||||
public enum switch_event_flag_t {
|
||||
EF_UNIQ_HEADERS = (1 << 0)
|
||||
EF_UNIQ_HEADERS = (1 << 0),
|
||||
EF_NO_CHAT_EXEC = (1 << 1)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26480,7 +26934,8 @@ namespace FreeSWITCH.Native {
|
||||
SFF_PROXY_PACKET = (1 << 5),
|
||||
SFF_DYNAMIC = (1 << 6),
|
||||
SFF_ZRTP = (1 << 7),
|
||||
SFF_UDPTL_PACKET = (1 << 8)
|
||||
SFF_UDPTL_PACKET = (1 << 8),
|
||||
SFF_NOT_AUDIO = (1 << 9)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28468,6 +28923,17 @@ public class switch_loadable_module_interface : IDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
public switch_chat_application_interface chat_application_interface {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_loadable_module_interface_chat_application_interface_set(swigCPtr, switch_chat_application_interface.getCPtr(value));
|
||||
}
|
||||
get {
|
||||
IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_interface_chat_application_interface_get(swigCPtr);
|
||||
switch_chat_application_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_chat_application_interface(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public switch_api_interface api_interface {
|
||||
set {
|
||||
freeswitchPINVOKE.switch_loadable_module_interface_api_interface_set(swigCPtr, switch_api_interface.getCPtr(value));
|
||||
@@ -29005,7 +29471,8 @@ public enum switch_module_interface_name_t {
|
||||
SWITCH_SAY_INTERFACE,
|
||||
SWITCH_ASR_INTERFACE,
|
||||
SWITCH_MANAGEMENT_INTERFACE,
|
||||
SWITCH_LIMIT_INTERFACE
|
||||
SWITCH_LIMIT_INTERFACE,
|
||||
SWITCH_CHAT_APPLICATION_INTERFACE
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29263,7 +29730,7 @@ public enum switch_rtp_bug_flag_t {
|
||||
RTP_BUG_START_SEQ_AT_ZERO = (1 << 4),
|
||||
RTP_BUG_NEVER_SEND_MARKER = (1 << 5),
|
||||
RTP_BUG_IGNORE_DTMF_DURATION = (1 << 6),
|
||||
RTP_BUG_PAUSE_BETWEEN_DTMF = (1 << 7)
|
||||
RTP_BUG_ACCEPT_ANY_PACKETS = (1 << 7)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30301,7 +30768,8 @@ public enum switch_session_ctl_t {
|
||||
SCSC_VERBOSE_EVENTS,
|
||||
SCSC_SHUTDOWN_CHECK,
|
||||
SCSC_PAUSE_CHECK,
|
||||
SCSC_READY_CHECK
|
||||
SCSC_READY_CHECK,
|
||||
SCSC_THREADED_SYSTEM_EXEC
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,3 +5,5 @@ for %%X in (*.cs) do type %%X >> swig.csx
|
||||
@ECHO ON
|
||||
move swig.csx managed\swig.cs
|
||||
del *.cs
|
||||
\tools\dos2unix\bin\dos2unix managed\swig.cs
|
||||
\tools\dos2unix\bin\dos2unix freeswitch_wrap.cxx
|
||||
@@ -292,6 +292,8 @@ sub DESTROY {
|
||||
}
|
||||
}
|
||||
|
||||
*chat_execute = *freeswitchc::Event_chat_execute;
|
||||
*chat_send = *freeswitchc::Event_chat_send;
|
||||
*serialize = *freeswitchc::Event_serialize;
|
||||
*setPriority = *freeswitchc::Event_setPriority;
|
||||
*getHeader = *freeswitchc::Event_getHeader;
|
||||
|
||||
@@ -3679,6 +3679,99 @@ XS(_wrap_delete_Event) {
|
||||
}
|
||||
|
||||
|
||||
XS(_wrap_Event_chat_execute) {
|
||||
{
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) NULL ;
|
||||
int result;
|
||||
void *argp1 = 0 ;
|
||||
int res1 = 0 ;
|
||||
int res2 ;
|
||||
char *buf2 = 0 ;
|
||||
int alloc2 = 0 ;
|
||||
int res3 ;
|
||||
char *buf3 = 0 ;
|
||||
int alloc3 = 0 ;
|
||||
int argvi = 0;
|
||||
dXSARGS;
|
||||
|
||||
if ((items < 2) || (items > 3)) {
|
||||
SWIG_croak("Usage: Event_chat_execute(self,app,data);");
|
||||
}
|
||||
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Event, 0 | 0 );
|
||||
if (!SWIG_IsOK(res1)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Event_chat_execute" "', argument " "1"" of type '" "Event *""'");
|
||||
}
|
||||
arg1 = reinterpret_cast< Event * >(argp1);
|
||||
res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
|
||||
if (!SWIG_IsOK(res2)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Event_chat_execute" "', argument " "2"" of type '" "char const *""'");
|
||||
}
|
||||
arg2 = reinterpret_cast< char * >(buf2);
|
||||
if (items > 2) {
|
||||
res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3);
|
||||
if (!SWIG_IsOK(res3)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Event_chat_execute" "', argument " "3"" of type '" "char const *""'");
|
||||
}
|
||||
arg3 = reinterpret_cast< char * >(buf3);
|
||||
}
|
||||
result = (int)(arg1)->chat_execute((char const *)arg2,(char const *)arg3);
|
||||
ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
|
||||
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
|
||||
XSRETURN(argvi);
|
||||
fail:
|
||||
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
|
||||
SWIG_croak_null();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XS(_wrap_Event_chat_send) {
|
||||
{
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
char *arg2 = (char *) NULL ;
|
||||
int result;
|
||||
void *argp1 = 0 ;
|
||||
int res1 = 0 ;
|
||||
int res2 ;
|
||||
char *buf2 = 0 ;
|
||||
int alloc2 = 0 ;
|
||||
int argvi = 0;
|
||||
dXSARGS;
|
||||
|
||||
if ((items < 1) || (items > 2)) {
|
||||
SWIG_croak("Usage: Event_chat_send(self,dest_proto);");
|
||||
}
|
||||
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Event, 0 | 0 );
|
||||
if (!SWIG_IsOK(res1)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Event_chat_send" "', argument " "1"" of type '" "Event *""'");
|
||||
}
|
||||
arg1 = reinterpret_cast< Event * >(argp1);
|
||||
if (items > 1) {
|
||||
res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
|
||||
if (!SWIG_IsOK(res2)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Event_chat_send" "', argument " "2"" of type '" "char const *""'");
|
||||
}
|
||||
arg2 = reinterpret_cast< char * >(buf2);
|
||||
}
|
||||
result = (int)(arg1)->chat_send((char const *)arg2);
|
||||
ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
|
||||
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
XSRETURN(argvi);
|
||||
fail:
|
||||
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
SWIG_croak_null();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XS(_wrap_Event_serialize) {
|
||||
{
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
@@ -9492,6 +9585,8 @@ static swig_command_info swig_commands[] = {
|
||||
{"freeswitchc::Event_mine_get", _wrap_Event_mine_get},
|
||||
{"freeswitchc::new_Event", _wrap_new_Event},
|
||||
{"freeswitchc::delete_Event", _wrap_delete_Event},
|
||||
{"freeswitchc::Event_chat_execute", _wrap_Event_chat_execute},
|
||||
{"freeswitchc::Event_chat_send", _wrap_Event_chat_send},
|
||||
{"freeswitchc::Event_serialize", _wrap_Event_serialize},
|
||||
{"freeswitchc::Event_setPriority", _wrap_Event_setPriority},
|
||||
{"freeswitchc::Event_getHeader", _wrap_Event_getHeader},
|
||||
|
||||
@@ -175,6 +175,8 @@ class Event(_object):
|
||||
except: self.this = this
|
||||
__swig_destroy__ = _freeswitch.delete_Event
|
||||
__del__ = lambda self : None;
|
||||
def chat_execute(*args): return _freeswitch.Event_chat_execute(*args)
|
||||
def chat_send(*args): return _freeswitch.Event_chat_send(*args)
|
||||
def serialize(*args): return _freeswitch.Event_serialize(*args)
|
||||
def setPriority(*args): return _freeswitch.Event_setPriority(*args)
|
||||
def getHeader(*args): return _freeswitch.Event_getHeader(*args)
|
||||
|
||||
@@ -4541,6 +4541,90 @@ fail:
|
||||
}
|
||||
|
||||
|
||||
SWIGINTERN PyObject *_wrap_Event_chat_execute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||
PyObject *resultobj = 0;
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) NULL ;
|
||||
int result;
|
||||
void *argp1 = 0 ;
|
||||
int res1 = 0 ;
|
||||
int res2 ;
|
||||
char *buf2 = 0 ;
|
||||
int alloc2 = 0 ;
|
||||
int res3 ;
|
||||
char *buf3 = 0 ;
|
||||
int alloc3 = 0 ;
|
||||
PyObject * obj0 = 0 ;
|
||||
PyObject * obj1 = 0 ;
|
||||
PyObject * obj2 = 0 ;
|
||||
|
||||
if (!PyArg_ParseTuple(args,(char *)"OO|O:Event_chat_execute",&obj0,&obj1,&obj2)) SWIG_fail;
|
||||
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Event, 0 | 0 );
|
||||
if (!SWIG_IsOK(res1)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Event_chat_execute" "', argument " "1"" of type '" "Event *""'");
|
||||
}
|
||||
arg1 = reinterpret_cast< Event * >(argp1);
|
||||
res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
|
||||
if (!SWIG_IsOK(res2)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Event_chat_execute" "', argument " "2"" of type '" "char const *""'");
|
||||
}
|
||||
arg2 = reinterpret_cast< char * >(buf2);
|
||||
if (obj2) {
|
||||
res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
|
||||
if (!SWIG_IsOK(res3)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Event_chat_execute" "', argument " "3"" of type '" "char const *""'");
|
||||
}
|
||||
arg3 = reinterpret_cast< char * >(buf3);
|
||||
}
|
||||
result = (int)(arg1)->chat_execute((char const *)arg2,(char const *)arg3);
|
||||
resultobj = SWIG_From_int(static_cast< int >(result));
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
|
||||
return resultobj;
|
||||
fail:
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
SWIGINTERN PyObject *_wrap_Event_chat_send(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||
PyObject *resultobj = 0;
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
char *arg2 = (char *) NULL ;
|
||||
int result;
|
||||
void *argp1 = 0 ;
|
||||
int res1 = 0 ;
|
||||
int res2 ;
|
||||
char *buf2 = 0 ;
|
||||
int alloc2 = 0 ;
|
||||
PyObject * obj0 = 0 ;
|
||||
PyObject * obj1 = 0 ;
|
||||
|
||||
if (!PyArg_ParseTuple(args,(char *)"O|O:Event_chat_send",&obj0,&obj1)) SWIG_fail;
|
||||
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Event, 0 | 0 );
|
||||
if (!SWIG_IsOK(res1)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Event_chat_send" "', argument " "1"" of type '" "Event *""'");
|
||||
}
|
||||
arg1 = reinterpret_cast< Event * >(argp1);
|
||||
if (obj1) {
|
||||
res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
|
||||
if (!SWIG_IsOK(res2)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Event_chat_send" "', argument " "2"" of type '" "char const *""'");
|
||||
}
|
||||
arg2 = reinterpret_cast< char * >(buf2);
|
||||
}
|
||||
result = (int)(arg1)->chat_send((char const *)arg2);
|
||||
resultobj = SWIG_From_int(static_cast< int >(result));
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
return resultobj;
|
||||
fail:
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
SWIGINTERN PyObject *_wrap_Event_serialize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||
PyObject *resultobj = 0;
|
||||
Event *arg1 = (Event *) 0 ;
|
||||
@@ -9042,6 +9126,8 @@ static PyMethodDef SwigMethods[] = {
|
||||
{ (char *)"Event_mine_get", _wrap_Event_mine_get, METH_VARARGS, NULL},
|
||||
{ (char *)"new_Event", _wrap_new_Event, METH_VARARGS, NULL},
|
||||
{ (char *)"delete_Event", _wrap_delete_Event, METH_VARARGS, NULL},
|
||||
{ (char *)"Event_chat_execute", _wrap_Event_chat_execute, METH_VARARGS, NULL},
|
||||
{ (char *)"Event_chat_send", _wrap_Event_chat_send, METH_VARARGS, NULL},
|
||||
{ (char *)"Event_serialize", _wrap_Event_serialize, METH_VARARGS, NULL},
|
||||
{ (char *)"Event_setPriority", _wrap_Event_setPriority, METH_VARARGS, NULL},
|
||||
{ (char *)"Event_getHeader", _wrap_Event_getHeader, METH_VARARGS, NULL},
|
||||
|
||||
@@ -22,35 +22,42 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_CC_C99
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
# pkgconfig
|
||||
AC_PATH_PROG([PKG_CONFIG], [pkg-config], ["no"])
|
||||
if test "x${PKG_CONFIG}" = "xno"
|
||||
then
|
||||
AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed in your PATH])
|
||||
fi
|
||||
AS_IF([test "x${PKG_CONFIG}" = "xno"],
|
||||
[AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed in your PATH])]
|
||||
)
|
||||
PKG_PROG_PKG_CONFIG
|
||||
|
||||
# Checks for cflags
|
||||
|
||||
##
|
||||
## Checks for cflags
|
||||
##
|
||||
AC_MSG_RESULT([${as_nl}<<>> Compiler vendor and features])
|
||||
|
||||
AX_COMPILER_VENDOR
|
||||
|
||||
AM_CONDITIONAL([CC_VENDOR_GNU], [test "x${ax_cv_c_compiler_vendor}" = "xgnu"])
|
||||
AM_CONDITIONAL([CC_VENDOR_SUN], [test "x${ax_cv_c_compiler_vendor}" = "xsun"])
|
||||
|
||||
|
||||
##
|
||||
## Compiler vendor and flag checks
|
||||
##
|
||||
HAVE_VISIBILITY="no"
|
||||
|
||||
AC_ARG_ENABLE([visibility],
|
||||
[AS_HELP_STRING([--disable-visibility], [Disable symbol visibility support (default: enabled, if available)])],
|
||||
[case "${enableval}" in
|
||||
yes) enable_visibility="yes" ;;
|
||||
no) enable_visibility="no" ;;
|
||||
*) AC_MSG_ERROR([Invalid value ${enableval} for parameter --disable-visibility]) ;;
|
||||
yes|no) enable_visibility="${enableval}" ;;
|
||||
*) AC_MSG_ERROR([Invalid value ${enableval} for parameter --disable-visibility]) ;;
|
||||
esac],
|
||||
[enable_visibility="yes"]
|
||||
)
|
||||
|
||||
AX_COMPILER_VENDOR
|
||||
|
||||
case "${ax_cv_c_compiler_vendor}" in
|
||||
gnu)
|
||||
AC_MSG_CHECKING([whether the compiler supports -fvisibility=hidden])
|
||||
@@ -63,36 +70,16 @@ gnu)
|
||||
[;]
|
||||
)],
|
||||
|
||||
[AC_MSG_RESULT([yes])
|
||||
AC_DEFINE([HAVE_VISIBILITY],[1],[GCC visibility support])
|
||||
HAVE_VISIBILITY="yes"],
|
||||
|
||||
[AC_MSG_RESULT([no])
|
||||
HAVE_VISIBILITY="no"]
|
||||
[HAVE_VISIBILITY="yes"
|
||||
AC_DEFINE([HAVE_VISIBILITY], [1], [Symbol visibility support])
|
||||
AC_SUBST([VISIBILITY_CFLAGS], [-fvisibility=hidden])
|
||||
AC_SUBST([VISIBILITY_CXXFLAGS], [-fvisibility=hidden])],
|
||||
[HAVE_VISIBILITY="no"]
|
||||
)
|
||||
AC_MSG_RESULT([${HAVE_VISIBILITY}])
|
||||
CFLAGS="${save_CFLAGS}"],
|
||||
[AC_MSG_RESULT([disabled by user])]
|
||||
)
|
||||
|
||||
AS_IF([test "x${HAVE_VISIBILITY}" != "xno"],
|
||||
[save_CFLAGS="${CFLAGS}"
|
||||
CFLAGS="${CFLAGS} -fvisibility-inlines-hidden"
|
||||
AC_MSG_CHECKING([whether the compiler supports -fvisibility-inlines-hidden])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[;], [;]
|
||||
)],
|
||||
|
||||
[AC_MSG_RESULT([yes])
|
||||
HAVE_VISIBILITY_INLINES_HIDDEN="yes"],
|
||||
|
||||
[AC_MSG_RESULT([no])
|
||||
HAVE_VISIBILITY_INLINES_HIDDEN="no"]
|
||||
)
|
||||
CFLAGS="${save_CFLAGS}"],
|
||||
[:]
|
||||
)
|
||||
AC_DEFINE([COMPILER_GCC], [1], [Compiler is GCC])
|
||||
;;
|
||||
sun)
|
||||
AC_MSG_CHECKING([whether the compiler supports -xldscope=hidden])
|
||||
@@ -105,28 +92,24 @@ sun)
|
||||
[;]
|
||||
)],
|
||||
|
||||
[AC_MSG_RESULT([yes])
|
||||
AC_DEFINE([HAVE_VISIBILITY],[1],[SUNCC visibility support])
|
||||
HAVE_VISIBILITY="yes"],
|
||||
|
||||
[AC_MSG_RESULT([no])
|
||||
HAVE_VISIBILITY="no"]
|
||||
[HAVE_VISIBILITY="yes"
|
||||
AC_DEFINE([HAVE_VISIBILITY], [1], [Symbol visibility support])
|
||||
AC_SUBST([VISIBILITY_CFLAGS], [-xldscope=hidden])
|
||||
AC_SUBST([VISIBILITY_CXXFLAGS], [-xldscope=hidden])],
|
||||
[HAVE_VISIBILITY="no"]
|
||||
)
|
||||
AC_MSG_RESULT([${HAVE_VISIBILITY}])
|
||||
CFLAGS="${save_CFLAGS}"],
|
||||
[AC_MSG_RESULT([disabled by user])]
|
||||
)
|
||||
AC_DEFINE([COMPILER_SUNCC], [1], [Compiler is SunCC])
|
||||
;;
|
||||
*)
|
||||
AC_MSG_WARN([No visibility checks for this compiler defined])
|
||||
;;
|
||||
esac
|
||||
|
||||
AM_CONDITIONAL([COMPILER_GCC], [test "x${ax_cv_c_compiler_vendor}" = "xgnu"])
|
||||
AM_CONDITIONAL([COMPILER_SUNCC], [test "x${ax_cv_c_compiler_vendor}" = "xsun"])
|
||||
AM_CONDITIONAL([CC_HAS_VISIBILITY], [test "x${HAVE_VISIBILITY}" = "xyes"])
|
||||
|
||||
AM_CONDITIONAL([HAVE_VISIBILITY], [test "x${HAVE_VISIBILITY}" = "xyes"])
|
||||
AM_CONDITIONAL([HAVE_VISIBILITY_INLINES_HIDDEN], [test "x${HAVE_VISIBILITY_INLINES_HIDDEN}" = "xyes"])
|
||||
|
||||
##
|
||||
## pkgconfig based freeswitch detection code
|
||||
@@ -210,6 +193,7 @@ PKG_CHECK_MODULES([freeswitch], [freeswitch],
|
||||
[AC_MSG_ERROR([FreeSWITCH not found])]
|
||||
)
|
||||
|
||||
|
||||
##
|
||||
## Add your other dependency checks here
|
||||
##
|
||||
@@ -221,6 +205,10 @@ AC_MSG_RESULT([${as_nl}<<>> Other dependencies])
|
||||
|
||||
# Checks for library functions.
|
||||
|
||||
|
||||
##
|
||||
## Done, create output files and print summary
|
||||
##
|
||||
AC_MSG_RESULT([${as_nl}<<>> Create output files])
|
||||
AC_CONFIG_FILES([Makefile src/Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
@@ -10,32 +10,26 @@ AM_CPPFLAGS= -I. -I$(includedir)
|
||||
AM_LDFLAGS = -L. -L$(libdir) -avoid-version -module -no-undefined -shared
|
||||
|
||||
###
|
||||
# GCC specific flags
|
||||
# GCC (and compatible) specific flags
|
||||
#
|
||||
if COMPILER_GCC
|
||||
if CC_VENDOR_GNU
|
||||
AM_CFLAGS += -Wall
|
||||
# symbol visibility support
|
||||
if HAVE_VISIBILITY
|
||||
AM_CFLAGS += -fvisibility=hidden
|
||||
AM_CXXFLAGS+= -fvisibility=hidden
|
||||
AM_CPPFLAGS+= -DSWITCH_API_VISIBILITY=1
|
||||
endif
|
||||
if HAVE_VISIBILITY_INLINES_HIDDEN
|
||||
AM_CXXFLAGS += -fvisibility-inlines-hidden
|
||||
endif
|
||||
endif
|
||||
|
||||
###
|
||||
# SunCC specific flags
|
||||
#
|
||||
if COMPILER_SUNCC
|
||||
if CC_VENDOR_SUN
|
||||
AM_CFLAGS +=
|
||||
# symbol visibility support
|
||||
if HAVE_VISIBILITY
|
||||
AM_CFLAGS += -xldscope=hidden
|
||||
AM_CXXFLAGS += -xldscope=hidden
|
||||
AM_CPPFLAGS += -DSWITCH_API_VISIBILITY=1
|
||||
endif
|
||||
|
||||
###
|
||||
# symbol visibility support
|
||||
#
|
||||
if CC_HAS_VISIBILITY
|
||||
AM_CFLAGS += $(VISIBILITY_CFLAGS)
|
||||
AM_CXXFLAGS += $(VISIBILITY_CXXFLAGS)
|
||||
AM_CPPFLAGS += -DSWITCH_API_VISIBILITY=1
|
||||
endif
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user