From: djfiander Date: Fri, 17 Oct 2008 23:48:02 +0000 (+0000) Subject: Untested fix for dealing with the incorrect record terminators X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1faec65785eb58c80f0bbb4c6a6fea3e3e05a473;p=SIPServer.git Untested fix for dealing with the incorrect record terminators transmitted by Cen-Tec self-check hardware. --- diff --git a/Sip.pm b/Sip.pm index 03b0815..a1e586c 100644 --- a/Sip.pm +++ b/Sip.pm @@ -164,6 +164,19 @@ sub read_SIP_packet { local $/ = "\r"; $record = readline($file); + + # + # Cen-Tec self-check terminals transmit '\r\n' line terminators. + # This is actually very hard to deal with in perl in a reasonable + # since every OTHER piece of hardware out there gets the protocol + # right. + # + # The incorrect line terminator presents as a \r at the end of the + # first record, and then a \n at the BEGINNING of the next record. + # So, the simplest thing to do is just throw away a leading newline + # on the input. + # + $record =~ s/^\012//; syslog("LOG_INFO", "INPUT MSG: '$record'") if $record; return $record; }