From 4fb68ce49a0ec9a069a92cd170b0536270c80c92 Mon Sep 17 00:00:00 2001 From: miker-pines Date: Fri, 7 Apr 2006 02:29:56 +0000 Subject: [PATCH] adding loadable module support --- SIPServer.pm | 18 ++++++++++++++++-- SIPconfig.xml | 6 +++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/SIPServer.pm b/SIPServer.pm index dcf1db5..4105ee5 100644 --- a/SIPServer.pm +++ b/SIPServer.pm @@ -7,6 +7,7 @@ use Sys::Syslog qw(syslog); use Net::Server::PreFork; use IO::Socket::INET; use Data::Dumper; # For debugging +require UNIVERSAL::require; #use Sip qw(readline); use Sip::Constants qw(:all); @@ -218,6 +219,7 @@ sub sip_protocol_loop { my $self = shift; my $expect; my $service = $self->{service}; + my $config = $self->{config}; my $input; local $/ = "\r"; # SIP protocol message terminator @@ -225,12 +227,24 @@ sub sip_protocol_loop { # # initialize connection to ILS # - $self->{ils} = new ILS $self->{account}->{institution}; + my $module = $config + ->{institutions} + ->{ $self->{account}->{institution} } + ->{implementation}; + $module->use; + + if ($@) { + syslog("LOG_ERR", "%s: Loading ILS implementation '%s' failed, exiting", + $self->{service}, $self->{account}->{institution}); + die("ILS initialization failed"); + } + + $self->{ils} = $module->new( $self->{institution} ); if (!$self->{ils}) { syslog("LOG_ERR", "%s: ILS connection to '%s' failed, exiting", - $self->{service}, $self->{institution}); + $self->{service}, $self->{account}->{institution}); die("ILS initialization failed"); } # Now that the terminal has logged in, the first message diff --git a/SIPconfig.xml b/SIPconfig.xml index ddea243..42cc19b 100644 --- a/SIPconfig.xml +++ b/SIPconfig.xml @@ -37,14 +37,14 @@ - + - + - \ No newline at end of file + -- 2.11.0