2006-03-03 16:57:21 +00:00
|
|
|
#include <switch.h>
|
2006-03-30 23:02:50 +00:00
|
|
|
#ifdef __ICC
|
|
|
|
#pragma warning (disable:1418)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-03-03 16:57:21 +00:00
|
|
|
|
2006-03-05 21:22:41 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include <perlibs.h>
|
|
|
|
#pragma comment(lib, PERL_LIB)
|
|
|
|
#endif
|
2006-03-05 20:45:40 +00:00
|
|
|
|
|
|
|
void fs_core_set_globals(void)
|
|
|
|
{
|
|
|
|
switch_core_set_globals();
|
|
|
|
}
|
|
|
|
|
|
|
|
int fs_core_init(char *path)
|
|
|
|
{
|
2006-04-29 23:43:28 +00:00
|
|
|
switch_status_t status;
|
2006-06-06 16:22:08 +00:00
|
|
|
const char *err = NULL;
|
2006-03-05 20:45:40 +00:00
|
|
|
|
|
|
|
if (switch_strlen_zero(path)) {
|
|
|
|
path = NULL;
|
|
|
|
}
|
|
|
|
|
2006-06-06 16:22:08 +00:00
|
|
|
status = switch_core_init(path, &err);
|
2006-03-05 20:45:40 +00:00
|
|
|
|
|
|
|
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2006-03-05 21:19:44 +00:00
|
|
|
int fs_core_destroy(void)
|
|
|
|
{
|
2006-04-29 23:43:28 +00:00
|
|
|
switch_status_t status;
|
2006-03-05 21:19:44 +00:00
|
|
|
|
|
|
|
status = switch_core_destroy();
|
|
|
|
|
|
|
|
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2006-03-05 20:45:40 +00:00
|
|
|
int fs_loadable_module_init(void)
|
|
|
|
{
|
|
|
|
return switch_loadable_module_init() == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2006-03-05 21:19:44 +00:00
|
|
|
int fs_loadable_module_shutdown(void)
|
|
|
|
{
|
|
|
|
switch_loadable_module_shutdown();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int fs_console_loop(void)
|
2006-03-05 20:45:40 +00:00
|
|
|
{
|
|
|
|
switch_console_loop();
|
2006-03-05 21:19:44 +00:00
|
|
|
return 0;
|
2006-03-05 20:45:40 +00:00
|
|
|
}
|
|
|
|
|
2006-03-03 16:57:21 +00:00
|
|
|
void fs_console_log(char *msg)
|
|
|
|
{
|
2006-04-11 21:13:44 +00:00
|
|
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, msg);
|
2006-03-03 16:57:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void fs_console_clean(char *msg)
|
|
|
|
{
|
2006-04-11 21:13:44 +00:00
|
|
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, msg);
|
2006-03-03 16:57:21 +00:00
|
|
|
}
|
|
|
|
|
2006-04-29 06:05:03 +00:00
|
|
|
switch_core_session_t *fs_core_session_locate(char *uuid)
|
2006-03-03 16:57:21 +00:00
|
|
|
{
|
|
|
|
return switch_core_session_locate(uuid);
|
|
|
|
}
|
|
|
|
|
2006-04-29 06:05:03 +00:00
|
|
|
void fs_channel_answer(switch_core_session_t *session)
|
2006-03-03 16:57:21 +00:00
|
|
|
{
|
2006-04-29 06:05:03 +00:00
|
|
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
2006-03-03 16:57:21 +00:00
|
|
|
switch_channel_answer(channel);
|
|
|
|
}
|
|
|
|
|
2006-04-29 06:05:03 +00:00
|
|
|
void fs_channel_pre_answer(switch_core_session_t *session)
|
2006-03-03 16:57:21 +00:00
|
|
|
{
|
2006-04-29 06:05:03 +00:00
|
|
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
2006-03-03 16:57:21 +00:00
|
|
|
switch_channel_pre_answer(channel);
|
|
|
|
}
|
|
|
|
|
2006-04-29 06:05:03 +00:00
|
|
|
void fs_channel_hangup(switch_core_session_t *session)
|
2006-03-03 16:57:21 +00:00
|
|
|
{
|
2006-04-29 06:05:03 +00:00
|
|
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
2006-04-22 03:05:25 +00:00
|
|
|
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
2006-03-03 16:57:21 +00:00
|
|
|
}
|
|
|
|
|
2006-04-29 06:05:03 +00:00
|
|
|
void fs_channel_set_variable(switch_core_session_t *session, char *var, char *val)
|
2006-03-03 16:57:21 +00:00
|
|
|
{
|
2006-04-29 06:05:03 +00:00
|
|
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
2006-03-03 16:57:21 +00:00
|
|
|
switch_channel_set_variable(channel, var, val);
|
|
|
|
}
|
|
|
|
|
2006-04-29 06:05:03 +00:00
|
|
|
void fs_channel_get_variable(switch_core_session_t *session, char *var)
|
2006-03-03 16:57:21 +00:00
|
|
|
{
|
2006-04-29 06:05:03 +00:00
|
|
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
2006-03-03 16:57:21 +00:00
|
|
|
switch_channel_get_variable(channel, var);
|
|
|
|
}
|
|
|
|
|
2006-04-29 06:05:03 +00:00
|
|
|
void fs_channel_set_state(switch_core_session_t *session, char *state)
|
2006-03-03 16:57:21 +00:00
|
|
|
{
|
2006-04-29 06:05:03 +00:00
|
|
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
2006-04-29 23:43:28 +00:00
|
|
|
switch_channel_state_t fs_state = switch_channel_get_state(channel);
|
2006-03-03 16:57:21 +00:00
|
|
|
|
|
|
|
if (!strcmp(state, "EXECUTE")) {
|
|
|
|
fs_state = CS_EXECUTE;
|
|
|
|
} else if (!strcmp(state, "TRANSMIT")) {
|
|
|
|
fs_state = CS_TRANSMIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch_channel_set_state(channel, fs_state);
|
|
|
|
}
|
|
|
|
|
2006-04-29 06:05:03 +00:00
|
|
|
int fs_ivr_play_file(switch_core_session_t *session, char *file, char *timer_name)
|
2006-03-03 16:57:21 +00:00
|
|
|
{
|
2006-04-29 23:43:28 +00:00
|
|
|
switch_status_t status;
|
2006-03-30 23:02:50 +00:00
|
|
|
if (switch_strlen_zero(timer_name)) {
|
|
|
|
timer_name = NULL;
|
|
|
|
}
|
|
|
|
|
2006-03-31 16:10:00 +00:00
|
|
|
status = switch_ivr_play_file(session, NULL, file, timer_name, NULL, NULL, 0);
|
2006-03-03 16:57:21 +00:00
|
|
|
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
|
|
|
}
|
|
|
|
|