提交 8027cb8e authored 作者: Anthony Minessale's avatar Anthony Minessale

return of mod_perl

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8198 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 ae76db7b
<configuration name="perl.conf" description="PERL Configuration">
<settings>
<!--<param name="xml-handler-script" value="/tmp/xml.pl"/>-->
<!--<param name="xml-handler-bindings" value="dialplan"/>-->
</settings>
</configuration>
BASE=../../../..
PERL = `which perl`
PERL_LIBDIR =-L$(shell perl -MConfig -e 'print $$Config{archlib}')/CORE
PERL_LIBS =$(shell perl -MConfig -e 'print $$Config{libs}')
LOCAL_CFLAGS= -w -DMULTIPLICITY $(shell $(PERL) -MExtUtils::Embed -e ccopts) -DEMBED_PERL
LOCAL_LDFLAGS=$(shell $(PERL) -MExtUtils::Embed -e ldopts) $(shell $(PERL) -MConfig -e 'print $$Config{libs}')
LOCAL_OBJS=freeswitch_perl.o mod_perl_wrap.o perlxsi.o
VERBOSE=1
include $(BASE)/build/modmake.rules
swigclean: clean
rm mod_perl_wrap.*
mod_perl_wrap.cpp: $(TOLUA_A)
swig -static -shadow -perl5 -c++ -DMULTIPLICITY -I../../../../src/include -o mod_perl_wrap.cpp freeswitch.i
freeswitch.$(DYNAMIC_LIB_EXTEN): $(LOCAL_OBJS) $(LOCAL_LIBADD)
$(LINK) $(SOLINK) -o freeswitch.$(DYNAMIC_LIB_EXTEN) $(LOCAL_OBJS) $(LOCAL_LIBADD) $(LDFLAGS)
local_all: freeswitch.$(DYNAMIC_LIB_EXTEN)
.perlok:
@(${PERL} -V | grep -i usemultiplicity=define >/dev/null && echo Phew, You have the right perl.) \
|| ((echo Sorry, you need to compile perl with threads and multiplicity.&& exit 1))
@touch .perlok
local_clean:
rm -fr *~ .perlok freeswitch.$(DYNAMIC_LIB_EXTEN)
depend_install:
mkdir -p $(PREFIX)/perl
$(LTINSTALL) freeswitch.$(DYNAMIC_LIB_EXTEN) freeswitch.pm $(PREFIX)/perl
if [ ! -f $(PREFIX)/perl/freeswitch.pm ] ; then $(LTINSTALL) freeswitch.pm $(PREFIX)/perl ; fi
/IC:\perl\lib\CORE
\ No newline at end of file
/I@PERL_INCLUDE@
\ No newline at end of file
%module freeswitch
//%include "cstring.i"
/**
* tell swig to treat these variables as mutable so they
* can be used to return values.
* See http://www.swig.org/Doc1.3/Library.html
*/
//%cstring_bounded_mutable(char *dtmf_buf, 128);
//%cstring_bounded_mutable(char *terminator, 8);
/** insert the following includes into generated code so it compiles */
%{
#include "switch_cpp.h"
#include "freeswitch_perl.h"
%}
%ignore SwitchToMempool;
/**
* tell swig to grok everything defined in these header files and
* build all sorts of c wrappers and lua shadows of the c wrappers.
*/
%include switch_cpp.h
%include freeswitch_perl.h
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
package freeswitch;
require Exporter;
@ISA = qw(Exporter);
package freeswitchc;
boot_freeswitch();
package freeswitch;
@EXPORT = qw( );
# ---------- BASE METHODS -------------
package freeswitch;
sub TIEHASH {
my ($classname,$obj) = @_;
return bless $obj, $classname;
}
sub CLEAR { }
sub FIRSTKEY { }
sub NEXTKEY { }
sub FETCH {
my ($self,$field) = @_;
my $member_func = "swig_${field}_get";
$self->$member_func();
}
sub STORE {
my ($self,$field,$newval) = @_;
my $member_func = "swig_${field}_set";
$self->$member_func($newval);
}
sub this {
my $ptr = shift;
return tied(%$ptr);
}
# ------- FUNCTION WRAPPERS --------
package freeswitch;
*console_log = *freeswitchc::console_log;
*console_clean_log = *freeswitchc::console_clean_log;
*api_execute = *freeswitchc::api_execute;
*api_reply_delete = *freeswitchc::api_reply_delete;
*process_callback_result = *freeswitchc::process_callback_result;
*bridge = *freeswitchc::bridge;
*hanguphook = *freeswitchc::hanguphook;
*dtmf_callback = *freeswitchc::dtmf_callback;
############# Class : freeswitch::input_callback_state_t ##############
package freeswitch::input_callback_state_t;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( freeswitch );
%OWNER = ();
%ITERATORS = ();
*swig_function_get = *freeswitchc::input_callback_state_t_function_get;
*swig_function_set = *freeswitchc::input_callback_state_t_function_set;
*swig_threadState_get = *freeswitchc::input_callback_state_t_threadState_get;
*swig_threadState_set = *freeswitchc::input_callback_state_t_threadState_set;
*swig_extra_get = *freeswitchc::input_callback_state_t_extra_get;
*swig_extra_set = *freeswitchc::input_callback_state_t_extra_set;
*swig_funcargs_get = *freeswitchc::input_callback_state_t_funcargs_get;
*swig_funcargs_set = *freeswitchc::input_callback_state_t_funcargs_set;
sub new {
my $pkg = shift;
my $self = freeswitchc::new_input_callback_state_t(@_);
bless $self, $pkg if defined($self);
}
sub DESTROY {
return unless $_[0]->isa('HASH');
my $self = tied(%{$_[0]});
return unless defined $self;
delete $ITERATORS{$self};
if (exists $OWNER{$self}) {
freeswitchc::delete_input_callback_state_t($self);
delete $OWNER{$self};
}
}
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
}
############# Class : freeswitch::Stream ##############
package freeswitch::Stream;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( freeswitch );
%OWNER = ();
%ITERATORS = ();
sub new {
my $pkg = shift;
my $self = freeswitchc::new_Stream(@_);
bless $self, $pkg if defined($self);
}
sub DESTROY {
return unless $_[0]->isa('HASH');
my $self = tied(%{$_[0]});
return unless defined $self;
delete $ITERATORS{$self};
if (exists $OWNER{$self}) {
freeswitchc::delete_Stream($self);
delete $OWNER{$self};
}
}
*write = *freeswitchc::Stream_write;
*get_data = *freeswitchc::Stream_get_data;
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
}
############# Class : freeswitch::Event ##############
package freeswitch::Event;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( freeswitch );
%OWNER = ();
%ITERATORS = ();
sub new {
my $pkg = shift;
my $self = freeswitchc::new_Event(@_);
bless $self, $pkg if defined($self);
}
sub DESTROY {
return unless $_[0]->isa('HASH');
my $self = tied(%{$_[0]});
return unless defined $self;
delete $ITERATORS{$self};
if (exists $OWNER{$self}) {
freeswitchc::delete_Event($self);
delete $OWNER{$self};
}
}
*set_priority = *freeswitchc::Event_set_priority;
*get_header = *freeswitchc::Event_get_header;
*get_body = *freeswitchc::Event_get_body;
*add_body = *freeswitchc::Event_add_body;
*add_header = *freeswitchc::Event_add_header;
*del_header = *freeswitchc::Event_del_header;
*fire = *freeswitchc::Event_fire;
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
}
############# Class : freeswitch::CoreSession ##############
package freeswitch::CoreSession;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( freeswitch );
%OWNER = ();
%ITERATORS = ();
sub DESTROY {
return unless $_[0]->isa('HASH');
my $self = tied(%{$_[0]});
return unless defined $self;
delete $ITERATORS{$self};
if (exists $OWNER{$self}) {
freeswitchc::delete_CoreSession($self);
delete $OWNER{$self};
}
}
*swig_session_get = *freeswitchc::CoreSession_session_get;
*swig_session_set = *freeswitchc::CoreSession_session_set;
*swig_channel_get = *freeswitchc::CoreSession_channel_get;
*swig_channel_set = *freeswitchc::CoreSession_channel_set;
*swig_flags_get = *freeswitchc::CoreSession_flags_get;
*swig_flags_set = *freeswitchc::CoreSession_flags_set;
*swig_allocated_get = *freeswitchc::CoreSession_allocated_get;
*swig_allocated_set = *freeswitchc::CoreSession_allocated_set;
*swig_cb_state_get = *freeswitchc::CoreSession_cb_state_get;
*swig_cb_state_set = *freeswitchc::CoreSession_cb_state_set;
*swig_hook_state_get = *freeswitchc::CoreSession_hook_state_get;
*swig_hook_state_set = *freeswitchc::CoreSession_hook_state_set;
*answer = *freeswitchc::CoreSession_answer;
*preAnswer = *freeswitchc::CoreSession_preAnswer;
*hangup = *freeswitchc::CoreSession_hangup;
*setVariable = *freeswitchc::CoreSession_setVariable;
*getVariable = *freeswitchc::CoreSession_getVariable;
*recordFile = *freeswitchc::CoreSession_recordFile;
*setCallerData = *freeswitchc::CoreSession_setCallerData;
*originate = *freeswitchc::CoreSession_originate;
*setDTMFCallback = *freeswitchc::CoreSession_setDTMFCallback;
*speak = *freeswitchc::CoreSession_speak;
*set_tts_parms = *freeswitchc::CoreSession_set_tts_parms;
*collectDigits = *freeswitchc::CoreSession_collectDigits;
*getDigits = *freeswitchc::CoreSession_getDigits;
*transfer = *freeswitchc::CoreSession_transfer;
*playAndGetDigits = *freeswitchc::CoreSession_playAndGetDigits;
*streamFile = *freeswitchc::CoreSession_streamFile;
*flushEvents = *freeswitchc::CoreSession_flushEvents;
*flushDigits = *freeswitchc::CoreSession_flushDigits;
*setAutoHangup = *freeswitchc::CoreSession_setAutoHangup;
*setHangupHook = *freeswitchc::CoreSession_setHangupHook;
*ready = *freeswitchc::CoreSession_ready;
*execute = *freeswitchc::CoreSession_execute;
*begin_allow_threads = *freeswitchc::CoreSession_begin_allow_threads;
*end_allow_threads = *freeswitchc::CoreSession_end_allow_threads;
*get_uuid = *freeswitchc::CoreSession_get_uuid;
*get_cb_args = *freeswitchc::CoreSession_get_cb_args;
*check_hangup_hook = *freeswitchc::CoreSession_check_hangup_hook;
*run_dtmf_callback = *freeswitchc::CoreSession_run_dtmf_callback;
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
}
############# Class : freeswitch::Session ##############
package freeswitch::Session;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( freeswitch::CoreSession freeswitch );
%OWNER = ();
%ITERATORS = ();
sub new {
my $pkg = shift;
my $self = freeswitchc::new_Session(@_);
bless $self, $pkg if defined($self);
}
sub DESTROY {
return unless $_[0]->isa('HASH');
my $self = tied(%{$_[0]});
return unless defined $self;
delete $ITERATORS{$self};
if (exists $OWNER{$self}) {
freeswitchc::delete_Session($self);
delete $OWNER{$self};
}
}
*begin_allow_threads = *freeswitchc::Session_begin_allow_threads;
*end_allow_threads = *freeswitchc::Session_end_allow_threads;
*check_hangup_hook = *freeswitchc::Session_check_hangup_hook;
*run_dtmf_callback = *freeswitchc::Session_run_dtmf_callback;
*swig_session_get = *freeswitchc::Session_session_get;
*swig_session_set = *freeswitchc::Session_session_set;
*swig_channel_get = *freeswitchc::Session_channel_get;
*swig_channel_set = *freeswitchc::Session_channel_set;
*swig_flags_get = *freeswitchc::Session_flags_get;
*swig_flags_set = *freeswitchc::Session_flags_set;
*swig_allocated_get = *freeswitchc::Session_allocated_get;
*swig_allocated_set = *freeswitchc::Session_allocated_set;
*swig_cb_state_get = *freeswitchc::Session_cb_state_get;
*swig_cb_state_set = *freeswitchc::Session_cb_state_set;
*swig_hook_state_get = *freeswitchc::Session_hook_state_get;
*swig_hook_state_set = *freeswitchc::Session_hook_state_set;
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
}
# ------- VARIABLE STUBS --------
package freeswitch;
*S_HUP = *freeswitchc::S_HUP;
*S_FREE = *freeswitchc::S_FREE;
*S_RDLOCK = *freeswitchc::S_RDLOCK;
1;
#include "freeswitch_perl.h"
Session::Session() : CoreSession()
{
}
Session::Session(char *uuid) : CoreSession(uuid)
{
}
Session::Session(switch_core_session_t *new_session) : CoreSession(new_session)
{
}
Session::~Session()
{
}
bool Session::begin_allow_threads()
{
return true;
}
bool Session::end_allow_threads()
{
return true;
}
void Session::check_hangup_hook()
{
}
switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t itype)
{
return SWITCH_STATUS_FALSE;
}
#if 0
int Session::answer() {}
int Session::preAnswer() {}
void Session::hangup(char *cause) {}
void Session::setVariable(char *var, char *val) {}
const char *Session::getVariable(char *var) {}
int Session::recordFile(char *file_name, int max_len, int silence_threshold, int silence_secs) {}
void Session::setCallerData(char *var, char *val) {}
int Session::originate(CoreSession *a_leg_session, char *dest, int timeout) {}
void Session::setDTMFCallback(void *cbfunc, char *funcargs) {}
int Session::speak(char *text) {}
void Session::set_tts_parms(char *tts_name, char *voice_name) {}
int Session::collectDigits(int timeout) {}
int Session::getDigits(char *dtmf_buf,
switch_size_t buflen,
switch_size_t maxdigits,
char *terminators,
char *terminator,
int timeout) {}
int Session::transfer(char *extensions, char *dialplan, char *context) {}
int Session::playAndGetDigits(int min_digits,
int max_digits,
int max_tries,
int timeout,
char *terminators,
char *audio_files,
char *bad_input_audio_files,
char *dtmf_buf,
char *digits_regex) {}
int Session::streamFile(char *file, int starting_sample_count) {}
int Session::flushEvents() {}
int Session::flushDigits() {}
int Session::setAutoHangup(bool val) {}
void Session::setHangupHook(void *hangup_func) {}
bool Session::ready() {}
void Session::execute(char *app, char *data) {}
char* Session::get_uuid() {}
const switch_input_args_t& Session::get_cb_args() {}
#endif
#ifndef FREESWITCH_PYTHON_H
#define FREESWITCH_PYTHON_H
#include <switch_cpp.h>
void console_log(char *level_str, char *msg);
void console_clean_log(char *msg);
char *api_execute(char *cmd, char *arg);
void api_reply_delete(char *reply);
class Session : public CoreSession {
private:
public:
Session();
Session(char *uuid);
Session(switch_core_session_t *session);
~Session();
virtual bool begin_allow_threads();
virtual bool end_allow_threads();
virtual void check_hangup_hook();
virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
switch_core_session_t *session;
switch_channel_t *channel;
unsigned int flags;
int allocated;
input_callback_state cb_state; // callback state, always pointed to by the buf
// field in this->args
switch_channel_state_t hook_state; // store hookstate for on_hangup callback
#if 0
int answer();
int preAnswer();
virtual void hangup(char *cause);
void setVariable(char *var, char *val);
const char *getVariable(char *var);
int recordFile(char *file_name, int max_len=0, int silence_threshold=0, int silence_secs=0);
void setCallerData(char *var, char *val);
int originate(CoreSession *a_leg_session, char *dest, int timeout=60);
void setDTMFCallback(void *cbfunc, char *funcargs);
int speak(char *text);
void set_tts_parms(char *tts_name, char *voice_name);
int collectDigits(int timeout);
int getDigits(char *dtmf_buf,
switch_size_t buflen,
switch_size_t maxdigits,
char *terminators,
char *terminator,
int timeout);
int transfer(char *extensions, char *dialplan, char *context);
int playAndGetDigits(int min_digits,
int max_digits,
int max_tries,
int timeout,
char *terminators,
char *audio_files,
char *bad_input_audio_files,
char *dtmf_buf,
char *digits_regex);
int streamFile(char *file, int starting_sample_count=0);
int flushEvents();
int flushDigits();
int setAutoHangup(bool val);
void setHangupHook(void *hangup_func);
bool ready();
void execute(char *app, char *data);
char* get_uuid();
const switch_input_args_t& get_cb_args();
#endif
};
#endif
差异被折叠。
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="mod_perl"
ProjectGUID="{7B077E7F-1BE7-4291-AB86-55E527B25CAC}"
RootNamespace="mod_perl"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
ConfigurationType="2"
InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="if not exist perlxsi.c perl -MExtUtils::Embed -e xsinit"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="@compiler.opts"
AdditionalIncludeDirectories="."
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;_CRT_SECURE_NO_DEPRECATE;MULTIPLICITY;EMBED_PERL"
UsePrecompiledHeader="0"
/>
</Configuration>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="if not exist perlxsi.c perl -MExtUtils::Embed -e xsinit"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="@compiler.opts"
AdditionalIncludeDirectories="."
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;MULTIPLICITY;EMBED_PERL"
UsePrecompiledHeader="0"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\mod_perl.c"
>
</File>
<File
RelativePath=".\perlxsi.c"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
差异被折叠。
#define PERL_LIB "C:\\perl\\lib\\CORE\\perl58.lib"
#include <EXTERN.h>
#include <perl.h>
EXTERN_C void xs_init (pTHX);
EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
EXTERN_C void boot_freeswitch (pTHX_ CV* cv);
EXTERN_C void
xs_init(pTHX)
{
char *file = __FILE__;
dXSUB_SYS;
/* DynaLoader is a special case */
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
newXS("freeswitchc::boot_freeswitch", boot_freeswitch, file);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论