From: <ssc...@us...> - 2003-03-21 05:33:38
|
Update of /cvsroot/popfile/engine/Proxy In directory sc8-pr-cvs1:/tmp/cvs-serv9422 Modified Files: Proxy.pm Log Message: added echo_to_regexp_ subroutine Index: Proxy.pm =================================================================== RCS file: /cvsroot/popfile/engine/Proxy/Proxy.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Proxy.pm 18 Mar 2003 15:28:45 -0000 1.9 --- Proxy.pm 21 Mar 2003 05:33:34 -0000 1.10 *************** *** 321,337 **** } # --------------------------------------------------------------------------------------------- # ! # echo_to_dot_ # # $mail The stream (created with IO::) to send the message to (the remote mail server) # $client The local mail client (created with IO::) that needs the response # ! # echo all information from the $mail server until a single line with a . is seen # # --------------------------------------------------------------------------------------------- ! sub echo_to_dot_ { ! my ( $self, $mail, $client ) = @_; while ( <$mail> ) { --- 321,346 ---- } + # --------------------------------------------------------------------------------------------- # ! # echo_to_regexp_ # # $mail The stream (created with IO::) to send the message to (the remote mail server) # $client The local mail client (created with IO::) that needs the response + # $regexp The pattern match to terminate echoing, compile using qr/pattern/ + # $verbose (OPTIONAL) log output if 1, defaults to 0 if unset # ! # echo all information from the $mail server until a single line matching $regexp is seen # # --------------------------------------------------------------------------------------------- ! sub echo_to_regexp_ { ! my ( $self, $mail, $client, $regexp, $verbose ) = @_; ! ! $verbose = 0 if (!defined($verbose)); ! ! # ASSERT: $regexp =~ /^\/.*\/$/ *shrug* ! ! #$regexp =~ s/^\/(.*)\/$/$1/; while ( <$mail> ) { *************** *** 339,352 **** last if ( $self->{alive_} == 0 ); ! print $client $_; ! #$self->tee_($client, $_); ! ! # The termination has to be a single line with exactly a dot on it and nothing ! # else other than line termination characters. This is vital so that we do ! # not mistake a line beginning with . as the end of the block ! last if ( /^\.(\r\n|\r|\n)$/ ); } } # --------------------------------------------------------------------------------------------- # --- 348,388 ---- last if ( $self->{alive_} == 0 ); ! if (!$verbose) { ! print $client $_; ! } else { ! # This creates log output ! $self->tee_($client, $_); ! } ! ! my $done = ($_ =~ $regexp); ! ! print $regexp . "=~" . $_ . ($done?'1':'0') . "\n" ; ! ! last if ( $_ =~ $regexp ); } } + + # --------------------------------------------------------------------------------------------- + # + # echo_to_dot_ + # + # $mail The stream (created with IO::) to send the message to (the remote mail server) + # $client The local mail client (created with IO::) that needs the response + # + # echo all information from the $mail server until a single line with a . is seen + # + # --------------------------------------------------------------------------------------------- + sub echo_to_dot_ + { + my ( $self, $mail, $client ) = @_; + + # The termination has to be a single line with exactly a dot on it and nothing + # else other than line termination characters. This is vital so that we do + # not mistake a line beginning with . as the end of the block + + $self->echo_to_regexp_( $mail, $client, qr/^\.(\r\n|\r|\n)$/); + } + # --------------------------------------------------------------------------------------------- # *************** *** 427,435 **** if ( $response ) { # Echo the response up to the mail client ! $self->tee_( $client, $response ); return $response; } } ! if (!null_resp) { # An error has occurred reading from the mail server --- 463,471 ---- if ( $response ) { # Echo the response up to the mail client ! $self->tee_( $client, $response ); return $response; } } ! if (!null_resp) { # An error has occurred reading from the mail server *************** *** 439,443 **** $self->tee_($client, ""); return ""; ! } } --- 475,479 ---- $self->tee_($client, ""); return ""; ! } } |