Add a terminator option to SIPConfig.xml, choices for 'terminator' are
'CR' or 'CRLF'. The default continues to be 'CRLF' if 'terminator' is
undefined.
Test Plan:
1) Apply patch
2) Start SIP server
3) Run C4/SIP/t/04patron_status.t
4) Stop SIP server
5) Add terminator="CR" for account login 'term1'
6) Run 04patron_status.t again, you should see no change
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
Signed-off-by: Adrien Saurat <adrien.saurat@biblibre.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
use strict;
use warnings;
use Exporter;
use strict;
use warnings;
use Exporter;
use Sys::Syslog qw(syslog);
use POSIX qw(strftime);
use Sys::Syslog qw(syslog);
use POSIX qw(strftime);
our $error_detection = 0;
our $protocol_version = 1;
our $field_delimiter = '|'; # Protocol Default
our $error_detection = 0;
our $protocol_version = 1;
our $field_delimiter = '|'; # Protocol Default
-# The message terminator for a SIP message is '\r' in the standard doc
-# However most sip devices in the wild send a CR LF pair
-# This is required by Telnet if that is your carrier mechanism
-# On raw connections it may also be required because the buffer is
-# only flushed on linefeed and its absence causes enough delay for
-# client machines to go into an error state
-# The below works for almost all machines if however you have one
-# which does not like the additional linefeed change value to $CR
-Readonly my $msg_terminator => $CRLF;
# We need to keep a copy of the last message we sent to the SC,
# in case there's a transmission error and the SC sends us a
# We need to keep a copy of the last message we sent to the SC,
# in case there's a transmission error and the SC sends us a
- my ($self, $msg, $file) = @_;
+ my ($self, $msg, $file, $terminator) = @_;
+
+ $terminator ||= q{};
+ $terminator = ( $terminator eq 'CR' ) ? $CR : $CRLF;
+
my $cksum;
# $msg = encode_utf8($msg);
my $cksum;
# $msg = encode_utf8($msg);
if ($file) {
$file->autoflush(1);
if ($file) {
$file->autoflush(1);
- print $file $msg, $msg_terminator;
+ print $file $msg, $terminator;
} else {
STDOUT->autoflush(1);
} else {
STDOUT->autoflush(1);
- print $msg, $msg_terminator;
+ print $msg, $terminator;
syslog("LOG_INFO", "OUTPUT MSG: '$msg'");
}
syslog("LOG_INFO", "OUTPUT MSG: '$msg'");
}
$ils->check_inst_id($fields->{(FID_INST_ID)}, "handle_patron_status");
$patron = $ils->find_patron($fields->{(FID_PATRON_ID)});
$resp = build_patron_status($patron, $lang, $fields);
$ils->check_inst_id($fields->{(FID_INST_ID)}, "handle_patron_status");
$patron = $ils->find_patron($fields->{(FID_PATRON_ID)});
$resp = build_patron_status($patron, $lang, $fields);
- $self->write_msg($resp);
+ $self->write_msg($resp,undef,$server->{account}->{terminator});
return (PATRON_STATUS_REQ);
}
return (PATRON_STATUS_REQ);
}
- $self->write_msg($resp);
+ $self->write_msg($resp,undef,$server->{account}->{terminator});
$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
- $self->write_msg($resp);
+ $self->write_msg($resp,undef,$server->{account}->{terminator});
}
$resp = build_patron_status($patron, $patron->language, $fields);
}
$resp = build_patron_status($patron, $patron->language, $fields);
- $self->write_msg($resp);
+ $self->write_msg($resp,undef,$server->{account}->{terminator});
if (!$last_response) {
# We haven't sent anything yet, so respond with a
# REQUEST_SC_RESEND msg (p. 16)
if (!$last_response) {
# We haven't sent anything yet, so respond with a
# REQUEST_SC_RESEND msg (p. 16)
- $self->write_msg(REQUEST_SC_RESEND);
+ $self->write_msg(REQUEST_SC_RESEND,undef,$server->{account}->{terminator});
} elsif ((length($last_response) < 9)
|| substr($last_response, -9, 2) ne 'AY') {
# When resending a message, we aren't supposed to include
} elsif ((length($last_response) < 9)
|| substr($last_response, -9, 2) ne 'AY') {
# When resending a message, we aren't supposed to include
# Cut out the sequence number and checksum, since the old
# checksum is wrong for the resent message.
my $rebuilt = substr($last_response, 0, -9);
# Cut out the sequence number and checksum, since the old
# checksum is wrong for the resent message.
my $rebuilt = substr($last_response, 0, -9);
- $self->write_msg($rebuilt);
+ $self->write_msg($rebuilt,undef,$server->{account}->{terminator});
}
return REQUEST_ACS_RESEND;
}
return REQUEST_ACS_RESEND;
}
else { $status = login_core($server,$uid,$pwd); }
}
else { $status = login_core($server,$uid,$pwd); }
- $self->write_msg(LOGIN_RESP . $status);
+ $self->write_msg(LOGIN_RESP . $status,undef,$server->{account}->{terminator});
return $status ? LOGIN : '';
}
return $status ? LOGIN : '';
}
- $self->write_msg($resp);
+ $self->write_msg($resp,undef,$server->{account}->{terminator});
$resp .= maybe_add(FID_SCREEN_MSG, $screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $print_line);
$resp .= maybe_add(FID_SCREEN_MSG, $screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $print_line);
- $self->write_msg($resp);
+ $self->write_msg($resp,undef,$server->{account}->{terminator});
return(END_PATRON_SESSION);
}
return(END_PATRON_SESSION);
}
$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
- $self->write_msg($resp);
+ $self->write_msg($resp,undef,$server->{account}->{terminator});
$resp .= maybe_add(FID_PRINT_LINE, $item->print_line);
}
$resp .= maybe_add(FID_PRINT_LINE, $item->print_line);
}
- $self->write_msg($resp);
+ $self->write_msg($resp,undef,$server->{account}->{terminator});
return(ITEM_INFORMATION);
}
return(ITEM_INFORMATION);
}
$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
- $self->write_msg($resp);
+ $self->write_msg($resp,undef,$server->{account}->{terminator});
return(ITEM_STATUS_UPDATE);
}
return(ITEM_STATUS_UPDATE);
}
$resp .= add_field(FID_INST_ID, $ils->institution);
$resp .= add_field(FID_INST_ID, $ils->institution);
- $self->write_msg($resp);
+ $self->write_msg($resp,undef,$server->{account}->{terminator});
$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
- $self->write_msg($resp);
+ $self->write_msg($resp,undef,$server->{account}->{terminator});
$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
- $self->write_msg($resp);
+ $self->write_msg($resp,undef,$server->{account}->{terminator});
$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
$resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
- $self->write_msg($resp);
+ $self->write_msg($resp,undef,$server->{account}->{terminator});
# Do we want to tell the terminal its location?
# Do we want to tell the terminal its location?
- $self->write_msg($msg);
+ $self->write_msg($msg,undef,$server->{account}->{terminator});
<accounts>
<login id="term1" password="term1" delimiter="|" error-detect="enabled" institution="CPL" />
<login id="koha" password="koha" delimiter="|" error-detect="enabled" institution="kohalibrary" />
<accounts>
<login id="term1" password="term1" delimiter="|" error-detect="enabled" institution="CPL" />
<login id="koha" password="koha" delimiter="|" error-detect="enabled" institution="kohalibrary" />
- <login id="koha2" password="koha" institution="kohalibrary2" />
+ <login id="koha2" password="koha" institution="kohalibrary2" terminator="CR" />
<login id="lpl-sc" password="1234" institution="LPL" />
<login id="lpl-sc-beacock" password="xyzzy"
delimiter="|" error-detect="enabled" institution="LPL" />
<login id="lpl-sc" password="1234" institution="LPL" />
<login id="lpl-sc-beacock" password="xyzzy"
delimiter="|" error-detect="enabled" institution="LPL" />