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

= ROOT|Technical|Code_Examples|Perl|site_perl|JUNOS|Device.pm =

page 4 of 11



#
# Perform an rpc using a raw command string. This is a mostly unsupported
# way of getting to any JUNOS command that is currently unsupported in
# JUNOScript. Caveat coder.
#
sub command
{
    tracept("Request");
    my($self, $request) = @_;
    $self->clear_errors() if caller() ne __PACKAGE__;

    my $rpc = "<rpc><command>" . $request . "</command></rpc>\n";
    $self->request($rpc);
}

# These callback handlers are called by the parser to let
# us know important things about the connection.

#
# unsupported.callback
#
sub callbackHandler
{
    my($self, $parser) = @_;

    $self->report_error("unsupported callback");
}

#
# A reply is complete; record it for the main loop above.
#
sub replyHandler
{
    tracept("Reply");

    my($self, $parser, $reply) = @_;

    $self->{JUNOS_Reply} = $reply;
}

#
# Raw character data is available that the parser does not want. This is
# normally because the connection is not yet in XML mode. Hand the data
# off to the access method so that it can deal with it.
#
sub charHandler
{
    my($self, $parser, $data) = @_;

    my $conn = $self->{JUNOS_Conn};
    $conn->incoming($data);
}

#
# These functions are wrappers for the parser
#

#
# Start the parser: create an XML::Parser with style==JUNOS, pull
# a parser instance off this expat-parser-instance, and make
# the world even more confusing by making these objects refer
# to each other.
#
sub parse_start
{
    tracept("Parse");
    my($self, %args) = @_;

    $args{Style} = "JUNOS::DOM::Parser";
    #$args{Style} = "Debug";

    my $expat = new XML::Parser(%args);
    $self->{JUNOS_Expat} = $expat;

    my $parser = $expat->parse_start();
    $parser->{JUNOS_Device} = $self;
    $self->{JUNOS_Parser} = $parser;
}

sub contains_end_tag
{
    $_[0] =~ m#</junoscript>#m;
}

#
# Parse some more input: toss the given input data to the parser.
#
sub parse_more
{
    tracept("Parse");
    my($self, $input) = @_;

    my $done = 0;

    # Get rid of any xtra stuff after closing tag if it's there
    $done = 1 if ($input =~ s#</junoscript>(.*)$#</junoscript>#ms);

    $self->{sofar} .= $input;
    my $parser = $self->{JUNOS_Parser};

=4=

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

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.00563216 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)