#
# 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= |