PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Perl|Proxy|httpproxy-1.5.3.pl =

page 7 of 8



  $debug{$socket} .= $message."\n";
  return 1;
}

sub serverclose ($) { #argumen is ref to server connection
  my $sck = shift;
  debug "Closing Server connection...", $sck;
  $sl_read->remove($sck);
  $sl_write->remove($sck);
  delete $st{$sck};
  close $sck;
}

sub clientclose($) { #argumen is ref to client connection
  my $sck = shift;
  serverclose $st{$sck}{ch} if defined $st{$st{$sck}{ch}};
  debug "Closing Client connection...", $sck;
  print $debug{$sck};
  delete $debug{$sck};
  $sl_read->remove($sck);
  $sl_write->remove($sck);
  delete $st{$sck};
  close $sck;
  return 1;
}

sub decode_b64 ($) { # taken from MIME::Base64
    my $str = shift;
    my $res = "";
    $str =~ tr|A-Za-z0-9+=/||cd;            # remove non-base64 chars
    return if (length($str) % 4);
    $str =~ s/=+$//;                        # remove padding
    $str =~ tr|A-Za-z0-9+/| -_|;            # convert to uuencoded format
    while ($str =~ /(.{1,60})/gs) {
	my $len = chr(32 + length($1)*3/4); # compute length byte
	$res .= unpack("u", $len . $1 );    # uudecode
    }
    return $res;
}

sub htmlfilter ($) { #argumen is reference to string
  my $ref_body = shift;
    for my $word (@sensors2) {
      $$ref_body =~ s|($word)|<font color=red>$1</font>|ig;
    }
  return 1;
}

sub showcommand ($) {
  my $sck = shift;
  my $buffer;
  my $byte_read = sysread $sck, $buffer, $max_buffering;
  chomp $buffer;
  if ($buffer eq "h") {
    print <<STOP;
Command: 
a - active connection
r - readable handles
w - writeable handles
d - toggle debugging
s - statistics
q - quit
h - this help
STOP
}
  elsif ($buffer eq "r") {
    for my $hd ($sl_read->handles) {
      if ($hd == $mainsocket) {
	print " main socket\n";
      }
      elsif (defined $st{$hd}) {
	print " $st{$hd}{peerhost}\n";
      }	 
    }
  }
  elsif ($buffer eq "w") {
    for my $hd ($sl_write->handles) {
      if (defined $st{$hd}) {
	print " $st{$hd}{peerhost}\n";
      }	 
    }
  }
  elsif ($buffer eq "q") {
    print "Have a nice day...\n";
    exit;
  }
  elsif ($buffer eq "d") {
    $opt_d = $opt_d? 0: 1;
    print "debugging: $opt_d\n";
  }
  elsif ($buffer eq "s") {
    
  }
  elsif ($buffer eq "n") {
    $non_block = $non_block? 0: 1;
    print "non-blocking: $non_block\n";
  }
  return 1;
}

=7=

1|2|3|4|5|6| < PREV = PAGE 7 = NEXT > |8

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.00672507 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)