Initial Release of Ruby
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2637 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
8d63c12387
commit
5e0ed731e4
|
@ -0,0 +1,43 @@
|
|||
LCFLAGS=-fPIC -DZTS -DPTHREADS
|
||||
CFLAGS += -fPIC -I../../../../libs/ruby-1.8.5/
|
||||
RBMOD=freeswitch
|
||||
LDFLAGS=-lruby-static -L$(PREFIX)/lib/
|
||||
|
||||
all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(RBMOD).$(DYNAMIC_LIB_EXTEN)
|
||||
|
||||
depends:
|
||||
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install ruby-1.8.5.tar.gz --prefix=$(PREFIX)
|
||||
cp -f config.h ../../../../libs/ruby-1.8.5/
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(LCFLAGS) $(CFLAGS) -c $< -o $@
|
||||
|
||||
mod_ruby.c:
|
||||
$(CC) $(LCFLAGS) $(CFLAGS) -c mod_ruby.c -o mod_ruby.o
|
||||
|
||||
reswig:
|
||||
rm -f switch_swig_wrap.c config.m4 CREDITS *${RBMOD}*
|
||||
swig -lswitch_swig.i -ignoremissing -DMULTIPLICITY -ruby -module $(RBMOD) switch_swig.c
|
||||
patch -p0 -i fix.diff
|
||||
|
||||
switch_swig_wrap.o: switch_swig_wrap.c Makefile
|
||||
$(CC) -w $(CFLAGS) -c $< -o $@
|
||||
|
||||
switch_swig.o: switch_swig.c Makefile
|
||||
$(CC) -w $(CFLAGS) -c $< -o $@
|
||||
|
||||
|
||||
$(RBMOD).$(DYNAMIC_LIB_EXTEN): $(MODNAME).$(DYNAMIC_LIB_EXTEN) switch_swig_wrap.o switch_swig.o Makefile
|
||||
$(CC) $(SOLINK) -o rb_$(RBMOD).$(DYNAMIC_LIB_EXTEN) switch_swig_wrap.o switch_swig.o $(LDFLAGS)
|
||||
|
||||
|
||||
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c $(MODNAME).o $(OBJS) Makefile
|
||||
$(CC) $(LCFLAGS) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~
|
||||
|
||||
install:
|
||||
#cp -f rb_$(RBMOD).$(DYNAMIC_LIB_EXTEN) $(MDIR)
|
||||
cp -f $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(PREFIX)/mod
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
Sorry guys.. Due to licensing its not being populated.
|
||||
When the license issue is fixed then I will populate it.
|
||||
Well here is what I know. As of now more or less the license
|
||||
maybe compatible. I am releasing with the clause that if the
|
||||
author of Ruby comes back and doesnt offer a license to us I
|
||||
will be pulling it back from the tree. Im sorry but licensing
|
||||
is licensing.
|
||||
|
||||
--Brian Fertig
|
||||
mod_ruby - Developer/Maintainer
|
||||
|
|
|
@ -0,0 +1,175 @@
|
|||
//#define PACKAGE_NAME ""
|
||||
//#define PACKAGE_TARNAME ""
|
||||
//#define PACKAGE_VERSION ""
|
||||
//#define PACKAGE_STRING ""
|
||||
//#define PACKAGE_BUGREPORT ""
|
||||
#define USE_BUILTIN_FRAME_ADDRESS 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_MEMORY_H 1
|
||||
#define HAVE_STRINGS_H 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#define HAVE_LONG_LONG 1
|
||||
#define HAVE_OFF_T 1
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_LONG 4
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#define SIZEOF___INT64 0
|
||||
#define SIZEOF_OFF_T 8
|
||||
#define SIZEOF_VOIDP 4
|
||||
#define SIZEOF_FLOAT 4
|
||||
#define SIZEOF_DOUBLE 8
|
||||
#define SIZEOF_TIME_T 4
|
||||
#define rb_pid_t pid_t
|
||||
#define rb_gid_t gid_t
|
||||
#define rb_uid_t uid_t
|
||||
#define HAVE_PROTOTYPES 1
|
||||
#define TOKEN_PASTE(x,y) x##y
|
||||
#define HAVE_STDARG_PROTOTYPES 1
|
||||
#define NORETURN(x) x __attribute__ ((noreturn))
|
||||
#define HAVE_DECL_SYS_NERR 1
|
||||
#define HAVE_LIBCRYPT 1
|
||||
#define HAVE_LIBDL 1
|
||||
#define HAVE_DIRENT_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_LIMITS_H 1
|
||||
#define HAVE_SYS_FILE_H 1
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
#define HAVE_SYS_SYSCALL_H 1
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_SYS_FCNTL_H 1
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
#define HAVE_SYS_TIMES_H 1
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
#define HAVE_SYSCALL_H 1
|
||||
#define HAVE_PWD_H 1
|
||||
#define HAVE_GRP_H 1
|
||||
#define HAVE_A_OUT_H 1
|
||||
#define HAVE_UTIME_H 1
|
||||
#define HAVE_MEMORY_H 1
|
||||
#define HAVE_SYS_RESOURCE_H 1
|
||||
#define HAVE_NETINET_IN_SYSTM_H 1
|
||||
#define HAVE_FLOAT_H 1
|
||||
#define HAVE_PTHREAD_H 1
|
||||
#define HAVE_UCONTEXT_H 1
|
||||
#define SIZEOF_RLIM_T 8
|
||||
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
|
||||
#define HAVE_ST_BLKSIZE 1
|
||||
#define HAVE_STRUCT_STAT_ST_BLOCKS 1
|
||||
#define HAVE_ST_BLOCKS 1
|
||||
#define HAVE_STRUCT_STAT_ST_RDEV 1
|
||||
#define HAVE_ST_RDEV 1
|
||||
#define GETGROUPS_T gid_t
|
||||
#define RETSIGTYPE void
|
||||
#define HAVE_ALLOCA_H 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define _LARGEFILE_SOURCE 1
|
||||
#define HAVE_FSEEKO 1
|
||||
#define HAVE_FTELLO 1
|
||||
#define HAVE_DUP2 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_STRCASECMP 1
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#define HAVE_STRERROR 1
|
||||
#define HAVE_STRFTIME 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOUL 1
|
||||
#define HAVE_CRYPT 1
|
||||
#define HAVE_FLOCK 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
#define HAVE_ISNAN 1
|
||||
#define HAVE_FINITE 1
|
||||
#define HAVE_ISINF 1
|
||||
#define HAVE_HYPOT 1
|
||||
#define HAVE_ACOSH 1
|
||||
#define HAVE_ERF 1
|
||||
#define HAVE_FMOD 1
|
||||
#define HAVE_KILLPG 1
|
||||
#define HAVE_WAIT4 1
|
||||
#define HAVE_WAITPID 1
|
||||
#define HAVE_SYSCALL 1
|
||||
#define HAVE_CHROOT 1
|
||||
#define HAVE_FSYNC 1
|
||||
#define HAVE_GETCWD 1
|
||||
#define HAVE_TRUNCATE 1
|
||||
#define HAVE_TIMES 1
|
||||
#define HAVE_UTIMES 1
|
||||
#define HAVE_FCNTL 1
|
||||
#define HAVE_LOCKF 1
|
||||
#define HAVE_LSTAT 1
|
||||
#define HAVE_SYMLINK 1
|
||||
#define HAVE_LINK 1
|
||||
#define HAVE_READLINK 1
|
||||
#define HAVE_SETITIMER 1
|
||||
#define HAVE_SETEUID 1
|
||||
#define HAVE_SETREUID 1
|
||||
#define HAVE_SETRESUID 1
|
||||
#define HAVE_SETEGID 1
|
||||
#define HAVE_SETREGID 1
|
||||
#define HAVE_SETRESGID 1
|
||||
#define HAVE_PAUSE 1
|
||||
#define HAVE_LCHOWN 1
|
||||
#define HAVE_GETPGRP 1
|
||||
#define HAVE_SETPGRP 1
|
||||
#define HAVE_GETPGID 1
|
||||
#define HAVE_SETPGID 1
|
||||
#define HAVE_INITGROUPS 1
|
||||
#define HAVE_GETGROUPS 1
|
||||
#define HAVE_SETGROUPS 1
|
||||
#define HAVE_GETPRIORITY 1
|
||||
#define HAVE_GETRLIMIT 1
|
||||
#define HAVE_SETRLIMIT 1
|
||||
#define HAVE_SYSCONF 1
|
||||
#define HAVE_DLOPEN 1
|
||||
#define HAVE_SIGPROCMASK 1
|
||||
#define HAVE_SIGACTION 1
|
||||
#define HAVE__SETJMP 1
|
||||
#define HAVE_SETSID 1
|
||||
#define HAVE_TELLDIR 1
|
||||
#define HAVE_SEEKDIR 1
|
||||
#define HAVE_FCHMOD 1
|
||||
#define HAVE_MKTIME 1
|
||||
#define HAVE_TIMEGM 1
|
||||
#define HAVE_COSH 1
|
||||
#define HAVE_SINH 1
|
||||
#define HAVE_TANH 1
|
||||
#define HAVE_SETUID 1
|
||||
#define HAVE_SETGID 1
|
||||
#define HAVE_SETENV 1
|
||||
#define HAVE_UNSETENV 1
|
||||
#define HAVE_STRUCT_TM_TM_ZONE 1
|
||||
#define HAVE_TM_ZONE 1
|
||||
#define HAVE_STRUCT_TM_TM_GMTOFF 1
|
||||
#define HAVE_DAYLIGHT 1
|
||||
#define NEGATIVE_TIME_T 1
|
||||
#define POSIX_SIGNAL 1
|
||||
#define GETPGRP_VOID 1
|
||||
#define SETPGRP_VOID 1
|
||||
#define RSHIFT(x,y) ((x)>>(int)y)
|
||||
#define FILE_READPTR _IO_read_ptr
|
||||
#define FILE_READEND _IO_read_end
|
||||
#define HUGE_ST_INO 1
|
||||
#define HAVE__SC_CLK_TCK 1
|
||||
#define STACK_GROW_DIRECTION -1
|
||||
#define DEFAULT_KCODE KCODE_NONE
|
||||
#define USE_ELF 1
|
||||
#define DLEXT ".so"
|
||||
#define RUBY_LIB "/usr/local/lib/ruby/1.8"
|
||||
#define RUBY_SITE_LIB "/usr/local/lib/ruby/site_ruby"
|
||||
#define RUBY_SITE_LIB2 "/usr/local/lib/ruby/site_ruby/1.8"
|
||||
#define RUBY_PLATFORM "i686-linux"
|
||||
#define RUBY_ARCHLIB "/usr/local/lib/ruby/1.8/i686-linux"
|
||||
#define RUBY_SITE_ARCHLIB "/usr/local/lib/ruby/site_ruby/1.8/i686-linux"
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
|
||||
*
|
||||
* 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 <anthmct@yahoo.com>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Brian Fertig <brian.fertig@convergencetek.com>
|
||||
*
|
||||
*
|
||||
* mod_ruby.c -- ruby Module
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _REENTRANT
|
||||
#define _REENTRANT
|
||||
#endif
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
#include <ruby.h>
|
||||
|
||||
|
||||
const char modname[] = "mod_ruby";
|
||||
|
||||
|
||||
|
||||
static void ruby_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
char *uuid = switch_core_session_get_uuid(session);
|
||||
uint32_t ulen = strlen(uuid);
|
||||
uint32_t len = strlen((char *) data) + ulen + 2;
|
||||
char *mydata = switch_core_session_alloc(session, len);
|
||||
int argc, state;
|
||||
char *argv[5];
|
||||
char ruby_code[1024];
|
||||
//void*** tsrm_ls = NULL;
|
||||
|
||||
snprintf(mydata, len, "%s %s", uuid, data);
|
||||
|
||||
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
sprintf(ruby_code, "$uuid=\"%s\"; include(\"%s\");\n", argv[0], argv[1]);
|
||||
|
||||
ruby_init();
|
||||
|
||||
ruby_init_loadpath();
|
||||
|
||||
ruby_script("embedded");
|
||||
rb_load_file(data);
|
||||
rb_p(rb_eval_string_protect(argv[1], &state));
|
||||
if (state) {
|
||||
VALUE error = rb_inspect(rb_gv_get("$!"));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Your code is broken. \nHere is the error I found: %s\n",error);
|
||||
}
|
||||
state = ruby_exec();
|
||||
state = ruby_cleanup(state);
|
||||
ruby_finalize();
|
||||
|
||||
|
||||
}
|
||||
|
||||
static const switch_application_interface_t ruby_application_interface = {
|
||||
/*.interface_name */ "ruby",
|
||||
/*.application_function */ ruby_function
|
||||
};
|
||||
|
||||
static switch_loadable_module_interface_t ruby_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ NULL,
|
||||
/*.application_interface */ &ruby_application_interface,
|
||||
/*.api_interface */ NULL,
|
||||
/*.file_interface */ NULL,
|
||||
/*.speech_interface */ NULL,
|
||||
/*.directory_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &ruby_module_interface;
|
||||
|
||||
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n");
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
Called when the system shuts down
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
|
||||
{
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
If it exists, this is called in it's own thread when the module-load completes
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
|
||||
{
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,326 @@
|
|||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
|
||||
*
|
||||
* 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 <anthmct@yahoo.com>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Anthony Minessale II <anthmct@yahoo.com>
|
||||
* Brian Fertig <brian.fertig@convergencetek.com>
|
||||
*
|
||||
* php_freeswitch.c -- PHP Module Framework
|
||||
*
|
||||
*/
|
||||
#include <switch.h>
|
||||
#ifdef __ICC
|
||||
#pragma warning (disable:1418)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <php.h>
|
||||
#pragma comment(lib, PHP_LIB)
|
||||
#endif
|
||||
|
||||
void fs_core_set_globals(void)
|
||||
{
|
||||
switch_core_set_globals();
|
||||
}
|
||||
|
||||
int fs_core_init(char *path)
|
||||
{
|
||||
switch_status_t status;
|
||||
const char *err = NULL;
|
||||
|
||||
if (switch_strlen_zero(path)) {
|
||||
path = NULL;
|
||||
}
|
||||
|
||||
status = switch_core_init(path, &err);
|
||||
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
int fs_core_destroy(void)
|
||||
{
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_core_destroy();
|
||||
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
int fs_loadable_module_init(void)
|
||||
{
|
||||
return switch_loadable_module_init() == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
int fs_loadable_module_shutdown(void)
|
||||
{
|
||||
switch_loadable_module_shutdown();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fs_console_loop(void)
|
||||
{
|
||||
switch_console_loop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fs_consol_log(char *level_str, char *msg)
|
||||
{
|
||||
switch_log_level_t level = SWITCH_LOG_DEBUG;
|
||||
if (level_str) {
|
||||
level = switch_log_str2level(level_str);
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, level, msg);
|
||||
}
|
||||
|
||||
void fs_consol_clean(char *msg)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, msg);
|
||||
}
|
||||
|
||||
switch_core_session_t *fs_core_session_locate(char *uuid)
|
||||
{
|
||||
switch_core_session_t *session;
|
||||
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
switch_core_session_rwunlock(session);
|
||||
}
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
void fs_channel_answer(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_channel_answer(channel);
|
||||
}
|
||||
|
||||
void fs_channel_pre_answer(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_channel_pre_answer(channel);
|
||||
}
|
||||
|
||||
void fs_channel_hangup(switch_core_session_t *session, char *cause)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_channel_hangup(channel, switch_channel_str2cause(cause));
|
||||
}
|
||||
|
||||
void fs_channel_set_variable(switch_core_session_t *session, char *var, char *val)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_channel_set_variable(channel, var, val);
|
||||
}
|
||||
|
||||
void fs_channel_get_variable(switch_core_session_t *session, char *var)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_channel_get_variable(channel, var);
|
||||
}
|
||||
|
||||
void fs_channel_set_state(switch_core_session_t *session, char *state)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_channel_state_t fs_state = switch_channel_get_state(channel);
|
||||
|
||||
if ((fs_state = switch_channel_name_state(state)) < CS_HANGUP) {
|
||||
switch_channel_set_state(channel, fs_state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
IVR Routines! You can do IVR in PHP NOW!
|
||||
*/
|
||||
|
||||
int fs_ivr_play_file(switch_core_session_t *session,
|
||||
char *file,
|
||||
char *timer_name,
|
||||
switch_input_callback_function_t dtmf_callback,
|
||||
void *buf,
|
||||
unsigned int buflen)
|
||||
{
|
||||
switch_status_t status;
|
||||
if (switch_strlen_zero(timer_name)) {
|
||||
timer_name = NULL;
|
||||
}
|
||||
|
||||
status = switch_ivr_play_file(session, NULL, file, timer_name, NULL, NULL, 0);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
int fs_switch_ivr_record_file(switch_core_session_t *session,
|
||||
switch_file_handle_t *fh,
|
||||
char *file,
|
||||
switch_input_callback_function_t dtmf_callback,
|
||||
void *buf,
|
||||
unsigned int buflen)
|
||||
{
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_ivr_record_file(session, fh, file, dtmf_callback, buf, buflen);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
int fs_switch_ivr_sleep(switch_core_session_t *session,
|
||||
uint32_t ms)
|
||||
{
|
||||
switch_status_t status;
|
||||
status = switch_ivr_sleep(session, ms);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
int fs_ivr_play_file2(switch_core_session_t *session,
|
||||
char *file)
|
||||
|
||||
{
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_ivr_play_file(session, NULL, file, NULL, NULL, NULL, 0);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
int fs_switch_ivr_collect_digits_callback (switch_core_session_t *session,
|
||||
switch_input_callback_function_t dtmf_callback,
|
||||
void *buf,
|
||||
unsigned int buflen)
|
||||
{
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_ivr_collect_digits_callback(session, dtmf_callback, buf, buflen);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
int fs_switch_ivr_collect_digits_count (switch_core_session_t *session,
|
||||
char *buf,
|
||||
unsigned int buflen,
|
||||
unsigned int maxdigits,
|
||||
const char *terminators,
|
||||
char *terminator,
|
||||
unsigned int timeout)
|
||||
{
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_ivr_collect_digits_count(session, buf, buflen, maxdigits, terminators, terminator, timeout);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
/*int fs_switch_ivr_multi_threaded_bridge (switch_core_session_t *session,
|
||||
switch_core_session_t *peer_session,
|
||||
switch_input_callback_function_t dtmf_callback,
|
||||
void *session_data,
|
||||
void *peer_session_data)
|
||||
{
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_ivr_multi_threaded_bridge(session, peer_session, dtmf_callback, session_data, peer_session_data);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
*/
|
||||
|
||||
int fs_switch_ivr_originate (switch_core_session_t *session,
|
||||
switch_core_session_t **bleg,
|
||||
char * bridgeto,
|
||||
uint32_t timelimit_sec)
|
||||
/*const switch_state_handler_table_t *table,
|
||||
char * cid_name_override,
|
||||
char * cid_num_override,
|
||||
switch_caller_profile_t *caller_profile_override) */
|
||||
{
|
||||
|
||||
switch_channel_t *caller_channel;
|
||||
switch_core_session_t *peer_session;
|
||||
unsigned int timelimit = 60;
|
||||
char *var;
|
||||
|
||||
caller_channel = switch_core_session_get_channel(session);
|
||||
assert(caller_channel != NULL);
|
||||
|
||||
if ((var = switch_channel_get_variable(caller_channel, "call_timeout"))) {
|
||||
timelimit = atoi(var);
|
||||
}
|
||||
|
||||
if (switch_ivr_originate(session, &peer_session, bridgeto, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
|
||||
switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
|
||||
return;
|
||||
} else {
|
||||
switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int fs_switch_ivr_session_transfer(switch_core_session_t *session,
|
||||
char *extension,
|
||||
char *dialplan,
|
||||
char *context)
|
||||
{
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_ivr_session_transfer(session,extension,dialplan,context);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
int fs_switch_ivr_speak_text (switch_core_session_t *session,
|
||||
char *tts_name,
|
||||
char *voice_name,
|
||||
char *timer_name,
|
||||
uint32_t rate,
|
||||
switch_input_callback_function_t dtmf_callback,
|
||||
char *text,
|
||||
void *buf,
|
||||
unsigned int buflen)
|
||||
{
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_ivr_speak_text(session,tts_name,voice_name,timer_name,rate,dtmf_callback,text,buf,buflen);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
******* CHANNEL STUFF *******
|
||||
|
||||
*/
|
||||
|
||||
char* fs_switch_channel_get_variable(switch_channel_t *channel, char *varname)
|
||||
{
|
||||
return switch_channel_get_variable(channel, varname);
|
||||
}
|
||||
|
||||
|
||||
int fs_switch_channel_set_variable(switch_channel_t *channel, char *varname, char *value)
|
||||
{
|
||||
switch_status_t status;
|
||||
|
||||
status = switch_channel_set_variable(channel, varname, value);
|
||||
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
%module fs_elmoscript
|
||||
%{
|
||||
#include "switch.h"
|
||||
%}
|
||||
|
||||
%include "/usr/local/freeswitch/include/switch.h"
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue