summaryrefslogtreecommitdiff
path: root/src/lib/mrtg2
diff options
context:
space:
mode:
authorbeatrice <beatrice@dangofactory.net>2026-11-22 20:00:14 +0900
committerbeatrice <beatrice@dangofactory.net>2026-11-22 20:00:14 +0900
commit8f68d02045982da8f00a559835b500caf3a1967d (patch)
treec8d0e92969b92e1b6559a0e032b6aa710a8ae2d9 /src/lib/mrtg2
parentbb5ff95073e5001be7dbf58ffce80d7926deff0b (diff)
downloadmrtg-master.tar.gz
mrtg-master.zip
Release tarball mrtg-2.17.7.tar.gz (dist-generated files / local differences from tag)HEADmaster
Diffstat (limited to 'src/lib/mrtg2')
-rw-r--r--src/lib/mrtg2/BER.pm913
-rw-r--r--src/lib/mrtg2/MRTG_lib.pm2368
-rw-r--r--src/lib/mrtg2/Net_SNMP_util.pm2130
-rw-r--r--src/lib/mrtg2/Pod/Checker.pm1268
-rw-r--r--src/lib/mrtg2/Pod/Find.pm535
-rw-r--r--src/lib/mrtg2/Pod/InputObjects.pm936
-rw-r--r--src/lib/mrtg2/Pod/ParseUtils.pm855
-rw-r--r--src/lib/mrtg2/Pod/Parser.pm1829
-rw-r--r--src/lib/mrtg2/Pod/PlainText.pm738
-rw-r--r--src/lib/mrtg2/Pod/Select.pm746
-rw-r--r--src/lib/mrtg2/Pod/Usage.pm730
-rw-r--r--src/lib/mrtg2/SNMP_Session.pm1118
-rw-r--r--src/lib/mrtg2/SNMP_util.pm1355
-rw-r--r--src/lib/mrtg2/locales_mrtg.pm5434
14 files changed, 0 insertions, 20955 deletions
diff --git a/src/lib/mrtg2/BER.pm b/src/lib/mrtg2/BER.pm
deleted file mode 100644
index 739b48d..0000000
--- a/src/lib/mrtg2/BER.pm
+++ /dev/null
@@ -1,913 +0,0 @@
-### -*- mode: Perl -*-
-######################################################################
-### BER (Basic Encoding Rules) encoding and decoding.
-######################################################################
-### Copyright (c) 1995-2008, Simon Leinen.
-###
-### This program is free software; you can redistribute it under the
-### "Artistic License 2.0" included in this distribution
-### (file "Artistic").
-######################################################################
-### This module implements encoding and decoding of ASN.1-based data
-### structures using the Basic Encoding Rules (BER). Only the subset
-### necessary for SNMP is implemented.
-######################################################################
-### Created by: Simon Leinen <simon@switch.ch>
-###
-### Contributions and fixes by:
-###
-### Andrzej Tobola <san@iem.pw.edu.pl>: Added long String decode
-### Tobias Oetiker <tobi@oetiker.ch>: Added 5 Byte Integer decode ...
-### Dave Rand <dlr@Bungi.com>: Added SysUpTime decode
-### Philippe Simonet <sip00@vg.swissptt.ch>: Support larger subids
-### Yufang HU <yhu@casc.com>: Support even larger subids
-### Mike Mitchell <Mike.Mitchell@sas.com>: New generalized encode_int()
-### Mike Diehn <mdiehn@mindspring.net>: encode_ip_address()
-### Rik Hoorelbeke <rik.hoorelbeke@pandora.be>: encode_oid() fix
-### Brett T Warden <wardenb@eluminant.com>: pretty UInteger32
-### Bert Driehuis <driehuis@playbeing.org>: Handle SNMPv2 exception codes
-### Jakob Ilves (/IlvJa) <jakob.ilves@oracle.com>: PDU decoding
-### Jan Kasprzak <kas@informatics.muni.cz>: Fix for PDU syntax check
-### Milen Pavlov <milen@batmbg.com>: Recognize variant length for ints
-######################################################################
-
-package BER;
-
-require 5.002;
-
-use strict;
-use vars qw(@ISA @EXPORT $VERSION $pretty_print_timeticks
- %pretty_printer %default_printer $errmsg);
-use Exporter;
-
-$VERSION = '1.05';
-
-@ISA = qw(Exporter);
-
-@EXPORT = qw(context_flag constructor_flag
- encode_int encode_int_0 encode_null encode_oid
- encode_sequence encode_tagged_sequence
- encode_string encode_ip_address encode_timeticks
- encode_uinteger32 encode_counter32 encode_counter64
- encode_gauge32
- decode_sequence decode_by_template
- pretty_print pretty_print_timeticks
- hex_string hex_string_of_type
- encoded_oid_prefix_p errmsg
- register_pretty_printer unregister_pretty_printer);
-
-### Variables
-
-## Bind this to zero if you want to avoid that TimeTicks are converted
-## into "human readable" strings containing days, hours, minutes and
-## seconds.
-##
-## If the variable is zero, pretty_print will simply return an
-## unsigned integer representing hundredths of seconds.
-##
-$pretty_print_timeticks = 1;
-
-### Prototypes
-sub encode_header ($$);
-sub encode_int_0 ();
-sub encode_int ($);
-sub encode_oid (@);
-sub encode_null ();
-sub encode_sequence (@);
-sub encode_tagged_sequence ($@);
-sub encode_string ($);
-sub encode_ip_address ($);
-sub encode_timeticks ($);
-sub pretty_print ($);
-sub pretty_using_decoder ($$);
-sub pretty_string ($);
-sub pretty_intlike ($);
-sub pretty_unsignedlike ($);
-sub pretty_oid ($);
-sub pretty_uptime ($);
-sub pretty_uptime_value ($);
-sub pretty_ip_address ($);
-sub pretty_generic_sequence ($);
-sub register_pretty_printer ($);
-sub unregister_pretty_printer ($);
-sub hex_string ($);
-sub hex_string_of_type ($$);
-sub decode_oid ($);
-sub decode_by_template;
-sub decode_by_template_2;
-sub decode_sequence ($);
-sub decode_int ($);
-sub decode_intlike ($);
-sub decode_unsignedlike ($);
-sub decode_intlike_s ($$);
-sub decode_string ($);
-sub decode_length ($@);
-sub encoded_oid_prefix_p ($$);
-sub decode_subid ($$$);
-sub decode_generic_tlv ($);
-sub error (@);
-sub template_error ($$$);
-
-sub version () { $VERSION; }
-
-### Flags for different types of tags
-
-sub universal_flag { 0x00 }
-sub application_flag { 0x40 }
-sub context_flag { 0x80 }
-sub private_flag { 0xc0 }
-
-sub primitive_flag { 0x00 }
-sub constructor_flag { 0x20 }
-
-### Universal tags
-
-sub boolean_tag { 0x01 }
-sub int_tag { 0x02 }
-sub bit_string_tag { 0x03 }
-sub octet_string_tag { 0x04 }
-sub null_tag { 0x05 }
-sub object_id_tag { 0x06 }
-sub sequence_tag { 0x10 }
-sub set_tag { 0x11 }
-sub uptime_tag { 0x43 }
-
-### Flag for length octet announcing multi-byte length field
-
-sub long_length { 0x80 }
-
-### SNMP specific tags
-
-sub snmp_ip_address_tag { 0x00 | application_flag () }
-sub snmp_counter32_tag { 0x01 | application_flag () }
-sub snmp_gauge32_tag { 0x02 | application_flag () }
-sub snmp_timeticks_tag { 0x03 | application_flag () }
-sub snmp_opaque_tag { 0x04 | application_flag () }
-sub snmp_nsap_address_tag { 0x05 | application_flag () }
-sub snmp_counter64_tag { 0x06 | application_flag () }
-sub snmp_uinteger32_tag { 0x07 | application_flag () }
-
-## Error codes (SNMPv2 and later)
-##
-sub snmp_nosuchobject { context_flag () | 0x00 }
-sub snmp_nosuchinstance { context_flag () | 0x01 }
-sub snmp_endofmibview { context_flag () | 0x02 }
-
-### pretty-printer initialization code. Create a hash with
-### the most common types of pretty-printer routines.
-
-BEGIN {
- $default_printer{int_tag()} = \&pretty_intlike;
- $default_printer{snmp_counter32_tag()} = \&pretty_unsignedlike;
- $default_printer{snmp_gauge32_tag()} = \&pretty_unsignedlike;
- $default_printer{snmp_counter64_tag()} = \&pretty_unsignedlike;
- $default_printer{snmp_uinteger32_tag()} = \&pretty_unsignedlike;
- $default_printer{octet_string_tag()} = \&pretty_string;
- $default_printer{object_id_tag()} = \&pretty_oid;
- $default_printer{snmp_ip_address_tag()} = \&pretty_ip_address;
-
- %pretty_printer = %default_printer;
-}
-
-#### Encoding
-
-sub encode_header ($$) {
- my ($type,$length) = @_;
- return pack ("C C", $type, $length) if $length < 128;
- return pack ("C C C", $type, long_length | 1, $length) if $length < 256;
- return pack ("C C n", $type, long_length | 2, $length) if $length < 65536;
- return error ("Cannot encode length $length yet");
-}
-
-sub encode_int_0 () {
- return pack ("C C C", 2, 1, 0);
-}
-
-sub encode_int ($) {
- return encode_intlike ($_[0], int_tag);
-}
-
-sub encode_uinteger32 ($) {
- return encode_intlike ($_[0], snmp_uinteger32_tag);
-}
-
-sub encode_counter32 ($) {
- return encode_intlike ($_[0], snmp_counter32_tag);
-}
-
-sub encode_counter64 ($) {
- return encode_intlike ($_[0], snmp_counter64_tag);
-}
-
-sub encode_gauge32 ($) {
- return encode_intlike ($_[0], snmp_gauge32_tag);
-}
-
-sub encode_intlike ($$) {
- my ($int, $tag)=@_;
- my ($sign, $val, @vals);
- $sign = ($int >= 0) ? 0 : 0xff;
- if (ref $int && $int->isa ("Math::BigInt")) {
- for(;;) {
- $val = $int->copy()->bmod (256);
- unshift(@vals, $val);
- return encode_header ($tag, $#vals + 1).pack ("C*", @vals)
- if ($int >= -128 && $int < 128);
- $int->bsub ($sign)->bdiv (256);
- }
- } else {
- for(;;) {
- $val = $int & 0xff;
- unshift(@vals, $val);
- return encode_header ($tag, $#vals + 1).pack ("C*", @vals)
- if ($int >= -128 && $int < 128);
- $int -= $sign, $int = int($int / 256);
- }
- }
-}
-
-sub encode_oid (@) {
- my @oid = @_;
- my ($result,$subid);
-
- $result = '';
- ## Ignore leading empty sub-ID. The favourite reason for
- ## those to occur is that people cut&paste numeric OIDs from
- ## CMU/UCD SNMP including the leading dot.
- shift @oid if $oid[0] eq '';
-
- return error ("Object ID too short: ", join('.',@oid))
- if $#oid < 1;
- ## The first two subids in an Object ID are encoded as a single
- ## byte in BER, according to a funny convention. This poses
- ## restrictions on the ranges of those subids. In the past, I
- ## didn't check for those. But since so many people try to use
- ## OIDs in CMU/UCD SNMP's format and leave out the mib-2 or
- ## enterprises prefix, I introduced this check to catch those
- ## errors.
- ##
- return error ("first subid too big in Object ID ", join('.',@oid))
- if $oid[0] > 2;
- $result = shift (@oid) * 40;
- $result += shift @oid;
- return error ("second subid too big in Object ID ", join('.',@oid))
- if $result > 255;
- $result = pack ("C", $result);
- foreach $subid (@oid) {
- if ( ($subid>=0) && ($subid<128) ){ #7 bits long subid
- $result .= pack ("C", $subid);
- } elsif ( ($subid>=128) && ($subid<16384) ){ #14 bits long subid
- $result .= pack ("CC", 0x80 | $subid >> 7, $subid & 0x7f);
- }
- elsif ( ($subid>=16384) && ($subid<2097152) ) {#21 bits long subid
- $result .= pack ("CCC",
- 0x80 | (($subid>>14) & 0x7f),
- 0x80 | (($subid>>7) & 0x7f),
- $subid & 0x7f);
- } elsif ( ($subid>=2097152) && ($subid<268435456) ){ #28 bits long subid
- $result .= pack ("CCCC",
- 0x80 | (($subid>>21) & 0x7f),
- 0x80 | (($subid>>14) & 0x7f),
- 0x80 | (($subid>>7) & 0x7f),
- $subid & 0x7f);
- } elsif ( ($subid>=268435456) && ($subid<4294967296) ){ #32 bits long subid
- $result .= pack ("CCCCC",
- 0x80 | (($subid>>28) & 0x0f), #mask the bits beyond 32
- 0x80 | (($subid>>21) & 0x7f),
- 0x80 | (($subid>>14) & 0x7f),
- 0x80 | (($subid>>7) & 0x7f),
- $subid & 0x7f);
- } else {
- return error ("Cannot encode subid $subid");
- }
- }
- encode_header (object_id_tag, length $result).$result;
-}
-
-sub encode_null () { encode_header (null_tag, 0); }
-sub encode_sequence (@) { encode_tagged_sequence (sequence_tag, @_); }
-
-sub encode_tagged_sequence ($@) {
- my ($tag,$result);
-
- $tag = shift @_;
- $result = join '',@_;
- return encode_header ($tag | constructor_flag, length $result).$result;
-}
-
-sub encode_string ($) {
- my ($string)=@_;
- return encode_header (octet_string_tag, length $string).$string;
-}
-
-sub encode_ip_address ($) {
- my ($addr)=@_;
- my @octets;
-
- if (length $addr == 4) {
- ## Four bytes... let's suppose that this is a binary IP address
- ## in network byte order.
- return encode_header (snmp_ip_address_tag, length $addr).$addr;
- } elsif (@octets = ($addr =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/)) {
- return encode_ip_address (pack ("CCCC", @octets));
- } else {
- return error ("IP address must be four bytes long or a dotted-quad");
- }
-}
-
-sub encode_timeticks ($) {
- my ($tt) = @_;
- return encode_intlike ($tt, snmp_timeticks_tag);
-}
-
-#### Decoding
-
-sub pretty_print ($) {
- my ($packet) = @_;
- return undef unless defined $packet;
- my $result = ord (substr ($packet, 0, 1));
- if (exists ($pretty_printer{$result})) {
- my $c_ref = $pretty_printer{$result};
- return &$c_ref ($packet);
- }
- return ($pretty_print_timeticks
- ? pretty_uptime ($packet)
- : pretty_unsignedlike ($packet))
- if $result == uptime_tag;
- return "(null)" if $result == null_tag;
- return error ("Exception code: noSuchObject") if $result == snmp_nosuchobject;
- return error ("Exception code: noSuchInstance") if $result == snmp_nosuchinstance;
- return error ("Exception code: endOfMibView") if $result == snmp_endofmibview;
-
- # IlvJa
- # pretty print sequences and their contents.
-
- my $ctx_cons_flags = context_flag | constructor_flag;
-
- if($result == (&constructor_flag | &sequence_tag) # sequence
- || $result == (0 | $ctx_cons_flags) #get_request
- || $result == (1 | $ctx_cons_flags) #getnext_request
- || $result == (2 | $ctx_cons_flags) #response
- || $result == (3 | $ctx_cons_flags) #set_request
- || $result == (4 | $ctx_cons_flags) #trap_request
- || $result == (5 | $ctx_cons_flags) #getbulk_request
- || $result == (6 | $ctx_cons_flags) #inform_request
- || $result == (7 | $ctx_cons_flags) #trap2_request
- )
- {
- my $pretty_result = pretty_generic_sequence($packet);
- $pretty_result =~ s/^/ /gm; #Indent.
-
- my $seq_type_desc =
- {
- (constructor_flag | sequence_tag) => "Sequence",
- (0 | $ctx_cons_flags) => "GetRequest",
- (1 | $ctx_cons_flags) => "GetNextRequest",
- (2 | $ctx_cons_flags) => "Response",
- (3 | $ctx_cons_flags) => "SetRequest",
- (4 | $ctx_cons_flags) => "Trap",
- (5 | $ctx_cons_flags) => "GetBulkRequest",
- (6 | $ctx_cons_flags) => "InformRequest",
- (7 | $ctx_cons_flags) => "SNMPv2-Trap",
- (8 | $ctx_cons_flags) => "Report",
- }->{($result)};
-
- return $seq_type_desc . "{\n" . $pretty_result . "\n}";
- }
-
- return sprintf ("#<unprintable BER type 0x%x>", $result);
-}
-
-sub pretty_using_decoder ($$) {
- my ($decoder, $packet) = @_;
- my ($decoded,$rest);
- ($decoded,$rest) = &$decoder ($packet);
- return error ("Junk after object") unless $rest eq '';
- return $decoded;
-}
-
-sub pretty_string ($) {
- pretty_using_decoder (\&decode_string, $_[0]);
-}
-
-sub pretty_intlike ($) {
- my $decoded = pretty_using_decoder (\&decode_intlike, $_[0]);
- $decoded;
-}
-
-sub pretty_unsignedlike ($) {
- return pretty_using_decoder (\&decode_unsignedlike, $_[0]);
-}
-
-sub pretty_oid ($) {
- my ($oid) = shift;
- my ($result,$subid,$next);
- my (@oid);
- $result = ord (substr ($oid, 0, 1));
- return error ("Object ID expected") unless $result == object_id_tag;
- ($result, $oid) = decode_length ($oid, 1);
- return error ("inconsistent length in OID") unless $result == length $oid;
- @oid = ();
- $subid = ord (substr ($oid, 0, 1));
- push @oid, int ($subid / 40);
- push @oid, $subid % 40;
- $oid = substr ($oid, 1);
- while ($oid ne '') {
- $subid = ord (substr ($oid, 0, 1));
- if ($subid < 128) {
- $oid = substr ($oid, 1);
- push @oid, $subid;
- } else {
- $next = $subid;
- $subid = 0;
- while ($next >= 128) {
- $subid = ($subid << 7) + ($next & 0x7f);
- $oid = substr ($oid, 1);
- $next = ord (substr ($oid, 0, 1));
- }
- $subid = ($subid << 7) + $next;
- $oid = substr ($oid, 1);
- push @oid, $subid;
- }
- }
- join ('.', @oid);
-}
-
-sub pretty_uptime ($) {
- my ($packet,$uptime);
-
- ($uptime,$packet) = &decode_unsignedlike (@_);
- pretty_uptime_value ($uptime);
-}
-
-sub pretty_uptime_value ($) {
- my ($uptime) = @_;
- my ($seconds,$minutes,$hours,$days,$result);
- ## We divide the uptime by hundred since we're not interested in
- ## sub-second precision.
- $uptime = int ($uptime / 100);
-
- $days = int ($uptime / (60 * 60 * 24));
- $uptime %= (60 * 60 * 24);
-
- $hours = int ($uptime / (60 * 60));
- $uptime %= (60 * 60);
-
- $minutes = int ($uptime / 60);
- $seconds = $uptime % 60;
-
- if ($days == 0){
- $result = sprintf ("%d:%02d:%02d", $hours, $minutes, $seconds);
- } elsif ($days == 1) {
- $result = sprintf ("%d day, %d:%02d:%02d",
- $days, $hours, $minutes, $seconds);
- } else {
- $result = sprintf ("%d days, %d:%02d:%02d",
- $days, $hours, $minutes, $seconds);
- }
- return $result;
-}
-
-
-sub pretty_ip_address ($) {
- my $pdu = shift;
- my ($length, $rest);
- return error ("IP Address tag (".snmp_ip_address_tag.") expected")
- unless ord (substr ($pdu, 0, 1)) == snmp_ip_address_tag;
- ($length,$pdu) = decode_length ($pdu, 1);
- return error ("Length of IP address should be four")
- unless $length == 4;
- sprintf "%d.%d.%d.%d", unpack ("CCCC", $pdu);
-}
-
-# IlvJa
-# Returns a string with the pretty prints of all
-# the elements in the sequence.
-sub pretty_generic_sequence ($) {
- my ($pdu) = shift;
-
- my $rest;
-
- my $type = ord substr ($pdu, 0 ,1);
- my $flags = context_flag | constructor_flag;
-
- return error (sprintf ("Tag 0x%x is not a valid sequence tag",$type))
- unless ($type == (&constructor_flag | &sequence_tag) # sequence
- || $type == (0 | $flags) #get_request
- || $type == (1 | $flags) #getnext_request
- || $type == (2 | $flags) #response
- || $type == (3 | $flags) #set_request
- || $type == (4 | $flags) #trap_request
- || $type == (5 | $flags) #getbulk_request
- || $type == (6 | $flags) #inform_request
- || $type == (7 | $flags) #trap2_request
- );
-
- my $curelem;
- my $pretty_result; # Holds the pretty printed sequence.
- my $pretty_elem; # Holds the pretty printed current elem.
- my $first_elem = 'true';
-
- # Cut away the first Tag and Length from $packet and then
- # init $rest with that.
- (undef, $rest) = decode_length ($pdu, 1);
- while($rest)
- {
- ($curelem,$rest) = decode_generic_tlv($rest);
- $pretty_elem = pretty_print($curelem);
-
- $pretty_result .= "\n" if not $first_elem;
- $pretty_result .= $pretty_elem;
-
- # The rest of the iterations are not related to the
- # first element of the sequence so..
- $first_elem = '' if $first_elem;
- }
- return $pretty_result;
-}
-
-sub hex_string ($) {
- &hex_string_of_type ($_[0], octet_string_tag);
-}
-
-sub hex_string_of_type ($$) {
- my ($pdu, $wanted_type) = @_;
- my ($length);
- return error ("BER tag ".$wanted_type." expected")
- unless ord (substr ($pdu, 0, 1)) == $wanted_type;
- ($length,$pdu) = decode_length ($pdu, 1);
- hex_string_aux ($pdu);
-}
-
-sub hex_string_aux ($) {
- my ($binary_string) = @_;
- my ($c, $result);
- $result = '';
- for $c (unpack "C*", $binary_string) {
- $result .= sprintf "%02x", $c;
- }
- $result;
-}
-
-sub decode_oid ($) {
- my ($pdu) = @_;
- my ($result,$pdu_rest);
- my (@result);
- $result = ord (substr ($pdu, 0, 1));
- return error ("Object ID expected") unless $result == object_id_tag;
- ($result, $pdu_rest) = decode_length ($pdu, 1);
- return error ("Short PDU")
- if $result > length $pdu_rest;
- @result = (substr ($pdu, 0, $result + (length ($pdu) - length ($pdu_rest))),
- substr ($pdu_rest, $result));
- @result;
-}
-
-# IlvJa
-# This takes a PDU and returns a two element list consisting of
-# the first element found in the PDU (whatever it is) and the
-# rest of the PDU
-sub decode_generic_tlv ($) {
- my ($pdu) = @_;
- my (@result);
- my ($elemlength,$pdu_rest) = decode_length ($pdu, 1);
- @result = (# Extract the first element.
- substr ($pdu, 0, $elemlength + (length ($pdu)
- - length ($pdu_rest)
- )
- ),
- #Extract the rest of the PDU.
- substr ($pdu_rest, $elemlength)
- );
- @result;
-}
-
-sub decode_by_template {
- my ($pdu) = shift;
- local ($_) = shift;
- return decode_by_template_2 ($pdu, $_, 0, 0, @_);
-}
-
-my $template_debug = 0;
-
-sub decode_by_template_2 {
- my ($pdu, $template, $pdu_index, $template_index);
- local ($_);
- $pdu = shift;
- $template = $_ = shift;
- $pdu_index = shift;
- $template_index = shift;
- my (@results);
- my ($length,$expected,$read,$rest);
- return undef unless defined $pdu;
- while (0 < length ($_)) {
- if (substr ($_, 0, 1) eq '%') {
- print STDERR "template $_ ", length $pdu," bytes remaining\n"
- if $template_debug;
- $_ = substr ($_,1);
- ++$template_index;
- if (($expected) = /^(\d*|\*)\{(.*)/) {
- ## %{
- $template_index += length ($expected) + 1;
- print STDERR "%{\n" if $template_debug;
- $_ = $2;
- $expected = shift | constructor_flag if ($expected eq '*');
- $expected = sequence_tag | constructor_flag
- if $expected eq '';
- return template_error ("Unexpected end of PDU",
- $template, $template_index)
- if !defined $pdu or $pdu eq '';
- return template_error ("Expected sequence tag $expected, got ".
- ord (substr ($pdu, 0, 1)),
- $template,
- $template_index)
- unless (ord (substr ($pdu, 0, 1)) == $expected);
- (($length,$pdu) = decode_length ($pdu, 1))
- || return template_error ("cannot read length",
- $template, $template_index);
- return template_error ("Expected length $length, got ".length $pdu ,
- $template, $template_index)
- unless length $pdu == $length;
- } elsif (($expected,$rest) = /^(\*|)s(.*)/) {
- ## %s
- $template_index += length ($expected) + 1;
- ($expected = shift) if $expected eq '*';
- (($read,$pdu) = decode_string ($pdu))
- || return template_error ("cannot read string",
- $template, $template_index);
- print STDERR "%s => $read\n" if $template_debug;
- if ($expected eq '') {
- push @results, $read;
- } else {
- return template_error ("Expected $expected, read $read",
- $template, $template_index)
- unless $expected eq $read;
- }
- $_ = $rest;
- } elsif (($rest) = /^A(.*)/) {
- ## %A
- $template_index += 1;
- {
- my ($tag, $length, $value);
- $tag = ord (substr ($pdu, 0, 1));
- return error ("Expected IP address, got tag ".$tag)
- unless $tag == snmp_ip_address_tag;
- ($length, $pdu) = decode_length ($pdu, 1);
- return error ("Inconsistent length of InetAddress encoding")
- if $length > length $pdu;
- return template_error ("IP address must be four bytes long",
- $template, $template_index)
- unless $length == 4;
- $read = substr ($pdu, 0, $length);
- $pdu = substr ($pdu, $length);
- }
- print STDERR "%A => $read\n" if $template_debug;
- push @results, $read;
- $_ = $rest;
- } elsif (/^O(.*)/) {
- ## %O
- $template_index += 1;
- $_ = $1;
- (($read,$pdu) = decode_oid ($pdu))
- || return template_error ("cannot read OID",
- $template, $template_index);
- print STDERR "%O => ".pretty_oid ($read)."\n"
- if $template_debug;
- push @results, $read;
- } elsif (($expected,$rest) = /^(\d*|\*|)i(.*)/) {
- ## %i
- $template_index += length ($expected) + 1;
- print STDERR "%i\n" if $template_debug;
- $_ = $rest;
- (($read,$pdu) = decode_int ($pdu))
- || return template_error ("cannot read int",
- $template, $template_index);
- if ($expected eq '') {
- push @results, $read;
- } else {
- $expected = int (shift) if $expected eq '*';
- return template_error (sprintf ("Expected %d (0x%x), got %d (0x%x)",
- $expected, $expected, $read, $read),
- $template, $template_index)
- unless ($expected == $read)
- }
- } elsif (($rest) = /^u(.*)/) {
- ## %u
- $template_index += 1;
- print STDERR "%u\n" if $template_debug;
- $_ = $rest;
- (($read,$pdu) = decode_unsignedlike ($pdu))
- || return template_error ("cannot read uptime",
- $template, $template_index);
- push @results, $read;
- } elsif (/^\@(.*)/) {
- ## %@
- $template_index += 1;
- print STDERR "%@\n" if $template_debug;
- $_ = $1;
- push @results, $pdu;
- $pdu = '';
- } else {
- return template_error ("Unknown decoding directive in template: $_",
- $template, $template_index);
- }
- } else {
- if (substr ($_, 0, 1) ne substr ($pdu, 0, 1)) {
- return template_error ("Expected ".substr ($_, 0, 1).", got ".substr ($pdu, 0, 1),
- $template, $template_index);
- }
- $_ = substr ($_,1);
- $pdu = substr ($pdu,1);
- }
- }
- return template_error ("PDU too long", $template, $template_index)
- if length ($pdu) > 0;
- return template_error ("PDU too short", $template, $template_index)
- if length ($_) > 0;
- @results;
-}
-
-sub decode_sequence ($) {
- my ($pdu) = @_;
- my ($result);
- my (@result);
- $result = ord (substr ($pdu, 0, 1));
- return error ("Sequence expected")
- unless $result == (sequence_tag | constructor_flag);
- ($result, $pdu) = decode_length ($pdu, 1);
- return error ("Short PDU")
- if $result > length $pdu;
- @result = (substr ($pdu, 0, $result), substr ($pdu, $result));
- @result;
-}
-
-sub decode_int ($) {
- my ($pdu) = @_;
- my $tag = ord (substr ($pdu, 0, 1));
- return error ("Integer expected, found tag ".$tag)
- unless $tag == int_tag;
- decode_intlike ($pdu);
-}
-
-sub decode_intlike ($) {
- decode_intlike_s ($_[0], 1);
-}
-
-sub decode_unsignedlike ($) {
- decode_intlike_s ($_[0], 0);
-}
-
-my $have_math_bigint_p = 0;
-
-sub decode_intlike_s ($$) {
- my ($pdu, $signedp) = @_;
- my ($length,$result);
- ($length,$pdu) = decode_length ($pdu, 1);
- my $ptr = 0;
- $result = unpack ($signedp ? "c" : "C", substr ($pdu, $ptr++, 1));
- if ($length > 5 || ($length == 5 && $result > 0)) {
- require 'Math/BigInt.pm' unless $have_math_bigint_p++;
- $result = new Math::BigInt ($result);
- }
- while (--$length > 0) {
- $result *= 256;
- $result += unpack ("C", substr ($pdu, $ptr++, 1));
- }
- ($result, substr ($pdu, $ptr));
-}
-
-sub decode_string ($) {
- my ($pdu) = shift;
- my ($result);
- $result = ord (substr ($pdu, 0, 1));
- return error ("Expected octet string, got tag ".$result)
- unless $result == octet_string_tag;
- ($result, $pdu) = decode_length ($pdu, 1);
- return error ("Short PDU")
- if $result > length $pdu;
- return (substr ($pdu, 0, $result), substr ($pdu, $result));
-}
-
-sub decode_length ($@) {
- my ($pdu) = shift;
- my $index = shift || 0;
- my ($result);
- my (@result);
- $result = ord (substr ($pdu, $index, 1));
- if ($result & long_length) {
- if ($result == (long_length | 1)) {
- @result = (ord (substr ($pdu, $index+1, 1)), substr ($pdu, $index+2));
- } elsif ($result == (long_length | 2)) {
- @result = ((ord (substr ($pdu, $index+1, 1)) << 8)
- + ord (substr ($pdu, $index+2, 1)), substr ($pdu, $index+3));
- } else {
- return error ("Unsupported length");
- }
- } else {
- @result = ($result, substr ($pdu, $index+1));
- }
- @result;
-}
-
-# This takes a hashref that specifies functions to call when
-# the specified value type is being printed. It returns the
-# number of functions that were registered.
-sub register_pretty_printer($)
-{
- my ($h_ref) = shift;
- my ($type, $val, $cnt);
-
- $cnt = 0;
- while(($type, $val) = each %$h_ref) {
- if (ref $val eq "CODE") {
- $pretty_printer{$type} = $val;
- $cnt++;
- }
- }
- return($cnt);
-}
-
-# This takes a hashref that specifies functions to call when
-# the specified value type is being printed. It removes the
-# functions from the list for the types specified.
-# It returns the number of functions that were unregistered.
-sub unregister_pretty_printer($)
-{
- my ($h_ref) = shift;
- my ($type, $val, $cnt);
-
- $cnt = 0;
- while(($type, $val) = each %$h_ref) {
- if ((exists ($pretty_printer{$type}))
- && ($pretty_printer{$type} == $val)) {
- if (exists($default_printer{$type})) {
- $pretty_printer{$type} = $default_printer{$type};
- } else {
- delete $pretty_printer{$type};
- }
- $cnt++;
- }
- }
- return($cnt);
-}
-
-#### OID prefix check
-
-### encoded_oid_prefix_p OID1 OID2
-###
-### OID1 and OID2 should be BER-encoded OIDs.
-### The function returns non-zero iff OID1 is a prefix of OID2.
-### This can be used in the termination condition of a loop that walks
-### a table using GetNext or GetBulk.
-###
-sub encoded_oid_prefix_p ($$) {
- my ($oid1, $oid2) = @_;
- my ($i1, $i2);
- my ($l1, $l2);
- my ($subid1, $subid2);
- return error ("OID tag expected") unless ord (substr ($oid1, 0, 1)) == object_id_tag;
- return error ("OID tag expected") unless ord (substr ($oid2, 0, 1)) == object_id_tag;
- ($l1,$oid1) = decode_length ($oid1, 1);
- ($l2,$oid2) = decode_length ($oid2, 1);
- for ($i1 = 0, $i2 = 0;
- $i1 < $l1 && $i2 < $l2;
- ++$i1, ++$i2) {
- ($subid1,$i1) = &decode_subid ($oid1, $i1, $l1);
- ($subid2,$i2) = &decode_subid ($oid2, $i2, $l2);
- return 0 unless $subid1 == $subid2;
- }
- return $i2 if $i1 == $l1;
- return 0;
-}
-
-### decode_subid OID INDEX
-###
-### Decodes a subid field from a BER-encoded object ID.
-### Returns two values: the field, and the index of the last byte that
-### was actually decoded.
-###
-sub decode_subid ($$$) {
- my ($oid, $i, $l) = @_;
- my $subid = 0;
- my $next;
-
- while (($next = ord (substr ($oid, $i, 1))) >= 128) {
- $subid = ($subid << 7) + ($next & 0x7f);
- ++$i;
- return error ("decoding object ID: short field")
- unless $i < $l;
- }
- return (($subid << 7) + $next, $i);
-}
-
-sub error (@) {
- $errmsg = join ("",@_);
- return undef;
-}
-
-sub template_error ($$$) {
- my ($errmsg, $template, $index) = @_;
- return error ($errmsg."\n ".$template."\n ".(' ' x $index)."^");
-}
-
-1;
diff --git a/src/lib/mrtg2/MRTG_lib.pm b/src/lib/mrtg2/MRTG_lib.pm
deleted file mode 100644
index ff3d7e1..0000000
--- a/src/lib/mrtg2/MRTG_lib.pm
+++ /dev/null
@@ -1,2368 +0,0 @@
-# -*- mode: Perl -*-
-package MRTG_lib;
-###################################################################
-# MRTG 2.17.7 Support library MRTG_lib.pm
-###################################################################
-# Created by Tobias Oetiker <tobi@oetiker.ch>
-# and Dave Rand <dlr@bungi.com>
-#
-# For individual Contributers check the CHANGES file
-#
-###################################################################
-#
-# Distributed under the GNU General Public License
-#
-###################################################################
-
-require 5.005;
-use strict;
-use vars qw($OS $SL $PS @EXPORT @ISA $VERSION %timestrpospattern);
-
-
-my %mrtgrules;
-
-BEGIN {
- # Automatic OS detection ... do NOT touch
- if ( $^O =~ /^(?:(ms)?(dos|win(32|nt)?))/i ) {
- $OS = 'NT';
- $SL = '\\';
- $PS = ';';
- } elsif ( $^O =~ /^NetWare$/i ) {
- $OS = 'NW';
- $SL = '/';
- $PS = ';';
- } elsif ( $^O =~ /^VMS$/i ) {
- $OS = 'VMS';
- $SL = '.';
- $PS = ':';
- } elsif ( $^O =~ /^os2$/i ) {
- $OS = 'OS2';
- $SL = '/';
- $PS = ';';
- } else {
- $OS = 'UNIX';
- $SL = '/';
- $PS = ':';
- }
-}
-
-require Exporter;
-@ISA = qw(Exporter);
-@EXPORT = qw(readcfg cfgcheck setup_loghandlers
- datestr expistr ensureSL timestamp
- create_pid demonize_me debug log2rrd storeincache readfromcache clearfromcache cleanhostkey
- populateconfcache readconfcache writeconfcache
- v4onlyifnecessary);
-
-$VERSION = 2.100016;
-
-%timestrpospattern =
- (
- 'NO' => 0,
- 'LU' => 1,
- 'RU' => 2,
- 'LL' => 3,
- 'RL' => 4
- );
-
-%mrtgrules =
- ( # General CFG
- 'workdir' =>
- [sub{$_[0] && (-d $_[0])}, sub{"Working directory $_[0] does not exist"}],
-
- 'htmldir' =>
- [sub{$_[0] && (-d $_[0])}, sub{"Html directory $_[0] does not exist"}],
-
- 'imagedir' =>
- [sub{$_[0] && (-d $_[0])}, sub{"Image directory $_[0] does not exist"}],
-
- 'logdir' =>
- [sub{$_[0] && (-d $_[0] )}, sub{"Log directory $_[0] does not exist"}],
-
- 'forks' =>
- [sub{$_[0] && (int($_[0]) > 0 and $MRTG_lib::OS eq 'UNIX')},
- sub{"Less than 1 fork or not running on Unix/Linux"}],
-
- 'refresh' =>
- [sub{int($_[0]) >= 300}, sub{"$_[0] should be 300 seconds or more"}],
-
- 'enablesnmpv3' =>
- [sub{((lc($_[0])) eq 'yes' or (lc($_[0])) eq 'no')}, sub{"$_[0] must be yes or no"}],
-
- 'enableipv6' =>
- [sub{((lc($_[0])) eq 'yes' or (lc($_[0])) eq 'no')}, sub{"$_[0] must be yes or no"}],
-
- 'interval' =>
- [sub{$_[0] =~ /(\d+)(?::(\d+))?/ ;
- my $int = $1*60; $int += $2 if $2;
- $int >= 1 and $int <= 60*60}, sub{"$_[0] should be at least 1 Second (0:01) and no more than 60 Minutes (60)"}],
-
- 'writeexpires' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'nomib2' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'singlerequest' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'icondir' =>
- [sub{$_[0]}, sub{"Directory argument missing"}],
-
- 'language' =>
- [sub{1}, sub{"Mrtg not localized for $_[0] - defaulting to english"}],
-
- 'loadmibs' =>
- [sub{$_[0]}, sub{"No MIB Files specified"}],
-
- 'userrdtool' =>
- [sub{0}, sub{"UseRRDtool is not valid any more. Use LogFormat, PathAdd and LibAdd instead"}],
-
- 'userrdtool[]' =>
- [sub{0}, sub{"UseRRDtool[] is not valid any more. Check the new xyz*bla[] syntax for passing parameters to tool xyz who reads the mrtg.cfg"}],
-
- 'logformat' =>
- [sub{$_[0] =~ /^(rateup|rrdtool)$/}, sub{"Invalid Logformat '$_[0]'"}],
-
- 'pathadd' =>
- [sub{-d $_[0]}, sub{"$_[0] is not the name of a directory"}],
-
- 'libadd' =>
- [sub{-d $_[0]}, sub{"$_[0] is not the name of a directory"}],
-
- 'runasdaemon' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'nodetach' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'maxage' =>
- [sub{(($_[0] =~ /^[0-9]+$/) and ($_[0] > 0)) },
- sub{"$_[0] must be a Number bigger than 0"}],
-
- 'nospacechar' =>
- [sub{length($_[0]) == 1}, sub{"$_[0] must be one character long"}],
-
- 'snmpoptions' =>
- [sub{ debug('eval',"snmpotions $_[0]");local $SIG{__DIE__}; eval( '{'.$_[0].'}' ); return not $@},
- sub{"Must have the format \"OptA => Number, OptB => 'String', ... \""}],
-
- 'conversioncode' =>
- [sub{-r $_[0]}, sub{"Cannot read conversion code file $_[0]"}],
-
- # Check for an environment setting for RRDCACHED_ADDRESS
- # Steve Shipway, Sep 2010
- 'rrdcached' =>
-# [sub{(($_[0] =~ /^unix:(\S+)/)and(-w $1))}, sub{"Currently, only UNIX domain sockets are supported for RRDCached, and must exist and be writeable."}],
- [sub{1},sub{"Internal Error"}],
-
- # Get graphite server name/ip and port
- 'sendtographite' =>
- [sub{$_[0] =~ /^.*,\d+$/}, sub{"Invalid Graphite Destination '$_[0]'"}],
-
- # Per Router CFG
- 'target[]' =>
- [sub{1}, sub{"Internal Error"}], #will test this later
-
- 'snmpoptions[]' =>
- [sub{ debug('eval',"snmpotions[] $_[0]");local $SIG{__DIE__}; eval('{'.$_[0].'}' ); return not $@},
- sub{"Must have the format \"OptA => Number, OptB => 'String', ... \""}],
-
- 'routeruptime[]' =>
- [sub{1}, sub{"Internal Error"}], #will test this later
-
- 'routername[]' =>
- [sub{1}, sub{"Internal Error"}], #will test this later
-
- 'nohc[]' =>
- [sub{((lc($_[0])) eq 'yes' or (lc($_[0])) eq 'no')}, sub{"$_[0] must be yes or no"}],
-
- 'maxbytes[]' =>
- [sub{(($_[0] =~ /^[0-9]+$/) && ($_[0] > 0)) },
- sub{"$_[0] must be a Number bigger than 0"}],
-
- 'maxbytes1[]' =>
- [sub{(($_[0] =~ /^[0-9]+$/) && ($_[0] > 0))},
- sub{"$_[0] must be numerical and larger than 0"}],
-
- 'maxbytes2[]' =>
- [sub{(($_[0] =~ /^[0-9]+$/) && ($_[0] > 0))},
- sub{"$_[0] must a number bigger than 0"}],
-
- 'ipv4only[]' =>
- [sub{((lc($_[0])) eq 'yes' or (lc($_[0])) eq 'no')}, sub{"$_[0] must be yes or no"}],
-
- 'absmax[]' =>
- [sub{($_[0] =~ /^[0-9]+$/)}, sub{"$_[0] must be a Number"}],
-
- 'title[]' =>
- [sub{1}, sub{"Internal Error"}], #what ever the user chooses.
-
- 'directory[]' =>
- [sub{1}, sub{"Internal Error"}], #what ever the user chooses.
-
- 'clonedirectory[]' =>
- [sub{($_[0] =~ /[^,]\s*$/)}, sub{"$_[0] with comma must have the second parameter"}],
-
- 'pagetop[]' =>
- [sub{1}, sub{"Internal Error"}], #what ever the user chooses.
-
- 'bodytag[]' =>
- [sub{1}, sub{"Internal Error"}], #what ever the user chooses.
-
- 'pagefoot[]' =>
- [sub{1}, sub{"Internal Error"}], #what ever the user chooses.
-
- 'addhead[]' =>
- [sub{1}, sub{"Internal Error"}], #what ever the user chooses.
-
- 'rrdrowcount[]' =>
- [sub{1}, sub{"Internal Error"}], #what ever the user chooses.
-
- 'rrdrowcount30m[]' =>
- [sub{1}, sub{"Internal Error"}], #what ever the user chooses.
-
- 'rrdrowcount2h[]' =>
- [sub{1}, sub{"Internal Error"}], #what ever the user chooses.
-
- 'rrdrowcount1d[]' =>
- [sub{1}, sub{"Internal Error"}], #what ever the user chooses.
-
- 'rrdhwrras[]' =>
- [sub{$_[0] =~ /^RRA:(HWPREDICT|SEASONAL|DEVPREDICT|DEVSEASONAL|FAILURES):\S+(\s+RRA:(HWPREDICT|SEASONAL|DEVPREDICT|DEVSEASONAL|FAILURES):\S+)*$/},
- sub{"This does not look like rrdtool HW RRAs. Check the rrdcreate manual page for inspiration. ($_[0])"}],
-
- 'extension[]' =>
- [sub{1}, sub{"Internal Error"}], #what ever the user chooses.
-
- 'unscaled[]' =>
- [sub{$_[0] =~ /[ndwmy]+/i}, sub{"Must be a string of [n]one, [d]ay, [w]eek, [m]onth, [y]ear"}],
-
- 'weekformat[]' =>
- [sub{$_[0] =~ /[UVW]/}, sub{"Must be either W, V, or U"}],
-
- 'withpeak[]' =>
- [sub{$_[0] =~ /[ndwmy]+/i}, sub{"Must be a string of [n]one, [d]ay, [w]eek, [m]onth, [y]ear"}],
-
- 'suppress[]' =>
- [sub{$_[0] =~ /[ndwmy]+/i}, sub{"Must be a string of [n]one, [d]ay, [w]eek, [m]onth, [y]ear"}],
-
- 'xsize[]' =>
- [sub{((int($_[0]) >= 30) && (int($_[0]) <= 600))}, sub{"$_[0] must be between 30 and 600 pixels"}],
-
- 'ysize[]' =>
- [sub{(int($_[0]) >= 30)}, sub{"Must be >= 30 pixels"}],
-
- 'ytics[]' =>
- [sub{(int($_[0]) >= 1) }, sub{"Must be >= 1"}],
-
- 'yticsfactor[]' =>
- [sub{$_[0] =~ /[-+0-9.efg]+/}, sub{"Should be a numerical value"}],
-
- 'factor[]' =>
- [sub{$_[0] =~ /[-+0-9.efg]+/}, sub{"Should be a numerical value"}],
-
- 'step[]' =>
- [sub{(int($_[0]) >= 0)}, sub{"$_[0] must be > 0"}],
-
- 'timezone[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'options[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'colours[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'background[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'kilo[]' =>
- [sub{($_[0] =~ /^[0-9]+$/)}, sub{"$_[0] must be a Integer Number"}],
- #define whatever k should be (1000, 1024, ???)
-
- 'kmg[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'pngtitle[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'ylegend[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'shortlegend[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'legend1[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'legend2[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'legend3[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'legend4[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'legend5[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'legendi[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'legendo[]' =>
- [sub{1}, sub{"Internal Error"}],
-
- 'setenv[]' =>
- [sub{$_[0] =~ /^(?:[-\w]+=\"[^"]*"(?:\s+|$))+$/},
- sub{"$_[0] must be XY=\"dddd\" AASD=\"kjlkj\" ... "}],
-
-
- 'xzoom[]' =>
- [sub{($_[0] =~ /^[0-9]+(?:\.[0-9]+)?$/)},
- sub{"$_[0] must be a Number xxx.xxx"}],
-
- 'yzoom[]' =>
- [sub{($_[0] =~ /^[0-9]+(?:\.[0-9]+)?$/)},
- sub{"$_[0] must be a Number xxx.xxx"}],
-
- 'xscale[]' =>
- [sub{($_[0] =~ /^[0-9]+(?:\.[0-9]+)?$/)},
- sub{"$_[0] must be a Number xxx.xxx"}],
-
- 'yscale[]' =>
- [sub{($_[0] =~ /^[0-9]+(?:\.[0-9]+)?$/)},
- sub{"$_[0] must be a Number xxx.xxx"}],
-
- 'threshdir' =>
- [sub{$_[0] && (-d $_[0])}, sub{"Threshold directory $_[0] does not exist"}],
-
- 'threshhyst' =>
- [sub{($_[0] =~ /^[0-9]+(?:\.[0-9]+)?$/)},
- sub{"$_[0] must be a Number xxx.xxx"}],
-
- 'hwthreshhyst' =>
- [sub{($_[0] =~ /^[0-9]+(?:\.[0-9]+)?$/)},
- sub{"$_[0] must be a Number xxx.xxx"}],
-
- 'threshmailserver' =>
- [sub{$_[0] && gethostbyname($_[0])}, sub{"Unknown mailserver hostname $_[0]"}],
-
- 'threshmailsender' =>
- [sub{$_[0] && ($_[0] =~ /\S+\@\S+/)}, sub{"ThreshMailAddress $_[0] does not look like an email address at all"}],
-
- 'threshmini[]' =>
- [sub{1}, sub{"Internal Threshold Config Error"}],
-
- 'threshmino[]' =>
- [sub{1}, sub{"Internal Threshold Config Error"}],
-
- 'threshmaxi[]' =>
- [sub{1}, sub{"Internal Threshold Config Error"}],
-
- 'threshmaxo[]' =>
- [sub{1}, sub{"Internal Threshold Config Error"}],
-
- 'threshdesc[]' =>
- [sub{1}, sub{"Internal Threshold Config Error"}],
-
- 'threshprogi[]' =>
- [sub{$_[0] && (-e $_[0])}, sub{"Threshold program $_[0] cannot be executed"}],
-
- 'threshprogo[]' =>
- [sub{$_[0] && (-e $_[0])}, sub{"Threshold program $_[0] cannot be executed"}],
-
- 'threshprogoki[]' =>
- [sub{$_[0] && (-e $_[0])}, sub{"Threshold program $_[0] cannot be executed"}],
-
- 'threshprogoko[]' =>
- [sub{$_[0] && (-e $_[0])}, sub{"Threshold program $_[0] cannot be executed"}],
-
- 'threshmailaddress[]' =>
- [sub{$_[0] && ($_[0] =~ /\S+\@\S+/)}, sub{"ThreshMailAddress $_[0] does not look like an email address at all"}],
-
- 'hwthreshmini[]' =>
- [sub{1}, sub{"Internal Threshold Config Error"}],
-
- 'hwthreshmino[]' =>
- [sub{1}, sub{"Internal Threshold Config Error"}],
-
- 'hwthreshmaxi[]' =>
- [sub{1}, sub{"Internal Threshold Config Error"}],
-
- 'hwthreshmaxo[]' =>
- [sub{1}, sub{"Internal Threshold Config Error"}],
-
- 'hwthreshdesc[]' =>
- [sub{1}, sub{"Internal Threshold Config Error"}],
-
- 'hwthreshprogi[]' =>
- [sub{$_[0] && (-e $_[0])}, sub{"Threshold program $_[0] cannot be executed"}],
-
- 'hwthreshprogo[]' =>
- [sub{$_[0] && (-e $_[0])}, sub{"Threshold program $_[0] cannot be executed"}],
-
- 'hwthreshprogoki[]' =>
- [sub{$_[0] && (-e $_[0])}, sub{"Threshold program $_[0] cannot be executed"}],
-
- 'hwthreshprogoko[]' =>
- [sub{$_[0] && (-e $_[0])}, sub{"Threshold program $_[0] cannot be executed"}],
-
- 'hwthreshmailaddress[]' =>
- [sub{$_[0] && ($_[0] =~ /\S+\@\S+/)}, sub{"ThreshMailAddress $_[0] does not look like an email address at all"}],
-
- 'timestrpos[]' =>
- [sub{$_[0] =~ /^(no|[lr][ul])$/i}, sub{"Must be a string of NO, LU, RU, LL, RL"}],
-
- 'timestrfmt[]' =>
- [sub{1}, sub{"Internal Error"}] #what ever the user chooses.
-);
-
-
-# config file reading
-
-sub readcfg ($$$$;$$) {
- my $cfgfile = shift;
- my $routers = shift;
- my $cfg = shift;
- my $rcfg = shift;
- my $extprefix = shift || '';
- my $extrules = shift;
- my ($first,$second,$key,$userules);
- my (%seen);
- my (%pre,%post,%deflt,%defaulted);
- unless ($cfgfile) {
- die "ERROR: readfg: no configfile specified\n";
- }
- unless (ref($routers) eq 'ARRAY' and ref($cfg) eq 'HASH'
- and ref($rcfg) eq 'HASH') {
- die "ERROR: readcfg called with wrong arguments\n";
- }
- if ($extprefix and ref($extrules) ne 'HASH') {
- die "ERROR: readcfg called with wrong args for mrtg extension\n";
- }
- my $hand;
- my $file;
- my @filestack;
- local *CFG;
- if ($cfgfile eq '-'){$cfgfile = '<&STDIN'};
- open (CFG, $cfgfile) || die "ERROR: unable to open config file: $cfgfile\n";
- $hand = *CFG;
- my @handstack;
- my $nextfile = $cfgfile;
- my %routerhash;
- while (1) {
- if (eof $hand || not defined ($_ = <$hand>) ) {
- close $hand;
- if (scalar @handstack){
- $hand = pop @handstack;
- $nextfile = pop @filestack;
- next;
- } else {
- last;
- }
- }
- $file=$nextfile;
- chomp;
- my $line = $.;
- if (/^include:\s*(.*?\S)\s*$/i){
- my $newhandle;
- my @nextfiles;
- $nextfile = $1;
- if( $nextfile =~ /\*/ ) {
- @nextfiles = glob( $nextfile );
- @nextfiles = glob( ($cfgfile =~ m#(.+)${MRTG_lib::SL}[^${MRTG_lib::SL}]+$#)[0] . ${MRTG_lib::SL} . $nextfile )
- if(!@nextfiles);
- } else {
- $nextfile = ($cfgfile =~ m#(.+)${MRTG_lib::SL}[^${MRTG_lib::SL}]+$#)[0] . ${MRTG_lib::SL} . $nextfile
- if(!-r $nextfile);
- @nextfiles = ( $nextfile );
- }
- foreach $nextfile ( @nextfiles ) {
- open my $newhandle, '<', $nextfile or die "ERROR: unable to open include file: $nextfile\n";
- push @handstack, $hand;
- push @filestack, $file;
- $hand = $newhandle;
- $file = $nextfile;
- }
- next;
- }
-
- debug('cfg',"$file\[$.\]: $_");
-
- s/\t/ /g; #replace tab by space
- s/\r$//; # kill dos newlines ...
- s/ +$//g; #remove space at the end of the line
- next if /^ *\#/; #ignore comment lines
- next if /^ *$/; #ignore empty lines
- # oops spelling error
- s/^supress/suppress/gi;
-
-
- # the line we got starts with white space so it is to be appended to what ever
- # was on the previous line.
-
- if (defined $first && /^\s+(.*\S)\s*$/) {
- if (defined $second) {
- $second eq '^' && do { $pre{$first} .= "\n".$1; next};
- $second eq '$' && do { $post{$first} .= "\n".$1; next};
- $second eq '_' && do { $deflt{$first} .= "\n".$1; next};
- $$rcfg{$first}{$second} .= " ".$1;
- } else {
- $$cfg{$first} .= "\n".$1;
- }
- next;
- }
-
- if (defined $first && defined $second && defined $post{$first} && ($second !~ /^[\$^_]$/)) {
- if (defined $defaulted{$first}{$second}) {
- $$rcfg{$first}{$second} = $post{$first};
- delete $defaulted{$first}{$second};
- } else {
- $$rcfg{$first}{$second} .= ( defined $$cfg{nospacechar} and $post{$first} =~ /(.*)\Q$$cfg{nospacechar}\E$/) ? $1 : " ".$post{$first} ;
- }
- }
-
- if (defined $first and $first =~ m/^([^*]+)\*(.+)$/) {
- $userules = ($1 eq $extprefix ? $extrules : '');
- } else {
- $userules = \%mrtgrules;
- }
-
- if ($first && defined $deflt{$first} && ($second eq '_')) {
- quickcheck($first,$second,$deflt{$first},$file,$line,$userules)
- } elsif ($first && $second && ($second !~ /^[\$^_]$/)) {
- quickcheck($first,$second,$$rcfg{$first}{$second},$file,$line,$userules)
- } elsif ($first && not $second) {
- quickcheck($first,0,$$cfg{$first},$file, $line,$userules)
- }
-
- if (/^([A-Za-z0-9*]+)\[(\S+)\]\s*:\s*(.*\S?)\s*$/) {
- $first = lc($1);
- $second = lc($2);
- # For us spelling-handicapped Americans. ;)
- # James Overbeck, grendel@gmo.jp, 2003/01/19
- if ($first eq 'colors') { $first = 'colours' };
- if ($second eq '^') {
- if ($3 ne '') {
- $pre{$first}=$3;
- } else {
- delete $pre{$first};
- }
- next;
- }
- if ($second eq '$') {
- if ($3 ne '') {
- $post{$first}=$3;
- } else {
- delete $post{$first};
- }
- next;
- }
- if ($second eq '_') {
- if ($3 ne '') {
- $deflt{$first}=$3;
- } else {
- delete $deflt{$first};
- }
- next;
- }
-
- if (not defined $routerhash{$second}) {
- push (@{$routers}, $second);
- $routerhash{$second} = 1;
- }
-
- # make sure that default tags spring into existance upon first
- # call of a router
-
- foreach $key (keys %deflt) {
- if (! defined $$rcfg{$key}{$second}) {
- $$rcfg{$key}{$second} = $deflt{$key};
- $defaulted{$key}{$second} = 1;
- }
- }
-
- # make sure that prefix-only tags spring into existance upon first
- # call of a router
-
- foreach $key (keys %pre) {
- if (! defined $$rcfg{$key}{$second}) {
- delete $defaulted{$key}{$second} if $defaulted{$key}{$second};
- $$rcfg{$key}{$second} = ( defined $$cfg{nospacechar} && $pre{$key} =~ m/(.*)\Q$$cfg{nospacechar}\E$/ ) ? $1 : $pre{$key}." ";
- }
- }
-
- if ($seen{$first}{$second}) {
- die ("ERROR: Line $line ($_) in CFG file ($file)\n".
- "contains a duplicate definition for $first\[$second].\n".
- "First definition is on line $seen{$first}{$second}\n")
- } else {
- $seen{$first}{$second} = $line;
- }
-
- if ($defaulted{$first}{$second}) {
- $$rcfg{$first}{$second} = '';
- delete $defaulted{$first}{$second};
- }
- $$rcfg{$first}{$second} .= $3;
-
- next;
-
- }
- if (/^(\S+):\s*(.*\S)\s*$/) {
- $first = lc($1);
- $$cfg{$first} = $2;
- $second = '';
- next;
- }
- die "ERROR: Line $line ($_) in CFG file ($file) does not make sense\n";
- }
-
- # append $ stuff to the very last tag in cfg file if necessary
- if (defined $first && defined $second && defined $post{$first} && ($second !~ /^[\$^_]$/)) {
- if ($defaulted{$first}{$second}) {
- $$rcfg{$first}{$second} = $post{$first};
- delete $defaulted{$first}{$second};
- } else {
- $$rcfg{$first}{$second} .=
- ( defined $$cfg{'nospacechar'} && $post{$first} =~ /(.*)\Q$$cfg{nospacechar}\E$/ ) ? $1 : " ".$post{$first} ;
- }
- }
-
- #check the last input line
- if ($first =~ m/^([^*]+)\*(.+)$/) {
- $userules = ($1 eq $extprefix ? $extrules : '');
- } else {
- $userules = \%mrtgrules;
- }
- if ($first && defined $deflt{$first} && ($second eq '_')) {
- quickcheck($first,$second,$deflt{$first},$file,$.,$userules)
- } elsif ($first && $second && ($second !~ /^[\$^_]$/)) {
- quickcheck($first,$second,$$rcfg{$first}{$second},$file,$.,$userules)
- } elsif ($first && not $second) {
- quickcheck($first,0,$$cfg{$first},$file,$.,$userules)
- }
-
- close (CFG);
-
- # Check for an environment setting for RRDCACHED_ADDRESS
- # Steve Shipway, Sep 2010
- if( $ENV{RRDCACHED_ADDRESS} and not exists $cfg->{ rrdcached } ) {
- warn("WARNING: Using environment variable RRDCACHED_ADDRESS\n");
- $cfg->{ rrdcached } = $ENV{RRDCACHED_ADDRESS};
- quickcheck('rrdcached',0,$ENV{RRDCACHED_ADDRESS},'Environment variable RRDCACHED_ADDRESS','n/a',\%mrtgrules);
- }
- if( exists $cfg->{ rrdcached } ) {
- warn ("WARNING: You are running with RRDCached enabled (".$cfg->{ rrdcached }."). This will disable all Threshold checking, since RRDCached does not support updatev and an update/fetch will cancel out the caching benefits.\n");
- if( $cfg->{ rrdcached } !~ /^unix:/ ) {
- warn("WARNING: You are running RRDCached in TCP mode. This means that it will use its own Base Directory instead of WorkDir for storing the RRD files. Also, changes to MaxBytes and DS Type will not be actioned after the RRD file has been created.\n");
- }
- }
- if ($cfg->{enablesnmpv3} and $cfg->{enablesnmpv3} eq 'yes' and eval {local $SIG{__DIE__}; require Net_SNMP_util} ) {
- import Net_SNMP_util;
- } else {
- require SNMP_util;
- import SNMP_util;
- }
-}
-
-# quick checks
-
-sub quickcheck ($$$$$$) {
- my ($first,$second,$arg,$file,$line,$rules) = @_;
- return unless ref($rules) eq 'HASH';
- my $braces = $second ? '[]':'';
- if (exists $rules->{$first.$braces}) {
- if (&{$rules->{$first.$braces}[0]}($arg)) {
- return 1;
- } else {
- if ($second) {
- die "ERROR: CFG Error in \"$first\[$second\]\", file $file line $line: ".
- &{$rules->{$first.$braces}[1]}($arg)."\n\n";
- } else {
- die "ERROR: CFG Error in \"$first\", file $file line $line: ".
- &{$rules->{$first.$braces}[1]}($arg)."\n\n";
- }
- }
- }
- die "ERROR: CFG Error Unknown Option \"$first\" in file $file on line $line or above.\n".
- " Check /usr/share/doc/mrtg/mrtg-reference.txt.gz for Help\n\n";
-}
-
-# complex config checks
-
-sub mkdirhier ($){
- my @dirs = split /\Q${MRTG_lib::SL}\E+/, shift;
- my $path = "";
- while (@dirs){
- $path .= shift @dirs;
- $path .= ${MRTG_lib::SL};
- if (! -d $path){
- warn ("WARNING: $path did not exist I will create it now\n");
- mkdir $path, 0777 or die ("ERROR: mkdir $path: $!\n");
- }
- }
-}
-
-sub cfgcheck ($$$$;$) {
- my $routers = shift;
- my $cfg = shift;
- my $rcfg = shift;
- my $target = shift;
- my $opts = shift || {};
- my ($rou, $confname, $one_option);
- # Target index hash. Keys are "int:community@router" target definition
- # strings and values are indices of the @$target array. Used to avoid
- # duplicate entries in @$target.
- my $targIndex = { };
- my $error="no";
- my(@known_options) = qw(growright bits noinfo absolute gauge nopercent avgpeak derive
- integer perhour perminute transparent dorelpercent
- unknaszero withzeroes noborder noarrow noi noo
- nobanner nolegend logscale secondmean pngdate printrouter expscale);
-
- snmpmapOID('hrSystemUptime' => '1.3.6.1.2.1.25.1.1');
-
- if (defined $$cfg{workdir}) {
- die ("ERROR: WorkDir must not contain spaces when running on Windows. (Yeat another reason to get Linux)\n")
- if ($OS eq 'NT' or $OS eq 'OS2') and $$cfg{workdir} =~ /\s/;
- ensureSL(\$$cfg{workdir});
- $$cfg{logdir}=$$cfg{htmldir}=$$cfg{imagedir}=$$cfg{workdir};
- mkdirhier "$$cfg{workdir}" unless $opts->{check};
-
- } elsif ( not (defined $$cfg{logdir} or defined $$cfg{htmldir} or defined $$cfg{imagedir})) {
- die ("ERROR: \"WorkDir\" not specified in mrtg config file\n");
- $error = "yes";
- } else {
- if (! defined $$cfg{logdir}) {
- warn ("WARNING: \"LogDir\" not specified\n");
- $error = "yes";
- } else {
- ensureSL(\$$cfg{logdir});
- mkdirhier $$cfg{logdir} unless $opts->{check};
- }
- if (! defined $$cfg{htmldir}) {
- warn ("WARNING: \"HtmlDir\" not specified\n");
- $error = "yes";
- } else {
- ensureSL(\$$cfg{htmldir});
- mkdirhier $$cfg{htmldir} unless $opts->{check};
- }
- if (! defined $$cfg{imagedir}) {
- warn ("WARNING: \"ImageDir\" not specified\n");
- $error = "yes";
- } else {
- ensureSL(\$$cfg{imagedir});
- mkdirhier $$cfg{imagedir} unless $opts->{check};
- }
- }
- if ($cfg->{threshmailserver} and not $cfg->{threshmailsender}){
- warn ("WARNING: If \"ThreshMailServer\" is defined, then \"ThreshMailSender\" must be defined too.\n");
- $error = "yes";
- }
- if ($cfg->{threshmailsender} and not $cfg->{threshmailserver}){
- warn ("WARNING: If \"ThreshMailSender\" is defined, then \"ThreshMailServer\" must be defined too.\n");
- $error = "yes";
- }
- # default ThreshHyst to 0.1 if ThreshDir is defined
- if ($cfg->{threshdir}){
- $cfg->{threshhyst} = 0.1 unless $cfg->{threshhyst};
- }
- # build relativ path from htmldir to image dir.
- my @htmldir = split /\Q${MRTG_lib::SL}\E+/, $$cfg{htmldir};
- my @imagedir = split /\Q${MRTG_lib::SL}\E+/, $$cfg{imagedir};
- while (scalar @htmldir > 0 and $htmldir[0] eq $imagedir[0]) {
- shift @htmldir; shift @imagedir;
- }
- # this is for the webpages so we use / path separator always
- $$cfg{imagehtml} = "";
- foreach my $dir ( @htmldir ) {
- $$cfg{imagehtml} .= "../" if $dir;
- }
- map {$$cfg{imagehtml} .= "$_/" } @imagedir;
- # relative path is built
- debug('dir', "imagehtml = $$cfg{imagehtml}");
-
- $SNMP_util::CacheFile = "$$cfg{'logdir'}oid-mib-cache.txt";
- $Net_SNMP_util::CacheFile = "$$cfg{'logdir'}oid-mib-cache.txt";
-
- if (defined $$cfg{loadmibs}) {
- my($mibFile);
- foreach $mibFile (split /[,\s]+/, $$cfg{loadmibs}) {
- snmpQueue_MIB_File($mibFile);
- }
- }
- if(defined $$cfg{pathadd}){
- ensureSL(\$$cfg{pathadd});
- $ENV{PATH} = "$$cfg{pathadd}${MRTG_lib::PS}$ENV{PATH}";
- }
- if(defined $$cfg{libadd}){
- ensureSL(\$$cfg{libadd});
- debug('eval',"libadd $$cfg{libadd}\n");
- local $SIG{__DIE__};
- eval "use lib qw( $$cfg{libadd} )";
- my @match;
- foreach my $dir (@INC){
- push @match, $dir if -f "$dir/RRDs.pm";
- }
- warn "WARN: found several copies of RRDs.pm in your path: ".
- (join ", ", @match)." I will be using $match[0]. This could ".
- "be a problem if this is an old copy and you think I would be using a newer one!\n"
- if $#match > 0;
- }
- $$cfg{logformat} = 'rateup' unless defined $$cfg{logformat};
-
- if($$cfg{logformat} eq 'rrdtool') {
- my ($name);
- if ($MRTG_lib::OS eq 'NT' or $MRTG_lib::OS eq 'OS2'){
- $name = "rrdtool.exe";
- } elsif ($MRTG_lib::OS eq 'NW'){
- $name = "rrdtool.nlm";
- } else {
- $name = "rrdtool";
- }
- foreach my $path (split /\Q${MRTG_lib::PS}\E/, $ENV{PATH}) {
- ensureSL(\$path);
- -f "$path$name" && do {
- $$cfg{'rrdtool'} = "$path$name";
- last;}
- };
- die "ERROR: could not find $name. Use PathAdd: in mrtg.cfg to help mrtg find rrdtool\n"
- unless defined $$cfg{rrdtool};
- debug ('rrd',"found rrdtool in $$cfg{rrdtool}");
- my $found;
- foreach my $path (@INC) {
- ensureSL(\$path);
- -f "${path}RRDs.pm" && do {
- $found=1;
- last;}
- };
- die "ERROR: could not find RRDs.pm. Use LibAdd: in mrtg.cfg to help mrtg find RRDs.pm\n"
- unless defined $found;
- }
- if (defined $$cfg{snmpoptions}) {
- debug('eval',"redef snmpotions $cfg->{snmpoptions}");
- local $SIG{__DIE__};
- $cfg->{snmpoptions} = eval('{'.$cfg->{snmpoptions}.'}');
- }
-
- # default interval is 5 minutes
- if ($cfg->{interval} and $cfg->{interval} =~ /(\d+)(?::(\d+))?/){
- $cfg->{interval} = $1;
- $cfg->{interval} += $2/60.0 if $2;
- } else {
- $cfg->{interval} = 5;
- }
- unless ($$cfg{logformat} eq 'rrdtool') {
- # interval has to be 5 minutes at least without userrdtool
- if ($$cfg{interval} < 5.0) {
- die "ERROR: CFG Error in \"Interval\": should be at least 5 Minutes (unless you use rrdtool)";
- }
- }
-
- # Check for a Conversion Code file and evaluate its contents, which
- # should consist of one or more subroutine definitions. The code goes
- # into the MRTGConversion name space.
- if( exists $cfg->{ conversioncode } ) {
- open CONV, $cfg->{ conversioncode }
- or die "ERROR: Can't open file $cfg->{ conversioncode }\n";
- my $code = "local \$SIG{__DIE__};package MRTGConversion;\n". join( '', <CONV> ) . "1;\n";
- close CONV;
- debug('eval',"covnversioncode $cfg->{ conversioncode }");
- die "ERROR: File $cfg->{ conversioncode } conversion code evaluation failed\n$@\n"
- unless eval $code;
- }
-
- my $thresh_error;
-
- # sendtographite directive parsing
- # sanity check for <ip>,<port> or <dnsname>,<port>
- if ($cfg->{sendtographite}){
- my @a = split ",",$cfg->{sendtographite};
-
- # is this an IP address?
- unless($a[0] =~ /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/) {
- # maybe we were passed a DNS name?
- unless(gethostbyname($a[0])) { die "ERROR: cannot find graphite server name $a[0] in DNS\n"; }
- }
-
- # if we got this far, now check the port number range
- unless($a[1] > 0 and $a[1] < 65536) {
- die "ERROR: invalid port number $a[1] in sendtographite directive\n";
- }
- }
-
- foreach $rou (@$routers) {
- # and now for the testing
- if (defined $rcfg->{threshmailaddress}{$rou}){
- if (not defined $cfg->{threshmailserver} and not $thresh_error){
- warn (qq{ERROR: ThreshMailAddress[$rou]: specified without "ThreshMailServer:"});
- $error = "yes";
- $thresh_error = "yes";
- }
- # the dependency between sender and server is taken care of already
- }
- if (! defined $rcfg->{snmpoptions}{$rou}) {
- $rcfg->{snmpoptions}{$rou} = {%{$cfg->{snmpoptions}}}
- if defined $cfg->{snmpoptions};
- } else {
- debug('eval',"redef snmpoptions[$rou] $rcfg->{snmpoptions}{$rou}");
- local $SIG{__DIE__};
- $rcfg->{snmpoptions}{$rou} = eval('{'.$rcfg->{snmpoptions}{$rou}.'}');
- }
- $rcfg->{snmpoptions}{$rou}{avoid_negative_request_ids} = 1;
- # $rcfg->{snmpoptions}{$rou}{domain} = 'udp';
-
- if (! defined $$rcfg{"title"}{$rou}) {
- warn ("WARNING: \"Title[$rou]\" not specified\n");
- $error = "yes";
- }
- if (defined $$rcfg{'directory'}{$rou} and $$rcfg{'directory'}{$rou} ne "") {
- # They specified a directory for this router. Append the
- # pathname seperator to it (so that it can either be present or
- # absent, and the rules for including it are the same).
- ensureSL(\$$rcfg{'directory'}{$rou});
- for my $x (qw(imagedir logdir htmldir)) {
- mkdirhier $$cfg{$x}.$$rcfg{directory}{$rou} unless $opts->{check};
- }
- $$rcfg{'directory_web'}{$rou} = $$rcfg{'directory'}{$rou};
- $$rcfg{'directory_web'}{$rou} =~ s/\Q${MRTG_lib::SL}\E+/\//g;
- debug('dir', "directory for $rou '$$rcfg{'directory_web'}{$rou}'");
- } else {
- $$rcfg{'directory'}{$rou}="";
- $$rcfg{'directory_web'}{$rou}="";
- }
-
- if (defined $$rcfg{"pagetop"}{$rou}) {
- $$rcfg{"pagetop"}{$rou} =~ s/\\n/\n/g;
- }
-
-
- if (defined $$rcfg{"pagefoot"}{$rou}) {
- # allow for linebreaks
- $$rcfg{"pagefoot"}{$rou} =~ s/\\n/\n/g;
- }
-
- $$rcfg{"maxbytes1"}{$rou} = $$rcfg{"maxbytes"}{$rou} unless defined $$rcfg{"maxbytes1"}{$rou};
- $$rcfg{"maxbytes2"}{$rou} = $$rcfg{"maxbytes"}{$rou} unless defined $$rcfg{"maxbytes2"}{$rou};
-
- if ( not defined $$rcfg{"maxbytes"}{$rou}
- and not defined $$rcfg{"maxbytes1"}{$rou}
- and not defined $$rcfg{"maxbytes2"}{$rou}) {
- warn ("WARNING: \"MaxBytes[$rou]\" not specified\n");
- $error = "yes";
- } else {
-
- if (not defined $$rcfg{"maxbytes1"}{$rou}) {
- warn ("WARNING: \"MaxBytes1[$rou]\" not specified\n");
- $error = "yes";
- }
- if (not defined $$rcfg{"maxbytes2"}{$rou}) {
- warn ("WARNING: \"MaxBytes2[$rou]\" not specified\n");
- $error = "yes";
- }
- }
- # set default extension
- if (! defined $$rcfg{"extension"}{$rou}) {
- $$rcfg{"extension"}{$rou}="html";
- }
-
- # set default size
- if (! defined $$rcfg{"xsize"}{$rou}) {
- $$rcfg{"xsize"}{$rou}=400;
- }
- if (! defined $$rcfg{"ysize"}{$rou}) {
- $$rcfg{"ysize"}{$rou}=100;
- }
- if (! defined $$rcfg{"ytics"}{$rou}) {
- $$rcfg{"ytics"}{$rou}=4;
- }
- if (! defined $$rcfg{"yticsfactor"}{$rou}) {
- $$rcfg{"yticsfactor"}{$rou}=1;
- }
- if (! defined $$rcfg{"factor"}{$rou}) {
- $$rcfg{"factor"}{$rou}=1;
- }
-
- if (defined $$rcfg{"options"}{$rou}) {
- my $opttemp = lc($$rcfg{"options"}{$rou});
- delete $$rcfg{"options"}{$rou};
- foreach $one_option (split /[,\s]+/, $opttemp) {
- if (grep {$one_option eq $_} @known_options) {
- $$rcfg{'options'}{$one_option}{$rou} = 1;
- } else {
- warn ("WARNING: Option[$rou]: \"$one_option\" is unknown\n");
- $error="yes";
- }
- }
- if ($rcfg->{'options'}{derive}{$rou} and not $cfg->{logformat} eq 'rrdtool'){
- warn ("WARNING: Option[$rou]: \"derive\" works only with rrdtool logformat\n");
- $error="yes";
- }
- }
- #
- # Check out routeruptime definition
- #
- if (defined $$rcfg{"routeruptime"}{$rou}) {
- ($$rcfg{"community"}{$rou},$$rcfg{"router"}{$rou}) =
- split(/@/,$$rcfg{"routeruptime"}{$rou});
- }
- #
- # Check out target definition
- #
- if (defined $$rcfg{"target"}{$rou}) {
- $$rcfg{targorig}{$rou} = $$rcfg{target}{$rou};
- debug ('tarp',"Starting $rou -> $$rcfg{target}{$rou}");
- # Decide whether to turn on IPv6 support for this target.
- # IPv6 support is turned on only if the EnableIPv6 global
- # setting is yes and the IPv4Only per-target setting is no.
- # If IPv6 is disabled, we set IPv4Only to true for all
- # targets, thus disabling all IPv6-related code.
- my $ipv4only = 1;
- if ($$cfg{enableipv6} and $$cfg{enableipv6} eq 'yes') {
- # IPv4Only is off by default
- $ipv4only = 0
- unless (defined $$rcfg{ipv4only}{$rou}) && (lc($$rcfg{ipv4only}{$rou}) eq 'yes');
- }
- # Check if nohc has been set, designating a low-speed interface
- # without working HC counters. Default is that high-speed
- # counters exist.
- my $nohc = 0;
- $nohc = 1 if (defined $$rcfg{nohc}{$rou}) && (lc($$rcfg{nohc}{$rou}) eq 'yes');
-
- ( $$rcfg{target}{$rou}, $$rcfg{uniqueTarget}{$rou} ) =
- targparser( $$rcfg{target}{$rou}, $target, $targIndex, $ipv4only, $rcfg->{snmpoptions}{$rou}, $nohc );
- } else {
- warn ("WARNING: I can't find a \"target[$rou]\" definition\n");
- $error = "yes";
- }
-
- # colors format: name#hexcol,
- if (defined $$rcfg{"colours"}{$rou}) {
- if ($$rcfg{'options'}{'dorelpercent'}{$rou}) {
- if ($$rcfg{"colours"}{$rou} =~
- /^([^\#]+)(\#[0-9a-f]{6})\s*,\s*
- ([^\#]+)(\#[0-9a-f]{6})\s*,\s*
- ([^\#]+)(\#[0-9a-f]{6})\s*,\s*
- ([^\#]+)(\#[0-9a-f]{6})\s*,\s*
- ([^\#]+)(\#[0-9a-f]{6})/ix) {
- ($$rcfg{'col1'}{$rou}, $$rcfg{'rgb1'}{$rou},
- $$rcfg{'col2'}{$rou}, $$rcfg{'rgb2'}{$rou},
- $$rcfg{'col3'}{$rou}, $$rcfg{'rgb3'}{$rou},
- $$rcfg{'col4'}{$rou}, $$rcfg{'rgb4'}{$rou},
- $$rcfg{'col5'}{$rou}, $$rcfg{'rgb5'}{$rou}) =
- ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);
- } else {
- warn ("WARNING: \"colours[$rou]\" for colour definition\n".
- " use the format: Name#hexcolour, Name#Hexcolour,...\n",
- " note, that dorelpercent requires 5 colours");
- $error="yes";
- }
- } else {
- if ($$rcfg{"colours"}{$rou} =~
- /^([^\#]+)(\#[0-9a-f]{6})\s*,\s*
- ([^\#]+)(\#[0-9a-f]{6})\s*,\s*
- ([^\#]+)(\#[0-9a-f]{6})\s*,\s*
- ([^\#]+)(\#[0-9a-f]{6})/ix) {
- ($$rcfg{'col1'}{$rou}, $$rcfg{'rgb1'}{$rou},
- $$rcfg{'col2'}{$rou}, $$rcfg{'rgb2'}{$rou},
- $$rcfg{'col3'}{$rou}, $$rcfg{'rgb3'}{$rou},
- $$rcfg{'col4'}{$rou}, $$rcfg{'rgb4'}{$rou}) =
- ($1, $2, $3, $4, $5, $6, $7, $8);
- } else {
- warn "WARNING: \"colours[$rou]\" for colour definition\n".
- " use the format: Name#hexcolour, Name#Hexcolour,...\n";
- $error="yes";
- }
- }
- } else {
- if (defined $$rcfg{'options'}{'dorelpercent'}{$rou}) {
- ($$rcfg{'col1'}{$rou}, $$rcfg{'rgb1'}{$rou},
- $$rcfg{'col2'}{$rou}, $$rcfg{'rgb2'}{$rou},
- $$rcfg{'col3'}{$rou}, $$rcfg{'rgb3'}{$rou},
- $$rcfg{'col4'}{$rou}, $$rcfg{'rgb4'}{$rou},
- $$rcfg{'col5'}{$rou}, $$rcfg{'rgb5'}{$rou}) =
- ("GREEN","#00cc00",
- "BLUE","#0000ff",
- "DARK GREEN","#006600",
- "MAGENTA","#ff00ff",
- "AMBER","#ef9f4f");
- } else {
- ($$rcfg{'col1'}{$rou}, $$rcfg{'rgb1'}{$rou},
- $$rcfg{'col2'}{$rou}, $$rcfg{'rgb2'}{$rou},
- $$rcfg{'col3'}{$rou}, $$rcfg{'rgb3'}{$rou},
- $$rcfg{'col4'}{$rou}, $$rcfg{'rgb4'}{$rou}) =
- ("GREEN","#00cc00",
- "BLUE","#0000ff",
- "DARK GREEN","#006600",
- "MAGENTA","#ff00ff");
- }
- }
- # Background color, format: #rrggbb
- if (! defined $$rcfg{'background'}{$rou}) {
- $$rcfg{'background'}{$rou} = "#ffffff";
- }
- if ($$rcfg{'background'}{$rou} =~ /^(\#[0-9a-f]{6})/i) {
- $$rcfg{'backgc'}{$rou} = "$1";
- } else {
- warn "WARNING: \"background[$rou]: ".
- "$$rcfg{'background'}{$rou}\" for colour definition\n".
- " use the format: #rrggbb\n";
- $error="yes";
- }
-
- if (! defined $$rcfg{'kilo'}{$rou}) {
- $$rcfg{'kilo'}{$rou} = 1000;
- }
- if (defined $$rcfg{'kmg'}{$rou}) {
- $$rcfg{'kmg'}{$rou} =~ s/\s+//g;
- }
-
- if (! defined $$rcfg{'xzoom'}{$rou}) {
- $$rcfg{'xzoom'}{$rou} = 1.0;
- }
- if (! defined $$rcfg{'yzoom'}{$rou}) {
- $$rcfg{'yzoom'}{$rou} = 1.0;
- }
- if (! defined $$rcfg{'xscale'}{$rou}) {
- $$rcfg{'xscale'}{$rou} = 1.0;
- }
- if (! defined $$rcfg{'yscale'}{$rou}) {
- $$rcfg{'yscale'}{$rou} = 1.0;
- }
- if (defined $$rcfg{'options'}{'pngdate'}{$rou}) {
- $$rcfg{'timestrpos'}{$rou} = 'RU';
- $$rcfg{'timestrfmt'}{$rou} = $$rcfg{'timezone'}{$rou} ? "%Y-%m-%d %H:%M %Z" : "%Y-%m-%d %H:%M";
- delete $$rcfg{'options'}{'pntdate'}{$rou}
- }
- if (! defined $$rcfg{'timestrpos'}{$rou}) {
- $$rcfg{'timestrpos'}{$rou} = 'NO';
- }
- if (! defined $$rcfg{'timestrfmt'}{$rou}) {
- $$rcfg{'timestrfmt'}{$rou} = "%Y-%m-%d %H:%M";
- }
- if ($error eq "yes") {
- die "ERROR: Please fix the error(s) in your config file\n";
- }
- }
-}
-
-# make sure string ends with a slash.
-sub ensureSL($) {
-# return;
- my $ref = shift;
- return if not $$ref;
- debug('dir',"ensure path IN: '$$ref'");
- if (${MRTG_lib::SL} eq '\\'){
- # two slashes at the start of the string are OK
- $$ref =~ s/(.)\Q${MRTG_lib::SL}\E+/$1${MRTG_lib::SL}/g;
- } else {
- $$ref =~ s/\Q${MRTG_lib::SL}\E+/${MRTG_lib::SL}/g;
- }
- $$ref =~ s/\Q${MRTG_lib::SL}\E*$/${MRTG_lib::SL}/;
- debug('dir',"ensure path OUT: '$$ref'");
-}
-
-# convert current supplied time into a nice date string
-
-sub datestr ($) {
- my ($time) = shift || return 0;
- my ($wday) = ('Sunday','Monday','Tuesday','Wednesday',
- 'Thursday','Friday','Saturday')[(localtime($time))[6]];
- my ($month) = ('January','February' ,'March' ,'April' ,
- 'May' , 'June' , 'July' , 'August' , 'September' ,
- 'October' ,
- 'November' , 'December' )[(localtime($time))[4]];
- my ($mday,$year,$hour,$min) = (localtime($time))[3,5,2,1];
- if ($min<10) {
- $min = "0$min";
- }
- return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-}
-
-
-# create expire date for expiery in ARG Minutes
-
-sub expistr ($) {
- my ($time) = time+int($_[0]*60)+5;
- my ($wday) = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat')[(gmtime($time))[6]];
- my ($month) = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep',
- 'Oct','Nov','Dec')[(gmtime($time))[4]];
- my ($mday,$year,$hour,$min,$sec) = (gmtime($time))[3,5,2,1,0];
- if ($mday<10) {
- $mday = "0$mday";
- }
- ;
- if ($hour<10) {
- $hour = "0$hour";
- }
- ;
- if ($min<10) {
- $min = "0$min";
- }
- if ($sec<10) {
- $sec = "0$sec";
- }
- return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-}
-
-sub create_pid ($) {
- my $pidfile = shift;
- return if ($OS eq 'NT' );
- return if -e $pidfile;
- if ( open(PIDFILE,">$pidfile")) {
- close PIDFILE;
- } else {
- warn "cannot write to $pidfile: $!\n";
- }
-}
-
-sub demonize_me ($) {
- my $pidfile = shift;
- my $cfgfile = shift;
- print "Daemonizing MRTG ...\n";
- if ( $OS eq 'NT' ) {
- print "Do Not close this window. Or MRTG will die\n";
-# require Win32::Console;
-# my $CONSOLE = new Win32::Console;
- # detach process from Console
-# $CONSOLE->Flush();
-# $CONSOLE->Free();
-# $CONSOLE->Alloc();
-# $CONSOLE->Mode()
- }
- elsif( $OS eq 'OS2')
- {
- require OS2::Process;
- if (my_type() eq 'VIO'){
- $main::Cleanfile3 = $pidfile;
-
- print "MRTG detached. PID=".system(P_DETACH(),$^X." ".$0." ".$cfgfile);
- exit;
- }
- } else {
- # Check out if there is another mrtg running before forking
- if (defined $pidfile && open(READPID, "<$pidfile")){
- if (not eof READPID) {
- chomp(my $input = <READPID>); # read process id in pidfile
- my ($pid) = $input =~ /^(\d+)$/; # to improve taint-safe code
- if ($pid && kill 0 => $pid) {# oops - the pid actually exists
- die "ERROR: I Quit! Another copy of mrtg seems to be running. Check $pidfile\n";
- }
- }
- close READPID;
- }
-
- defined (my $pid = fork) or die "Can't fork: $!";
- if ($pid) {
- exit;
- } else {
- if (defined $pidfile){
- $main::Cleanfile3 = $pidfile;
- if (open(PIDFILE,">$pidfile")) {
- print PIDFILE "$$\n";
- close PIDFILE;
- } else {
- warn "cannot write to $pidfile: $!\n";
- }
- }
- require 'POSIX.pm';
- POSIX::setsid() or die "Can't start a new session: $!";
- open STDOUT,'>/dev/null' or die "ERROR: Redirecting STDOUT to /dev/null: $!";
- open STDERR,'>/dev/null' or die "ERROR: Redirecting STDERR to /dev/null: $!";
- open STDIN, '</dev/null' or die "ERROR: Redirecting STDIN from /dev/null: $!";
- }
- }
-}
-
-# Create a new SNMP target entry for the @$target array and return a
-# reference to it
-sub newSnmpTarg( $$ ) {
- my $t = shift; # target string
- my $if = shift; # interface match strings
- my $targ = { }; # New target closure
- $targ->{ Methode } = 'SNMP';
- $targ->{ Community } = $if->{ComStr};
- $targ->{ Host } = ( defined $if->{HostIPv6} ) ? $if->{HostIPv6} : $if->{HostName};
- $targ->{ SnmpOpt } = $if->{SnmpInfo};
- $targ->{ snmpoptions} = $if->{snmpoptions};
- $targ->{ Conversion } = ( defined $if->{ConvSub} ) ? $if->{ConvSub} : '';
- for my $i( 0..1 ) {
- die 'ERROR: Malformed ', $i ? 'output ' : 'input ', "ifSpec in '$t'\n"
- if not defined $if->{OID}[$i] and not defined $if->{Alt}[$i];
- $targ->{OID}[$i] = $if->{OID}[$i];
- if( defined $if->{Alt}[$i] ) {
- if( defined $if->{Num}[$i] ) {
- $targ->{IfSel}[$i] = 'If';
- $targ->{Key}[$i] = $if->{Num}[$i];
- } elsif( defined $if->{IP}[$i] ) {
- $targ->{IfSel}[$i] = 'Ip';
- $targ->{Key}[$i] = $if->{IP}[$i];
- } elsif( defined $if->{Desc}[$i] ) {
- $targ->{IfSel}[$i] = 'Descr';
- $targ->{Key}[$i] = $if->{Desc}[$i];
- } elsif( defined $if->{Name}[$i] ) {
- $targ->{IfSel}[$i] = 'Name';
- $targ->{Key}[$i] = $if->{Name}[$i];
- } elsif( defined $if->{Eth}[$i] ) {
- $targ->{IfSel}[$i] = 'Eth';
- $targ->{Key}[$i] = join( '-', map( { sprintf '%02x', hex $_ } split( /-/, $if->{Eth}[$i] ) ) );
- } elsif( defined $if->{Type}[$i] ) {
- $targ->{IfSel}[$i] = 'Type';
- $targ->{Key}[$i] = $if->{Type}[$i];
- } else {
- die "ERROR: Internal error parsing ifSpec in '$t'\n";
- }
- } else {
- $targ->{IfSel}[$i] = 'None';
- $targ->{Key}[$i] = '';
- }
- # Remove escaped characters and trailing space from Descr or Name Key
- $targ->{Key}[$i] =~ s/\\([\s:&@])/$1/g
- if $targ->{IfSel}[$i] eq 'Descr' or $targ->{IfSel}[$i] eq 'Name';
- $targ->{Key}[$i] =~ s/[\0- ]+$//;
- }
- # Remove escaped characters from community
- $targ->{ Community } =~ s/\\([ @])/$1/g;
- return $targ; # Return new target closure
-}
-
-# ( $string, $unique ) = targparser( $string, $target, $targIndex, $ipv4only )
-# Walk amd analyze the target string $string. $target is a reference to the
-# array of targets being built. $targIndex is a reference to a hash of targets
-# previously encountered indexed by target string. When $ipv4only is nonzero,
-# only IPv4 is in use. Returns the modifed target string and the index of the
-# @$target array to which the target refers if that index is unique. If the
-# index is not unique, i.e. the target definition is a calculation involving
-# two or more different targets, then the value -1 is returned for $unique.
-# Targparser updates the target array avoiding duplicate targets. The goal is
-# to substitute all target definitions with strings of the form
-# "$t1$thisTarg$t2", where $thisTarg is the target index, and $t1 and $t2 are
-# as defined below. The intended result is a target string that can be eval'ed
-# in its entirety later on when monitoring data has been collected. This
-# evaluation occurs in sub getcurrent in the main mrtg script.
-
-# Note: In the regular expressions in &targparser, we have avoided m/.../i
-# and the variables &`, $&, and $'. Use of these makes regex processing less
-# efficient. See Friedl, J.E.F. Mastering Regular Expressions. O'Reilly.
-# p. 273
-
-sub targparser( $$$$$$ ) {
- # Target string (int:community@router, etc.)
- my $string = shift;
- # Reference to target array
- my $target = shift;
- # Reference to target index hash
- my $targIndex = shift;
- # Nonzero if only IPv4 is in use
- my $ipv4only = shift;
- # options passed per target.
- my $snmpoptions = shift;
- # Highspeed Counter test
- my $nohc = shift;
-
- # Next available index in the @$target array
- my $idx = @$target;
- # Common match strings: pre-target, target, post-target
- my( $pre, $t, $post );
- # Portion of string already parsed
- my $parsed = '';
- # Initialize $unique to undefined. It will take on the $targIndex value
- # of the first target encountered. $otherTargCount will count the
- # number of other targets (targets with different values of $targIndex)
- # encountered during the parse. $unique will be returned as undef
- # unless $otherTargCount remains 0.
- my $unique = -1;
- my $otherTargCount = 0;
-
- # Components of the target expression that are substituted into the
- # target string each time a target is identified. The substitution
- # string is the interpolated value of "$t1$targIndex$t2". At present
- # $t1 and $t2 are set to create a new BigFloat object.
-# my $t1 = ' Math::BigFloat->new($target->[';
-# my $t2 = ']{$mode}) ';
- # this gives problems with perl 5.005 so bigfloat is introduces in mrtg itself
- my $t1 = ' $target->[';
- my $t2 = ']{$mode} ';
-
- # Find and substitute all external program targets
- while( ( $pre, $t, $post ) = $string =~ m<
- ^(.*?) # capture pre-target string
- ` # beginning of program target
- ((?:\\`|[^`])+) # capture target contents (\` allowed)
- ` # end of program target
- (.*)$ # capture post-target string
- >x ) { # Total of 3 captures
- my $thisTarg;
- if( exists $targIndex->{ $t } ) {
- # This program target has been encountered previously
- $thisTarg = $targIndex->{ $t };
- debug( 'tarp', "Existing program target [$thisTarg]" );
- } else {
- # A new program target is needed
- my $targ = { };
- $targ->{ Methode } = 'EXEC';
- $targ->{ Command } = $t;
- # Remove escaped backticks
- $targ->{ Command } =~ s/\\\`/\`/g;
- $target->[ $idx ] = $targ;
- $thisTarg = $idx++;
- $targIndex->{ $t } = $thisTarg;
- debug( 'tarp', "New program target [$thisTarg] '$t'" );
- }
- $parsed .= "$pre$t1$thisTarg$t2";
- $string = $post;
- if( $unique < 0 ) {
- $unique = $thisTarg;
- } else {
- $otherTargCount++ unless $thisTarg == $unique;
- }
- };
- # Reset $string for new target type search
- $string = $parsed . $string;
- $parsed = '';
- debug( 'tarp', "&targparser external done: '$string'" );
-
- # Common interface specification regex components
-
- # Simple interface specification regex component. Matches interface
- # specification by IPv4 address, description, name, Ethernet address, or
- # type.
- my $ifSimple =
- ' (\d+)|' . # by number ($if->{Num})
- ' / (\d+(?:\.\d+)+)|' . # by IPv4 address ($if->{IP})
- ' \\\\ ((?:\\\\[\s:&@]|[^\s:&@])+)|' . # by description (allow \ \: \& \@) ($if->{Desc})
- ' \# ((?:\\\\[\s:&@]|[^\s:&@])+)|' . # by name (allow \ \: \& \@) ($if->{Name})
- ' ! ([a-fA-F0-9]+(?:-[a-fA-F0-9]+)+)|' . # by Ethernet address ($if->{Eth})
- ' % (\d+)'; # by type ($if->{Type})
-
- # Complex interface specification regex component. Note that a null string
- # will match. Therefore the match must be postprocessed to check that
- # $ifOID and $ifAlt are not both null.
- my $ifComplex =
- '((?:\.\d+)*?\.?[-a-zA-Z0-9]*(?:\.\d+)*?)' . # OID possibly starting with a MIB name ($if->{OID})
- '(' . # Interface specification alternatives: ($if->{Alt})
- '\.' . # separator
- $ifSimple . # simple alternatives (6 variables)
- ')?'; # maybe none of the above
-
- # Community-host interface specification regex component.
- my $ifComHost =
- '((?:\\\\[@ ]|[^\s@])+)' . # community string ('\@' and '\ ' allowed) ($if->{ComStr})
- '@' . # separator
- '(?:(\[[a-fA-F0-9:]*\])|' . # hostname as IPv6 address ($if->{HostIPv6})
- '([-\w]+(?:\.[-\w]+)*))' . # or DNS name ($if->{HostName})
- '((?::[\d.!]*)*)' . # SNMP session configuration ($if->{SnmpInfo})
- '(?:\|([a-zA-Z_][\w]*))?'; # numeric conversion subroutine ($if->{ConvSub})
-
- # Match strings for simple and complex interface specifications. Entries
- # are of the form $if->{k1}[i], where k1 is OID, Alt, Num, IP, Desc,
- # Name, Eth, or Type, and i is 0 or 1 (input or output). Entries may also
- # have the form $if->{k1}, where k1 is Rev, ComStr, HostIPv6, HostName,
- # SnmpInfo, or ConvSub, with no [i] in these cases.
- my $if;
-
- # Find and substitute all complex OID targets
-
- while( ( $pre, $t, $if->{OID}[0], $if->{Alt}[0], $if->{Num}[0],
- $if->{IP}[0], $if->{Desc}[0], $if->{Name}[0], $if->{Eth}[0],
- $if->{Type}[0], $if->{OID}[1], $if->{Alt}[1], $if->{Num}[1],
- $if->{IP}[1], $if->{Desc}[1], $if->{Name}[1], $if->{Eth}[1],
- $if->{Type}[1], $if->{ComStr}, $if->{HostIPv6}, $if->{HostName},
- $if->{SnmpInfo}, $if->{ConvSub}, $post ) = $string =~ m<
- ^(.*?) # capture pre-target string
- ( # capture entire target
- ${ifComplex} # input interface specification (8 captures)
- & # separator
- ${ifComplex} # output interface specification (8 captures)
- : # separator
- ${ifComHost} # community-host specification (5 captures)
- ) # end of entire target capture
- (.*)$ # capture post-target string
- >x ) { # Total of 24 captures
- my $thisTarg;
- # Exception: skip and try to parse later as a simple target if
- # $if->{Desc}[0], $if->{Name}[0], $if->{Desc}[1], or $if->{Name}[1]
- # ends with a backslash character
- if( ( defined $if->{Desc}[0] and $if->{Desc}[0] =~ m<\\$> ) or
- ( defined $if->{Name}[0] and $if->{Name}[0] =~ m<\\$> ) or
- ( defined $if->{Desc}[1] and $if->{Desc}[1] =~ m<\\$> ) or
- ( defined $if->{Name}[1] and $if->{Name}[1] =~ m<\\$> ) ) {
- $parsed .= "$pre$t";
- $string = $post;
- next;
- }
- if( exists $targIndex->{ $t } ) {
- # This complex target has been encountered previously
- $thisTarg = $targIndex->{ $t };
- debug( 'tarp', "Existing complex target [$thisTarg]" );
- } else {
- # A new complex target is needed
- my $targ = newSnmpTarg( $t, $if );
- $targ->{ ipv4only } = $ipv4only;
- $targ->{ snmpoptions } = $snmpoptions;
- $target->[ $idx ] = $targ;
- $thisTarg = $idx++;
- $targIndex->{ $t } = $thisTarg;
- debug( 'tarp', "New complex target [$thisTarg] '$t':\n" .
- " Comu: $targ->{Community}, Host: $targ->{Host}\n" .
- " Opt: $targ->{SnmpOpt}, IPv4: $targ->{ipv4only}\n" .
- " Conv: $targ->{Conversion}\n" .
- " OID: $targ->{OID}[0], $targ->{OID}[1]\n" .
- " IfSel: $targ->{IfSel}[0], $targ->{IfSel}[1]\n" .
- " Key: $targ->{Key}[0], $targ->{Key}[1]" );
- }
- $parsed .= "$pre$t1$thisTarg$t2";
- $string = $post;
- if( $unique < 0 ) {
- $unique = $thisTarg;
- } else {
- $otherTargCount++ unless $thisTarg == $unique;
- }
- }
- # Reset $string and $parsedfor new target type search
- $string = $parsed . $string;
- $parsed = '';
- debug( 'tarp', "&targparser complex done: '$string'" );
-
- # Find and substitute all simple targets
-
- while( ( $pre, $t, $if->{Rev}, $if->{Num}[0], $if->{IP}[0],
- $if->{Desc}[0], $if->{Name}[0], $if->{Eth}[0], $if->{Type}[0],
- $if->{ComStr}, $if->{HostIPv6}, $if->{HostName}, $if->{SnmpInfo},
- $if->{ConvSub}, $post ) = $string =~ m<
- ^(.*?) # capture pre-target string
- ( # capture entire target
- (-)? # capture direction reversal
- (?: ${ifSimple} ) # simple interface specification (6 captures)
- : # separator
- ${ifComHost} # community-host specification (5 captures)
- ) # end of entire target capture
- (.*)$ # capture post-target string
- >x ) { # Total of 15 captures
- my $thisTarg;
- if( exists $targIndex->{ $t } ) {
- # This simple target has been encountered previously
- $thisTarg = $targIndex->{ $t };
- debug( 'tarp', "Existing simple target [$thisTarg]" );
- } else {
- # A new simple target is needed
- # Reverse interface directions if indicated by $if->{Rev}.
- # The sense of $d1 and $d2 is 0 for input and 1 for output
- my $d1 = ( defined $if->{Rev} and $if->{Rev} eq '-' ) ? 1 : 0;
- my $d2 = 1 - $d1;
- # Set the OIDs depending on whether SNMPv2 has been specified
- # and on the direction
- if( $if->{SnmpInfo} =~ m/(?::[^:]*){4}:[32][Cc]?/ and $nohc == 0 ) {
- $if->{OID}[$d1] = 'ifHCInOctets';
- $if->{OID}[$d2] = 'ifHCOutOctets';
- } else {
- $if->{OID}[$d1] = 'ifInOctets';
- $if->{OID}[$d2] = 'ifOutOctets';
- }
- # Give $if->{Alt}[i] an arbitrary defined value so that
- # &newSnmpTarg works correctly
- $if->{Alt}[0] = 1;
- $if->{Alt}[1] = 1;
- # Copy input specification to output
- $if->{Num}[1] = $if->{Num}[0];
- $if->{IP}[1] = $if->{IP}[0];
- $if->{Desc}[1] = $if->{Desc}[0];
- $if->{Name}[1] = $if->{Name}[0];
- $if->{Eth}[1] = $if->{Eth}[0];
- $if->{Type}[1] = $if->{Type}[0];
- my $targ = newSnmpTarg( $t, $if );
- $targ->{ snmpoptions} = $snmpoptions;
- $targ->{ ipv4only } = $ipv4only;
- $target->[ $idx ] = $targ;
- $thisTarg = $idx++;
- $targIndex->{ $t } = $thisTarg;
- debug( 'tarp', "New simple target [$thisTarg] '$t':\n" .
- " Comu: $targ->{Community}, Host: $targ->{Host}\n" .
- " Opt: $targ->{SnmpOpt}, IPv4: $targ->{ipv4only}\n" .
- " Conv: $targ->{Conversion}\n" .
- " OID: $targ->{OID}[0], $targ->{OID}[1]\n" .
- " IfSel: $targ->{IfSel}[0], $targ->{IfSel}[1]\n" .
- " Key: $targ->{Key}[0], $targ->{Key}[1]" );
- }
- $parsed .= "$pre$t1$thisTarg$t2";
- $string = $post;
- if( $unique < 0 ) {
- $unique = $thisTarg;
- } else {
- $otherTargCount++ unless $thisTarg == $unique;
- }
- }
- # Assemble string to be returned
- $string = $parsed . $string;
- # Set $unique undefined if more than one target is referred to in the
- # target string
- $unique = -1 if $otherTargCount;
- debug( 'tarp', "&targparser simple done: '$string'" );
- debug( 'tarp', "&targparser returning: unique = $unique" );
- return ( $string, $unique );
-}
-
-# Display of &targparser intermediate values for debugging purposes. Call as
-# showMatch( $string, $pre, $t, $post, $if ) from within &targparser.
-sub showMatch( $$$$$ ) {
- my( $string, $pre, $t, $post, $if ) = @_;
- warn "# Matching on string '$string'\n";
- warn "# Prematch: '$pre'\n";
- warn "# Target: '$t'\n";
- warn "# Postmatch: '$post'\n";
- warn "# Captured:\n";
- foreach my $k( keys %$if ) {
- if( ref( $if->{$k} ) eq 'ARRAY' ) {
- warn "# \$if->{$k}[0,1]: '",
- ( defined $if->{$k}[0] ) ? $if->{$k}[0] : 'undef', "', '",
- ( defined $if->{$k}[1] ) ? $if->{$k}[1] : 'undef', "'\n";
- } else {
- warn "# \$if->{$k}: '",
- ( defined $if->{$k} ) ? $if->{$k} : 'undef', "'\n";
- }
- }
-}
-
-sub readconfcache ($) {
- my $cfgfile = shift;
- my %confcache;
- if (open (CFGOK,"<$cfgfile")) {
- while (<CFGOK>) {
- chomp;
- next unless /\t/; #ignore odd lines
- next if /^\S+:/; #ignore legacy lines
- my ($host,$method,$key,$if) = split (/\t/, $_);
- $key =~ s/[\0- ]+$//; # no trailing whitespace in keys realy !
- $key =~ s/[\0- ]/ /g; # all else becomes a normal space ... get a life
- $confcache{$host}{$method}{$key} = $if;
- }
- close CFGOK;
- }
- return \%confcache;
-}
-
-sub writeconfcache ($$) {
- my $confcache = shift;
- my $cfgfile = shift;
- if ($cfgfile ne '&STDOUT'){
- open (CFGOK,">$cfgfile") or die "ERROR: writing $cfgfile.ok: $!";
- }
- my @hosts;
- if (defined $$confcache{___updated}) {
- @hosts = @{$$confcache{___updated}} ;
- delete $$confcache{___updated};
- } else {
- @hosts = grep !/^___/, keys %{$confcache}
- }
- foreach my $host (sort @hosts) {
- foreach my $method (sort keys %{$$confcache{$host}}) {
- foreach my $key (sort keys %{$$confcache{$host}{$method}}) {
- if ($cfgfile ne '&STDOUT'){
- print CFGOK "$host\t$method\t$key\t".
- $$confcache{$host}{$method}{$key},"\n";
- } else {
- print "$host\t$method\t$key\t".
- $$confcache{$host}{$method}{$key},"\n";
- }
- }
- }
- }
- close CFGOK;
-}
-
-sub cleanhostkey ($){
- my $host = shift;
- return undef unless defined $host;
- $host =~ s/(:\d*)(?:(:\d*)(?:(:\d*)(?:(:\d*)(?:(:\d*)))))$/$1$5/
- or
- $host =~ s/(:\d*)(?:(:\d*)(?:(:\d*)(?:(:\d*)?)?)?)$/$1/;
- $host =~ s/:/_/g; # make sure that double invocations do not kill us
- return $host;
-}
-
-sub storeincache ($$$$$){
- my($confcache,$host,$method,$key,$value) = @_;
- $host = cleanhostkey $host;
- if (not defined $value ){
- $$confcache{$host}{$method}{$key} = undef;
- return;
- }
- $value =~ s/[\0- ]/ /g; # all else becomes a normal space ... get a life
- $value =~ s/ +$//; # no trailing spaces
- if (defined $$confcache{$host}{$method}{$key} and
- $$confcache{$host}{$method}{$key} ne $value) {
- $$confcache{$host}{$method}{$key} = "Dup";
- debug('coca',"store in confcache $host $method $key --> $value (duplicate)");
- } else {
- $$confcache{$host}{$method}{$key} = $value;
- debug('coca',"store in confcache $host $method $key --> $value");
- }
-
-}
-
-sub readfromcache ($$$$){
- my($confcache,$host,$method,$key) = @_;
- $host = cleanhostkey $host;
- return $$confcache{$host}{$method}{$key};
-}
-
-
-sub clearfromcache ($$){
- my($confcache,$host) = @_;
- $host = cleanhostkey $host;
- delete $$confcache{$host};
- debug('coca',"clear confcache $host");
-}
-
-
-sub populateconfcache ($$$$$) {
- my $confcache = shift;
- my $host = shift;
- my $ipv4only = shift;
- my $reread = shift;
- my $snmpoptions = shift || {};
- my $hostkey = cleanhostkey $host;
- return if defined $$confcache{$hostkey} and not $reread;
- my $snmp_errlevel = $SNMP_Session::suppress_warnings;
- my $net_snmp_errlevel = $Net_SNMP_util::suppress_warnings;
- $SNMP_Session::suppress_warnings = 3;
- $Net_SNMP_util::suppress_warnings = 3;
- debug('coca',"populate confcache $host");
-
- # clear confcache for host;
- delete $$confcache{$hostkey};
-
- my @ret;
- my %tables = ( ifDescr => 'Descr',
- ifName => 'Name',
- ifType => 'Type',
- ipAdEntIfIndex => 'Ip' );
- my @nodes = qw (ifName ifDescr ifType ipAdEntIfIndex);
- # it seems that some devices only give back sensible data if their tables
- # are walked in the right ordere ....
- foreach my $node (@nodes) {
- next if $confcache->{___deadhosts}{$hostkey} and time - $confcache->{___deadhosts}{$hostkey} < 300;
- $SNMP_Session::errmsg = undef;
- $Net_SNMP_util::ErrorMessage = undef;
- @ret = &main::snmpwalk(v4onlyifnecessary($host, $ipv4only), $snmpoptions, $node);
- unless ( $SNMP_Session::errmsg or $Net_SNMP_util::ErrorMessage){
- foreach my $ret (@ret)
- {
- my ($oid, $desc) = split(':', $ret, 2);
- if ($tables{$node} eq 'Ip') {
- storeincache($confcache,$host,$tables{$node},$oid,$desc);
- } else {
- $desc =~ s/[\0- ]+$//; #trailing whitespace is too sick for us
- $desc =~ s/[\0- ]/ /g; #whitespace is just whitespace
- storeincache($confcache,$host,$tables{$node},$desc,$oid);
- }
- };
- } else {
- $confcache->{___deadhosts}{$hostkey} = time
- if defined($SNMP_Session::errmsg) and $SNMP_Session::errmsg =~ /no response received/;
- $confcache->{___deadhosts}{$hostkey} = time
- if defined($Net_SNMP_util::ErrorMessage) and $Net_SNMP_util::ErrorMessage =~ /No response from remote/;
- debug('coca',"Skipping $node scanning because $host does not seem to support it");
- }
- }
- if ($confcache->{___deadhosts}{$hostkey} and time - $confcache->{___deadhosts}{$hostkey} < 300){
- $SNMP_Session::suppress_warnings = $snmp_errlevel;
- $Net_SNMP_util::suppress_warnings = $snmp_errlevel;
- return;
- }
- $SNMP_Session::errmsg = undef;
- $Net_SNMP_util::ErrorMessage = undef;
- @ret = &main::snmpwalk(v4onlyifnecessary($host, $ipv4only), $snmpoptions, "ifPhysAddress");
- unless ( $SNMP_Session::errmsg or $Net_SNMP_util::ErrorMessage){
- foreach my $ret (@ret)
- {
- my ($oid, $bin) = split(':', $ret, 2);
- my $eth = unpack 'H*', $bin;
- my @eth;
- while ($eth =~ s/^..//){
- push @eth, $&;
- }
- my $phys=join '-', @eth;
- storeincache($confcache,$host,"Eth",$phys,$oid);
- }
- } else {
- debug('coca',"Skipping ifPhysAddress scanning because $host does not seem to support it");
- }
-
- if (ref $$confcache{___updated} ne 'ARRAY') {
- $$confcache{___updated} = []; #init to empty array
- }
- push @{$$confcache{___updated}}, $hostkey;
-
- $SNMP_Session::suppress_warnings = $snmp_errlevel;
- $Net_SNMP_util::supress_warnings = $net_snmp_errlevel;
-}
-
-sub log2rrd ($$$) {
- my $router = shift;
- my $cfg = shift;
- my $rcfg = shift;
- my %mark;
- my %incomp;
- my %elapsed_time;
- my %rate;
- my %store;
- my %first_step;
- my %cur;
- my %next;
- my $rrd;
- my @steps = qw(300 1800 7200 86400);
- my %sizes = ( 300 => 600, 1800 => 700, 7200 => 775, 86400 => 797);
-
- open R, "<$$cfg{logdir}$$rcfg{'directory'}{$router}$router.log" or
- die "ERROR: opening $$cfg{logdir}$$rcfg{'directory'}{$router}$router.log: $!";
- debug('rrd',"converting $$cfg{logdir}$$rcfg{'directory'}{$router}$router.log");
- my $latest_timestamp;
- my %latest_counter;
- chomp($_ = <R>);
- my $time;
- my $next_time;
- ($latest_timestamp,$latest_counter{in},$latest_counter{out}) = split /\s+/;
- chomp($_ = <R>);
- ($time,$cur{in},$cur{out},$cur{maxin},$cur{maxout}) = split /\s+/;
-
- foreach my $s (@steps) {
- $mark{$s} = $latest_timestamp - ($latest_timestamp % $s) + $s;
- $first_step{$s} = $latest_timestamp - ($mark{$s} - $s);
- $elapsed_time{$s} = $s - $first_step{$s};
- $rate{in}{$s}=$cur{in};
- $rate{out}{$s}=$cur{out};
- $rate{maxin}{$s}=$cur{maxin};
- $rate{maxout}{$s}=$cur{maxout};
- }
-
- while(<R>){
- chomp;
- ($next_time,$next{in},$next{out},$next{maxin},$next{maxout}) =
- split /\s+/;
- foreach my $s (@steps) {
- # bail if we have enough entries
- next if ref $store{in}{$s} and
- scalar @{$store{in}{$s}} > $sizes{$s};
-
- # ok we are still here. If next mark is before the next time
- # we take a short step, else we gobble up
- my $next_stop;
- do {
- if ($elapsed_time{$s} + $time - $next_time > $s) {
- $next_stop = $mark{$s}-$s;
- } else {
- $next_stop = $next_time;
- }
- my $time_diff = $time-$next_stop;
- foreach my $d (qw(in out)) {
- $rate{$d}{$s} = ($rate{$d}{$s} * $elapsed_time{$s}
- + $cur{$d} * $time_diff) /
- ($elapsed_time{$s} + $time_diff);
- }
- foreach my $d (qw(maxin maxout)){
- $rate{$d}{$s} = $cur{$d} if $rate{$d}{$s} < $cur{$d};
- }
- $elapsed_time{$s} += $time_diff;
-# print "$time $next_stop\n" if $s == 300;
- if ($next_stop == $mark{$s}-$s) {
- foreach my $t (qw(in out maxin maxout)){
- $rate{$t}{$s}/=3600
- if (defined $$rcfg{'options'}{'perhour'}{$router});
- $rate{$t}{$s}/=60
- if (defined $$rcfg{'options'}{'perminute'}{$router});
- push @{$store{$t}{$s}}, $rate{$t}{$s};
- }
- $mark{$s} -= $s;
- $rate{maxin}{$s} = 0;
- $rate{maxout}{$s} = 0;
- $elapsed_time{$s} = 0;
- }
- } while ($next_stop > $next_time );
- }
- ($time,$cur{in},$cur{out},$cur{maxin},$cur{maxout}) =
- ($next_time,$next{in},$next{out},$next{maxin},$next{maxout});
- }
- close R;
- # lets see if we have rrdtool 1.2 at our hands
- my $VERSION = '0001';
- if ($RRDs::VERSION >= 1.2){
- $VERSION = '0003';
- }
- my $DST;
- my $pdprepin = (shift @{$store{in}{300}})*($first_step{300});
- my $pdprepout = (shift @{$store{out}{300}})*($first_step{300});
-
- if (defined $$rcfg{'options'}{'absolute'}{$router}) {
- $DST = 'ABSOLUTE'
- } elsif (defined $$rcfg{'options'}{'gauge'}{$router}) {
- $DST = 'GAUGE'
- } else {
- $DST = 'COUNTER'
- }
-
- my $MHB = int($$cfg{interval} * 60 * 2);
-
- my $MAX1 =
- $$rcfg{'absmax'}{$router}
- || $$rcfg{'maxbytes1'}{$router}
- || 'U';
-
- my $MAX2 =
- $$rcfg{'absmax'}{$router}
- || $$rcfg{'maxbytes2'}{$router}
- || 'U';
-
- $rrd = <<RRD;
-<!-- MRTG Log converted to RRD -->
-<rrd>
- <version> $VERSION </version>
- <step> 300 </step>
- <lastupdate> $latest_timestamp </lastupdate>
-
- <ds>
- <name> ds0 </name>
- <type> $DST </type>
- <minimal_heartbeat> $MHB </minimal_heartbeat>
- <min> 0 </min>
- <max> $MAX1 </max>
-
- <!-- PDP Status -->
- <last_ds> $latest_counter{in} </last_ds>
- <value> $pdprepin </value>
- <unknown_sec> 0 </unknown_sec>
- </ds>
-
- <ds>
- <name> ds1 </name>
- <type> $DST </type>
- <minimal_heartbeat> $MHB </minimal_heartbeat>
- <min> 0 </min>
- <max> $MAX2 </max>
-
- <!-- PDP Status -->
- <last_ds> $latest_counter{out} </last_ds>
- <value> $pdprepout </value>
- <unknown_sec> 0 </unknown_sec>
- </ds>
-RRD
- $first_step{300} = 0; # invalidate
- addarch(1,'AVERAGE','in','out',\%store,\%first_step,\$rrd);
- addarch(6,'AVERAGE','in','out',\%store,\%first_step,\$rrd);
- addarch(24,'AVERAGE','in','out',\%store,\%first_step,\$rrd);
- addarch(288,'AVERAGE','in','out',\%store,\%first_step,\$rrd);
- addarch(1,'MAX','maxin','maxout',\%store,\%first_step,\$rrd);
- addarch(6,'MAX','maxin','maxout',\%store,\%first_step,\$rrd);
- addarch(24,'MAX','maxin','maxout',\%store,\%first_step,\$rrd);
- addarch(288,'MAX','maxin','maxout',\%store,\%first_step,\$rrd);
- $rrd .= <<RRD;
-</rrd>
-RRD
-
- if ( $OS eq 'NT' or $OS eq 'OS2') {
- open (R, "|$$cfg{rrdtool} restore - $$cfg{logdir}$$rcfg{'directory'}{$router}$router.rrd");
- } else {
- open (R, "|-") or exec "$$cfg{rrdtool}","restore","-","$$cfg{logdir}$$rcfg{'directory'}{$router}$router.rrd";
- }
- print R $rrd;
- close R;
-}
-
-
-sub addarch($$$$$$$){
- my $steps = shift;
- my $cons = shift;
- my $in = shift;
- my $out = shift;
- my $store = shift;
- my $first_step = shift;
- my $rrd = shift;
- my $cdpin = 'NaN';
- my $cdpout = 'NaN';
-
- my $param_start = '';
- my $param_end = '';
- my $extra_ds = '';
- if ($RRDs::VERSION >= 1.2){
- $param_start = '<params>';
- $param_end = '</params>';
- $extra_ds = '<primary_value> 0.0000000000e+00 </primary_value> <secondary_value> 0.0000000000e+00 </secondary_value>';
- }
-
- if ($steps != 300) {
- $cdpin = shift @{$$store{$in}{300*$steps}};
- $cdpout = shift @{$$store{$out}{300*$steps}};
- };
- $$rrd .= <<RRD;
-<!-- Round Robin Archive -->
- <rra>
- <cf> $cons </cf>
- <pdp_per_row> $steps </pdp_per_row>
- $param_start <xff> 0.5 </xff> $param_end
- <cdp_prep>
- <ds>$extra_ds <value> $cdpin </value> <unknown_datapoints> 0 </unknown_datapoints></ds>
- <ds>$extra_ds <value> $cdpout </value> <unknown_datapoints> 0 </unknown_datapoints></ds>
- </cdp_prep>
-
- <database>
-RRD
- while (@{$$store{$in}{$steps*300}}){
- # we take zero as UNKNOWN
- my $inr = pop @{$$store{$in}{$steps*300}} || 'NaN';
- my $outr = pop @{$$store{$out}{$steps*300}} || 'NaN';
- $$rrd .= <<RRD;
- <row><v> $inr </v><v> $outr </v></row>
-RRD
- }
- $$rrd .= <<RRD;
- </database>
- </rra>
-RRD
-}
-
-
-
-
-# debug if the relevant debug tag is active print the debug message
-sub debug ($$) {
- return unless scalar @main::DEBUG;
- my $tag = shift;
- my $msg = shift;
- return unless grep {$_ eq $tag} @main::DEBUG;
- warn "--".$tag.": ".$msg."\n";
- return;
-}
-
-# timestamp
-sub timestamp () {
- my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
- localtime(time);
- $year += 1900;
- $mon += 1;
- return sprintf "%4d-%02d-%02d %02d:%02d:%02d", $year,$mon,$mday,$hour,$min,$sec;
-}
-
-# configure __DIE__ and __WARN__
-
-sub setup_loghandlers ($){
- $::global_logfile = $_[0];
- for($_[0]){
- /^eventlog$/i && do {
- require Win32::EventLog;
- $SIG{__WARN__} = sub {
- my $EventLog = Win32::EventLog->new('MRTG');
- my $Type = ($_[0] =~ /warning/) ?
- &Win32::EventLog::EVENTLOG_WARNING_TYPE :
- &Win32::EventLog::EVENTLOG_INFORMATION_TYPE;
- my $Msg = $_[0];
- $Msg =~ s/\n/\r\n/g;
- $Msg =~ s/[\n\r]$//g;
- $EventLog->Report({
- EventID => 1000,
- Category => "WARN",
- EventType => $Type,
- Data => '',
- Strings => $Msg });
- $EventLog->Close;
- };
- $SIG{__DIE__} = sub {
- return if $^S ; # no handler in eval
- my $EventLog = Win32::EventLog->new('MRTG');
- my $Msg = $_[0];
- $Msg =~ s/\n/\r\n/g;
- $Msg =~ s/[\n\r]$//g;
- $EventLog->Report({
- EventID => 1000,
- Category => "ERROR",
- EventType => &Win32::EventLog::EVENTLOG_ERROR_TYPE,
- Data => '',
- Strings => $Msg });
- $EventLog->Close;
- exit 1;
- };
- last;
- };
- $SIG{__WARN__} = sub {
- if (open DEB, ">>$::global_logfile") {
- print DEB timestamp." -- $_[0]";
- close DEB;
- } else {
- print STDERR timestamp." -- $_[0]"
- }
- };
-
-
- $SIG{__DIE__} = sub {
- return if $^S ; # no handler in eval
- if ( open DEB, ">>$::global_logfile") {
- print DEB timestamp." -- $_[0]";
- close DEB;
- } else {
- print STDERR timestamp." -- $_[0]"
- }
- exit 1
- };
-
- }
-}
-
-# Adds the v4only attribute to a target if the caller requests it.
-# (this includes targets specified using numeric IPv6 addresses...)
-sub v4onlyifnecessary ($$) {
- my $target = shift;
- my $add = shift;
- my ($v6addr, $temptarget);
-
- if($add) {
- # Catch numeric IPv6 addresses
- if ( $target =~ /(\[[\w:]*\])(.*)/) {
- ($v6addr, $temptarget) = ($1,$2);
- } else {
- $temptarget = $target;
- }
- return $target.(":" x (5 - ($temptarget =~ tr/://))).":v4only";
- } else {
- return $target;
- }
-}
-__END__
-
-=pod
-
-=head1 NAME
-
-MRTG_lib.pm - Library for MRTG and support scripts
-
-=head1 SYNOPSIS
-
- use MRTG_lib;
- my ($configfile, @target_names, %globalcfg, %targetcfg);
- readcfg($configfile, \@target_names, \%globalcfg, \%targetcfg);
- my (@parsed_targets);
- cfgcheck(\@target_names, \%globalcfg, \%targetcfg, \@parsed_targets);
-
-=head1 DESCRIPTION
-
-MRTG_lib is part of MRTG, the Multi Router Traffic Grapher. It was separated
-from MRTG to allow other programs to easily use the same config files. The
-main part of MRTG_lib is the config file parser but some other funcions are
-there too.
-
-=over 4
-
-=item C<$MRTG_lib::OS>
-
-Type of OS: WIN, UNIX, VMS
-
-=item C<$MRTG_lib::SL>
-
-I<Slash> in the current OS.
-
-=item C<$MRTG_lib::PS>
-
-Path separator in PATH variable
-
-=item C<readcfg>
-
-C<readcfg($file, \@targets, \%globalcfg, \%targetcfg [, $prefix, \%extrules])>
-
-Reads a config file, parses it and fills some arrays and hashes. The
-mandatory arguments are: the name of the config file, a ref to an array which
-will be filled with a list of the target names, a hashref for the global
-configuration, a hashref for the target configuration.
-
-The configuration file syntax is:
-
- globaloption: value
- targetoption[targetname]: value
- aprefix*extglobal: value
- aprefix*exttarget[target2]: value
-
-E.g.
-
- workdir: /var/stat/mrtg
- target[router1]: 2:public@router1.local.net
- 14all*columns: 2
-
-The global config hash has the structure
-
- $globalcfg{configoption} = 'value'
-
-The target config hash has the structure
-
- $targetcfg{configoption}{targetname} = 'value'
-
-See L<mrtg-reference> for more information about the MRTG configuration syntax.
-
-C<readcfg> can take two additional arguments to extend the config file
-syntax. This allows programs to put their configuration into the mrtg config
-file. The fifth argument is the prefix of the extension, the sixth argument
-is a hash with the checkrules for these extension settings. E.g. if the
-prefix is "14all" C<readcfg> will check config lines that begin with
-"14all*", i.e. all lines like
-
- 14all*columns: 2
- 14all*graphsize[target3]: 500 200
-
-against the rules in %extrules. The format of this hash is:
-
- $extrules{option} = [sub{$_[0] =~ m/^\d+$/}, sub{"Error message for $_[0]"}]
- i.e.
- $extrules{option}[0] -> a test expression
- $extrules{option}[1] -> error message if test fails
-
-The first part of the array is a perl expression to test the value of the
-option. The test can access this value in the variable "$arg". The second
-part of the array is an error message to display when the test fails. The
-failed value can be integrated by using the variable "$arg".
-
-Config settings with an different prefix than the one given in the C<readcfg>
-call are not checked but inserted into I<%globalcfg> and I<%targetcfg>.
-Prefixed settings keep their prefix in the config hashes:
-
- $targetcfg{'14all*graphsize'}{'target3'} = '500 200'
-
-=item C<cfgcheck>
-
-C<cfgcheck(\@target_names, \%globalcfg, \%targetcfg, \@parsed_targets)>
-
-Checks the configuration read by C<readcfg>. Checks the values in the config
-for syntactical and/or semantical errors. Sets defaults for some options.
-Parses the "target[...]" options and filles the array @parsed_targets ready
-for mrtg functions.
-
-The first three arguments are the same as for C<readcfg>. The fourth argument
-is an arrayref which will be filled with the parsed target defs.
-
-C<cfgcheck> converts the values of target settings I<options>, e.g.
-
- options[router1]: bits, growright
-
-to a hash:
-
- $targetcfg{'option'}{'bits'}{'router1'} = 1
- $targetcfg{'option'}{'growright'}{'router1'} = 1
-
-This is not done by C<readcfg> so if you don't use C<cfgcheck> you have to
-check the scalar variable I<$targetcfg{'option'}{'router1'}> (MRTG allows
-options to be separated by space or ',').
-
-=item C<ensureSL>
-
-C<ensureSL(\$pathname)>
-
-Checks that the I<pathname> does not contain double path separators and ends
-with a path separator. It uses $MRTG_lib::SL as path separator which will be /
-or \ depending on the OS.
-
-=item C<log2rrd>
-
-C<log2rrd ($router,\%globalcfg,\%targetcfg)>
-
-Convert log file to rrd format. Needs rrdtool.
-
-=item C<datestr>
-
-C<datestr(time)>
-
-Returns the time given in the argument as a nicely formated date string.
-The argument has to be in UNIX time format (seconds since 1970-1-1).
-
-=item C<timestamp>
-
-C<timestamp()>
-
-Return a string representing the current time.
-
-=item C<setup_loghandlers>
-
-C<setup_loghandlers(filename)>
-
-Install signalhandlers for __DIE__ and __WARN__ making the errors
-go the the specified destination. If filename is 'eventlog'
-mrtg will log to the windows event logger.
-
-=item C<expistr>
-
-C<expistr(time)>
-
-Returns the time given in the argument formatted suitable for HTTP
-Expire-Headers.
-
-=item C<create_pid>
-
-C<create_pid()>
-
-Creates a pid file for the mrtg daemon
-
-=item C<demonize_me>
-
-C<demonize_me()>
-
-Puts the running program into background, detaching it from the terminal.
-
-=item C<populatecache>
-
-C<populatecache(\%confcache, $host, $reread, $snmpoptshash)>
-
-Reads the SNMP variables I<ifDescr>, I<ipAdEntIfIndex>, I<ifPhysAddress>, I<ifName> from
-the I<host> and stores the values in I<%confcache> as follows:
-
- $confcache{$host}{'Descr'}{ifDescr}{oid} = (ifDescr or 'Dup')
- $confcache{$host}{'IP'}{ipAdEntIfIndex}{oid} = (ipAdEntIfIndex or 'Dup')
- $confcache{$host}{'Eth'}{ifPhysAddress}{oid} = (ifPhysAddress or 'Dup')
- $confcache{$host}{'Name'}{ifName}{oid} = (ifName or 'Dup')
- $confcache{$host}{'Type'}{ifType}{oid} = (ifType or 'Dup')
-
-The value (at the right side of =) is 'Dup' if a value was retrieved
-muliple times, the retrieved value else.
-
-=item C<readconfcache>
-
-C<my $confcache = readconfcache($file)>
-
-Preload the confcache from a file.
-
-=item C<readfromconfcache>
-
-C<writeconfcache($confcache,$file)>
-
-Store the current confcache into a file.
-
-=item C<writeconfcache>
-
-C<writeconfcache($confcache,$file)>
-
-Store the current confcache into a file.
-
-=item C<storeincache>
-
-C<storeincache($confcache,$host,$method,$key,$value)>
-
-=item C<readfromcache>
-
-C<readfromcache($confcache,$host,$method,$key)>
-
-=item C<clearfromcache>
-
-C<clearfromcache($confcache,$host)>
-
-=item C<debug>
-
-C<debug($type, $message)>
-
-Prints the I<message> on STDERR if debugging is enabled for type I<type>.
-A debug type is enabled if I<type> is in array @main::DEBUG.
-
-=back
-
-=head1 AUTHORS
-
-Rainer Bawidamann E<lt>Rainer.Bawidamann@rz.uni-ulm.deE<gt>
-
-(This Manpage)
-
-=cut
diff --git a/src/lib/mrtg2/Net_SNMP_util.pm b/src/lib/mrtg2/Net_SNMP_util.pm
deleted file mode 100644
index b0299fc..0000000
--- a/src/lib/mrtg2/Net_SNMP_util.pm
+++ /dev/null
@@ -1,2130 +0,0 @@
-### - *- mode: Perl -*-
-######################################################################
-### Net_SNMP_util -- SNMP utilities using Net::SNMP
-######################################################################
-### Copyright (c) 2005-2011 Mike Mitchell.
-###
-### This program is free software; you can redistribute it under the
-### "Artistic License" included in this distribution (file "Artistic").
-######################################################################
-### Created by: Mike Mitchell <Mike.Mitchell@sas.com>
-###
-### Contributions and fixes by:
-###
-### Laszlo Herczeg <laszlo.herczeg@austinenergy.com>
-### ignore unimplemented SNMP_Session.pm options
-###
-### Daniel McDonald <dmcdonald@digicontech.com>
-### make sure snmpwalk_flg stops when last instance in table is fetched
-###
-### Alexander Kozlov <avk@post.eao.ru>
-### Leave snmpwalk_flg early if no OIDs are returned
-###
-### <jaccobs@online.nl>
-### parse NOTIFICATION-TYPE in MIB
-###
-### Dan Thorson <Dan.Thorson@seagate.com>
-### Handle quotes in MIB comments better
-###
-### Daniel J McDonald <dan.mcdonald@austinenergy.com>
-### fix getbulk_request -> get_bulk_request typo
-###
-### Tobias Oetiker <tobi@oetiker.ch>
-### fix '-privpassword' error against snmpv2 hosts
-###
-######################################################################
-
-package Net_SNMP_util;
-
-=head1 NAME
-
-Net_SNMP_util - SNMP utilities based on Net::SNMP
-
-=head1 SYNOPSIS
-
-The Net_SNMP_util module implements SNMP utilities using the Net::SNMP module.
-It implements snmpget, snmpgetnext, snmpwalk, snmpset, snmptrap, and
-snmpgetbulk. The Net_SNMP_util module assumes that the user has a basic
-understanding of the Simple Network Management Protocol and related network
-management concepts.
-
-=head1 DESCRIPTION
-
-The Net_SNMP_util module simplifies SNMP queries even more than Net::SNMP
-alone. Easy-to-use "get", "getnext", "walk", "set", "trap", and "getbulk"
-routines are provided, hiding all the details of a SNMP query.
-
-=cut
-
-# ==========================================================================
-
-use strict;
-
-## Validate the version of Perl
-
-BEGIN
-{
- die('Perl version 5.6.0 or greater is required') if ($] < 5.006);
-}
-
-## Handle importing/exporting of symbols
-
-use vars qw( @ISA @EXPORT $VERSION $ErrorMessage);
-use Exporter;
-
-our @ISA = qw( Exporter );
-
-our @EXPORT = qw(
- snmpget snmpgetnext snmpwalk snmpset snmptrap snmpgetbulk snmpmaptable
- snmpmaptable4 snmpwalkhash snmpmapOID snmpMIB_to_OID snmpLoad_OID_Cache
- snmpQueue_MIB_File ErrorMessage
-);
-
-## Version of the Net_SNMP_util module
-
-our $VERSION = v1.0.20;
-
-use Carp;
-
-use Net::SNMP v5.0;
-
-# The OID numbers from RFC1213 (MIB-II) and RFC1315 (Frame Relay)
-# are pre-loaded below.
-%Net_SNMP_util::OIDS =
- (
- 'iso' => '1',
- 'org' => '1.3',
- 'dod' => '1.3.6',
- 'internet' => '1.3.6.1',
- 'directory' => '1.3.6.1.1',
- 'mgmt' => '1.3.6.1.2',
- 'mib-2' => '1.3.6.1.2.1',
- 'system' => '1.3.6.1.2.1.1',
- 'sysDescr' => '1.3.6.1.2.1.1.1.0',
- 'sysObjectID' => '1.3.6.1.2.1.1.2.0',
- 'sysUpTime' => '1.3.6.1.2.1.1.3.0',
- 'sysUptime' => '1.3.6.1.2.1.1.3.0',
- 'sysContact' => '1.3.6.1.2.1.1.4.0',
- 'sysName' => '1.3.6.1.2.1.1.5.0',
- 'sysLocation' => '1.3.6.1.2.1.1.6.0',
- 'sysServices' => '1.3.6.1.2.1.1.7.0',
- 'interfaces' => '1.3.6.1.2.1.2',
- 'ifNumber' => '1.3.6.1.2.1.2.1.0',
- 'ifTable' => '1.3.6.1.2.1.2.2',
- 'ifEntry' => '1.3.6.1.2.1.2.2.1',
- 'ifIndex' => '1.3.6.1.2.1.2.2.1.1',
- 'ifInOctets' => '1.3.6.1.2.1.2.2.1.10',
- 'ifInUcastPkts' => '1.3.6.1.2.1.2.2.1.11',
- 'ifInNUcastPkts' => '1.3.6.1.2.1.2.2.1.12',
- 'ifInDiscards' => '1.3.6.1.2.1.2.2.1.13',
- 'ifInErrors' => '1.3.6.1.2.1.2.2.1.14',
- 'ifInUnknownProtos' => '1.3.6.1.2.1.2.2.1.15',
- 'ifOutOctets' => '1.3.6.1.2.1.2.2.1.16',
- 'ifOutUcastPkts' => '1.3.6.1.2.1.2.2.1.17',
- 'ifOutNUcastPkts' => '1.3.6.1.2.1.2.2.1.18',
- 'ifOutDiscards' => '1.3.6.1.2.1.2.2.1.19',
- 'ifDescr' => '1.3.6.1.2.1.2.2.1.2',
- 'ifOutErrors' => '1.3.6.1.2.1.2.2.1.20',
- 'ifOutQLen' => '1.3.6.1.2.1.2.2.1.21',
- 'ifSpecific' => '1.3.6.1.2.1.2.2.1.22',
- 'ifType' => '1.3.6.1.2.1.2.2.1.3',
- 'ifMtu' => '1.3.6.1.2.1.2.2.1.4',
- 'ifSpeed' => '1.3.6.1.2.1.2.2.1.5',
- 'ifPhysAddress' => '1.3.6.1.2.1.2.2.1.6',
- 'ifAdminHack' => '1.3.6.1.2.1.2.2.1.7',
- 'ifAdminStatus' => '1.3.6.1.2.1.2.2.1.7',
- 'ifOperHack' => '1.3.6.1.2.1.2.2.1.8',
- 'ifOperStatus' => '1.3.6.1.2.1.2.2.1.8',
- 'ifLastChange' => '1.3.6.1.2.1.2.2.1.9',
- 'at' => '1.3.6.1.2.1.3',
- 'atTable' => '1.3.6.1.2.1.3.1',
- 'atEntry' => '1.3.6.1.2.1.3.1.1',
- 'atIfIndex' => '1.3.6.1.2.1.3.1.1.1',
- 'atPhysAddress' => '1.3.6.1.2.1.3.1.1.2',
- 'atNetAddress' => '1.3.6.1.2.1.3.1.1.3',
- 'ip' => '1.3.6.1.2.1.4',
- 'ipForwarding' => '1.3.6.1.2.1.4.1',
- 'ipOutRequests' => '1.3.6.1.2.1.4.10',
- 'ipOutDiscards' => '1.3.6.1.2.1.4.11',
- 'ipOutNoRoutes' => '1.3.6.1.2.1.4.12',
- 'ipReasmTimeout' => '1.3.6.1.2.1.4.13',
- 'ipReasmReqds' => '1.3.6.1.2.1.4.14',
- 'ipReasmOKs' => '1.3.6.1.2.1.4.15',
- 'ipReasmFails' => '1.3.6.1.2.1.4.16',
- 'ipFragOKs' => '1.3.6.1.2.1.4.17',
- 'ipFragFails' => '1.3.6.1.2.1.4.18',
- 'ipFragCreates' => '1.3.6.1.2.1.4.19',
- 'ipDefaultTTL' => '1.3.6.1.2.1.4.2',
- 'ipAddrTable' => '1.3.6.1.2.1.4.20',
- 'ipAddrEntry' => '1.3.6.1.2.1.4.20.1',
- 'ipAdEntAddr' => '1.3.6.1.2.1.4.20.1.1',
- 'ipAdEntIfIndex' => '1.3.6.1.2.1.4.20.1.2',
- 'ipAdEntNetMask' => '1.3.6.1.2.1.4.20.1.3',
- 'ipAdEntBcastAddr' => '1.3.6.1.2.1.4.20.1.4',
- 'ipAdEntReasmMaxSize' => '1.3.6.1.2.1.4.20.1.5',
- 'ipRouteTable' => '1.3.6.1.2.1.4.21',
- 'ipRouteEntry' => '1.3.6.1.2.1.4.21.1',
- 'ipRouteDest' => '1.3.6.1.2.1.4.21.1.1',
- 'ipRouteAge' => '1.3.6.1.2.1.4.21.1.10',
- 'ipRouteMask' => '1.3.6.1.2.1.4.21.1.11',
- 'ipRouteMetric5' => '1.3.6.1.2.1.4.21.1.12',
- 'ipRouteInfo' => '1.3.6.1.2.1.4.21.1.13',
- 'ipRouteIfIndex' => '1.3.6.1.2.1.4.21.1.2',
- 'ipRouteMetric1' => '1.3.6.1.2.1.4.21.1.3',
- 'ipRouteMetric2' => '1.3.6.1.2.1.4.21.1.4',
- 'ipRouteMetric3' => '1.3.6.1.2.1.4.21.1.5',
- 'ipRouteMetric4' => '1.3.6.1.2.1.4.21.1.6',
- 'ipRouteNextHop' => '1.3.6.1.2.1.4.21.1.7',
- 'ipRouteType' => '1.3.6.1.2.1.4.21.1.8',
- 'ipRouteProto' => '1.3.6.1.2.1.4.21.1.9',
- 'ipNetToMediaTable' => '1.3.6.1.2.1.4.22',
- 'ipNetToMediaEntry' => '1.3.6.1.2.1.4.22.1',
- 'ipNetToMediaIfIndex' => '1.3.6.1.2.1.4.22.1.1',
- 'ipNetToMediaPhysAddress' => '1.3.6.1.2.1.4.22.1.2',
- 'ipNetToMediaNetAddress' => '1.3.6.1.2.1.4.22.1.3',
- 'ipNetToMediaType' => '1.3.6.1.2.1.4.22.1.4',
- 'ipRoutingDiscards' => '1.3.6.1.2.1.4.23',
- 'ipInReceives' => '1.3.6.1.2.1.4.3',
- 'ipInHdrErrors' => '1.3.6.1.2.1.4.4',
- 'ipInAddrErrors' => '1.3.6.1.2.1.4.5',
- 'ipForwDatagrams' => '1.3.6.1.2.1.4.6',
- 'ipInUnknownProtos' => '1.3.6.1.2.1.4.7',
- 'ipInDiscards' => '1.3.6.1.2.1.4.8',
- 'ipInDelivers' => '1.3.6.1.2.1.4.9',
- 'icmp' => '1.3.6.1.2.1.5',
- 'icmpInMsgs' => '1.3.6.1.2.1.5.1',
- 'icmpInTimestamps' => '1.3.6.1.2.1.5.10',
- 'icmpInTimestampReps' => '1.3.6.1.2.1.5.11',
- 'icmpInAddrMasks' => '1.3.6.1.2.1.5.12',
- 'icmpInAddrMaskReps' => '1.3.6.1.2.1.5.13',
- 'icmpOutMsgs' => '1.3.6.1.2.1.5.14',
- 'icmpOutErrors' => '1.3.6.1.2.1.5.15',
- 'icmpOutDestUnreachs' => '1.3.6.1.2.1.5.16',
- 'icmpOutTimeExcds' => '1.3.6.1.2.1.5.17',
- 'icmpOutParmProbs' => '1.3.6.1.2.1.5.18',
- 'icmpOutSrcQuenchs' => '1.3.6.1.2.1.5.19',
- 'icmpInErrors' => '1.3.6.1.2.1.5.2',
- 'icmpOutRedirects' => '1.3.6.1.2.1.5.20',
- 'icmpOutEchos' => '1.3.6.1.2.1.5.21',
- 'icmpOutEchoReps' => '1.3.6.1.2.1.5.22',
- 'icmpOutTimestamps' => '1.3.6.1.2.1.5.23',
- 'icmpOutTimestampReps' => '1.3.6.1.2.1.5.24',
- 'icmpOutAddrMasks' => '1.3.6.1.2.1.5.25',
- 'icmpOutAddrMaskReps' => '1.3.6.1.2.1.5.26',
- 'icmpInDestUnreachs' => '1.3.6.1.2.1.5.3',
- 'icmpInTimeExcds' => '1.3.6.1.2.1.5.4',
- 'icmpInParmProbs' => '1.3.6.1.2.1.5.5',
- 'icmpInSrcQuenchs' => '1.3.6.1.2.1.5.6',
- 'icmpInRedirects' => '1.3.6.1.2.1.5.7',
- 'icmpInEchos' => '1.3.6.1.2.1.5.8',
- 'icmpInEchoReps' => '1.3.6.1.2.1.5.9',
- 'tcp' => '1.3.6.1.2.1.6',
- 'tcpRtoAlgorithm' => '1.3.6.1.2.1.6.1',
- 'tcpInSegs' => '1.3.6.1.2.1.6.10',
- 'tcpOutSegs' => '1.3.6.1.2.1.6.11',
- 'tcpRetransSegs' => '1.3.6.1.2.1.6.12',
- 'tcpConnTable' => '1.3.6.1.2.1.6.13',
- 'tcpConnEntry' => '1.3.6.1.2.1.6.13.1',
- 'tcpConnState' => '1.3.6.1.2.1.6.13.1.1',
- 'tcpConnLocalAddress' => '1.3.6.1.2.1.6.13.1.2',
- 'tcpConnLocalPort' => '1.3.6.1.2.1.6.13.1.3',
- 'tcpConnRemAddress' => '1.3.6.1.2.1.6.13.1.4',
- 'tcpConnRemPort' => '1.3.6.1.2.1.6.13.1.5',
- 'tcpInErrs' => '1.3.6.1.2.1.6.14',
- 'tcpOutRsts' => '1.3.6.1.2.1.6.15',
- 'tcpRtoMin' => '1.3.6.1.2.1.6.2',
- 'tcpRtoMax' => '1.3.6.1.2.1.6.3',
- 'tcpMaxConn' => '1.3.6.1.2.1.6.4',
- 'tcpActiveOpens' => '1.3.6.1.2.1.6.5',
- 'tcpPassiveOpens' => '1.3.6.1.2.1.6.6',
- 'tcpAttemptFails' => '1.3.6.1.2.1.6.7',
- 'tcpEstabResets' => '1.3.6.1.2.1.6.8',
- 'tcpCurrEstab' => '1.3.6.1.2.1.6.9',
- 'udp' => '1.3.6.1.2.1.7',
- 'udpInDatagrams' => '1.3.6.1.2.1.7.1',
- 'udpNoPorts' => '1.3.6.1.2.1.7.2',
- 'udpInErrors' => '1.3.6.1.2.1.7.3',
- 'udpOutDatagrams' => '1.3.6.1.2.1.7.4',
- 'udpTable' => '1.3.6.1.2.1.7.5',
- 'udpEntry' => '1.3.6.1.2.1.7.5.1',
- 'udpLocalAddress' => '1.3.6.1.2.1.7.5.1.1',
- 'udpLocalPort' => '1.3.6.1.2.1.7.5.1.2',
- 'egp' => '1.3.6.1.2.1.8',
- 'egpInMsgs' => '1.3.6.1.2.1.8.1',
- 'egpInErrors' => '1.3.6.1.2.1.8.2',
- 'egpOutMsgs' => '1.3.6.1.2.1.8.3',
- 'egpOutErrors' => '1.3.6.1.2.1.8.4',
- 'egpNeighTable' => '1.3.6.1.2.1.8.5',
- 'egpNeighEntry' => '1.3.6.1.2.1.8.5.1',
- 'egpNeighState' => '1.3.6.1.2.1.8.5.1.1',
- 'egpNeighStateUps' => '1.3.6.1.2.1.8.5.1.10',
- 'egpNeighStateDowns' => '1.3.6.1.2.1.8.5.1.11',
- 'egpNeighIntervalHello' => '1.3.6.1.2.1.8.5.1.12',
- 'egpNeighIntervalPoll' => '1.3.6.1.2.1.8.5.1.13',
- 'egpNeighMode' => '1.3.6.1.2.1.8.5.1.14',
- 'egpNeighEventTrigger' => '1.3.6.1.2.1.8.5.1.15',
- 'egpNeighAddr' => '1.3.6.1.2.1.8.5.1.2',
- 'egpNeighAs' => '1.3.6.1.2.1.8.5.1.3',
- 'egpNeighInMsgs' => '1.3.6.1.2.1.8.5.1.4',
- 'egpNeighInErrs' => '1.3.6.1.2.1.8.5.1.5',
- 'egpNeighOutMsgs' => '1.3.6.1.2.1.8.5.1.6',
- 'egpNeighOutErrs' => '1.3.6.1.2.1.8.5.1.7',
- 'egpNeighInErrMsgs' => '1.3.6.1.2.1.8.5.1.8',
- 'egpNeighOutErrMsgs' => '1.3.6.1.2.1.8.5.1.9',
- 'egpAs' => '1.3.6.1.2.1.8.6',
- 'transmission' => '1.3.6.1.2.1.10',
- 'frame-relay' => '1.3.6.1.2.1.10.32',
- 'frDlcmiTable' => '1.3.6.1.2.1.10.32.1',
- 'frDlcmiEntry' => '1.3.6.1.2.1.10.32.1.1',
- 'frDlcmiIfIndex' => '1.3.6.1.2.1.10.32.1.1.1',
- 'frDlcmiState' => '1.3.6.1.2.1.10.32.1.1.2',
- 'frDlcmiAddress' => '1.3.6.1.2.1.10.32.1.1.3',
- 'frDlcmiAddressLen' => '1.3.6.1.2.1.10.32.1.1.4',
- 'frDlcmiPollingInterval' => '1.3.6.1.2.1.10.32.1.1.5',
- 'frDlcmiFullEnquiryInterval' => '1.3.6.1.2.1.10.32.1.1.6',
- 'frDlcmiErrorThreshold' => '1.3.6.1.2.1.10.32.1.1.7',
- 'frDlcmiMonitoredEvents' => '1.3.6.1.2.1.10.32.1.1.8',
- 'frDlcmiMaxSupportedVCs' => '1.3.6.1.2.1.10.32.1.1.9',
- 'frDlcmiMulticast' => '1.3.6.1.2.1.10.32.1.1.10',
- 'frCircuitTable' => '1.3.6.1.2.1.10.32.2',
- 'frCircuitEntry' => '1.3.6.1.2.1.10.32.2.1',
- 'frCircuitIfIndex' => '1.3.6.1.2.1.10.32.2.1.1',
- 'frCircuitDlci' => '1.3.6.1.2.1.10.32.2.1.2',
- 'frCircuitState' => '1.3.6.1.2.1.10.32.2.1.3',
- 'frCircuitReceivedFECNs' => '1.3.6.1.2.1.10.32.2.1.4',
- 'frCircuitReceivedBECNs' => '1.3.6.1.2.1.10.32.2.1.5',
- 'frCircuitSentFrames' => '1.3.6.1.2.1.10.32.2.1.6',
- 'frCircuitSentOctets' => '1.3.6.1.2.1.10.32.2.1.7',
- 'frOutOctets' => '1.3.6.1.2.1.10.32.2.1.7',
- 'frCircuitReceivedFrames' => '1.3.6.1.2.1.10.32.2.1.8',
- 'frCircuitReceivedOctets' => '1.3.6.1.2.1.10.32.2.1.9',
- 'frInOctets' => '1.3.6.1.2.1.10.32.2.1.9',
- 'frCircuitCreationTime' => '1.3.6.1.2.1.10.32.2.1.10',
- 'frCircuitLastTimeChange' => '1.3.6.1.2.1.10.32.2.1.11',
- 'frCircuitCommittedBurst' => '1.3.6.1.2.1.10.32.2.1.12',
- 'frCircuitExcessBurst' => '1.3.6.1.2.1.10.32.2.1.13',
- 'frCircuitThroughput' => '1.3.6.1.2.1.10.32.2.1.14',
- 'frErrTable' => '1.3.6.1.2.1.10.32.3',
- 'frErrEntry' => '1.3.6.1.2.1.10.32.3.1',
- 'frErrIfIndex' => '1.3.6.1.2.1.10.32.3.1.1',
- 'frErrType' => '1.3.6.1.2.1.10.32.3.1.2',
- 'frErrData' => '1.3.6.1.2.1.10.32.3.1.3',
- 'frErrTime' => '1.3.6.1.2.1.10.32.3.1.4',
- 'frame-relay-globals' => '1.3.6.1.2.1.10.32.4',
- 'frTrapState' => '1.3.6.1.2.1.10.32.4.1',
- 'snmp' => '1.3.6.1.2.1.11',
- 'snmpInPkts' => '1.3.6.1.2.1.11.1',
- 'snmpInBadValues' => '1.3.6.1.2.1.11.10',
- 'snmpInReadOnlys' => '1.3.6.1.2.1.11.11',
- 'snmpInGenErrs' => '1.3.6.1.2.1.11.12',
- 'snmpInTotalReqVars' => '1.3.6.1.2.1.11.13',
- 'snmpInTotalSetVars' => '1.3.6.1.2.1.11.14',
- 'snmpInGetRequests' => '1.3.6.1.2.1.11.15',
- 'snmpInGetNexts' => '1.3.6.1.2.1.11.16',
- 'snmpInSetRequests' => '1.3.6.1.2.1.11.17',
- 'snmpInGetResponses' => '1.3.6.1.2.1.11.18',
- 'snmpInTraps' => '1.3.6.1.2.1.11.19',
- 'snmpOutPkts' => '1.3.6.1.2.1.11.2',
- 'snmpOutTooBigs' => '1.3.6.1.2.1.11.20',
- 'snmpOutNoSuchNames' => '1.3.6.1.2.1.11.21',
- 'snmpOutBadValues' => '1.3.6.1.2.1.11.22',
- 'snmpOutGenErrs' => '1.3.6.1.2.1.11.24',
- 'snmpOutGetRequests' => '1.3.6.1.2.1.11.25',
- 'snmpOutGetNexts' => '1.3.6.1.2.1.11.26',
- 'snmpOutSetRequests' => '1.3.6.1.2.1.11.27',
- 'snmpOutGetResponses' => '1.3.6.1.2.1.11.28',
- 'snmpOutTraps' => '1.3.6.1.2.1.11.29',
- 'snmpInBadVersions' => '1.3.6.1.2.1.11.3',
- 'snmpEnableAuthenTraps' => '1.3.6.1.2.1.11.30',
- 'snmpInBadCommunityNames' => '1.3.6.1.2.1.11.4',
- 'snmpInBadCommunityUses' => '1.3.6.1.2.1.11.5',
- 'snmpInASNParseErrs' => '1.3.6.1.2.1.11.6',
- 'snmpInTooBigs' => '1.3.6.1.2.1.11.8',
- 'snmpInNoSuchNames' => '1.3.6.1.2.1.11.9',
- 'ifName' => '1.3.6.1.2.1.31.1.1.1.1',
- 'ifInMulticastPkts' => '1.3.6.1.2.1.31.1.1.1.2',
- 'ifInBroadcastPkts' => '1.3.6.1.2.1.31.1.1.1.3',
- 'ifOutMulticastPkts' => '1.3.6.1.2.1.31.1.1.1.4',
- 'ifOutBroadcastPkts' => '1.3.6.1.2.1.31.1.1.1.5',
- 'ifHCInOctets' => '1.3.6.1.2.1.31.1.1.1.6',
- 'ifHCInUcastPkts' => '1.3.6.1.2.1.31.1.1.1.7',
- 'ifHCInMulticastPkts' => '1.3.6.1.2.1.31.1.1.1.8',
- 'ifHCInBroadcastPkts' => '1.3.6.1.2.1.31.1.1.1.9',
- 'ifHCOutOctets' => '1.3.6.1.2.1.31.1.1.1.10',
- 'ifHCOutUcastPkts' => '1.3.6.1.2.1.31.1.1.1.11',
- 'ifHCOutMulticastPkts' => '1.3.6.1.2.1.31.1.1.1.12',
- 'ifHCOutBroadcastPkts' => '1.3.6.1.2.1.31.1.1.1.13',
- 'ifLinkUpDownTrapEnable' => '1.3.6.1.2.1.31.1.1.1.14',
- 'ifHighSpeed' => '1.3.6.1.2.1.31.1.1.1.15',
- 'ifPromiscuousMode' => '1.3.6.1.2.1.31.1.1.1.16',
- 'ifConnectorPresent' => '1.3.6.1.2.1.31.1.1.1.17',
- 'ifAlias' => '1.3.6.1.2.1.31.1.1.1.18',
- 'ifCounterDiscontinuityTime' => '1.3.6.1.2.1.31.1.1.1.19',
- 'experimental' => '1.3.6.1.3',
- 'private' => '1.3.6.1.4',
- 'enterprises' => '1.3.6.1.4.1',
- );
-
-# GIL
-my %revOIDS = (); # Reversed %Net_SNMP_util::OIDS hash
-my $RevNeeded = 1;
-
-undef $Net_SNMP_util::Host;
-undef $Net_SNMP_util::Session;
-undef $Net_SNMP_util::Version;
-undef $Net_SNMP_util::LHost;
-undef $Net_SNMP_util::IPv4only;
-undef $Net_SNMP_util::ContextEngineID;
-undef $Net_SNMP_util::ContextName;
-$Net_SNMP_util::Debug = 0;
-$Net_SNMP_util::SuppressWarnings = 0;
-$Net_SNMP_util::CacheFile = "OID_cache.txt";
-$Net_SNMP_util::CacheLoaded = 0;
-$Net_SNMP_util::ReturnArrayRefs = 0;
-$Net_SNMP_util::ReturnHashRefs = 0;
-$Net_SNMP_util::MaxRepetitions = 12;
-
-### Prototypes
-sub snmpget ($@);
-sub snmpgetnext ($@);
-sub snmpopen ($$$);
-sub snmpwalk ($@);
-sub snmpwalk_flg ($$@);
-sub snmpset ($@);
-sub snmptrap ($$$$$@);
-sub snmpgetbulk ($$$@);
-sub snmpwalkhash ($$@);
-sub toOID (@);
-sub snmpmapOID (@);
-sub snmpMIB_to_OID ($);
-sub Check_OID ($);
-sub snmpLoad_OID_Cache ($);
-sub snmpQueue_MIB_File (@);
-sub ASNtype ($);
-sub error_msg ($);
-sub MIB_fill_OID ($);
-
-sub version () { $VERSION; }
-
-=head1 Option Notes
-
-=over
-
-=item host Parameter
-
-SNMP parameters can be specified as part of the hostname/ip address passed
-as the first argument. The syntax is
-
- community@host:port:timeout:retries:backoff:version
-
-If the community is left off, it defaults to "public".
-If the port is left off, it defaults to 161 for everything but snmptrap().
-The snmptrap() routine uses a default port of 162.
-Timeout and retries defaults to whatever Net::SNMP uses, currently 5.0 seconds
-and 1 retry (2 tries total).
-The backoff parameter is currently unimplemented.
-The version parameter defaults to SNMP version 1. Some SNMP values such as
-64-bit counters have to be queried using SNMP version 2. Specifying "2" or
-"2c" as the version parameter will accomplish this. The snmpgetbulk routine
-is only supported in SNMP version 2 and higher. Additional security features
-are available under SNMP version 3.
-
-Some machines have additional security features that only allow SNMP
-queries to come from certain IP addresses. If the host doing the query
-has multiple interfaces, it may be necessary to specify the interface
-the query should come from. The port parameter is further broken down into
-
- remote_port!local_address!local_port
-
-Here are some examples:
-
- somehost
- somehost:161
- somehost:161!192.168.2.4!4000 use 192.168.2.4 and port 4000 as source
- somehost:!192.168.2.4 use 192.168.2.4 as source
- somehost:!!4000 use port 4000 as source
-
-Most people will only need to use the first form ("somehost").
-
-=item OBJECT IDENTIFIERs
-
-To further simplify SNMP queries, the query routines use a small table that
-maps the textual representation of OBJECT IDENTIFIERs to their dotted notation.
-The OBJECT IDENTIFIERs from RFC1213 (MIB-II) and RFC1315 (Frame Relay) are
-preloaded. This allows OBJECT IDENTIFIERs like "ifInOctets.4" to be used
-instead of the more cumbersome "1.3.6.1.2.1.2.2.1.10.4".
-
-Several functions are provided to manage the mapping table. Mapping entries
-can be added directly, SNMP MIB files can be read, and a cache file with the
-text-to-OBJECT-IDENTIFIER mappings are maintained. By default, the file
-"OID_cache.txt" is loaded, but it can by changed by setting the variable
-$Net_SNMP_util::CacheFile to the desired file name. The functions to
-manipulate the mappings are:
-
- snmpmapOID Add a textual OID mapping directly
- snmpMIB_to_OID Read a SNMP MIB file
- snmpLoad_OID_Cache Load an OID-mapping cache file
- snmpQueue_MIB_File Queue a SNMP MIB file for loading on demand
-
-=item Net::SNMP extensions
-
-This module is built on top of Net::SNMP. Net::SNMP has a different method
-of specifying SNMP parameters. To support this different method, this module
-will accept an optional hash reference containing the SNMP parameters. The
-hash may contain the following:
-
- [-port => $port,]
- [-localaddr => $localaddr,]
- [-localport => $localport,]
- [-version => $version,]
- [-domain => $domain,]
- [-timeout => $seconds,]
- [-retries => $count,]
- [-maxmsgsize => $octets,]
- [-debug => $bitmask,]
- [-community => $community,] # v1/v2c
- [-username => $username,] # v3
- [-authkey => $authkey,] # v3
- [-authpassword => $authpasswd,] # v3
- [-authprotocol => $authproto,] # v3
- [-privkey => $privkey,] # v3
- [-privpassword => $privpasswd,] # v3
- [-privprotocol => $privproto,] # v3
- [-contextengineid => $engine_id,] # v3
- [-contextname => $name,] # v3
-
-Please see the documentation for Net::SNMP for a description of these
-parameters.
-
-=item SNMPv3 Arguments
-
-A SNMP context is a collection of management information accessible by a SNMP
-entity. An item of management information may exist in more than one context
-and a SNMP entity potentially has access to many contexts. The combination of
-a contextEngineID and a contextName unambiguously identifies a context within
-an administrative domain. In a SNMPv3 message, the contextEngineID and
-contextName are included as part of the scopedPDU. All methods that generate
-a SNMP message optionally take a B<-contextengineid> and B<-contextname>
-argument to configure these fields.
-
-=over
-
-=item Context Engine ID
-
-The B<-contextengineid> argument expects a hexadecimal string representing
-the desired contextEngineID. The string must be 10 to 64 characters (5 to
-32 octets) long and can be prefixed with an optional "0x". Once the
-B<-contextengineid> is specified it stays with the object until it is changed
-again or reset to default by passing in the undefined value. By default, the
-contextEngineID is set to match the authoritativeEngineID of the authoritative
-SNMP engine.
-
-=item Context Name
-
-The contextName is passed as a string which must be 0 to 32 octets in length
-using the B<-contextname> argument. The contextName stays with the object
-until it is changed. The contextName defaults to an empty string which
-represents the "default" context.
-
-=back
-
-=back
-
-=cut
-
-# [public methods] ---------------------------------------------------
-
-=head1 Functions
-
-=head2 snmpget() - send a SNMP get-request to the remote agent
-
- @result = snmpget(
- [community@]host[:port[:timeout[:retries[:backoff[:version]]]]],
- [\%param_hash],
- @oids
- );
-
-This function performs a SNMP get-request query to gather data from the remote
-agent on the host specified. The message is built using the list of OBJECT
-IDENTIFIERs passed as an array. Each OBJECT IDENTIFIER is placed into a single
-SNMP GetRequest-PDU in the same order that it held in the original list.
-
-The requested values are returned in an array in the same order as they were
-requested. In scalar context the first requested value is returned.
-
-=cut
-
-#
-# snmpget.
-#
-sub snmpget ($@) {
- my($host, @vars) = @_;
- my($session, @enoid, %args, $ret, $oid, @retvals);
-
- @retvals = ();
- $session = &snmpopen($host, 0, \@vars);
- if (!defined($session)) {
- carp "SNMPGET Problem for $host"
- unless ($Net_SNMP_util::SuppressWarnings > 1);
- return wantarray ? @retvals : undef;
- }
-
- @enoid = &toOID(@vars);
- if ($#enoid < 0) {
- return wantarray ? @retvals : undef;
- }
-
- $args{'-varbindlist'} = \@enoid;
- if ($Net_SNMP_util::Version > 2) {
- $args{'-contextengineid'} = $Net_SNMP_util::ContextEngineID
- if (defined($Net_SNMP_util::ContextEngineID));
- $args{'-contextname'} = $Net_SNMP_util::ContextName
- if (defined($Net_SNMP_util::ContextName));
- }
-
- $ret = $session->get_request(%args);
-
- if ($ret) {
- foreach $oid (@enoid) {
- push @retvals, $ret->{$oid} if (exists($ret->{$oid}));
- }
- return wantarray ? @retvals : $retvals[0];
- }
- $ret = join(' ', @vars);
- error_msg("SNMPGET Problem for $ret on ${host}: " . $session->error());
- return wantarray ? @retvals : undef;
-}
-
-=head2 snmpgetnext() - send a SNMP get-next-request to the remote agent
-
- @result = snmpgetnext(
- [community@]host[:port[:timeout[:retries[:backoff[:version]]]]],
- [\%param_hash],
- @oids
- );
-
-This function performs a SNMP get-next-request query to gather data from the
-remote agent on the host specified. The message is built using the list of
-OBJECT IDENTIFIERs passed as an array. Each OBJECT IDENTIFIER is placed into a
-single SNMP GetNextRequest-PDU in the same order that it held in the original
-list.
-
-The requested values are returned in an array in the same order as they were
-requested. The OBJECT IDENTIFIER number is added as a prefix to each value
-using a colon as a separator, like '1.3.6.1.2.1.2.2.1.2.1:ethernet'.
-In scalar context the first requested value is returned.
-
-=cut
-
-#
-# snmpgetnext.
-#
-sub snmpgetnext ($@) {
- my($host, @vars) = @_;
- my($session, @enoid, %args, $ret, $oid, @retvals);
-
- @retvals = ();
- $session = &snmpopen($host, 0, \@vars);
- if (!defined($session)) {
- carp "SNMPGETNEXT Problem for $host"
- unless ($Net_SNMP_util::SuppressWarnings > 1);
- return wantarray ? @retvals : undef;
- }
-
- @enoid = &toOID(@vars);
- if ($#enoid < 0) {
- return wantarray ? @retvals : undef;
- }
-
- $args{'-varbindlist'} = \@enoid;
- if ($Net_SNMP_util::Version > 2) {
- $args{'-contextengineid'} = $Net_SNMP_util::ContextEngineID
- if (defined($Net_SNMP_util::ContextEngineID));
- $args{'-contextname'} = $Net_SNMP_util::ContextName
- if (defined($Net_SNMP_util::ContextName));
- }
-
- $ret = $session->get_next_request(%args);
-
- if ($ret) {
- foreach $oid (@enoid) {
- push @retvals, $oid . ':' . $ret->{$oid} if (exists($ret->{$oid}));
- }
- return wantarray ? @retvals : $retvals[0];
- }
- $ret = join(' ', @vars);
- error_msg("SNMPGETNEXT Problem for $ret on ${host}: " . $session->error());
- return wantarray ? @retvals : undef;
-}
-
-=head2 snmpgetbulk() - send a SNMP get-bulk-request to the remote agent
-
- @result = snmpgetbulk(
- [community@]host[:port[:timeout[:retries[:backoff[:version]]]]],
- $nonrepeaters,
- $maxrepetitions,
- [\%param_hash],
- @oids
- );
-
-This function performs a SNMP get-bulk-request query to gather data from the
-remote agent on the host specified.
-
-=over
-
-=item *
-
-The B<$nonrepeaters> value specifies the number of variables in the @oids list
-for which a single successor is to be returned. If it is null or undefined,
-a value of 0 is used.
-
-=item *
-
-The B<$maxrepetitions> value specifies the number of successors to be returned
-for the remaining variables in the @oids list. If it is null or undefined,
-the default value of 12 is used.
-
-=item *
-
-The message is built using the list of
-OBJECT IDENTIFIERs passed as an array. Each OBJECT IDENTIFIER is placed into a
-single SNMP GetNextRequest-PDU in the same order that it held in the original
-list.
-
-=back
-
-The requested values are returned in an array in the same order as they were
-requested.
-
-B<NOTE:> This function can only be used when the SNMP version is set to
-SNMPv2c or SNMPv3.
-
-=cut
-
-#
-# snmpgetbulk.
-#
-sub snmpgetbulk ($$$@) {
- my($host, $nr, $mr, @vars) = @_;
- my($session, %args, @enoid, $ret);
- my($oid, @retvals);
-
- @retvals = ();
- $session = &snmpopen($host, 0, \@vars);
- if (!defined($session)) {
- carp "SNMPGETBULK Problem for $host"
- unless ($Net_SNMP_util::SuppressWarnings > 1);
- return @retvals;
- }
-
- if ($Net_SNMP_util::Version < 2) {
- carp "SNMPGETBULK Problem for $host : must use SNMP version > 1"
- unless ($Net_SNMP_util::SuppressWarnings > 1);
- return @retvals;
- }
-
- $args{'-nonrepeaters'} = $nr if ($nr > 0);
- $mr = $Net_SNMP_util::MaxRepetitions if ($mr <= 0);
- $args{'-maxrepetitions'} = $mr;
-
- if ($Net_SNMP_util::Version > 2) {
- $args{'-contextengineid'} = $Net_SNMP_util::ContextEngineID
- if (defined($Net_SNMP_util::ContextEngineID));
- $args{'-contextname'} = $Net_SNMP_util::ContextName
- if (defined($Net_SNMP_util::ContextName));
- }
-
- @enoid = &toOID(@vars);
- return @retvals if ($#enoid < 0);
-
- $args{'-varbindlist'} = \@enoid;
- $ret = $session->get_bulk_request(%args);
-
- if ($ret) {
- @enoid = &Net::SNMP::oid_lex_sort(keys %$ret);
- foreach $oid (@enoid) {
- push @retvals, $oid . ":" . $ret->{$oid};
- }
- return @retvals;
- } else {
- $ret = join(' ', @vars);
- error_msg("SNMPGETBULK Problem for $ret on ${host}: " . $session->error());
- return @retvals;
- }
-}
-
-
-=head2 snmpwalk() - walk OBJECT IDENTIFIER tree(s) on the remote agent
-
- @result = snmpwalk(
- [community@]host[:port[:timeout[:retries[:backoff[:version]]]]],
- [\%param_hash],
- @oids
- );
-
-This function performs a sequence of SNMP get-next-request or get-bulk-request
-(if the SNMP version is 2 or higher) queries to gather data from the remote
-agent on the host specified. The initial message is built using the list of
-OBJECT IDENTIFIERs passed as an array. Each OBJECT IDENTIFIER is placed into a
-single SNMP GetNextRequest-PDU in the same order that it held in the original
-list. Queries continue until all the returned OBJECT IDENTIFIERs are no longer
-a child of the base OBJECT IDENTIFIERs.
-
-The requested values are returned in an array in the same order as they were
-requested. The OBJECT IDENTIFIER number is added as a prefix to each value
-using a colon as a separator, like '1.3.6.1.2.1.2.2.1.2.1:ethernet'. If only
-one OBJECT IDENTIFIER is requested, just the "instance" part of the OBJECT
-IDENTIFIER is added as a prefix, like '1:ethernet', '2:ethernet', '3:fddi'.
-
-=cut
-
-#
-# snmpwalk.
-#
-sub snmpwalk ($@) {
- my($host, @vars) = @_;
- return(&snmpwalk_flg($host, undef, @vars));
-}
-
-=head2 snmpset() - send a SNMP set-request to the remote agent
-
- @result = snmpset(
- [community@]host[:port[:timeout[:retries[:backoff[:version]]]]],
- [\%param_hash],
- $oid1, $type1, $value1,
- [$oid2, $type2, $value2 ...]
- );
-
-This function is used to modify data on the remote agent using a SNMP
-set-request. The message is built using the list of values consisting of groups
-of an OBJECT IDENTIFIER, an object type, and the actual value to be set.
-The object type can be one of the following strings:
-
- integer | int
- string | octetstring | octet string
- oid | object id | object identifier
- ipaddr | ip addr4ess
- timeticks
- uint | uinteger | uinteger32 | unsigned int | unsigned integer | unsigned integer32
- counter | counter 32
- counter64
- gauge | gauge32
-
-The object type may also be an octet corresponding to the ASN.1 type. See
-the Net::SNMP documentation for more information.
-
-The requested values are returned in an array in the same order as they were
-requested. In scalar context the first requested value is returned.
-
-=cut
-
-#
-# snmpset.
-#
-sub snmpset($@) {
- my($host, @vars) = @_;
- my($session, @vals, %args, $ret);
- my($oid, $type, $value, @enoid, @retvals);
-
- @retvals = ();
- $session = &snmpopen($host, 0, \@vars);
- if (!defined($session)) {
- carp "SNMPSET Problem for $host"
- unless ($Net_SNMP_util::SuppressWarnings > 1);
- return wantarray ? @retvals : undef;
- }
-
- if ($Net_SNMP_util::Version > 2) {
- $args{'-contextengineid'} = $Net_SNMP_util::ContextEngineID
- if (defined($Net_SNMP_util::ContextEngineID));
- $args{'-contextname'} = $Net_SNMP_util::ContextName
- if (defined($Net_SNMP_util::ContextName));
- }
-
- while(@vars) {
- ($oid) = toOID((shift @vars));
- $ret = shift @vars;
- $value = shift @vars;
- $type = ASNtype($ret);
- if (!defined($type)) {
- carp "Unknown SNMP type: $type\n"
- unless ($Net_SNMP_util::SuppressWarnings > 1);
- }
- push @vals, $oid, $type, $value;
- push @enoid, $oid;
- }
- if ($#vals < 0) {
- return wantarray ? @retvals : undef;
- }
-
- $args{'-varbindlist'} = \@vals;
-
- $ret = $session->set_request(%args);
- if ($ret) {
- foreach $oid (@enoid) {
- push @retvals, $ret->{$oid} if (exists($ret->{$oid}));
- }
- return wantarray ? @retvals : $retvals[0];
- }
- $ret = join(' ', @enoid);
- error_msg("SNMPSET Problem for $ret on ${host}: " . $session->error());
- return wantarray ? @retvals : undef;
-}
-
-=head2 snmptrap() - send a SNMP trap to the remote manager
-
- @result = snmptrap(
- [community@]host[:port[:timeout[:retries[:backoff[:version]]]]],
- $enterprise,
- $agentaddr,
- $generictrap,
- $specifictrap,
- [\%param_hash],
- $oid1, $type1, $value1,
- [$oid2, $type2, $value2 ...]
- );
-
-This function sends a SNMP trap to the remote manager on the host specified.
-The message is built using the list of values consisting of groups of an
-OBJECT IDENTIFIER, an object type, and the actual value to be set.
-The object type can be one of the following strings:
-
- integer | int
- string | octetstring | octet string
- oid | object id | object identifier
- ipaddr | ip addr4ess
- timeticks
- uint | uinteger | uinteger32 | unsigned int | unsigned integer | unsigned integer32
- counter | counter 32
- counter64
- gauge | gauge32
-
-The object type may also be an octet corresponding to the ASN.1 type. See
-the Net::SNMP documentation for more information.
-
-A true value is returned if sending the trap is successful. The undefined value
-is returned when a failure has occurred.
-
-When the trap is sent as SNMPv2c, the B<$enterprise>, B<$agentaddr>,
-B<$generictrap>, and B<$specifictrap> arguments are ignored. Furthermore,
-the first two (oid, type, value) tuples should be:
-
-=over
-
-=item *
-
-sysUpTime.0 - ('1.3.6.1.2.1.1.3.0', 'timeticks', $timeticks)
-
-=item *
-
-snmpTrapOID.0 - ('1.3.6.1.6.3.1.1.4.1.0', 'oid', $oid)
-
-=back
-
-B<NOTE:> This function can only be used when the SNMP version is set to
-SNMPv1 or SNMPv2c.
-
-=cut
-
-#
-# Send an SNMP trap
-#
-sub snmptrap($$$$$@) {
- my($host, $ent, $agent, $gen, $spec, @vars) = @_;
- my($oid, $type, $value, $ret, @enoid, @vals);
- my($session, %args);
-
- $session = &snmpopen($host, 1, \@vars);
- if (!defined($session)) {
- carp "SNMPTRAP Problem for $host"
- unless ($Net_SNMP_util::SuppressWarnings > 1);
- return undef;
- }
-
- if ($Net_SNMP_util::Version == 1) {
- $args{'-enterprise'} = $ent if (defined($ent) and (length($ent) > 0));
- $args{'-agentaddr'} = $agent if (defined($agent) and (length($agent) > 0));
- $args{'-generictrap'} = $gen if (defined($gen) and (length($gen) > 0));
- $args{'-specifictrap'} = $spec if (defined($spec) and (length($spec) > 0));
- } elsif ($Net_SNMP_util::Version > 2) {
- carp "SNMPTRAP Problem for $host : must use SNMP version 1 or 2"
- unless ($Net_SNMP_util::SuppressWarnings > 1);
- }
-
- while(@vars) {
- ($oid) = toOID((shift @vars));
- $ret = shift @vars;
- $value = shift @vars;
- $type = ASNtype($ret);
- if (!defined($type)) {
- carp "unknown SNMP type: $type"
- unless ($Net_SNMP_util::SuppressWarnings > 1);
- }
- push @vals, $oid, $type, $value;
- push @enoid, $oid;
- }
- return undef unless defined $vals[0];
-
- $args{'-varbindlist'} = \@vals;
-
- if ($Net_SNMP_util::Version == 1) {
- $ret = $session->trap_request(%args);
- } else {
- $ret = $session->snmpv2_trap(%args);
- }
-
- if (!$ret) {
- $ret = join(' ', @enoid);
- error_msg("SNMPTRAP Problem for $ret on ${host}: " . $session->error());
- }
- return $ret;
-}
-
-=head2 snmpmaptable() - walk OBJECT IDENTIFIER tree(s) on the remote agent
-
- $result = snmpmaptable(
- [community@]host[:port[:timeout[:retries[:backoff[:version]]]]],
- \&function,
- [\%param_hash],
- @oids
- );
-
-This function performs a sequence of SNMP get-next-request or get-bulk-request
-(if the SNMP version is 2 or higher) queries to gather data from the remote
-agent on the host specified. The initial message is built using the list of
-OBJECT IDENTIFIERs passed as an array. Each OBJECT IDENTIFIER is placed into a
-single SNMP GetNextRequest-PDU in the same order that it held in the original
-list. Queries continue until all the returned OBJECT IDENTIFIERs are no longer
-a child of the base OBJECT IDENTIFIERs. The OBJECT IDENTIFIERs must correspond
-to column entries for a conceptual row in a table. They may however be columns
-in different tables as long as each table is indexed the same way.
-
-=over
-
-=item *
-
-The B<\&function> argument will be called once per row of the table. It
-will be passed the row index as a partial OBJECT IDENTIFIER in dotted notation,
-e.g. "1.3" or "10.0.1.34", and the values of the requested table columns in
-that row.
-
-=back
-
-The number of rows in the table is returned on success. The undefined value
-is returned when a failure has occurred.
-
-=cut
-
-#
-# walk a table, calling a user-supplied function for each
-# column of a table.
-#
-sub snmpmaptable($$@) {
- my($host, $fun, @vars) = @_;
- return snmpmaptable4($host, $fun, 0, @vars);
-}
-
-=head2 snmpmaptable4() - walk OBJECT IDENTIFIER tree(s) on the remote agent
-
- $result = snmpmaptable4(
- [community@]host[:port[:timeout[:retries[:backoff[:version]]]]],
- \&function,
- $maxrepetitions,
- [\%param_hash],
- @oids
- );
-
-This function performs a sequence of SNMP get-next-request or get-bulk-request
-(if the SNMP version is 2 or higher) queries to gather data from the remote
-agent on the host specified. The initial message is built using the list of
-OBJECT IDENTIFIERs passed as an array. Each OBJECT IDENTIFIER is placed into a
-single SNMP GetNextRequest-PDU in the same order that it held in the original
-list. Queries continue until all the returned OBJECT IDENTIFIERs are no longer
-a child of the base OBJECT IDENTIFIERs. The OBJECT IDENTIFIERs must correspond
-to column entries for a conceptual row in a table. They may however be columns
-in different tables as long as each table is indexed the same way.
-
-=over
-
-=item *
-
-The B<\&function> argument will be called once per row of the table. It
-will be passed the row index as a partial OBJECT IDENTIFIER in dotted notation,
-e.g. "1.3" or "10.0.1.34", and the values of the requested table columns in
-that row.
-
-=item *
-
-The B<$maxrepetitions> argument specifies the number of rows to be returned
-by a single get-bulk-request. If it is null or undefined, the default value
-of 12 is used.
-
-=back
-
-The number of rows in the table is returned on success. The undefined value
-is returned when a failure has occurred.
-
-=cut
-
-sub snmpmaptable4($$$@) {
- my($host, $fun, $max_reps, @vars) = @_;
- my($session, @enoid, %args, $ret);
- my($oid, $soid, $toid, $inst, @row, $nr);
-
- $session = &snmpopen($host, 0, \@vars);
- if (!defined($session)) {
- carp "SNMPMAPTABLE Problem for $host"
- unless ($Net_SNMP_util::SuppressWarnings > 1);
- return undef;
- }
-
- @enoid = toOID(@vars);
- return undef unless defined $enoid[0];
-
- if ($Net_SNMP_util::Version > 1) {
- $max_reps = $Net_SNMP_util::MaxRepetitions if ($max_reps <= 0);
- $args{'-maxrepetitions'} = $max_reps;
- }
- if ($Net_SNMP_util::Version > 2) {
- $args{'-contextengineid'} = $Net_SNMP_util::ContextEngineID
- if (defined($Net_SNMP_util::ContextEngineID));
- $args{'-contextname'} = $Net_SNMP_util::ContextName
- if (defined($Net_SNMP_util::ContextName));
- }
-
- $args{'-columns'} = \@enoid;
-
- $ret = $session->get_entries(%args);
-
- if ($ret) {
- $soid = $enoid[0];
- $nr = 0;
- foreach $oid (&Net::SNMP::oid_lex_sort(keys %$ret)) {
- if (&Net::SNMP::oid_base_match($soid, $oid)) {
- $inst = substr($oid, length($soid)+1);
- undef @row;
- foreach $toid (@enoid) {
- push @row, $ret->{$toid . "." . $inst};
- }
- &$fun($inst, @row);
- $nr++;
- } else {
- return($nr) if ($nr > 0);
- }
- }
- return($nr);
- } else {
- $ret = join(' ', @vars);
- error_msg("SNMPMAPTABLE Problem for $ret on ${host}: " . $session->error());
- return undef;
- }
-}
-
-=head2 snmpwalkhash() - send a SNMP get-next-request to the remote agent
-
- @result = snmpwalkhash(
- [community@]host[:port[:timeout[:retries[:backoff[:version]]]]],
- \&function(),
- [\%param_hash],
- @oids,
- [\%hash]
- );
-
-This function performs a sequence of SNMP get-next-request or get-bulk-request
-(if the SNMP version is 2 or higher) queries to gather data from the remote
-agent on the host specified. The message is built using the list of
-OBJECT IDENTIFIERs passed as an array. Each OBJECT IDENTIFIER is placed into a
-single SNMP GetNextRequest-PDU in the same order that it held in the original
-list. Queries continue until all the returned OBJECT IDENTIFIERs are outside
-of the tree specified by the initial OBJECT IDENTIFIERs.
-
-The B<\&function> is called once for every returned value. It is passed a
-reference to a hash, the hostname, the textual OBJECT IDENTIFIER, the
-dotted-numberic OBJECT IDENTIFIER, the instance, the value and the requested
-textual OBJECT IDENTIFIER. That function can customize the result so the
-values can be extracted later by hosts, by oid_names, by oid_numbers,
-by instances... like these:
-
- $hash{$host}{$name}{$inst} = $value;
- $hash{$host}{$oid}{$inst} = $value;
- $hash{$name}{$inst} = $value;
- $hash{$oid}{$inst} = $value;
- $hash{$oid . '.' . $ints} = $value;
- $hash{$inst} = $value;
- ...
-
-If the last argument to B<snmpwalkhash> is a reference to a hash, that hash
-reference is passed to the passed-in function instead of a local hash
-reference. That way the function can look up other objects unrelated
-to the current invocation of B<snmpwalkhash>.
-
-The snmpwalkhash routine returns the hash.
-
-=cut
-
-#
-# Walk the MIB, putting everything you find into hashes.
-#
-sub snmpwalkhash($$@) {
-# my($host, $hash_sub, @vars) = @_;
- return(&snmpwalk_flg( @_ ));
-}
-
-
-=head2 snmpmapOID() - add texual OBJECT INDENTIFIER mapping
-
- snmpmapOID(
- $text1, $oid1,
- [ $text2, $oid2 ...]
- );
-
-This routine adds entries to the table that maps textual representation of
-OBJECT IDENTIFIERs to their dotted notation. For example,
-
- snmpmapOID('ciscoCPU', '1.3.6.1.4.1.9.9.109.1.1.1.1.5.1');
-
-allows the string 'ciscoCPU' to be used as an OBJECT IDENTIFIER in any SNMP
-query routine.
-
-This routine doesn't return anything.
-
-=cut
-
-#
-# Add passed-in text, OID pairs to the OID mapping table.
-#
-sub snmpmapOID(@)
-{
- my(@vars) = @_;
- my($oid, $txt);
-
- $Net_SNMP_util::ErrorMessage = '';
- while($#vars >= 0) {
- $txt = shift @vars;
- $oid = shift @vars;
-
- next unless($txt =~ /^[a-zA-Z][\w\-]*(\.[a-zA-Z][\w\-])*$/);
- next unless($oid =~ /^\d+(\.\d+)*$/);
-
- $Net_SNMP_util::OIDS{$txt} = $oid;
- $RevNeeded = 1;
- print "snmpmapOID: $txt => $oid\n" if $Net_SNMP_util::Debug;
- }
-
- return undef;
-}
-
-=head2 snmpLoad_OID_Cache() - Read a file of cached OID mappings
-
- $result = snmpLoad_OID_Cache(
- $file
- );
-
-This routine opens the file named by the B<$file> argument and reads it.
-The file should contain text, OBJECT IDENTIFIER pairs, one pair
-per line. It adds the pairs as entries to the table that maps textual
-representation of OBJECT IDENTIFIERs to their dotted notation.
-Blank lines and anything after a '#' or between '--' is ignored.
-
-This routine returns 0 on success and -1 if the B<$file> could not be opened.
-
-=cut
-
-#
-# Open the passed-in file name and read it in to populate
-# the cache of text-to-OID map table. It expects lines
-# with two fields, the first the textual string like "ifInOctets",
-# and the second the OID value, like "1.3.6.1.2.1.2.2.1.10".
-#
-# blank lines and anything after a '#' or between '--' is ignored.
-#
-sub snmpLoad_OID_Cache ($) {
- my($arg) = @_;
- my($txt, $oid);
-
- $Net_SNMP_util::ErrorMessage = '';
- if (!open(CACHE, $arg)) {
- error_msg("snmpLoad_OID_Cache: Can't open ${arg}: $!");
- return -1;
- }
-
- while(<CACHE>) {
- s/#.*//; # '#' starts a comment
- s/--.*?--/ /g; # comment delimited by '--', like MIBs
- s/--.*//; # comment started by '--'
- next if (/^$/);
- next unless (/\s/); # must have whitespace as separator
- chomp;
- ($txt, $oid) = split(' ', $_, 2);
- $txt = $1 if ($txt =~ /^[\'\"](.*)[\'\"]/);
- $oid = $1 if ($oid =~ /^[\'\"](.*)[\'\"]/);
- if (($txt =~ /^\.?\d+(\.\d+)*\.?$/)
- and ($oid !~ /^\.?\d+(\.\d+)*\.?$/)) {
- my($a) = $oid;
- $oid = $txt;
- $txt = $a;
- }
- $oid =~ s/^\.//;
- $oid =~ s/\.$//;
- &snmpmapOID($txt, $oid);
- }
- close(CACHE);
- return 0;
-}
-
-=head2 snmpMIB_to_OID() - Read a MIB file for textual OID mappings
-
- $result = snmpMIB_to_OID(
- $file
- );
-
-This routine opens the file named by the B<$file> argument and reads it.
-The file should be an SNMP Management Information Base (MIB) file
-that describes OBJECT IDENTIFIERs supported by an SNMP agent.
-per line. It adds the textual representation of the OBJECT IDENTIFIERs
-to the text-to-OID mapping table.
-
-This routine returns the number of entries added to the table or -1 if
-the B<$file> could not be opened.
-
-=cut
-
-#
-# Read in the passed MIB file, parsing it
-# for their text-to-OID mappings
-#
-sub snmpMIB_to_OID ($) {
- my($arg) = @_;
- my($cnt, $quote, $buf, %tOIDs, $tgot);
- my($var, @parts, $strt, $indx, $ind, $val);
-
- $Net_SNMP_util::ErrorMessage = '';
- if (!open(MIB, $arg)) {
- error_msg("snmpMIB_to_OID: Can't open ${arg}: $!");
- return -1;
- }
- print "snmpMIB_to_OID: loading $arg\n" if $Net_SNMP_util::Debug;
- $cnt = 0;
- $quote = 0;
- $tgot = 0;
- $buf = '';
- while(<MIB>) {
- if ($quote) {
- next unless /"/;
- $quote = 0;
- }
- chomp;
- $buf .= ' ' . $_;
-
- $buf =~ s/"[^"]*"//g; # throw away quoted strings
- $buf =~ s/--.*?--/ /g; # throw away comments (-- anything --)
- $buf =~ s/--.*//; # throw away comments (-- anything to EOL)
- $buf =~ s/\s+/ /g; # clean up multiple spaces
-
- if ($buf =~ /"/) {
- $quote = 1;
- next;
- }
-
- if ($buf =~ /DEFINITIONS *::= *BEGIN/) {
- $cnt += MIB_fill_OID(\%tOIDs) if ($tgot);
- $buf = '';
- %tOIDs = ();
- $tgot = 0;
- next;
- }
- $buf =~ s/OBJECT-TYPE/OBJECT IDENTIFIER/;
- $buf =~ s/OBJECT-IDENTITY/OBJECT IDENTIFIER/;
- $buf =~ s/OBJECT-GROUP/OBJECT IDENTIFIER/;
- $buf =~ s/MODULE-IDENTITY/OBJECT IDENTIFIER/;
- $buf =~ s/NOTIFICATION-TYPE/OBJECT IDENTIFIER/;
- $buf =~ s/ IMPORTS .*\;//;
- $buf =~ s/ SEQUENCE *{.*}//;
- $buf =~ s/ SYNTAX .*//;
- $buf =~ s/ [\w\-]+ *::= *OBJECT IDENTIFIER//;
- $buf =~ s/ OBJECT IDENTIFIER.*::= *{/ OBJECT IDENTIFIER ::= {/;
-
- if ($buf =~ / ([\w\-]+) OBJECT IDENTIFIER *::= *{([^}]+)}/) {
- $var = $1;
- $buf = $2;
- $buf =~ s/ +$//;
- $buf =~ s/\s+\(/\(/g; # remove spacing around '('
- $buf =~ s/\(\s+/\(/g;
- $buf =~ s/\s+\)/\)/g; # remove spacing before ')'
- @parts = split(' ', $buf);
- $strt = '';
- foreach $indx (@parts) {
- if ($indx =~ /([\w\-]+)\((\d+)\)/) {
- $ind = $1;
- $val = $2;
- if (exists($tOIDs{$strt})) {
- $tOIDs{$ind} = $tOIDs{$strt} . '.' . $val;
- } elsif ($strt ne '') {
- $tOIDs{$ind} = "${strt}.${val}";
- } else {
- $tOIDs{$ind} = $val;
- }
- $strt = $ind;
- $tgot = 1;
- } elsif ($indx =~ /^\d+$/) {
- if (exists($tOIDs{$strt})) {
- $tOIDs{$var} = $tOIDs{$strt} . '.' . $indx;
- } else {
- $tOIDs{$var} = "${strt}.${indx}";
- }
- $tgot = 1;
- } else {
- $strt = $indx;
- }
- }
- $buf = '';
- }
- }
- $cnt += MIB_fill_OID(\%tOIDs) if ($tgot);
- $RevNeeded = 1 if ($cnt > 0);
- return $cnt;
-}
-
-=head2 snmpQueue_MIB_File() - queue a MIB file for reading "on demand"
-
- snmpQueue_MIB_File(
- $file1,
- [$file2, ...]
- );
-
-This routine queues the list of SNMP MIB files for later processing.
-Whenever a text-to-OBJECT IDENTIFIER lookup fails, the list of queued MIB
-files is consulted. If it isn't empty, the first MIB file in the list is
-removed and passed to B<snmpMIB_to_OID()>. The lookup is attempted again,
-and if that still fails the next MIB file in the list is removed and passed
-to B<snmpMIB_to_OID()>. This process continues until the lookup succeeds
-or the list is exhausted.
-
-This routine doesn't return anything.
-
-=cut
-
-#
-# Save the passed-in list of MIB files until an OID can't be
-# found in the existing table. At that time the MIB file will
-# be loaded, and the lookup attempted again.
-#
-sub snmpQueue_MIB_File (@) {
- my(@files) = @_;
- my($file);
-
- $Net_SNMP_util::ErrorMessage = '';
- foreach $file (@files) {
- push(@Net_SNMP_util::MIB_Files, $file);
- }
-}
-
-# [private methods] -------------------------------------
-
-#
-# Start an snmp session
-#
-sub snmpopen ($$$) {
- my($host, $type, $vars) = @_;
- my($nhost, $port, $community, $lhost, $lport, $nlhost);
- my($timeout, $retries, $backoff, $version, $v4onlystr);
- my($opts, %args, $tmp, $sess);
- my($debug, $maxmsgsize);
-
- $type = 0 if (!defined($type));
- $community = "public";
- $nlhost = "";
-
- ($community, $host) = ($1, $2) if ($host =~ /^(.*)@([^@]+)$/);
-
- # We can't split on the : character because a numeric IPv6
- # address contains a variable number of :'s
- if( ($host =~ /^(\[.*\]):(.*)$/) or ($host =~ /^(\[.*\])$/) ) {
- # Numeric IPv6 address between []
- ($host, $opts) = ($1, $2);
- } else {
- # Hostname or numeric IPv4 address
- ($host, $opts) = split(':', $host, 2);
- }
- ($port, $timeout, $retries, $backoff, $version, $v4onlystr)
- = split(':', $opts, 6) if(defined($opts) and (length $opts > 0) );
-
- undef($timeout) if (defined($timeout) and length($timeout) <= 0);
- undef($retries) if (defined($retries) and length($retries) <= 0);
- undef($backoff) if (defined($backoff) and length($backoff) <= 0);
- undef($version) if (defined($version) and length($version) <= 0);
-
- $v4onlystr = "" unless defined $v4onlystr;
-
- if (defined($port) and ($port =~ /^([^!]*)!(.*)$/)) {
- ($port, $lhost) = ($1, $2);
- $nlhost = $lhost;
- ($lhost, $lport) = ($1, $2) if ($lhost =~ /^(.*)!(.*)$/);
- undef($lport) if (defined($lport) and (length($lport) <= 0));
- }
- undef($port) if (defined($port) and length($port) <= 0);
-
- if (ref $vars->[0] eq 'HASH') {
- undef($debug);
- undef($maxmsgsize);
- undef $Net_SNMP_util::ContextEngineID;
- undef $Net_SNMP_util::ContextName;
- $opts = shift @$vars;
- foreach $type (keys %$opts) {
- if ($type =~ /^-?return_array_refs$/i) {
- $Net_SNMP_util::ReturnArrayRefs = $opts->{$type};
- } elsif ($type =~ /^-?return_hash_refs$/i) {
- $Net_SNMP_util::ReturnHashRefs = $opts->{$type};
- } elsif ($type =~ /^-?contextengineid$/i) {
- $Net_SNMP_util::ContextEngineID = $opts->{$type};
- } elsif ($type =~ /^-?contextname$/i) {
- $Net_SNMP_util::ContextName = $opts->{$type};
- } elsif ($type =~ /^-?maxrepetitions$/i) {
- $Net_SNMP_util::MaxRepetitions = $opts->{$type};
- } elsif ($type =~ /^-?default_max_repetitions$/i) {
- $Net_SNMP_util::MaxRepetitions = $opts->{$type};
- } elsif ($type =~ /^-?version$/i) {
- $version = $opts->{$type};
- } elsif ($type =~ /^-?port$/i) {
- $port = $opts->{$type};
- } elsif ($type =~ /^-?localaddr$/i) {
- $lhost = $opts->{$type};
- } elsif ($type =~ /^-?community$/i) {
- $community = $opts->{$type};
- } elsif ($type =~ /^-?timeout$/i) {
- $timeout = $opts->{$type};
- } elsif ($type =~ /^-?retries$/i) {
- $retries = $opts->{$type};
- } elsif ($type =~ /^-?maxmsgsize$/i) {
- $maxmsgsize = $opts->{$type};
- } elsif ($type =~ /^-?debug$/i) {
- $debug = $opts->{$type};
- } elsif ($type =~ /^-?backoff$/i) {
- next; # XXXX not implemented in Net::SNMP
- } elsif ($type =~ /^-?avoid_negative_request_ids$/i) {
- next; # XXXX not implemented in Net::SNMP
- } elsif ($type =~ /^-?lenient_source_/i) {
- next; # XXXX not implemented in Net::SNMP
- } elsif ($type =~ /^-?use_16bit_request_ids$/i) {
- next; # XXXX not implemented in Net::SNMP
- } elsif ($type =~ /^-?use_getbulk$/i) {
- next; # XXXX not implemented in Net::SNMP
- } else {
- $tmp = $type;
- $tmp = '-' . $tmp unless ($tmp =~ /^-/);
- $args{$tmp} = $opts->{$type};
- }
- }
- }
-
- $port = 162 if ($type == 1 and !defined($port));
- $nhost = "$community\@$host";
- $nhost .= ":" . $port if (defined($port));
- undef($lhost) if (defined($lhost) and (length($lhost) <= 0));
-
- $version = '1' unless defined $version;
- if ($version =~ /1/) {
- $version = 1;
- } elsif ($version =~ /2/) {
- $version = 2;
- } elsif ($version =~ /3/) {
- $version = 3;
- }
- $Net_SNMP_util::ErrorMessage = '';
- if ((!defined($Net_SNMP_util::Session))
- or ($Net_SNMP_util::Host ne $nhost)
- or ($Net_SNMP_util::Version ne $version)
- or ($Net_SNMP_util::LHost ne $nlhost)
- or ($Net_SNMP_util::IPv4only ne $v4onlystr)) {
- if (defined($Net_SNMP_util::Session)) {
- $Net_SNMP_util::Session->close();
- undef $Net_SNMP_util::Session;
- undef $Net_SNMP_util::Host;
- undef $Net_SNMP_util::Version;
- undef $Net_SNMP_util::LHost;
- undef $Net_SNMP_util::IPv4only;
- }
-
- $args{'-hostname'} = $host;
- $args{'-port'} = $port if (defined($port));
- $args{'-localaddr'} = $lhost if (defined($lhost));
- $args{'-localport'} = $lport if (defined($lport));
- $args{'-version'} = $version;
- $args{'-domain'} = "udp/ipv4" if (length($v4onlystr) > 0);
- $args{'-timeout'} = $timeout if (defined($timeout));
- $args{'-retries'} = $retries if (defined($retries));
- $args{'-maxmsgsize'} = $maxmsgsize if (defined($maxmsgsize));
- $args{'-debug'} = $debug if (defined($debug));
- $args{'-community'} = $community unless ($community eq "public");
- if ($version == 3) {
- delete $args{'-community'}
- } else {
- delete $args{'-username'};
- delete $args{'-authkey'};
- delete $args{'-authpassword'};
- delete $args{'-authprotocol'};
- delete $args{'-privkey'};
- delete $args{'-privpassword'};
- delete $args{'-privprotocol'};
- }
-
- ($sess, $tmp) = Net::SNMP->session(%args);
-
- if (defined($sess)) {
- $Net_SNMP_util::Session = $sess;
- $Net_SNMP_util::Host = $nhost;
- $Net_SNMP_util::Version = $version;
- $Net_SNMP_util::LHost = $nlhost;
- $Net_SNMP_util::IPv4only = $v4onlystr;
- } else {
- error_msg("SNMPopen failed: $tmp\n");
- return(undef);
- }
- return $Net_SNMP_util::Session;
- } else {
- $Net_SNMP_util::Session->timeout($timeout)
- if (defined($timeout) and (length($timeout) > 0));
- $Net_SNMP_util::Session->retries($retries)
- if (defined($retries) and (length($retries) > 0));
- $Net_SNMP_util::Session->maxmsgsize($maxmsgsize)
- if (defined($maxmsgsize) and (length($maxmsgsize) > 0));
- $Net_SNMP_util::Session->debug($debug)
- if (defined($debug) and (length($debug) > 0));
- $Net_SNMP_util::Session->{_context_engine_id} = undef
- if (!defined($Net_SNMP_util::ContextEngineID));
- $Net_SNMP_util::Session->{_context_name} = undef
- if (!defined($Net_SNMP_util::ContextName));
- }
- return $Net_SNMP_util::Session;
-}
-
-#
-# Given an OID in either ASN.1 or mixed text/ASN.1 notation, return an OID.
-#
-sub toOID(@) {
- my(@vars) = @_;
- my($oid, $var, $tmp, $tmpv, @retvar);
-
- @retvar = ();
- foreach $var (@vars) {
- ($oid, $tmp) = &Check_OID($var);
- if (!$oid and $Net_SNMP_util::CacheLoaded == 0) {
- $tmp = $Net_SNMP_util::SuppressWarnings;
- $Net_SNMP_util::SuppressWarnings = 1000;
-
- &snmpLoad_OID_Cache($Net_SNMP_util::CacheFile);
-
- $Net_SNMP_util::CacheLoaded = 1;
- $Net_SNMP_util::SuppressWarnings = $tmp;
-
- ($oid, $tmp) = &Check_OID($var);
- }
- while (!$oid and $#Net_SNMP_util::MIB_Files >= 0) {
- $tmp = $Net_SNMP_util::SuppressWarnings;
- $Net_SNMP_util::SuppressWarnings = 1000;
-
- snmpMIB_to_OID(shift(@Net_SNMP_util::MIB_Files));
-
- $Net_SNMP_util::SuppressWarnings = $tmp;
-
- ($oid, $tmp) = &Check_OID($var);
- if ($oid) {
- open(CACHE, ">>$Net_SNMP_util::CacheFile");
- print CACHE "$tmp\t$oid\n";
- close(CACHE);
- }
- }
- if ($oid) {
- $var =~ s/^$tmp/$oid/;
- } else {
- carp("Unknown SNMP var $var\n")
- unless ($Net_SNMP_util::SuppressWarnings > 1);
- next;
- }
- while ($var =~ /\"([^\"]*)\"/) {
- $tmp = sprintf("%d.%s", length($1), join(".", map(ord, split(//, $1))));
- $var =~ s/\"$1\"/$tmp/;
- }
- print "toOID: $var\n" if $Net_SNMP_util::Debug;
- push(@retvar, $var);
- }
- return @retvar;
-}
-
-#
-# Check to see if an OID is in the text-to-OID cache.
-# Returns the OID and the corresponding text as two separate
-# elements.
-#
-sub Check_OID ($) {
- my($var) = @_;
- my($tmp, $tmpv, $oid);
-
- if ($var =~ /^[a-zA-Z][\w\-]*(\.[a-zA-Z][\w\-]*)*/) {
- $tmp = $&;
- $tmpv = $tmp;
- for (;;) {
- last if exists($Net_SNMP_util::OIDS{$tmpv});
- last if !($tmpv =~ s/^[^\.]*\.//);
- }
- $oid = $Net_SNMP_util::OIDS{$tmpv};
- if ($oid) {
- return ($oid, $tmp);
- } else {
- my @empty = ();
- return @empty;
- }
- }
- return ($var, $var);
-}
-
-sub snmpwalk_flg ($$@) {
- my($host, $hash_sub, @vars) = @_;
- my($session, %args, @enoid, @poid, $toid, $oid, $got);
- my($val, $ret, %soid, %nsoid, @retvals, $tmp);
- my(%rethash, $h_ref, @tmprefs);
- my($stop);
-
- $h_ref = (ref $vars[$#vars] eq "HASH") ? pop(@vars) : \%rethash;
-
- $session = &snmpopen($host, 0, \@vars);
- if (!defined($session)) {
- carp "SNMPWALK Problem for $host"
- unless ($Net_SNMP_util::SuppressWarnings > 1);
- if (defined($hash_sub)) {
- return ($h_ref) if ($SNMP_util::Return_hash_refs);
- return (%$h_ref);
- } else {
- @retvals = ();
- return (@retvals);
- }
- }
-
- @enoid = toOID(@vars);
- if ($#enoid < 0) {
- if (defined($hash_sub)) {
- return ($h_ref) if ($SNMP_util::Return_hash_refs);
- return (%$h_ref);
- } else {
- @retvals = ();
- return (@retvals);
- }
- }
-
- #
- # Create/Refresh a reversed hash with oid -> name
- #
- if (defined($hash_sub) and ($RevNeeded)) {
- %revOIDS = reverse %Net_SNMP_util::OIDS;
- $RevNeeded = 0;
- }
-
- #
- # Create temporary array of refs to return values
- #
- foreach $oid (0..$#enoid) {
- my $tmparray = [];
- $tmprefs[$oid] = $tmparray;
- $nsoid{$oid} = $oid;
- }
-
- $got = 0;
- @poid = @enoid;
-
- if ($Net_SNMP_util::Version > 1 and $Net_SNMP_util::MaxRepetitions > 0) {
- $args{'-maxrepetitions'} = $Net_SNMP_util::MaxRepetitions;
- }
- if ($Net_SNMP_util::Version > 2) {
- $args{'-contextengineid'} = $Net_SNMP_util::ContextEngineID
- if (defined($Net_SNMP_util::ContextEngineID));
- $args{'-contextname'} = $Net_SNMP_util::ContextName
- if (defined($Net_SNMP_util::ContextName));
- }
-
- while($#poid >= 0) {
- $args{'-varbindlist'} = \@poid;
- if (($Net_SNMP_util::Version > 1)
- and ($Net_SNMP_util::MaxRepetitions > 1)) {
- $ret = $session->get_bulk_request(%args);
- } else {
- $ret = $session->get_next_request(%args);
- }
- last if (!defined($ret));
-
- %soid = %nsoid;
- undef %nsoid;
- $stop = 0;
- foreach $oid (&Net::SNMP::oid_lex_sort(keys %$ret)) {
- $got = 1;
- $tmp = -1;
- foreach $toid (@enoid) {
- $tmp++;
- if (&Net::SNMP::oid_base_match($toid, $oid)
- and (!exists($soid{$toid}) or ($oid ne $soid{$toid}))) {
- $nsoid{$toid} = $oid;
- if (defined($hash_sub)) {
- #
- # extract name of the oid, if possible, the rest becomes the
- # instance
- #
- my $inst = "";
- my $upo = $toid;
- while (!exists($revOIDS{$upo}) and length($upo)) {
- $upo =~ s/(\.\d+?)$//;
- if (defined($1) and length($1)) {
- $inst = $1 . $inst;
- } else {
- $upo = "";
- last;
- }
- }
- if (length($upo) and exists($revOIDS{$upo})) {
- $upo = $revOIDS{$upo} . $inst;
- } else {
- $upo = $toid;
- }
-
- my $qoid = $oid;
- my $tmpo;
- $inst = "";
- while (!exists($revOIDS{$qoid}) and length($qoid)) {
- $qoid =~ s/(\.\d+?)$//;
- if (defined($1) and length($1)) {
- $inst = $1 . $inst;
- } else {
- $qoid = "";
- last;
- }
- }
- if (length($qoid) and exists($revOIDS{$qoid})) {
- $tmpo = $qoid;
- $qoid = $revOIDS{$qoid};
- } else {
- $qoid = $oid;
- $tmpo = $toid;
- $inst = substr($oid, length($tmpo)+1);
- }
- #
- # call hash_sub
- #
- &$hash_sub($h_ref, $host, $qoid, $tmpo, $inst, $ret->{$oid}, $upo);
- } else {
- my $tmpo;
- my $tmpv = $ret->{$oid};
- $tmpo = substr($oid, length($toid)+1);
- push @{$tmprefs[$tmp]}, "$tmpo:$tmpv";
- }
- } else {
- $stop = 1 if ($#enoid == 0);
- }
- }
- }
- undef @poid;
- @poid = values %nsoid if (!$stop);
- }
- if ($got) {
- if (defined($hash_sub)) {
- return ($h_ref) if ($Net_SNMP_util::ReturnHashRefs);
- return (%$h_ref);
- } elsif ($Net_SNMP_util::Return_array_refs) {
- return (@tmprefs);
- } else {
- do {
- $got = 0;
- foreach $toid (0..$#enoid) {
- next if (scalar(@{$tmprefs[$toid]}) <= 0);
- $got = 1;
- $oid = shift(@{$tmprefs[$toid]});
- if ($#enoid > 0) {
- ($oid, $val) = split(':', $oid, 2);
- $oid = $enoid[$toid] . '.' . $oid;
- push(@retvals, "$oid:$val");
- } else {
- push(@retvals, $oid);
- }
- }
- } while($got);
- return (@retvals);
- }
- } else {
- $ret = join(' ', @vars);
- error_msg("SNMPWALK Problem for $ret on ${host}: " . $session->error());
- if (defined($hash_sub)) {
- return ($h_ref) if ($SNMP_util::Return_hash_refs);
- return (%$h_ref);
- } else {
- @retvals = ();
- return (@retvals);
- }
- }
-}
-
-#
-# When passed a string, return the ASN.1 type that corresponds to the
-# string.
-#
-sub ASNtype($) {
- my($type) = @_;
-
- $type =~ tr/A-Z/a-z/;
- if ($type eq "int") {
- $type = 0x02;
- } elsif ($type eq "integer") {
- $type = 0x02;
- } elsif ($type eq "string") {
- $type = 0x04;
- } elsif ($type eq "octetstring") {
- $type = 0x04;
- } elsif ($type eq "octet string") {
- $type = 0x04;
- } elsif ($type eq "oid") {
- $type = 0x06;
- } elsif ($type eq "object id") {
- $type = 0x06;
- } elsif ($type eq "object identifier") {
- $type = 0x06;
- } elsif ($type eq "ipaddr") {
- $type = 0x40;
- } elsif ($type eq "ip address") {
- $type = 0x40;
- } elsif ($type eq "timeticks") {
- $type = 0x43;
- } elsif ($type eq "uint") {
- $type = 0x47;
- } elsif ($type eq "uinteger") {
- $type = 0x47;
- } elsif ($type eq "uinteger32") {
- $type = 0x47;
- } elsif ($type eq "unsigned int") {
- $type = 0x47;
- } elsif ($type eq "unsigned integer") {
- $type = 0x47;
- } elsif ($type eq "unsigned integer32") {
- $type = 0x47;
- } elsif ($type eq "counter") {
- $type = 0x41;
- } elsif ($type eq "counter32") {
- $type = 0x41;
- } elsif ($type eq "counter64") {
- $type = 0x46;
- } elsif ($type eq "gauge") {
- $type = 0x42;
- } elsif ($type eq "gauge32") {
- $type = 0x42;
- } elsif (($type <= 0) or ($type > 255)) {
- return undef;
- }
- return $type;
-}
-
-#
-# set the ErrorMessage global and print an error message
-#
-sub error_msg($)
-{
- my($msg) = @_;
- $Net_SNMP_util::ErrorMessage = $msg;
- if ($Net_SNMP_util::SuppressWarnings <= 1) {
- $Carp::CarpLevel++;
- carp($msg);
- $Carp::CarpLevel--;
- }
-}
-
-#
-# Fill the OIDS hash with results from the MIB parsing
-#
-sub MIB_fill_OID($)
-{
- my($href) = @_;
- my($cnt, $changed, @del, $var, $val, @parts, $indx);
- my(%seen);
-
- $cnt = 0;
- do {
- $changed = 0;
- @del = ();
- foreach $var (keys %$href) {
- $val = $href->{$var};
- @parts = split('\.', $val);
- $val = '';
- foreach $indx (@parts) {
- if ($indx =~ /^\d+$/) {
- $val .= '.' . $indx;
- } else {
- if (exists($Net_SNMP_util::OIDS{$indx})) {
- $val = $Net_SNMP_util::OIDS{$indx};
- } else {
- $val .= '.' . $indx;
- }
- }
- }
- if ($val =~ /^[\d\.]+$/) {
- $val =~ s/^\.+//;
- if (!exists($Net_SNMP_util::OIDS{$var})
- || (length($val) > length($Net_SNMP_util::OIDS{$var}))) {
- $Net_SNMP_util::OIDS{$var} = $val;
- print "'$var' => '$val'\n" if $Net_SNMP_util::Debug;
- $changed = 1;
- $cnt++;
- }
- push @del, $var;
- }
- }
- foreach $var (@del) {
- delete $href->{$var};
- }
- } while($changed);
-
- $Carp::CarpLevel++;
- foreach $var (sort keys %$href) {
- $val = $href->{$var};
- $val =~ s/\..*//;
- next if (exists($seen{$val}));
- $seen{$val} = 1;
- $seen{$var} = 1;
- error_msg(
- "snmpMIB_to_OID: prefix \"$val\" unknown, load the parent MIB first.\n"
- );
- }
- $Carp::CarpLevel--;
- return $cnt;
-}
-
-
-# [documentation] ------------------------------------------------------------
-
-=head1 EXPORTS
-
-The Net_SNMP_util module uses the F<Exporter> module to export useful
-constants and subroutines. These exportable symbols are defined below and
-follow the rules and conventions of the F<Exporter> module (see L<Exporter>).
-
-=over
-
-=item Exportable
-
-&snmpget, &snmpgetnext, &snmpgetbulk, &snmpwalk, &snmpset, &snmptrap,
-&snmpmaptable, &snmpmaptable4, &snmpwalkhash, &snmpmapOID, &snmpMIB_to_OID,
-&snmpLoad_OID_Cache, &snmpQueue_MIB_File, ErrorMessage
-
-=back
-
-=head1 EXAMPLES
-
-=head2 1. SNMPv1 get-request for sysUpTime
-
-This example gets the sysUpTime from a remote host.
-
- #! /usr/local/bin/perl
- use strict;
- use Net_SNMP_util;
- my ($host, $ret)
- $host = shift || 'localhost';
- $ret = snmpget($host, 'sysUpTime');
-
- print("sysUpTime for $host is $ret\n");
-
- exit 0;
-
-=head2 2. SNMPv3 set-request of sysContact
-
-This example sets the sysContact information on the remote host to
-"Help Desk x911". The parameters passed to the snmpset function are for
-the demonstration of syntax only. These parameters will need to be
-set according to the SNMPv3 parameters of the remote host used by the script.
-
- #! /usr/local/bin/perl
- use strict;
- use Net_SNMP_util;
- my($host, %v3hash, $ret);
- $host = shift || 'localhost';
- $v3hash{'-version'} = 'snmpv3';
- $v3hash{'-username'} = 'myv3Username';
- $v3hash{'-authkey'} = '0x05c7fbde31916f64da4d5b77156bdfa7';
- $v3hash{'-authprotocol'} = 'md5';
- $v3hash{'-privkey'} = '0x93725fd3a02a48ce02df4e065a1c1746';
-
- $ret = snmpset($host, \%v3hash, 'sysContact', 'string', 'Help Desk x911');
-
- print "sysContact on $host is now $ret\n";
- exit 0;
-
-=head2 3. SNMPv2c walk for ifTable
-
-This example gets the contents of the ifTable by sending get-bulk-requests
-until the responses are no longer part of the ifTable. The ifTable can also
-be retrieved using C<snmpmaptable>.
-
- #! /usr/local/bin/perl
- use strict;
- use Net_SNMP_util;
- my($host, @ret, $oid, $val);
- $host = shift || 'localhost';
-
- @ret = snmpwalk($host . ':::::2', 'ifTable');
- foreach $val (@ret) {
- ($oid, $val) = split(':', $val, 2);
- print "$oid => $val\n";
- }
- exit 0;
-
-=head2 4. SNMPv2c maptable collecting ifDescr, ifInOctets, and ifOutOctets.
-
-This example collects a table containing the columns ifDescr, ifInOctets, and
-ifOutOctets. A printing function is called once per row.
-
- #! /usr/local/bin/perl
- use strict;
- use Net_SNMP_util;
-
- sub printfun($$$$) {
- my($inst, $desc, $in, $out) = @_;
- printf "%3d %-52.52s %10d %10d\n", $inst, $desc, $in, $out;
- }
-
- my($host, @ret);
- $host = shift || 'localhost';
-
- printf "%-3s %-52s %10s %10s\n", "Int", "Description", "In", "Out";
- @ret = snmpmaptable($host . ':::::2', \&printfun,
- 'ifDescr', 'ifInOctets', 'ifOutOctets');
-
- exit 0;
-
-=head1 REQUIREMENTS
-
-=over
-
-=item *
-
-The Net_SNMP_util module uses syntax that is not supported in versions of Perl
-earlier than v5.6.0.
-
-=item *
-
-The Net_SNMP_util module uses the F<Net::SNMP> module, and as such may depend
-on other modules. Please see the documentaion on F<Net::SNMP> for more
-information.
-
-=back
-
-=head1 AUTHOR
-
-Mike Mitchell <Mike.Mitchell@sas.com>
-
-=head1 ACKNOWLEGEMENTS
-
-The original concept for this module was based on F<SNMP_Session.pm> written
-by Simon Leinen <simon@switch.ch>
-
-=head1 COPYRIGHT
-
-Copyright (c) 2007 Mike Mitchell. All rights reserved. This program
-is free software; you may redistribute it and/or modify it under the same
-terms as Perl itself.
-
-=cut
-
-# ======================================================================
-1; # [end Net_SNMP_util]
diff --git a/src/lib/mrtg2/Pod/Checker.pm b/src/lib/mrtg2/Pod/Checker.pm
deleted file mode 100644
index a230542..0000000
--- a/src/lib/mrtg2/Pod/Checker.pm
+++ /dev/null
@@ -1,1268 +0,0 @@
-#############################################################################
-# Pod/Checker.pm -- check pod documents for syntax errors
-#
-# Copyright (C) 1994-2000 by Bradford Appleton. All rights reserved.
-# This file is part of "PodParser". PodParser is free software;
-# you can redistribute it and/or modify it under the same terms
-# as Perl itself.
-#############################################################################
-
-package Pod::Checker;
-use strict;
-
-use vars qw($VERSION @ISA @EXPORT %VALID_COMMANDS %VALID_SEQUENCES);
-$VERSION = '1.45'; ## Current version of this package
-require 5.005; ## requires this Perl version or later
-
-use Pod::ParseUtils; ## for hyperlinks and lists
-
-=head1 NAME
-
-Pod::Checker, podchecker() - check pod documents for syntax errors
-
-=head1 SYNOPSIS
-
- use Pod::Checker;
-
- $syntax_okay = podchecker($filepath, $outputpath, %options);
-
- my $checker = new Pod::Checker %options;
- $checker->parse_from_file($filepath, \*STDERR);
-
-=head1 OPTIONS/ARGUMENTS
-
-C<$filepath> is the input POD to read and C<$outputpath> is
-where to write POD syntax error messages. Either argument may be a scalar
-indicating a file-path, or else a reference to an open filehandle.
-If unspecified, the input-file it defaults to C<\*STDIN>, and
-the output-file defaults to C<\*STDERR>.
-
-=head2 podchecker()
-
-This function can take a hash of options:
-
-=over 4
-
-=item B<-warnings> =E<gt> I<val>
-
-Turn warnings on/off. I<val> is usually 1 for on, but higher values
-trigger additional warnings. See L<"Warnings">.
-
-=back
-
-=head1 DESCRIPTION
-
-B<podchecker> will perform syntax checking of Perl5 POD format documentation.
-
-Curious/ambitious users are welcome to propose additional features they wish
-to see in B<Pod::Checker> and B<podchecker> and verify that the checks are
-consistent with L<perlpod>.
-
-The following checks are currently performed:
-
-=over 4
-
-=item *
-
-Unknown '=xxxx' commands, unknown 'XE<lt>...E<gt>' interior-sequences,
-and unterminated interior sequences.
-
-=item *
-
-Check for proper balancing of C<=begin> and C<=end>. The contents of such
-a block are generally ignored, i.e. no syntax checks are performed.
-
-=item *
-
-Check for proper nesting and balancing of C<=over>, C<=item> and C<=back>.
-
-=item *
-
-Check for same nested interior-sequences (e.g.
-C<LE<lt>...LE<lt>...E<gt>...E<gt>>).
-
-=item *
-
-Check for malformed or non-existing entities C<EE<lt>...E<gt>>.
-
-=item *
-
-Check for correct syntax of hyperlinks C<LE<lt>...E<gt>>. See L<perlpod>
-for details.
-
-=item *
-
-Check for unresolved document-internal links. This check may also reveal
-misspelled links that seem to be internal links but should be links
-to something else.
-
-=back
-
-=head1 DIAGNOSTICS
-
-=head2 Errors
-
-=over 4
-
-=item * empty =headn
-
-A heading (C<=head1> or C<=head2>) without any text? That ain't no
-heading!
-
-=item * =over on line I<N> without closing =back
-
-The C<=over> command does not have a corresponding C<=back> before the
-next heading (C<=head1> or C<=head2>) or the end of the file.
-
-=item * =item without previous =over
-
-=item * =back without previous =over
-
-An C<=item> or C<=back> command has been found outside a
-C<=over>/C<=back> block.
-
-=item * No argument for =begin
-
-A C<=begin> command was found that is not followed by the formatter
-specification.
-
-=item * =end without =begin
-
-A standalone C<=end> command was found.
-
-=item * Nested =begin's
-
-There were at least two consecutive C<=begin> commands without
-the corresponding C<=end>. Only one C<=begin> may be active at
-a time.
-
-=item * =for without formatter specification
-
-There is no specification of the formatter after the C<=for> command.
-
-=item * unresolved internal link I<NAME>
-
-The given link to I<NAME> does not have a matching node in the current
-POD. This also happened when a single word node name is not enclosed in
-C<"">.
-
-=item * Unknown command "I<CMD>"
-
-An invalid POD command has been found. Valid are C<=head1>, C<=head2>,
-C<=head3>, C<=head4>, C<=over>, C<=item>, C<=back>, C<=begin>, C<=end>,
-C<=for>, C<=pod>, C<=cut>
-
-=item * Unknown interior-sequence "I<SEQ>"
-
-An invalid markup command has been encountered. Valid are:
-C<BE<lt>E<gt>>, C<CE<lt>E<gt>>, C<EE<lt>E<gt>>, C<FE<lt>E<gt>>,
-C<IE<lt>E<gt>>, C<LE<lt>E<gt>>, C<SE<lt>E<gt>>, C<XE<lt>E<gt>>,
-C<ZE<lt>E<gt>>
-
-=item * nested commands I<CMD>E<lt>...I<CMD>E<lt>...E<gt>...E<gt>
-
-Two nested identical markup commands have been found. Generally this
-does not make sense.
-
-=item * garbled entity I<STRING>
-
-The I<STRING> found cannot be interpreted as a character entity.
-
-=item * Entity number out of range
-
-An entity specified by number (dec, hex, oct) is out of range (1-255).
-
-=item * malformed link LE<lt>E<gt>
-
-The link found cannot be parsed because it does not conform to the
-syntax described in L<perlpod>.
-
-=item * nonempty ZE<lt>E<gt>
-
-The C<ZE<lt>E<gt>> sequence is supposed to be empty.
-
-=item * empty XE<lt>E<gt>
-
-The index entry specified contains nothing but whitespace.
-
-=item * Spurious text after =pod / =cut
-
-The commands C<=pod> and C<=cut> do not take any arguments.
-
-=item * Spurious character(s) after =back
-
-The C<=back> command does not take any arguments.
-
-=back
-
-=head2 Warnings
-
-These may not necessarily cause trouble, but indicate mediocre style.
-
-=over 4
-
-=item * multiple occurrence of link target I<name>
-
-The POD file has some C<=item> and/or C<=head> commands that have
-the same text. Potential hyperlinks to such a text cannot be unique then.
-This warning is printed only with warning level greater than one.
-
-=item * line containing nothing but whitespace in paragraph
-
-There is some whitespace on a seemingly empty line. POD is very sensitive
-to such things, so this is flagged. B<vi> users switch on the B<list>
-option to avoid this problem.
-
-=begin _disabled_
-
-=item * file does not start with =head
-
-The file starts with a different POD directive than head.
-This is most probably something you do not want.
-
-=end _disabled_
-
-=item * previous =item has no contents
-
-There is a list C<=item> right above the flagged line that has no
-text contents. You probably want to delete empty items.
-
-=item * preceding non-item paragraph(s)
-
-A list introduced by C<=over> starts with a text or verbatim paragraph,
-but continues with C<=item>s. Move the non-item paragraph out of the
-C<=over>/C<=back> block.
-
-=item * =item type mismatch (I<one> vs. I<two>)
-
-A list started with e.g. a bullet-like C<=item> and continued with a
-numbered one. This is obviously inconsistent. For most translators the
-type of the I<first> C<=item> determines the type of the list.
-
-=item * I<N> unescaped C<E<lt>E<gt>> in paragraph
-
-Angle brackets not written as C<E<lt>ltE<gt>> and C<E<lt>gtE<gt>>
-can potentially cause errors as they could be misinterpreted as
-markup commands. This is only printed when the -warnings level is
-greater than 1.
-
-=item * Unknown entity
-
-A character entity was found that does not belong to the standard
-ISO set or the POD specials C<verbar> and C<sol>.
-
-=item * No items in =over
-
-The list opened with C<=over> does not contain any items.
-
-=item * No argument for =item
-
-C<=item> without any parameters is deprecated. It should either be followed
-by C<*> to indicate an unordered list, by a number (optionally followed
-by a dot) to indicate an ordered (numbered) list or simple text for a
-definition list.
-
-=item * empty section in previous paragraph
-
-The previous section (introduced by a C<=head> command) does not contain
-any text. This usually indicates that something is missing. Note: A
-C<=head1> followed immediately by C<=head2> does not trigger this warning.
-
-=item * Verbatim paragraph in NAME section
-
-The NAME section (C<=head1 NAME>) should consist of a single paragraph
-with the script/module name, followed by a dash `-' and a very short
-description of what the thing is good for.
-
-=item * =headI<n> without preceding higher level
-
-For example if there is a C<=head2> in the POD file prior to a
-C<=head1>.
-
-=back
-
-=head2 Hyperlinks
-
-There are some warnings with respect to malformed hyperlinks:
-
-=over 4
-
-=item * ignoring leading/trailing whitespace in link
-
-There is whitespace at the beginning or the end of the contents of
-LE<lt>...E<gt>.
-
-=item * (section) in '$page' deprecated
-
-There is a section detected in the page name of LE<lt>...E<gt>, e.g.
-C<LE<lt>passwd(2)E<gt>>. POD hyperlinks may point to POD documents only.
-Please write C<CE<lt>passwd(2)E<gt>> instead. Some formatters are able
-to expand this to appropriate code. For links to (builtin) functions,
-please say C<LE<lt>perlfunc/mkdirE<gt>>, without ().
-
-=item * alternative text/node '%s' contains non-escaped | or /
-
-The characters C<|> and C</> are special in the LE<lt>...E<gt> context.
-Although the hyperlink parser does its best to determine which "/" is
-text and which is a delimiter in case of doubt, one ought to escape
-these literal characters like this:
-
- / E<sol>
- | E<verbar>
-
-=back
-
-=head1 RETURN VALUE
-
-B<podchecker> returns the number of POD syntax errors found or -1 if
-there were no POD commands at all found in the file.
-
-=head1 EXAMPLES
-
-See L</SYNOPSIS>
-
-=head1 INTERFACE
-
-While checking, this module collects document properties, e.g. the nodes
-for hyperlinks (C<=headX>, C<=item>) and index entries (C<XE<lt>E<gt>>).
-POD translators can use this feature to syntax-check and get the nodes in
-a first pass before actually starting to convert. This is expensive in terms
-of execution time, but allows for very robust conversions.
-
-Since PodParser-1.24 the B<Pod::Checker> module uses only the B<poderror>
-method to print errors and warnings. The summary output (e.g.
-"Pod syntax OK") has been dropped from the module and has been included in
-B<podchecker> (the script). This allows users of B<Pod::Checker> to
-control completely the output behavior. Users of B<podchecker> (the script)
-get the well-known behavior.
-
-=cut
-
-#############################################################################
-
-#use diagnostics;
-use Carp qw(croak);
-use Exporter;
-use Pod::Parser;
-
-@ISA = qw(Pod::Parser);
-@EXPORT = qw(&podchecker);
-
-my %VALID_COMMANDS = (
- 'pod' => 1,
- 'cut' => 1,
- 'head1' => 1,
- 'head2' => 1,
- 'head3' => 1,
- 'head4' => 1,
- 'over' => 1,
- 'back' => 1,
- 'item' => 1,
- 'for' => 1,
- 'begin' => 1,
- 'end' => 1,
- 'encoding' => 1,
-);
-
-my %VALID_SEQUENCES = (
- 'I' => 1,
- 'B' => 1,
- 'S' => 1,
- 'C' => 1,
- 'L' => 1,
- 'F' => 1,
- 'X' => 1,
- 'Z' => 1,
- 'E' => 1,
-);
-
-# stolen from HTML::Entities
-my %ENTITIES = (
- # Some normal chars that have special meaning in SGML context
- amp => '&', # ampersand
-'gt' => '>', # greater than
-'lt' => '<', # less than
- quot => '"', # double quote
-
- # PUBLIC ISO 8879-1986//ENTITIES Added Latin 1//EN//HTML
- AElig => 'Æ', # capital AE diphthong (ligature)
- Aacute => 'Á', # capital A, acute accent
- Acirc => 'Â', # capital A, circumflex accent
- Agrave => 'À', # capital A, grave accent
- Aring => 'Å', # capital A, ring
- Atilde => 'Ã', # capital A, tilde
- Auml => 'Ä', # capital A, dieresis or umlaut mark
- Ccedil => 'Ç', # capital C, cedilla
- ETH => 'Ð', # capital Eth, Icelandic
- Eacute => 'É', # capital E, acute accent
- Ecirc => 'Ê', # capital E, circumflex accent
- Egrave => 'È', # capital E, grave accent
- Euml => 'Ë', # capital E, dieresis or umlaut mark
- Iacute => 'Í', # capital I, acute accent
- Icirc => 'Î', # capital I, circumflex accent
- Igrave => 'Ì', # capital I, grave accent
- Iuml => 'Ï', # capital I, dieresis or umlaut mark
- Ntilde => 'Ñ', # capital N, tilde
- Oacute => 'Ó', # capital O, acute accent
- Ocirc => 'Ô', # capital O, circumflex accent
- Ograve => 'Ò', # capital O, grave accent
- Oslash => 'Ø', # capital O, slash
- Otilde => 'Õ', # capital O, tilde
- Ouml => 'Ö', # capital O, dieresis or umlaut mark
- THORN => 'Þ', # capital THORN, Icelandic
- Uacute => 'Ú', # capital U, acute accent
- Ucirc => 'Û', # capital U, circumflex accent
- Ugrave => 'Ù', # capital U, grave accent
- Uuml => 'Ü', # capital U, dieresis or umlaut mark
- Yacute => 'Ý', # capital Y, acute accent
- aacute => 'á', # small a, acute accent
- acirc => 'â', # small a, circumflex accent
- aelig => 'æ', # small ae diphthong (ligature)
- agrave => 'à', # small a, grave accent
- aring => 'å', # small a, ring
- atilde => 'ã', # small a, tilde
- auml => 'ä', # small a, dieresis or umlaut mark
- ccedil => 'ç', # small c, cedilla
- eacute => 'é', # small e, acute accent
- ecirc => 'ê', # small e, circumflex accent
- egrave => 'è', # small e, grave accent
- eth => 'ð', # small eth, Icelandic
- euml => 'ë', # small e, dieresis or umlaut mark
- iacute => 'í', # small i, acute accent
- icirc => 'î', # small i, circumflex accent
- igrave => 'ì', # small i, grave accent
- iuml => 'ï', # small i, dieresis or umlaut mark
- ntilde => 'ñ', # small n, tilde
- oacute => 'ó', # small o, acute accent
- ocirc => 'ô', # small o, circumflex accent
- ograve => 'ò', # small o, grave accent
- oslash => 'ø', # small o, slash
- otilde => 'õ', # small o, tilde
- ouml => 'ö', # small o, dieresis or umlaut mark
- szlig => 'ß', # small sharp s, German (sz ligature)
- thorn => 'þ', # small thorn, Icelandic
- uacute => 'ú', # small u, acute accent
- ucirc => 'û', # small u, circumflex accent
- ugrave => 'ù', # small u, grave accent
- uuml => 'ü', # small u, dieresis or umlaut mark
- yacute => 'ý', # small y, acute accent
- yuml => 'ÿ', # small y, dieresis or umlaut mark
-
- # Some extra Latin 1 chars that are listed in the HTML3.2 draft (21-May-96)
- copy => '©', # copyright sign
- reg => '®', # registered sign
- nbsp => "\240", # non breaking space
-
- # Additional ISO-8859/1 entities listed in rfc1866 (section 14)
- iexcl => '¡',
- cent => '¢',
- pound => '£',
- curren => '¤',
- yen => '¥',
- brvbar => '¦',
- sect => '§',
- uml => '¨',
- ordf => 'ª',
- laquo => '«',
-'not' => '¬', # not is a keyword in perl
- shy => '­',
- macr => '¯',
- deg => '°',
- plusmn => '±',
- sup1 => '¹',
- sup2 => '²',
- sup3 => '³',
- acute => '´',
- micro => 'µ',
- para => '¶',
- middot => '·',
- cedil => '¸',
- ordm => 'º',
- raquo => '»',
- frac14 => '¼',
- frac12 => '½',
- frac34 => '¾',
- iquest => '¿',
-'times' => '×', # times is a keyword in perl
- divide => '÷',
-
-# some POD special entities
- verbar => '|',
- sol => '/'
-);
-
-##---------------------------------------------------------------------------
-
-##---------------------------------
-## Function definitions begin here
-##---------------------------------
-
-sub podchecker {
- my ($infile, $outfile, %options) = @_;
- local $_;
-
- ## Set defaults
- $infile ||= \*STDIN;
- $outfile ||= \*STDERR;
-
- ## Now create a pod checker
- my $checker = new Pod::Checker(%options);
-
- ## Now check the pod document for errors
- $checker->parse_from_file($infile, $outfile);
-
- ## Return the number of errors found
- return $checker->num_errors();
-}
-
-##---------------------------------------------------------------------------
-
-##-------------------------------
-## Method definitions begin here
-##-------------------------------
-
-##################################
-
-=over 4
-
-=item C<Pod::Checker-E<gt>new( %options )>
-
-Return a reference to a new Pod::Checker object that inherits from
-Pod::Parser and is used for calling the required methods later. The
-following options are recognized:
-
-C<-warnings =E<gt> num>
- Print warnings if C<num> is true. The higher the value of C<num>,
-the more warnings are printed. Currently there are only levels 1 and 2.
-
-C<-quiet =E<gt> num>
- If C<num> is true, do not print any errors/warnings. This is useful
-when Pod::Checker is used to munge POD code into plain text from within
-POD formatters.
-
-=cut
-
-## sub new {
-## my $this = shift;
-## my $class = ref($this) || $this;
-## my %params = @_;
-## my $self = {%params};
-## bless $self, $class;
-## $self->initialize();
-## return $self;
-## }
-
-sub initialize {
- my $self = shift;
- ## Initialize number of errors, and setup an error function to
- ## increment this number and then print to the designated output.
- $self->{_NUM_ERRORS} = 0;
- $self->{_NUM_WARNINGS} = 0;
- $self->{-quiet} ||= 0;
- # set the error handling subroutine
- $self->errorsub($self->{-quiet} ? sub { 1; } : 'poderror');
- $self->{_commands} = 0; # total number of POD commands encountered
- $self->{_list_stack} = []; # stack for nested lists
- $self->{_have_begin} = ''; # stores =begin
- $self->{_links} = []; # stack for internal hyperlinks
- $self->{_nodes} = []; # stack for =head/=item nodes
- $self->{_index} = []; # text in X<>
- # print warnings?
- $self->{-warnings} = 1 unless(defined $self->{-warnings});
- $self->{_current_head1} = ''; # the current =head1 block
- $self->parseopts(-process_cut_cmd => 1, -warnings => $self->{-warnings});
-}
-
-##################################
-
-=item C<$checker-E<gt>poderror( @args )>
-
-=item C<$checker-E<gt>poderror( {%opts}, @args )>
-
-Internal method for printing errors and warnings. If no options are
-given, simply prints "@_". The following options are recognized and used
-to form the output:
-
- -msg
-
-A message to print prior to C<@args>.
-
- -line
-
-The line number the error occurred in.
-
- -file
-
-The file (name) the error occurred in.
-
- -severity
-
-The error level, should be 'WARNING' or 'ERROR'.
-
-=cut
-
-# Invoked as $self->poderror( @args ), or $self->poderror( {%opts}, @args )
-sub poderror {
- my $self = shift;
- my %opts = (ref $_[0]) ? %{shift()} : ();
-
- ## Retrieve options
- chomp( my $msg = ($opts{-msg} || '')."@_" );
- my $line = (exists $opts{-line}) ? " at line $opts{-line}" : '';
- my $file = (exists $opts{-file}) ? " in file $opts{-file}" : '';
- unless (exists $opts{-severity}) {
- ## See if can find severity in message prefix
- $opts{-severity} = $1 if ( $msg =~ s/^\**\s*([A-Z]{3,}):\s+// );
- }
- my $severity = (exists $opts{-severity}) ? "*** $opts{-severity}: " : '';
-
- ## Increment error count and print message "
- ++($self->{_NUM_ERRORS})
- if(!%opts || ($opts{-severity} && $opts{-severity} eq 'ERROR'));
- ++($self->{_NUM_WARNINGS})
- if(!%opts || ($opts{-severity} && $opts{-severity} eq 'WARNING'));
- unless($self->{-quiet}) {
- my $out_fh = $self->output_handle() || \*STDERR;
- print $out_fh ($severity, $msg, $line, $file, "\n")
- if($self->{-warnings} || !%opts || $opts{-severity} ne 'WARNING');
- }
-}
-
-##################################
-
-=item C<$checker-E<gt>num_errors()>
-
-Set (if argument specified) and retrieve the number of errors found.
-
-=cut
-
-sub num_errors {
- return (@_ > 1) ? ($_[0]->{_NUM_ERRORS} = $_[1]) : $_[0]->{_NUM_ERRORS};
-}
-
-##################################
-
-=item C<$checker-E<gt>num_warnings()>
-
-Set (if argument specified) and retrieve the number of warnings found.
-
-=cut
-
-sub num_warnings {
- return (@_ > 1) ? ($_[0]->{_NUM_WARNINGS} = $_[1]) : $_[0]->{_NUM_WARNINGS};
-}
-
-##################################
-
-=item C<$checker-E<gt>name()>
-
-Set (if argument specified) and retrieve the canonical name of POD as
-found in the C<=head1 NAME> section.
-
-=cut
-
-sub name {
- return (@_ > 1 && $_[1]) ?
- ($_[0]->{-name} = $_[1]) : $_[0]->{-name};
-}
-
-##################################
-
-=item C<$checker-E<gt>node()>
-
-Add (if argument specified) and retrieve the nodes (as defined by C<=headX>
-and C<=item>) of the current POD. The nodes are returned in the order of
-their occurrence. They consist of plain text, each piece of whitespace is
-collapsed to a single blank.
-
-=cut
-
-sub node {
- my ($self,$text) = @_;
- if(defined $text) {
- $text =~ s/\s+$//s; # strip trailing whitespace
- $text =~ s/\s+/ /gs; # collapse whitespace
- # add node, order important!
- push(@{$self->{_nodes}}, $text);
- # keep also a uniqueness counter
- $self->{_unique_nodes}->{$text}++ if($text !~ /^\s*$/s);
- return $text;
- }
- @{$self->{_nodes}};
-}
-
-##################################
-
-=item C<$checker-E<gt>idx()>
-
-Add (if argument specified) and retrieve the index entries (as defined by
-C<XE<lt>E<gt>>) of the current POD. They consist of plain text, each piece
-of whitespace is collapsed to a single blank.
-
-=cut
-
-# set/return index entries of current POD
-sub idx {
- my ($self,$text) = @_;
- if(defined $text) {
- $text =~ s/\s+$//s; # strip trailing whitespace
- $text =~ s/\s+/ /gs; # collapse whitespace
- # add node, order important!
- push(@{$self->{_index}}, $text);
- # keep also a uniqueness counter
- $self->{_unique_nodes}->{$text}++ if($text !~ /^\s*$/s);
- return $text;
- }
- @{$self->{_index}};
-}
-
-##################################
-
-=item C<$checker-E<gt>hyperlink()>
-
-Add (if argument specified) and retrieve the hyperlinks (as defined by
-C<LE<lt>E<gt>>) of the current POD. They consist of a 2-item array: line
-number and C<Pod::Hyperlink> object.
-
-=back
-
-=cut
-
-# set/return hyperlinks of the current POD
-sub hyperlink {
- my $self = shift;
- if($_[0]) {
- push(@{$self->{_links}}, $_[0]);
- return $_[0];
- }
- @{$self->{_links}};
-}
-
-## overrides for Pod::Parser
-
-sub end_pod {
- ## Do some final checks and
- ## print the number of errors found
- my $self = shift;
- my $infile = $self->input_file();
-
- if(@{$self->{_list_stack}}) {
- my $list;
- while(($list = $self->_close_list('EOF',$infile)) &&
- $list->indent() ne 'auto') {
- $self->poderror({ -line => 'EOF', -file => $infile,
- -severity => 'ERROR', -msg => '=over on line ' .
- $list->start() . ' without closing =back' });
- }
- }
-
- # check validity of document internal hyperlinks
- # first build the node names from the paragraph text
- my %nodes;
- foreach($self->node()) {
- $nodes{$_} = 1;
- if(/^(\S+)\s+\S/) {
- # we have more than one word. Use the first as a node, too.
- # This is used heavily in perlfunc.pod
- $nodes{$1} ||= 2; # derived node
- }
- }
- foreach($self->idx()) {
- $nodes{$_} = 3; # index node
- }
- foreach($self->hyperlink()) {
- my ($line,$link) = @$_;
- # _TODO_ what if there is a link to the page itself by the name,
- # e.g. in Tk::Pod : L<Tk::Pod/"DESCRIPTION">
- if($link->node() && !$link->page() && $link->type() ne 'hyperlink') {
- my $node = $self->_check_ptree($self->parse_text($link->node(),
- $line), $line, $infile, 'L');
- if($node && !$nodes{$node}) {
- $self->poderror({ -line => $line || '', -file => $infile,
- -severity => 'ERROR',
- -msg => "unresolved internal link '$node'"});
- }
- }
- }
-
- # check the internal nodes for uniqueness. This pertains to
- # =headX, =item and X<...>
- if($self->{-warnings} && $self->{-warnings}>1) {
- foreach(grep($self->{_unique_nodes}->{$_} > 1,
- keys %{$self->{_unique_nodes}})) {
- $self->poderror({ -line => '-', -file => $infile,
- -severity => 'WARNING',
- -msg => "multiple occurrence of link target '$_'"});
- }
- }
-
- # no POD found here
- $self->num_errors(-1) if($self->{_commands} == 0);
-}
-
-# check a POD command directive
-sub command {
- my ($self, $cmd, $paragraph, $line_num, $pod_para) = @_;
- my ($file, $line) = $pod_para->file_line;
- ## Check the command syntax
- my $arg; # this will hold the command argument
- if (! $VALID_COMMANDS{$cmd}) {
- $self->poderror({ -line => $line, -file => $file, -severity => 'ERROR',
- -msg => "Unknown command '$cmd'" });
- }
- else { # found a valid command
- $self->{_commands}++; # delete this line if below is enabled again
-
- ##### following check disabled due to strong request
- #if(!$self->{_commands}++ && $cmd !~ /^head/) {
- # $self->poderror({ -line => $line, -file => $file,
- # -severity => 'WARNING',
- # -msg => "file does not start with =head" });
- #}
-
- # check syntax of particular command
- if($cmd eq 'over') {
- # check for argument
- $arg = $self->interpolate_and_check($paragraph, $line,$file);
- my $indent = 4; # default
- if($arg && $arg =~ /^\s*(\d+)\s*$/) {
- $indent = $1;
- }
- # start a new list
- $self->_open_list($indent,$line,$file);
- }
- elsif($cmd eq 'item') {
- # are we in a list?
- unless(@{$self->{_list_stack}}) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => '=item without previous =over' });
- # auto-open in case we encounter many more
- $self->_open_list('auto',$line,$file);
- }
- my $list = $self->{_list_stack}->[0];
- # check whether the previous item had some contents
- if(defined $self->{_list_item_contents} &&
- $self->{_list_item_contents} == 0) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'WARNING',
- -msg => 'previous =item has no contents' });
- }
- if($list->{_has_par}) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'WARNING',
- -msg => 'preceding non-item paragraph(s)' });
- delete $list->{_has_par};
- }
- # check for argument
- $arg = $self->interpolate_and_check($paragraph, $line, $file);
- if($arg && $arg =~ /(\S+)/) {
- $arg =~ s/[\s\n]+$//;
- my $type;
- if($arg =~ /^[*]\s*(\S*.*)/) {
- $type = 'bullet';
- $self->{_list_item_contents} = $1 ? 1 : 0;
- $arg = $1;
- }
- elsif($arg =~ /^\d+\.?\s+(\S*)/) {
- $type = 'number';
- $self->{_list_item_contents} = $1 ? 1 : 0;
- $arg = $1;
- }
- else {
- $type = 'definition';
- $self->{_list_item_contents} = 1;
- }
- my $first = $list->type();
- if($first && $first ne $type) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'WARNING',
- -msg => "=item type mismatch ('$first' vs. '$type')"});
- }
- else { # first item
- $list->type($type);
- }
- }
- else {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'WARNING',
- -msg => 'No argument for =item' });
- $arg = ' '; # empty
- $self->{_list_item_contents} = 0;
- }
- # add this item
- $list->item($arg);
- # remember this node
- $self->node($arg);
- }
- elsif($cmd eq 'back') {
- # check if we have an open list
- unless(@{$self->{_list_stack}}) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => '=back without previous =over' });
- }
- else {
- # check for spurious characters
- $arg = $self->interpolate_and_check($paragraph, $line,$file);
- if($arg && $arg =~ /\S/) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => 'Spurious character(s) after =back' });
- }
- # close list
- my $list = $self->_close_list($line,$file);
- # check for empty lists
- if(!$list->item() && $self->{-warnings}) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'WARNING',
- -msg => 'No items in =over (at line ' .
- $list->start() . ') / =back list'});
- }
- }
- }
- elsif($cmd =~ /^head(\d+)/) {
- my $hnum = $1;
- $self->{"_have_head_$hnum"}++; # count head types
- if($hnum > 1 && !$self->{'_have_head_'.($hnum -1)}) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'WARNING',
- -msg => "=head$hnum without preceding higher level"});
- }
- # check whether the previous =head section had some contents
- if(defined $self->{_commands_in_head} &&
- $self->{_commands_in_head} == 0 &&
- defined $self->{_last_head} &&
- $self->{_last_head} >= $hnum) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'WARNING',
- -msg => 'empty section in previous paragraph'});
- }
- $self->{_commands_in_head} = -1;
- $self->{_last_head} = $hnum;
- # check if there is an open list
- if(@{$self->{_list_stack}}) {
- my $list;
- while(($list = $self->_close_list($line,$file)) &&
- $list->indent() ne 'auto') {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => '=over on line '. $list->start() .
- " without closing =back (at $cmd)" });
- }
- }
- # remember this node
- $arg = $self->interpolate_and_check($paragraph, $line,$file);
- $arg =~ s/[\s\n]+$//s;
- $self->node($arg);
- unless(length($arg)) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => "empty =$cmd"});
- }
- if($cmd eq 'head1') {
- $self->{_current_head1} = $arg;
- } else {
- $self->{_current_head1} = '';
- }
- }
- elsif($cmd eq 'begin') {
- if($self->{_have_begin}) {
- # already have a begin
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => q{Nested =begin's (first at line } .
- $self->{_have_begin} . ')'});
- }
- else {
- # check for argument
- $arg = $self->interpolate_and_check($paragraph, $line,$file);
- unless($arg && $arg =~ /(\S+)/) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => 'No argument for =begin'});
- }
- # remember the =begin
- $self->{_have_begin} = "$line:$1";
- }
- }
- elsif($cmd eq 'end') {
- if($self->{_have_begin}) {
- # close the existing =begin
- $self->{_have_begin} = '';
- # check for spurious characters
- $arg = $self->interpolate_and_check($paragraph, $line,$file);
- # the closing argument is optional
- #if($arg && $arg =~ /\S/) {
- # $self->poderror({ -line => $line, -file => $file,
- # -severity => 'WARNING',
- # -msg => "Spurious character(s) after =end" });
- #}
- }
- else {
- # don't have a matching =begin
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => '=end without =begin' });
- }
- }
- elsif($cmd eq 'for') {
- unless($paragraph =~ /\s*(\S+)\s*/) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => '=for without formatter specification' });
- }
- $arg = ''; # do not expand paragraph below
- }
- elsif($cmd =~ /^(pod|cut)$/) {
- # check for argument
- $arg = $self->interpolate_and_check($paragraph, $line,$file);
- if($arg && $arg =~ /(\S+)/) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => "Spurious text after =$cmd"});
- }
- }
- $self->{_commands_in_head}++;
- ## Check the interior sequences in the command-text
- $self->interpolate_and_check($paragraph, $line,$file)
- unless(defined $arg);
- }
-}
-
-sub _open_list
-{
- my ($self,$indent,$line,$file) = @_;
- my $list = Pod::List->new(
- -indent => $indent,
- -start => $line,
- -file => $file);
- unshift(@{$self->{_list_stack}}, $list);
- undef $self->{_list_item_contents};
- $list;
-}
-
-sub _close_list
-{
- my ($self,$line,$file) = @_;
- my $list = shift(@{$self->{_list_stack}});
- if(defined $self->{_list_item_contents} &&
- $self->{_list_item_contents} == 0) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'WARNING',
- -msg => 'previous =item has no contents' });
- }
- undef $self->{_list_item_contents};
- $list;
-}
-
-# process a block of some text
-sub interpolate_and_check {
- my ($self, $paragraph, $line, $file) = @_;
- ## Check the interior sequences in the command-text
- # and return the text
- $self->_check_ptree(
- $self->parse_text($paragraph,$line), $line, $file, '');
-}
-
-sub _check_ptree {
- my ($self,$ptree,$line,$file,$nestlist) = @_;
- local($_);
- my $text = '';
- # process each node in the parse tree
- foreach(@$ptree) {
- # regular text chunk
- unless(ref) {
- # count the unescaped angle brackets
- # complain only when warning level is greater than 1
- if($self->{-warnings} && $self->{-warnings}>1) {
- my $count;
- if($count = tr/<>/<>/) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'WARNING',
- -msg => "$count unescaped <> in paragraph" });
- }
- }
- $text .= $_;
- next;
- }
- # have an interior sequence
- my $cmd = $_->cmd_name();
- my $contents = $_->parse_tree();
- ($file,$line) = $_->file_line();
- # check for valid tag
- if (! $VALID_SEQUENCES{$cmd}) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => qq(Unknown interior-sequence '$cmd')});
- # expand it anyway
- $text .= $self->_check_ptree($contents, $line, $file, "$nestlist$cmd");
- next;
- }
- if($nestlist =~ /$cmd/) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'WARNING',
- -msg => "nested commands $cmd<...$cmd<...>...>"});
- # _TODO_ should we add the contents anyway?
- # expand it anyway, see below
- }
- if($cmd eq 'E') {
- # preserve entities
- if(@$contents > 1 || ref $$contents[0] || $$contents[0] !~ /^\w+$/) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => 'garbled entity ' . $_->raw_text()});
- next;
- }
- my $ent = $$contents[0];
- my $val;
- if($ent =~ /^0x[0-9a-f]+$/i) {
- # hexadec entity
- $val = hex($ent);
- }
- elsif($ent =~ /^0\d+$/) {
- # octal
- $val = oct($ent);
- }
- elsif($ent =~ /^\d+$/) {
- # numeric entity
- $val = $ent;
- }
- if(defined $val) {
- if($val>0 && $val<256) {
- $text .= chr($val);
- }
- else {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => 'Entity number out of range ' . $_->raw_text()});
- }
- }
- elsif($ENTITIES{$ent}) {
- # known ISO entity
- $text .= $ENTITIES{$ent};
- }
- else {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'WARNING',
- -msg => 'Unknown entity ' . $_->raw_text()});
- $text .= "E<$ent>";
- }
- }
- elsif($cmd eq 'L') {
- # try to parse the hyperlink
- my $link = Pod::Hyperlink->new($contents->raw_text());
- unless(defined $link) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => 'malformed link ' . $_->raw_text() ." : $@"});
- next;
- }
- $link->line($line); # remember line
- if($self->{-warnings}) {
- foreach my $w ($link->warning()) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'WARNING',
- -msg => $w });
- }
- }
- # check the link text
- $text .= $self->_check_ptree($self->parse_text($link->text(),
- $line), $line, $file, "$nestlist$cmd");
- # remember link
- $self->hyperlink([$line,$link]);
- }
- elsif($cmd =~ /[BCFIS]/) {
- # add the guts
- $text .= $self->_check_ptree($contents, $line, $file, "$nestlist$cmd");
- }
- elsif($cmd eq 'Z') {
- if(length($contents->raw_text())) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => 'Nonempty Z<>'});
- }
- }
- elsif($cmd eq 'X') {
- my $idx = $self->_check_ptree($contents, $line, $file, "$nestlist$cmd");
- if($idx =~ /^\s*$/s) {
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'ERROR',
- -msg => 'Empty X<>'});
- }
- else {
- # remember this node
- $self->idx($idx);
- }
- }
- else {
- # not reached
- croak 'internal error';
- }
- }
- $text;
-}
-
-# process a block of verbatim text
-sub verbatim {
- ## Nothing particular to check
- my ($self, $paragraph, $line_num, $pod_para) = @_;
-
- $self->_preproc_par($paragraph);
-
- if($self->{_current_head1} eq 'NAME') {
- my ($file, $line) = $pod_para->file_line;
- $self->poderror({ -line => $line, -file => $file,
- -severity => 'WARNING',
- -msg => 'Verbatim paragraph in NAME section' });
- }
-}
-
-# process a block of regular text
-sub textblock {
- my ($self, $paragraph, $line_num, $pod_para) = @_;
- my ($file, $line) = $pod_para->file_line;
-
- $self->_preproc_par($paragraph);
-
- # skip this paragraph if in a =begin block
- unless($self->{_have_begin}) {
- my $block = $self->interpolate_and_check($paragraph, $line,$file);
- if($self->{_current_head1} eq 'NAME') {
- if($block =~ /^\s*(\S+?)\s*[,-]/) {
- # this is the canonical name
- $self->{-name} = $1 unless(defined $self->{-name});
- }
- }
- }
-}
-
-sub _preproc_par
-{
- my $self = shift;
- $_[0] =~ s/[\s\n]+$//;
- if($_[0]) {
- $self->{_commands_in_head}++;
- $self->{_list_item_contents}++ if(defined $self->{_list_item_contents});
- if(@{$self->{_list_stack}} && !$self->{_list_stack}->[0]->item()) {
- $self->{_list_stack}->[0]->{_has_par} = 1;
- }
- }
-}
-
-1;
-
-__END__
-
-=head1 AUTHOR
-
-Please report bugs using L<http://rt.cpan.org>.
-
-Brad Appleton E<lt>bradapp@enteract.comE<gt> (initial version),
-Marek Rouchal E<lt>marekr@cpan.orgE<gt>
-
-Based on code for B<Pod::Text::pod2text()> written by
-Tom Christiansen E<lt>tchrist@mox.perl.comE<gt>
-
-=cut
-
diff --git a/src/lib/mrtg2/Pod/Find.pm b/src/lib/mrtg2/Pod/Find.pm
deleted file mode 100644
index 8d1103b..0000000
--- a/src/lib/mrtg2/Pod/Find.pm
+++ /dev/null
@@ -1,535 +0,0 @@
-#############################################################################
-# Pod/Find.pm -- finds files containing POD documentation
-#
-# Author: Marek Rouchal <marekr@cpan.org>
-#
-# Copyright (C) 1999-2000 by Marek Rouchal (and borrowing code
-# from Nick Ing-Simmon's PodToHtml). All rights reserved.
-# This file is part of "PodParser". Pod::Find is free software;
-# you can redistribute it and/or modify it under the same terms
-# as Perl itself.
-#############################################################################
-
-package Pod::Find;
-use strict;
-
-use vars qw($VERSION);
-$VERSION = '1.35'; ## Current version of this package
-require 5.005; ## requires this Perl version or later
-use Carp;
-
-BEGIN {
- if ($] < 5.006) {
- require Symbol;
- import Symbol;
- }
-}
-
-#############################################################################
-
-=head1 NAME
-
-Pod::Find - find POD documents in directory trees
-
-=head1 SYNOPSIS
-
- use Pod::Find qw(pod_find simplify_name);
- my %pods = pod_find({ -verbose => 1, -inc => 1 });
- foreach(keys %pods) {
- print "found library POD `$pods{$_}' in $_\n";
- }
-
- print "podname=",simplify_name('a/b/c/mymodule.pod'),"\n";
-
- $location = pod_where( { -inc => 1 }, "Pod::Find" );
-
-=head1 DESCRIPTION
-
-B<Pod::Find> provides a set of functions to locate POD files. Note that
-no function is exported by default to avoid pollution of your namespace,
-so be sure to specify them in the B<use> statement if you need them:
-
- use Pod::Find qw(pod_find);
-
-From this version on the typical SCM (software configuration management)
-files/directories like RCS, CVS, SCCS, .svn are ignored.
-
-=cut
-
-#use diagnostics;
-use Exporter;
-use File::Spec;
-use File::Find;
-use Cwd;
-
-use vars qw(@ISA @EXPORT_OK $VERSION);
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(&pod_find &simplify_name &pod_where &contains_pod);
-
-# package global variables
-my $SIMPLIFY_RX;
-
-=head2 C<pod_find( { %opts } , @directories )>
-
-The function B<pod_find> searches for POD documents in a given set of
-files and/or directories. It returns a hash with the file names as keys
-and the POD name as value. The POD name is derived from the file name
-and its position in the directory tree.
-
-E.g. when searching in F<$HOME/perl5lib>, the file
-F<$HOME/perl5lib/MyModule.pm> would get the POD name I<MyModule>,
-whereas F<$HOME/perl5lib/Myclass/Subclass.pm> would be
-I<Myclass::Subclass>. The name information can be used for POD
-translators.
-
-Only text files containing at least one valid POD command are found.
-
-A warning is printed if more than one POD file with the same POD name
-is found, e.g. F<CPAN.pm> in different directories. This usually
-indicates duplicate occurrences of modules in the I<@INC> search path.
-
-B<OPTIONS> The first argument for B<pod_find> may be a hash reference
-with options. The rest are either directories that are searched
-recursively or files. The POD names of files are the plain basenames
-with any Perl-like extension (.pm, .pl, .pod) stripped.
-
-=over 4
-
-=item C<-verbose =E<gt> 1>
-
-Print progress information while scanning.
-
-=item C<-perl =E<gt> 1>
-
-Apply Perl-specific heuristics to find the correct PODs. This includes
-stripping Perl-like extensions, omitting subdirectories that are numeric
-but do I<not> match the current Perl interpreter's version id, suppressing
-F<site_perl> as a module hierarchy name etc.
-
-=item C<-script =E<gt> 1>
-
-Search for PODs in the current Perl interpreter's installation
-B<scriptdir>. This is taken from the local L<Config|Config> module.
-
-=item C<-inc =E<gt> 1>
-
-Search for PODs in the current Perl interpreter's I<@INC> paths. This
-automatically considers paths specified in the C<PERL5LIB> environment
-as this is included in I<@INC> by the Perl interpreter itself.
-
-=back
-
-=cut
-
-# return a hash of the POD files found
-# first argument may be a hashref (options),
-# rest is a list of directories to search recursively
-sub pod_find
-{
- my %opts;
- if(ref $_[0]) {
- %opts = %{shift()};
- }
-
- $opts{-verbose} ||= 0;
- $opts{-perl} ||= 0;
-
- my (@search) = @_;
-
- if($opts{-script}) {
- require Config;
- push(@search, $Config::Config{scriptdir})
- if -d $Config::Config{scriptdir};
- $opts{-perl} = 1;
- }
-
- if($opts{-inc}) {
- if ($^O eq 'MacOS') {
- # tolerate '.', './some_dir' and '(../)+some_dir' on Mac OS
- my @new_INC = @INC;
- for (@new_INC) {
- if ( $_ eq '.' ) {
- $_ = ':';
- } elsif ( $_ =~ s{^((?:\.\./)+)}{':' x (length($1)/3)}e ) {
- $_ = ':'. $_;
- } else {
- $_ =~ s{^\./}{:};
- }
- }
- push(@search, grep($_ ne File::Spec->curdir, @new_INC));
- } else {
- push(@search, grep($_ ne File::Spec->curdir, @INC));
- }
-
- $opts{-perl} = 1;
- }
-
- if($opts{-perl}) {
- require Config;
- # this code simplifies the POD name for Perl modules:
- # * remove "site_perl"
- # * remove e.g. "i586-linux" (from 'archname')
- # * remove e.g. 5.00503
- # * remove pod/ if followed by *.pod (e.g. in pod/perlfunc.pod)
-
- # Mac OS:
- # * remove ":?site_perl:"
- # * remove :?pod: if followed by *.pod (e.g. in :pod:perlfunc.pod)
-
- if ($^O eq 'MacOS') {
- $SIMPLIFY_RX =
- qq!^(?i:\:?site_perl\:|\:?pod\:(?=.*?\\.pod\\z))*!;
- } else {
- $SIMPLIFY_RX =
- qq!^(?i:site(_perl)?/|\Q$Config::Config{archname}\E/|\\d+\\.\\d+([_.]?\\d+)?/|pod/(?=.*?\\.pod\\z))*!;
- }
- }
-
- my %dirs_visited;
- my %pods;
- my %names;
- my $pwd = cwd();
-
- foreach my $try (@search) {
- unless(File::Spec->file_name_is_absolute($try)) {
- # make path absolute
- $try = File::Spec->catfile($pwd,$try);
- }
- # simplify path
- # on VMS canonpath will vmsify:[the.path], but File::Find::find
- # wants /unixy/paths
- $try = File::Spec->canonpath($try) if ($^O ne 'VMS');
- $try = VMS::Filespec::unixify($try) if ($^O eq 'VMS');
- my $name;
- if(-f $try) {
- if($name = _check_and_extract_name($try, $opts{-verbose})) {
- _check_for_duplicates($try, $name, \%names, \%pods);
- }
- next;
- }
- my $root_rx = $^O eq 'MacOS' ? qq!^\Q$try\E! : qq!^\Q$try\E/!;
- File::Find::find( sub {
- my $item = $File::Find::name;
- if(-d) {
- if($item =~ m{/(?:RCS|CVS|SCCS|\.svn)$}) {
- $File::Find::prune = 1;
- return;
- }
- elsif($dirs_visited{$item}) {
- warn "Directory '$item' already seen, skipping.\n"
- if($opts{-verbose});
- $File::Find::prune = 1;
- return;
- }
- else {
- $dirs_visited{$item} = 1;
- }
- if($opts{-perl} && /^(\d+\.[\d_]+)\z/s && eval "$1" != $]) {
- $File::Find::prune = 1;
- warn "Perl $] version mismatch on $_, skipping.\n"
- if($opts{-verbose});
- }
- return;
- }
- if($name = _check_and_extract_name($item, $opts{-verbose}, $root_rx)) {
- _check_for_duplicates($item, $name, \%names, \%pods);
- }
- }, $try); # end of File::Find::find
- }
- chdir $pwd;
- return %pods;
-}
-
-sub _check_for_duplicates {
- my ($file, $name, $names_ref, $pods_ref) = @_;
- if($$names_ref{$name}) {
- warn "Duplicate POD found (shadowing?): $name ($file)\n";
- warn ' Already seen in ',
- join(' ', grep($$pods_ref{$_} eq $name, keys %$pods_ref)),"\n";
- }
- else {
- $$names_ref{$name} = 1;
- }
- return $$pods_ref{$file} = $name;
-}
-
-sub _check_and_extract_name {
- my ($file, $verbose, $root_rx) = @_;
-
- # check extension or executable flag
- # this involves testing the .bat extension on Win32!
- unless(-f $file && -T $file && ($file =~ /\.(pod|pm|plx?)\z/i || -x $file )) {
- return;
- }
-
- return unless contains_pod($file,$verbose);
-
- # strip non-significant path components
- # TODO what happens on e.g. Win32?
- my $name = $file;
- if(defined $root_rx) {
- $name =~ s/$root_rx//s;
- $name =~ s/$SIMPLIFY_RX//s if(defined $SIMPLIFY_RX);
- }
- else {
- if ($^O eq 'MacOS') {
- $name =~ s/^.*://s;
- } else {
- $name =~ s{^.*/}{}s;
- }
- }
- _simplify($name);
- $name =~ s{/+}{::}g;
- if ($^O eq 'MacOS') {
- $name =~ s{:+}{::}g; # : -> ::
- } else {
- $name =~ s{/+}{::}g; # / -> ::
- }
- return $name;
-}
-
-=head2 C<simplify_name( $str )>
-
-The function B<simplify_name> is equivalent to B<basename>, but also
-strips Perl-like extensions (.pm, .pl, .pod) and extensions like
-F<.bat>, F<.cmd> on Win32 and OS/2, or F<.com> on VMS, respectively.
-
-=cut
-
-# basic simplification of the POD name:
-# basename & strip extension
-sub simplify_name {
- my ($str) = @_;
- # remove all path components
- if ($^O eq 'MacOS') {
- $str =~ s/^.*://s;
- } else {
- $str =~ s{^.*/}{}s;
- }
- _simplify($str);
- return $str;
-}
-
-# internal sub only
-sub _simplify {
- # strip Perl's own extensions
- $_[0] =~ s/\.(pod|pm|plx?)\z//i;
- # strip meaningless extensions on Win32 and OS/2
- $_[0] =~ s/\.(bat|exe|cmd)\z//i if($^O =~ /mswin|os2/i);
- # strip meaningless extensions on VMS
- $_[0] =~ s/\.(com)\z//i if($^O eq 'VMS');
-}
-
-# contribution from Tim Jenness <t.jenness@jach.hawaii.edu>
-
-=head2 C<pod_where( { %opts }, $pod )>
-
-Returns the location of a pod document given a search directory
-and a module (e.g. C<File::Find>) or script (e.g. C<perldoc>) name.
-
-Options:
-
-=over 4
-
-=item C<-inc =E<gt> 1>
-
-Search @INC for the pod and also the C<scriptdir> defined in the
-L<Config|Config> module.
-
-=item C<-dirs =E<gt> [ $dir1, $dir2, ... ]>
-
-Reference to an array of search directories. These are searched in order
-before looking in C<@INC> (if B<-inc>). Current directory is used if
-none are specified.
-
-=item C<-verbose =E<gt> 1>
-
-List directories as they are searched
-
-=back
-
-Returns the full path of the first occurrence to the file.
-Package names (eg 'A::B') are automatically converted to directory
-names in the selected directory. (eg on unix 'A::B' is converted to
-'A/B'). Additionally, '.pm', '.pl' and '.pod' are appended to the
-search automatically if required.
-
-A subdirectory F<pod/> is also checked if it exists in any of the given
-search directories. This ensures that e.g. L<perlfunc|perlfunc> is
-found.
-
-It is assumed that if a module name is supplied, that that name
-matches the file name. Pods are not opened to check for the 'NAME'
-entry.
-
-A check is made to make sure that the file that is found does
-contain some pod documentation.
-
-=cut
-
-sub pod_where {
-
- # default options
- my %options = (
- '-inc' => 0,
- '-verbose' => 0,
- '-dirs' => [ File::Spec->curdir ],
- );
-
- # Check for an options hash as first argument
- if (defined $_[0] && ref($_[0]) eq 'HASH') {
- my $opt = shift;
-
- # Merge default options with supplied options
- %options = (%options, %$opt);
- }
-
- # Check usage
- carp 'Usage: pod_where({options}, $pod)' unless (scalar(@_));
-
- # Read argument
- my $pod = shift;
-
- # Split on :: and then join the name together using File::Spec
- my @parts = split (/::/, $pod);
-
- # Get full directory list
- my @search_dirs = @{ $options{'-dirs'} };
-
- if ($options{'-inc'}) {
-
- require Config;
-
- # Add @INC
- if ($^O eq 'MacOS' && $options{'-inc'}) {
- # tolerate '.', './some_dir' and '(../)+some_dir' on Mac OS
- my @new_INC = @INC;
- for (@new_INC) {
- if ( $_ eq '.' ) {
- $_ = ':';
- } elsif ( $_ =~ s{^((?:\.\./)+)}{':' x (length($1)/3)}e ) {
- $_ = ':'. $_;
- } else {
- $_ =~ s{^\./}{:};
- }
- }
- push (@search_dirs, @new_INC);
- } elsif ($options{'-inc'}) {
- push (@search_dirs, @INC);
- }
-
- # Add location of pod documentation for perl man pages (eg perlfunc)
- # This is a pod directory in the private install tree
- #my $perlpoddir = File::Spec->catdir($Config::Config{'installprivlib'},
- # 'pod');
- #push (@search_dirs, $perlpoddir)
- # if -d $perlpoddir;
-
- # Add location of binaries such as pod2text
- push (@search_dirs, $Config::Config{'scriptdir'})
- if -d $Config::Config{'scriptdir'};
- }
-
- warn 'Search path is: '.join(' ', @search_dirs)."\n"
- if $options{'-verbose'};
-
- # Loop over directories
- Dir: foreach my $dir ( @search_dirs ) {
-
- # Don't bother if can't find the directory
- if (-d $dir) {
- warn "Looking in directory $dir\n"
- if $options{'-verbose'};
-
- # Now concatenate this directory with the pod we are searching for
- my $fullname = File::Spec->catfile($dir, @parts);
- warn "Filename is now $fullname\n"
- if $options{'-verbose'};
-
- # Loop over possible extensions
- foreach my $ext ('', '.pod', '.pm', '.pl') {
- my $fullext = $fullname . $ext;
- if (-f $fullext &&
- contains_pod($fullext, $options{'-verbose'}) ) {
- warn "FOUND: $fullext\n" if $options{'-verbose'};
- return $fullext;
- }
- }
- } else {
- warn "Directory $dir does not exist\n"
- if $options{'-verbose'};
- next Dir;
- }
- # for some strange reason the path on MacOS/darwin/cygwin is
- # 'pods' not 'pod'
- # this could be the case also for other systems that
- # have a case-tolerant file system, but File::Spec
- # does not recognize 'darwin' yet. And cygwin also has "pods",
- # but is not case tolerant. Oh well...
- if((File::Spec->case_tolerant || $^O =~ /macos|darwin|cygwin/i)
- && -d File::Spec->catdir($dir,'pods')) {
- $dir = File::Spec->catdir($dir,'pods');
- redo Dir;
- }
- if(-d File::Spec->catdir($dir,'pod')) {
- $dir = File::Spec->catdir($dir,'pod');
- redo Dir;
- }
- }
- # No match;
- return;
-}
-
-=head2 C<contains_pod( $file , $verbose )>
-
-Returns true if the supplied filename (not POD module) contains some pod
-information.
-
-=cut
-
-sub contains_pod {
- my $file = shift;
- my $verbose = 0;
- $verbose = shift if @_;
-
- # check for one line of POD
- my $podfh;
- if ($] < 5.006) {
- $podfh = gensym();
- }
-
- unless(open($podfh,"<$file")) {
- warn "Error: $file is unreadable: $!\n";
- return;
- }
-
- local $/ = undef;
- my $pod = <$podfh>;
- close($podfh) || die "Error closing $file: $!\n";
- unless($pod =~ /^=(head\d|pod|over|item|cut)\b/m) {
- warn "No POD in $file, skipping.\n"
- if($verbose);
- return 0;
- }
-
- return 1;
-}
-
-=head1 AUTHOR
-
-Please report bugs using L<http://rt.cpan.org>.
-
-Marek Rouchal E<lt>marekr@cpan.orgE<gt>,
-heavily borrowing code from Nick Ing-Simmons' PodToHtml.
-
-Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt> provided
-C<pod_where> and C<contains_pod>.
-
-=head1 SEE ALSO
-
-L<Pod::Parser>, L<Pod::Checker>, L<perldoc>
-
-=cut
-
-1;
-
diff --git a/src/lib/mrtg2/Pod/InputObjects.pm b/src/lib/mrtg2/Pod/InputObjects.pm
deleted file mode 100644
index 13a8618..0000000
--- a/src/lib/mrtg2/Pod/InputObjects.pm
+++ /dev/null
@@ -1,936 +0,0 @@
-#############################################################################
-# Pod/InputObjects.pm -- package which defines objects for input streams
-# and paragraphs and commands when parsing POD docs.
-#
-# Copyright (C) 1996-2000 by Bradford Appleton. All rights reserved.
-# This file is part of "PodParser". PodParser is free software;
-# you can redistribute it and/or modify it under the same terms
-# as Perl itself.
-#############################################################################
-
-package Pod::InputObjects;
-use strict;
-
-use vars qw($VERSION);
-$VERSION = '1.31'; ## Current version of this package
-require 5.005; ## requires this Perl version or later
-
-#############################################################################
-
-=head1 NAME
-
-Pod::InputObjects - objects representing POD input paragraphs, commands, etc.
-
-=head1 SYNOPSIS
-
- use Pod::InputObjects;
-
-=head1 REQUIRES
-
-perl5.004, Carp
-
-=head1 EXPORTS
-
-Nothing.
-
-=head1 DESCRIPTION
-
-This module defines some basic input objects used by B<Pod::Parser> when
-reading and parsing POD text from an input source. The following objects
-are defined:
-
-=over 4
-
-=begin __PRIVATE__
-
-=item package B<Pod::InputSource>
-
-An object corresponding to a source of POD input text. It is mostly a
-wrapper around a filehandle or C<IO::Handle>-type object (or anything
-that implements the C<getline()> method) which keeps track of some
-additional information relevant to the parsing of PODs.
-
-=end __PRIVATE__
-
-=item package B<Pod::Paragraph>
-
-An object corresponding to a paragraph of POD input text. It may be a
-plain paragraph, a verbatim paragraph, or a command paragraph (see
-L<perlpod>).
-
-=item package B<Pod::InteriorSequence>
-
-An object corresponding to an interior sequence command from the POD
-input text (see L<perlpod>).
-
-=item package B<Pod::ParseTree>
-
-An object corresponding to a tree of parsed POD text. Each "node" in
-a parse-tree (or I<ptree>) is either a text-string or a reference to
-a B<Pod::InteriorSequence> object. The nodes appear in the parse-tree
-in the order in which they were parsed from left-to-right.
-
-=back
-
-Each of these input objects are described in further detail in the
-sections which follow.
-
-=cut
-
-#############################################################################
-
-package Pod::InputSource;
-
-##---------------------------------------------------------------------------
-
-=begin __PRIVATE__
-
-=head1 B<Pod::InputSource>
-
-This object corresponds to an input source or stream of POD
-documentation. When parsing PODs, it is necessary to associate and store
-certain context information with each input source. All of this
-information is kept together with the stream itself in one of these
-C<Pod::InputSource> objects. Each such object is merely a wrapper around
-an C<IO::Handle> object of some kind (or at least something that
-implements the C<getline()> method). They have the following
-methods/attributes:
-
-=end __PRIVATE__
-
-=cut
-
-##---------------------------------------------------------------------------
-
-=begin __PRIVATE__
-
-=head2 B<new()>
-
- my $pod_input1 = Pod::InputSource->new(-handle => $filehandle);
- my $pod_input2 = new Pod::InputSource(-handle => $filehandle,
- -name => $name);
- my $pod_input3 = new Pod::InputSource(-handle => \*STDIN);
- my $pod_input4 = Pod::InputSource->new(-handle => \*STDIN,
- -name => "(STDIN)");
-
-This is a class method that constructs a C<Pod::InputSource> object and
-returns a reference to the new input source object. It takes one or more
-keyword arguments in the form of a hash. The keyword C<-handle> is
-required and designates the corresponding input handle. The keyword
-C<-name> is optional and specifies the name associated with the input
-handle (typically a file name).
-
-=end __PRIVATE__
-
-=cut
-
-sub new {
- ## Determine if we were called via an object-ref or a classname
- my $this = shift;
- my $class = ref($this) || $this;
-
- ## Any remaining arguments are treated as initial values for the
- ## hash that is used to represent this object. Note that we default
- ## certain values by specifying them *before* the arguments passed.
- ## If they are in the argument list, they will override the defaults.
- my $self = { -name => '(unknown)',
- -handle => undef,
- -was_cutting => 0,
- @_ };
-
- ## Bless ourselves into the desired class and perform any initialization
- bless $self, $class;
- return $self;
-}
-
-##---------------------------------------------------------------------------
-
-=begin __PRIVATE__
-
-=head2 B<name()>
-
- my $filename = $pod_input->name();
- $pod_input->name($new_filename_to_use);
-
-This method gets/sets the name of the input source (usually a filename).
-If no argument is given, it returns a string containing the name of
-the input source; otherwise it sets the name of the input source to the
-contents of the given argument.
-
-=end __PRIVATE__
-
-=cut
-
-sub name {
- (@_ > 1) and $_[0]->{'-name'} = $_[1];
- return $_[0]->{'-name'};
-}
-
-## allow 'filename' as an alias for 'name'
-*filename = \&name;
-
-##---------------------------------------------------------------------------
-
-=begin __PRIVATE__
-
-=head2 B<handle()>
-
- my $handle = $pod_input->handle();
-
-Returns a reference to the handle object from which input is read (the
-one used to contructed this input source object).
-
-=end __PRIVATE__
-
-=cut
-
-sub handle {
- return $_[0]->{'-handle'};
-}
-
-##---------------------------------------------------------------------------
-
-=begin __PRIVATE__
-
-=head2 B<was_cutting()>
-
- print "Yes.\n" if ($pod_input->was_cutting());
-
-The value of the C<cutting> state (that the B<cutting()> method would
-have returned) immediately before any input was read from this input
-stream. After all input from this stream has been read, the C<cutting>
-state is restored to this value.
-
-=end __PRIVATE__
-
-=cut
-
-sub was_cutting {
- (@_ > 1) and $_[0]->{-was_cutting} = $_[1];
- return $_[0]->{-was_cutting};
-}
-
-##---------------------------------------------------------------------------
-
-#############################################################################
-
-package Pod::Paragraph;
-
-##---------------------------------------------------------------------------
-
-=head1 B<Pod::Paragraph>
-
-An object representing a paragraph of POD input text.
-It has the following methods/attributes:
-
-=cut
-
-##---------------------------------------------------------------------------
-
-=head2 Pod::Paragraph-E<gt>B<new()>
-
- my $pod_para1 = Pod::Paragraph->new(-text => $text);
- my $pod_para2 = Pod::Paragraph->new(-name => $cmd,
- -text => $text);
- my $pod_para3 = new Pod::Paragraph(-text => $text);
- my $pod_para4 = new Pod::Paragraph(-name => $cmd,
- -text => $text);
- my $pod_para5 = Pod::Paragraph->new(-name => $cmd,
- -text => $text,
- -file => $filename,
- -line => $line_number);
-
-This is a class method that constructs a C<Pod::Paragraph> object and
-returns a reference to the new paragraph object. It may be given one or
-two keyword arguments. The C<-text> keyword indicates the corresponding
-text of the POD paragraph. The C<-name> keyword indicates the name of
-the corresponding POD command, such as C<head1> or C<item> (it should
-I<not> contain the C<=> prefix); this is needed only if the POD
-paragraph corresponds to a command paragraph. The C<-file> and C<-line>
-keywords indicate the filename and line number corresponding to the
-beginning of the paragraph
-
-=cut
-
-sub new {
- ## Determine if we were called via an object-ref or a classname
- my $this = shift;
- my $class = ref($this) || $this;
-
- ## Any remaining arguments are treated as initial values for the
- ## hash that is used to represent this object. Note that we default
- ## certain values by specifying them *before* the arguments passed.
- ## If they are in the argument list, they will override the defaults.
- my $self = {
- -name => undef,
- -text => (@_ == 1) ? shift : undef,
- -file => '<unknown-file>',
- -line => 0,
- -prefix => '=',
- -separator => ' ',
- -ptree => [],
- @_
- };
-
- ## Bless ourselves into the desired class and perform any initialization
- bless $self, $class;
- return $self;
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_para-E<gt>B<cmd_name()>
-
- my $para_cmd = $pod_para->cmd_name();
-
-If this paragraph is a command paragraph, then this method will return
-the name of the command (I<without> any leading C<=> prefix).
-
-=cut
-
-sub cmd_name {
- (@_ > 1) and $_[0]->{'-name'} = $_[1];
- return $_[0]->{'-name'};
-}
-
-## let name() be an alias for cmd_name()
-*name = \&cmd_name;
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_para-E<gt>B<text()>
-
- my $para_text = $pod_para->text();
-
-This method will return the corresponding text of the paragraph.
-
-=cut
-
-sub text {
- (@_ > 1) and $_[0]->{'-text'} = $_[1];
- return $_[0]->{'-text'};
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_para-E<gt>B<raw_text()>
-
- my $raw_pod_para = $pod_para->raw_text();
-
-This method will return the I<raw> text of the POD paragraph, exactly
-as it appeared in the input.
-
-=cut
-
-sub raw_text {
- return $_[0]->{'-text'} unless (defined $_[0]->{'-name'});
- return $_[0]->{'-prefix'} . $_[0]->{'-name'} .
- $_[0]->{'-separator'} . $_[0]->{'-text'};
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_para-E<gt>B<cmd_prefix()>
-
- my $prefix = $pod_para->cmd_prefix();
-
-If this paragraph is a command paragraph, then this method will return
-the prefix used to denote the command (which should be the string "="
-or "==").
-
-=cut
-
-sub cmd_prefix {
- return $_[0]->{'-prefix'};
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_para-E<gt>B<cmd_separator()>
-
- my $separator = $pod_para->cmd_separator();
-
-If this paragraph is a command paragraph, then this method will return
-the text used to separate the command name from the rest of the
-paragraph (if any).
-
-=cut
-
-sub cmd_separator {
- return $_[0]->{'-separator'};
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_para-E<gt>B<parse_tree()>
-
- my $ptree = $pod_parser->parse_text( $pod_para->text() );
- $pod_para->parse_tree( $ptree );
- $ptree = $pod_para->parse_tree();
-
-This method will get/set the corresponding parse-tree of the paragraph's text.
-
-=cut
-
-sub parse_tree {
- (@_ > 1) and $_[0]->{'-ptree'} = $_[1];
- return $_[0]->{'-ptree'};
-}
-
-## let ptree() be an alias for parse_tree()
-*ptree = \&parse_tree;
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_para-E<gt>B<file_line()>
-
- my ($filename, $line_number) = $pod_para->file_line();
- my $position = $pod_para->file_line();
-
-Returns the current filename and line number for the paragraph
-object. If called in a list context, it returns a list of two
-elements: first the filename, then the line number. If called in
-a scalar context, it returns a string containing the filename, followed
-by a colon (':'), followed by the line number.
-
-=cut
-
-sub file_line {
- my @loc = ($_[0]->{'-file'} || '<unknown-file>',
- $_[0]->{'-line'} || 0);
- return (wantarray) ? @loc : join(':', @loc);
-}
-
-##---------------------------------------------------------------------------
-
-#############################################################################
-
-package Pod::InteriorSequence;
-
-##---------------------------------------------------------------------------
-
-=head1 B<Pod::InteriorSequence>
-
-An object representing a POD interior sequence command.
-It has the following methods/attributes:
-
-=cut
-
-##---------------------------------------------------------------------------
-
-=head2 Pod::InteriorSequence-E<gt>B<new()>
-
- my $pod_seq1 = Pod::InteriorSequence->new(-name => $cmd
- -ldelim => $delimiter);
- my $pod_seq2 = new Pod::InteriorSequence(-name => $cmd,
- -ldelim => $delimiter);
- my $pod_seq3 = new Pod::InteriorSequence(-name => $cmd,
- -ldelim => $delimiter,
- -file => $filename,
- -line => $line_number);
-
- my $pod_seq4 = new Pod::InteriorSequence(-name => $cmd, $ptree);
- my $pod_seq5 = new Pod::InteriorSequence($cmd, $ptree);
-
-This is a class method that constructs a C<Pod::InteriorSequence> object
-and returns a reference to the new interior sequence object. It should
-be given two keyword arguments. The C<-ldelim> keyword indicates the
-corresponding left-delimiter of the interior sequence (e.g. 'E<lt>').
-The C<-name> keyword indicates the name of the corresponding interior
-sequence command, such as C<I> or C<B> or C<C>. The C<-file> and
-C<-line> keywords indicate the filename and line number corresponding
-to the beginning of the interior sequence. If the C<$ptree> argument is
-given, it must be the last argument, and it must be either string, or
-else an array-ref suitable for passing to B<Pod::ParseTree::new> (or
-it may be a reference to a Pod::ParseTree object).
-
-=cut
-
-sub new {
- ## Determine if we were called via an object-ref or a classname
- my $this = shift;
- my $class = ref($this) || $this;
-
- ## See if first argument has no keyword
- if (((@_ <= 2) or (@_ % 2)) and $_[0] !~ /^-\w/) {
- ## Yup - need an implicit '-name' before first parameter
- unshift @_, '-name';
- }
-
- ## See if odd number of args
- if ((@_ % 2) != 0) {
- ## Yup - need an implicit '-ptree' before the last parameter
- splice @_, $#_, 0, '-ptree';
- }
-
- ## Any remaining arguments are treated as initial values for the
- ## hash that is used to represent this object. Note that we default
- ## certain values by specifying them *before* the arguments passed.
- ## If they are in the argument list, they will override the defaults.
- my $self = {
- -name => (@_ == 1) ? $_[0] : undef,
- -file => '<unknown-file>',
- -line => 0,
- -ldelim => '<',
- -rdelim => '>',
- @_
- };
-
- ## Initialize contents if they havent been already
- my $ptree = $self->{'-ptree'} || new Pod::ParseTree();
- if ( ref $ptree =~ /^(ARRAY)?$/ ) {
- ## We have an array-ref, or a normal scalar. Pass it as an
- ## an argument to the ptree-constructor
- $ptree = new Pod::ParseTree($1 ? [$ptree] : $ptree);
- }
- $self->{'-ptree'} = $ptree;
-
- ## Bless ourselves into the desired class and perform any initialization
- bless $self, $class;
- return $self;
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_seq-E<gt>B<cmd_name()>
-
- my $seq_cmd = $pod_seq->cmd_name();
-
-The name of the interior sequence command.
-
-=cut
-
-sub cmd_name {
- (@_ > 1) and $_[0]->{'-name'} = $_[1];
- return $_[0]->{'-name'};
-}
-
-## let name() be an alias for cmd_name()
-*name = \&cmd_name;
-
-##---------------------------------------------------------------------------
-
-## Private subroutine to set the parent pointer of all the given
-## children that are interior-sequences to be $self
-
-sub _set_child2parent_links {
- my ($self, @children) = @_;
- ## Make sure any sequences know who their parent is
- for (@children) {
- next unless (length and ref and ref ne 'SCALAR');
- if (UNIVERSAL::isa($_, 'Pod::InteriorSequence') or
- UNIVERSAL::can($_, 'nested'))
- {
- $_->nested($self);
- }
- }
-}
-
-## Private subroutine to unset child->parent links
-
-sub _unset_child2parent_links {
- my $self = shift;
- $self->{'-parent_sequence'} = undef;
- my $ptree = $self->{'-ptree'};
- for (@$ptree) {
- next unless (length and ref and ref ne 'SCALAR');
- $_->_unset_child2parent_links()
- if UNIVERSAL::isa($_, 'Pod::InteriorSequence');
- }
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_seq-E<gt>B<prepend()>
-
- $pod_seq->prepend($text);
- $pod_seq1->prepend($pod_seq2);
-
-Prepends the given string or parse-tree or sequence object to the parse-tree
-of this interior sequence.
-
-=cut
-
-sub prepend {
- my $self = shift;
- $self->{'-ptree'}->prepend(@_);
- _set_child2parent_links($self, @_);
- return $self;
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_seq-E<gt>B<append()>
-
- $pod_seq->append($text);
- $pod_seq1->append($pod_seq2);
-
-Appends the given string or parse-tree or sequence object to the parse-tree
-of this interior sequence.
-
-=cut
-
-sub append {
- my $self = shift;
- $self->{'-ptree'}->append(@_);
- _set_child2parent_links($self, @_);
- return $self;
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_seq-E<gt>B<nested()>
-
- $outer_seq = $pod_seq->nested || print "not nested";
-
-If this interior sequence is nested inside of another interior
-sequence, then the outer/parent sequence that contains it is
-returned. Otherwise C<undef> is returned.
-
-=cut
-
-sub nested {
- my $self = shift;
- (@_ == 1) and $self->{'-parent_sequence'} = shift;
- return $self->{'-parent_sequence'} || undef;
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_seq-E<gt>B<raw_text()>
-
- my $seq_raw_text = $pod_seq->raw_text();
-
-This method will return the I<raw> text of the POD interior sequence,
-exactly as it appeared in the input.
-
-=cut
-
-sub raw_text {
- my $self = shift;
- my $text = $self->{'-name'} . $self->{'-ldelim'};
- for ( $self->{'-ptree'}->children ) {
- $text .= (ref $_) ? $_->raw_text : $_;
- }
- $text .= $self->{'-rdelim'};
- return $text;
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_seq-E<gt>B<left_delimiter()>
-
- my $ldelim = $pod_seq->left_delimiter();
-
-The leftmost delimiter beginning the argument text to the interior
-sequence (should be "<").
-
-=cut
-
-sub left_delimiter {
- (@_ > 1) and $_[0]->{'-ldelim'} = $_[1];
- return $_[0]->{'-ldelim'};
-}
-
-## let ldelim() be an alias for left_delimiter()
-*ldelim = \&left_delimiter;
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_seq-E<gt>B<right_delimiter()>
-
-The rightmost delimiter beginning the argument text to the interior
-sequence (should be ">").
-
-=cut
-
-sub right_delimiter {
- (@_ > 1) and $_[0]->{'-rdelim'} = $_[1];
- return $_[0]->{'-rdelim'};
-}
-
-## let rdelim() be an alias for right_delimiter()
-*rdelim = \&right_delimiter;
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_seq-E<gt>B<parse_tree()>
-
- my $ptree = $pod_parser->parse_text($paragraph_text);
- $pod_seq->parse_tree( $ptree );
- $ptree = $pod_seq->parse_tree();
-
-This method will get/set the corresponding parse-tree of the interior
-sequence's text.
-
-=cut
-
-sub parse_tree {
- (@_ > 1) and $_[0]->{'-ptree'} = $_[1];
- return $_[0]->{'-ptree'};
-}
-
-## let ptree() be an alias for parse_tree()
-*ptree = \&parse_tree;
-
-##---------------------------------------------------------------------------
-
-=head2 $pod_seq-E<gt>B<file_line()>
-
- my ($filename, $line_number) = $pod_seq->file_line();
- my $position = $pod_seq->file_line();
-
-Returns the current filename and line number for the interior sequence
-object. If called in a list context, it returns a list of two
-elements: first the filename, then the line number. If called in
-a scalar context, it returns a string containing the filename, followed
-by a colon (':'), followed by the line number.
-
-=cut
-
-sub file_line {
- my @loc = ($_[0]->{'-file'} || '<unknown-file>',
- $_[0]->{'-line'} || 0);
- return (wantarray) ? @loc : join(':', @loc);
-}
-
-##---------------------------------------------------------------------------
-
-=head2 Pod::InteriorSequence::B<DESTROY()>
-
-This method performs any necessary cleanup for the interior-sequence.
-If you override this method then it is B<imperative> that you invoke
-the parent method from within your own method, otherwise
-I<interior-sequence storage will not be reclaimed upon destruction!>
-
-=cut
-
-sub DESTROY {
- ## We need to get rid of all child->parent pointers throughout the
- ## tree so their reference counts will go to zero and they can be
- ## garbage-collected
- _unset_child2parent_links(@_);
-}
-
-##---------------------------------------------------------------------------
-
-#############################################################################
-
-package Pod::ParseTree;
-
-##---------------------------------------------------------------------------
-
-=head1 B<Pod::ParseTree>
-
-This object corresponds to a tree of parsed POD text. As POD text is
-scanned from left to right, it is parsed into an ordered list of
-text-strings and B<Pod::InteriorSequence> objects (in order of
-appearance). A B<Pod::ParseTree> object corresponds to this list of
-strings and sequences. Each interior sequence in the parse-tree may
-itself contain a parse-tree (since interior sequences may be nested).
-
-=cut
-
-##---------------------------------------------------------------------------
-
-=head2 Pod::ParseTree-E<gt>B<new()>
-
- my $ptree1 = Pod::ParseTree->new;
- my $ptree2 = new Pod::ParseTree;
- my $ptree4 = Pod::ParseTree->new($array_ref);
- my $ptree3 = new Pod::ParseTree($array_ref);
-
-This is a class method that constructs a C<Pod::Parse_tree> object and
-returns a reference to the new parse-tree. If a single-argument is given,
-it must be a reference to an array, and is used to initialize the root
-(top) of the parse tree.
-
-=cut
-
-sub new {
- ## Determine if we were called via an object-ref or a classname
- my $this = shift;
- my $class = ref($this) || $this;
-
- my $self = (@_ == 1 and ref $_[0]) ? $_[0] : [];
-
- ## Bless ourselves into the desired class and perform any initialization
- bless $self, $class;
- return $self;
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $ptree-E<gt>B<top()>
-
- my $top_node = $ptree->top();
- $ptree->top( $top_node );
- $ptree->top( @children );
-
-This method gets/sets the top node of the parse-tree. If no arguments are
-given, it returns the topmost node in the tree (the root), which is also
-a B<Pod::ParseTree>. If it is given a single argument that is a reference,
-then the reference is assumed to a parse-tree and becomes the new top node.
-Otherwise, if arguments are given, they are treated as the new list of
-children for the top node.
-
-=cut
-
-sub top {
- my $self = shift;
- if (@_ > 0) {
- @{ $self } = (@_ == 1 and ref $_[0]) ? ${ @_ } : @_;
- }
- return $self;
-}
-
-## let parse_tree() & ptree() be aliases for the 'top' method
-*parse_tree = *ptree = \&top;
-
-##---------------------------------------------------------------------------
-
-=head2 $ptree-E<gt>B<children()>
-
-This method gets/sets the children of the top node in the parse-tree.
-If no arguments are given, it returns the list (array) of children
-(each of which should be either a string or a B<Pod::InteriorSequence>.
-Otherwise, if arguments are given, they are treated as the new list of
-children for the top node.
-
-=cut
-
-sub children {
- my $self = shift;
- if (@_ > 0) {
- @{ $self } = (@_ == 1 and ref $_[0]) ? ${ @_ } : @_;
- }
- return @{ $self };
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $ptree-E<gt>B<prepend()>
-
-This method prepends the given text or parse-tree to the current parse-tree.
-If the first item on the parse-tree is text and the argument is also text,
-then the text is prepended to the first item (not added as a separate string).
-Otherwise the argument is added as a new string or parse-tree I<before>
-the current one.
-
-=cut
-
-use vars qw(@ptree); ## an alias used for performance reasons
-
-sub prepend {
- my $self = shift;
- local *ptree = $self;
- for (@_) {
- next unless length;
- if (@ptree && !(ref $ptree[0]) && !(ref $_)) {
- $ptree[0] = $_ . $ptree[0];
- }
- else {
- unshift @ptree, $_;
- }
- }
-}
-
-##---------------------------------------------------------------------------
-
-=head2 $ptree-E<gt>B<append()>
-
-This method appends the given text or parse-tree to the current parse-tree.
-If the last item on the parse-tree is text and the argument is also text,
-then the text is appended to the last item (not added as a separate string).
-Otherwise the argument is added as a new string or parse-tree I<after>
-the current one.
-
-=cut
-
-sub append {
- my $self = shift;
- local *ptree = $self;
- my $can_append = @ptree && !(ref $ptree[-1]);
- for (@_) {
- if (ref) {
- push @ptree, $_;
- }
- elsif(!length) {
- next;
- }
- elsif ($can_append) {
- $ptree[-1] .= $_;
- }
- else {
- push @ptree, $_;
- }
- }
-}
-
-=head2 $ptree-E<gt>B<raw_text()>
-
- my $ptree_raw_text = $ptree->raw_text();
-
-This method will return the I<raw> text of the POD parse-tree
-exactly as it appeared in the input.
-
-=cut
-
-sub raw_text {
- my $self = shift;
- my $text = '';
- for ( @$self ) {
- $text .= (ref $_) ? $_->raw_text : $_;
- }
- return $text;
-}
-
-##---------------------------------------------------------------------------
-
-## Private routines to set/unset child->parent links
-
-sub _unset_child2parent_links {
- my $self = shift;
- local *ptree = $self;
- for (@ptree) {
- next unless (defined and length and ref and ref ne 'SCALAR');
- $_->_unset_child2parent_links()
- if UNIVERSAL::isa($_, 'Pod::InteriorSequence');
- }
-}
-
-sub _set_child2parent_links {
- ## nothing to do, Pod::ParseTrees cant have parent pointers
-}
-
-=head2 Pod::ParseTree::B<DESTROY()>
-
-This method performs any necessary cleanup for the parse-tree.
-If you override this method then it is B<imperative>
-that you invoke the parent method from within your own method,
-otherwise I<parse-tree storage will not be reclaimed upon destruction!>
-
-=cut
-
-sub DESTROY {
- ## We need to get rid of all child->parent pointers throughout the
- ## tree so their reference counts will go to zero and they can be
- ## garbage-collected
- _unset_child2parent_links(@_);
-}
-
-#############################################################################
-
-=head1 SEE ALSO
-
-See L<Pod::Parser>, L<Pod::Select>
-
-=head1 AUTHOR
-
-Please report bugs using L<http://rt.cpan.org>.
-
-Brad Appleton E<lt>bradapp@enteract.comE<gt>
-
-=cut
-
-1;
diff --git a/src/lib/mrtg2/Pod/ParseUtils.pm b/src/lib/mrtg2/Pod/ParseUtils.pm
deleted file mode 100644
index f3c7ef4..0000000
--- a/src/lib/mrtg2/Pod/ParseUtils.pm
+++ /dev/null
@@ -1,855 +0,0 @@
-#############################################################################
-# Pod/ParseUtils.pm -- helpers for POD parsing and conversion
-#
-# Copyright (C) 1999-2000 by Marek Rouchal. All rights reserved.
-# This file is part of "PodParser". PodParser is free software;
-# you can redistribute it and/or modify it under the same terms
-# as Perl itself.
-#############################################################################
-
-package Pod::ParseUtils;
-use strict;
-
-use vars qw($VERSION);
-$VERSION = '1.36'; ## Current version of this package
-require 5.005; ## requires this Perl version or later
-
-=head1 NAME
-
-Pod::ParseUtils - helpers for POD parsing and conversion
-
-=head1 SYNOPSIS
-
- use Pod::ParseUtils;
-
- my $list = new Pod::List;
- my $link = Pod::Hyperlink->new('Pod::Parser');
-
-=head1 DESCRIPTION
-
-B<Pod::ParseUtils> contains a few object-oriented helper packages for
-POD parsing and processing (i.e. in POD formatters and translators).
-
-=cut
-
-#-----------------------------------------------------------------------------
-# Pod::List
-#
-# class to hold POD list info (=over, =item, =back)
-#-----------------------------------------------------------------------------
-
-package Pod::List;
-
-use Carp;
-
-=head2 Pod::List
-
-B<Pod::List> can be used to hold information about POD lists
-(written as =over ... =item ... =back) for further processing.
-The following methods are available:
-
-=over 4
-
-=item Pod::List-E<gt>new()
-
-Create a new list object. Properties may be specified through a hash
-reference like this:
-
- my $list = Pod::List->new({ -start => $., -indent => 4 });
-
-See the individual methods/properties for details.
-
-=cut
-
-sub new {
- my $this = shift;
- my $class = ref($this) || $this;
- my %params = @_;
- my $self = {%params};
- bless $self, $class;
- $self->initialize();
- return $self;
-}
-
-sub initialize {
- my $self = shift;
- $self->{-file} ||= 'unknown';
- $self->{-start} ||= 'unknown';
- $self->{-indent} ||= 4; # perlpod: "should be the default"
- $self->{_items} = [];
- $self->{-type} ||= '';
-}
-
-=item $list-E<gt>file()
-
-Without argument, retrieves the file name the list is in. This must
-have been set before by either specifying B<-file> in the B<new()>
-method or by calling the B<file()> method with a scalar argument.
-
-=cut
-
-# The POD file name the list appears in
-sub file {
- return (@_ > 1) ? ($_[0]->{-file} = $_[1]) : $_[0]->{-file};
-}
-
-=item $list-E<gt>start()
-
-Without argument, retrieves the line number where the list started.
-This must have been set before by either specifying B<-start> in the
-B<new()> method or by calling the B<start()> method with a scalar
-argument.
-
-=cut
-
-# The line in the file the node appears
-sub start {
- return (@_ > 1) ? ($_[0]->{-start} = $_[1]) : $_[0]->{-start};
-}
-
-=item $list-E<gt>indent()
-
-Without argument, retrieves the indent level of the list as specified
-in C<=over n>. This must have been set before by either specifying
-B<-indent> in the B<new()> method or by calling the B<indent()> method
-with a scalar argument.
-
-=cut
-
-# indent level
-sub indent {
- return (@_ > 1) ? ($_[0]->{-indent} = $_[1]) : $_[0]->{-indent};
-}
-
-=item $list-E<gt>type()
-
-Without argument, retrieves the list type, which can be an arbitrary value,
-e.g. C<OL>, C<UL>, ... when thinking the HTML way.
-This must have been set before by either specifying
-B<-type> in the B<new()> method or by calling the B<type()> method
-with a scalar argument.
-
-=cut
-
-# The type of the list (UL, OL, ...)
-sub type {
- return (@_ > 1) ? ($_[0]->{-type} = $_[1]) : $_[0]->{-type};
-}
-
-=item $list-E<gt>rx()
-
-Without argument, retrieves a regular expression for simplifying the
-individual item strings once the list type has been determined. Usage:
-E.g. when converting to HTML, one might strip the leading number in
-an ordered list as C<E<lt>OLE<gt>> already prints numbers itself.
-This must have been set before by either specifying
-B<-rx> in the B<new()> method or by calling the B<rx()> method
-with a scalar argument.
-
-=cut
-
-# The regular expression to simplify the items
-sub rx {
- return (@_ > 1) ? ($_[0]->{-rx} = $_[1]) : $_[0]->{-rx};
-}
-
-=item $list-E<gt>item()
-
-Without argument, retrieves the array of the items in this list.
-The items may be represented by any scalar.
-If an argument has been given, it is pushed on the list of items.
-
-=cut
-
-# The individual =items of this list
-sub item {
- my ($self,$item) = @_;
- if(defined $item) {
- push(@{$self->{_items}}, $item);
- return $item;
- }
- else {
- return @{$self->{_items}};
- }
-}
-
-=item $list-E<gt>parent()
-
-Without argument, retrieves information about the parent holding this
-list, which is represented as an arbitrary scalar.
-This must have been set before by either specifying
-B<-parent> in the B<new()> method or by calling the B<parent()> method
-with a scalar argument.
-
-=cut
-
-# possibility for parsers/translators to store information about the
-# lists's parent object
-sub parent {
- return (@_ > 1) ? ($_[0]->{-parent} = $_[1]) : $_[0]->{-parent};
-}
-
-=item $list-E<gt>tag()
-
-Without argument, retrieves information about the list tag, which can be
-any scalar.
-This must have been set before by either specifying
-B<-tag> in the B<new()> method or by calling the B<tag()> method
-with a scalar argument.
-
-=back
-
-=cut
-
-# possibility for parsers/translators to store information about the
-# list's object
-sub tag {
- return (@_ > 1) ? ($_[0]->{-tag} = $_[1]) : $_[0]->{-tag};
-}
-
-#-----------------------------------------------------------------------------
-# Pod::Hyperlink
-#
-# class to manipulate POD hyperlinks (L<>)
-#-----------------------------------------------------------------------------
-
-package Pod::Hyperlink;
-
-=head2 Pod::Hyperlink
-
-B<Pod::Hyperlink> is a class for manipulation of POD hyperlinks. Usage:
-
- my $link = Pod::Hyperlink->new('alternative text|page/"section in page"');
-
-The B<Pod::Hyperlink> class is mainly designed to parse the contents of the
-C<LE<lt>...E<gt>> sequence, providing a simple interface for accessing the
-different parts of a POD hyperlink for further processing. It can also be
-used to construct hyperlinks.
-
-=over 4
-
-=item Pod::Hyperlink-E<gt>new()
-
-The B<new()> method can either be passed a set of key/value pairs or a single
-scalar value, namely the contents of a C<LE<lt>...E<gt>> sequence. An object
-of the class C<Pod::Hyperlink> is returned. The value C<undef> indicates a
-failure, the error message is stored in C<$@>.
-
-=cut
-
-use Carp;
-
-sub new {
- my $this = shift;
- my $class = ref($this) || $this;
- my $self = +{};
- bless $self, $class;
- $self->initialize();
- if(defined $_[0]) {
- if(ref($_[0])) {
- # called with a list of parameters
- %$self = %{$_[0]};
- $self->_construct_text();
- }
- else {
- # called with L<> contents
- return unless($self->parse($_[0]));
- }
- }
- return $self;
-}
-
-sub initialize {
- my $self = shift;
- $self->{-line} ||= 'undef';
- $self->{-file} ||= 'undef';
- $self->{-page} ||= '';
- $self->{-node} ||= '';
- $self->{-alttext} ||= '';
- $self->{-type} ||= 'undef';
- $self->{_warnings} = [];
-}
-
-=item $link-E<gt>parse($string)
-
-This method can be used to (re)parse a (new) hyperlink, i.e. the contents
-of a C<LE<lt>...E<gt>> sequence. The result is stored in the current object.
-Warnings are stored in the B<warnings> property.
-E.g. sections like C<LE<lt>open(2)E<gt>> are deprecated, as they do not point
-to Perl documents. C<LE<lt>DBI::foo(3p)E<gt>> is wrong as well, the manpage
-section can simply be dropped.
-
-=cut
-
-sub parse {
- my $self = shift;
- local($_) = $_[0];
- # syntax check the link and extract destination
- my ($alttext,$page,$node,$type,$quoted) = (undef,'','','',0);
-
- $self->{_warnings} = [];
-
- # collapse newlines with whitespace
- s/\s*\n+\s*/ /g;
-
- # strip leading/trailing whitespace
- if(s/^[\s\n]+//) {
- $self->warning('ignoring leading whitespace in link');
- }
- if(s/[\s\n]+$//) {
- $self->warning('ignoring trailing whitespace in link');
- }
- unless(length($_)) {
- _invalid_link('empty link');
- return;
- }
-
- ## Check for different possibilities. This is tedious and error-prone
- # we match all possibilities (alttext, page, section/item)
- #warn "DEBUG: link=$_\n";
-
- # only page
- # problem: a lot of people use (), or (1) or the like to indicate
- # man page sections. But this collides with L<func()> that is supposed
- # to point to an internal funtion...
- my $page_rx = '[\w.-]+(?:::[\w.-]+)*(?:[(](?:\d\w*|)[)]|)';
- # page name only
- if(/^($page_rx)$/o) {
- $page = $1;
- $type = 'page';
- }
- # alttext, page and "section"
- elsif(m{^(.*?)\s*[|]\s*($page_rx)\s*/\s*"(.+)"$}o) {
- ($alttext, $page, $node) = ($1, $2, $3);
- $type = 'section';
- $quoted = 1; #... therefore | and / are allowed
- }
- # alttext and page
- elsif(/^(.*?)\s*[|]\s*($page_rx)$/o) {
- ($alttext, $page) = ($1, $2);
- $type = 'page';
- }
- # alttext and "section"
- elsif(m{^(.*?)\s*[|]\s*(?:/\s*|)"(.+)"$}) {
- ($alttext, $node) = ($1,$2);
- $type = 'section';
- $quoted = 1;
- }
- # page and "section"
- elsif(m{^($page_rx)\s*/\s*"(.+)"$}o) {
- ($page, $node) = ($1, $2);
- $type = 'section';
- $quoted = 1;
- }
- # page and item
- elsif(m{^($page_rx)\s*/\s*(.+)$}o) {
- ($page, $node) = ($1, $2);
- $type = 'item';
- }
- # only "section"
- elsif(m{^/?"(.+)"$}) {
- $node = $1;
- $type = 'section';
- $quoted = 1;
- }
- # only item
- elsif(m{^\s*/(.+)$}) {
- $node = $1;
- $type = 'item';
- }
-
- # non-standard: Hyperlink with alt-text - doesn't remove protocol prefix, maybe it should?
- elsif(/^ \s* (.*?) \s* [|] \s* (\w+:[^:\s] [^\s|]*?) \s* $/ix) {
- ($alttext,$node) = ($1,$2);
- $type = 'hyperlink';
- }
-
- # non-standard: Hyperlink
- elsif(/^(\w+:[^:\s]\S*)$/i) {
- $node = $1;
- $type = 'hyperlink';
- }
- # alttext, page and item
- elsif(m{^(.*?)\s*[|]\s*($page_rx)\s*/\s*(.+)$}o) {
- ($alttext, $page, $node) = ($1, $2, $3);
- $type = 'item';
- }
- # alttext and item
- elsif(m{^(.*?)\s*[|]\s*/(.+)$}) {
- ($alttext, $node) = ($1,$2);
- }
- # must be an item or a "malformed" section (without "")
- else {
- $node = $_;
- $type = 'item';
- }
- # collapse whitespace in nodes
- $node =~ s/\s+/ /gs;
-
- # empty alternative text expands to node name
- if(defined $alttext) {
- if(!length($alttext)) {
- $alttext = $node || $page;
- }
- }
- else {
- $alttext = '';
- }
-
- if($page =~ /[(]\w*[)]$/) {
- $self->warning("(section) in '$page' deprecated");
- }
- if(!$quoted && $node =~ m{[|/]} && $type ne 'hyperlink') {
- $self->warning("node '$node' contains non-escaped | or /");
- }
- if($alttext =~ m{[|/]}) {
- $self->warning("alternative text '$node' contains non-escaped | or /");
- }
- $self->{-page} = $page;
- $self->{-node} = $node;
- $self->{-alttext} = $alttext;
- #warn "DEBUG: page=$page section=$section item=$item alttext=$alttext\n";
- $self->{-type} = $type;
- $self->_construct_text();
- 1;
-}
-
-sub _construct_text {
- my $self = shift;
- my $alttext = $self->alttext();
- my $type = $self->type();
- my $section = $self->node();
- my $page = $self->page();
- my $page_ext = '';
- $page =~ s/([(]\w*[)])$// && ($page_ext = $1);
- if($alttext) {
- $self->{_text} = $alttext;
- }
- elsif($type eq 'hyperlink') {
- $self->{_text} = $section;
- }
- else {
- $self->{_text} = ($section || '') .
- (($page && $section) ? ' in ' : '') .
- "$page$page_ext";
- }
- # for being marked up later
- # use the non-standard markers P<> and Q<>, so that the resulting
- # text can be parsed by the translators. It's their job to put
- # the correct hypertext around the linktext
- if($alttext) {
- $self->{_markup} = "Q<$alttext>";
- }
- elsif($type eq 'hyperlink') {
- $self->{_markup} = "Q<$section>";
- }
- else {
- $self->{_markup} = (!$section ? '' : "Q<$section>") .
- ($page ? ($section ? ' in ':'') . "P<$page>$page_ext" : '');
- }
-}
-
-=item $link-E<gt>markup($string)
-
-Set/retrieve the textual value of the link. This string contains special
-markers C<PE<lt>E<gt>> and C<QE<lt>E<gt>> that should be expanded by the
-translator's interior sequence expansion engine to the
-formatter-specific code to highlight/activate the hyperlink. The details
-have to be implemented in the translator.
-
-=cut
-
-#' retrieve/set markuped text
-sub markup {
- return (@_ > 1) ? ($_[0]->{_markup} = $_[1]) : $_[0]->{_markup};
-}
-
-=item $link-E<gt>text()
-
-This method returns the textual representation of the hyperlink as above,
-but without markers (read only). Depending on the link type this is one of
-the following alternatives (the + and * denote the portions of the text
-that are marked up):
-
- +perl+ L<perl>
- *$|* in +perlvar+ L<perlvar/$|>
- *OPTIONS* in +perldoc+ L<perldoc/"OPTIONS">
- *DESCRIPTION* L<"DESCRIPTION">
-
-=cut
-
-# The complete link's text
-sub text {
- return $_[0]->{_text};
-}
-
-=item $link-E<gt>warning()
-
-After parsing, this method returns any warnings encountered during the
-parsing process.
-
-=cut
-
-# Set/retrieve warnings
-sub warning {
- my $self = shift;
- if(@_) {
- push(@{$self->{_warnings}}, @_);
- return @_;
- }
- return @{$self->{_warnings}};
-}
-
-=item $link-E<gt>file()
-
-=item $link-E<gt>line()
-
-Just simple slots for storing information about the line and the file
-the link was encountered in. Has to be filled in manually.
-
-=cut
-
-# The line in the file the link appears
-sub line {
- return (@_ > 1) ? ($_[0]->{-line} = $_[1]) : $_[0]->{-line};
-}
-
-# The POD file name the link appears in
-sub file {
- return (@_ > 1) ? ($_[0]->{-file} = $_[1]) : $_[0]->{-file};
-}
-
-=item $link-E<gt>page()
-
-This method sets or returns the POD page this link points to.
-
-=cut
-
-# The POD page the link appears on
-sub page {
- if (@_ > 1) {
- $_[0]->{-page} = $_[1];
- $_[0]->_construct_text();
- }
- return $_[0]->{-page};
-}
-
-=item $link-E<gt>node()
-
-As above, but the destination node text of the link.
-
-=cut
-
-# The link destination
-sub node {
- if (@_ > 1) {
- $_[0]->{-node} = $_[1];
- $_[0]->_construct_text();
- }
- return $_[0]->{-node};
-}
-
-=item $link-E<gt>alttext()
-
-Sets or returns an alternative text specified in the link.
-
-=cut
-
-# Potential alternative text
-sub alttext {
- if (@_ > 1) {
- $_[0]->{-alttext} = $_[1];
- $_[0]->_construct_text();
- }
- return $_[0]->{-alttext};
-}
-
-=item $link-E<gt>type()
-
-The node type, either C<section> or C<item>. As an unofficial type,
-there is also C<hyperlink>, derived from e.g. C<LE<lt>http://perl.comE<gt>>
-
-=cut
-
-# The type: item or headn
-sub type {
- return (@_ > 1) ? ($_[0]->{-type} = $_[1]) : $_[0]->{-type};
-}
-
-=item $link-E<gt>link()
-
-Returns the link as contents of C<LE<lt>E<gt>>. Reciprocal to B<parse()>.
-
-=back
-
-=cut
-
-# The link itself
-sub link {
- my $self = shift;
- my $link = $self->page() || '';
- if($self->node()) {
- my $node = $self->node();
- $node =~ s/\|/E<verbar>/g;
- $node =~ s{/}{E<sol>}g;
- if($self->type() eq 'section') {
- $link .= ($link ? '/' : '') . '"' . $node . '"';
- }
- elsif($self->type() eq 'hyperlink') {
- $link = $self->node();
- }
- else { # item
- $link .= '/' . $node;
- }
- }
- if($self->alttext()) {
- my $text = $self->alttext();
- $text =~ s/\|/E<verbar>/g;
- $text =~ s{/}{E<sol>}g;
- $link = "$text|$link";
- }
- return $link;
-}
-
-sub _invalid_link {
- my ($msg) = @_;
- # this sets @_
- #eval { die "$msg\n" };
- #chomp $@;
- $@ = $msg; # this seems to work, too!
- return;
-}
-
-#-----------------------------------------------------------------------------
-# Pod::Cache
-#
-# class to hold POD page details
-#-----------------------------------------------------------------------------
-
-package Pod::Cache;
-
-=head2 Pod::Cache
-
-B<Pod::Cache> holds information about a set of POD documents,
-especially the nodes for hyperlinks.
-The following methods are available:
-
-=over 4
-
-=item Pod::Cache-E<gt>new()
-
-Create a new cache object. This object can hold an arbitrary number of
-POD documents of class Pod::Cache::Item.
-
-=cut
-
-sub new {
- my $this = shift;
- my $class = ref($this) || $this;
- my $self = [];
- bless $self, $class;
- return $self;
-}
-
-=item $cache-E<gt>item()
-
-Add a new item to the cache. Without arguments, this method returns a
-list of all cache elements.
-
-=cut
-
-sub item {
- my ($self,%param) = @_;
- if(%param) {
- my $item = Pod::Cache::Item->new(%param);
- push(@$self, $item);
- return $item;
- }
- else {
- return @{$self};
- }
-}
-
-=item $cache-E<gt>find_page($name)
-
-Look for a POD document named C<$name> in the cache. Returns the
-reference to the corresponding Pod::Cache::Item object or undef if
-not found.
-
-=back
-
-=cut
-
-sub find_page {
- my ($self,$page) = @_;
- foreach(@$self) {
- if($_->page() eq $page) {
- return $_;
- }
- }
- return;
-}
-
-package Pod::Cache::Item;
-
-=head2 Pod::Cache::Item
-
-B<Pod::Cache::Item> holds information about individual POD documents,
-that can be grouped in a Pod::Cache object.
-It is intended to hold information about the hyperlink nodes of POD
-documents.
-The following methods are available:
-
-=over 4
-
-=item Pod::Cache::Item-E<gt>new()
-
-Create a new object.
-
-=cut
-
-sub new {
- my $this = shift;
- my $class = ref($this) || $this;
- my %params = @_;
- my $self = {%params};
- bless $self, $class;
- $self->initialize();
- return $self;
-}
-
-sub initialize {
- my $self = shift;
- $self->{-nodes} = [] unless(defined $self->{-nodes});
-}
-
-=item $cacheitem-E<gt>page()
-
-Set/retrieve the POD document name (e.g. "Pod::Parser").
-
-=cut
-
-# The POD page
-sub page {
- return (@_ > 1) ? ($_[0]->{-page} = $_[1]) : $_[0]->{-page};
-}
-
-=item $cacheitem-E<gt>description()
-
-Set/retrieve the POD short description as found in the C<=head1 NAME>
-section.
-
-=cut
-
-# The POD description, taken out of NAME if present
-sub description {
- return (@_ > 1) ? ($_[0]->{-description} = $_[1]) : $_[0]->{-description};
-}
-
-=item $cacheitem-E<gt>path()
-
-Set/retrieve the POD file storage path.
-
-=cut
-
-# The file path
-sub path {
- return (@_ > 1) ? ($_[0]->{-path} = $_[1]) : $_[0]->{-path};
-}
-
-=item $cacheitem-E<gt>file()
-
-Set/retrieve the POD file name.
-
-=cut
-
-# The POD file name
-sub file {
- return (@_ > 1) ? ($_[0]->{-file} = $_[1]) : $_[0]->{-file};
-}
-
-=item $cacheitem-E<gt>nodes()
-
-Add a node (or a list of nodes) to the document's node list. Note that
-the order is kept, i.e. start with the first node and end with the last.
-If no argument is given, the current list of nodes is returned in the
-same order the nodes have been added.
-A node can be any scalar, but usually is a pair of node string and
-unique id for the C<find_node> method to work correctly.
-
-=cut
-
-# The POD nodes
-sub nodes {
- my ($self,@nodes) = @_;
- if(@nodes) {
- push(@{$self->{-nodes}}, @nodes);
- return @nodes;
- }
- else {
- return @{$self->{-nodes}};
- }
-}
-
-=item $cacheitem-E<gt>find_node($name)
-
-Look for a node or index entry named C<$name> in the object.
-Returns the unique id of the node (i.e. the second element of the array
-stored in the node array) or undef if not found.
-
-=cut
-
-sub find_node {
- my ($self,$node) = @_;
- my @search;
- push(@search, @{$self->{-nodes}}) if($self->{-nodes});
- push(@search, @{$self->{-idx}}) if($self->{-idx});
- foreach(@search) {
- if($_->[0] eq $node) {
- return $_->[1]; # id
- }
- }
- return;
-}
-
-=item $cacheitem-E<gt>idx()
-
-Add an index entry (or a list of them) to the document's index list. Note that
-the order is kept, i.e. start with the first node and end with the last.
-If no argument is given, the current list of index entries is returned in the
-same order the entries have been added.
-An index entry can be any scalar, but usually is a pair of string and
-unique id.
-
-=back
-
-=cut
-
-# The POD index entries
-sub idx {
- my ($self,@idx) = @_;
- if(@idx) {
- push(@{$self->{-idx}}, @idx);
- return @idx;
- }
- else {
- return @{$self->{-idx}};
- }
-}
-
-=head1 AUTHOR
-
-Please report bugs using L<http://rt.cpan.org>.
-
-Marek Rouchal E<lt>marekr@cpan.orgE<gt>, borrowing
-a lot of things from L<pod2man> and L<pod2roff> as well as other POD
-processing tools by Tom Christiansen, Brad Appleton and Russ Allbery.
-
-=head1 SEE ALSO
-
-L<pod2man>, L<pod2roff>, L<Pod::Parser>, L<Pod::Checker>,
-L<pod2html>
-
-=cut
-
-1;
diff --git a/src/lib/mrtg2/Pod/Parser.pm b/src/lib/mrtg2/Pod/Parser.pm
deleted file mode 100644
index c807f3f..0000000
--- a/src/lib/mrtg2/Pod/Parser.pm
+++ /dev/null
@@ -1,1829 +0,0 @@
-#############################################################################
-# Pod/Parser.pm -- package which defines a base class for parsing POD docs.
-#
-# Copyright (C) 1996-2000 by Bradford Appleton. All rights reserved.
-# This file is part of "PodParser". PodParser is free software;
-# you can redistribute it and/or modify it under the same terms
-# as Perl itself.
-#############################################################################
-
-package Pod::Parser;
-use strict;
-
-## These "variables" are used as local "glob aliases" for performance
-use vars qw($VERSION @ISA %myData %myOpts @input_stack);
-$VERSION = '1.37'; ## Current version of this package
-require 5.005; ## requires this Perl version or later
-
-#############################################################################
-
-=head1 NAME
-
-Pod::Parser - base class for creating POD filters and translators
-
-=head1 SYNOPSIS
-
- use Pod::Parser;
-
- package MyParser;
- @ISA = qw(Pod::Parser);
-
- sub command {
- my ($parser, $command, $paragraph, $line_num) = @_;
- ## Interpret the command and its text; sample actions might be:
- if ($command eq 'head1') { ... }
- elsif ($command eq 'head2') { ... }
- ## ... other commands and their actions
- my $out_fh = $parser->output_handle();
- my $expansion = $parser->interpolate($paragraph, $line_num);
- print $out_fh $expansion;
- }
-
- sub verbatim {
- my ($parser, $paragraph, $line_num) = @_;
- ## Format verbatim paragraph; sample actions might be:
- my $out_fh = $parser->output_handle();
- print $out_fh $paragraph;
- }
-
- sub textblock {
- my ($parser, $paragraph, $line_num) = @_;
- ## Translate/Format this block of text; sample actions might be:
- my $out_fh = $parser->output_handle();
- my $expansion = $parser->interpolate($paragraph, $line_num);
- print $out_fh $expansion;
- }
-
- sub interior_sequence {
- my ($parser, $seq_command, $seq_argument) = @_;
- ## Expand an interior sequence; sample actions might be:
- return "*$seq_argument*" if ($seq_command eq 'B');
- return "`$seq_argument'" if ($seq_command eq 'C');
- return "_${seq_argument}_'" if ($seq_command eq 'I');
- ## ... other sequence commands and their resulting text
- }
-
- package main;
-
- ## Create a parser object and have it parse file whose name was
- ## given on the command-line (use STDIN if no files were given).
- $parser = new MyParser();
- $parser->parse_from_filehandle(\*STDIN) if (@ARGV == 0);
- for (@ARGV) { $parser->parse_from_file($_); }
-
-=head1 REQUIRES
-
-perl5.005, Pod::InputObjects, Exporter, Symbol, Carp
-
-=head1 EXPORTS
-
-Nothing.
-
-=head1 DESCRIPTION
-
-B<Pod::Parser> is a base class for creating POD filters and translators.
-It handles most of the effort involved with parsing the POD sections
-from an input stream, leaving subclasses free to be concerned only with
-performing the actual translation of text.
-
-B<Pod::Parser> parses PODs, and makes method calls to handle the various
-components of the POD. Subclasses of B<Pod::Parser> override these methods
-to translate the POD into whatever output format they desire.
-
-=head1 QUICK OVERVIEW
-
-To create a POD filter for translating POD documentation into some other
-format, you create a subclass of B<Pod::Parser> which typically overrides
-just the base class implementation for the following methods:
-
-=over 2
-
-=item *
-
-B<command()>
-
-=item *
-
-B<verbatim()>
-
-=item *
-
-B<textblock()>
-
-=item *
-
-B<interior_sequence()>
-
-=back
-
-You may also want to override the B<begin_input()> and B<end_input()>
-methods for your subclass (to perform any needed per-file and/or
-per-document initialization or cleanup).
-
-If you need to perform any preprocessing of input before it is parsed
-you may want to override one or more of B<preprocess_line()> and/or
-B<preprocess_paragraph()>.
-
-Sometimes it may be necessary to make more than one pass over the input
-files. If this is the case you have several options. You can make the
-first pass using B<Pod::Parser> and override your methods to store the
-intermediate results in memory somewhere for the B<end_pod()> method to
-process. You could use B<Pod::Parser> for several passes with an
-appropriate state variable to control the operation for each pass. If
-your input source can't be reset to start at the beginning, you can
-store it in some other structure as a string or an array and have that
-structure implement a B<getline()> method (which is all that
-B<parse_from_filehandle()> uses to read input).
-
-Feel free to add any member data fields you need to keep track of things
-like current font, indentation, horizontal or vertical position, or
-whatever else you like. Be sure to read L<"PRIVATE METHODS AND DATA">
-to avoid name collisions.
-
-For the most part, the B<Pod::Parser> base class should be able to
-do most of the input parsing for you and leave you free to worry about
-how to interpret the commands and translate the result.
-
-Note that all we have described here in this quick overview is the
-simplest most straightforward use of B<Pod::Parser> to do stream-based
-parsing. It is also possible to use the B<Pod::Parser::parse_text> function
-to do more sophisticated tree-based parsing. See L<"TREE-BASED PARSING">.
-
-=head1 PARSING OPTIONS
-
-A I<parse-option> is simply a named option of B<Pod::Parser> with a
-value that corresponds to a certain specified behavior. These various
-behaviors of B<Pod::Parser> may be enabled/disabled by setting
-or unsetting one or more I<parse-options> using the B<parseopts()> method.
-The set of currently accepted parse-options is as follows:
-
-=over 3
-
-=item B<-want_nonPODs> (default: unset)
-
-Normally (by default) B<Pod::Parser> will only provide access to
-the POD sections of the input. Input paragraphs that are not part
-of the POD-format documentation are not made available to the caller
-(not even using B<preprocess_paragraph()>). Setting this option to a
-non-empty, non-zero value will allow B<preprocess_paragraph()> to see
-non-POD sections of the input as well as POD sections. The B<cutting()>
-method can be used to determine if the corresponding paragraph is a POD
-paragraph, or some other input paragraph.
-
-=item B<-process_cut_cmd> (default: unset)
-
-Normally (by default) B<Pod::Parser> handles the C<=cut> POD directive
-by itself and does not pass it on to the caller for processing. Setting
-this option to a non-empty, non-zero value will cause B<Pod::Parser> to
-pass the C<=cut> directive to the caller just like any other POD command
-(and hence it may be processed by the B<command()> method).
-
-B<Pod::Parser> will still interpret the C<=cut> directive to mean that
-"cutting mode" has been (re)entered, but the caller will get a chance
-to capture the actual C<=cut> paragraph itself for whatever purpose
-it desires.
-
-=item B<-warnings> (default: unset)
-
-Normally (by default) B<Pod::Parser> recognizes a bare minimum of
-pod syntax errors and warnings and issues diagnostic messages
-for errors, but not for warnings. (Use B<Pod::Checker> to do more
-thorough checking of POD syntax.) Setting this option to a non-empty,
-non-zero value will cause B<Pod::Parser> to issue diagnostics for
-the few warnings it recognizes as well as the errors.
-
-=back
-
-Please see L<"parseopts()"> for a complete description of the interface
-for the setting and unsetting of parse-options.
-
-=cut
-
-#############################################################################
-
-#use diagnostics;
-use Pod::InputObjects;
-use Carp;
-use Exporter;
-BEGIN {
- if ($] < 5.006) {
- require Symbol;
- import Symbol;
- }
-}
-@ISA = qw(Exporter);
-
-#############################################################################
-
-=head1 RECOMMENDED SUBROUTINE/METHOD OVERRIDES
-
-B<Pod::Parser> provides several methods which most subclasses will probably
-want to override. These methods are as follows:
-
-=cut
-
-##---------------------------------------------------------------------------
-
-=head1 B<command()>
-
- $parser->command($cmd,$text,$line_num,$pod_para);
-
-This method should be overridden by subclasses to take the appropriate
-action when a POD command paragraph (denoted by a line beginning with
-"=") is encountered. When such a POD directive is seen in the input,
-this method is called and is passed:
-
-=over 3
-
-=item C<$cmd>
-
-the name of the command for this POD paragraph
-
-=item C<$text>
-
-the paragraph text for the given POD paragraph command.
-
-=item C<$line_num>
-
-the line-number of the beginning of the paragraph
-
-=item C<$pod_para>
-
-a reference to a C<Pod::Paragraph> object which contains further
-information about the paragraph command (see L<Pod::InputObjects>
-for details).
-
-=back
-
-B<Note> that this method I<is> called for C<=pod> paragraphs.
-
-The base class implementation of this method simply treats the raw POD
-command as normal block of paragraph text (invoking the B<textblock()>
-method with the command paragraph).
-
-=cut
-
-sub command {
- my ($self, $cmd, $text, $line_num, $pod_para) = @_;
- ## Just treat this like a textblock
- $self->textblock($pod_para->raw_text(), $line_num, $pod_para);
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<verbatim()>
-
- $parser->verbatim($text,$line_num,$pod_para);
-
-This method may be overridden by subclasses to take the appropriate
-action when a block of verbatim text is encountered. It is passed the
-following parameters:
-
-=over 3
-
-=item C<$text>
-
-the block of text for the verbatim paragraph
-
-=item C<$line_num>
-
-the line-number of the beginning of the paragraph
-
-=item C<$pod_para>
-
-a reference to a C<Pod::Paragraph> object which contains further
-information about the paragraph (see L<Pod::InputObjects>
-for details).
-
-=back
-
-The base class implementation of this method simply prints the textblock
-(unmodified) to the output filehandle.
-
-=cut
-
-sub verbatim {
- my ($self, $text, $line_num, $pod_para) = @_;
- my $out_fh = $self->{_OUTPUT};
- print $out_fh $text;
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<textblock()>
-
- $parser->textblock($text,$line_num,$pod_para);
-
-This method may be overridden by subclasses to take the appropriate
-action when a normal block of POD text is encountered (although the base
-class method will usually do what you want). It is passed the following
-parameters:
-
-=over 3
-
-=item C<$text>
-
-the block of text for the a POD paragraph
-
-=item C<$line_num>
-
-the line-number of the beginning of the paragraph
-
-=item C<$pod_para>
-
-a reference to a C<Pod::Paragraph> object which contains further
-information about the paragraph (see L<Pod::InputObjects>
-for details).
-
-=back
-
-In order to process interior sequences, subclasses implementations of
-this method will probably want to invoke either B<interpolate()> or
-B<parse_text()>, passing it the text block C<$text>, and the corresponding
-line number in C<$line_num>, and then perform any desired processing upon
-the returned result.
-
-The base class implementation of this method simply prints the text block
-as it occurred in the input stream).
-
-=cut
-
-sub textblock {
- my ($self, $text, $line_num, $pod_para) = @_;
- my $out_fh = $self->{_OUTPUT};
- print $out_fh $self->interpolate($text, $line_num);
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<interior_sequence()>
-
- $parser->interior_sequence($seq_cmd,$seq_arg,$pod_seq);
-
-This method should be overridden by subclasses to take the appropriate
-action when an interior sequence is encountered. An interior sequence is
-an embedded command within a block of text which appears as a command
-name (usually a single uppercase character) followed immediately by a
-string of text which is enclosed in angle brackets. This method is
-passed the sequence command C<$seq_cmd> and the corresponding text
-C<$seq_arg>. It is invoked by the B<interpolate()> method for each interior
-sequence that occurs in the string that it is passed. It should return
-the desired text string to be used in place of the interior sequence.
-The C<$pod_seq> argument is a reference to a C<Pod::InteriorSequence>
-object which contains further information about the interior sequence.
-Please see L<Pod::InputObjects> for details if you need to access this
-additional information.
-
-Subclass implementations of this method may wish to invoke the
-B<nested()> method of C<$pod_seq> to see if it is nested inside
-some other interior-sequence (and if so, which kind).
-
-The base class implementation of the B<interior_sequence()> method
-simply returns the raw text of the interior sequence (as it occurred
-in the input) to the caller.
-
-=cut
-
-sub interior_sequence {
- my ($self, $seq_cmd, $seq_arg, $pod_seq) = @_;
- ## Just return the raw text of the interior sequence
- return $pod_seq->raw_text();
-}
-
-#############################################################################
-
-=head1 OPTIONAL SUBROUTINE/METHOD OVERRIDES
-
-B<Pod::Parser> provides several methods which subclasses may want to override
-to perform any special pre/post-processing. These methods do I<not> have to
-be overridden, but it may be useful for subclasses to take advantage of them.
-
-=cut
-
-##---------------------------------------------------------------------------
-
-=head1 B<new()>
-
- my $parser = Pod::Parser->new();
-
-This is the constructor for B<Pod::Parser> and its subclasses. You
-I<do not> need to override this method! It is capable of constructing
-subclass objects as well as base class objects, provided you use
-any of the following constructor invocation styles:
-
- my $parser1 = MyParser->new();
- my $parser2 = new MyParser();
- my $parser3 = $parser2->new();
-
-where C<MyParser> is some subclass of B<Pod::Parser>.
-
-Using the syntax C<MyParser::new()> to invoke the constructor is I<not>
-recommended, but if you insist on being able to do this, then the
-subclass I<will> need to override the B<new()> constructor method. If
-you do override the constructor, you I<must> be sure to invoke the
-B<initialize()> method of the newly blessed object.
-
-Using any of the above invocations, the first argument to the
-constructor is always the corresponding package name (or object
-reference). No other arguments are required, but if desired, an
-associative array (or hash-table) my be passed to the B<new()>
-constructor, as in:
-
- my $parser1 = MyParser->new( MYDATA => $value1, MOREDATA => $value2 );
- my $parser2 = new MyParser( -myflag => 1 );
-
-All arguments passed to the B<new()> constructor will be treated as
-key/value pairs in a hash-table. The newly constructed object will be
-initialized by copying the contents of the given hash-table (which may
-have been empty). The B<new()> constructor for this class and all of its
-subclasses returns a blessed reference to the initialized object (hash-table).
-
-=cut
-
-sub new {
- ## Determine if we were called via an object-ref or a classname
- my ($this,%params) = @_;
- my $class = ref($this) || $this;
- ## Any remaining arguments are treated as initial values for the
- ## hash that is used to represent this object.
- my $self = { %params };
- ## Bless ourselves into the desired class and perform any initialization
- bless $self, $class;
- $self->initialize();
- return $self;
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<initialize()>
-
- $parser->initialize();
-
-This method performs any necessary object initialization. It takes no
-arguments (other than the object instance of course, which is typically
-copied to a local variable named C<$self>). If subclasses override this
-method then they I<must> be sure to invoke C<$self-E<gt>SUPER::initialize()>.
-
-=cut
-
-sub initialize {
- #my $self = shift;
- #return;
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<begin_pod()>
-
- $parser->begin_pod();
-
-This method is invoked at the beginning of processing for each POD
-document that is encountered in the input. Subclasses should override
-this method to perform any per-document initialization.
-
-=cut
-
-sub begin_pod {
- #my $self = shift;
- #return;
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<begin_input()>
-
- $parser->begin_input();
-
-This method is invoked by B<parse_from_filehandle()> immediately I<before>
-processing input from a filehandle. The base class implementation does
-nothing, however, subclasses may override it to perform any per-file
-initializations.
-
-Note that if multiple files are parsed for a single POD document
-(perhaps the result of some future C<=include> directive) this method
-is invoked for every file that is parsed. If you wish to perform certain
-initializations once per document, then you should use B<begin_pod()>.
-
-=cut
-
-sub begin_input {
- #my $self = shift;
- #return;
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<end_input()>
-
- $parser->end_input();
-
-This method is invoked by B<parse_from_filehandle()> immediately I<after>
-processing input from a filehandle. The base class implementation does
-nothing, however, subclasses may override it to perform any per-file
-cleanup actions.
-
-Please note that if multiple files are parsed for a single POD document
-(perhaps the result of some kind of C<=include> directive) this method
-is invoked for every file that is parsed. If you wish to perform certain
-cleanup actions once per document, then you should use B<end_pod()>.
-
-=cut
-
-sub end_input {
- #my $self = shift;
- #return;
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<end_pod()>
-
- $parser->end_pod();
-
-This method is invoked at the end of processing for each POD document
-that is encountered in the input. Subclasses should override this method
-to perform any per-document finalization.
-
-=cut
-
-sub end_pod {
- #my $self = shift;
- #return;
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<preprocess_line()>
-
- $textline = $parser->preprocess_line($text, $line_num);
-
-This method should be overridden by subclasses that wish to perform
-any kind of preprocessing for each I<line> of input (I<before> it has
-been determined whether or not it is part of a POD paragraph). The
-parameter C<$text> is the input line; and the parameter C<$line_num> is
-the line number of the corresponding text line.
-
-The value returned should correspond to the new text to use in its
-place. If the empty string or an undefined value is returned then no
-further processing will be performed for this line.
-
-Please note that the B<preprocess_line()> method is invoked I<before>
-the B<preprocess_paragraph()> method. After all (possibly preprocessed)
-lines in a paragraph have been assembled together and it has been
-determined that the paragraph is part of the POD documentation from one
-of the selected sections, then B<preprocess_paragraph()> is invoked.
-
-The base class implementation of this method returns the given text.
-
-=cut
-
-sub preprocess_line {
- my ($self, $text, $line_num) = @_;
- return $text;
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<preprocess_paragraph()>
-
- $textblock = $parser->preprocess_paragraph($text, $line_num);
-
-This method should be overridden by subclasses that wish to perform any
-kind of preprocessing for each block (paragraph) of POD documentation
-that appears in the input stream. The parameter C<$text> is the POD
-paragraph from the input file; and the parameter C<$line_num> is the
-line number for the beginning of the corresponding paragraph.
-
-The value returned should correspond to the new text to use in its
-place If the empty string is returned or an undefined value is
-returned, then the given C<$text> is ignored (not processed).
-
-This method is invoked after gathering up all the lines in a paragraph
-and after determining the cutting state of the paragraph,
-but before trying to further parse or interpret them. After
-B<preprocess_paragraph()> returns, the current cutting state (which
-is returned by C<$self-E<gt>cutting()>) is examined. If it evaluates
-to true then input text (including the given C<$text>) is cut (not
-processed) until the next POD directive is encountered.
-
-Please note that the B<preprocess_line()> method is invoked I<before>
-the B<preprocess_paragraph()> method. After all (possibly preprocessed)
-lines in a paragraph have been assembled together and either it has been
-determined that the paragraph is part of the POD documentation from one
-of the selected sections or the C<-want_nonPODs> option is true,
-then B<preprocess_paragraph()> is invoked.
-
-The base class implementation of this method returns the given text.
-
-=cut
-
-sub preprocess_paragraph {
- my ($self, $text, $line_num) = @_;
- return $text;
-}
-
-#############################################################################
-
-=head1 METHODS FOR PARSING AND PROCESSING
-
-B<Pod::Parser> provides several methods to process input text. These
-methods typically won't need to be overridden (and in some cases they
-can't be overridden), but subclasses may want to invoke them to exploit
-their functionality.
-
-=cut
-
-##---------------------------------------------------------------------------
-
-=head1 B<parse_text()>
-
- $ptree1 = $parser->parse_text($text, $line_num);
- $ptree2 = $parser->parse_text({%opts}, $text, $line_num);
- $ptree3 = $parser->parse_text(\%opts, $text, $line_num);
-
-This method is useful if you need to perform your own interpolation
-of interior sequences and can't rely upon B<interpolate> to expand
-them in simple bottom-up order.
-
-The parameter C<$text> is a string or block of text to be parsed
-for interior sequences; and the parameter C<$line_num> is the
-line number corresponding to the beginning of C<$text>.
-
-B<parse_text()> will parse the given text into a parse-tree of "nodes."
-and interior-sequences. Each "node" in the parse tree is either a
-text-string, or a B<Pod::InteriorSequence>. The result returned is a
-parse-tree of type B<Pod::ParseTree>. Please see L<Pod::InputObjects>
-for more information about B<Pod::InteriorSequence> and B<Pod::ParseTree>.
-
-If desired, an optional hash-ref may be specified as the first argument
-to customize certain aspects of the parse-tree that is created and
-returned. The set of recognized option keywords are:
-
-=over 3
-
-=item B<-expand_seq> =E<gt> I<code-ref>|I<method-name>
-
-Normally, the parse-tree returned by B<parse_text()> will contain an
-unexpanded C<Pod::InteriorSequence> object for each interior-sequence
-encountered. Specifying B<-expand_seq> tells B<parse_text()> to "expand"
-every interior-sequence it sees by invoking the referenced function
-(or named method of the parser object) and using the return value as the
-expanded result.
-
-If a subroutine reference was given, it is invoked as:
-
- &$code_ref( $parser, $sequence )
-
-and if a method-name was given, it is invoked as:
-
- $parser->method_name( $sequence )
-
-where C<$parser> is a reference to the parser object, and C<$sequence>
-is a reference to the interior-sequence object.
-[I<NOTE>: If the B<interior_sequence()> method is specified, then it is
-invoked according to the interface specified in L<"interior_sequence()">].
-
-=item B<-expand_text> =E<gt> I<code-ref>|I<method-name>
-
-Normally, the parse-tree returned by B<parse_text()> will contain a
-text-string for each contiguous sequence of characters outside of an
-interior-sequence. Specifying B<-expand_text> tells B<parse_text()> to
-"preprocess" every such text-string it sees by invoking the referenced
-function (or named method of the parser object) and using the return value
-as the preprocessed (or "expanded") result. [Note that if the result is
-an interior-sequence, then it will I<not> be expanded as specified by the
-B<-expand_seq> option; Any such recursive expansion needs to be handled by
-the specified callback routine.]
-
-If a subroutine reference was given, it is invoked as:
-
- &$code_ref( $parser, $text, $ptree_node )
-
-and if a method-name was given, it is invoked as:
-
- $parser->method_name( $text, $ptree_node )
-
-where C<$parser> is a reference to the parser object, C<$text> is the
-text-string encountered, and C<$ptree_node> is a reference to the current
-node in the parse-tree (usually an interior-sequence object or else the
-top-level node of the parse-tree).
-
-=item B<-expand_ptree> =E<gt> I<code-ref>|I<method-name>
-
-Rather than returning a C<Pod::ParseTree>, pass the parse-tree as an
-argument to the referenced subroutine (or named method of the parser
-object) and return the result instead of the parse-tree object.
-
-If a subroutine reference was given, it is invoked as:
-
- &$code_ref( $parser, $ptree )
-
-and if a method-name was given, it is invoked as:
-
- $parser->method_name( $ptree )
-
-where C<$parser> is a reference to the parser object, and C<$ptree>
-is a reference to the parse-tree object.
-
-=back
-
-=cut
-
-sub parse_text {
- my $self = shift;
- local $_ = '';
-
- ## Get options and set any defaults
- my %opts = (ref $_[0]) ? %{ shift() } : ();
- my $expand_seq = $opts{'-expand_seq'} || undef;
- my $expand_text = $opts{'-expand_text'} || undef;
- my $expand_ptree = $opts{'-expand_ptree'} || undef;
-
- my $text = shift;
- my $line = shift;
- my $file = $self->input_file();
- my $cmd = "";
-
- ## Convert method calls into closures, for our convenience
- my $xseq_sub = $expand_seq;
- my $xtext_sub = $expand_text;
- my $xptree_sub = $expand_ptree;
- if (defined $expand_seq and $expand_seq eq 'interior_sequence') {
- ## If 'interior_sequence' is the method to use, we have to pass
- ## more than just the sequence object, we also need to pass the
- ## sequence name and text.
- $xseq_sub = sub {
- my ($sself, $iseq) = @_;
- my $args = join('', $iseq->parse_tree->children);
- return $sself->interior_sequence($iseq->name, $args, $iseq);
- };
- }
- ref $xseq_sub or $xseq_sub = sub { shift()->$expand_seq(@_) };
- ref $xtext_sub or $xtext_sub = sub { shift()->$expand_text(@_) };
- ref $xptree_sub or $xptree_sub = sub { shift()->$expand_ptree(@_) };
-
- ## Keep track of the "current" interior sequence, and maintain a stack
- ## of "in progress" sequences.
- ##
- ## NOTE that we push our own "accumulator" at the very beginning of the
- ## stack. It's really a parse-tree, not a sequence; but it implements
- ## the methods we need so we can use it to gather-up all the sequences
- ## and strings we parse. Thus, by the end of our parsing, it should be
- ## the only thing left on our stack and all we have to do is return it!
- ##
- my $seq = Pod::ParseTree->new();
- my @seq_stack = ($seq);
- my ($ldelim, $rdelim) = ('', '');
-
- ## Iterate over all sequence starts text (NOTE: split with
- ## capturing parens keeps the delimiters)
- $_ = $text;
- my @tokens = split /([A-Z]<(?:<+\s)?)/;
- while ( @tokens ) {
- $_ = shift @tokens;
- ## Look for the beginning of a sequence
- if ( /^([A-Z])(<(?:<+\s)?)$/ ) {
- ## Push a new sequence onto the stack of those "in-progress"
- my $ldelim_orig;
- ($cmd, $ldelim_orig) = ($1, $2);
- ($ldelim = $ldelim_orig) =~ s/\s+$//;
- ($rdelim = $ldelim) =~ tr/</>/;
- $seq = Pod::InteriorSequence->new(
- -name => $cmd,
- -ldelim => $ldelim_orig, -rdelim => $rdelim,
- -file => $file, -line => $line
- );
- (@seq_stack > 1) and $seq->nested($seq_stack[-1]);
- push @seq_stack, $seq;
- }
- ## Look for sequence ending
- elsif ( @seq_stack > 1 ) {
- ## Make sure we match the right kind of closing delimiter
- my ($seq_end, $post_seq) = ('', '');
- if ( ($ldelim eq '<' and /\A(.*?)(>)/s)
- or /\A(.*?)(\s+$rdelim)/s )
- {
- ## Found end-of-sequence, capture the interior and the
- ## closing the delimiter, and put the rest back on the
- ## token-list
- $post_seq = substr($_, length($1) + length($2));
- ($_, $seq_end) = ($1, $2);
- (length $post_seq) and unshift @tokens, $post_seq;
- }
- if (length) {
- ## In the middle of a sequence, append this text to it, and
- ## dont forget to "expand" it if that's what the caller wanted
- $seq->append($expand_text ? &$xtext_sub($self,$_,$seq) : $_);
- $_ .= $seq_end;
- }
- if (length $seq_end) {
- ## End of current sequence, record terminating delimiter
- $seq->rdelim($seq_end);
- ## Pop it off the stack of "in progress" sequences
- pop @seq_stack;
- ## Append result to its parent in current parse tree
- $seq_stack[-1]->append($expand_seq ? &$xseq_sub($self,$seq)
- : $seq);
- ## Remember the current cmd-name and left-delimiter
- if(@seq_stack > 1) {
- $cmd = $seq_stack[-1]->name;
- $ldelim = $seq_stack[-1]->ldelim;
- $rdelim = $seq_stack[-1]->rdelim;
- } else {
- $cmd = $ldelim = $rdelim = '';
- }
- }
- }
- elsif (length) {
- ## In the middle of a sequence, append this text to it, and
- ## dont forget to "expand" it if that's what the caller wanted
- $seq->append($expand_text ? &$xtext_sub($self,$_,$seq) : $_);
- }
- ## Keep track of line count
- $line += s/\r*\n//;
- ## Remember the "current" sequence
- $seq = $seq_stack[-1];
- }
-
- ## Handle unterminated sequences
- my $errorsub = (@seq_stack > 1) ? $self->errorsub() : undef;
- while (@seq_stack > 1) {
- ($cmd, $file, $line) = ($seq->name, $seq->file_line);
- $ldelim = $seq->ldelim;
- ($rdelim = $ldelim) =~ tr/</>/;
- $rdelim =~ s/^(\S+)(\s*)$/$2$1/;
- pop @seq_stack;
- my $errmsg = "*** ERROR: unterminated ${cmd}${ldelim}...${rdelim}".
- " at line $line in file $file\n";
- (ref $errorsub) and &{$errorsub}($errmsg)
- or (defined $errorsub) and $self->$errorsub($errmsg)
- or carp($errmsg);
- $seq_stack[-1]->append($expand_seq ? &$xseq_sub($self,$seq) : $seq);
- $seq = $seq_stack[-1];
- }
-
- ## Return the resulting parse-tree
- my $ptree = (pop @seq_stack)->parse_tree;
- return $expand_ptree ? &$xptree_sub($self, $ptree) : $ptree;
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<interpolate()>
-
- $textblock = $parser->interpolate($text, $line_num);
-
-This method translates all text (including any embedded interior sequences)
-in the given text string C<$text> and returns the interpolated result. The
-parameter C<$line_num> is the line number corresponding to the beginning
-of C<$text>.
-
-B<interpolate()> merely invokes a private method to recursively expand
-nested interior sequences in bottom-up order (innermost sequences are
-expanded first). If there is a need to expand nested sequences in
-some alternate order, use B<parse_text> instead.
-
-=cut
-
-sub interpolate {
- my($self, $text, $line_num) = @_;
- my %parse_opts = ( -expand_seq => 'interior_sequence' );
- my $ptree = $self->parse_text( \%parse_opts, $text, $line_num );
- return join '', $ptree->children();
-}
-
-##---------------------------------------------------------------------------
-
-=begin __PRIVATE__
-
-=head1 B<parse_paragraph()>
-
- $parser->parse_paragraph($text, $line_num);
-
-This method takes the text of a POD paragraph to be processed, along
-with its corresponding line number, and invokes the appropriate method
-(one of B<command()>, B<verbatim()>, or B<textblock()>).
-
-For performance reasons, this method is invoked directly without any
-dynamic lookup; Hence subclasses may I<not> override it!
-
-=end __PRIVATE__
-
-=cut
-
-sub parse_paragraph {
- my ($self, $text, $line_num) = @_;
- local *myData = $self; ## alias to avoid deref-ing overhead
- local *myOpts = ($myData{_PARSEOPTS} ||= {}); ## get parse-options
- local $_;
-
- ## See if we want to preprocess nonPOD paragraphs as well as POD ones.
- my $wantNonPods = $myOpts{'-want_nonPODs'};
-
- ## Update cutting status
- $myData{_CUTTING} = 0 if $text =~ /^={1,2}\S/;
-
- ## Perform any desired preprocessing if we wanted it this early
- $wantNonPods and $text = $self->preprocess_paragraph($text, $line_num);
-
- ## Ignore up until next POD directive if we are cutting
- return if $myData{_CUTTING};
-
- ## Now we know this is block of text in a POD section!
-
- ##-----------------------------------------------------------------
- ## This is a hook (hack ;-) for Pod::Select to do its thing without
- ## having to override methods, but also without Pod::Parser assuming
- ## $self is an instance of Pod::Select (if the _SELECTED_SECTIONS
- ## field exists then we assume there is an is_selected() method for
- ## us to invoke (calling $self->can('is_selected') could verify this
- ## but that is more overhead than I want to incur)
- ##-----------------------------------------------------------------
-
- ## Ignore this block if it isnt in one of the selected sections
- if (exists $myData{_SELECTED_SECTIONS}) {
- $self->is_selected($text) or return ($myData{_CUTTING} = 1);
- }
-
- ## If we havent already, perform any desired preprocessing and
- ## then re-check the "cutting" state
- unless ($wantNonPods) {
- $text = $self->preprocess_paragraph($text, $line_num);
- return 1 unless ((defined $text) and (length $text));
- return 1 if ($myData{_CUTTING});
- }
-
- ## Look for one of the three types of paragraphs
- my ($pfx, $cmd, $arg, $sep) = ('', '', '', '');
- my $pod_para = undef;
- if ($text =~ /^(={1,2})(?=\S)/) {
- ## Looks like a command paragraph. Capture the command prefix used
- ## ("=" or "=="), as well as the command-name, its paragraph text,
- ## and whatever sequence of characters was used to separate them
- $pfx = $1;
- $_ = substr($text, length $pfx);
- ($cmd, $sep, $text) = split /(\s+)/, $_, 2;
- ## If this is a "cut" directive then we dont need to do anything
- ## except return to "cutting" mode.
- if ($cmd eq 'cut') {
- $myData{_CUTTING} = 1;
- return unless $myOpts{'-process_cut_cmd'};
- }
- }
- ## Save the attributes indicating how the command was specified.
- $pod_para = new Pod::Paragraph(
- -name => $cmd,
- -text => $text,
- -prefix => $pfx,
- -separator => $sep,
- -file => $myData{_INFILE},
- -line => $line_num
- );
- # ## Invoke appropriate callbacks
- # if (exists $myData{_CALLBACKS}) {
- # ## Look through the callback list, invoke callbacks,
- # ## then see if we need to do the default actions
- # ## (invoke_callbacks will return true if we do).
- # return 1 unless $self->invoke_callbacks($cmd, $text, $line_num, $pod_para);
- # }
-
- # If the last paragraph ended in whitespace, and we're not between verbatim blocks, carp
- if ($myData{_WHITESPACE} and $myOpts{'-warnings'}
- and not ($text =~ /^\s+/ and ($myData{_PREVIOUS}||"") eq "verbatim")) {
- my $errorsub = $self->errorsub();
- my $line = $line_num - 1;
- my $errmsg = "*** WARNING: line containing nothing but whitespace".
- " in paragraph at line $line in file $myData{_INFILE}\n";
- (ref $errorsub) and &{$errorsub}($errmsg)
- or (defined $errorsub) and $self->$errorsub($errmsg)
- or carp($errmsg);
- }
-
- if (length $cmd) {
- ## A command paragraph
- $self->command($cmd, $text, $line_num, $pod_para);
- $myData{_PREVIOUS} = $cmd;
- }
- elsif ($text =~ /^\s+/) {
- ## Indented text - must be a verbatim paragraph
- $self->verbatim($text, $line_num, $pod_para);
- $myData{_PREVIOUS} = "verbatim";
- }
- else {
- ## Looks like an ordinary block of text
- $self->textblock($text, $line_num, $pod_para);
- $myData{_PREVIOUS} = "textblock";
- }
-
- # Update the whitespace for the next time around
- $myData{_WHITESPACE} = $text =~ /^[^\S\r\n]+\Z/m ? 1 : 0;
-
- return 1;
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<parse_from_filehandle()>
-
- $parser->parse_from_filehandle($in_fh,$out_fh);
-
-This method takes an input filehandle (which is assumed to already be
-opened for reading) and reads the entire input stream looking for blocks
-(paragraphs) of POD documentation to be processed. If no first argument
-is given the default input filehandle C<STDIN> is used.
-
-The C<$in_fh> parameter may be any object that provides a B<getline()>
-method to retrieve a single line of input text (hence, an appropriate
-wrapper object could be used to parse PODs from a single string or an
-array of strings).
-
-Using C<$in_fh-E<gt>getline()>, input is read line-by-line and assembled
-into paragraphs or "blocks" (which are separated by lines containing
-nothing but whitespace). For each block of POD documentation
-encountered it will invoke a method to parse the given paragraph.
-
-If a second argument is given then it should correspond to a filehandle where
-output should be sent (otherwise the default output filehandle is
-C<STDOUT> if no output filehandle is currently in use).
-
-B<NOTE:> For performance reasons, this method caches the input stream at
-the top of the stack in a local variable. Any attempts by clients to
-change the stack contents during processing when in the midst executing
-of this method I<will not affect> the input stream used by the current
-invocation of this method.
-
-This method does I<not> usually need to be overridden by subclasses.
-
-=cut
-
-sub parse_from_filehandle {
- my $self = shift;
- my %opts = (ref $_[0] eq 'HASH') ? %{ shift() } : ();
- my ($in_fh, $out_fh) = @_;
- $in_fh = \*STDIN unless ($in_fh);
- local *myData = $self; ## alias to avoid deref-ing overhead
- local *myOpts = ($myData{_PARSEOPTS} ||= {}); ## get parse-options
- local $_;
-
- ## Put this stream at the top of the stack and do beginning-of-input
- ## processing. NOTE that $in_fh might be reset during this process.
- my $topstream = $self->_push_input_stream($in_fh, $out_fh);
- (exists $opts{-cutting}) and $self->cutting( $opts{-cutting} );
-
- ## Initialize line/paragraph
- my ($textline, $paragraph) = ('', '');
- my ($nlines, $plines) = (0, 0);
-
- ## Use <$fh> instead of $fh->getline where possible (for speed)
- $_ = ref $in_fh;
- my $tied_fh = (/^(?:GLOB|FileHandle|IO::\w+)$/ or tied $in_fh);
-
- ## Read paragraphs line-by-line
- while (defined ($textline = $tied_fh ? <$in_fh> : $in_fh->getline)) {
- $textline = $self->preprocess_line($textline, ++$nlines);
- next unless ((defined $textline) && (length $textline));
-
- if ((! length $paragraph) && ($textline =~ /^==/)) {
- ## '==' denotes a one-line command paragraph
- $paragraph = $textline;
- $plines = 1;
- $textline = '';
- } else {
- ## Append this line to the current paragraph
- $paragraph .= $textline;
- ++$plines;
- }
-
- ## See if this line is blank and ends the current paragraph.
- ## If it isnt, then keep iterating until it is.
- next unless (($textline =~ /^([^\S\r\n]*)[\r\n]*$/)
- && (length $paragraph));
-
- ## Now process the paragraph
- parse_paragraph($self, $paragraph, ($nlines - $plines) + 1);
- $paragraph = '';
- $plines = 0;
- }
- ## Dont forget about the last paragraph in the file
- if (length $paragraph) {
- parse_paragraph($self, $paragraph, ($nlines - $plines) + 1)
- }
-
- ## Now pop the input stream off the top of the input stack.
- $self->_pop_input_stream();
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<parse_from_file()>
-
- $parser->parse_from_file($filename,$outfile);
-
-This method takes a filename and does the following:
-
-=over 2
-
-=item *
-
-opens the input and output files for reading
-(creating the appropriate filehandles)
-
-=item *
-
-invokes the B<parse_from_filehandle()> method passing it the
-corresponding input and output filehandles.
-
-=item *
-
-closes the input and output files.
-
-=back
-
-If the special input filename "-" or "<&STDIN" is given then the STDIN
-filehandle is used for input (and no open or close is performed). If no
-input filename is specified then "-" is implied. Filehandle references,
-or objects that support the regular IO operations (like C<E<lt>$fhE<gt>>
-or C<$fh-<Egt>getline>) are also accepted; the handles must already be
-opened.
-
-If a second argument is given then it should be the name of the desired
-output file. If the special output filename "-" or ">&STDOUT" is given
-then the STDOUT filehandle is used for output (and no open or close is
-performed). If the special output filename ">&STDERR" is given then the
-STDERR filehandle is used for output (and no open or close is
-performed). If no output filehandle is currently in use and no output
-filename is specified, then "-" is implied.
-Alternatively, filehandle references or objects that support the regular
-IO operations (like C<print>, e.g. L<IO::String>) are also accepted;
-the object must already be opened.
-
-This method does I<not> usually need to be overridden by subclasses.
-
-=cut
-
-sub parse_from_file {
- my $self = shift;
- my %opts = (ref $_[0] eq 'HASH') ? %{ shift() } : ();
- my ($infile, $outfile) = @_;
- my ($in_fh, $out_fh);
- if ($] < 5.006) {
- ($in_fh, $out_fh) = (gensym(), gensym());
- }
- my ($close_input, $close_output) = (0, 0);
- local *myData = $self;
- local *_;
-
- ## Is $infile a filename or a (possibly implied) filehandle
- if (defined $infile && ref $infile) {
- if (ref($infile) =~ /^(SCALAR|ARRAY|HASH|CODE|REF)$/) {
- croak "Input from $1 reference not supported!\n";
- }
- ## Must be a filehandle-ref (or else assume its a ref to an object
- ## that supports the common IO read operations).
- $myData{_INFILE} = ${$infile};
- $in_fh = $infile;
- }
- elsif (!defined($infile) || !length($infile) || ($infile eq '-')
- || ($infile =~ /^<&(?:STDIN|0)$/i))
- {
- ## Not a filename, just a string implying STDIN
- $infile ||= '-';
- $myData{_INFILE} = '<standard input>';
- $in_fh = \*STDIN;
- }
- else {
- ## We have a filename, open it for reading
- $myData{_INFILE} = $infile;
- open($in_fh, "< $infile") or
- croak "Can't open $infile for reading: $!\n";
- $close_input = 1;
- }
-
- ## NOTE: we need to be *very* careful when "defaulting" the output
- ## file. We only want to use a default if this is the beginning of
- ## the entire document (but *not* if this is an included file). We
- ## determine this by seeing if the input stream stack has been set-up
- ## already
-
- ## Is $outfile a filename, a (possibly implied) filehandle, maybe a ref?
- if (ref $outfile) {
- ## we need to check for ref() first, as other checks involve reading
- if (ref($outfile) =~ /^(ARRAY|HASH|CODE)$/) {
- croak "Output to $1 reference not supported!\n";
- }
- elsif (ref($outfile) eq 'SCALAR') {
-# # NOTE: IO::String isn't a part of the perl distribution,
-# # so probably we shouldn't support this case...
-# require IO::String;
-# $myData{_OUTFILE} = "$outfile";
-# $out_fh = IO::String->new($outfile);
- croak "Output to SCALAR reference not supported!\n";
- }
- else {
- ## Must be a filehandle-ref (or else assume its a ref to an
- ## object that supports the common IO write operations).
- $myData{_OUTFILE} = ${$outfile};
- $out_fh = $outfile;
- }
- }
- elsif (!defined($outfile) || !length($outfile) || ($outfile eq '-')
- || ($outfile =~ /^>&?(?:STDOUT|1)$/i))
- {
- if (defined $myData{_TOP_STREAM}) {
- $out_fh = $myData{_OUTPUT};
- }
- else {
- ## Not a filename, just a string implying STDOUT
- $outfile ||= '-';
- $myData{_OUTFILE} = '<standard output>';
- $out_fh = \*STDOUT;
- }
- }
- elsif ($outfile =~ /^>&(STDERR|2)$/i) {
- ## Not a filename, just a string implying STDERR
- $myData{_OUTFILE} = '<standard error>';
- $out_fh = \*STDERR;
- }
- else {
- ## We have a filename, open it for writing
- $myData{_OUTFILE} = $outfile;
- (-d $outfile) and croak "$outfile is a directory, not POD input!\n";
- open($out_fh, "> $outfile") or
- croak "Can't open $outfile for writing: $!\n";
- $close_output = 1;
- }
-
- ## Whew! That was a lot of work to set up reasonably/robust behavior
- ## in the case of a non-filename for reading and writing. Now we just
- ## have to parse the input and close the handles when we're finished.
- $self->parse_from_filehandle(\%opts, $in_fh, $out_fh);
-
- $close_input and
- close($in_fh) || croak "Can't close $infile after reading: $!\n";
- $close_output and
- close($out_fh) || croak "Can't close $outfile after writing: $!\n";
-}
-
-#############################################################################
-
-=head1 ACCESSOR METHODS
-
-Clients of B<Pod::Parser> should use the following methods to access
-instance data fields:
-
-=cut
-
-##---------------------------------------------------------------------------
-
-=head1 B<errorsub()>
-
- $parser->errorsub("method_name");
- $parser->errorsub(\&warn_user);
- $parser->errorsub(sub { print STDERR, @_ });
-
-Specifies the method or subroutine to use when printing error messages
-about POD syntax. The supplied method/subroutine I<must> return TRUE upon
-successful printing of the message. If C<undef> is given, then the B<carp>
-builtin is used to issue error messages (this is the default behavior).
-
- my $errorsub = $parser->errorsub()
- my $errmsg = "This is an error message!\n"
- (ref $errorsub) and &{$errorsub}($errmsg)
- or (defined $errorsub) and $parser->$errorsub($errmsg)
- or carp($errmsg);
-
-Returns a method name, or else a reference to the user-supplied subroutine
-used to print error messages. Returns C<undef> if the B<carp> builtin
-is used to issue error messages (this is the default behavior).
-
-=cut
-
-sub errorsub {
- return (@_ > 1) ? ($_[0]->{_ERRORSUB} = $_[1]) : $_[0]->{_ERRORSUB};
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<cutting()>
-
- $boolean = $parser->cutting();
-
-Returns the current C<cutting> state: a boolean-valued scalar which
-evaluates to true if text from the input file is currently being "cut"
-(meaning it is I<not> considered part of the POD document).
-
- $parser->cutting($boolean);
-
-Sets the current C<cutting> state to the given value and returns the
-result.
-
-=cut
-
-sub cutting {
- return (@_ > 1) ? ($_[0]->{_CUTTING} = $_[1]) : $_[0]->{_CUTTING};
-}
-
-##---------------------------------------------------------------------------
-
-##---------------------------------------------------------------------------
-
-=head1 B<parseopts()>
-
-When invoked with no additional arguments, B<parseopts> returns a hashtable
-of all the current parsing options.
-
- ## See if we are parsing non-POD sections as well as POD ones
- my %opts = $parser->parseopts();
- $opts{'-want_nonPODs}' and print "-want_nonPODs\n";
-
-When invoked using a single string, B<parseopts> treats the string as the
-name of a parse-option and returns its corresponding value if it exists
-(returns C<undef> if it doesn't).
-
- ## Did we ask to see '=cut' paragraphs?
- my $want_cut = $parser->parseopts('-process_cut_cmd');
- $want_cut and print "-process_cut_cmd\n";
-
-When invoked with multiple arguments, B<parseopts> treats them as
-key/value pairs and the specified parse-option names are set to the
-given values. Any unspecified parse-options are unaffected.
-
- ## Set them back to the default
- $parser->parseopts(-warnings => 0);
-
-When passed a single hash-ref, B<parseopts> uses that hash to completely
-reset the existing parse-options, all previous parse-option values
-are lost.
-
- ## Reset all options to default
- $parser->parseopts( { } );
-
-See L<"PARSING OPTIONS"> for more information on the name and meaning of each
-parse-option currently recognized.
-
-=cut
-
-sub parseopts {
- local *myData = shift;
- local *myOpts = ($myData{_PARSEOPTS} ||= {});
- return %myOpts if (@_ == 0);
- if (@_ == 1) {
- local $_ = shift;
- return ref($_) ? $myData{_PARSEOPTS} = $_ : $myOpts{$_};
- }
- my @newOpts = (%myOpts, @_);
- $myData{_PARSEOPTS} = { @newOpts };
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<output_file()>
-
- $fname = $parser->output_file();
-
-Returns the name of the output file being written.
-
-=cut
-
-sub output_file {
- return $_[0]->{_OUTFILE};
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<output_handle()>
-
- $fhandle = $parser->output_handle();
-
-Returns the output filehandle object.
-
-=cut
-
-sub output_handle {
- return $_[0]->{_OUTPUT};
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<input_file()>
-
- $fname = $parser->input_file();
-
-Returns the name of the input file being read.
-
-=cut
-
-sub input_file {
- return $_[0]->{_INFILE};
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<input_handle()>
-
- $fhandle = $parser->input_handle();
-
-Returns the current input filehandle object.
-
-=cut
-
-sub input_handle {
- return $_[0]->{_INPUT};
-}
-
-##---------------------------------------------------------------------------
-
-=begin __PRIVATE__
-
-=head1 B<input_streams()>
-
- $listref = $parser->input_streams();
-
-Returns a reference to an array which corresponds to the stack of all
-the input streams that are currently in the middle of being parsed.
-
-While parsing an input stream, it is possible to invoke
-B<parse_from_file()> or B<parse_from_filehandle()> to parse a new input
-stream and then return to parsing the previous input stream. Each input
-stream to be parsed is pushed onto the end of this input stack
-before any of its input is read. The input stream that is currently
-being parsed is always at the end (or top) of the input stack. When an
-input stream has been exhausted, it is popped off the end of the
-input stack.
-
-Each element on this input stack is a reference to C<Pod::InputSource>
-object. Please see L<Pod::InputObjects> for more details.
-
-This method might be invoked when printing diagnostic messages, for example,
-to obtain the name and line number of the all input files that are currently
-being processed.
-
-=end __PRIVATE__
-
-=cut
-
-sub input_streams {
- return $_[0]->{_INPUT_STREAMS};
-}
-
-##---------------------------------------------------------------------------
-
-=begin __PRIVATE__
-
-=head1 B<top_stream()>
-
- $hashref = $parser->top_stream();
-
-Returns a reference to the hash-table that represents the element
-that is currently at the top (end) of the input stream stack
-(see L<"input_streams()">). The return value will be the C<undef>
-if the input stack is empty.
-
-This method might be used when printing diagnostic messages, for example,
-to obtain the name and line number of the current input file.
-
-=end __PRIVATE__
-
-=cut
-
-sub top_stream {
- return $_[0]->{_TOP_STREAM} || undef;
-}
-
-#############################################################################
-
-=head1 PRIVATE METHODS AND DATA
-
-B<Pod::Parser> makes use of several internal methods and data fields
-which clients should not need to see or use. For the sake of avoiding
-name collisions for client data and methods, these methods and fields
-are briefly discussed here. Determined hackers may obtain further
-information about them by reading the B<Pod::Parser> source code.
-
-Private data fields are stored in the hash-object whose reference is
-returned by the B<new()> constructor for this class. The names of all
-private methods and data-fields used by B<Pod::Parser> begin with a
-prefix of "_" and match the regular expression C</^_\w+$/>.
-
-=cut
-
-##---------------------------------------------------------------------------
-
-=begin _PRIVATE_
-
-=head1 B<_push_input_stream()>
-
- $hashref = $parser->_push_input_stream($in_fh,$out_fh);
-
-This method will push the given input stream on the input stack and
-perform any necessary beginning-of-document or beginning-of-file
-processing. The argument C<$in_fh> is the input stream filehandle to
-push, and C<$out_fh> is the corresponding output filehandle to use (if
-it is not given or is undefined, then the current output stream is used,
-which defaults to standard output if it doesnt exist yet).
-
-The value returned will be reference to the hash-table that represents
-the new top of the input stream stack. I<Please Note> that it is
-possible for this method to use default values for the input and output
-file handles. If this happens, you will need to look at the C<INPUT>
-and C<OUTPUT> instance data members to determine their new values.
-
-=end _PRIVATE_
-
-=cut
-
-sub _push_input_stream {
- my ($self, $in_fh, $out_fh) = @_;
- local *myData = $self;
-
- ## Initialize stuff for the entire document if this is *not*
- ## an included file.
- ##
- ## NOTE: we need to be *very* careful when "defaulting" the output
- ## filehandle. We only want to use a default value if this is the
- ## beginning of the entire document (but *not* if this is an included
- ## file).
- unless (defined $myData{_TOP_STREAM}) {
- $out_fh = \*STDOUT unless (defined $out_fh);
- $myData{_CUTTING} = 1; ## current "cutting" state
- $myData{_INPUT_STREAMS} = []; ## stack of all input streams
- }
-
- ## Initialize input indicators
- $myData{_OUTFILE} = '(unknown)' unless (defined $myData{_OUTFILE});
- $myData{_OUTPUT} = $out_fh if (defined $out_fh);
- $in_fh = \*STDIN unless (defined $in_fh);
- $myData{_INFILE} = '(unknown)' unless (defined $myData{_INFILE});
- $myData{_INPUT} = $in_fh;
- my $input_top = $myData{_TOP_STREAM}
- = new Pod::InputSource(
- -name => $myData{_INFILE},
- -handle => $in_fh,
- -was_cutting => $myData{_CUTTING}
- );
- local *input_stack = $myData{_INPUT_STREAMS};
- push(@input_stack, $input_top);
-
- ## Perform beginning-of-document and/or beginning-of-input processing
- $self->begin_pod() if (@input_stack == 1);
- $self->begin_input();
-
- return $input_top;
-}
-
-##---------------------------------------------------------------------------
-
-=begin _PRIVATE_
-
-=head1 B<_pop_input_stream()>
-
- $hashref = $parser->_pop_input_stream();
-
-This takes no arguments. It will perform any necessary end-of-file or
-end-of-document processing and then pop the current input stream from
-the top of the input stack.
-
-The value returned will be reference to the hash-table that represents
-the new top of the input stream stack.
-
-=end _PRIVATE_
-
-=cut
-
-sub _pop_input_stream {
- my ($self) = @_;
- local *myData = $self;
- local *input_stack = $myData{_INPUT_STREAMS};
-
- ## Perform end-of-input and/or end-of-document processing
- $self->end_input() if (@input_stack > 0);
- $self->end_pod() if (@input_stack == 1);
-
- ## Restore cutting state to whatever it was before we started
- ## parsing this file.
- my $old_top = pop(@input_stack);
- $myData{_CUTTING} = $old_top->was_cutting();
-
- ## Dont forget to reset the input indicators
- my $input_top = undef;
- if (@input_stack > 0) {
- $input_top = $myData{_TOP_STREAM} = $input_stack[-1];
- $myData{_INFILE} = $input_top->name();
- $myData{_INPUT} = $input_top->handle();
- } else {
- delete $myData{_TOP_STREAM};
- delete $myData{_INPUT_STREAMS};
- }
-
- return $input_top;
-}
-
-#############################################################################
-
-=head1 TREE-BASED PARSING
-
-If straightforward stream-based parsing wont meet your needs (as is
-likely the case for tasks such as translating PODs into structured
-markup languages like HTML and XML) then you may need to take the
-tree-based approach. Rather than doing everything in one pass and
-calling the B<interpolate()> method to expand sequences into text, it
-may be desirable to instead create a parse-tree using the B<parse_text()>
-method to return a tree-like structure which may contain an ordered
-list of children (each of which may be a text-string, or a similar
-tree-like structure).
-
-Pay special attention to L<"METHODS FOR PARSING AND PROCESSING"> and
-to the objects described in L<Pod::InputObjects>. The former describes
-the gory details and parameters for how to customize and extend the
-parsing behavior of B<Pod::Parser>. B<Pod::InputObjects> provides
-several objects that may all be used interchangeably as parse-trees. The
-most obvious one is the B<Pod::ParseTree> object. It defines the basic
-interface and functionality that all things trying to be a POD parse-tree
-should do. A B<Pod::ParseTree> is defined such that each "node" may be a
-text-string, or a reference to another parse-tree. Each B<Pod::Paragraph>
-object and each B<Pod::InteriorSequence> object also supports the basic
-parse-tree interface.
-
-The B<parse_text()> method takes a given paragraph of text, and
-returns a parse-tree that contains one or more children, each of which
-may be a text-string, or an InteriorSequence object. There are also
-callback-options that may be passed to B<parse_text()> to customize
-the way it expands or transforms interior-sequences, as well as the
-returned result. These callbacks can be used to create a parse-tree
-with custom-made objects (which may or may not support the parse-tree
-interface, depending on how you choose to do it).
-
-If you wish to turn an entire POD document into a parse-tree, that process
-is fairly straightforward. The B<parse_text()> method is the key to doing
-this successfully. Every paragraph-callback (i.e. the polymorphic methods
-for B<command()>, B<verbatim()>, and B<textblock()> paragraphs) takes
-a B<Pod::Paragraph> object as an argument. Each paragraph object has a
-B<parse_tree()> method that can be used to get or set a corresponding
-parse-tree. So for each of those paragraph-callback methods, simply call
-B<parse_text()> with the options you desire, and then use the returned
-parse-tree to assign to the given paragraph object.
-
-That gives you a parse-tree for each paragraph - so now all you need is
-an ordered list of paragraphs. You can maintain that yourself as a data
-element in the object/hash. The most straightforward way would be simply
-to use an array-ref, with the desired set of custom "options" for each
-invocation of B<parse_text>. Let's assume the desired option-set is
-given by the hash C<%options>. Then we might do something like the
-following:
-
- package MyPodParserTree;
-
- @ISA = qw( Pod::Parser );
-
- ...
-
- sub begin_pod {
- my $self = shift;
- $self->{'-paragraphs'} = []; ## initialize paragraph list
- }
-
- sub command {
- my ($parser, $command, $paragraph, $line_num, $pod_para) = @_;
- my $ptree = $parser->parse_text({%options}, $paragraph, ...);
- $pod_para->parse_tree( $ptree );
- push @{ $self->{'-paragraphs'} }, $pod_para;
- }
-
- sub verbatim {
- my ($parser, $paragraph, $line_num, $pod_para) = @_;
- push @{ $self->{'-paragraphs'} }, $pod_para;
- }
-
- sub textblock {
- my ($parser, $paragraph, $line_num, $pod_para) = @_;
- my $ptree = $parser->parse_text({%options}, $paragraph, ...);
- $pod_para->parse_tree( $ptree );
- push @{ $self->{'-paragraphs'} }, $pod_para;
- }
-
- ...
-
- package main;
- ...
- my $parser = new MyPodParserTree(...);
- $parser->parse_from_file(...);
- my $paragraphs_ref = $parser->{'-paragraphs'};
-
-Of course, in this module-author's humble opinion, I'd be more inclined to
-use the existing B<Pod::ParseTree> object than a simple array. That way
-everything in it, paragraphs and sequences, all respond to the same core
-interface for all parse-tree nodes. The result would look something like:
-
- package MyPodParserTree2;
-
- ...
-
- sub begin_pod {
- my $self = shift;
- $self->{'-ptree'} = new Pod::ParseTree; ## initialize parse-tree
- }
-
- sub parse_tree {
- ## convenience method to get/set the parse-tree for the entire POD
- (@_ > 1) and $_[0]->{'-ptree'} = $_[1];
- return $_[0]->{'-ptree'};
- }
-
- sub command {
- my ($parser, $command, $paragraph, $line_num, $pod_para) = @_;
- my $ptree = $parser->parse_text({<<options>>}, $paragraph, ...);
- $pod_para->parse_tree( $ptree );
- $parser->parse_tree()->append( $pod_para );
- }
-
- sub verbatim {
- my ($parser, $paragraph, $line_num, $pod_para) = @_;
- $parser->parse_tree()->append( $pod_para );
- }
-
- sub textblock {
- my ($parser, $paragraph, $line_num, $pod_para) = @_;
- my $ptree = $parser->parse_text({<<options>>}, $paragraph, ...);
- $pod_para->parse_tree( $ptree );
- $parser->parse_tree()->append( $pod_para );
- }
-
- ...
-
- package main;
- ...
- my $parser = new MyPodParserTree2(...);
- $parser->parse_from_file(...);
- my $ptree = $parser->parse_tree;
- ...
-
-Now you have the entire POD document as one great big parse-tree. You
-can even use the B<-expand_seq> option to B<parse_text> to insert
-whole different kinds of objects. Just don't expect B<Pod::Parser>
-to know what to do with them after that. That will need to be in your
-code. Or, alternatively, you can insert any object you like so long as
-it conforms to the B<Pod::ParseTree> interface.
-
-One could use this to create subclasses of B<Pod::Paragraphs> and
-B<Pod::InteriorSequences> for specific commands (or to create your own
-custom node-types in the parse-tree) and add some kind of B<emit()>
-method to each custom node/subclass object in the tree. Then all you'd
-need to do is recursively walk the tree in the desired order, processing
-the children (most likely from left to right) by formatting them if
-they are text-strings, or by calling their B<emit()> method if they
-are objects/references.
-
-=head1 CAVEATS
-
-Please note that POD has the notion of "paragraphs": this is something
-starting I<after> a blank (read: empty) line, with the single exception
-of the file start, which is also starting a paragraph. That means that
-especially a command (e.g. C<=head1>) I<must> be preceded with a blank
-line; C<__END__> is I<not> a blank line.
-
-=head1 SEE ALSO
-
-L<Pod::InputObjects>, L<Pod::Select>
-
-B<Pod::InputObjects> defines POD input objects corresponding to
-command paragraphs, parse-trees, and interior-sequences.
-
-B<Pod::Select> is a subclass of B<Pod::Parser> which provides the ability
-to selectively include and/or exclude sections of a POD document from being
-translated based upon the current heading, subheading, subsubheading, etc.
-
-=for __PRIVATE__
-B<Pod::Callbacks> is a subclass of B<Pod::Parser> which gives its users
-the ability the employ I<callback functions> instead of, or in addition
-to, overriding methods of the base class.
-
-=for __PRIVATE__
-B<Pod::Select> and B<Pod::Callbacks> do not override any
-methods nor do they define any new methods with the same name. Because
-of this, they may I<both> be used (in combination) as a base class of
-the same subclass in order to combine their functionality without
-causing any namespace clashes due to multiple inheritance.
-
-=head1 AUTHOR
-
-Please report bugs using L<http://rt.cpan.org>.
-
-Brad Appleton E<lt>bradapp@enteract.comE<gt>
-
-Based on code for B<Pod::Text> written by
-Tom Christiansen E<lt>tchrist@mox.perl.comE<gt>
-
-=head1 LICENSE
-
-Pod-Parser is free software; you can redistribute it and/or modify it
-under the terms of the Artistic License distributed with Perl version
-5.000 or (at your option) any later version. Please refer to the
-Artistic License that came with your Perl distribution for more
-details. If your version of Perl was not distributed under the
-terms of the Artistic License, than you may distribute PodParser
-under the same terms as Perl itself.
-
-=cut
-
-1;
-# vim: ts=4 sw=4 et
diff --git a/src/lib/mrtg2/Pod/PlainText.pm b/src/lib/mrtg2/Pod/PlainText.pm
deleted file mode 100644
index 0dce179..0000000
--- a/src/lib/mrtg2/Pod/PlainText.pm
+++ /dev/null
@@ -1,738 +0,0 @@
-# Pod::PlainText -- Convert POD data to formatted ASCII text.
-# $Id: Text.pm,v 2.1 1999/09/20 11:53:33 eagle Exp $
-#
-# Copyright 1999-2000 by Russ Allbery <rra@stanford.edu>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the same terms as Perl itself.
-#
-# This module is intended to be a replacement for Pod::Text, and attempts to
-# match its output except for some specific circumstances where other
-# decisions seemed to produce better output. It uses Pod::Parser and is
-# designed to be very easy to subclass.
-
-############################################################################
-# Modules and declarations
-############################################################################
-
-package Pod::PlainText;
-use strict;
-
-require 5.005;
-
-use Carp qw(carp croak);
-use Pod::Select ();
-
-use vars qw(@ISA %ESCAPES $VERSION);
-
-# We inherit from Pod::Select instead of Pod::Parser so that we can be used
-# by Pod::Usage.
-@ISA = qw(Pod::Select);
-
-$VERSION = '2.04';
-
-BEGIN {
- if ($] < 5.006) {
- require Symbol;
- import Symbol;
- }
-}
-
-############################################################################
-# Table of supported E<> escapes
-############################################################################
-
-# This table is taken near verbatim from Pod::PlainText in Pod::Parser,
-# which got it near verbatim from the original Pod::Text. It is therefore
-# credited to Tom Christiansen, and I'm glad I didn't have to write it. :)
-%ESCAPES = (
- 'amp' => '&', # ampersand
- 'lt' => '<', # left chevron, less-than
- 'gt' => '>', # right chevron, greater-than
- 'quot' => '"', # double quote
-
- "Aacute" => "\xC1", # capital A, acute accent
- "aacute" => "\xE1", # small a, acute accent
- "Acirc" => "\xC2", # capital A, circumflex accent
- "acirc" => "\xE2", # small a, circumflex accent
- "AElig" => "\xC6", # capital AE diphthong (ligature)
- "aelig" => "\xE6", # small ae diphthong (ligature)
- "Agrave" => "\xC0", # capital A, grave accent
- "agrave" => "\xE0", # small a, grave accent
- "Aring" => "\xC5", # capital A, ring
- "aring" => "\xE5", # small a, ring
- "Atilde" => "\xC3", # capital A, tilde
- "atilde" => "\xE3", # small a, tilde
- "Auml" => "\xC4", # capital A, dieresis or umlaut mark
- "auml" => "\xE4", # small a, dieresis or umlaut mark
- "Ccedil" => "\xC7", # capital C, cedilla
- "ccedil" => "\xE7", # small c, cedilla
- "Eacute" => "\xC9", # capital E, acute accent
- "eacute" => "\xE9", # small e, acute accent
- "Ecirc" => "\xCA", # capital E, circumflex accent
- "ecirc" => "\xEA", # small e, circumflex accent
- "Egrave" => "\xC8", # capital E, grave accent
- "egrave" => "\xE8", # small e, grave accent
- "ETH" => "\xD0", # capital Eth, Icelandic
- "eth" => "\xF0", # small eth, Icelandic
- "Euml" => "\xCB", # capital E, dieresis or umlaut mark
- "euml" => "\xEB", # small e, dieresis or umlaut mark
- "Iacute" => "\xCD", # capital I, acute accent
- "iacute" => "\xED", # small i, acute accent
- "Icirc" => "\xCE", # capital I, circumflex accent
- "icirc" => "\xEE", # small i, circumflex accent
- "Igrave" => "\xCD", # capital I, grave accent
- "igrave" => "\xED", # small i, grave accent
- "Iuml" => "\xCF", # capital I, dieresis or umlaut mark
- "iuml" => "\xEF", # small i, dieresis or umlaut mark
- "Ntilde" => "\xD1", # capital N, tilde
- "ntilde" => "\xF1", # small n, tilde
- "Oacute" => "\xD3", # capital O, acute accent
- "oacute" => "\xF3", # small o, acute accent
- "Ocirc" => "\xD4", # capital O, circumflex accent
- "ocirc" => "\xF4", # small o, circumflex accent
- "Ograve" => "\xD2", # capital O, grave accent
- "ograve" => "\xF2", # small o, grave accent
- "Oslash" => "\xD8", # capital O, slash
- "oslash" => "\xF8", # small o, slash
- "Otilde" => "\xD5", # capital O, tilde
- "otilde" => "\xF5", # small o, tilde
- "Ouml" => "\xD6", # capital O, dieresis or umlaut mark
- "ouml" => "\xF6", # small o, dieresis or umlaut mark
- "szlig" => "\xDF", # small sharp s, German (sz ligature)
- "THORN" => "\xDE", # capital THORN, Icelandic
- "thorn" => "\xFE", # small thorn, Icelandic
- "Uacute" => "\xDA", # capital U, acute accent
- "uacute" => "\xFA", # small u, acute accent
- "Ucirc" => "\xDB", # capital U, circumflex accent
- "ucirc" => "\xFB", # small u, circumflex accent
- "Ugrave" => "\xD9", # capital U, grave accent
- "ugrave" => "\xF9", # small u, grave accent
- "Uuml" => "\xDC", # capital U, dieresis or umlaut mark
- "uuml" => "\xFC", # small u, dieresis or umlaut mark
- "Yacute" => "\xDD", # capital Y, acute accent
- "yacute" => "\xFD", # small y, acute accent
- "yuml" => "\xFF", # small y, dieresis or umlaut mark
-
- "lchevron" => "\xAB", # left chevron (double less than)
- "rchevron" => "\xBB", # right chevron (double greater than)
-);
-
-
-############################################################################
-# Initialization
-############################################################################
-
-# Initialize the object. Must be sure to call our parent initializer.
-sub initialize {
- my $self = shift;
-
- $$self{alt} = 0 unless defined $$self{alt};
- $$self{indent} = 4 unless defined $$self{indent};
- $$self{loose} = 0 unless defined $$self{loose};
- $$self{sentence} = 0 unless defined $$self{sentence};
- $$self{width} = 76 unless defined $$self{width};
-
- $$self{INDENTS} = []; # Stack of indentations.
- $$self{MARGIN} = $$self{indent}; # Current left margin in spaces.
-
- return $self->SUPER::initialize;
-}
-
-
-############################################################################
-# Core overrides
-############################################################################
-
-# Called for each command paragraph. Gets the command, the associated
-# paragraph, the line number, and a Pod::Paragraph object. Just dispatches
-# the command to a method named the same as the command. =cut is handled
-# internally by Pod::Parser.
-sub command {
- my $self = shift;
- my $command = shift;
- return if $command eq 'pod';
- return if ($$self{EXCLUDE} && $command ne 'end');
- if (defined $$self{ITEM}) {
- $self->item ("\n");
- local $_ = "\n";
- $self->output($_) if($command eq 'back');
- }
- $command = 'cmd_' . $command;
- return $self->$command (@_);
-}
-
-# Called for a verbatim paragraph. Gets the paragraph, the line number, and
-# a Pod::Paragraph object. Just output it verbatim, but with tabs converted
-# to spaces.
-sub verbatim {
- my $self = shift;
- return if $$self{EXCLUDE};
- $self->item if defined $$self{ITEM};
- local $_ = shift;
- return if /^\s*$/;
- s/^(\s*\S+)/(' ' x $$self{MARGIN}) . $1/gme;
- return $self->output($_);
-}
-
-# Called for a regular text block. Gets the paragraph, the line number, and
-# a Pod::Paragraph object. Perform interpolation and output the results.
-sub textblock {
- my $self = shift;
- return if $$self{EXCLUDE};
- if($$self{VERBATIM}) {
- $self->output($_[0]);
- return;
- }
- local $_ = shift;
- my $line = shift;
-
- # Perform a little magic to collapse multiple L<> references. This is
- # here mostly for backwards-compatibility. We'll just rewrite the whole
- # thing into actual text at this part, bypassing the whole internal
- # sequence parsing thing.
- s{
- (
- L< # A link of the form L</something>.
- /
- (
- [:\w]+ # The item has to be a simple word...
- (\(\))? # ...or simple function.
- )
- >
- (
- ,?\s+(and\s+)? # Allow lots of them, conjuncted.
- L<
- /
- (
- [:\w]+
- (\(\))?
- )
- >
- )+
- )
- } {
- local $_ = $1;
- s%L</([^>]+)>%$1%g;
- my @items = split /(?:,?\s+(?:and\s+)?)/;
- my $string = "the ";
- my $i;
- for ($i = 0; $i < @items; $i++) {
- $string .= $items[$i];
- $string .= ", " if @items > 2 && $i != $#items;
- $string .= " and " if ($i == $#items - 1);
- }
- $string .= " entries elsewhere in this document";
- $string;
- }gex;
-
- # Now actually interpolate and output the paragraph.
- $_ = $self->interpolate ($_, $line);
- s/\s*$/\n/s;
- if (defined $$self{ITEM}) {
- $self->item ($_ . "\n");
- } else {
- $self->output ($self->reformat ($_ . "\n"));
- }
-}
-
-# Called for an interior sequence. Gets the command, argument, and a
-# Pod::InteriorSequence object and is expected to return the resulting text.
-# Calls code, bold, italic, file, and link to handle those types of
-# sequences, and handles S<>, E<>, X<>, and Z<> directly.
-sub interior_sequence {
- my $self = shift;
- my $command = shift;
- local $_ = shift;
- return '' if ($command eq 'X' || $command eq 'Z');
-
- # Expand escapes into the actual character now, carping if invalid.
- if ($command eq 'E') {
- return $ESCAPES{$_} if defined $ESCAPES{$_};
- carp "Unknown escape: E<$_>";
- return "E<$_>";
- }
-
- # For all the other sequences, empty content produces no output.
- return if $_ eq '';
-
- # For S<>, compress all internal whitespace and then map spaces to \01.
- # When we output the text, we'll map this back.
- if ($command eq 'S') {
- s/\s{2,}/ /g;
- tr/ /\01/;
- return $_;
- }
-
- # Anything else needs to get dispatched to another method.
- if ($command eq 'B') { return $self->seq_b ($_) }
- elsif ($command eq 'C') { return $self->seq_c ($_) }
- elsif ($command eq 'F') { return $self->seq_f ($_) }
- elsif ($command eq 'I') { return $self->seq_i ($_) }
- elsif ($command eq 'L') { return $self->seq_l ($_) }
- else { carp "Unknown sequence $command<$_>" }
-}
-
-# Called for each paragraph that's actually part of the POD. We take
-# advantage of this opportunity to untabify the input.
-sub preprocess_paragraph {
- my $self = shift;
- local $_ = shift;
- 1 while s/^(.*?)(\t+)/$1 . ' ' x (length ($2) * 8 - length ($1) % 8)/me;
- return $_;
-}
-
-
-############################################################################
-# Command paragraphs
-############################################################################
-
-# All command paragraphs take the paragraph and the line number.
-
-# First level heading.
-sub cmd_head1 {
- my $self = shift;
- local $_ = shift;
- s/\s+$//s;
- $_ = $self->interpolate ($_, shift);
- if ($$self{alt}) {
- $self->output ("\n==== $_ ====\n\n");
- } else {
- $_ .= "\n" if $$self{loose};
- $self->output ($_ . "\n");
- }
-}
-
-# Second level heading.
-sub cmd_head2 {
- my $self = shift;
- local $_ = shift;
- s/\s+$//s;
- $_ = $self->interpolate ($_, shift);
- if ($$self{alt}) {
- $self->output ("\n== $_ ==\n\n");
- } else {
- $_ .= "\n" if $$self{loose};
- $self->output (' ' x ($$self{indent} / 2) . $_ . "\n");
- }
-}
-
-# third level heading - not strictly perlpodspec compliant
-sub cmd_head3 {
- my $self = shift;
- local $_ = shift;
- s/\s+$//s;
- $_ = $self->interpolate ($_, shift);
- if ($$self{alt}) {
- $self->output ("\n= $_ =\n");
- } else {
- $_ .= "\n" if $$self{loose};
- $self->output (' ' x ($$self{indent}) . $_ . "\n");
- }
-}
-
-# fourth level heading - not strictly perlpodspec compliant
-# just like head3
-*cmd_head4 = \&cmd_head3;
-
-# Start a list.
-sub cmd_over {
- my $self = shift;
- local $_ = shift;
- unless (/^[-+]?\d+\s+$/) { $_ = $$self{indent} }
- push (@{ $$self{INDENTS} }, $$self{MARGIN});
- $$self{MARGIN} += ($_ + 0);
-}
-
-# End a list.
-sub cmd_back {
- my $self = shift;
- $$self{MARGIN} = pop @{ $$self{INDENTS} };
- unless (defined $$self{MARGIN}) {
- carp 'Unmatched =back';
- $$self{MARGIN} = $$self{indent};
- }
-}
-
-# An individual list item.
-sub cmd_item {
- my $self = shift;
- if (defined $$self{ITEM}) { $self->item }
- local $_ = shift;
- s/\s+$//s;
- $$self{ITEM} = $self->interpolate ($_);
-}
-
-# Begin a block for a particular translator. Setting VERBATIM triggers
-# special handling in textblock().
-sub cmd_begin {
- my $self = shift;
- local $_ = shift;
- my ($kind) = /^(\S+)/ or return;
- if ($kind eq 'text') {
- $$self{VERBATIM} = 1;
- } else {
- $$self{EXCLUDE} = 1;
- }
-}
-
-# End a block for a particular translator. We assume that all =begin/=end
-# pairs are properly closed.
-sub cmd_end {
- my $self = shift;
- $$self{EXCLUDE} = 0;
- $$self{VERBATIM} = 0;
-}
-
-# One paragraph for a particular translator. Ignore it unless it's intended
-# for text, in which case we treat it as a verbatim text block.
-sub cmd_for {
- my $self = shift;
- local $_ = shift;
- my $line = shift;
- return unless s/^text\b[ \t]*\n?//;
- $self->verbatim ($_, $line);
-}
-
-
-############################################################################
-# Interior sequences
-############################################################################
-
-# The simple formatting ones. These are here mostly so that subclasses can
-# override them and do more complicated things.
-sub seq_b { return $_[0]{alt} ? "``$_[1]''" : $_[1] }
-sub seq_c { return $_[0]{alt} ? "``$_[1]''" : "`$_[1]'" }
-sub seq_f { return $_[0]{alt} ? "\"$_[1]\"" : $_[1] }
-sub seq_i { return '*' . $_[1] . '*' }
-
-# The complicated one. Handle links. Since this is plain text, we can't
-# actually make any real links, so this is all to figure out what text we
-# print out.
-sub seq_l {
- my $self = shift;
- local $_ = shift;
-
- # Smash whitespace in case we were split across multiple lines.
- s/\s+/ /g;
-
- # If we were given any explicit text, just output it.
- if (/^([^|]+)\|/) { return $1 }
-
- # Okay, leading and trailing whitespace isn't important; get rid of it.
- s/^\s+//;
- s/\s+$//;
-
- # Default to using the whole content of the link entry as a section
- # name. Note that L<manpage/> forces a manpage interpretation, as does
- # something looking like L<manpage(section)>. The latter is an
- # enhancement over the original Pod::Text.
- my ($manpage, $section) = ('', $_);
- if (/^(?:https?|ftp|news):/) {
- # a URL
- return $_;
- } elsif (/^"\s*(.*?)\s*"$/) {
- $section = '"' . $1 . '"';
- } elsif (m/^[-:.\w]+(?:\(\S+\))?$/) {
- ($manpage, $section) = ($_, '');
- } elsif (m{/}) {
- ($manpage, $section) = split (/\s*\/\s*/, $_, 2);
- }
-
- my $text = '';
- # Now build the actual output text.
- if (!length $section) {
- $text = "the $manpage manpage" if length $manpage;
- } elsif ($section =~ /^[:\w]+(?:\(\))?/) {
- $text .= 'the ' . $section . ' entry';
- $text .= (length $manpage) ? " in the $manpage manpage"
- : ' elsewhere in this document';
- } else {
- $section =~ s/^\"\s*//;
- $section =~ s/\s*\"$//;
- $text .= 'the section on "' . $section . '"';
- $text .= " in the $manpage manpage" if length $manpage;
- }
- return $text;
-}
-
-
-############################################################################
-# List handling
-############################################################################
-
-# This method is called whenever an =item command is complete (in other
-# words, we've seen its associated paragraph or know for certain that it
-# doesn't have one). It gets the paragraph associated with the item as an
-# argument. If that argument is empty, just output the item tag; if it
-# contains a newline, output the item tag followed by the newline.
-# Otherwise, see if there's enough room for us to output the item tag in the
-# margin of the text or if we have to put it on a separate line.
-sub item {
- my $self = shift;
- local $_ = shift;
- my $tag = $$self{ITEM};
- unless (defined $tag) {
- carp 'item called without tag';
- return;
- }
- undef $$self{ITEM};
- my $indent = $$self{INDENTS}[-1];
- unless (defined $indent) { $indent = $$self{indent} }
- my $space = ' ' x $indent;
- $space =~ s/^ /:/ if $$self{alt};
- if (!$_ || /^\s+$/ || ($$self{MARGIN} - $indent < length ($tag) + 1)) {
- my $margin = $$self{MARGIN};
- $$self{MARGIN} = $indent;
- my $output = $self->reformat ($tag);
- $output =~ s/\n*$/\n/;
- $self->output ($output);
- $$self{MARGIN} = $margin;
- $self->output ($self->reformat ($_)) if /\S/;
- } else {
- $_ = $self->reformat ($_);
- s/^ /:/ if ($$self{alt} && $indent > 0);
- my $tagspace = ' ' x length $tag;
- s/^($space)$tagspace/$1$tag/ or carp 'Bizarre space in item';
- $self->output ($_);
- }
-}
-
-
-############################################################################
-# Output formatting
-############################################################################
-
-# Wrap a line, indenting by the current left margin. We can't use
-# Text::Wrap because it plays games with tabs. We can't use formline, even
-# though we'd really like to, because it screws up non-printing characters.
-# So we have to do the wrapping ourselves.
-sub wrap {
- my $self = shift;
- local $_ = shift;
- my $output = '';
- my $spaces = ' ' x $$self{MARGIN};
- my $width = $$self{width} - $$self{MARGIN};
- while (length > $width) {
- if (s/^([^\n]{0,$width})\s+// || s/^([^\n]{$width})//) {
- $output .= $spaces . $1 . "\n";
- } else {
- last;
- }
- }
- $output .= $spaces . $_;
- $output =~ s/\s+$/\n\n/;
- return $output;
-}
-
-# Reformat a paragraph of text for the current margin. Takes the text to
-# reformat and returns the formatted text.
-sub reformat {
- my $self = shift;
- local $_ = shift;
-
- # If we're trying to preserve two spaces after sentences, do some
- # munging to support that. Otherwise, smash all repeated whitespace.
- if ($$self{sentence}) {
- s/ +$//mg;
- s/\.\n/. \n/g;
- s/\n/ /g;
- s/ +/ /g;
- } else {
- s/\s+/ /g;
- }
- return $self->wrap($_);
-}
-
-# Output text to the output device.
-sub output { $_[1] =~ tr/\01/ /; print { $_[0]->output_handle } $_[1] }
-
-
-############################################################################
-# Backwards compatibility
-############################################################################
-
-# The old Pod::Text module did everything in a pod2text() function. This
-# tries to provide the same interface for legacy applications.
-sub pod2text {
- my @args;
-
- # This is really ugly; I hate doing option parsing in the middle of a
- # module. But the old Pod::Text module supported passing flags to its
- # entry function, so handle -a and -<number>.
- while ($_[0] =~ /^-/) {
- my $flag = shift;
- if ($flag eq '-a') { push (@args, alt => 1) }
- elsif ($flag =~ /^-(\d+)$/) { push (@args, width => $1) }
- else {
- unshift (@_, $flag);
- last;
- }
- }
-
- # Now that we know what arguments we're using, create the parser.
- my $parser = Pod::PlainText->new (@args);
-
- # If two arguments were given, the second argument is going to be a file
- # handle. That means we want to call parse_from_filehandle(), which
- # means we need to turn the first argument into a file handle. Magic
- # open will handle the <&STDIN case automagically.
- if (defined $_[1]) {
- my $infh;
- if ($] < 5.006) {
- $infh = gensym();
- }
- unless (open ($infh, $_[0])) {
- croak ("Can't open $_[0] for reading: $!\n");
- }
- $_[0] = $infh;
- return $parser->parse_from_filehandle (@_);
- } else {
- return $parser->parse_from_file (@_);
- }
-}
-
-
-############################################################################
-# Module return value and documentation
-############################################################################
-
-1;
-__END__
-
-=head1 NAME
-
-Pod::PlainText - Convert POD data to formatted ASCII text
-
-=head1 SYNOPSIS
-
- use Pod::PlainText;
- my $parser = Pod::PlainText->new (sentence => 0, width => 78);
-
- # Read POD from STDIN and write to STDOUT.
- $parser->parse_from_filehandle;
-
- # Read POD from file.pod and write to file.txt.
- $parser->parse_from_file ('file.pod', 'file.txt');
-
-=head1 DESCRIPTION
-
-Pod::PlainText is a module that can convert documentation in the POD format (the
-preferred language for documenting Perl) into formatted ASCII. It uses no
-special formatting controls or codes whatsoever, and its output is therefore
-suitable for nearly any device.
-
-As a derived class from Pod::Parser, Pod::PlainText supports the same methods and
-interfaces. See L<Pod::Parser> for all the details; briefly, one creates a
-new parser with C<Pod::PlainText-E<gt>new()> and then calls either
-parse_from_filehandle() or parse_from_file().
-
-new() can take options, in the form of key/value pairs, that control the
-behavior of the parser. The currently recognized options are:
-
-=over 4
-
-=item alt
-
-If set to a true value, selects an alternate output format that, among other
-things, uses a different heading style and marks C<=item> entries with a
-colon in the left margin. Defaults to false.
-
-=item indent
-
-The number of spaces to indent regular text, and the default indentation for
-C<=over> blocks. Defaults to 4.
-
-=item loose
-
-If set to a true value, a blank line is printed after a C<=headN> headings.
-If set to false (the default), no blank line is printed after C<=headN>.
-This is the default because it's the expected formatting for manual pages;
-if you're formatting arbitrary text documents, setting this to true may
-result in more pleasing output.
-
-=item sentence
-
-If set to a true value, Pod::PlainText will assume that each sentence ends in two
-spaces, and will try to preserve that spacing. If set to false, all
-consecutive whitespace in non-verbatim paragraphs is compressed into a
-single space. Defaults to true.
-
-=item width
-
-The column at which to wrap text on the right-hand side. Defaults to 76.
-
-=back
-
-The standard Pod::Parser method parse_from_filehandle() takes up to two
-arguments, the first being the file handle to read POD from and the second
-being the file handle to write the formatted output to. The first defaults
-to STDIN if not given, and the second defaults to STDOUT. The method
-parse_from_file() is almost identical, except that its two arguments are the
-input and output disk files instead. See L<Pod::Parser> for the specific
-details.
-
-=head1 DIAGNOSTICS
-
-=over 4
-
-=item Bizarre space in item
-
-(W) Something has gone wrong in internal C<=item> processing. This message
-indicates a bug in Pod::PlainText; you should never see it.
-
-=item Can't open %s for reading: %s
-
-(F) Pod::PlainText was invoked via the compatibility mode pod2text() interface
-and the input file it was given could not be opened.
-
-=item Unknown escape: %s
-
-(W) The POD source contained an C<EE<lt>E<gt>> escape that Pod::PlainText didn't
-know about.
-
-=item Unknown sequence: %s
-
-(W) The POD source contained a non-standard internal sequence (something of
-the form C<XE<lt>E<gt>>) that Pod::PlainText didn't know about.
-
-=item Unmatched =back
-
-(W) Pod::PlainText encountered a C<=back> command that didn't correspond to an
-C<=over> command.
-
-=back
-
-=head1 RESTRICTIONS
-
-Embedded Ctrl-As (octal 001) in the input will be mapped to spaces on
-output, due to an internal implementation detail.
-
-=head1 NOTES
-
-This is a replacement for an earlier Pod::Text module written by Tom
-Christiansen. It has a revamped interface, since it now uses Pod::Parser,
-but an interface roughly compatible with the old Pod::Text::pod2text()
-function is still available. Please change to the new calling convention,
-though.
-
-The original Pod::Text contained code to do formatting via termcap
-sequences, although it wasn't turned on by default and it was problematic to
-get it to work at all. This rewrite doesn't even try to do that, but a
-subclass of it does. Look for L<Pod::Text::Termcap|Pod::Text::Termcap>.
-
-=head1 SEE ALSO
-
-L<Pod::Parser|Pod::Parser>, L<Pod::Text::Termcap|Pod::Text::Termcap>,
-pod2text(1)
-
-=head1 AUTHOR
-
-Please report bugs using L<http://rt.cpan.org>.
-
-Russ Allbery E<lt>rra@stanford.eduE<gt>, based I<very> heavily on the
-original Pod::Text by Tom Christiansen E<lt>tchrist@mox.perl.comE<gt> and
-its conversion to Pod::Parser by Brad Appleton
-E<lt>bradapp@enteract.comE<gt>.
-
-=cut
diff --git a/src/lib/mrtg2/Pod/Select.pm b/src/lib/mrtg2/Pod/Select.pm
deleted file mode 100644
index 4724cb7..0000000
--- a/src/lib/mrtg2/Pod/Select.pm
+++ /dev/null
@@ -1,746 +0,0 @@
-#############################################################################
-# Pod/Select.pm -- function to select portions of POD docs
-#
-# Copyright (C) 1996-2000 by Bradford Appleton. All rights reserved.
-# This file is part of "PodParser". PodParser is free software;
-# you can redistribute it and/or modify it under the same terms
-# as Perl itself.
-#############################################################################
-
-package Pod::Select;
-use strict;
-
-use vars qw($VERSION @ISA @EXPORT $MAX_HEADING_LEVEL %myData @section_headings @selected_sections);
-$VERSION = '1.36'; ## Current version of this package
-require 5.005; ## requires this Perl version or later
-
-#############################################################################
-
-=head1 NAME
-
-Pod::Select, podselect() - extract selected sections of POD from input
-
-=head1 SYNOPSIS
-
- use Pod::Select;
-
- ## Select all the POD sections for each file in @filelist
- ## and print the result on standard output.
- podselect(@filelist);
-
- ## Same as above, but write to tmp.out
- podselect({-output => "tmp.out"}, @filelist):
-
- ## Select from the given filelist, only those POD sections that are
- ## within a 1st level section named any of: NAME, SYNOPSIS, OPTIONS.
- podselect({-sections => ["NAME|SYNOPSIS", "OPTIONS"]}, @filelist):
-
- ## Select the "DESCRIPTION" section of the PODs from STDIN and write
- ## the result to STDERR.
- podselect({-output => ">&STDERR", -sections => ["DESCRIPTION"]}, \*STDIN);
-
-or
-
- use Pod::Select;
-
- ## Create a parser object for selecting POD sections from the input
- $parser = new Pod::Select();
-
- ## Select all the POD sections for each file in @filelist
- ## and print the result to tmp.out.
- $parser->parse_from_file("<&STDIN", "tmp.out");
-
- ## Select from the given filelist, only those POD sections that are
- ## within a 1st level section named any of: NAME, SYNOPSIS, OPTIONS.
- $parser->select("NAME|SYNOPSIS", "OPTIONS");
- for (@filelist) { $parser->parse_from_file($_); }
-
- ## Select the "DESCRIPTION" and "SEE ALSO" sections of the PODs from
- ## STDIN and write the result to STDERR.
- $parser->select("DESCRIPTION");
- $parser->add_selection("SEE ALSO");
- $parser->parse_from_filehandle(\*STDIN, \*STDERR);
-
-=head1 REQUIRES
-
-perl5.005, Pod::Parser, Exporter, Carp
-
-=head1 EXPORTS
-
-podselect()
-
-=head1 DESCRIPTION
-
-B<podselect()> is a function which will extract specified sections of
-pod documentation from an input stream. This ability is provided by the
-B<Pod::Select> module which is a subclass of B<Pod::Parser>.
-B<Pod::Select> provides a method named B<select()> to specify the set of
-POD sections to select for processing/printing. B<podselect()> merely
-creates a B<Pod::Select> object and then invokes the B<podselect()>
-followed by B<parse_from_file()>.
-
-=head1 SECTION SPECIFICATIONS
-
-B<podselect()> and B<Pod::Select::select()> may be given one or more
-"section specifications" to restrict the text processed to only the
-desired set of sections and their corresponding subsections. A section
-specification is a string containing one or more Perl-style regular
-expressions separated by forward slashes ("/"). If you need to use a
-forward slash literally within a section title you can escape it with a
-backslash ("\/").
-
-The formal syntax of a section specification is:
-
-=over 4
-
-=item *
-
-I<head1-title-regex>/I<head2-title-regex>/...
-
-=back
-
-Any omitted or empty regular expressions will default to ".*".
-Please note that each regular expression given is implicitly
-anchored by adding "^" and "$" to the beginning and end. Also, if a
-given regular expression starts with a "!" character, then the
-expression is I<negated> (so C<!foo> would match anything I<except>
-C<foo>).
-
-Some example section specifications follow.
-
-=over 4
-
-=item *
-
-Match the C<NAME> and C<SYNOPSIS> sections and all of their subsections:
-
-C<NAME|SYNOPSIS>
-
-=item *
-
-Match only the C<Question> and C<Answer> subsections of the C<DESCRIPTION>
-section:
-
-C<DESCRIPTION/Question|Answer>
-
-=item *
-
-Match the C<Comments> subsection of I<all> sections:
-
-C</Comments>
-
-=item *
-
-Match all subsections of C<DESCRIPTION> I<except> for C<Comments>:
-
-C<DESCRIPTION/!Comments>
-
-=item *
-
-Match the C<DESCRIPTION> section but do I<not> match any of its subsections:
-
-C<DESCRIPTION/!.+>
-
-=item *
-
-Match all top level sections but none of their subsections:
-
-C</!.+>
-
-=back
-
-=begin _NOT_IMPLEMENTED_
-
-=head1 RANGE SPECIFICATIONS
-
-B<podselect()> and B<Pod::Select::select()> may be given one or more
-"range specifications" to restrict the text processed to only the
-desired ranges of paragraphs in the desired set of sections. A range
-specification is a string containing a single Perl-style regular
-expression (a regex), or else two Perl-style regular expressions
-(regexs) separated by a ".." (Perl's "range" operator is "..").
-The regexs in a range specification are delimited by forward slashes
-("/"). If you need to use a forward slash literally within a regex you
-can escape it with a backslash ("\/").
-
-The formal syntax of a range specification is:
-
-=over 4
-
-=item *
-
-/I<start-range-regex>/[../I<end-range-regex>/]
-
-=back
-
-Where each the item inside square brackets (the ".." followed by the
-end-range-regex) is optional. Each "range-regex" is of the form:
-
- =cmd-expr text-expr
-
-Where I<cmd-expr> is intended to match the name of one or more POD
-commands, and I<text-expr> is intended to match the paragraph text for
-the command. If a range-regex is supposed to match a POD command, then
-the first character of the regex (the one after the initial '/')
-absolutely I<must> be a single '=' character; it may not be anything
-else (not even a regex meta-character) if it is supposed to match
-against the name of a POD command.
-
-If no I<=cmd-expr> is given then the text-expr will be matched against
-plain textblocks unless it is preceded by a space, in which case it is
-matched against verbatim text-blocks. If no I<text-expr> is given then
-only the command-portion of the paragraph is matched against.
-
-Note that these two expressions are each implicitly anchored. This
-means that when matching against the command-name, there will be an
-implicit '^' and '$' around the given I<=cmd-expr>; and when matching
-against the paragraph text there will be an implicit '\A' and '\Z'
-around the given I<text-expr>.
-
-Unlike with section-specs, the '!' character does I<not> have any special
-meaning (negation or otherwise) at the beginning of a range-spec!
-
-Some example range specifications follow.
-
-=over 4
-
-=item
-Match all C<=for html> paragraphs:
-
-C</=for html/>
-
-=item
-Match all paragraphs between C<=begin html> and C<=end html>
-(note that this will I<not> work correctly if such sections
-are nested):
-
-C</=begin html/../=end html/>
-
-=item
-Match all paragraphs between the given C<=item> name until the end of the
-current section:
-
-C</=item mine/../=head\d/>
-
-=item
-Match all paragraphs between the given C<=item> until the next item, or
-until the end of the itemized list (note that this will I<not> work as
-desired if the item contains an itemized list nested within it):
-
-C</=item mine/../=(item|back)/>
-
-=back
-
-=end _NOT_IMPLEMENTED_
-
-=cut
-
-#############################################################################
-
-#use diagnostics;
-use Carp;
-use Pod::Parser 1.04;
-
-@ISA = qw(Pod::Parser);
-@EXPORT = qw(&podselect);
-
-## Maximum number of heading levels supported for '=headN' directives
-*MAX_HEADING_LEVEL = \3;
-
-#############################################################################
-
-=head1 OBJECT METHODS
-
-The following methods are provided in this module. Each one takes a
-reference to the object itself as an implicit first parameter.
-
-=cut
-
-##---------------------------------------------------------------------------
-
-## =begin _PRIVATE_
-##
-## =head1 B<_init_headings()>
-##
-## Initialize the current set of active section headings.
-##
-## =cut
-##
-## =end _PRIVATE_
-
-sub _init_headings {
- my $self = shift;
- local *myData = $self;
-
- ## Initialize current section heading titles if necessary
- unless (defined $myData{_SECTION_HEADINGS}) {
- local *section_headings = $myData{_SECTION_HEADINGS} = [];
- for (my $i = 0; $i < $MAX_HEADING_LEVEL; ++$i) {
- $section_headings[$i] = '';
- }
- }
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<curr_headings()>
-
- ($head1, $head2, $head3, ...) = $parser->curr_headings();
- $head1 = $parser->curr_headings(1);
-
-This method returns a list of the currently active section headings and
-subheadings in the document being parsed. The list of headings returned
-corresponds to the most recently parsed paragraph of the input.
-
-If an argument is given, it must correspond to the desired section
-heading number, in which case only the specified section heading is
-returned. If there is no current section heading at the specified
-level, then C<undef> is returned.
-
-=cut
-
-sub curr_headings {
- my $self = shift;
- $self->_init_headings() unless (defined $self->{_SECTION_HEADINGS});
- my @headings = @{ $self->{_SECTION_HEADINGS} };
- return (@_ > 0 and $_[0] =~ /^\d+$/) ? $headings[$_[0] - 1] : @headings;
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<select()>
-
- $parser->select($section_spec1,$section_spec2,...);
-
-This method is used to select the particular sections and subsections of
-POD documentation that are to be printed and/or processed. The existing
-set of selected sections is I<replaced> with the given set of sections.
-See B<add_selection()> for adding to the current set of selected
-sections.
-
-Each of the C<$section_spec> arguments should be a section specification
-as described in L<"SECTION SPECIFICATIONS">. The section specifications
-are parsed by this method and the resulting regular expressions are
-stored in the invoking object.
-
-If no C<$section_spec> arguments are given, then the existing set of
-selected sections is cleared out (which means C<all> sections will be
-processed).
-
-This method should I<not> normally be overridden by subclasses.
-
-=cut
-
-sub select {
- my ($self, @sections) = @_;
- local *myData = $self;
- local $_;
-
-### NEED TO DISCERN A SECTION-SPEC FROM A RANGE-SPEC (look for m{^/.+/$}?)
-
- ##---------------------------------------------------------------------
- ## The following is a blatant hack for backward compatibility, and for
- ## implementing add_selection(). If the *first* *argument* is the
- ## string "+", then the remaining section specifications are *added*
- ## to the current set of selections; otherwise the given section
- ## specifications will *replace* the current set of selections.
- ##
- ## This should probably be fixed someday, but for the present time,
- ## it seems incredibly unlikely that "+" would ever correspond to
- ## a legitimate section heading
- ##---------------------------------------------------------------------
- my $add = ($sections[0] eq '+') ? shift(@sections) : '';
-
- ## Reset the set of sections to use
- unless (@sections) {
- delete $myData{_SELECTED_SECTIONS} unless ($add);
- return;
- }
- $myData{_SELECTED_SECTIONS} = []
- unless ($add && exists $myData{_SELECTED_SECTIONS});
- local *selected_sections = $myData{_SELECTED_SECTIONS};
-
- ## Compile each spec
- for my $spec (@sections) {
- if ( defined($_ = _compile_section_spec($spec)) ) {
- ## Store them in our sections array
- push(@selected_sections, $_);
- }
- else {
- carp qq{Ignoring section spec "$spec"!\n};
- }
- }
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<add_selection()>
-
- $parser->add_selection($section_spec1,$section_spec2,...);
-
-This method is used to add to the currently selected sections and
-subsections of POD documentation that are to be printed and/or
-processed. See <select()> for replacing the currently selected sections.
-
-Each of the C<$section_spec> arguments should be a section specification
-as described in L<"SECTION SPECIFICATIONS">. The section specifications
-are parsed by this method and the resulting regular expressions are
-stored in the invoking object.
-
-This method should I<not> normally be overridden by subclasses.
-
-=cut
-
-sub add_selection {
- my $self = shift;
- return $self->select('+', @_);
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<clear_selections()>
-
- $parser->clear_selections();
-
-This method takes no arguments, it has the exact same effect as invoking
-<select()> with no arguments.
-
-=cut
-
-sub clear_selections {
- my $self = shift;
- return $self->select();
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<match_section()>
-
- $boolean = $parser->match_section($heading1,$heading2,...);
-
-Returns a value of true if the given section and subsection heading
-titles match any of the currently selected section specifications in
-effect from prior calls to B<select()> and B<add_selection()> (or if
-there are no explicitly selected/deselected sections).
-
-The arguments C<$heading1>, C<$heading2>, etc. are the heading titles of
-the corresponding sections, subsections, etc. to try and match. If
-C<$headingN> is omitted then it defaults to the current corresponding
-section heading title in the input.
-
-This method should I<not> normally be overridden by subclasses.
-
-=cut
-
-sub match_section {
- my $self = shift;
- my (@headings) = @_;
- local *myData = $self;
-
- ## Return true if no restrictions were explicitly specified
- my $selections = (exists $myData{_SELECTED_SECTIONS})
- ? $myData{_SELECTED_SECTIONS} : undef;
- return 1 unless ((defined $selections) && @{$selections});
-
- ## Default any unspecified sections to the current one
- my @current_headings = $self->curr_headings();
- for (my $i = 0; $i < $MAX_HEADING_LEVEL; ++$i) {
- (defined $headings[$i]) or $headings[$i] = $current_headings[$i];
- }
-
- ## Look for a match against the specified section expressions
- for my $section_spec ( @{$selections} ) {
- ##------------------------------------------------------
- ## Each portion of this spec must match in order for
- ## the spec to be matched. So we will start with a
- ## match-value of 'true' and logically 'and' it with
- ## the results of matching a given element of the spec.
- ##------------------------------------------------------
- my $match = 1;
- for (my $i = 0; $i < $MAX_HEADING_LEVEL; ++$i) {
- my $regex = $section_spec->[$i];
- my $negated = ($regex =~ s/^\!//);
- $match &= ($negated ? ($headings[$i] !~ /${regex}/)
- : ($headings[$i] =~ /${regex}/));
- last unless ($match);
- }
- return 1 if ($match);
- }
- return 0; ## no match
-}
-
-##---------------------------------------------------------------------------
-
-=head1 B<is_selected()>
-
- $boolean = $parser->is_selected($paragraph);
-
-This method is used to determine if the block of text given in
-C<$paragraph> falls within the currently selected set of POD sections
-and subsections to be printed or processed. This method is also
-responsible for keeping track of the current input section and
-subsections. It is assumed that C<$paragraph> is the most recently read
-(but not yet processed) input paragraph.
-
-The value returned will be true if the C<$paragraph> and the rest of the
-text in the same section as C<$paragraph> should be selected (included)
-for processing; otherwise a false value is returned.
-
-=cut
-
-sub is_selected {
- my ($self, $paragraph) = @_;
- local $_;
- local *myData = $self;
-
- $self->_init_headings() unless (defined $myData{_SECTION_HEADINGS});
-
- ## Keep track of current sections levels and headings
- $_ = $paragraph;
- if (/^=((?:sub)*)(?:head(?:ing)?|sec(?:tion)?)(\d*)\s+(.*?)\s*$/)
- {
- ## This is a section heading command
- my ($level, $heading) = ($2, $3);
- $level = 1 + (length($1) / 3) if ((! length $level) || (length $1));
- ## Reset the current section heading at this level
- $myData{_SECTION_HEADINGS}->[$level - 1] = $heading;
- ## Reset subsection headings of this one to empty
- for (my $i = $level; $i < $MAX_HEADING_LEVEL; ++$i) {
- $myData{_SECTION_HEADINGS}->[$i] = '';
- }
- }
-
- return $self->match_section();
-}
-
-#############################################################################
-
-=head1 EXPORTED FUNCTIONS
-
-The following functions are exported by this module. Please note that
-these are functions (not methods) and therefore C<do not> take an
-implicit first argument.
-
-=cut
-
-##---------------------------------------------------------------------------
-
-=head1 B<podselect()>
-
- podselect(\%options,@filelist);
-
-B<podselect> will print the raw (untranslated) POD paragraphs of all
-POD sections in the given input files specified by C<@filelist>
-according to the given options.
-
-If any argument to B<podselect> is a reference to a hash
-(associative array) then the values with the following keys are
-processed as follows:
-
-=over 4
-
-=item B<-output>
-
-A string corresponding to the desired output file (or ">&STDOUT"
-or ">&STDERR"). The default is to use standard output.
-
-=item B<-sections>
-
-A reference to an array of sections specifications (as described in
-L<"SECTION SPECIFICATIONS">) which indicate the desired set of POD
-sections and subsections to be selected from input. If no section
-specifications are given, then all sections of the PODs are used.
-
-=begin _NOT_IMPLEMENTED_
-
-=item B<-ranges>
-
-A reference to an array of range specifications (as described in
-L<"RANGE SPECIFICATIONS">) which indicate the desired range of POD
-paragraphs to be selected from the desired input sections. If no range
-specifications are given, then all paragraphs of the desired sections
-are used.
-
-=end _NOT_IMPLEMENTED_
-
-=back
-
-All other arguments should correspond to the names of input files
-containing POD sections. A file name of "-" or "<&STDIN" will
-be interpreted to mean standard input (which is the default if no
-filenames are given).
-
-=cut
-
-sub podselect {
- my(@argv) = @_;
- my %defaults = ();
- my $pod_parser = new Pod::Select(%defaults);
- my $num_inputs = 0;
- my $output = '>&STDOUT';
- my %opts;
- local $_;
- for (@argv) {
- if (ref($_)) {
- next unless (ref($_) eq 'HASH');
- %opts = (%defaults, %{$_});
-
- ##-------------------------------------------------------------
- ## Need this for backward compatibility since we formerly used
- ## options that were all uppercase words rather than ones that
- ## looked like Unix command-line options.
- ## to be uppercase keywords)
- ##-------------------------------------------------------------
- %opts = map {
- my ($key, $val) = (lc $_, $opts{$_});
- $key =~ s/^(?=\w)/-/;
- $key =~ /^-se[cl]/ and $key = '-sections';
- #! $key eq '-range' and $key .= 's';
- ($key => $val);
- } (keys %opts);
-
- ## Process the options
- (exists $opts{'-output'}) and $output = $opts{'-output'};
-
- ## Select the desired sections
- $pod_parser->select(@{ $opts{'-sections'} })
- if ( (defined $opts{'-sections'})
- && ((ref $opts{'-sections'}) eq 'ARRAY') );
-
- #! ## Select the desired paragraph ranges
- #! $pod_parser->select(@{ $opts{'-ranges'} })
- #! if ( (defined $opts{'-ranges'})
- #! && ((ref $opts{'-ranges'}) eq 'ARRAY') );
- }
- else {
- $pod_parser->parse_from_file($_, $output);
- ++$num_inputs;
- }
- }
- $pod_parser->parse_from_file('-') unless ($num_inputs > 0);
-}
-
-#############################################################################
-
-=head1 PRIVATE METHODS AND DATA
-
-B<Pod::Select> makes uses a number of internal methods and data fields
-which clients should not need to see or use. For the sake of avoiding
-name collisions with client data and methods, these methods and fields
-are briefly discussed here. Determined hackers may obtain further
-information about them by reading the B<Pod::Select> source code.
-
-Private data fields are stored in the hash-object whose reference is
-returned by the B<new()> constructor for this class. The names of all
-private methods and data-fields used by B<Pod::Select> begin with a
-prefix of "_" and match the regular expression C</^_\w+$/>.
-
-=cut
-
-##---------------------------------------------------------------------------
-
-=begin _PRIVATE_
-
-=head1 B<_compile_section_spec()>
-
- $listref = $parser->_compile_section_spec($section_spec);
-
-This function (note it is a function and I<not> a method) takes a
-section specification (as described in L<"SECTION SPECIFICATIONS">)
-given in C<$section_sepc>, and compiles it into a list of regular
-expressions. If C<$section_spec> has no syntax errors, then a reference
-to the list (array) of corresponding regular expressions is returned;
-otherwise C<undef> is returned and an error message is printed (using
-B<carp>) for each invalid regex.
-
-=end _PRIVATE_
-
-=cut
-
-sub _compile_section_spec {
- my ($section_spec) = @_;
- my (@regexs, $negated);
-
- ## Compile the spec into a list of regexs
- local $_ = $section_spec;
- s{\\\\}{\001}g; ## handle escaped backward slashes
- s{\\/}{\002}g; ## handle escaped forward slashes
-
- ## Parse the regexs for the heading titles
- @regexs = split(/\//, $_, $MAX_HEADING_LEVEL);
-
- ## Set default regex for ommitted levels
- for (my $i = 0; $i < $MAX_HEADING_LEVEL; ++$i) {
- $regexs[$i] = '.*' unless ((defined $regexs[$i])
- && (length $regexs[$i]));
- }
- ## Modify the regexs as needed and validate their syntax
- my $bad_regexs = 0;
- for (@regexs) {
- $_ .= '.+' if ($_ eq '!');
- s{\001}{\\\\}g; ## restore escaped backward slashes
- s{\002}{\\/}g; ## restore escaped forward slashes
- $negated = s/^\!//; ## check for negation
- eval "m{$_}"; ## check regex syntax
- if ($@) {
- ++$bad_regexs;
- carp qq{Bad regular expression /$_/ in "$section_spec": $@\n};
- }
- else {
- ## Add the forward and rear anchors (and put the negator back)
- $_ = '^' . $_ unless (/^\^/);
- $_ = $_ . '$' unless (/\$$/);
- $_ = '!' . $_ if ($negated);
- }
- }
- return (! $bad_regexs) ? [ @regexs ] : undef;
-}
-
-##---------------------------------------------------------------------------
-
-=begin _PRIVATE_
-
-=head2 $self->{_SECTION_HEADINGS}
-
-A reference to an array of the current section heading titles for each
-heading level (note that the first heading level title is at index 0).
-
-=end _PRIVATE_
-
-=cut
-
-##---------------------------------------------------------------------------
-
-=begin _PRIVATE_
-
-=head2 $self->{_SELECTED_SECTIONS}
-
-A reference to an array of references to arrays. Each subarray is a list
-of anchored regular expressions (preceded by a "!" if the expression is to
-be negated). The index of the expression in the subarray should correspond
-to the index of the heading title in C<$self-E<gt>{_SECTION_HEADINGS}>
-that it is to be matched against.
-
-=end _PRIVATE_
-
-=cut
-
-#############################################################################
-
-=head1 SEE ALSO
-
-L<Pod::Parser>
-
-=head1 AUTHOR
-
-Please report bugs using L<http://rt.cpan.org>.
-
-Brad Appleton E<lt>bradapp@enteract.comE<gt>
-
-Based on code for B<pod2text> written by
-Tom Christiansen E<lt>tchrist@mox.perl.comE<gt>
-
-=cut
-
-1;
-# vim: ts=4 sw=4 et
diff --git a/src/lib/mrtg2/Pod/Usage.pm b/src/lib/mrtg2/Pod/Usage.pm
deleted file mode 100644
index f463fb9..0000000
--- a/src/lib/mrtg2/Pod/Usage.pm
+++ /dev/null
@@ -1,730 +0,0 @@
-#############################################################################
-# Pod/Usage.pm -- print usage messages for the running script.
-#
-# Copyright (C) 1996-2000 by Bradford Appleton. All rights reserved.
-# This file is part of "PodParser". PodParser is free software;
-# you can redistribute it and/or modify it under the same terms
-# as Perl itself.
-#############################################################################
-
-package Pod::Usage;
-use strict;
-
-use vars qw($VERSION @ISA @EXPORT);
-$VERSION = '1.36'; ## Current version of this package
-require 5.005; ## requires this Perl version or later
-
-=head1 NAME
-
-Pod::Usage, pod2usage() - print a usage message from embedded pod documentation
-
-=head1 SYNOPSIS
-
- use Pod::Usage
-
- my $message_text = "This text precedes the usage message.";
- my $exit_status = 2; ## The exit status to use
- my $verbose_level = 0; ## The verbose level to use
- my $filehandle = \*STDERR; ## The filehandle to write to
-
- pod2usage($message_text);
-
- pod2usage($exit_status);
-
- pod2usage( { -message => $message_text ,
- -exitval => $exit_status ,
- -verbose => $verbose_level,
- -output => $filehandle } );
-
- pod2usage( -msg => $message_text ,
- -exitval => $exit_status ,
- -verbose => $verbose_level,
- -output => $filehandle );
-
- pod2usage( -verbose => 2,
- -noperldoc => 1 )
-
-=head1 ARGUMENTS
-
-B<pod2usage> should be given either a single argument, or a list of
-arguments corresponding to an associative array (a "hash"). When a single
-argument is given, it should correspond to exactly one of the following:
-
-=over 4
-
-=item *
-
-A string containing the text of a message to print I<before> printing
-the usage message
-
-=item *
-
-A numeric value corresponding to the desired exit status
-
-=item *
-
-A reference to a hash
-
-=back
-
-If more than one argument is given then the entire argument list is
-assumed to be a hash. If a hash is supplied (either as a reference or
-as a list) it should contain one or more elements with the following
-keys:
-
-=over 4
-
-=item C<-message>
-
-=item C<-msg>
-
-The text of a message to print immediately prior to printing the
-program's usage message.
-
-=item C<-exitval>
-
-The desired exit status to pass to the B<exit()> function.
-This should be an integer, or else the string "NOEXIT" to
-indicate that control should simply be returned without
-terminating the invoking process.
-
-=item C<-verbose>
-
-The desired level of "verboseness" to use when printing the usage
-message. If the corresponding value is 0, then only the "SYNOPSIS"
-section of the pod documentation is printed. If the corresponding value
-is 1, then the "SYNOPSIS" section, along with any section entitled
-"OPTIONS", "ARGUMENTS", or "OPTIONS AND ARGUMENTS" is printed. If the
-corresponding value is 2 or more then the entire manpage is printed.
-
-The special verbosity level 99 requires to also specify the -sections
-parameter; then these sections are extracted (see L<Pod::Select>)
-and printed.
-
-=item C<-sections>
-
-A string representing a selection list for sections to be printed
-when -verbose is set to 99, e.g. C<"NAME|SYNOPSIS|DESCRIPTION|VERSION">.
-
-Alternatively, an array reference of section specifications can be used:
-
- pod2usage(-verbose => 99,
- -sections => [ qw(fred fred/subsection) ] );
-
-=item C<-output>
-
-A reference to a filehandle, or the pathname of a file to which the
-usage message should be written. The default is C<\*STDERR> unless the
-exit value is less than 2 (in which case the default is C<\*STDOUT>).
-
-=item C<-input>
-
-A reference to a filehandle, or the pathname of a file from which the
-invoking script's pod documentation should be read. It defaults to the
-file indicated by C<$0> (C<$PROGRAM_NAME> for users of F<English.pm>).
-
-If you are calling B<pod2usage()> from a module and want to display
-that module's POD, you can use this:
-
- use Pod::Find qw(pod_where);
- pod2usage( -input => pod_where({-inc => 1}, __PACKAGE__) );
-
-=item C<-pathlist>
-
-A list of directory paths. If the input file does not exist, then it
-will be searched for in the given directory list (in the order the
-directories appear in the list). It defaults to the list of directories
-implied by C<$ENV{PATH}>. The list may be specified either by a reference
-to an array, or by a string of directory paths which use the same path
-separator as C<$ENV{PATH}> on your system (e.g., C<:> for Unix, C<;> for
-MSWin32 and DOS).
-
-=item C<-noperldoc>
-
-By default, Pod::Usage will call L<perldoc> when -verbose >= 2 is
-specified. This does not work well e.g. if the script was packed
-with L<PAR>. The -noperldoc option suppresses the external call to
-L<perldoc> and uses the simple text formatter (L<Pod::Text>) to
-output the POD.
-
-=back
-
-=head1 DESCRIPTION
-
-B<pod2usage> will print a usage message for the invoking script (using
-its embedded pod documentation) and then exit the script with the
-desired exit status. The usage message printed may have any one of three
-levels of "verboseness": If the verbose level is 0, then only a synopsis
-is printed. If the verbose level is 1, then the synopsis is printed
-along with a description (if present) of the command line options and
-arguments. If the verbose level is 2, then the entire manual page is
-printed.
-
-Unless they are explicitly specified, the default values for the exit
-status, verbose level, and output stream to use are determined as
-follows:
-
-=over 4
-
-=item *
-
-If neither the exit status nor the verbose level is specified, then the
-default is to use an exit status of 2 with a verbose level of 0.
-
-=item *
-
-If an exit status I<is> specified but the verbose level is I<not>, then the
-verbose level will default to 1 if the exit status is less than 2 and
-will default to 0 otherwise.
-
-=item *
-
-If an exit status is I<not> specified but verbose level I<is> given, then
-the exit status will default to 2 if the verbose level is 0 and will
-default to 1 otherwise.
-
-=item *
-
-If the exit status used is less than 2, then output is printed on
-C<STDOUT>. Otherwise output is printed on C<STDERR>.
-
-=back
-
-Although the above may seem a bit confusing at first, it generally does
-"the right thing" in most situations. This determination of the default
-values to use is based upon the following typical Unix conventions:
-
-=over 4
-
-=item *
-
-An exit status of 0 implies "success". For example, B<diff(1)> exits
-with a status of 0 if the two files have the same contents.
-
-=item *
-
-An exit status of 1 implies possibly abnormal, but non-defective, program
-termination. For example, B<grep(1)> exits with a status of 1 if
-it did I<not> find a matching line for the given regular expression.
-
-=item *
-
-An exit status of 2 or more implies a fatal error. For example, B<ls(1)>
-exits with a status of 2 if you specify an illegal (unknown) option on
-the command line.
-
-=item *
-
-Usage messages issued as a result of bad command-line syntax should go
-to C<STDERR>. However, usage messages issued due to an explicit request
-to print usage (like specifying B<-help> on the command line) should go
-to C<STDOUT>, just in case the user wants to pipe the output to a pager
-(such as B<more(1)>).
-
-=item *
-
-If program usage has been explicitly requested by the user, it is often
-desirable to exit with a status of 1 (as opposed to 0) after issuing
-the user-requested usage message. It is also desirable to give a
-more verbose description of program usage in this case.
-
-=back
-
-B<pod2usage> doesn't force the above conventions upon you, but it will
-use them by default if you don't expressly tell it to do otherwise. The
-ability of B<pod2usage()> to accept a single number or a string makes it
-convenient to use as an innocent looking error message handling function:
-
- use Pod::Usage;
- use Getopt::Long;
-
- ## Parse options
- GetOptions("help", "man", "flag1") || pod2usage(2);
- pod2usage(1) if ($opt_help);
- pod2usage(-verbose => 2) if ($opt_man);
-
- ## Check for too many filenames
- pod2usage("$0: Too many files given.\n") if (@ARGV > 1);
-
-Some user's however may feel that the above "economy of expression" is
-not particularly readable nor consistent and may instead choose to do
-something more like the following:
-
- use Pod::Usage;
- use Getopt::Long;
-
- ## Parse options
- GetOptions("help", "man", "flag1") || pod2usage(-verbose => 0);
- pod2usage(-verbose => 1) if ($opt_help);
- pod2usage(-verbose => 2) if ($opt_man);
-
- ## Check for too many filenames
- pod2usage(-verbose => 2, -message => "$0: Too many files given.\n")
- if (@ARGV > 1);
-
-As with all things in Perl, I<there's more than one way to do it>, and
-B<pod2usage()> adheres to this philosophy. If you are interested in
-seeing a number of different ways to invoke B<pod2usage> (although by no
-means exhaustive), please refer to L<"EXAMPLES">.
-
-=head1 EXAMPLES
-
-Each of the following invocations of C<pod2usage()> will print just the
-"SYNOPSIS" section to C<STDERR> and will exit with a status of 2:
-
- pod2usage();
-
- pod2usage(2);
-
- pod2usage(-verbose => 0);
-
- pod2usage(-exitval => 2);
-
- pod2usage({-exitval => 2, -output => \*STDERR});
-
- pod2usage({-verbose => 0, -output => \*STDERR});
-
- pod2usage(-exitval => 2, -verbose => 0);
-
- pod2usage(-exitval => 2, -verbose => 0, -output => \*STDERR);
-
-Each of the following invocations of C<pod2usage()> will print a message
-of "Syntax error." (followed by a newline) to C<STDERR>, immediately
-followed by just the "SYNOPSIS" section (also printed to C<STDERR>) and
-will exit with a status of 2:
-
- pod2usage("Syntax error.");
-
- pod2usage(-message => "Syntax error.", -verbose => 0);
-
- pod2usage(-msg => "Syntax error.", -exitval => 2);
-
- pod2usage({-msg => "Syntax error.", -exitval => 2, -output => \*STDERR});
-
- pod2usage({-msg => "Syntax error.", -verbose => 0, -output => \*STDERR});
-
- pod2usage(-msg => "Syntax error.", -exitval => 2, -verbose => 0);
-
- pod2usage(-message => "Syntax error.",
- -exitval => 2,
- -verbose => 0,
- -output => \*STDERR);
-
-Each of the following invocations of C<pod2usage()> will print the
-"SYNOPSIS" section and any "OPTIONS" and/or "ARGUMENTS" sections to
-C<STDOUT> and will exit with a status of 1:
-
- pod2usage(1);
-
- pod2usage(-verbose => 1);
-
- pod2usage(-exitval => 1);
-
- pod2usage({-exitval => 1, -output => \*STDOUT});
-
- pod2usage({-verbose => 1, -output => \*STDOUT});
-
- pod2usage(-exitval => 1, -verbose => 1);
-
- pod2usage(-exitval => 1, -verbose => 1, -output => \*STDOUT});
-
-Each of the following invocations of C<pod2usage()> will print the
-entire manual page to C<STDOUT> and will exit with a status of 1:
-
- pod2usage(-verbose => 2);
-
- pod2usage({-verbose => 2, -output => \*STDOUT});
-
- pod2usage(-exitval => 1, -verbose => 2);
-
- pod2usage({-exitval => 1, -verbose => 2, -output => \*STDOUT});
-
-=head2 Recommended Use
-
-Most scripts should print some type of usage message to C<STDERR> when a
-command line syntax error is detected. They should also provide an
-option (usually C<-H> or C<-help>) to print a (possibly more verbose)
-usage message to C<STDOUT>. Some scripts may even wish to go so far as to
-provide a means of printing their complete documentation to C<STDOUT>
-(perhaps by allowing a C<-man> option). The following complete example
-uses B<Pod::Usage> in combination with B<Getopt::Long> to do all of these
-things:
-
- use Getopt::Long;
- use Pod::Usage;
-
- my $man = 0;
- my $help = 0;
- ## Parse options and print usage if there is a syntax error,
- ## or if usage was explicitly requested.
- GetOptions('help|?' => \$help, man => \$man) or pod2usage(2);
- pod2usage(1) if $help;
- pod2usage(-verbose => 2) if $man;
-
- ## If no arguments were given, then allow STDIN to be used only
- ## if it's not connected to a terminal (otherwise print usage)
- pod2usage("$0: No files given.") if ((@ARGV == 0) && (-t STDIN));
- __END__
-
- =head1 NAME
-
- sample - Using GetOpt::Long and Pod::Usage
-
- =head1 SYNOPSIS
-
- sample [options] [file ...]
-
- Options:
- -help brief help message
- -man full documentation
-
- =head1 OPTIONS
-
- =over 8
-
- =item B<-help>
-
- Print a brief help message and exits.
-
- =item B<-man>
-
- Prints the manual page and exits.
-
- =back
-
- =head1 DESCRIPTION
-
- B<This program> will read the given input file(s) and do something
- useful with the contents thereof.
-
- =cut
-
-=head1 CAVEATS
-
-By default, B<pod2usage()> will use C<$0> as the path to the pod input
-file. Unfortunately, not all systems on which Perl runs will set C<$0>
-properly (although if C<$0> isn't found, B<pod2usage()> will search
-C<$ENV{PATH}> or else the list specified by the C<-pathlist> option).
-If this is the case for your system, you may need to explicitly specify
-the path to the pod docs for the invoking script using something
-similar to the following:
-
- pod2usage(-exitval => 2, -input => "/path/to/your/pod/docs");
-
-In the pathological case that a script is called via a relative path
-I<and> the script itself changes the current working directory
-(see L<perlfunc/chdir>) I<before> calling pod2usage, Pod::Usage will
-fail even on robust platforms. Don't do that.
-
-=head1 AUTHOR
-
-Please report bugs using L<http://rt.cpan.org>.
-
-Marek Rouchal E<lt>marekr@cpan.orgE<gt>
-
-Brad Appleton E<lt>bradapp@enteract.comE<gt>
-
-Based on code for B<Pod::Text::pod2text()> written by
-Tom Christiansen E<lt>tchrist@mox.perl.comE<gt>
-
-=head1 ACKNOWLEDGMENTS
-
-Steven McDougall E<lt>swmcd@world.std.comE<gt> for his help and patience
-with re-writing this manpage.
-
-=head1 SEE ALSO
-
-L<Pod::Parser>, L<Getopt::Long>, L<Pod::Find>
-
-=cut
-
-#############################################################################
-
-#use diagnostics;
-use Carp;
-use Config;
-use Exporter;
-use File::Spec;
-
-@EXPORT = qw(&pod2usage);
-BEGIN {
- if ( $] >= 5.005_58 ) {
- require Pod::Text;
- @ISA = qw( Pod::Text );
- }
- else {
- require Pod::PlainText;
- @ISA = qw( Pod::PlainText );
- }
-}
-
-require Pod::Select;
-
-##---------------------------------------------------------------------------
-
-##---------------------------------
-## Function definitions begin here
-##---------------------------------
-
-sub pod2usage {
- local($_) = shift;
- my %opts;
- ## Collect arguments
- if (@_ > 0) {
- ## Too many arguments - assume that this is a hash and
- ## the user forgot to pass a reference to it.
- %opts = ($_, @_);
- }
- elsif (!defined $_) {
- $_ = '';
- }
- elsif (ref $_) {
- ## User passed a ref to a hash
- %opts = %{$_} if (ref($_) eq 'HASH');
- }
- elsif (/^[-+]?\d+$/) {
- ## User passed in the exit value to use
- $opts{'-exitval'} = $_;
- }
- else {
- ## User passed in a message to print before issuing usage.
- $_ and $opts{'-message'} = $_;
- }
-
- ## Need this for backward compatibility since we formerly used
- ## options that were all uppercase words rather than ones that
- ## looked like Unix command-line options.
- ## to be uppercase keywords)
- %opts = map {
- my ($key, $val) = ($_, $opts{$_});
- $key =~ s/^(?=\w)/-/;
- $key =~ /^-msg/i and $key = '-message';
- $key =~ /^-exit/i and $key = '-exitval';
- lc($key) => $val;
- } (keys %opts);
-
- ## Now determine default -exitval and -verbose values to use
- if ((! defined $opts{'-exitval'}) && (! defined $opts{'-verbose'})) {
- $opts{'-exitval'} = 2;
- $opts{'-verbose'} = 0;
- }
- elsif (! defined $opts{'-exitval'}) {
- $opts{'-exitval'} = ($opts{'-verbose'} > 0) ? 1 : 2;
- }
- elsif (! defined $opts{'-verbose'}) {
- $opts{'-verbose'} = (lc($opts{'-exitval'}) eq 'noexit' ||
- $opts{'-exitval'} < 2);
- }
-
- ## Default the output file
- $opts{'-output'} = (lc($opts{'-exitval'}) eq 'noexit' ||
- $opts{'-exitval'} < 2) ? \*STDOUT : \*STDERR
- unless (defined $opts{'-output'});
- ## Default the input file
- $opts{'-input'} = $0 unless (defined $opts{'-input'});
-
- ## Look up input file in path if it doesnt exist.
- unless ((ref $opts{'-input'}) || (-e $opts{'-input'})) {
- my $basename = $opts{'-input'};
- my $pathsep = ($^O =~ /^(?:dos|os2|MSWin32)$/i) ? ';'
- : (($^O eq 'MacOS' || $^O eq 'VMS') ? ',' : ':');
- my $pathspec = $opts{'-pathlist'} || $ENV{PATH} || $ENV{PERL5LIB};
-
- my @paths = (ref $pathspec) ? @$pathspec : split($pathsep, $pathspec);
- for my $dirname (@paths) {
- $_ = File::Spec->catfile($dirname, $basename) if length;
- last if (-e $_) && ($opts{'-input'} = $_);
- }
- }
-
- ## Now create a pod reader and constrain it to the desired sections.
- my $parser = new Pod::Usage(USAGE_OPTIONS => \%opts);
- if ($opts{'-verbose'} == 0) {
- $parser->select('(?:SYNOPSIS|USAGE)\s*');
- }
- elsif ($opts{'-verbose'} == 1) {
- my $opt_re = '(?i)' .
- '(?:OPTIONS|ARGUMENTS)' .
- '(?:\s*(?:AND|\/)\s*(?:OPTIONS|ARGUMENTS))?';
- $parser->select( '(?:SYNOPSIS|USAGE)\s*', $opt_re, "DESCRIPTION/$opt_re" );
- }
- elsif ($opts{'-verbose'} >= 2 && $opts{'-verbose'} != 99) {
- $parser->select('.*');
- }
- elsif ($opts{'-verbose'} == 99) {
- my $sections = $opts{'-sections'};
- $parser->select( (ref $sections) ? @$sections : $sections );
- $opts{'-verbose'} = 1;
- }
-
- ## Now translate the pod document and then exit with the desired status
- if ( !$opts{'-noperldoc'}
- and $opts{'-verbose'} >= 2
- and !ref($opts{'-input'})
- and $opts{'-output'} == \*STDOUT )
- {
- ## spit out the entire PODs. Might as well invoke perldoc
- my $progpath = File::Spec->catfile($Config{scriptdir}, 'perldoc');
- print { $opts{'-output'} } ($opts{'-message'}, "\n") if($opts{'-message'});
- if(defined $opts{-input} && $opts{-input} =~ /^\s*(\S.*?)\s*$/) {
- # the perldocs back to 5.005 should all have -F
- # without -F there are warnings in -T scripts
- system($progpath, '-F', $1);
- if($?) {
- # RT16091: fall back to more if perldoc failed
- system(($Config{pager} || $ENV{PAGER} || '/bin/more'), $1);
- }
- } else {
- croak "Unspecified input file or insecure argument.\n";
- }
- }
- else {
- $parser->parse_from_file($opts{'-input'}, $opts{'-output'});
- }
-
- exit($opts{'-exitval'}) unless (lc($opts{'-exitval'}) eq 'noexit');
-}
-
-##---------------------------------------------------------------------------
-
-##-------------------------------
-## Method definitions begin here
-##-------------------------------
-
-sub new {
- my $this = shift;
- my $class = ref($this) || $this;
- my %params = @_;
- my $self = {%params};
- bless $self, $class;
- if ($self->can('initialize')) {
- $self->initialize();
- } else {
- $self = $self->SUPER::new();
- %$self = (%$self, %params);
- }
- return $self;
-}
-
-sub select {
- my ($self, @sections) = @_;
- if ($ISA[0]->can('select')) {
- $self->SUPER::select(@sections);
- } else {
- # we're using Pod::Simple - need to mimic the behavior of Pod::Select
- my $add = ($sections[0] eq '+') ? shift(@sections) : '';
- ## Reset the set of sections to use
- unless (@sections) {
- delete $self->{USAGE_SELECT} unless ($add);
- return;
- }
- $self->{USAGE_SELECT} = []
- unless ($add && $self->{USAGE_SELECT});
- my $sref = $self->{USAGE_SELECT};
- ## Compile each spec
- for my $spec (@sections) {
- my $cs = Pod::Select::_compile_section_spec($spec);
- if ( defined $cs ) {
- ## Store them in our sections array
- push(@$sref, $cs);
- } else {
- carp qq{Ignoring section spec "$spec"!\n};
- }
- }
- }
-}
-
-# Override Pod::Text->seq_i to return just "arg", not "*arg*".
-sub seq_i { return $_[1] }
-
-# This overrides the Pod::Text method to do something very akin to what
-# Pod::Select did as well as the work done below by preprocess_paragraph.
-# Note that the below is very, very specific to Pod::Text.
-sub _handle_element_end {
- my ($self, $element) = @_;
- if ($element eq 'head1') {
- $self->{USAGE_HEADINGS} = [ $$self{PENDING}[-1][1] ];
- if ($self->{USAGE_OPTIONS}->{-verbose} < 2) {
- $$self{PENDING}[-1][1] =~ s/^\s*SYNOPSIS\s*$/USAGE/;
- }
- } elsif ($element =~ /^head(\d+)$/ && $1) { # avoid 0
- my $idx = $1 - 1;
- $self->{USAGE_HEADINGS} = [] unless($self->{USAGE_HEADINGS});
- $self->{USAGE_HEADINGS}->[$idx] = $$self{PENDING}[-1][1];
- }
- if ($element =~ /^head\d+$/) {
- $$self{USAGE_SKIPPING} = 1;
- if (!$$self{USAGE_SELECT} || !@{ $$self{USAGE_SELECT} }) {
- $$self{USAGE_SKIPPING} = 0;
- } else {
- my @headings = @{$$self{USAGE_HEADINGS}};
- for my $section_spec ( @{$$self{USAGE_SELECT}} ) {
- my $match = 1;
- for (my $i = 0; $i < $Pod::Select::MAX_HEADING_LEVEL; ++$i) {
- $headings[$i] = '' unless defined $headings[$i];
- my $regex = $section_spec->[$i];
- my $negated = ($regex =~ s/^\!//);
- $match &= ($negated ? ($headings[$i] !~ /${regex}/)
- : ($headings[$i] =~ /${regex}/));
- last unless ($match);
- } # end heading levels
- if ($match) {
- $$self{USAGE_SKIPPING} = 0;
- last;
- }
- } # end sections
- }
-
- # Try to do some lowercasing instead of all-caps in headings, and use
- # a colon to end all headings.
- if($self->{USAGE_OPTIONS}->{-verbose} < 2) {
- local $_ = $$self{PENDING}[-1][1];
- s{([A-Z])([A-Z]+)}{((length($2) > 2) ? $1 : lc($1)) . lc($2)}ge;
- s/\s*$/:/ unless (/:\s*$/);
- $_ .= "\n";
- $$self{PENDING}[-1][1] = $_;
- }
- }
- if ($$self{USAGE_SKIPPING} && $element !~ m/^over-/) {
- pop @{ $$self{PENDING} };
- } else {
- $self->SUPER::_handle_element_end($element);
- }
-}
-
-# required for Pod::Simple API
-sub start_document {
- my $self = shift;
- $self->SUPER::start_document();
- my $msg = $self->{USAGE_OPTIONS}->{-message} or return 1;
- my $out_fh = $self->output_fh();
- print $out_fh "$msg\n";
-}
-
-# required for old Pod::Parser API
-sub begin_pod {
- my $self = shift;
- $self->SUPER::begin_pod(); ## Have to call superclass
- my $msg = $self->{USAGE_OPTIONS}->{-message} or return 1;
- my $out_fh = $self->output_handle();
- print $out_fh "$msg\n";
-}
-
-sub preprocess_paragraph {
- my $self = shift;
- local $_ = shift;
- my $line = shift;
- ## See if this is a heading and we arent printing the entire manpage.
- if (($self->{USAGE_OPTIONS}->{-verbose} < 2) && /^=head/) {
- ## Change the title of the SYNOPSIS section to USAGE
- s/^=head1\s+SYNOPSIS\s*$/=head1 USAGE/;
- ## Try to do some lowercasing instead of all-caps in headings
- s{([A-Z])([A-Z]+)}{((length($2) > 2) ? $1 : lc($1)) . lc($2)}ge;
- ## Use a colon to end all headings
- s/\s*$/:/ unless (/:\s*$/);
- $_ .= "\n";
- }
- return $self->SUPER::preprocess_paragraph($_);
-}
-
-1; # keep require happy
diff --git a/src/lib/mrtg2/SNMP_Session.pm b/src/lib/mrtg2/SNMP_Session.pm
deleted file mode 100644
index 84b3af3..0000000
--- a/src/lib/mrtg2/SNMP_Session.pm
+++ /dev/null
@@ -1,1118 +0,0 @@
-### -*- mode: Perl -*-
-######################################################################
-### SNMP Request/Response Handling
-######################################################################
-### Copyright (c) 1995-2008, Simon Leinen.
-###
-### This program is free software; you can redistribute it under the
-### "Artistic License 2.0" included in this distribution
-### (file "Artistic").
-######################################################################
-### The abstract class SNMP_Session defines objects that can be used
-### to communicate with SNMP entities. It has methods to send
-### requests to and receive responses from an agent.
-###
-### Two instantiable subclasses are defined:
-### SNMPv1_Session implements SNMPv1 (RFC 1157) functionality
-### SNMPv2c_Session implements community-based SNMPv2.
-######################################################################
-### Created by: Simon Leinen <simon@switch.ch>
-###
-### Contributions and fixes by:
-###
-### Matthew Trunnell <matter@media.mit.edu>
-### Tobias Oetiker <tobi@oetiker.ch>
-### Heine Peters <peters@dkrz.de>
-### Daniel L. Needles <dan_needles@INS.COM>
-### Mike Mitchell <mcm@unx.sas.com>
-### Clinton Wong <clintdw@netcom.com>
-### Alan Nichols <Alan.Nichols@Ebay.Sun.COM>
-### Mike McCauley <mikem@open.com.au>
-### Andrew W. Elble <elble@icculus.nsg.nwu.edu>
-### Brett T Warden <wardenb@eluminant.com>: pretty UInteger32
-### Michael Deegan <michael@cnspc18.murdoch.edu.au>
-### Sergio Macedo <macedo@tmp.com.br>
-### Jakob Ilves (/IlvJa) <jakob.ilves@oracle.com>: PDU capture
-### Valerio Bontempi <v.bontempi@inwind.it>: IPv6 support
-### Lorenzo Colitti <lorenzo@colitti.com>: IPv6 support
-### Philippe Simonet <Philippe.Simonet@swisscom.com>: Export avoid...
-### Luc Pauwels <Luc.Pauwels@xalasys.com>: use_16bit_request_ids
-### Andrew Cornford-Matheson <andrew.matheson@corenetworks.com>: inform
-### Gerry Dalton <gerry.dalton@consolidated.com>: strict subs bug
-### Mike Fischer <mlf2@tampabay.rr.com>: pass MSG_DONTWAIT to recv()
-######################################################################
-
-package SNMP_Session;
-
-require 5.002;
-
-use strict;
-use Exporter;
-use vars qw(@ISA $VERSION @EXPORT $errmsg
- $suppress_warnings
- $default_avoid_negative_request_ids
- $default_use_16bit_request_ids);
-use Socket;
-use BER '1.05';
-use Carp;
-
-sub map_table ($$$ );
-sub map_table_4 ($$$$);
-sub map_table_start_end ($$$$$$);
-sub index_compare ($$);
-sub oid_diff ($$);
-
-$VERSION = '1.12';
-
-@ISA = qw(Exporter);
-
-@EXPORT = qw(errmsg suppress_warnings index_compare oid_diff recycle_socket ipv6available);
-
-my $default_debug = 0;
-
-### Default initial timeout (in seconds) waiting for a response PDU
-### after a request is sent. Note that when a request is retried, the
-### timeout is increased by BACKOFF (see below).
-###
-my $default_timeout = 2.0;
-
-### Default number of attempts to get a reply for an SNMP request. If
-### no response is received after TIMEOUT seconds, the request is
-### resent and a new response awaited with a longer timeout (see the
-### documentation on BACKOFF below). The "retries" value should be at
-### least 1, because the first attempt counts, too (the name "retries"
-### is confusing, sorry for that).
-###
-my $default_retries = 5;
-
-### Default backoff factor for SNMP_Session objects. This factor is
-### used to increase the TIMEOUT every time an SNMP request is
-### retried.
-###
-my $default_backoff = 1.0;
-
-### Default value for maxRepetitions. This specifies how many table
-### rows are requested in getBulk requests. Used when walking tables
-### using getBulk (only available in SNMPv2(c) and later). If this is
-### too small, then a table walk will need unnecessarily many
-### request/response exchanges. If it is too big, the agent may
-### compute many variables after the end of the table. It is
-### recommended to set this explicitly for each table walk by using
-### map_table_4().
-###
-my $default_max_repetitions = 12;
-
-### Default value for "avoid_negative_request_ids".
-###
-### Set this to non-zero if you have agents that have trouble with
-### negative request IDs, and don't forget to complain to your agent
-### vendor. According to the spec (RFC 1905), the request-id is an
-### Integer32, i.e. its range is from -(2^31) to (2^31)-1. However,
-### some agents erroneously encode the response ID as an unsigned,
-### which prevents this code from matching such responses to requests.
-###
-$SNMP_Session::default_avoid_negative_request_ids = 0;
-
-### Default value for "use_16bit_request_ids".
-###
-### Set this to non-zero if you have agents that use 16bit request IDs,
-### and don't forget to complain to your agent vendor.
-###
-$SNMP_Session::default_use_16bit_request_ids = 0;
-
-### Whether all SNMP_Session objects should share a single UDP socket.
-###
-$SNMP_Session::recycle_socket = 0;
-
-### IPv6 initialization code: check that IPv6 libraries are available,
-### and if so load them.
-
-### We store the length of an IPv6 socket address structure in the class
-### so we can determine if a socket address is IPv4 or IPv6 just by checking
-### its length. The proper way to do this would be to use sockaddr_family(),
-### but this function is only available in recent versions of Socket.pm.
-my $ipv6_addr_len;
-
-### Flags to be passed to recv() when non-blocking behavior is
-### desired. On most POSIX-like systems this will be set to
-### MSG_DONTWAIT, on other systems we leave it at zero.
-###
-my $dont_wait_flags;
-
-BEGIN {
- $ipv6_addr_len = undef;
- $SNMP_Session::ipv6available = 0;
- $dont_wait_flags = 0;
-
- if (eval {local $SIG{__DIE__};require Socket6;} &&
- eval {local $SIG{__DIE__};require IO::Socket::INET6; IO::Socket::INET6->VERSION("1.26");}) {
- Socket6->import(qw(pack_sockaddr_in6 inet_pton getaddrinfo));
- $ipv6_addr_len = length(pack_sockaddr_in6(161, inet_pton(AF_INET6(), "::1")));
- $SNMP_Session::ipv6available = 1;
- }
- eval 'local $SIG{__DIE__};local $SIG{__WARN__};$dont_wait_flags = MSG_DONTWAIT();';
-}
-
-my $the_socket;
-
-$SNMP_Session::errmsg = '';
-$SNMP_Session::suppress_warnings = 0;
-
-sub get_request { 0 | context_flag () };
-sub getnext_request { 1 | context_flag () };
-sub get_response { 2 | context_flag () };
-sub set_request { 3 | context_flag () };
-sub trap_request { 4 | context_flag () };
-sub getbulk_request { 5 | context_flag () };
-sub inform_request { 6 | context_flag () };
-sub trap2_request { 7 | context_flag () };
-
-sub standard_udp_port { 161 };
-
-sub open
-{
- return SNMPv1_Session::open (@_);
-}
-
-sub timeout { $_[0]->{timeout} }
-sub retries { $_[0]->{retries} }
-sub backoff { $_[0]->{backoff} }
-sub set_timeout {
- my ($session, $timeout) = @_;
- croak ("timeout ($timeout) must be a positive number") unless $timeout > 0.0;
- $session->{'timeout'} = $timeout;
-}
-sub set_retries {
- my ($session, $retries) = @_;
- croak ("retries ($retries) must be a non-negative integer")
- unless $retries == int ($retries) && $retries >= 0;
- $session->{'retries'} = $retries;
-}
-sub set_backoff {
- my ($session, $backoff) = @_;
- croak ("backoff ($backoff) must be a number >= 1.0")
- unless $backoff == int ($backoff) && $backoff >= 1.0;
- $session->{'backoff'} = $backoff;
-}
-
-sub encode_request_3 ($$$@) {
- my($this, $reqtype, $encoded_oids_or_pairs, $i1, $i2) = @_;
- my($request);
- local($_);
-
- $this->{request_id} = ($this->{request_id} == 0x7fffffff)
- ? -0x80000000 : $this->{request_id}+1;
- $this->{request_id} += 0x80000000
- if ($this->{avoid_negative_request_ids} && $this->{request_id} < 0);
- $this->{request_id} &= 0x0000ffff
- if ($this->{use_16bit_request_ids});
- foreach $_ (@{$encoded_oids_or_pairs}) {
- if (ref ($_) eq 'ARRAY') {
- $_ = &encode_sequence ($_->[0], $_->[1])
- || return $this->ber_error ("encoding pair");
- } else {
- $_ = &encode_sequence ($_, encode_null())
- || return $this->ber_error ("encoding value/null pair");
- }
- }
- $request = encode_tagged_sequence
- ($reqtype,
- encode_int ($this->{request_id}),
- defined $i1 ? encode_int ($i1) : encode_int_0 (),
- defined $i2 ? encode_int ($i2) : encode_int_0 (),
- encode_sequence (@{$encoded_oids_or_pairs}))
- || return $this->ber_error ("encoding request PDU");
- return $this->wrap_request ($request);
-}
-
-sub encode_get_request {
- my($this, @oids) = @_;
- return encode_request_3 ($this, get_request, \@oids);
-}
-
-sub encode_getnext_request {
- my($this, @oids) = @_;
- return encode_request_3 ($this, getnext_request, \@oids);
-}
-
-sub encode_getbulk_request {
- my($this, $non_repeaters, $max_repetitions, @oids) = @_;
- return encode_request_3 ($this, getbulk_request, \@oids,
- $non_repeaters, $max_repetitions);
-}
-
-sub encode_set_request {
- my($this, @encoded_pairs) = @_;
- return encode_request_3 ($this, set_request, \@encoded_pairs);
-}
-
-sub encode_trap_request ($$$$$$@) {
- my($this, $ent, $agent, $gen, $spec, $dt, @pairs) = @_;
- my($request);
- local($_);
-
- foreach $_ (@pairs) {
- if (ref ($_) eq 'ARRAY') {
- $_ = &encode_sequence ($_->[0], $_->[1])
- || return $this->ber_error ("encoding pair");
- } else {
- $_ = &encode_sequence ($_, encode_null())
- || return $this->ber_error ("encoding value/null pair");
- }
- }
- $request = encode_tagged_sequence
- (trap_request, $ent, $agent, $gen, $spec, $dt, encode_sequence (@pairs))
- || return $this->ber_error ("encoding trap PDU");
- return $this->wrap_request ($request);
-}
-
-sub encode_v2_trap_request ($@) {
- my($this, @pairs) = @_;
-
- return encode_request_3($this, trap2_request, \@pairs);
-}
-
-sub decode_get_response {
- my($this, $response) = @_;
- my @rest;
- @{$this->{'unwrapped'}};
-}
-
-sub decode_trap_request ($$) {
- my ($this, $trap) = @_;
- my ($snmp_version, $community, $ent, $agent, $gen, $spec, $dt,
- $request_id, $error_status, $error_index,
- $bindings);
- ($snmp_version, $community,
- $ent, $agent,
- $gen, $spec, $dt,
- $bindings)
- = decode_by_template ($trap, "%{%i%s%*{%O%A%i%i%u%{%@",
- trap_request);
- if (!defined $snmp_version) {
- ($snmp_version, $community,
- $request_id, $error_status, $error_index,
- $bindings)
- = decode_by_template ($trap, "%{%i%s%*{%i%i%i%{%@",
- trap2_request);
- if (!defined $snmp_version) {
- ($snmp_version, $community,$request_id, $error_status, $error_index, $bindings)
- = decode_by_template ($trap, "%{%i%s%*{%i%i%i%{%@", inform_request);
- }
- return $this->error_return ("v2 trap/inform request contained errorStatus/errorIndex "
- .$error_status."/".$error_index)
- if defined $error_status && defined $error_index
- && ($error_status != 0 || $error_index != 0);
- }
- if (!defined $snmp_version) {
- return $this->error_return ("BER error decoding trap:\n ".$BER::errmsg);
- }
- return ($community, $ent, $agent, $gen, $spec, $dt, $bindings);
-}
-
-sub wait_for_response {
- my($this) = shift;
- my($timeout) = shift || 10.0;
- my($rin,$win,$ein) = ('','','');
- my($rout,$wout,$eout);
- vec($rin,$this->sockfileno,1) = 1;
- select($rout=$rin,$wout=$win,$eout=$ein,$timeout);
-}
-
-sub get_request_response ($@) {
- my($this, @oids) = @_;
- return $this->request_response_5 ($this->encode_get_request (@oids),
- get_response, \@oids, 1);
-}
-
-sub set_request_response ($@) {
- my($this, @pairs) = @_;
- return $this->request_response_5 ($this->encode_set_request (@pairs),
- get_response, \@pairs, 1);
-}
-
-sub getnext_request_response ($@) {
- my($this,@oids) = @_;
- return $this->request_response_5 ($this->encode_getnext_request (@oids),
- get_response, \@oids, 1);
-}
-
-sub getbulk_request_response ($$$@) {
- my($this,$non_repeaters,$max_repetitions,@oids) = @_;
- return $this->request_response_5
- ($this->encode_getbulk_request ($non_repeaters,$max_repetitions,@oids),
- get_response, \@oids, 1);
-}
-
-sub trap_request_send ($$$$$$@) {
- my($this, $ent, $agent, $gen, $spec, $dt, @pairs) = @_;
- my($req);
-
- $req = $this->encode_trap_request ($ent, $agent, $gen, $spec, $dt, @pairs);
- ## Encoding may have returned an error.
- return undef unless defined $req;
- $this->send_query($req)
- || return $this->error ("send_trap: $!");
- return 1;
-}
-
-sub v2_trap_request_send ($$$@) {
- my($this, $trap_oid, $dt, @pairs) = @_;
- my @sysUptime_OID = ( 1,3,6,1,2,1,1,3 );
- my @snmpTrapOID_OID = ( 1,3,6,1,6,3,1,1,4,1 );
- my($req);
-
- unshift @pairs, [encode_oid (@snmpTrapOID_OID,0),
- encode_oid (@{$trap_oid})];
- unshift @pairs, [encode_oid (@sysUptime_OID,0),
- encode_timeticks ($dt)];
- $req = $this->encode_v2_trap_request (@pairs);
- ## Encoding may have returned an error.
- return undef unless defined $req;
- $this->send_query($req)
- || return $this->error ("send_trap: $!");
- return 1;
-}
-
-sub request_response_5 ($$$$$) {
- my ($this, $req, $response_tag, $oids, $errorp) = @_;
- my $retries = $this->retries;
- my $timeout = $this->timeout;
- my ($nfound, $timeleft);
-
- ## Encoding may have returned an error.
- return undef unless defined $req;
-
- $timeleft = $timeout;
- while ($retries > 0) {
- $this->send_query ($req)
- || return $this->error ("send_query: $!");
- # IlvJa
- # Add request pdu to capture_buffer
- push @{$this->{'capture_buffer'}}, $req
- if (defined $this->{'capture_buffer'}
- and ref $this->{'capture_buffer'} eq 'ARRAY');
- #
- wait_for_response:
- ($nfound, $timeleft) = $this->wait_for_response($timeleft);
- if ($nfound > 0) {
- my($response_length);
-
- $response_length
- = $this->receive_response_3 ($response_tag, $oids, $errorp, 1);
- if ($response_length) {
- # IlvJa
- # Add response pdu to capture_buffer
- push (@{$this->{'capture_buffer'}},
- substr($this->{'pdu_buffer'}, 0, $response_length)
- )
- if (defined $this->{'capture_buffer'}
- and ref $this->{'capture_buffer'} eq 'ARRAY');
- #
- return $response_length;
- } elsif (defined ($response_length)) {
- goto wait_for_response;
- # A response has been received, but for a different
- # request ID or from a different IP address.
- } else {
- return undef;
- }
- } else {
- ## No response received - retry
- --$retries;
- $timeout *= $this->backoff;
- $timeleft = $timeout;
- }
- }
- # IlvJa
- # Add empty packet to capture_buffer
- push @{$this->{'capture_buffer'}}, ""
- if (defined $this->{'capture_buffer'}
- and ref $this->{'capture_buffer'} eq 'ARRAY');
- #
- $this->error ("no response received");
-}
-
-sub map_table ($$$) {
- my ($session, $columns, $mapfn) = @_;
- return $session->map_table_4 ($columns, $mapfn,
- $session->default_max_repetitions ());
-}
-
-sub map_table_4 ($$$$) {
- my ($session, $columns, $mapfn, $max_repetitions) = @_;
- return $session->map_table_start_end ($columns, $mapfn,
- "", undef,
- $max_repetitions);
-}
-
-sub map_table_start_end ($$$$$$) {
- my ($session, $columns, $mapfn, $start, $end, $max_repetitions) = @_;
-
- my @encoded_oids;
- my $call_counter = 0;
- my $base_index = $start;
-
- do {
- foreach (@encoded_oids = @{$columns}) {
- $_=encode_oid (@{$_},split '\.',$base_index)
- || return $session->ber_error ("encoding OID $base_index");
- }
- if ($session->getnext_request_response (@encoded_oids)) {
- my $response = $session->pdu_buffer;
- my ($bindings) = $session->decode_get_response ($response);
- my $smallest_index = undef;
- my @collected_values = ();
-
- my @bases = @{$columns};
- while ($bindings ne '') {
- my ($binding, $oid, $value);
- my $base = shift @bases;
- ($binding, $bindings) = decode_sequence ($bindings);
- ($oid, $value) = decode_by_template ($binding, "%O%@");
-
- my $out_index;
-
- $out_index = &oid_diff ($base, $oid);
- my $cmp;
- if (!defined $smallest_index
- || ($cmp = index_compare ($out_index,$smallest_index)) == -1) {
- $smallest_index = $out_index;
- grep ($_=undef, @collected_values);
- push @collected_values, $value;
- } elsif ($cmp == 1) {
- push @collected_values, undef;
- } else {
- push @collected_values, $value;
- }
- }
- (++$call_counter,
- &$mapfn ($smallest_index, @collected_values))
- if defined $smallest_index;
- $base_index = $smallest_index;
- } else {
- return undef;
- }
- }
- while (defined $base_index
- && (!defined $end || index_compare ($base_index, $end) < 0));
- $call_counter;
-}
-
-sub index_compare ($$) {
- my ($i1, $i2) = @_;
- $i1 = '' unless defined $i1;
- $i2 = '' unless defined $i2;
- if ($i1 eq '') {
- return $i2 eq '' ? 0 : 1;
- } elsif ($i2 eq '') {
- return 1;
- } elsif (!$i1) {
- return $i2 eq '' ? 1 : !$i2 ? 0 : 1;
- } elsif (!$i2) {
- return -1;
- } else {
- my ($f1,$r1) = split('\.',$i1,2);
- my ($f2,$r2) = split('\.',$i2,2);
-
- if ($f1 < $f2) {
- return -1;
- } elsif ($f1 > $f2) {
- return 1;
- } else {
- return index_compare ($r1,$r2);
- }
- }
-}
-
-sub oid_diff ($$) {
- my($base, $full) = @_;
- my $base_dotnot = join ('.',@{$base});
- my $full_dotnot = BER::pretty_oid ($full);
-
- return undef unless substr ($full_dotnot, 0, length $base_dotnot)
- eq $base_dotnot
- && substr ($full_dotnot, length $base_dotnot, 1) eq '.';
- substr ($full_dotnot, length ($base_dotnot)+1);
-}
-
-# Pretty_address returns a human-readable representation of an IPv4 or IPv6 address.
-sub pretty_address {
- my($addr) = shift;
- my($port, $addrunpack, $addrstr);
-
- # Disable strict subs to stop old versions of perl from
- # complaining about AF_INET6 when Socket6 is not available
-
- if( (defined $ipv6_addr_len) && (length $addr == $ipv6_addr_len)) {
- ($port,$addrunpack) = Socket6::unpack_sockaddr_in6 ($addr);
- $addrstr = inet_ntop (AF_INET6(), $addrunpack);
- } else {
- ($port,$addrunpack) = unpack_sockaddr_in ($addr);
- $addrstr = inet_ntoa ($addrunpack);
- }
-
- return sprintf ("[%s].%d", $addrstr, $port);
-}
-
-sub version { $VERSION; }
-
-
-sub error_return ($$) {
- my ($this,$message) = @_;
- $SNMP_Session::errmsg = $message;
- unless ($SNMP_Session::suppress_warnings) {
- $message =~ s/^/ /mg;
- carp ("Error:\n".$message."\n");
- }
- return undef;
-}
-
-sub error ($$) {
- my ($this,$message) = @_;
- my $session = $this->to_string;
- $SNMP_Session::errmsg = $message."\n".$session;
- unless ($SNMP_Session::suppress_warnings) {
- $session =~ s/^/ /mg;
- $message =~ s/^/ /mg;
- carp ("SNMP Error:\n".$SNMP_Session::errmsg."\n");
- }
- return undef;
-}
-
-sub ber_error ($$) {
- my ($this,$type) = @_;
- my ($errmsg) = $BER::errmsg;
-
- $errmsg =~ s/^/ /mg;
- return $this->error ("$type:\n$errmsg");
-}
-
-package SNMPv1_Session;
-
-use strict qw(vars subs); # see above
-use vars qw(@ISA);
-use SNMP_Session;
-use Socket;
-use BER;
-use IO::Socket;
-use Carp;
-
-BEGIN {
- if($SNMP_Session::ipv6available) {
- import IO::Socket::INET6;
- Socket6->import(qw(pack_sockaddr_in6 inet_pton getaddrinfo));
- }
-}
-
-@ISA = qw(SNMP_Session);
-
-sub snmp_version { 0 }
-
-# Supports both IPv4 and IPv6.
-# Numeric IPv6 addresses must be passed between square brackets []
-sub open {
- my($this,
- $remote_hostname,$community,$port,
- $max_pdu_len,$local_port,$max_repetitions,
- $local_hostname,$ipv4only) = @_;
- my($remote_addr,$socket,$sockfamily);
-
- $ipv4only = 1 unless defined $ipv4only;
- $sockfamily = AF_INET;
-
- $community = 'public' unless defined $community;
- $port = SNMP_Session::standard_udp_port unless defined $port;
- $max_pdu_len = 8000 unless defined $max_pdu_len;
- $max_repetitions = $default_max_repetitions
- unless defined $max_repetitions;
-
- if ($ipv4only || ! $SNMP_Session::ipv6available) {
- # IPv4-only code, uses only Socket and INET calls
- if (defined $remote_hostname) {
- $remote_addr = inet_aton ($remote_hostname)
- or return $this->error_return ("can't resolve \"$remote_hostname\" to IP address");
- }
- if ($SNMP_Session::recycle_socket && defined $the_socket) {
- $socket = $the_socket;
- } else {
- $socket = IO::Socket::INET->new(Proto => 17,
- Type => SOCK_DGRAM,
- LocalAddr => $local_hostname,
- LocalPort => $local_port)
- || return $this->error_return ("creating socket: $!");
- $the_socket = $socket
- if $SNMP_Session::recycle_socket;
- }
- $remote_addr = pack_sockaddr_in ($port, $remote_addr)
- if defined $remote_addr;
- } else {
- # IPv6-capable code. Will use IPv6 or IPv4 depending on the address.
- # Uses Socket6 and INET6 calls.
-
- # If it's a numeric IPv6 addresses, remove square brackets
- if ($remote_hostname =~ /^\[(.*)\]$/) {
- $remote_hostname = $1;
- }
-
- my (@res, $socktype_tmp, $proto_tmp, $canonname_tmp);
- @res = getaddrinfo($remote_hostname, $port, AF_UNSPEC, SOCK_DGRAM);
- ($sockfamily, $socktype_tmp, $proto_tmp, $remote_addr, $canonname_tmp) = @res;
- if (scalar(@res) < 5) {
- return $this->error_return ("can't resolve \"$remote_hostname\" to IPv6 address");
- }
-
- if ($SNMP_Session::recycle_socket && defined $the_socket) {
- $socket = $the_socket;
- } elsif ($sockfamily == AF_INET) {
- $socket = IO::Socket::INET->new(Proto => 17,
- Type => SOCK_DGRAM,
- LocalAddr => $local_hostname,
- LocalPort => $local_port)
- || return $this->error_return ("creating socket: $!");
- } else {
- $socket = IO::Socket::INET6->new(Proto => 17,
- Type => SOCK_DGRAM,
- LocalAddr => $local_hostname,
- LocalPort => $local_port)
- || return $this->error_return ("creating socket: $!");
- $the_socket = $socket
- if $SNMP_Session::recycle_socket;
- }
- }
- bless {
- 'sock' => $socket,
- 'sockfileno' => fileno ($socket),
- 'community' => $community,
- 'remote_hostname' => $remote_hostname,
- 'remote_addr' => $remote_addr,
- 'sockfamily' => $sockfamily,
- 'max_pdu_len' => $max_pdu_len,
- 'pdu_buffer' => '\0' x $max_pdu_len,
- 'request_id' => (int (rand 0x10000) << 16)
- + int (rand 0x10000) - 0x80000000,
- 'timeout' => $default_timeout,
- 'retries' => $default_retries,
- 'backoff' => $default_backoff,
- 'debug' => $default_debug,
- 'error_status' => 0,
- 'error_index' => 0,
- 'default_max_repetitions' => $max_repetitions,
- 'use_getbulk' => 1,
- 'lenient_source_address_matching' => 1,
- 'lenient_source_port_matching' => 1,
- 'avoid_negative_request_ids' => $SNMP_Session::default_avoid_negative_request_ids,
- 'use_16bit_request_ids' => $SNMP_Session::default_use_16bit_request_ids,
- 'capture_buffer' => undef,
- };
-}
-
-sub open_trap_session (@) {
- my ($this, $port) = @_;
- $port = 162 unless defined $port;
- return $this->open (undef, "", 161, undef, $port);
-}
-
-sub sock { $_[0]->{sock} }
-sub sockfileno { $_[0]->{sockfileno} }
-sub remote_addr { $_[0]->{remote_addr} }
-sub pdu_buffer { $_[0]->{pdu_buffer} }
-sub max_pdu_len { $_[0]->{max_pdu_len} }
-sub default_max_repetitions {
- defined $_[1]
- ? $_[0]->{default_max_repetitions} = $_[1]
- : $_[0]->{default_max_repetitions} }
-sub debug { defined $_[1] ? $_[0]->{debug} = $_[1] : $_[0]->{debug} }
-
-sub close {
- my($this) = shift;
- ## Avoid closing the socket if it may be shared with other session
- ## objects.
- if (! defined $the_socket || $this->sock ne $the_socket) {
- close ($this->sock) || $this->error ("close: $!");
- }
-}
-
-sub wrap_request {
- my($this) = shift;
- my($request) = shift;
-
- encode_sequence (encode_int ($this->snmp_version),
- encode_string ($this->{community}),
- $request)
- || return $this->ber_error ("wrapping up request PDU");
-}
-
-my @error_status_code = qw(noError tooBig noSuchName badValue readOnly
- genErr noAccess wrongType wrongLength
- wrongEncoding wrongValue noCreation
- inconsistentValue resourceUnavailable
- commitFailed undoFailed authorizationError
- notWritable inconsistentName);
-
-sub unwrap_response_5b {
- my ($this,$response,$tag,$oids,$errorp) = @_;
- my ($community,$request_id,@rest,$snmpver);
-
- ($snmpver,$community,$request_id,
- $this->{error_status},
- $this->{error_index},
- @rest)
- = decode_by_template ($response, "%{%i%s%*{%i%i%i%{%@",
- $tag);
- return $this->ber_error ("Error decoding response PDU")
- unless defined $snmpver;
- return $this->error ("Received SNMP response with unknown snmp-version field $snmpver")
- unless $snmpver == $this->snmp_version;
- if ($this->{error_status} != 0) {
- if ($errorp) {
- my ($oid, $errmsg);
- $errmsg = $error_status_code[$this->{error_status}] || $this->{error_status};
- $oid = $oids->[$this->{error_index}-1]
- if $this->{error_index} > 0 && $this->{error_index}-1 <= $#{$oids};
- $oid = $oid->[0]
- if ref($oid) eq 'ARRAY';
- return ($community, $request_id,
- $this->error ("Received SNMP response with error code\n"
- ." error status: $errmsg\n"
- ." index ".$this->{error_index}
- .(defined $oid
- ? " (OID: ".&BER::pretty_oid($oid).")"
- : "")));
- } else {
- if ($this->{error_index} == 1) {
- @rest[$this->{error_index}-1..$this->{error_index}] = ();
- }
- }
- }
- ($community, $request_id, @rest);
-}
-
-sub send_query ($$) {
- my ($this,$query) = @_;
- send ($this->sock,$query,0,$this->remote_addr);
-}
-
-## Compare two sockaddr_in structures for equality. This is used when
-## matching incoming responses with outstanding requests. Previous
-## versions of the code simply did a bytewise comparison ("eq") of the
-## two sockaddr_in structures, but this didn't work on some systems
-## where sockaddr_in contains other elements than just the IP address
-## and port number, notably FreeBSD.
-##
-## We allow for varying degrees of leniency when checking the source
-## address. By default we now ignore it altogether, because there are
-## agents that don't respond from UDP port 161, and there are agents
-## that don't respond from the IP address the query had been sent to.
-##
-## The address family is stored in the session object. We could use
-## sockaddr_family() to determine it from the sockaddr, but this function
-## is only available in recent versions of Socket.pm.
-sub sa_equal_p ($$$) {
- my ($this, $sa1, $sa2) = @_;
- my ($p1,$a1,$p2,$a2);
-
- # Disable strict subs to stop old versions of perl from
- # complaining about AF_INET6 when Socket6 is not available
- if($this->{'sockfamily'} == AF_INET) {
- # IPv4 addresses
- ($p1,$a1) = unpack_sockaddr_in ($sa1);
- ($p2,$a2) = unpack_sockaddr_in ($sa2);
- } elsif($this->{'sockfamily'} == AF_INET6()) {
- # IPv6 addresses
- ($p1,$a1) = Socket6::unpack_sockaddr_in6 ($sa1);
- ($p2,$a2) = Socket6::unpack_sockaddr_in6 ($sa2);
- } else {
- return 0;
- }
- use strict "subs";
-
- if (! $this->{'lenient_source_address_matching'}) {
- return 0 if $a1 ne $a2;
- }
- if (! $this->{'lenient_source_port_matching'}) {
- return 0 if $p1 != $p2;
- }
- return 1;
-}
-
-sub receive_response_3 {
- my ($this, $response_tag, $oids, $errorp, $dont_block_p) = @_;
- my ($remote_addr);
- my $flags = 0;
- $flags = $dont_wait_flags if defined $dont_block_p and $dont_block_p;
- $remote_addr = recv ($this->sock,$this->{'pdu_buffer'},$this->max_pdu_len,$flags);
- return $this->error ("receiving response PDU: $!")
- unless defined $remote_addr;
- return $this->error ("short (".length $this->{'pdu_buffer'}
- ." bytes) response PDU")
- unless length $this->{'pdu_buffer'} > 2;
- my $response = $this->{'pdu_buffer'};
- ##
- ## Check whether the response came from the address we've sent the
- ## request to. If this is not the case, we should probably ignore
- ## it, as it may relate to another request.
- ##
- if (defined $this->{'remote_addr'}) {
- if (! $this->sa_equal_p ($remote_addr, $this->{'remote_addr'})) {
- if ($this->{'debug'} && !$SNMP_Session::recycle_socket) {
- carp ("Response came from ".&SNMP_Session::pretty_address($remote_addr)
- .", not ".&SNMP_Session::pretty_address($this->{'remote_addr'}))
- unless $SNMP_Session::suppress_warnings;
- }
- return 0;
- }
- }
- $this->{'last_sender_addr'} = $remote_addr;
- my ($response_community, $response_id, @unwrapped)
- = $this->unwrap_response_5b ($response, $response_tag,
- $oids, $errorp);
- if ($response_community ne $this->{community}
- || $response_id ne $this->{request_id}) {
- if ($this->{'debug'}) {
- carp ("$response_community != $this->{community}")
- unless $SNMP_Session::suppress_warnings
- || $response_community eq $this->{community};
- carp ("$response_id != $this->{request_id}")
- unless $SNMP_Session::suppress_warnings
- || $response_id == $this->{request_id};
- }
- return 0;
- }
- if (!defined $unwrapped[0]) {
- $this->{'unwrapped'} = undef;
- return undef;
- }
- $this->{'unwrapped'} = \@unwrapped;
- return length $this->pdu_buffer;
-}
-
-sub receive_trap {
- my ($this) = @_;
- my ($remote_addr, $iaddr, $port, $trap);
- $remote_addr = recv ($this->sock,$this->{'pdu_buffer'},$this->max_pdu_len,0);
- return undef unless $remote_addr;
-
- if( (defined $ipv6_addr_len) && (length $remote_addr == $ipv6_addr_len)) {
- ($port,$iaddr) = Socket6::unpack_sockaddr_in6($remote_addr);
- } else {
- ($port,$iaddr) = unpack_sockaddr_in($remote_addr);
- }
-
- $trap = $this->{'pdu_buffer'};
- return ($trap, $iaddr, $port);
-}
-
-sub describe {
- my($this) = shift;
- print $this->to_string (),"\n";
-}
-
-sub to_string {
- my($this) = shift;
- my ($class,$prefix);
-
- $class = ref($this);
- $prefix = ' ' x (length ($class) + 2);
- ($class
- .(defined $this->{remote_hostname}
- ? " (remote host: \"".$this->{remote_hostname}."\""
- ." ".&SNMP_Session::pretty_address ($this->remote_addr).")"
- : " (no remote host specified)")
- ."\n"
- .$prefix." community: \"".$this->{'community'}."\"\n"
- .$prefix." request ID: ".$this->{'request_id'}."\n"
- .$prefix."PDU bufsize: ".$this->{'max_pdu_len'}." bytes\n"
- .$prefix." timeout: ".$this->{timeout}."s\n"
- .$prefix." retries: ".$this->{retries}."\n"
- .$prefix." backoff: ".$this->{backoff}.")");
-## sprintf ("SNMP_Session: %s (size %d timeout %g)",
-## &SNMP_Session::pretty_address ($this->remote_addr),$this->max_pdu_len,
-## $this->timeout);
-}
-
-### SNMP Agent support
-### contributed by Mike McCauley <mikem@open.com.au>
-###
-sub receive_request {
- my ($this) = @_;
- my ($remote_addr, $iaddr, $port, $request);
-
- $remote_addr = recv($this->sock, $this->{'pdu_buffer'},
- $this->{'max_pdu_len'}, 0);
- return undef unless $remote_addr;
-
- if( (defined $ipv6_addr_len) && (length $remote_addr == $ipv6_addr_len)) {
- ($port,$iaddr) = Socket6::unpack_sockaddr_in6($remote_addr);
- } else {
- ($port,$iaddr) = unpack_sockaddr_in($remote_addr);
- }
-
- $request = $this->{'pdu_buffer'};
- return ($request, $iaddr, $port);
-}
-
-sub decode_request {
- my ($this, $request) = @_;
- my ($snmp_version, $community, $requestid, $errorstatus, $errorindex, $bindings);
-
- ($snmp_version, $community, $requestid, $errorstatus, $errorindex, $bindings)
- = decode_by_template ($request, "%{%i%s%*{%i%i%i%@", SNMP_Session::get_request);
- if (defined $snmp_version)
- {
- # Its a valid get_request
- return(SNMP_Session::get_request, $requestid, $bindings, $community);
- }
-
- ($snmp_version, $community, $requestid, $errorstatus, $errorindex, $bindings)
- = decode_by_template ($request, "%{%i%s%*{%i%i%i%@", SNMP_Session::getnext_request);
- if (defined $snmp_version)
- {
- # Its a valid getnext_request
- return(SNMP_Session::getnext_request, $requestid, $bindings, $community);
- }
-
- ($snmp_version, $community, $requestid, $errorstatus, $errorindex, $bindings)
- = decode_by_template ($request, "%{%i%s%*{%i%i%i%@", SNMP_Session::set_request);
- if (defined $snmp_version)
- {
- # Its a valid set_request
- return(SNMP_Session::set_request, $requestid, $bindings, $community);
- }
-
- # Something wrong with this packet
- # Decode failed
- return undef;
-}
-
-package SNMPv2c_Session;
-use strict qw(vars subs); # see above
-use vars qw(@ISA);
-use SNMP_Session;
-use BER;
-use Carp;
-
-@ISA = qw(SNMPv1_Session);
-
-sub snmp_version { 1 }
-
-sub open {
- my $session = SNMPv1_Session::open (@_);
- return undef unless defined $session;
- return bless $session;
-}
-
-## map_table_start_end using get-bulk
-##
-sub map_table_start_end ($$$$$$) {
- my ($session, $columns, $mapfn, $start, $end, $max_repetitions) = @_;
-
- my @encoded_oids;
- my $call_counter = 0;
- my $base_index = $start;
- my $ncols = @{$columns};
- my @collected_values = ();
-
- if (! $session->{'use_getbulk'}) {
- return SNMP_Session::map_table_start_end
- ($session, $columns, $mapfn, $start, $end, $max_repetitions);
- }
- $max_repetitions = $session->default_max_repetitions
- unless defined $max_repetitions;
-
- for (;;) {
- foreach (@encoded_oids = @{$columns}) {
- $_=encode_oid (@{$_},split '\.',$base_index)
- || return $session->ber_error ("encoding OID $base_index");
- }
- if ($session->getbulk_request_response (0, $max_repetitions,
- @encoded_oids)) {
- my $response = $session->pdu_buffer;
- my ($bindings) = $session->decode_get_response ($response);
- my @colstack = ();
- my $k = 0;
- my $j;
-
- my $min_index = undef;
-
- my @bases = @{$columns};
- my $n_bindings = 0;
- my $binding;
-
- ## Copy all bindings into the colstack.
- ## The colstack is a vector of vectors.
- ## It contains one vector for each "repeater" variable.
- ##
- while ($bindings ne '') {
- ($binding, $bindings) = decode_sequence ($bindings);
- my ($oid, $value) = decode_by_template ($binding, "%O%@");
-
- push @{$colstack[$k]}, [$oid, $value];
- ++$k; $k = 0 if $k >= $ncols;
- }
-
- ## Now collect rows from the column stack:
- ##
- ## Iterate through the column stacks to find the smallest
- ## index, collecting the values for that index in
- ## @collected_values.
- ##
- ## As long as a row can be assembled, the map function is
- ## called on it and the iteration proceeds.
- ##
- $base_index = undef;
- walk_rows_from_pdu:
- for (;;) {
- my $min_index = undef;
-
- for ($k = 0; $k < $ncols; ++$k) {
- $collected_values[$k] = undef;
- my $pair = $colstack[$k]->[0];
- unless (defined $pair) {
- $min_index = undef;
- last walk_rows_from_pdu;
- }
- my $this_index
- = SNMP_Session::oid_diff ($columns->[$k], $pair->[0]);
- if (defined $this_index) {
- my $cmp
- = !defined $min_index
- ? -1
- : SNMP_Session::index_compare
- ($this_index, $min_index);
- if ($cmp == -1) {
- for ($j = 0; $j < $k; ++$j) {
- unshift (@{$colstack[$j]},
- [$min_index,
- $collected_values[$j]]);
- $collected_values[$j] = undef;
- }
- $min_index = $this_index;
- }
- if ($cmp <= 0) {
- $collected_values[$k] = $pair->[1];
- shift @{$colstack[$k]};
- }
- }
- }
- ($base_index = undef), last
- if !defined $min_index;
- last
- if defined $end
- and SNMP_Session::index_compare ($min_index, $end) >= 0;
- &$mapfn ($min_index, @collected_values);
- ++$call_counter;
- $base_index = $min_index;
- }
- } else {
- return undef;
- }
- last if !defined $base_index;
- last
- if defined $end
- and SNMP_Session::index_compare ($base_index, $end) >= 0;
- }
- $call_counter;
-}
-
-1;
diff --git a/src/lib/mrtg2/SNMP_util.pm b/src/lib/mrtg2/SNMP_util.pm
deleted file mode 100644
index 7ce96a6..0000000
--- a/src/lib/mrtg2/SNMP_util.pm
+++ /dev/null
@@ -1,1355 +0,0 @@
-### - *- mode: Perl -*-
-######################################################################
-### SNMP_util -- SNMP utilities using SNMP_Session.pm and BER.pm
-######################################################################
-### Copyright (c) 1998-2010, Mike Mitchell.
-###
-### This program is free software; you can redistribute it under the
-### "Artistic License 2.0" included in this distribution
-### (file "Artistic").
-######################################################################
-### Created by: Mike Mitchell <Mike.Mitchell@sas.com>
-###
-### Contributions and fixes by:
-###
-### Tobias Oetiker <tobi@oetiker.ch>: Basic layout
-### Simon Leinen <simon@switch.ch>: SNMP_session.pm/BER.pm
-### Jeff Allen <jeff.allen@acm.org>: length() of undefined value
-### Johannes Demel <demel@zid.tuwien.ac.at>: MIB file parse problem
-### Simon Leinen <simon@switch.ch>: more OIDs from Interface MIB
-### Jacques Supcik <supcik@ip-plus.net>: Specify local IP, port
-### Tobias Oetiker <tobi@oetiker.ch>: HASH as first OID to set SNMP options
-### Simon Leinen <simon@switch.ch>: 'undefined port' bug
-### Daniel McDonald <dmcdonald@digicontech.com>: request for getbulk support
-### Laurent Girod <it.fb@net2000.ch>: code for snmpwalkhash
-### Ian Duplisse <i.duplisse@cablelabs.com>: MIB parsing suggestions
-### Jakob Ilves <jakob.ilves@oracle.com>: return_array_refs for snmpwalk()
-### Valerio Bontempi <v.bontempi@inwind.it>: IPv6 support
-### Lorenzo Colitti <lorenzo@colitti.com>: IPv6 support
-### Joerg Kummer <JOERG.KUMMER@Roche.COM>: TimeTicks support in snmpset()
-### Christopher J. Tengi <tengi@CS.Princeton.EDU>: Gauge32 support in snmpset()
-### Nicolai Petri <nicolai@catpipe.net>: hashref passing for snmpwalkhash()
-### <jaccobs@online.nl>: parse NOTIFICATION-TYPE in MIB
-### Dan Thorson <Dan.Thorson@seagate.com>: handle quotes in MIB comments better
-######################################################################
-
-package SNMP_util;
-
-require 5.004;
-
-use strict;
-use vars qw(@ISA @EXPORT $VERSION);
-use Exporter;
-use Carp;
-
-use BER "1.02";
-use SNMP_Session "1.00";
-use Socket;
-
-$VERSION = '1.15';
-
-@ISA = qw(Exporter);
-
-@EXPORT = qw(snmpget snmpgetnext snmpwalk snmpset snmptrap snmpgetbulk snmpmaptable snmpmaptable4 snmpwalkhash snmpmapOID snmpMIB_to_OID snmpLoad_OID_Cache snmpQueue_MIB_File);
-
-# The OID numbers from RFC1213 (MIB-II) and RFC1315 (Frame Relay)
-# are pre-loaded below.
-%SNMP_util::OIDS =
- (
- 'iso' => '1',
- 'org' => '1.3',
- 'dod' => '1.3.6',
- 'internet' => '1.3.6.1',
- 'directory' => '1.3.6.1.1',
- 'mgmt' => '1.3.6.1.2',
- 'mib-2' => '1.3.6.1.2.1',
- 'system' => '1.3.6.1.2.1.1',
- 'sysDescr' => '1.3.6.1.2.1.1.1.0',
- 'sysObjectID' => '1.3.6.1.2.1.1.2.0',
- 'sysUpTime' => '1.3.6.1.2.1.1.3.0',
- 'sysUptime' => '1.3.6.1.2.1.1.3.0',
- 'sysContact' => '1.3.6.1.2.1.1.4.0',
- 'sysName' => '1.3.6.1.2.1.1.5.0',
- 'sysLocation' => '1.3.6.1.2.1.1.6.0',
- 'sysServices' => '1.3.6.1.2.1.1.7.0',
- 'interfaces' => '1.3.6.1.2.1.2',
- 'ifNumber' => '1.3.6.1.2.1.2.1.0',
- 'ifTable' => '1.3.6.1.2.1.2.2',
- 'ifEntry' => '1.3.6.1.2.1.2.2.1',
- 'ifIndex' => '1.3.6.1.2.1.2.2.1.1',
- 'ifInOctets' => '1.3.6.1.2.1.2.2.1.10',
- 'ifInUcastPkts' => '1.3.6.1.2.1.2.2.1.11',
- 'ifInNUcastPkts' => '1.3.6.1.2.1.2.2.1.12',
- 'ifInDiscards' => '1.3.6.1.2.1.2.2.1.13',
- 'ifInErrors' => '1.3.6.1.2.1.2.2.1.14',
- 'ifInUnknownProtos' => '1.3.6.1.2.1.2.2.1.15',
- 'ifOutOctets' => '1.3.6.1.2.1.2.2.1.16',
- 'ifOutUcastPkts' => '1.3.6.1.2.1.2.2.1.17',
- 'ifOutNUcastPkts' => '1.3.6.1.2.1.2.2.1.18',
- 'ifOutDiscards' => '1.3.6.1.2.1.2.2.1.19',
- 'ifDescr' => '1.3.6.1.2.1.2.2.1.2',
- 'ifOutErrors' => '1.3.6.1.2.1.2.2.1.20',
- 'ifOutQLen' => '1.3.6.1.2.1.2.2.1.21',
- 'ifSpecific' => '1.3.6.1.2.1.2.2.1.22',
- 'ifType' => '1.3.6.1.2.1.2.2.1.3',
- 'ifMtu' => '1.3.6.1.2.1.2.2.1.4',
- 'ifSpeed' => '1.3.6.1.2.1.2.2.1.5',
- 'ifPhysAddress' => '1.3.6.1.2.1.2.2.1.6',
- 'ifAdminHack' => '1.3.6.1.2.1.2.2.1.7',
- 'ifAdminStatus' => '1.3.6.1.2.1.2.2.1.7',
- 'ifOperHack' => '1.3.6.1.2.1.2.2.1.8',
- 'ifOperStatus' => '1.3.6.1.2.1.2.2.1.8',
- 'ifLastChange' => '1.3.6.1.2.1.2.2.1.9',
- 'at' => '1.3.6.1.2.1.3',
- 'atTable' => '1.3.6.1.2.1.3.1',
- 'atEntry' => '1.3.6.1.2.1.3.1.1',
- 'atIfIndex' => '1.3.6.1.2.1.3.1.1.1',
- 'atPhysAddress' => '1.3.6.1.2.1.3.1.1.2',
- 'atNetAddress' => '1.3.6.1.2.1.3.1.1.3',
- 'ip' => '1.3.6.1.2.1.4',
- 'ipForwarding' => '1.3.6.1.2.1.4.1',
- 'ipOutRequests' => '1.3.6.1.2.1.4.10',
- 'ipOutDiscards' => '1.3.6.1.2.1.4.11',
- 'ipOutNoRoutes' => '1.3.6.1.2.1.4.12',
- 'ipReasmTimeout' => '1.3.6.1.2.1.4.13',
- 'ipReasmReqds' => '1.3.6.1.2.1.4.14',
- 'ipReasmOKs' => '1.3.6.1.2.1.4.15',
- 'ipReasmFails' => '1.3.6.1.2.1.4.16',
- 'ipFragOKs' => '1.3.6.1.2.1.4.17',
- 'ipFragFails' => '1.3.6.1.2.1.4.18',
- 'ipFragCreates' => '1.3.6.1.2.1.4.19',
- 'ipDefaultTTL' => '1.3.6.1.2.1.4.2',
- 'ipAddrTable' => '1.3.6.1.2.1.4.20',
- 'ipAddrEntry' => '1.3.6.1.2.1.4.20.1',
- 'ipAdEntAddr' => '1.3.6.1.2.1.4.20.1.1',
- 'ipAdEntIfIndex' => '1.3.6.1.2.1.4.20.1.2',
- 'ipAdEntNetMask' => '1.3.6.1.2.1.4.20.1.3',
- 'ipAdEntBcastAddr' => '1.3.6.1.2.1.4.20.1.4',
- 'ipAdEntReasmMaxSize' => '1.3.6.1.2.1.4.20.1.5',
- 'ipRouteTable' => '1.3.6.1.2.1.4.21',
- 'ipRouteEntry' => '1.3.6.1.2.1.4.21.1',
- 'ipRouteDest' => '1.3.6.1.2.1.4.21.1.1',
- 'ipRouteAge' => '1.3.6.1.2.1.4.21.1.10',
- 'ipRouteMask' => '1.3.6.1.2.1.4.21.1.11',
- 'ipRouteMetric5' => '1.3.6.1.2.1.4.21.1.12',
- 'ipRouteInfo' => '1.3.6.1.2.1.4.21.1.13',
- 'ipRouteIfIndex' => '1.3.6.1.2.1.4.21.1.2',
- 'ipRouteMetric1' => '1.3.6.1.2.1.4.21.1.3',
- 'ipRouteMetric2' => '1.3.6.1.2.1.4.21.1.4',
- 'ipRouteMetric3' => '1.3.6.1.2.1.4.21.1.5',
- 'ipRouteMetric4' => '1.3.6.1.2.1.4.21.1.6',
- 'ipRouteNextHop' => '1.3.6.1.2.1.4.21.1.7',
- 'ipRouteType' => '1.3.6.1.2.1.4.21.1.8',
- 'ipRouteProto' => '1.3.6.1.2.1.4.21.1.9',
- 'ipNetToMediaTable' => '1.3.6.1.2.1.4.22',
- 'ipNetToMediaEntry' => '1.3.6.1.2.1.4.22.1',
- 'ipNetToMediaIfIndex' => '1.3.6.1.2.1.4.22.1.1',
- 'ipNetToMediaPhysAddress' => '1.3.6.1.2.1.4.22.1.2',
- 'ipNetToMediaNetAddress' => '1.3.6.1.2.1.4.22.1.3',
- 'ipNetToMediaType' => '1.3.6.1.2.1.4.22.1.4',
- 'ipRoutingDiscards' => '1.3.6.1.2.1.4.23',
- 'ipInReceives' => '1.3.6.1.2.1.4.3',
- 'ipInHdrErrors' => '1.3.6.1.2.1.4.4',
- 'ipInAddrErrors' => '1.3.6.1.2.1.4.5',
- 'ipForwDatagrams' => '1.3.6.1.2.1.4.6',
- 'ipInUnknownProtos' => '1.3.6.1.2.1.4.7',
- 'ipInDiscards' => '1.3.6.1.2.1.4.8',
- 'ipInDelivers' => '1.3.6.1.2.1.4.9',
- 'icmp' => '1.3.6.1.2.1.5',
- 'icmpInMsgs' => '1.3.6.1.2.1.5.1',
- 'icmpInTimestamps' => '1.3.6.1.2.1.5.10',
- 'icmpInTimestampReps' => '1.3.6.1.2.1.5.11',
- 'icmpInAddrMasks' => '1.3.6.1.2.1.5.12',
- 'icmpInAddrMaskReps' => '1.3.6.1.2.1.5.13',
- 'icmpOutMsgs' => '1.3.6.1.2.1.5.14',
- 'icmpOutErrors' => '1.3.6.1.2.1.5.15',
- 'icmpOutDestUnreachs' => '1.3.6.1.2.1.5.16',
- 'icmpOutTimeExcds' => '1.3.6.1.2.1.5.17',
- 'icmpOutParmProbs' => '1.3.6.1.2.1.5.18',
- 'icmpOutSrcQuenchs' => '1.3.6.1.2.1.5.19',
- 'icmpInErrors' => '1.3.6.1.2.1.5.2',
- 'icmpOutRedirects' => '1.3.6.1.2.1.5.20',
- 'icmpOutEchos' => '1.3.6.1.2.1.5.21',
- 'icmpOutEchoReps' => '1.3.6.1.2.1.5.22',
- 'icmpOutTimestamps' => '1.3.6.1.2.1.5.23',
- 'icmpOutTimestampReps' => '1.3.6.1.2.1.5.24',
- 'icmpOutAddrMasks' => '1.3.6.1.2.1.5.25',
- 'icmpOutAddrMaskReps' => '1.3.6.1.2.1.5.26',
- 'icmpInDestUnreachs' => '1.3.6.1.2.1.5.3',
- 'icmpInTimeExcds' => '1.3.6.1.2.1.5.4',
- 'icmpInParmProbs' => '1.3.6.1.2.1.5.5',
- 'icmpInSrcQuenchs' => '1.3.6.1.2.1.5.6',
- 'icmpInRedirects' => '1.3.6.1.2.1.5.7',
- 'icmpInEchos' => '1.3.6.1.2.1.5.8',
- 'icmpInEchoReps' => '1.3.6.1.2.1.5.9',
- 'tcp' => '1.3.6.1.2.1.6',
- 'tcpRtoAlgorithm' => '1.3.6.1.2.1.6.1',
- 'tcpInSegs' => '1.3.6.1.2.1.6.10',
- 'tcpOutSegs' => '1.3.6.1.2.1.6.11',
- 'tcpRetransSegs' => '1.3.6.1.2.1.6.12',
- 'tcpConnTable' => '1.3.6.1.2.1.6.13',
- 'tcpConnEntry' => '1.3.6.1.2.1.6.13.1',
- 'tcpConnState' => '1.3.6.1.2.1.6.13.1.1',
- 'tcpConnLocalAddress' => '1.3.6.1.2.1.6.13.1.2',
- 'tcpConnLocalPort' => '1.3.6.1.2.1.6.13.1.3',
- 'tcpConnRemAddress' => '1.3.6.1.2.1.6.13.1.4',
- 'tcpConnRemPort' => '1.3.6.1.2.1.6.13.1.5',
- 'tcpInErrs' => '1.3.6.1.2.1.6.14',
- 'tcpOutRsts' => '1.3.6.1.2.1.6.15',
- 'tcpRtoMin' => '1.3.6.1.2.1.6.2',
- 'tcpRtoMax' => '1.3.6.1.2.1.6.3',
- 'tcpMaxConn' => '1.3.6.1.2.1.6.4',
- 'tcpActiveOpens' => '1.3.6.1.2.1.6.5',
- 'tcpPassiveOpens' => '1.3.6.1.2.1.6.6',
- 'tcpAttemptFails' => '1.3.6.1.2.1.6.7',
- 'tcpEstabResets' => '1.3.6.1.2.1.6.8',
- 'tcpCurrEstab' => '1.3.6.1.2.1.6.9',
- 'udp' => '1.3.6.1.2.1.7',
- 'udpInDatagrams' => '1.3.6.1.2.1.7.1',
- 'udpNoPorts' => '1.3.6.1.2.1.7.2',
- 'udpInErrors' => '1.3.6.1.2.1.7.3',
- 'udpOutDatagrams' => '1.3.6.1.2.1.7.4',
- 'udpTable' => '1.3.6.1.2.1.7.5',
- 'udpEntry' => '1.3.6.1.2.1.7.5.1',
- 'udpLocalAddress' => '1.3.6.1.2.1.7.5.1.1',
- 'udpLocalPort' => '1.3.6.1.2.1.7.5.1.2',
- 'egp' => '1.3.6.1.2.1.8',
- 'egpInMsgs' => '1.3.6.1.2.1.8.1',
- 'egpInErrors' => '1.3.6.1.2.1.8.2',
- 'egpOutMsgs' => '1.3.6.1.2.1.8.3',
- 'egpOutErrors' => '1.3.6.1.2.1.8.4',
- 'egpNeighTable' => '1.3.6.1.2.1.8.5',
- 'egpNeighEntry' => '1.3.6.1.2.1.8.5.1',
- 'egpNeighState' => '1.3.6.1.2.1.8.5.1.1',
- 'egpNeighStateUps' => '1.3.6.1.2.1.8.5.1.10',
- 'egpNeighStateDowns' => '1.3.6.1.2.1.8.5.1.11',
- 'egpNeighIntervalHello' => '1.3.6.1.2.1.8.5.1.12',
- 'egpNeighIntervalPoll' => '1.3.6.1.2.1.8.5.1.13',
- 'egpNeighMode' => '1.3.6.1.2.1.8.5.1.14',
- 'egpNeighEventTrigger' => '1.3.6.1.2.1.8.5.1.15',
- 'egpNeighAddr' => '1.3.6.1.2.1.8.5.1.2',
- 'egpNeighAs' => '1.3.6.1.2.1.8.5.1.3',
- 'egpNeighInMsgs' => '1.3.6.1.2.1.8.5.1.4',
- 'egpNeighInErrs' => '1.3.6.1.2.1.8.5.1.5',
- 'egpNeighOutMsgs' => '1.3.6.1.2.1.8.5.1.6',
- 'egpNeighOutErrs' => '1.3.6.1.2.1.8.5.1.7',
- 'egpNeighInErrMsgs' => '1.3.6.1.2.1.8.5.1.8',
- 'egpNeighOutErrMsgs' => '1.3.6.1.2.1.8.5.1.9',
- 'egpAs' => '1.3.6.1.2.1.8.6',
- 'transmission' => '1.3.6.1.2.1.10',
- 'frame-relay' => '1.3.6.1.2.1.10.32',
- 'frDlcmiTable' => '1.3.6.1.2.1.10.32.1',
- 'frDlcmiEntry' => '1.3.6.1.2.1.10.32.1.1',
- 'frDlcmiIfIndex' => '1.3.6.1.2.1.10.32.1.1.1',
- 'frDlcmiState' => '1.3.6.1.2.1.10.32.1.1.2',
- 'frDlcmiAddress' => '1.3.6.1.2.1.10.32.1.1.3',
- 'frDlcmiAddressLen' => '1.3.6.1.2.1.10.32.1.1.4',
- 'frDlcmiPollingInterval' => '1.3.6.1.2.1.10.32.1.1.5',
- 'frDlcmiFullEnquiryInterval' => '1.3.6.1.2.1.10.32.1.1.6',
- 'frDlcmiErrorThreshold' => '1.3.6.1.2.1.10.32.1.1.7',
- 'frDlcmiMonitoredEvents' => '1.3.6.1.2.1.10.32.1.1.8',
- 'frDlcmiMaxSupportedVCs' => '1.3.6.1.2.1.10.32.1.1.9',
- 'frDlcmiMulticast' => '1.3.6.1.2.1.10.32.1.1.10',
- 'frCircuitTable' => '1.3.6.1.2.1.10.32.2',
- 'frCircuitEntry' => '1.3.6.1.2.1.10.32.2.1',
- 'frCircuitIfIndex' => '1.3.6.1.2.1.10.32.2.1.1',
- 'frCircuitDlci' => '1.3.6.1.2.1.10.32.2.1.2',
- 'frCircuitState' => '1.3.6.1.2.1.10.32.2.1.3',
- 'frCircuitReceivedFECNs' => '1.3.6.1.2.1.10.32.2.1.4',
- 'frCircuitReceivedBECNs' => '1.3.6.1.2.1.10.32.2.1.5',
- 'frCircuitSentFrames' => '1.3.6.1.2.1.10.32.2.1.6',
- 'frCircuitSentOctets' => '1.3.6.1.2.1.10.32.2.1.7',
- 'frOutOctets' => '1.3.6.1.2.1.10.32.2.1.7',
- 'frCircuitReceivedFrames' => '1.3.6.1.2.1.10.32.2.1.8',
- 'frCircuitReceivedOctets' => '1.3.6.1.2.1.10.32.2.1.9',
- 'frInOctets' => '1.3.6.1.2.1.10.32.2.1.9',
- 'frCircuitCreationTime' => '1.3.6.1.2.1.10.32.2.1.10',
- 'frCircuitLastTimeChange' => '1.3.6.1.2.1.10.32.2.1.11',
- 'frCircuitCommittedBurst' => '1.3.6.1.2.1.10.32.2.1.12',
- 'frCircuitExcessBurst' => '1.3.6.1.2.1.10.32.2.1.13',
- 'frCircuitThroughput' => '1.3.6.1.2.1.10.32.2.1.14',
- 'frErrTable' => '1.3.6.1.2.1.10.32.3',
- 'frErrEntry' => '1.3.6.1.2.1.10.32.3.1',
- 'frErrIfIndex' => '1.3.6.1.2.1.10.32.3.1.1',
- 'frErrType' => '1.3.6.1.2.1.10.32.3.1.2',
- 'frErrData' => '1.3.6.1.2.1.10.32.3.1.3',
- 'frErrTime' => '1.3.6.1.2.1.10.32.3.1.4',
- 'frame-relay-globals' => '1.3.6.1.2.1.10.32.4',
- 'frTrapState' => '1.3.6.1.2.1.10.32.4.1',
- 'snmp' => '1.3.6.1.2.1.11',
- 'snmpInPkts' => '1.3.6.1.2.1.11.1',
- 'snmpInBadValues' => '1.3.6.1.2.1.11.10',
- 'snmpInReadOnlys' => '1.3.6.1.2.1.11.11',
- 'snmpInGenErrs' => '1.3.6.1.2.1.11.12',
- 'snmpInTotalReqVars' => '1.3.6.1.2.1.11.13',
- 'snmpInTotalSetVars' => '1.3.6.1.2.1.11.14',
- 'snmpInGetRequests' => '1.3.6.1.2.1.11.15',
- 'snmpInGetNexts' => '1.3.6.1.2.1.11.16',
- 'snmpInSetRequests' => '1.3.6.1.2.1.11.17',
- 'snmpInGetResponses' => '1.3.6.1.2.1.11.18',
- 'snmpInTraps' => '1.3.6.1.2.1.11.19',
- 'snmpOutPkts' => '1.3.6.1.2.1.11.2',
- 'snmpOutTooBigs' => '1.3.6.1.2.1.11.20',
- 'snmpOutNoSuchNames' => '1.3.6.1.2.1.11.21',
- 'snmpOutBadValues' => '1.3.6.1.2.1.11.22',
- 'snmpOutGenErrs' => '1.3.6.1.2.1.11.24',
- 'snmpOutGetRequests' => '1.3.6.1.2.1.11.25',
- 'snmpOutGetNexts' => '1.3.6.1.2.1.11.26',
- 'snmpOutSetRequests' => '1.3.6.1.2.1.11.27',
- 'snmpOutGetResponses' => '1.3.6.1.2.1.11.28',
- 'snmpOutTraps' => '1.3.6.1.2.1.11.29',
- 'snmpInBadVersions' => '1.3.6.1.2.1.11.3',
- 'snmpEnableAuthenTraps' => '1.3.6.1.2.1.11.30',
- 'snmpInBadCommunityNames' => '1.3.6.1.2.1.11.4',
- 'snmpInBadCommunityUses' => '1.3.6.1.2.1.11.5',
- 'snmpInASNParseErrs' => '1.3.6.1.2.1.11.6',
- 'snmpInTooBigs' => '1.3.6.1.2.1.11.8',
- 'snmpInNoSuchNames' => '1.3.6.1.2.1.11.9',
- 'ifName' => '1.3.6.1.2.1.31.1.1.1.1',
- 'ifInMulticastPkts' => '1.3.6.1.2.1.31.1.1.1.2',
- 'ifInBroadcastPkts' => '1.3.6.1.2.1.31.1.1.1.3',
- 'ifOutMulticastPkts' => '1.3.6.1.2.1.31.1.1.1.4',
- 'ifOutBroadcastPkts' => '1.3.6.1.2.1.31.1.1.1.5',
- 'ifHCInOctets' => '1.3.6.1.2.1.31.1.1.1.6',
- 'ifHCInUcastPkts' => '1.3.6.1.2.1.31.1.1.1.7',
- 'ifHCInMulticastPkts' => '1.3.6.1.2.1.31.1.1.1.8',
- 'ifHCInBroadcastPkts' => '1.3.6.1.2.1.31.1.1.1.9',
- 'ifHCOutOctets' => '1.3.6.1.2.1.31.1.1.1.10',
- 'ifHCOutUcastPkts' => '1.3.6.1.2.1.31.1.1.1.11',
- 'ifHCOutMulticastPkts' => '1.3.6.1.2.1.31.1.1.1.12',
- 'ifHCOutBroadcastPkts' => '1.3.6.1.2.1.31.1.1.1.13',
- 'ifLinkUpDownTrapEnable' => '1.3.6.1.2.1.31.1.1.1.14',
- 'ifHighSpeed' => '1.3.6.1.2.1.31.1.1.1.15',
- 'ifPromiscuousMode' => '1.3.6.1.2.1.31.1.1.1.16',
- 'ifConnectorPresent' => '1.3.6.1.2.1.31.1.1.1.17',
- 'ifAlias' => '1.3.6.1.2.1.31.1.1.1.18',
- 'ifCounterDiscontinuityTime' => '1.3.6.1.2.1.31.1.1.1.19',
- 'experimental' => '1.3.6.1.3',
- 'private' => '1.3.6.1.4',
- 'enterprises' => '1.3.6.1.4.1',
- );
-
-# GIL
-my %revOIDS = (); # Reversed %SNMP_util::OIDS hash
-my $RevNeeded = 1;
-
-my $agent_start_time = time;
-
-undef $SNMP_util::Host;
-undef $SNMP_util::Session;
-undef $SNMP_util::Version;
-undef $SNMP_util::LHost;
-undef $SNMP_util::IPv4only;
-$SNMP_util::Debug = 0;
-$SNMP_util::CacheFile = "OID_cache.txt";
-$SNMP_util::CacheLoaded = 0;
-$SNMP_util::Return_array_refs = 0;
-$SNMP_util::Return_hash_refs = 0;
-
-srand(time + $$);
-
-### Prototypes
-sub snmpget ($@);
-sub snmpgetnext ($@);
-sub snmpopen ($$$);
-sub snmpwalk ($@);
-sub snmpwalk_flg ($$@);
-sub snmpset ($@);
-sub snmptrap ($$$$$@);
-sub snmpgetbulk ($$$@);
-sub snmpmaptable ($$@);
-sub snmpmaptable4 ($$$@);
-sub snmpwalkhash ($$@);
-sub toOID (@);
-sub snmpmapOID (@);
-sub snmpMIB_to_OID ($);
-sub encode_oid_with_errmsg ($);
-sub Check_OID ($);
-sub snmpLoad_OID_Cache ($);
-sub snmpQueue_MIB_File (@);
-sub MIB_fill_OID ($);
-
-sub version () { $VERSION; }
-
-#
-# Start an snmp session
-#
-sub snmpopen ($$$) {
- my($host, $type, $vars) = @_;
- my($nhost, $port, $community, $lhost, $lport, $nlhost);
- my($timeout, $retries, $backoff, $version);
- my $v4onlystr;
-
- $type = 0 if (!defined($type));
- $community = "public";
- $nlhost = "";
-
- ($community, $host) = ($1, $2) if ($host =~ /^(.*)@([^@]+)$/);
-
- # We can't split on the : character because a numeric IPv6
- # address contains a variable number of :'s
- my $opts;
- if( ($host =~ /^(\[.*\]):(.*)$/) or ($host =~ /^(\[.*\])$/) ) {
- # Numeric IPv6 address between []
- ($host, $opts) = ($1, $2);
- } else {
- # Hostname or numeric IPv4 address
- ($host, $opts) = split(':', $host, 2);
- }
- ($port, $timeout, $retries, $backoff, $version, $v4onlystr) = split(':', $opts, 6)
- if(defined($opts) and (length $opts > 0) );
-
- undef($version) if (defined($version) and length($version) <= 0);
- $v4onlystr = "" unless defined $v4onlystr;
- $version = '1' unless defined $version;
- if (defined($port) and ($port =~ /^([^!]*)!(.*)$/)) {
- ($port, $lhost) = ($1, $2);
- $nlhost = $lhost;
- ($lhost, $lport) = ($1, $2) if ($lhost =~ /^(.*)!(.*)$/);
- undef($lhost) if (defined($lhost) and (length($lhost) <= 0));
- undef($lport) if (defined($lport) and (length($lport) <= 0));
- }
- undef($port) if (defined($port) and length($port) <= 0);
- $port = 162 if ($type == 1 and !defined($port));
- $nhost = "$community\@$host";
- $nhost .= ":" . $port if (defined($port));
-
- if ((!defined($SNMP_util::Session))
- or ($SNMP_util::Host ne $nhost)
- or ($SNMP_util::Version ne $version)
- or ($SNMP_util::LHost ne $nlhost)
- or ($SNMP_util::IPv4only ne $v4onlystr)) {
- if (defined($SNMP_util::Session)) {
- $SNMP_util::Session->close();
- undef $SNMP_util::Session;
- undef $SNMP_util::Host;
- undef $SNMP_util::Version;
- undef $SNMP_util::LHost;
- undef $SNMP_util::IPv4only;
- }
- $SNMP_util::Session = ($version =~ /^2c?$/i)
- ? SNMPv2c_Session->open($host, $community, $port, undef,
- $lport, undef, $lhost, ($v4onlystr eq 'v4only') ? 1:0 )
- : SNMP_Session->open($host, $community, $port, undef,
- $lport, undef, $lhost, ($v4onlystr eq 'v4only') ? 1:0 );
- ($SNMP_util::Host = $nhost, $SNMP_util::Version = $version,
- $SNMP_util::LHost = $nlhost, $SNMP_util::IPv4only = $v4onlystr) if defined($SNMP_util::Session);
- }
-
- if (defined($SNMP_util::Session)) {
- if (ref $vars->[0] eq 'HASH') {
- my $opts = shift @$vars;
- foreach $type (keys %$opts) {
- if ($type eq 'return_array_refs') {
- $SNMP_util::Return_array_refs = $opts->{$type};
- } elsif ($type eq 'return_hash_refs') {
- $SNMP_util::Return_hash_refs = $opts->{$type};
- } else {
- if (exists $SNMP_util::Session->{$type}) {
- if ($type eq 'timeout') {
- $SNMP_util::Session->set_timeout($opts->{$type});
- } elsif ($type eq 'retries') {
- $SNMP_util::Session->set_retries($opts->{$type});
- } elsif ($type eq 'backoff') {
- $SNMP_util::Session->set_backoff($opts->{$type});
- } else {
- $SNMP_util::Session->{$type} = $opts->{$type};
- }
- } else {
- carp "SNMPopen Unknown SNMP Option Key '$type'\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- }
- }
- }
- }
- $SNMP_util::Session->set_timeout($timeout)
- if (defined($timeout) and (length($timeout) > 0));
- $SNMP_util::Session->set_retries($retries)
- if (defined($retries) and (length($retries) > 0));
- $SNMP_util::Session->set_backoff($backoff)
- if (defined($backoff) and (length($backoff) > 0));
- }
- return $SNMP_util::Session;
-}
-
-
-#
-# A restricted snmpget.
-#
-sub snmpget ($@) {
- my($host, @vars) = @_;
- my(@enoid, $var, $response, $bindings, $binding, $value, $oid, @retvals);
- my $session;
-
- @retvals = ();
- $session = &snmpopen($host, 0, \@vars);
- if (!defined($session)) {
- carp "SNMPGET Problem for $host\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- return wantarray ? @retvals : undef;
- }
-
- @enoid = &toOID(@vars);
- if ($#enoid < 0) {
- return wantarray ? @retvals : undef;
- }
-
- if ($session->get_request_response(@enoid)) {
- $response = $session->pdu_buffer;
- ($bindings) = $session->decode_get_response($response);
- while ($bindings) {
- ($binding, $bindings) = decode_sequence($bindings);
- ($oid, $value) = decode_by_template($binding, "%O%@");
- my $tempo = pretty_print($value);
- push @retvals, $tempo;
- }
- return wantarray ? @retvals : $retvals[0];
- }
- $var = join(' ', @vars);
- carp "SNMPGET Problem for $var on $host\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- return wantarray ? @retvals : undef;
-}
-
-#
-# A restricted snmpgetnext.
-#
-sub snmpgetnext ($@) {
- my($host, @vars) = @_;
- my(@enoid, $var, $response, $bindings, $binding);
- my($value, $upoid, $oid, @retvals);
- my($noid);
- my $session;
-
- @retvals = ();
- $session = &snmpopen($host, 0, \@vars);
- if (!defined($session)) {
- carp "SNMPGETNEXT Problem for $host\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- return wantarray ? @retvals : undef;
- }
-
- @enoid = &toOID(@vars);
- if ($#enoid < 0) {
- return wantarray ? @retvals : undef;
- }
-
- undef @vars;
- undef @retvals;
- foreach $noid (@enoid) {
- $upoid = pretty_print($noid);
- push(@vars, $upoid);
- }
- if ($session->getnext_request_response(@enoid)) {
- $response = $session->pdu_buffer;
- ($bindings) = $session->decode_get_response($response);
- while ($bindings) {
- ($binding, $bindings) = decode_sequence($bindings);
- ($oid, $value) = decode_by_template($binding, "%O%@");
- my $tempo = pretty_print($oid);
- my $tempv = pretty_print($value);
- push @retvals, "$tempo:$tempv";
- }
- return wantarray ? @retvals : $retvals[0];
- } else {
- $var = join(' ', @vars);
- carp "SNMPGETNEXT Problem for $var on $host\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- return wantarray ? @retvals : undef;
- }
-}
-
-#
-# A restricted snmpwalk.
-#
-sub snmpwalk ($@) {
- my($host, @vars) = @_;
- return(&snmpwalk_flg($host, undef, @vars));
-}
-
-#
-# Walk the MIB, putting everything you find into hashes.
-#
-sub snmpwalkhash($$@) {
-# my($host, $hash_sub, @vars) = @_;
- return(&snmpwalk_flg( @_ ));
-}
-
-sub snmpwalk_flg ($$@) {
- my($host, $hash_sub, @vars) = @_;
- my(@enoid, $var, $response, $bindings, $binding);
- my($value, $upoid, $oid, @retvals, @retvaltmprefs);
- my($got, @nnoid, $noid, $ok, $ix, @avars);
- my $session;
- my(%soid);
- my(%done, %rethash, $h_ref);
-
- $h_ref = (ref $vars[$#vars] eq "HASH") ? pop(@vars) : \%rethash;
-
- $session = &snmpopen($host, 0, \@vars);
- if (!defined($session)) {
- carp "SNMPWALK Problem for $host\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- if (defined($hash_sub)) {
- return ($h_ref) if ($SNMP_util::Return_hash_refs);
- return (%$h_ref);
- } else {
- @retvals = ();
- return (@retvals);
- }
- }
-
- @enoid = toOID(@vars);
- if ($#enoid < 0) {
- if (defined($hash_sub)) {
- return ($h_ref) if ($SNMP_util::Return_hash_refs);
- return (%$h_ref);
- } else {
- @retvals = ();
- return (@retvals);
- }
- }
-
- # GIL
- #
- # Create/Refresh a reversed hash with oid -> name
- #
- if (defined($hash_sub) and ($RevNeeded)) {
- %revOIDS = reverse %SNMP_util::OIDS;
- $RevNeeded = 0;
- }
-
- $got = 0;
- @nnoid = @enoid;
- undef @vars;
- foreach $noid (@enoid) {
- $upoid = pretty_print($noid);
- push(@vars, $upoid);
- }
-
- # @vars is the original set of walked variables.
- # @avars is the current set of walked variables as the
- # walk goes on.
- # @vars stays static while @avars may shrink as we reach end
- # of walk for individual variables during PDU exchange.
-
- @avars = @vars;
-
- # IlvJa
- #
- # Create temporary array of refs to return vals.
-
- if ($SNMP_util::Return_array_refs) {
- for($ix = 0;$ix < scalar @vars; $ix++) {
- my $tmparray = [];
- $retvaltmprefs[$ix] = $tmparray;
- $retvals[$ix] = $tmparray;
- }
- }
-
-
- while(($SNMP_util::Version ne '1' and $session->{'use_getbulk'})
- ? $session->getbulk_request_response(0,
- $session->default_max_repetitions(),
- @nnoid)
- : $session->getnext_request_response(@nnoid))
- {
- $got = 1;
- $response = $session->pdu_buffer;
- ($bindings) = $session->decode_get_response($response);
- $ix = 0;
- while ($bindings) {
- ($binding, $bindings) = decode_sequence($bindings);
- unless ($nnoid[$ix]) { # IlvJa
- $ix = ++$ix % (scalar @avars);
- next;
- }
- ($oid, $value) = decode_by_template($binding, "%O%@");
- $ok = 0;
- my $tempo = pretty_print($oid);
- $noid = $avars[$ix]; # IlvJa
- if ($tempo =~ /^$noid\./ or $tempo eq $noid ) {
- $ok = 1;
- $upoid = $noid;
- } else {
- # IlvJa
- #
- # The walk for variable $vars[$ix] has been finished as
- # $nnoid[$ix] no longer is in the $avar[$ix] OID tree.
- # So we exclude this variable from further requests.
-
- $avars[$ix] = "";
- $nnoid[$ix] = "";
- $retvaltmprefs[$ix] = undef if $SNMP_util::Return_array_refs;
- }
- if ($ok) {
- my $tmp = encode_oid_with_errmsg ($tempo);
- if (!defined $tmp) {
- if (defined($hash_sub)) {
- return ($h_ref) if ($SNMP_util::Return_hash_refs);
- return (%$h_ref);
- } else {
- @retvals = ();
- return (@retvals);
- }
- }
- if (exists($done{$tmp})) { # GIL, Ilvja
- #
- # We've detected a loop for $nnoid[$ix], so mark it as finished.
- # Exclude this variable from further requests.
- #
- $avars[$ix] = "";
- $nnoid[$ix] = "";
- $retvaltmprefs[$ix] = undef if $SNMP_util::Return_array_refs;
- next;
- }
- $nnoid[$ix] = $tmp; # Keep on walking. (IlvJa)
- my $tempv = pretty_print($value);
- if (defined($hash_sub)) {
- #
- # extract name of the oid, if possible, the rest becomes the instance
- #
- my $inst = "";
- my $upo = $upoid;
- while (!exists($revOIDS{$upo}) and length($upo)) {
- $upo =~ s/(\.\d+?)$//;
- if (defined($1) and length($1)) {
- $inst = $1 . $inst;
- } else {
- $upo = "";
- last;
- }
- }
- if (length($upo) and exists($revOIDS{$upo})) {
- $upo = $revOIDS{$upo} . $inst;
- } else {
- $upo = $upoid;
- }
-
- $inst = "";
- while (!exists($revOIDS{$tempo}) and length($tempo)) {
- $tempo =~ s/(\.\d+?)$//;
- if (defined($1) and length($1)) {
- $inst = $1 . $inst;
- } else {
- $tempo = "";
- last;
- }
- }
- if (length($tempo) and exists($revOIDS{$tempo})) {
- $var = $revOIDS{$tempo};
- } else {
- $var = pretty_print($oid);
- }
- #
- # call hash_sub
- #
- &$hash_sub($h_ref, $host, $var, $tempo, $inst,
- $tempv, $upo);
- } else {
- if ($SNMP_util::Return_array_refs) {
- $tempo=~s/^$upoid\.//;
- push @{$retvaltmprefs[$ix]}, "$tempo:$tempv";
- } else {
- $tempo=~s/^$upoid\.// if ($#enoid <= 0);
- push @retvals, "$tempo:$tempv";
- }
- }
- $done{$tmp} = 1; # GIL
- }
- $ix = ++$ix % (scalar @avars);
- }
-
- # Ok, @nnoid should contain the remaining variables for the
- # next request. Some or all entries in @nnoid might be the empty
- # string. If the nth element in @nnoid is "" that means that
- # the walk related to the nth variable in the last request has been
- # completed and we should not include that var in subsequent reqs.
-
- # Clean up both @nnoid and @avars so "" elements are removed.
- @nnoid = grep (($_), @nnoid);
- @avars = grep (($_), @avars);
- @retvaltmprefs = grep (($_), @retvaltmprefs);
-
- last if ($#nnoid < 0); # @nnoid empty means we are done walking.
- }
- if (!$got) {
- $var = join(' ', @vars);
- carp "SNMPWALK Problem for $var on $host\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- @retvals = ();
- }
- if (defined($hash_sub)) {
- return ($h_ref) if ($SNMP_util::Return_hash_refs);
- return (%$h_ref);
- } else {
- return (@retvals);
- }
-}
-
-#
-# A restricted snmpset.
-#
-sub snmpset($@) {
- my($host, @vars) = @_;
- my(@enoid, $response, $bindings, $binding);
- my($oid, @retvals, $type, $value, $val);
- my $session;
-
- @retvals = ();
- $session = &snmpopen($host, 0, \@vars);
- if (!defined($session)) {
- carp "SNMPSET Problem for $host\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- return wantarray ? @retvals : undef;
- }
-
- while(@vars) {
- ($oid) = toOID((shift @vars));
- $type = shift @vars;
- $value = shift @vars;
- $type =~ tr/A-Z/a-z/;
- if ($type eq "int") {
- $val = encode_int($value);
- } elsif ($type eq "integer") {
- $val = encode_int($value);
- } elsif ($type eq "string") {
- $val = encode_string($value);
- } elsif ($type eq "octetstring") {
- $val = encode_string($value);
- } elsif ($type eq "octet string") {
- $val = encode_string($value);
- } elsif ($type eq "oid") {
- $val = encode_oid_with_errmsg($value);
- } elsif ($type eq "object id") {
- $val = encode_oid_with_errmsg($value);
- } elsif ($type eq "object identifier") {
- $val = encode_oid_with_errmsg($value);
- } elsif ($type eq "ipaddr") {
- $val = encode_ip_address($value);
- } elsif ($type eq "ip address") {
- $val = encode_ip_address($value);
- } elsif ($type eq "timeticks") {
- $val = encode_timeticks($value);
- } elsif ($type eq "uint") {
- $val = encode_uinteger32($value);
- } elsif ($type eq "uinteger") {
- $val = encode_uinteger32($value);
- } elsif ($type eq "uinteger32") {
- $val = encode_uinteger32($value);
- } elsif ($type eq "unsigned int") {
- $val = encode_uinteger32($value);
- } elsif ($type eq "unsigned integer") {
- $val = encode_uinteger32($value);
- } elsif ($type eq "unsigned integer32") {
- $val = encode_uinteger32($value);
- } elsif ($type eq "counter") {
- $val = encode_counter32($value);
- } elsif ($type eq "counter32") {
- $val = encode_counter32($value);
- } elsif ($type eq "counter64") {
- $val = encode_counter64($value);
- } elsif ($type eq "gauge") {
- $val = encode_gauge32($value);
- } elsif ($type eq "gauge32") {
- $val = encode_gauge32($value);
- } else {
- carp "unknown SNMP type: $type\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- return wantarray ? @retvals : undef;
- }
- if (!defined($val)) {
- carp "SNMP type $type value $value didn't encode properly\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- return wantarray ? @retvals : undef;
- }
- push @enoid, [$oid,$val];
- }
- if ($#enoid < 0) {
- return wantarray ? @retvals : undef;
- }
- if ($session->set_request_response(@enoid)) {
- $response = $session->pdu_buffer;
- ($bindings) = $session->decode_get_response($response);
- while ($bindings) {
- ($binding, $bindings) = decode_sequence($bindings);
- ($oid, $value) = decode_by_template($binding, "%O%@");
- my $tempo = pretty_print($value);
- push @retvals, $tempo;
- }
- return wantarray ? @retvals : $retvals[0];
- }
- return wantarray ? @retvals : undef;
-}
-
-#
-# Send an SNMP trap
-#
-sub snmptrap($$$$$@) {
- my($host, $ent, $agent, $gen, $spec, @vars) = @_;
- my($oid, @retvals, $type, $value);
- my(@enoid);
- my $session;
-
- $session = &snmpopen($host, 1, \@vars);
- if (!defined($session)) {
- carp "SNMPTRAP Problem for $host\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- return undef;
- }
-
- if ($agent =~ /^\d+\.\d+\.\d+\.\d+(.*)/ ) {
- $agent = pack("C*", split /\./, $agent);
- } else {
- $agent = inet_aton($agent);
- }
- push @enoid, toOID(($ent));
- push @enoid, encode_ip_address($agent);
- push @enoid, encode_int($gen);
- push @enoid, encode_int($spec);
- push @enoid, encode_timeticks((time-$agent_start_time) * 100);
- while(@vars) {
- ($oid) = toOID((shift @vars));
- $type = shift @vars;
- $value = shift @vars;
- if ($type =~ /string/i) {
- $value = encode_string($value);
- push @enoid, [$oid,$value];
- } elsif ($type =~ /ipaddr/i) {
- $value = encode_ip_address($value);
- push @enoid, [$oid,$value];
- } elsif ($type =~ /int/i) {
- $value = encode_int($value);
- push @enoid, [$oid,$value];
- } elsif ($type =~ /oid/i) {
- my $tmp = encode_oid_with_errmsg($value);
- return undef unless defined $tmp;
- push @enoid, [$oid,$tmp];
- } else {
- carp "unknown SNMP type: $type\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- return undef;
- }
- }
- return($session->trap_request_send(@enoid));
-}
-
-#
-# A restricted snmpgetbulk.
-#
-sub snmpgetbulk ($$$@) {
- my($host, $nr, $mr, @vars) = @_;
- my(@enoid, $var, $response, $bindings, $binding);
- my($value, $upoid, $oid, @retvals);
- my($noid);
- my $session;
-
- @retvals = ();
- $session = &snmpopen($host, 0, \@vars);
- if (!defined($session)) {
- carp "SNMPGETBULK Problem for $host\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- return @retvals;
- }
-
- @enoid = &toOID(@vars);
- return @retvals if ($#enoid < 0);
-
- undef @vars;
- foreach $noid (@enoid) {
- $upoid = pretty_print($noid);
- push(@vars, $upoid);
- }
- if ($session->getbulk_request_response($nr, $mr, @enoid)) {
- $response = $session->pdu_buffer;
- ($bindings) = $session->decode_get_response($response);
- while ($bindings) {
- ($binding, $bindings) = decode_sequence($bindings);
- ($oid, $value) = decode_by_template($binding, "%O%@");
- my $tempo = pretty_print($oid);
- my $tempv = pretty_print($value);
- push @retvals, "$tempo:$tempv";
- }
- return @retvals;
- } else {
- $var = join(' ', @vars);
- carp "SNMPGETBULK Problem for $var on $host\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- return @retvals;
- }
-}
-
-#
-# walk a table, calling a user-supplied function for each
-# column of a table.
-#
-sub snmpmaptable($$@) {
- my($host, $fun, @vars) = @_;
- return snmpmaptable4($host, $fun, 0, @vars);
-}
-
-sub snmpmaptable4($$$@) {
- my($host, $fun, $max_reps, @vars) = @_;
- my(@enoid, $var, $session);
-
- $session = &snmpopen($host, 0, \@vars);
- if (!defined($session)) {
- carp "SNMPMAPTABLE Problem for $host\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- return undef;
- }
-
- foreach $var (toOID(@vars)) {
- push(@enoid, [split('\.', pretty_print($var))]);
- }
-
- $max_reps = $session->default_max_repetitions() if ($max_reps <= 0);
-
- return $session->map_table_start_end( [@enoid],
- sub() {
- my ($ind, @vals) = @_;
- my (@pvals, $val);
-
- foreach $val (@vals) {
- push(@pvals, pretty_print($val));
- }
- &$fun($ind, @pvals);
- },
- "", undef, $max_reps);
-}
-
-
-#
-# Given an OID in either ASN.1 or mixed text/ASN.1 notation, return an
-# encoded OID.
-#
-sub toOID(@) {
- my(@vars) = @_;
- my($oid, $var, $tmp, $tmpv, @retvar);
-
- undef @retvar;
- foreach $var (@vars) {
- ($oid, $tmp) = &Check_OID($var);
- if (!$oid and $SNMP_util::CacheLoaded == 0) {
- $tmp = $SNMP_Session::suppress_warnings;
- $SNMP_Session::suppress_warnings = 1000;
-
- &snmpLoad_OID_Cache($SNMP_util::CacheFile);
-
- $SNMP_util::CacheLoaded = 1;
- $SNMP_Session::suppress_warnings = $tmp;
-
- ($oid, $tmp) = &Check_OID($var);
- }
- while (!$oid and $#SNMP_util::MIB_Files >= 0) {
- $tmp = $SNMP_Session::suppress_warnings;
- $SNMP_Session::suppress_warnings = 1000;
-
- snmpMIB_to_OID(shift(@SNMP_util::MIB_Files));
-
- $SNMP_Session::suppress_warnings = $tmp;
-
- ($oid, $tmp) = &Check_OID($var);
- if ($oid) {
- open(CACHE, ">>$SNMP_util::CacheFile");
- print CACHE "$tmp\t$oid\n";
- close(CACHE);
- }
- }
- if ($oid) {
- $var =~ s/^$tmp/$oid/;
- } else {
- carp "Unknown SNMP var $var\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- next;
- }
- while ($var =~ /\"([^\"]*)\"/) {
- $tmp = sprintf("%d.%s", length($1), join(".", map(ord, split(//, $1))));
- $var =~ s/\"$1\"/$tmp/;
- }
- print "toOID: $var\n" if $SNMP_util::Debug;
- $tmp = encode_oid_with_errmsg($var);
- if (!defined($tmp)) {
- my @empty = ();
- return @empty;
- }
- push(@retvar, $tmp);
- }
- return @retvar;
-}
-
-#
-# Add passed-in text, OID pairs to the OID mapping table.
-#
-sub snmpmapOID(@)
-{
- my(@vars) = @_;
- my($oid, $txt);
-
- while($#vars >= 0) {
- $txt = shift @vars;
- $oid = shift @vars;
-
- next unless($txt =~ /^[a-zA-Z][\w\-]*(\.[a-zA-Z][\w\-])*$/);
- next unless($oid =~ /^\d+(\.\d+)*$/);
-
- $SNMP_util::OIDS{$txt} = $oid;
- $RevNeeded = 1;
- print "snmpmapOID: $txt => $oid\n" if $SNMP_util::Debug;
- }
-
- return undef;
-}
-
-#
-# Open the passed-in file name and read it in to populate
-# the cache of text-to-OID map table. It expects lines
-# with two fields, the first the textual string like "ifInOctets",
-# and the second the OID value, like "1.3.6.1.2.1.2.2.1.10".
-#
-# blank lines and anything after a '#' or between '--' is ignored.
-#
-sub snmpLoad_OID_Cache ($) {
- my($arg) = @_;
- my($txt, $oid);
-
- if (!open(CACHE, $arg)) {
- carp "snmpLoad_OID_Cache: Can't open $arg: $!"
- unless ($SNMP_Session::suppress_warnings > 1);
- return -1;
- }
-
- while(<CACHE>) {
- s/#.*//; # '#' starts a comment
- s/--.*?--/ /g; # comment delimited by '--', like MIBs
- s/--.*//; # comment started by '--'
- next if (/^$/);
- next unless (/\s/); # must have whitespace as separator
- chomp;
- ($txt, $oid) = split(' ', $_, 2);
- $txt = $1 if ($txt =~ /^[\'\"](.*)[\'\"]/);
- $oid = $1 if ($oid =~ /^[\'\"](.*)[\'\"]/);
- if (($txt =~ /^\.?\d+(\.\d+)*\.?$/)
- and ($oid !~ /^\.?\d+(\.\d+)*\.?$/)) {
- my($a) = $oid;
- $oid = $txt;
- $txt = $a;
- }
- $oid =~ s/^\.//;
- $oid =~ s/\.$//;
- &snmpmapOID($txt, $oid);
- }
- close(CACHE);
- return 0;
-}
-
-#
-# Check to see if an OID is in the text-to-OID cache.
-# Returns the OID and the corresponding text as two separate
-# elements.
-#
-sub Check_OID ($) {
- my($var) = @_;
- my($tmp, $tmpv, $oid);
-
- if ($var =~ /^[a-zA-Z][\w\-]*(\.[a-zA-Z][\w\-]*)*/)
- {
- $tmp = $&;
- $tmpv = $tmp;
- for (;;) {
- last if exists($SNMP_util::OIDS{$tmpv});
- last if !($tmpv =~ s/^[^\.]*\.//);
- }
- $oid = $SNMP_util::OIDS{$tmpv};
- if ($oid) {
- return ($oid, $tmp);
- } else {
- my @empty = ();
- return @empty;
- }
- }
- return ($var, $var);
-}
-
-#
-# Save the passed-in list of MIB files until an OID can't be
-# found in the existing table. At that time the MIB file will
-# be loaded, and the lookup attempted again.
-#
-sub snmpQueue_MIB_File (@) {
- my(@files) = @_;
- my($file);
-
- foreach $file (@files) {
- push(@SNMP_util::MIB_Files, $file);
- }
-}
-
-#
-# Read in the passed MIB file, parsing it
-# for their text-to-OID mappings
-#
-sub snmpMIB_to_OID ($) {
- my($arg) = @_;
- my($cnt, $quote, $buf, %tOIDs, $tgot);
- my($var, @parts, $strt, $indx, $ind, $val);
-
- if (!open(MIB, $arg)) {
- carp "snmpMIB_to_OID: Can't open $arg: $!"
- unless ($SNMP_Session::suppress_warnings > 1);
- return -1;
- }
- print "snmpMIB_to_OID: loading $arg\n" if $SNMP_util::Debug;
- $cnt = 0;
- $quote = 0;
- $tgot = 0;
- $buf = '';
- while(<MIB>) {
- if ($quote) {
- next unless /"/;
- $quote = 0;
- }
- chomp;
- $buf .= ' ' . $_;
-
- $buf =~ s/"[^"]*"//g; # throw away quoted strings
- $buf =~ s/--.*?--/ /g; # throw away comments (-- anything --)
- $buf =~ s/--.*//; # throw away comments (-- anything to EOL)
- $buf =~ s/\s+/ /g; # clean up multiple spaces
-
- if ($buf =~ /"/) { # look for quoted string
- $quote = 1;
- next;
- }
-
- if ($buf =~ /DEFINITIONS *::= *BEGIN/) {
- $cnt += MIB_fill_OID(\%tOIDs) if ($tgot);
- $buf = '';
- %tOIDs = ();
- $tgot = 0;
- next;
- }
- $buf =~ s/OBJECT-TYPE/OBJECT IDENTIFIER/;
- $buf =~ s/OBJECT-IDENTITY/OBJECT IDENTIFIER/;
- $buf =~ s/OBJECT-GROUP/OBJECT IDENTIFIER/;
- $buf =~ s/MODULE-IDENTITY/OBJECT IDENTIFIER/;
- $buf =~ s/NOTIFICATION-TYPE/OBJECT IDENTIFIER/;
- $buf =~ s/ IMPORTS .*\;//;
- $buf =~ s/ SEQUENCE *{.*}//;
- $buf =~ s/ SYNTAX .*//;
- $buf =~ s/ [\w\-]+ *::= *OBJECT IDENTIFIER//;
- $buf =~ s/ OBJECT IDENTIFIER.*::= *{/ OBJECT IDENTIFIER ::= {/;
-
- if ($buf =~ / ([\w\-]+) OBJECT IDENTIFIER *::= *{([^}]+)}/) {
- $var = $1;
- $buf = $2;
- $buf =~ s/ +$//;
- $buf =~ s/\s+\(/\(/g; # remove spacing around '('
- $buf =~ s/\(\s+/\(/g;
- $buf =~ s/\s+\)/\)/g; # remove spacing before ')'
- @parts = split(' ', $buf);
- $strt = '';
- foreach $indx (@parts) {
- if ($indx =~ /([\w\-]+)\((\d+)\)/) {
- $ind = $1;
- $val = $2;
- if (exists($tOIDs{$strt})) {
- $tOIDs{$ind} = $tOIDs{$strt} . '.' . $val;
- } elsif ($strt ne '') {
- $tOIDs{$ind} = "${strt}.${val}";
- } else {
- $tOIDs{$ind} = $val;
- }
- $strt = $ind;
- $tgot = 1;
- } elsif ($indx =~ /^\d+$/) {
- if (exists($tOIDs{$strt})) {
- $tOIDs{$var} = $tOIDs{$strt} . '.' . $indx;
- } else {
- $tOIDs{$var} = "${strt}.${indx}";
- }
- $tgot = 1;
- } else {
- $strt = $indx;
- }
- }
- $buf = '';
- }
- }
- $cnt += MIB_fill_OID(\%tOIDs) if ($tgot);
- $RevNeeded = 1 if ($cnt > 0);
- return $cnt;
-}
-
-#
-# Fill the OIDS hash with results from the MIB parsing
-#
-sub MIB_fill_OID ($)
-{
- my($href) = @_;
- my($cnt, $changed, @del, $var, $val, @parts, $indx);
- my(%seen);
-
- $cnt = 0;
- do {
- $changed = 0;
- @del = ();
- foreach $var (keys %$href) {
- $val = $href->{$var};
- @parts = split('\.', $val);
- $val = '';
- foreach $indx (@parts) {
- if ($indx =~ /^\d+$/) {
- $val .= '.' . $indx;
- } else {
- if (exists($SNMP_util::OIDS{$indx})) {
- $val = $SNMP_util::OIDS{$indx};
- } else {
- $val .= '.' . $indx;
- }
- }
- }
- if ($val =~ /^[\d\.]+$/) {
- $val =~ s/^\.+//;
- if (!exists($SNMP_util::OIDS{$var})
- || (length($val) > length($SNMP_util::OIDS{$var}))) {
- $SNMP_util::OIDS{$var} = $val;
- print "'$var' => '$val'\n" if $SNMP_util::Debug;
- $changed = 1;
- $cnt++;
- }
- push @del, $var;
- }
- }
- foreach $var (@del) {
- delete $href->{$var};
- }
- } while($changed);
-
- $Carp::CarpLevel++;
- foreach $var (sort keys %$href) {
- $val = $href->{$var};
- $val =~ s/\..*//;
- next if (exists($seen{$val}));
- $seen{$val} = 1;
- $seen{$var} = 1;
- carp "snmpMIB_to_OID: prefix \"$val\" unknown, load the parent MIB first.\n"
- unless ($SNMP_Session::suppress_warnings > 1);
- }
- $Carp::CarpLevel--;
- return $cnt;
-}
-
-
-sub encode_oid_with_errmsg ($) {
- my ($oid) = @_;
- my $tmp = encode_oid(split(/\./, $oid));
- if (! defined $tmp) {
- carp "cannot encode Object ID $oid: $BER::errmsg"
- unless ($SNMP_Session::suppress_warnings > 1);
- return undef;
- }
- return $tmp;
-}
-
-1;
diff --git a/src/lib/mrtg2/locales_mrtg.pm b/src/lib/mrtg2/locales_mrtg.pm
deleted file mode 100644
index 7b2477f..0000000
--- a/src/lib/mrtg2/locales_mrtg.pm
+++ /dev/null
@@ -1,5434 +0,0 @@
-# -*- mode: Perl -*-
-######################################################################
-### Localization of mrtg output pages
-######################################################################
-# #
-# This is a generated perl module file. #
-# Please see the perl script mergelocale.pl and the language #
-# databasefiles skelton.pm0 and locale.*.pmd in translate/. #
-# If you want to contribute to mrtg change in the *.pmd files. #
-# If you just want to change your own mrtg: Go ahead and edit! #
-# #
-######################################################################
-### Defines programs which handles centralized pattern matching and pattern
-### replacements in order to translate the given strings
-######################################################################
-### Created by: Morten Storgaard Nielsen <msn@ipt.dtu.dk>
-###################################################################
-#
-# Distributed under the GNU copyleft
-#
-###################################################################
-### Locale by:
-### Belarusian/Белару�ка�
-### => Глеб Валошка <375gnu@gmail.com>
-### Chinese/¤¤¤åÁcÅé
-### => Tate Chen ³¯¥@°¶ <tate@joy-tech.com.tw>
-### => Ryan Huang ¶ÀªF¶© <ryan@asplord.com>
-### Brazil/Brazilian Portuguese
-### => Luiz Felipe R E <luizfelipe@encarnacao.com>
-### => Gleydson Mazoli da Silva <gleydson@debian.org> (Atualização)
-### Bulgarian/Áúëãàðñêè
-### => Yovko Lambrev <yovko@sdf.lonestar.org>
-### catalan/Català
-### => LLuís Gras <lluis@seccat.com>
-### Simplified Chinese/¼òÌåÖÐÎÄ
-### => »Æ»ª¶° <webmaster@kingisme.com>
-### => QQ:582955 »¶Ó­ÌÖÂÛFreeBSD
-### => ÐÞÕýÁËÔ­À´µÄ´íÎó.·¢²¼Ð°汾.
-### cn/ÖÐÎĺº×Ö
-### => À¹â <zurkabsd@yahoo.com.cn>
-### => MSN:chenguang2001@hotmail.com FreeBSD Fan
-### => MRTGÍêÃÀºº»¯.
-### Croatian/Hrvatski
-### => Dinko Korunic <kreator@fly.srk.fer.hr>
-### Czech/Èesky
-### => Martin Och <martin@och.cz>
-### Czech/ÄŒesky
-### => David Toman <david@idkfa.cz>
-### Danish/Dansk
-### => Morten Storgaard Nielsen <msn@ipt.dtu.dk>
-### Dutch/Nederlands
-### => Barry van Dijk <barry@dijk.com>
-### Estonian/Eesti
-### => Klemens Kasemaa <klem@linux.ee>
-### ÆüËܸì(EUC-JP)
-### => Fuminori Uematsu <uematsu@kgz.com>
-### Finnish/Suomi
-### => Jussi Siponen <jussi.siponen@online.tietokone.fi>
-### French/Francais
-### => Fabrice Prigent <fabrice.prigent@univ-tlse1.fr>
-### and Stéphane Marzloff <secrer@le-bar.fdn.fr>
-### Galician/Galego
-### => David Garabana Barro <dgaraban@arrakis.es>
-### Chinese/¼òÌ庺×Ö
-### => Zhanghui ÕÅ»Ô <zhanghui2@asiainfo.com>
-### Chinese/ÖÐÎļòÌå
-### => Peter Wong ×ÓÈÙ<me@tcpip.com.cn>
-### German/Deutsch
-### => Ilja Pavkovic <illsen@gumblfarz.de>
-### Greek/Ellinika
-### => Simos Xenitellis <simos@hellug.gr>
-### Hungarian/Magyar
-### => Levente Nagy <levinet@euroweb.hu>
-### Icelandic/Islenska
-### => Halldor Karl Högnason <halldor.hognason@islandssimi.is>
-### Indonesian/Indonesia
-### => Jamaludin Ahmad <jamaludin@jamalinux.com>
-### taken from malaysian translation
-### by Assakhof Ab. Satar <assakhof@mimos.my>
-### $BF|K\8l(B(ISO-2022-JP)
-### => Fuminori Uematsu <uematsu@kgz.com>
-### Italian/Italiano
-### => Andrea Rossi <rouge@shiny.it>
-### Korean
-### => Kensoon Hwang <lovesh@static.co.kr>
-### CHOI Junho <cjh@kr.FreeBSD.org>
-### Lithuanian/Lietuviðkai
-### => ve <ve@hardcore.lt>
-### Macedonian/Makedonski
-### => Delev Zoran <delevz@esmak.com.mk>
-### Malaysian/Malay
-### => Assakhof Ab. Satar <assakhof@mimos.my>
-### Norwegian/norsk
-### => Knut Grøneng <knut.groneng@merkantildata.no
-### Polish/Polski
-### => Lukasz Jokiel <Lukasz.Jokiel@klonex.com.pl>
-### Portuguese/Português
-### => Diogo Gomes <etdgomes@ua.pt>
-### Romãn/Romanian
-### => József Szilágyi <jozsi@maxiq.ro>
-### Russian/òÕÓÓËÉÊ
-### => äÍÉÔÒÉÊ óÉ×ÁÞÅÎËÏ <dima@chg.ru>
-### Russian1251/Ðóññêèé1251
-### => Àëåêñàíäð Ðåäþê <aredyuk@irmcity.com>
-### Serbian/Srpski
-### => Ratko Bucic <ratko@ni.ac.yu>
-### Slovak/Slovensky
-### => Ladislav Mihok <laco@mrokh.shmu.sk>
-### Slovenian/Slovensko
-### => Aljosa Us <us@sweet-sorrow.com>
-### Spanish/Español
-### => Marcelo Roccasalva <marcelo@linuxfan.com>
-### Swedish/Svenska
-### => Clas Mayer <clas@mayer.se>
-### Turkish/Türkçe
-### => Özgür C. Demir <ozgurcd@koc.net>
-### Ukrainian/õËÒÁ§ÎÓØËÁ
-### => óÅÒÇ¦Ê çÕͦΦÌÏ×ÉÞ <gray@arte-fact.net>
-### Ukrainian/Óêðà¿íñüêà
-### => Olexander Kunytsa <xakep@snark.ukma.kiev.ua>
-###
-### Contributions and fixes by:
-###
-### 0.05 fixed DARK GREEN entry (msn@ipt.dtu.dk)
-### fixed credits for native language (msn@ipt.dtu.dk)
-### 0.06 added the PATCHTAGs (msn@ipt.dtu.dk)
-### fixed several small errors (msn@ipt.dtu.dk)
-### 0.07 changed PATCHTAG to support
-### mergelocale.pl (msn@ipt.dtu.dk)
-###
-######################################################################
-###
-package locales_mrtg;
-
-require 5.002;
-# make sure we do not get hit by UTF-8 here
-no locale;
-use strict;
-use vars qw(@ISA @EXPORT $VERSION);
-use Exporter;
-
-$VERSION = '0.07';
-
-@ISA = qw(Exporter);
-
-@EXPORT = qw
-(
- &english
- &belarusian
- &big5
- &brazilian
- &bulgarian
- &catalan
- &chinese
- &cn
- &croatian
- &czech
- &czechutf8
- &danish
- &dutch
- &estonian
- &eucjp
- &german
- &french
- &galician
- &gb
- &gb2312
- &german
- &greek
- &hungarian
- &icelandic
- &indonesia
- &iso2022jp
- &italian
- &korean
- &lithuanian
- &macedonian
- &malay
- &norwegianh
- &polish
- &portuguese
- &romanian
- &russian
- &russian1251
- &serbian
- &slovak
- &slovenian
- &spanish
- &swedish
- &turkish
- &ukrainian
- &ukrainian1251
-);
-
-%lang2tran::LOCALE=
-(
- 'english' => \&english,
- 'default' => \&english,
- 'belarusian' => \&belarusian,
- 'белару�ка�' => \&belarusian,
- 'big5' => \&big5,
- '¤¤¤åÁcÅé' => \&big5,
- 'brazil' => \&brazilian,
- 'brazilian' => \&brazilian,
- 'bulgarian' => \&bulgarian,
- 'áúëãàðñêè' => \&bulgarian,
- 'catalan' => \&catalan,
- 'catalan' => \&catalan,
- 'chinese' => \&chinese,
- '¼òÌåÖÐÎÄ' => \&chinese,
- 'cn' => \&cn,
- 'ÖÐÎĺº×Ö' => \&cn,
- 'croatian' => \&croatian,
- 'hrvatski' => \&croatian,
- 'czech' => \&czech,
- 'czechutf8' => \&czechutf8,
- 'danish' => \&danish,
- 'dansk' => \&danish,
- 'dutch' => \&dutch,
- 'nederlands' => \&dutch,
- 'estonian' => \&estonian,
- 'eesti' => \&estonian,
- 'eucjp' => \&eucjp,
- 'euc-jp' => \&eucjp,
- 'finnish' => \&finnish,
- 'suomi' => \&finnish,
- 'french' => \&french,
- 'francais' => \&french,
- 'galician' => \&galician,
- 'galego' => \&galician,
- 'gb' => \&gb,
- '¼òÌ庺×Ö' => \&gb,
- 'gb2312' => \&gb2312,
- 'ÖÐÎļòÌå' => \&gb2312,
- 'german' => \&german,
- 'german' => \&german,
- 'greek' => \&greek,
- 'ellinika' => \&greek,
- 'hungarian' => \&hungarian,
- 'magyar' => \&hungarian,
- 'icelandic' => \&icelandic,
- 'islenska' => \&icelandic,
- 'indonesia' => \&indonesia,
- 'indonesian' => \&indonesia,
- 'iso2022jp' => \&iso2022jp,
- 'iso-2022-jp' => \&iso2022jp,
- 'italian' => \&italian,
- 'italiano' => \&italian,
- 'korean' => \&korean,
- 'lithuanian' => \&lithuanian,
- 'lietuviðkai' => \&lithuanian,
- 'macedonian' => \&macedonian,
- 'makedonski' => \&macedonian,
- 'malay' => \&malay,
- 'malaysian' => \&malay,
- 'norwegian' => \&norwegian,
- 'norsk' => \&norwegian,
- 'polish' => \&polish,
- 'polski' => \&polish,
- 'portuguese' => \&portuguese,
- 'romanian' => \&romanian,
- 'romãn' => \&romanian,
- 'russian' => \&russian,
- 'òÕÓÓËÉÊ' => \&russian,
- 'russian1251' => \&russian1251,
- 'Ðóññêèé1251' => \&russian1251,
- 'serbian' => \&serbian,
- 'slovak' => \&slovak,
- 'slovenian' => \&slovenian,
- 'spanish' => \&spanish,
- 'espanol' => \&spanish,
- 'swedish' => \&swedish,
- 'svenska' => \&swedish,
- 'turkish' => \&turkish,
- 'turkce' => \&turkish,
- 'ukrainian' => \&ukrainian,
- 'õËÒÁ§ÎÓØËÁ' => \&ukrainian,
- 'ukrainian1251' => \&ukrainian1251,
- 'Óêðà¿íñüêà1251' => \&ukrainian1251,
-);
-
-%credits::LOCALE=
- (
-# default
- 'default' =>
- "Prepared for localization by
- <a href=\"http://www.ipt.dtu.dk\">Morten S. Nielsen</a>
- <a href=\"mailto:msn\@ipt.dtu.dk\">&lt;msn\@ipt.dtu.dk&gt;</a>",
-# Belarusian/белару�ка�
- 'belarusian' =>
- "Белару�кі пераклад:
- <a href=\"http://375gnu.wordpress.com\">Глеб Валошка</a>
- <a href=\"mailto:375gnu\@gmail.com\">&lt;375gnu\@gmail.com&gt;</a>",
-# Chinese/¤¤¤åÁcÅé
- 'big5' =>
- "¤¤¤å¤Æ§@ªÌ
- <a href=\"http://www.joy-tech.com.tw/~tate\">Tate Chen</a>
- <a href=\"mailto:tate\@joy-tech.com.tw\">&lt;tate\@joy-tech.com.tw&gt;</a><br />
- and <a href=\"http://asplord.com\">¶ÀªF¶©</a>
- <a href=\"mailto:ryan\@asplord.com\">&lt;ryan\@asplord.com&gt;</a>",
-# Brazil/brazilian
- 'brazilian' =>
- "Localiza&ccedil;&atilde;o efetuada por
- <a href=\"http://www.encarnacao.com\">Luiz Felipe R E</a>
- <a href=\"mailto:luizfelipe\@encarnacao.com\">&lt;luizfelipe\@encarnacao.com&gt;</a><br />
- atualização por Gleydson Mazioli da Silva
- <a href=\"mailto:gleydson\@debian.org\">&lt;gleydson\@debian.org&gt;</a>",
-# Bulgarian/Áúëãàðñêè
- 'bulgarian' =>
- "Ëîêàëèçàöèÿ íà áúëãàðñêè åçèê:
- <a href=\"http://linux.gyuvet.ch/\">Éîâêî Ëàìáðåâ</a>
- <a href=\"mailto:yovko\@sdf.lonestar.org\">&lt;yovko\@sdf.lonestar.org&gt;</a>",
-# catalan/catalan
- 'catalan' =>
- "Preparat per a localització per:
- <a hre=\"mailto:lluis\@seccat.com\">LLuís Gras</a>",
-# Simplified Chinese/¼òÌåÖÐÎÄ
- 'chinese' =>
- "ȫмòÌåÖÐÎĺº»¯£º
- <a href=\"http://www.kingisme.com\">»Æ»ª¶°</a>
- <a href=\"mailto:webmaster\@kingisme.com\">&lt;webmaster\@kingisme.com&gt;</a>",
-# cn/ÖÐÎĺº×Ö
- 'cn' =>
- " <HR NOSHADE>
- MRTGÍêÃÀºº»¯£º
- <NOBR><A HREF=\"http://www.darkstage.net\">À¹â</A>
- <A HREF=\"mailto:zurkabsd\@yahoo.com.cn\">
- &lt;zurkabsd\@yahoo.com.cn&gt;</A></NOBR>",
-# Croatian/hrvatski
- 'croatian' =>
- "Hrvatska lokalizacija -
- Dinko Korunic
- <a href=\"mailto:kreator\@fly.srk.fer.hr\">&lt;kreator\@fly.srk.fer.hr&gt;</a>",
-# Czech/Èesky
- 'czech' =>
- "Èeský pøeklad pøipravil
- <a href=\"http://www.och.cz\">Martin Och</a>
- <a href=\"mailto:martin\@och.cz\"> &lt;martin\@och.cz&gt;</a>",
-# Czechutf8/ÄŒesky
- 'czechutf8' =>
- "Český překlad do UTF-8 připravil
- <a href=\"http://www.idkfa.cz\">David Toman</a>
- <a href=\"mailto:david\@idkfa.cz\"> &lt;david\@idkfa.cz&gt;</a>",
-# Danish/dansk
- 'danish' =>
- "Forberedt for sprog samt oversat til dansk af
- <a href=\"http://www.ipt.dtu.dk\">Morten S. Nielsen</a>
- <a href=\"mailto:msn\@ipt.dtu.dk\">&lt;msn\@ipt.dtu.dk&gt;</a>",
-# the danish string means: "Prepared for languages and translated to danish by"
-# Dutch/nederlands
- 'dutch' =>
- "Vertaald naar het Nederlands door
- <a href=\"http://doema.peterson.nl\">Barry van Dijk</a>
- <a href=\"mailto:barry\@dijk.com\">&lt;barry\@dijk.com&gt;</a><br />;
- Aangepast door Paul Slootman
- <a href=\"mailto:paul\@debian.org\">&lt;paul\@debian.org&gt;</a>",
-# Estonian/Eesti
- 'estonian' =>
- "T&otilde;lge eesti keelde
- <a href=\"http://www.linux.ee/~klem\">Klemens Kasemaa</a>
- <a href=\"mailto:klem\@linux.ee\">&lt;klem\@linux.ee&gt;</a>",
-# the estonian string means: "Translation to estonian by"
-# eucjp/euc-jp
- 'eucjp' =>
- "ÆüËܸìÌõ(EUC-JP)ºîÀ®
- <a href=\"http://www.kgz.com/~uematsu/\">¿¢¾¾ ʸÆÁ</a>
- <a href=\"mailto:uematsu\@kgz.com\">&lt;uematsu\@kgz.com&gt;</a>",
-# Finnish/Suomi
- 'finnish' =>
- "Lokalisoinut
- Jussi Siponen
- <a href=\"mailto:jussi.siponen\@online.tietokone.fi\">&lt;jussi.siponen\@online.tietokone.fi&gt;</a>",
-# the Finnish string means: "Localized by"
-# French/francais
- 'french' =>
- "Localisation effectu&eacute;e par
- <a href=\"http://cache.univ-tlse1.fr/les.personnes/fabrice.prigent\">Fabrice Prigent</a>
- <a href=\"mailto:fabrice.prigent\@univ-tlse1.fr\">&lt;fabrice.prigent\@univ-tlse1.fr&gt;</a>",
-# Galician/Galego
- 'galician' =>
- "Traducido ao galego por
- David Garabana Barro
- <a href=\"mailto:dgaraban\@arrakis.es\">&lt;dgaraban\@arrakis.es&gt;</a>",
-# Chinese/¼òÌ庺×Ö
- 'gb' =>
- "¤¤¤å¤Æ§@ªÌ
- <a href=\"http://www.asiainfo.com/~zhanghui\">Hui Zhang</a>
- <a href=\"mailto:zhanghui2\@asiainfo.com\">&lt;zhanghui\@asiainfo.com&gt;</a>",
-# Chinese/ÖÐÎļòÌå
- 'gb2312' =>
- "ÖÐÎÄ»¯×÷Õß
- <a href=\"http://linux.tcpip.com.cn\">Peter Wong</a>
- <a href=\"mailto:webmaster\@tcpip.com.cn\">&webmaster\@tcpip.com.cn&gt;</a>",
-# German/deutsch
- 'german' =>
- "Vorbereitet f&uuml;r die Lokalisation von
- <a href=\"http://www.gumblfarz.de/~illsen\">Ilja Pavkovic</a>
- <a href=\"mailto:illsen\@gumblfarz.de\">&lt;illsen\@gumblfarz.de&gt;</a>",
-# Greek/Ellinika
- 'greek' =>
- "Ðñïåôïéìáóßá óôá åëëçíéêÜ áðü ôï
- <a href=\"http://hq.hellug.gr/~nls\">Óßìï ÎåíéôÝëëç</a>
- <a href=\"mailto:S.Xenitellis\@hellug.gr\">&lt;S.Xenitellis\@hellug.gr&gt;</a>",
-# Hungarian/magyar
- 'hungarian' =>
- "Magyaros&iacute;totta
- Nagy Levente
- <a href=\"mailto:levinet\@euroweb.hu\">&lt;levinet\@euroweb.hu&gt;</a>",
-# the hungarian string means: "Prepared for languages and translated to Hungarian by"
-# Icelandic/islenska
- 'icelandic' =>
- "&THORN;&yacute;tt yfir &aacute; &iacute;slensku af
- <a href=\"http://www.islandssimi.is\">Halld&oacute;r Karl H&ouml;gnason</a>
- <a href=\"mailto:halldor.hognason\@islandssimi.is\">&lt;halldor.hognason\@islandssimi.is&gt;</a>",
-# Indonesian/Indonesia
- 'indonesia' =>
- "Terjemahan ke bahasa Indonesia oleh:
- <a href=\"http://www.jamalinux.com\">Jamaludin Ahmad</a>
- <a href=\"mailto:jamaludin_at_jamalinux_dot_com\">&lt;jamaludin\@jamalinux.com&gt;</a>",
-# iso2022jp/iso-2022-jp
- 'iso2022jp' =>
- "\e\$BF|K\\8lLu\e(B(ISO-2022-JP)\e\$B:n\@.\e(B
- <a href=\"http://www.kgz.com/~uematsu/\">\e\$B?\">>\e(B \e\$BJ8FA\e(B</a>
- <a href=\"mailto:uematsu\@kgz.com\">&lt;uematsu\@kgz.com&gt;</a>",
-# Italian/Italiano
- 'italian' =>
- "Localizzazione effettuata da
- <a href=\"http://www.shinystat.it\">Andrea Rossi</a>
- <a href=\"mailto:rouge\@shiny.it\">&lt;rouge\@shiny.it&gt;</a>",
-# korean
- ,'korean' =>
- "Çѱ۸޽ÃÁö ¹ø¿ª:
- <a href=\"mailto:lovesh\@static.co.kr\">Ȳ°Ç¼ø</a>,
- <a href=\"mailto:cjh\@kr.FreeBSD.org\">ÃÖÁØÈ£</a>",
-# Lithuanian/lietuviðkai
- 'lithuanian' =>
- "Paruoðë ir á lietuviø kalbà iðvertë
- <a href=\"http://www.hardcore.lt\">ve</a>
- <a href=\"mailto:ve\@hardcore.lt\">&lt;ve\@hardcore.lt&gt;</a>",
-# the lithuanian string means: "Prepared for languages and translated to lithuanian by"
-# Macedonian/makedonski
- 'macedonian' =>
- "Makedonska lokalizacija -
- <a href=\"http://www.esmak.com.mk\">Delev D Zoran</a>
- <a href=\"mailto:delevz\@esmak.com.mk\">&lt;delevz\@esmak.com.mk&gt;</a>",
-# the macedonian string means: "Prepared for languages and translated to macedonian by"
-# Malaysian/Malay
- 'malay' =>
- "Terjemahan ke bahasa Malaysia/Indonesia oleh:
- <a href=\"http://www.mimos.my\">Assakhof Ab. Satar</a>
- <a href=\"mailto:assakhof\@mimos.my\">&lt;assakhof\@mimos.my&gt;</a>",
-# Danish/dansk
- 'norwegian' =>
- "Oversatt til norsk av
- Knut Grøneng
- <a href=\"mailto:knut.groneng\@merkantildata.no\">&lt;knut.groneng\@merkantildata.no&gt;</a>",
-# the norwegian string means: "Translated to norwegian by"
-# Polish/polski
- 'polish' =>
- "Polska lokalizacja
- <a href=\"http://www.klonex.com.pl/~lcj\">Lukasz Jokiel</a>
- <a href=\"mailto:Lukasz.Jokiel\@klonex.com.pl\">&lt;Lukasz.Jokiel\@klonex.com.pl&gt;</a>",
-# Português/portuguese
- 'portuguese' =>
- "Traduzido por
- <a href=\"http://sweet.ua.pt/~etdgomes\">Diogo Gomes</>
- <a href=\"mailto:etdgomes\@ua.pt\">&lt;etdgomes\@ua.pt&gt;</a>",
-# Romãn/romanian
- 'romanian' =>
- "Tradus de
- <a href=\"http://szjozsef.go.ro/\">József Szilágyi</a>
- <a href=\"mailto:jozsi\@maxiq.ro\">&lt;jozsi\@maxiq.ro&gt;</a>",
-# Russian/òÕÓÓËÉÊ
- 'russian' =>
- "ðÅÒÅ×ÏÄ ÎÁ ÒÕÓÓËÉÊ ÑÚÙË:
- <a href=\"http://mitya.pp.ru/\">äÍÉÔÒÉÊ óÉ×ÁÞÅÎËÏ</a>
- <a href=\"mailto:mitya\@cavia.pp.ru\">&lt;mitya\@cavia.pp.ru&gt;</a>",
-# Russian1251/Ðóññêèé1251
- 'russian1251' =>
- "Ïåðåâîä íà ðóññêèé ÿçûê (êîäèðîâêà 1251):
- <a href=\"http://www.irmcity.com\">Àëåêñàíäð Ðåäþê</a>
- <a href=\"mailto:aredyuk\@irmcity.com\">&lt;aredyuk\@irmcity.com&gt;</a>",
-# Serbian/Srpski
- 'serbian' =>
- "Ported to Serbian by / Srpski prevod uradio:
- Ratko Buèiæ
- <a href=\"mailto:ratko\@ni.ac.yu\">&lt;ratko\@ni.ac.yu&gt;</a>",
-# Slovak/Slovensky
- 'slovak' =>
- "Slovenský preklad pripravil
- Ing. Ladislav Mihok
- <a href=\"mailto:laco\@mrokh.shmu.sk\">&lt;laco\@mrokh.shmu.sk&gt;</a>",
-# Slovenian/Slovensko
- 'slovenian' =>
- "Slovenski prevod pripravil
- Ragnar Belial Us
- <a href=\"mailto:us\@sweet-sorrow.com\">&lt;us\@sweet-sorrow.com&gt;</a>",
-# Spanish/español
- 'spanish' =>
- "Preparado para localización por
- <a href=\"mailto:marcelo\@linuxfan.com\">Marcelo Roccasalva</a>",
-# Swedish/Svenska
- 'swedish' =>
- "&Oumlversatt till svenska av
- Clas Mayer
- <a href=\"mailto:clas\@mayer.se\">&lt;clas\@mayer.se&gt;</a>",
-# the Swedish string means: "Prepared for languages and translated to Swedish by"
-# Turkish/Türkçe
- 'turkish' =>
- "Türkçeleþtiren
- <a href=\"mailto:ozgurcd\@koc.net\">Özgür C. Demir</a>",
-# Ukrainian/õËÒÁ§ÎÓØËÁ
- 'ukrainian' =>
- "ðÅÒÅËÌÁÄ ÎÁ ÕËÒÁ§ÎÓØËÕ ÍÏ×Õ:
- <a href=\"http://www.arte-fact.net/~gray/\">óÅÒÇ¦Ê çÕͦΦÌÏ×ÉÞ</a>
- <a href=\"mailto:gray\@arte-fact.net\">&lt;gray\@arte-fact.net&gt;</a>",
-# Ukrainian1251/Óêðà¿íñüêà1251
- 'ukrainian1251' =>
- "Ïåðåêëàä óêðà¿íñüêîþ (cp1251):
- Îëåêñàíäð Êóíèöÿ
- <a href=\"mailto:xakep\@snark.ukma.kiev.ua\">&lt;xakep\@snark.ukma.kiev.ua&gt;</a>",
- );
-
-$credits::LOCALE{'белару�ка�'}=$credits::LOCALE{'belarusian'};
-$credits::LOCALE{'¤¤¤åÁcÅé'}=$credits::LOCALE{'big5'};
-$credits::LOCALE{'brazil'}=$credits::LOCALE{'brazilian'};
-$credits::LOCALE{'áúëãàðñêè'}=$credits::LOCALE{'bulgarian'};
-$credits::LOCALE{'catalan'}=$credits::LOCALE{'catalan'};
-$credits::LOCALE{'¼òÌåÖÐÎÄ'}=$credits::LOCALE{'Chinese'};
-$credits::LOCALE{'ÖÐÎĺº×Ö'}=$credits::LOCALE{'cn'};
-$credits::LOCALE{'hrvatski'}=$credits::LOCALE{'croatian'};
-$credits::LOCALE{'czech'}=$credits::LOCALE{'czech'};
-$credits::LOCALE{'czechutf8'}=$credits::LOCALE{'czechutf8'};
-$credits::LOCALE{'dansk'}=$credits::LOCALE{'danish'};
-$credits::LOCALE{'nederlands'}=$credits::LOCALE{'dutch'};
-$credits::LOCALE{'eesti'}=$credits::LOCALE{'estonian'};
-$credits::LOCALE{'euc-jp'}=$credits::LOCALE{'eucjp'};
-$credits::LOCALE{'finnish'}=$credits::LOCALE{'finnish'};
-$credits::LOCALE{'francais'}=$credits::LOCALE{'french'};
-$credits::LOCALE{'galego'}=$credits::LOCALE{'galician'};
-$credits::LOCALE{'¼òÌ庺×Ö'}=$credits::LOCALE{'gb'};
-$credits::LOCALE{'ÖÐÎļòÌå'}=$credits::LOCALE{'gb2312'};
-$credits::LOCALE{'deutsch'}=$credits::LOCALE{'german'};
-$credits::LOCALE{'ellinika'}=$credits::LOCALE{'greek'};
-$credits::LOCALE{'magyar'}=$credits::LOCALE{'hungarian'};
-$credits::LOCALE{'islenska'}=$credits::LOCALE{'icelandic'};
-$credits::LOCALE{'indonesian'}=$credits::LOCALE{'indonesia'};
-$credits::LOCALE{'iso-2022-jp'}=$credits::LOCALE{'iso2022jp'};
-$credits::LOCALE{'italiano'}=$credits::LOCALE{'italian'};
-$credits::LOCALE{'korean'}=$credits::LOCALE{'korean'};
-$credits::LOCALE{'lietuviðkai'}=$credits::LOCALE{'lithuanian'};
-$credits::LOCALE{'macedonian'}=$credits::LOCALE{'macedonian'};
-$credits::LOCALE{'malaysian'}=$credits::LOCALE{'malay'};
-$credits::LOCALE{'norsk'}=$credits::LOCALE{'norwegian'};
-$credits::LOCALE{'polski'}=$credits::LOCALE{'polish'};
-$credits::LOCALE{'portuguese'}=$credits::LOCALE{'portuguese'};
-$credits::LOCALE{'romãn'}=$credits::LOCALE{'romanian'};
-$credits::LOCALE{'òÕÓÓËÉÊ'}=$credits::LOCALE{'russian'};
-$credits::LOCALE{'Ðóññêèé1251'}=$credits::LOCALE{'russian1251'};
-$credits::LOCALE{'serbian'}=$credits::LOCALE{'serbian'};
-$credits::LOCALE{'slovak'}=$credits::LOCALE{'slovak'};
-$credits::LOCALE{'slovenian'}=$credits::LOCALE{'slovenian'};
-$credits::LOCALE{'espanol'}=$credits::LOCALE{'spanish'};
-$credits::LOCALE{'svenska'}=$credits::LOCALE{'swedish'};
-$credits::LOCALE{'turkce'}=$credits::LOCALE{'turkish'};
-$credits::LOCALE{'õËÒÁ§ÎÓØËÁ'}=$credits::LOCALE{'ukrainian'};
-$credits::LOCALE{'Óêðà¿íñüêà1251'}=$credits::LOCALE{'ukrainian1251'};
-
-# English - default
-sub english
-{
- return shift;
-};
-
-# Belarusian
-
-sub belarusian
-{
- my $string = shift;
- return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=utf-8
-
- %translations =
- (
- 'iso-8859-1' => 'utf-8',
- 'Maximal 5 Minute Incoming Traffic' => '�айбольшы ўваходны трафік за 5 хвілін',
- 'Maximal 5 Minute Outgoing Traffic' => '�айбольшы выходны трафік за 5 хвілін',
- 'the device' => 'прылада',
- 'The statistics were last updated(.*)' => '�пошні раз �таты�тыка абнаўл�ла��: $1',
- ' Average\)' => ')',
- 'Average' => '�па��р�днены',
- 'Max' => 'найбольшы',
- 'Current' => 'б�гучы',
- 'version' => 'в�р�і�',
- '`Daily\' Graph \((.*) Minute' => 'Графік трафіку за �уткі (за $1 хвілін ',
- '`Weekly\' Graph \(30 Minute' => 'Графік трафіку за тыдзень (за 30 хвілін ',
- '`Monthly\' Graph \(2 Hour' => 'Графік трафіку за ме��ц (за 2 гадзіны ',
- '`Yearly\' Graph \(1 Day' => 'Графік трафіку за год (за 1 дзень ',
- 'Incoming Traffic in (\S+) per Second' => 'Уваходны трафік $1 за ��кунду',
- 'Outgoing Traffic in (\S+) per Second' => 'Выходны трафік $1 за ��кунду',
- 'Incoming Traffic in (\S+) per Minute' => 'Уваходны трафік $1 за хвіліну',
- 'Outgoing Traffic in (\S+) per Minute' => 'Выходны трафік $1 за хвіліну',
- 'Incoming Traffic in (\S+) per Hour' => 'Уваходны трафік $1 за гадзіну',
- 'Outgoing Traffic in (\S+) per Hour' => 'Выходны трафік $1 за гадзіну',
- 'at which time (.*) had been up for(.*)' => 'калі $1 працаваў $2',
- '(\S+) per minute' => '$1 за хвіліну',
- '(\S+) per hour' => '$1 за гадзіну',
- '(.+)/s$' => '$1/�',
- '(.+)/min' => '$1/хв',
- '(.+)/h$' => '$1/г',
- '([kMG]?)([bB])/s' => '$1$2/�',
- '([kMG]?)([bB])/min' => '$1$2/хв',
- '([kMG]?)([bB])/h' => '$1$2/г',
- 'Bits' => 'бітах',
- 'Bytes' => 'байтах',
- 'In' => 'Уваходны',
- 'Out' => 'Выходны',
- 'Percentage' => '�д�откі',
- 'Ported to OpenVMS Alpha by' => 'Перано� на OpenVMS:',
- 'Ported to WindowsNT by' => 'Перано� на WindowsNT:',
- 'and' => 'Ñ–',
- '^GREEN' => 'ЗЯЛ��Ы',
- 'BLUE' => 'СІ�І',
- 'DARK GREEN' => 'Ц�М��ЗЯЛ��Ы',
- 'MAGENTA' => 'РУЖОВЫ',
- 'AMBER' => 'БУРШТЫ��ВЫ'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => '��дзел�', 'Sun' => '�д',
- 'Monday' => 'Пан�дзелак', 'Mon' => 'Пн',
- 'Tuesday' => '�ўторак', 'Tue' => '�ў',
- 'Wednesday' => 'Серада', 'Wed' => 'Ср',
- 'Thursday' => 'Чацьвер', 'Thu' => 'Чц',
- 'Friday' => 'П�тніца', 'Fri' => 'Пт',
- 'Saturday' => 'Субота', 'Sat' => 'Сб'
- );
-
-%month =
- (
- 'January' => 'Студзень', 'February' => 'Люты' , 'March' => 'Сакавік',
- 'Jan' => 'Сту', 'Feb' => 'Лют', 'Mar' => 'Сак',
- 'April' => 'Кра�авік', 'May' => 'Травень', 'June' => 'Ч�рвень',
- 'Apr' => 'Кра', 'May' => 'Тра', 'Jun' => 'Ч�р',
- 'July' => 'Ліпень', 'August' => 'Жнівень', 'September' => 'Вера�ень',
- 'Jul' => 'Ліп', 'Aug' => 'Жні', 'Sep' => 'Вер',
- 'October' => 'Ка�трычнік','November' => 'Лі�тапад', 'December' => 'Сьнежань',
- 'Oct' => 'Ка�', 'Nov' => 'Лі�', 'Dec' => 'Сьн'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." у ".$quux[1];
- };
- return "$wday{$foo[0]}, $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-
-
-
-# Chinese Big5 Code
-
-sub big5
-{
- my $string = shift;
- return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'big5',
- 'Maximal 5 Minute Incoming Traffic' => '5¤ÀÄÁ³Ì¤j¬y¤J¶q',
- 'Maximal 5 Minute Outgoing Traffic' => '5¤ÀÄÁ³Ì¤j¬y¥X¶q',
- 'the device' => '¸Ë¸m',
- 'The statistics were last updated(.*)' => '¤W¦¸²Î­p§ó·s®É¶¡: $1',
- ' Average\)' => ' ¥­§¡)',
- 'Average' => '¥­§¡',
- 'Max$' => '³Ì¤j',
- 'Current' => '¥Ø«e',
- 'version' => 'ª©¥»',
- '`Daily\' Graph \((.*) Minute' => '¨C¤é ¹Ïªí ($1 ¤ÀÄÁ',
- '`Weekly\' Graph \(30 Minute' => '¨C¶g ¹Ïªí (30 ¤ÀÄÁ' ,
- '`Monthly\' Graph \(2 Hour' => '¨C¤ë ¹Ïªí (2 ¤p®É',
- '`Yearly\' Graph \(1 Day' => '¨C¦~ ¹Ïªí (1 ¤Ñ',
- 'Incoming Traffic in (\S+) per Second' => '¨C¬í¬y¤J¶q (³æ¦ì $1)',
- 'Outgoing Traffic in (\S+) per Second' => '¨C¬í¬y¥X¶q (³æ¦ì $1)',
- 'Incoming Traffic in (\S+) per Minute' => '¨C¤ÀÄÁ¬y¤J¶q (³æ¦ì $1)',
- 'Outgoing Traffic in (\S+) per Minute' => '¨C¤ÀÄÁ¬y¥X¶q (³æ¦ì $1)',
- 'Incoming Traffic in (\S+) per Hour' => '¨C¤p®É¬y¤J¶q (³æ¦ì $1)',
- 'Outgoing Traffic in (\S+) per Hour' => '¨C¤p®É¬y¥X¶q (³æ¦ì $1)',
- 'at which time (.*) had been up for(.*)' => '³]³Æ¦WºÙ $1¡A¤w¹B§@®É¶¡(UPTIME): $2',
- '(\S+) per minute' => '$1/¤À',
- '(\S+) per hour' => '$1/¤p®É',
- '(.+)/s$' => '$1/’',
- '(.+)/min$' => '$1/¤À',
- '(.+)/h$' => '$1/¤p®É',
- #'([kMG]?)([bB])/s' => '$1$2/s',
- #'([kMG]?)([bB])/min' => '$1$2/min',
- #'([kMG]?)([bB])/h' => '$1$2/std',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => '¬y¤J',
- 'Out$' => '¬y¥X',
- 'Percentage' => '¦Ê¤À¤ñ',
- 'Ported to OpenVMS Alpha by' => '²¾´Ó¨ì OpenVM Alpha §@ªÌ',
- 'Ported to WindowsNT by' => '²¾´Ó¨ì WindowsNT §@ªÌ',
- 'and' => '¤Î',
- '^GREEN' => 'ºñ¦â',
- 'BLUE' => 'ÂŦâ',
- 'DARK GREEN' => '¾¥ºñ¦â',
- 'MAGENTA' => 'µµ¦â',
- 'AMBER' => 'µ[¬Ä¦â'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => '¬P´Á¤é', 'Sun' => '¤é',
- 'Monday' => '¬P´Á¤@', 'Mon' => '¤@',
- 'Tuesday' => '¬P´Á¤G', 'Tue' => '¤G',
- 'Wednesday' => '¬P´Á¤T', 'Wed' => '¤T',
- 'Thursday' => '¬P´Á¥|', 'Thu' => '¥|',
- 'Friday' => '¬P´Á¤­', 'Fri' => '¤­',
- 'Saturday' => '¬P´Á¤»', 'Sat' => '¤»'
- );
-
-%month =
- (
- 'January' => '¤@¤ë', 'February' => '¤G¤ë', 'March' => '¤T¤ë',
- 'Jan' => '¤@', 'Feb' => '¤G', 'Mar' => '¤T',
- 'April' => '¥|¤ë', 'May' => '¤­¤ë', 'June' => '¤»¤ë',
- 'Apr' => '¥|', 'May' => '¤­', 'Jun' => '¤»',
- 'July' => '¤C¤ë', 'August' => '¤K¤ë', 'September' => '¤E¤ë',
- 'Jul' => '¤C', 'Aug' => '¤K', 'Sep' => '¤E',
- 'October' => '¤Q¤ë', 'November' => '¤Q¤@¤ë', 'December' => '¤Q¤G¤ë',
- 'Oct' => '¤Q', 'Nov' => '¤Q¤@', 'Dec' => '¤Q¤G'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0];
- $foo[4]=$quux[1];
- };
- return "$foo[3] ¦~ $month{$foo[2]} $foo[1] ¤é $wday{$foo[0]} $foo[4]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# Brazilian (Portugues)
-
-sub brazilian
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Tr&aacute;fego M&aacute;ximo de Entrada em 5 minutos',
- 'Maximal 5 Minute Outgoing Traffic' => 'Tr&aacute;fego M&aacute;ximo de Sa&iacute;da em 5 minutos',
- 'the device' => 'dispositivo',
- 'The statistics were last updated (.*)' => '&Uacute;ltima atualiza&ccedil;&atilde;o das estat&iacute;sticas: $1',
- ' Average\)' => ' - m&eacute;dia)',
- 'Average' => 'M&eacute;dia',
- 'Max' => 'M&aacute;x',
- 'Current' => 'Atual',
- 'version' => 'vers&atilde;o',
- '`Daily\' Graph \((.*) Minute' => 'Gr&aacute;fico `Di&aacute;rio\' ($1 minutos',
- '`Weekly\' Graph \(30 Minute' => 'Gr&aacute;fico `Semanal\' (30 minutos' ,
- '`Monthly\' Graph \(2 Hour' => 'Gr&aacute;fico `Mensal\' (2 horas',
- '`Yearly\' Graph \(1 Day' => 'Gr&aacute;fico `Anual\' (1 dia',
- 'Incoming Traffic in (\S+) per Second' => 'Tr&aacute;fego de Entrada em $1 por segundo',
- 'Outgoing Traffic in (\S+) per Second' => 'Tr&aacute;fego de Sa&iacute;da em $1 por segundo',
- 'at which time (.*) had been up for(.*)' => 'nesta hora $1 estava ativo por $2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- # '([kMG]?)([bB])/h' => '$1$2/t',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Entr.',
- 'Out' => 'Sa&iacute;',
- 'Percentage' => 'Porc.',
- 'Ported to OpenVMS Alpha by' => 'Adaptado para o Alpha OpenVMS por',
- 'Ported to WindowsNT by' => 'Adaptado para o WindowsNT por',
- 'and' => 'e',
- '^GREEN' => 'VERDE',
- 'BLUE' => 'AZUL',
- 'DARK GREEN' => 'VERDE ESCURO',
- 'MAGENTA' => 'LIL&Aacute;S',
- 'AMBER' => 'AMBAR'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Domingo', 'Sun' => 'Dom',
- 'Monday' => 'Segunda', 'Mon' => 'Seg',
- 'Tuesday' => 'Ter&ccedil;a', 'Tue' => 'Ter',
- 'Wednesday' => 'Quarta', 'Wed' => 'Qua',
- 'Thursday' => 'Quinta', 'Thu' => 'Qui',
- 'Friday' => 'Sexta', 'Fri' => 'Sex',
- 'Saturday' => 'S&aacute;bado', 'Sat' => 'S&aacute;b'
-
- );
-
-%month =
- (
- 'January' => 'Janeiro', 'February' => 'Fevereiro' , 'March' => 'Mar&ccedil;o',
- 'Jan' => 'Jan', 'Feb' => 'Fev', 'Mar' => 'Mar',
- 'April' => 'Abril', 'May' => 'Maio', 'June' => 'Junho',
- 'Apr' => 'Abr', 'May' => 'Mai', 'Jun' => 'Jun',
- 'July' => 'Julho', 'August' => 'Agosto', 'September' => 'Setembro',
- 'Jul' => 'Jul', 'Aug' => 'Ago', 'Sep' => 'Set',
- 'October' => 'Outubro', 'November' => 'Novembro', 'December' => 'Dezembro',
- 'Oct' => 'Out', 'Nov' => 'Nov', 'Dec' => 'Dez'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." &agrave;s ".$quux[1];
- };
- return "$wday{$foo[0]}, $foo[1] de $month{$foo[2]} de $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-
-
-# Bulgarian
-
-sub bulgarian
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'windows-1251',
- 'Maximal 5 Minute Incoming Traffic' => 'Ìàêñèìàëåí âõîäÿù òðàôèê çà 5 ìèíóòè',
- 'Maximal 5 Minute Outgoing Traffic' => 'Ìàêñèìàëåí èçõîäÿù òðàôèê çà 5 ìèíóòè',
- 'the device' => 'óñòðîéñòâîòî',
- 'The statistics were last updated(.*)' => 'Ñòàòèñòè÷åñêèòå äàííè ñà îò÷åòåíè íà: $1',
- ' Average\)' => ' ñðåäíî)',
- 'Average' => 'Ñðåäíî',
- 'Max' => 'Ìàêñ.',
- 'Current' => 'Òåêóùî',
- 'version' => 'âåðñèÿ',
- '`Daily\' Graph \((.*) Minute' => 'Äíåâíà ãðàôèêà (ïðåç $1 ìèíóòè',
- '`Weekly\' Graph \(30 Minute' => 'Ñåäìè÷íà ãðàôèêà (ïðåç 30 ìèíóòè' ,
- '`Monthly\' Graph \(2 Hour' => 'Ìåñå÷íà ãðàôèêà (ïðåç 2 ÷àñà',
- '`Yearly\' Graph \(1 Day' => 'Ãîäèøíà ãðàôèêà (ïðåç 1 äåí',
- 'Incoming Traffic in (\S+) per Second' => 'Âõîäÿù òðàôèê â $1 çà ñåêóíäà',
- 'Outgoing Traffic in (\S+) per Second' => 'Èçõîäÿù òðàôèê â $1 çà ñåêóíäà',
- 'at which time (.*) had been up for(.*)' => 'â êîåòî âðåìå $1 ðàáîòè îò $2',
- #'([kMG]?)([bB])/s' => '$1$1/ñåê',
- #'([kMG]?)([bB])/min' => '$1$2/ìèí',
- '([kMG]?)([bB])/h' => '$1$2/÷',
- 'Bits' => 'áèòà',
- 'Bytes' => 'áàéòà',
- 'In' => 'Âõ.',
- 'Out' => 'Èçõ.',
- 'Percentage' => 'Ïðîöåíò',
- 'Ported to OpenVMS Alpha by' => 'Ïîðò çà OpenVMS Alpha îò',
- 'Ported to WindowsNT by' => 'Ïîðò çà WindowsNT îò',
- 'and' => 'è',
- '^GREEN' => 'çåëåí',
- 'BLUE' => 'ñèí',
- 'DARK GREEN' => 'òúìíîçåëåí',
- 'MAGENTA' => 'êåðåìèäåí',
- 'AMBER' => 'êåõëèáàð'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => ' Íåäåëÿ', 'Sun' => 'Íä',
- 'Monday' => ' Ïîíåäåëíèê', 'Mon' => 'Ïí',
- 'Tuesday' => ' Âòîðíèê', 'Tue' => 'Âò',
- 'Wednesday' => ' Ñðÿäà', 'Wed' => 'Ñð',
- 'Thursday' => ' ×åòâúðòúê', 'Thu' => '×ò',
- 'Friday' => ' Ïåòúê', 'Fri' => 'Ïò',
- 'Saturday' => ' Ñúáîòà', 'Sat' => 'Ñá'
- );
-
-%month =
- (
- 'January' => 'ßíóàðè', 'February' => 'Ôåâðóàðè' , 'March' => 'Ìàðò',
- 'Jan' => 'ßíó', 'Feb' => 'Ôåâ', 'Mar' => 'Ìàð',
- 'April' => 'Àïðèë', 'May' => 'Ìàé', 'June' => 'Þíè',
- 'Apr' => 'Àïð', 'May' => 'Ìàé', 'Jun' => 'Þíè',
- 'July' => 'Þëè', 'August' => 'Àâãóñò', 'September' => 'Ñåïòåìâðè',
- 'Jul' => 'Þëè', 'Aug' => 'Àâã', 'Sep' => 'Ñåï',
- 'October' => 'Îêòîìâðè', 'November' => 'Íîåìâðè', 'December' => 'Äåêåìâðè',
- 'Oct' => 'Îêò', 'Nov' => 'Íîå', 'Dec' => 'Äåê'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]."Ç. × ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# catalan
-
-sub catalan
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Tr&agrave;fic entrant m&agrave;xim en 5 minuts',
- 'Maximal 5 Minute Outgoing Traffic' => 'Tr&agrave;fic sortint m&agrave;xim en 5 minuts',
- 'the device' => 'el dispositiu',
- 'The statistics were last updated(.*)' => 'Estad&iacute;stiques actualitzades el $1',
- ' Average\)' => ' Promig)',
- 'Average' => 'Promig',
- 'Max' => 'M&agrave;xim',
- 'Current' => 'Actual',
- 'version' => 'versi&oacute',
- '`Daily\' Graph \((.*) Minute' => 'Gr&agrave;fic diari ($1 minuts :',
- '`Weekly\' Graph \(30 Minute' => 'Gr&agrave;fic setmanal (30 minuts :' ,
- '`Monthly\' Graph \(2 Hour' => 'Gr&agrave;fic mensual (2 hores :',
- '`Yearly\' Graph \(1 Day' => 'Gr&agrave;fic anual (1 dia :',
- 'Incoming Traffic in (\S+) per Second' => 'Tr&agrave;fic entrant en $1 per segon',
- 'Outgoing Traffic in (\S+) per Second' => 'Tr&agrave;fic sortint en $1 per segon',
- 'at which time (.*) had been up for(.*)' => '$1 ha estat funcionant durant $2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- # '([kMG]?)([bB])/h' => '$1$2/t',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Entrant',
- 'Out' => 'Sortint',
- 'Percentage' => 'Percentatge',
- 'Ported to OpenVMS Alpha by' => 'Portat a OpenVMS Alpha per',
- 'Ported to WindowsNT by' => 'Portat a WindowsNT per',
- 'and' => 'i',
- '^GREEN' => 'VERD',
- 'BLUE' => 'BLAU',
- 'DARK GREEN' => 'VERD FOSC',
- 'MAGENTA' => 'MAGENTA',
- 'AMBER' => 'AMBAR'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Diumenge', 'Sun' => 'Dg',
- 'Monday' => 'Dilluns', 'Mon' => 'Dl',
- 'Tuesday' => 'Dimarts', 'Tue' => 'Dm',
- 'Wednesday' => 'Dimecres', 'Wed' => 'Dc',
- 'Thursday' => 'Dijous', 'Thu' => 'Dj',
- 'Friday' => 'Divendres', 'Fri' => 'Dv',
- 'Saturday' => 'Dissabte', 'Sat' => 'Ds'
- );
-
-%month =
- (
- 'January' => 'Gener', 'February' => 'Febrer' , 'March' => 'Març',
- 'Jan' => 'Gen', 'Feb' => 'Feb', 'Mar' => 'Mar',
- 'April' => 'Abril', 'May' => 'Maig', 'June' => 'Juny',
- 'Apr' => 'Abr', 'May' => 'Mai', 'Jun' => 'Jun',
- 'July' => 'Juliol', 'August' => 'Agost', 'September' => 'Setembre',
- 'Jul' => 'Jul', 'Aug' => 'Ago', 'Sep' => 'Set',
- 'October' => 'Octubre', 'November' => 'Novembre', 'December' => 'Desembre',
- 'Oct' => 'Oct', 'Nov' => 'Nov', 'Dec' => 'Des'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." a les ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] de $month{$foo[2]} de $foo[3]";
- };
- return $string;
-
-};
-
-# Simplified Chinese
-
-sub chinese
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
-
- %translations =
- (
- 'iso-8859-1' => 'gb2312',
- 'Maximal 5 Minute Incoming Traffic' => '5·ÖÖÓ×î´óÁ÷ÈëÁ¿',
- 'Maximal 5 Minute Outgoing Traffic' => '5·ÖÖÓ×î´óÁ÷³öÁ¿',
- 'the device' => 'É豸',
- 'The statistics were last updated(.*)' => '×îºóͳ¼Æ¸üÐÂʱ¼ä£º$1',
- ' Average\)' => ' ƽ¾ù)',
- 'Average' => 'ƽ¾ù',
- 'Max' => '×î´ó',
- 'Current' => 'µ±Ç°',
- 'version' => '°æ±¾',
- '`Daily\' Graph \((.*) Minute' => 'ÿÈÕ Í¼±í ($1 ·ÖÖÓ',
- '`Weekly\' Graph \(30 Minute' => 'ÿÖÜ Í¼±í (30 ·ÖÖÓ' ,
- '`Monthly\' Graph \(2 Hour' => 'ÿÔ ͼ±í (2 Сʱ',
- '`Yearly\' Graph \(1 Day' => 'ÿÄê ͼ±í (1 Ìì',
- 'Incoming Traffic in (\S+) per Second' => 'ÿÃëÁ÷ÈëÁ¿ (µ¥Î» $1 )',
- 'Outgoing Traffic in (\S+) per Second' => 'ÿÃëÁ÷³öÁ¿ (µ¥Î» $1 )',
- 'at which time (.*) had been up for(.*)' => ' $1 ÒÑÔËÐÐÁË£º $2 ',
- '(.+)/s$' => '$1/Ãë',
- '(.+)/min$' => '$1/·Ö',
- '(.+)/h$' => '$1/ʱ',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Á÷È룺',
- 'Out' => 'Á÷³ö£º',
- 'Percentage' => '°Ù·Ö±È£º',
- 'Ported to OpenVMS Alpha by' => 'ÒÆÖ²µ½ OpenVMS µÄÊÇ',
- 'Ported to WindowsNT by' => 'ÒÆÖ²µ½ WindowsNT µÄÊÇ',
- 'and' => 'Óë',
- '^GREEN' => 'ÂÌÉ«',
- 'BLUE' => 'À¶É«',
- 'DARK GREEN' => 'Ä«ÂÌ',
- 'MAGENTA' => '×ÏÉ«',
- 'AMBER' => 'çúçêÉ«'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'ÐÇÆÚÌì', 'Sun' => 'ÈÕ',
- 'Monday' => 'ÐÇÆÚÒ»', 'Mon' => 'Ò»',
- 'Tuesday' => 'ÐÇÆÚ¶þ', 'Tue' => '¶þ',
- 'Wednesday' => 'ÐÇÆÚÈý', 'Wed' => 'Èý',
- 'Thursday' => 'ÐÇÆÚËÄ', 'Thu' => 'ËÄ',
- 'Friday' => 'ÐÇÆÚÎå', 'Fri' => 'Îå',
- 'Saturday' => 'ÐÇÆÚÁù', 'Sat' => 'Áù'
-
- );
-
-%month =
- (
- 'January' => ' Ò» ÔÂ', 'February' => ' ¶þ ÔÂ', 'March' => ' Èý ÔÂ',
- 'April' => ' ËÄ ÔÂ', 'May' => ' Îå ÔÂ', 'June' => ' Áù ÔÂ',
- 'July' => ' Æß ÔÂ', 'August' => ' °Ë ÔÂ', 'September' => ' ¾Å ÔÂ',
- 'October' => ' Ê® ÔÂ', 'November' => 'ʮһÔÂ', 'December' => 'Ê®¶þÔÂ',
- 'Jan' => '£±ÔÂ', 'Feb' => '£²ÔÂ', 'Mar' => '£³ÔÂ',
- 'Apr' => '£´ÔÂ', 'May' => '£µÔÂ', 'Jun' => '£¶ÔÂ',
- 'Jul' => '£·ÔÂ', 'Aug' => '£¸ÔÂ', 'Sep' => '£¹ÔÂ',
- 'Oct' => '10ÔÂ', 'Nov' => '11ÔÂ', 'Dec' => '12ÔÂ'
-
- );
-
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0];
- $foo[4]=$quux[1];
- };
- return "$foo[3]Äê $month{$foo[2]} $foo[1] ÈÕ £¬$wday{$foo[0]} £¬$foo[4]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# cn s-Chinese
-
-sub cn
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
-
- %translations =
- (
- 'charset=iso-8859-1' => 'charset=gb2312',
- 'Maximal 5 Minute Incoming Traffic' => '5·ÖÖÓ×î´óÁ÷ÈëÁ¿',
- 'Maximal 5 Minute Outgoing Traffic' => '5·ÖÖÓ×î´óÁ÷³öÁ¿',
- 'the device' => 'É豸',
- 'The statistics were last updated(.*)' => 'ͳ¼Æ×îºó¸üÐÂʱ¼ä£º$1',
- ' Average\)</B><BR>' => ' ƽ¾ù)</B><BR>',
- '<TD ALIGN=right><SMALL>Average(.*)' => '<TD ALIGN=right><SMALL>ƽ¾ù$1',
- '<TD ALIGN=right><SMALL>Max(.*)' => '<TD ALIGN=right><SMALL>×î´ó$1',
- '<TD ALIGN=right><SMALL>Current(.*)' => '<TD ALIGN=right><SMALL>µ±Ç°$1',
- 'version' => '°æ±¾',
- '<B>`Daily\' Graph \((.*) Minute' => '<B>"ÿÈÕ" ͼ±í ($1 ·ÖÖÓ',
- '<B>`Weekly\' Graph \(30 Minute' => '<B>"ÿÖÜ" ͼ±í (30 ·ÖÖÓ' ,
- '<B>`Monthly\' Graph \(2 Hour' => '<B>"ÿÔÂ" ͼ±í (2 Сʱ',
- '<B>`Yearly\' Graph \(1 Day' => '<B>"ÿÄê" ͼ±í (1 Ìì',
- 'Incoming Traffic in (\S+) per Second' => 'ÿÃëÁ÷Èë $1 Á¿',
- 'Outgoing Traffic in (\S+) per Second' => 'ÿÃëÁ÷³ö $1 Á¿',
- 'at which time (.*) had been up for(.*)' => '´Ëʱ $1 ÒÑÔË×÷ÁË£º $2 ',
- '(.+)/s$' => '$1/Ãë',
- '(.+)/min$' => '$1/·Ö',
- '(.+)/h$' => '$1/ʱ',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- '&nbsp;In:</FONT>' => '&nbsp;Á÷È룺</FONT>',
- '&nbsp;Out:</FONT>' => '&nbsp;Á÷³ö£º</FONT>',
- '&nbsp;Percentage</FONT>' => '&nbsp;°Ù·Ö±È£º</FONT>',
- 'Ported to OpenVMS Alpha by' => 'ÒÆÖ²µ½ OpenVMS Õß',
- 'Ported to WindowsNT by' => 'ÒÆÖ²µ½ WindowsNT Õß',
- 'and' => 'ºÍ',
- '^GREEN' => 'ÂÌ',
- 'BLUE' => '˦',
- 'DARK GREEN' => 'Ä«ÂÌ',
- 'MAGENTA' => '×Ï',
- 'AMBER' => 'çúçêÉ«'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'ÐÇÆÚÌì', 'Sun' => 'ÈÕ',
- 'Monday' => 'ÐÇÆÚÒ»', 'Mon' => 'Ò»',
- 'Tuesday' => 'ÐÇÆÚ¶þ', 'Tue' => '¶þ',
- 'Wednesday' => 'ÐÇÆÚÈý', 'Wed' => 'Èý',
- 'Thursday' => 'ÐÇÆÚËÄ', 'Thu' => 'ËÄ',
- 'Friday' => 'ÐÇÆÚÎå', 'Fri' => 'Îå',
- 'Saturday' => 'ÐÇÆÚÁù', 'Sat' => 'Áù'
-
- );
-
-%month =
- (
- 'January' => ' Ò» ÔÂ', 'February' => ' ¶þ ÔÂ', 'March' => ' Èý ÔÂ',
- 'April' => ' ËÄ ÔÂ', 'May' => ' Îå ÔÂ', 'June' => ' Áù ÔÂ',
- 'July' => ' Æß ÔÂ', 'August' => ' °Ë ÔÂ', 'September' => ' ¾Å ÔÂ',
- 'October' => ' Ê® ÔÂ', 'November' => 'ʮһÔÂ', 'December' => 'Ê®¶þÔÂ',
- 'Jan' => '£±ÔÂ', 'Feb' => '£²ÔÂ', 'Mar' => '£³ÔÂ',
- 'Apr' => '£´ÔÂ', 'May' => '£µÔÂ', 'Jun' => '£¶ÔÂ',
- 'Jul' => '£·ÔÂ', 'Aug' => '£¸ÔÂ', 'Sep' => '£¹ÔÂ',
- 'Oct' => '£±£°ÔÂ', 'Nov' => '£±£±ÔÂ', 'Dec' => '£±£²ÔÂ'
-
- );
-
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0];
- $foo[4]=$quux[1];
- };
- return "$foo[3]Äê $month{$foo[2]} $foo[1] ÈÕ £¬$wday{$foo[0]} £¬$foo[4]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-
-sub croatian
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
-
- %translations =
- (
- 'iso-8859-1' => 'iso-8859-2',
- 'Maximal 5 Minute Incoming Traffic' => 'Maksimalni ulazni promet unutar 5 minuta',
- 'Maximal 5 Minute Outgoing Traffic' => 'Maksimalni izlazni promet unutar 5 minuta',
- 'the device' => 'ureðaj',
- 'The statistics were last updated(.*)' => 'Statistike su zadnji puta izmijenjene $1',
- ' Average\)' => ' prosjeèna vrijednost)',
- 'Average' => 'Prosjeèno',
- 'Max' => 'Maksimalno',
- 'Current' => 'Trenutno',
- 'version' => 'verzija',
- '`Daily\' Graph \((.*) Minute' => 'Dnevne statistike (svakih $1 minuta',
- '`Weekly\' Graph \(30 Minute' => 'Tjedne statistike (svakih 30 minuta' ,
- '`Monthly\' Graph \(2 Hour' => 'Mjeseène statistike (svakih 2 sata',
- '`Yearly\' Graph \(1 Day' => 'Godi¹nje statistike (svaki 1 dan',
- 'Incoming Traffic in (\S+) per Second' => 'Ulazni promet - $1 po sekundi',
- 'Outgoing Traffic in (\S+) per Second' => 'Izlazni promet - $1 po sekundi',
- 'at which time (.*) had been up for(.*)' => 'gdje $1 je bio aktivan $2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/g',
- 'Bits' => 'Bitova',
- 'Bytes' => 'Bajtova',
- 'In' => 'Unutra',
- 'Out' => 'Van',
- 'Percentage' => 'Postotak',
- 'Ported to OpenVMS Alpha by' => 'Port na OpenVMS Alpha od',
- 'Ported to WindowsNT by' => 'Post od WindowsNT od',
- 'and' => 'i',
- '^GREEN' => 'ZELENA',
- 'BLUE' => 'PLAVA',
- 'DARK GREEN' => 'TAMNO ZELENA',
- 'MAGENTA' => 'LJUBIÈASTA',
- 'AMBER' => 'AMBER'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Nedjelja', 'Sun' => 'Ned',
- 'Monday' => 'Ponedjeljak', 'Mon' => 'Pon',
- 'Tuesday' => 'Utorak', 'Tue' => 'Uto',
- 'Wednesday' => 'Srijeda', 'Wed' => 'Sri',
- 'Thursday' => 'Èetvrtak', 'Thu' => 'Èet',
- 'Friday' => 'Petak', 'Fri' => 'Pet',
- 'Saturday' => 'Subota', 'Sat' => 'Sub'
-
- );
-
-%month =
- (
- 'January' => 'Sijeèanj', 'February' => 'Veljaèa', 'March' => 'O¾ujak',
- 'Jan' => 'Sij', 'Feb' => 'Vel', 'Mar' => 'O¾u',
- 'April' => 'Travanj', 'May' => 'Svibanj', 'June' => 'Lipanj',
- 'Apr' => 'Tra', 'May' => 'Svi', 'Jun' => 'Lip',
- 'July' => 'Srpanj', 'August' => 'Kolovoz', 'September' => 'Rujan',
- 'Jul' => 'Srp', 'Aug' => 'Kol', 'Sep' => 'Ruj',
- 'October' => 'Listopad', 'November' => 'Studeni', 'December' => 'Prosinac',
- 'Oct' => 'Lis', 'Nov' => 'Stu', 'Dec' => 'Pro'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." godine"." u".$quux[1];
- };
- return "$wday{$foo[0]} dana $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# Czech
-
-sub czech
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'windows-1250',
- 'Maximal 5 Minute Incoming Traffic' => 'Maximální 5 minutový pøíchozí tok',
- 'Maximal 5 Minute Outgoing Traffic' => 'Maximální 5 minutový odchozí tok',
- 'the device' => 'zaøízení',
- 'The statistics were last updated(.*)' => 'Poslední aktualizace statistiky:$1',
- ' Average\)' => ' prùmìr)',
- 'Average' => 'Prùm.',
- 'Max' => 'Max.',
- 'Current' => 'Akt.',
- 'version' => 'verze',
- '`Daily\' Graph \((.*) Minute' => 'Denní graf ($1 minutový',
- '`Weekly\' Graph \(30 Minute' => 'Týdenní graf (30 minutový' ,
- '`Monthly\' Graph \(2 Hour' => 'Mìsíèní graf (2 hodinový',
- '`Yearly\' Graph \(1 Day' => 'Roèní graf (1 denní',
- 'Incoming Traffic in (\S+) per Second' => 'Pøíchozí tok v $1 za sec.',
- 'Outgoing Traffic in (\S+) per Second' => 'Odchozí tok v $1 za sec.',
- 'at which time (.*) had been up for(.*)' => 'od posledního restartu $1 ubìhlo: $2',
- #'([kMG]?)([bB])/s' => '\$1\$2/s',
- #'([kMG]?)([bB])/min' => '\$1\$2/min',
- #'([kMG]?)([bB])/h' => '$1$2/h',
- 'Bits' => 'bitech',
- 'Bytes' => 'bajtech',
- #'&nbsp;In:</FONT>' => '&nbsp;In:</FONT>',
- #'&nbsp;Out:</FONT>' => '&nbsp;Out:</FONT>',
- 'Percentage' => 'Proc.',
- 'Ported to OpenVMS Alpha by' => 'Na OpenVMS portoval',
- 'Ported to WindowsNT by' => 'Na WindowsNT portoval',
- 'and' => 'a',
- '^GREEN' => 'Zelená',
- 'BLUE' => 'Modrá',
- 'DARK GREEN' => 'Tmavì zelená',
- 'MAGENTA' => 'Fialová',
- 'AMBER' => 'Žlutá'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Nedìle', 'Sun' => 'Ne',
- 'Monday' => 'Pondìli', 'Mon' => 'Po',
- 'Tuesday' => 'Úterý', 'Tue' => 'Út',
- 'Wednesday' => 'Støeda', 'Wed' => 'St',
- 'Thursday' => 'Ètvrtek', 'Thu' => 'Èt',
- 'Friday' => 'Pátek', 'Fri' => 'Pá',
- 'Saturday' => 'Sobota', 'Sat' => 'So'
- );
-
-%month =
- (
- 'January' => 'Leden', 'February' => 'Únor', 'March' => 'Bøezen',
- 'Jan' => 'Leden', 'Feb' => 'Únor', 'Mar' => 'Bøezen',
- 'April' => 'Duben', 'May' => 'Kvìten', 'June' => 'Èerven',
- 'Apr' => 'Duben', 'May' => 'Kvìten', 'Jun' => 'Èerven',
- 'July' => 'Èervenec','August' => 'Srpen', 'September' => 'Záøí',
- 'Jul' => 'Èervenec','Aug' => 'Srpen', 'Sep' => 'Záøí',
- 'October' => 'Øíjen', 'November' => 'Listopad', 'December' => 'Prosinec',
- 'Oct' => 'Øíjen', 'Nov' => 'Listopad', 'Dec' => 'Prosinec'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0].",".$quux[1]." hod.";
- };
- return "$wday{$foo[0]} $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-}
-#
-# Czechutf8
-
-sub czechutf8
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'utf-8',
- 'Maximal 5 Minute Incoming Traffic' => 'Maximální 5 minutový příchozí tok',
- 'Maximal 5 Minute Outgoing Traffic' => 'Maximální 5 minutový odchozí tok',
- 'the device' => 'zařízení',
- 'The statistics were last updated(.*)' => 'Poslední aktualizace statistiky:$1',
- ' Average\)' => ' průměr)',
- 'Average' => 'Prům.',
- 'Max' => 'Max.',
- 'Current' => 'Akt.',
- 'version' => 'verze',
- '`Daily\' Graph \((.*) Minute' => 'Denní graf ($1 minutový',
- '`Weekly\' Graph \(30 Minute' => 'Týdenní graf (30 minutový' ,
- '`Monthly\' Graph \(2 Hour' => 'Měsí�ní graf (2 hodinový',
- '`Yearly\' Graph \(1 Day' => 'Ro�ní graf (1 denní',
- 'Incoming Traffic in (\S+) per Second' => 'Příchozí tok v $1 za sec.',
- 'Outgoing Traffic in (\S+) per Second' => 'Odchozí tok v $1 za sec.',
- 'at which time (.*) had been up for(.*)' => 'od posledního restartu $1 uběhlo: $2',
- #'([kMG]?)([bB])/s' => '\$1\$2/s',
- #'([kMG]?)([bB])/min' => '\$1\$2/min',
- #'([kMG]?)([bB])/h' => '$1$2/h',
- 'Bits' => 'bitech',
- 'Bytes' => 'bajtech',
- #'&nbsp;In:</FONT>' => '&nbsp;In:</FONT>',
- #'&nbsp;Out:</FONT>' => '&nbsp;Out:</FONT>',
- 'Percentage' => 'Proc.',
- 'Ported to OpenVMS Alpha by' => 'Na OpenVMS portoval',
- 'Ported to WindowsNT by' => 'Na WindowsNT portoval',
- 'and' => 'a',
- '^GREEN' => 'Zelená',
- 'BLUE' => 'Modrá',
- 'DARK GREEN' => 'Tmavě zelená',
- 'MAGENTA' => 'Fialová',
- 'AMBER' => 'Žlutá'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Neděle', 'Sun' => 'Ne',
- 'Monday' => 'Pondělí', 'Mon' => 'Po',
- 'Tuesday' => 'Úterý', 'Tue' => 'Út',
- 'Wednesday' => 'Středa', 'Wed' => 'St',
- 'Thursday' => 'ÄŒtvrtek', 'Thu' => 'ÄŒt',
- 'Friday' => 'Pátek', 'Fri' => 'Pá',
- 'Saturday' => 'Sobota', 'Sat' => 'So'
- );
-
-%month =
- (
- 'January' => 'Leden', 'February' => 'Únor', 'March' => 'Březen',
- 'Jan' => 'Leden', 'Feb' => 'Únor', 'Mar' => 'Březen',
- 'April' => 'Duben', 'May' => 'Květen', 'June' => 'Červen',
- 'Apr' => 'Duben', 'May' => 'Květen', 'Jun' => 'Červen',
- 'July' => 'Červenec','August' => 'Srpen', 'September' => 'Září',
- 'Jul' => 'Červenec','Aug' => 'Srpen', 'Sep' => 'Září',
- 'October' => 'Říjen', 'November' => 'Listopad', 'December' => 'Prosinec',
- 'Oct' => 'Říjen', 'Nov' => 'Listopad', 'Dec' => 'Prosinec'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0].",".$quux[1]." hod.";
- };
- return "$wday{$foo[0]} $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-}
-#
-# Danish
-
-sub danish
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Maksimal indg&aring;ende trafik i 5 minutter',
- 'Maximal 5 Minute Outgoing Traffic' => 'Maksimal udg&aring;ende trafik i 5 minutter',
- 'the device' => 'enheden',
- 'The statistics were last updated(.*)' => 'Statistikken blev sidst opdateret$1',
- ' Average\)' => ' Middel)',
- 'Average' => 'Middel',
- 'Max' => 'Max',
- 'Current' => 'Nu',
- 'version' => 'version',
- '`Daily\' Graph \((.*) Minute' => '`Daglig\' graf ($1 minuts',
- '`Weekly\' Graph \(30 Minute' => '`Ugentlig\' graf (30 minuts' ,
- '`Monthly\' Graph \(2 Hour' => '`M&aring;nedlig\' graf (2 times',
- '`Yearly\' Graph \(1 Day' => '`&Aring;rlig\' graf (1 dags',
- 'Incoming Traffic in (\S+) per Second' => 'Indg&aring;ende trafik i $1 per sekund',
- 'Outgoing Traffic in (\S+) per Second' => 'Udg&aring;ende trafik i $1 per sekund',
- 'at which time (.*) had been up for(.*)' => 'hvor $1 havde v&aelig;ret oppe i$2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/t',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Ind',
- 'Out' => 'Ud',
- 'Percentage' => 'Procent',
- 'Ported to OpenVMS Alpha by' => 'Port til OpenVMS af',
- 'Ported to WindowsNT by' => 'Port til WindowsNT af',
- 'and' => 'og',
- '^GREEN' => 'GR&Oslash;N',
- 'BLUE' => 'BL&Aring;',
- 'DARK GREEN' => 'M&Oslash;RKEGR&Oslash;N',
- 'MAGENTA' => 'LYSLILLA',
- 'AMBER' => 'RAV'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'S&oslash;ndag', 'Sun' => 'S&oslash;n',
- 'Monday' => 'Mandag', 'Mon' => 'Man',
- 'Tuesday' => 'Tirsdag', 'Tue' => 'Tir',
- 'Wednesday' => 'Onsdag', 'Wed' => 'Ons',
- 'Thursday' => 'Torsdag', 'Thu' => 'Tor',
- 'Friday' => 'Fredag', 'Fri' => 'Fre',
- 'Saturday' => 'L&oslash;rdag', 'Sat' => 'L&oslash;r'
-
- );
-
-%month =
- (
- 'January' => 'Januar', 'February' => 'Februar' , 'March' => 'Marts',
- 'Jan' => 'Jan', 'Feb' => 'Feb', 'Mar' => 'Mar',
- 'April' => 'April', 'May' => 'Maj', 'June' => 'Juni',
- 'Apr' => 'Apr', 'May' => 'Maj', 'Jun' => 'Jun',
- 'July' => 'Juli', 'August' => 'August', 'September' => 'September',
- 'Jul' => 'Jul', 'Aug' => 'Aug', 'Sep' => 'Sep',
- 'October' => 'Oktober', 'November' => 'November', 'December' => 'December',
- 'Oct' => 'Okt', 'Nov' => 'Nov', 'Dec' => 'Dec'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." kl.".$quux[1];
- };
- return "$wday{$foo[0]} den $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
- };
-
-# Dutch
-
-sub dutch
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Maximaal inkomend verkeer per 5 minuten',
- 'Maximal 5 Minute Outgoing Traffic' => 'Maximaal uitgaand verkeer per 5 minuten',
- 'the device' => 'het apparaat',
- 'The statistics were last updated(.*)' => 'Statistieken voor het laatst bijgewerkt op$1',
- ' Average\)' => ' gemiddeld)',
- 'Average' => 'Gemiddeld',
- 'Max' => 'Max',
- 'Current' => 'Actueel',
- 'version' => 'versie',
- '`Daily\' Graph \((.*) Minute' => '`Dagelijkse\' grafiek ($1 minuten',
- '`Weekly\' Graph \(30 Minute' => '`Wekelijkse\' grafiek (30 minuten' ,
- '`Monthly\' Graph \(2 Hour' => '`Maandelijkse\' grafiek (2 uur',
- '`Yearly\' Graph \(1 Day' => '`Jaarlijkse\' grafiek (1 dag',
- 'Incoming Traffic in (\S+) per Second' => 'Inkomend verkeer in $1 per seconde',
- 'Outgoing Traffic in (\S+) per Second' => 'Uitgaand verkeer in $1 per seconde',
- 'at which time (.*) had been up for(.*)' => 'op het moment dat $1 reeds actief was voor$2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/u',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- # '&nbsp;In:</FONT>' => '&nbsp;In:</FONT>',
- 'Out' => 'Uit',
- 'Percentage' => 'Procent',
- 'Ported to OpenVMS Alpha by' => 'Ported naar OpenVMS door',
- 'Ported to WindowsNT by' => 'Ported naar WindowsNT door',
- 'and' => 'en',
- 'DARK GREEN' => 'DONKER GROEN',
- '^GREEN' => 'GROEN',
- 'BLUE' => 'BLAUW',
- 'MAGENTA' => 'LILA',
- 'AMBER' => 'AMBER'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'zondag', 'Sun' => 'zon',
- 'Monday' => 'maandag', 'Mon' => 'maa',
- 'Tuesday' => 'dinsdag', 'Tue' => 'din',
- 'Wednesday' => 'woensdag', 'Wed' => 'woe',
- 'Thursday' => 'donderdag', 'Thu' => 'don',
- 'Friday' => 'vrijdag', 'Fri' => 'vri',
- 'Saturday' => 'zaterdag', 'Sat' => 'zat'
-
- );
-
-%month =
- (
- 'January' => 'januari', 'February' => 'februari', 'March' => 'maart',
- 'Jan' => 'jan', 'Feb' => 'feb', 'Mar' => 'mrt',
- 'April' => 'april', 'May' => 'mei', 'June' => 'juni',
- 'Apr' => 'apr', 'May' => 'mei', 'Jun' => 'jun',
- 'July' => 'juli', 'August' => 'augustus', 'September' => 'september',
- 'Jul' => 'jul', 'Aug' => 'aug', 'Sep' => 'sep',
- 'October' => 'oktober', 'November' => 'november', 'December' => 'december',
- 'Oct' => 'okt', 'Nov' => 'nov', 'Dec' => 'dec'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." om".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# Estonian
-
-sub estonian
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => '5 minuti maksimaalne sisenev liiklus',
- 'Maximal 5 Minute Outgoing Traffic' => '5 minuti maksimaalne v&auml;ljuv liiklus',
- 'the device' => 'seade',
- 'The statistics were last updated(.*)' => 'Statistikat uuendati viimati$1',
- ' Average\)' => ' keskmine)',
- 'Average' => 'Keskmine',
- #'Max' => 'Max',
- 'Current' => 'Hetkel',
- 'version' => 'versioon',
- '`Daily\' Graph \((.*) Minute' => '`P&auml;evane\' graafik ($1 minuti',
- '`Weekly\' Graph \(30 Minute' => '`N&auml;dala\' graafik (30 minuti' ,
- '`Monthly\' Graph \(2 Hour' => '`Kuu \' graafik (2 tunni',
- '`Yearly\' Graph \(1 Day' => '`Aasta\' graafik (1 p&auml;eva',
- 'Incoming Traffic in (\S+) per Second' => 'Sisenev liiklus $1 sekundi kohta',
- 'Outgoing Traffic in (\S+) per Second' => 'V&auml;ljuv liiklus $1 sekundi kohta',
- 'at which time (.*) had been up for(.*)' => 'kui $1 on katkematult t&ouml;&ouml;tanud$2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/t',
- 'Bits' => 'bitti',
- 'Bytes' => 'baiti',
- 'In' => 'sisse',
- 'Out' => 'v&auml;lja',
- 'Percentage' => 'protsent',
- 'Ported to OpenVMS Alpha by' => 'portis OpenVMS-le:',
- 'Ported to WindowsNT by' => 'portis WindowsNT-le:',
- 'and' => 'ja',
- '^GREEN' => 'ROHELINE',
- 'BLUE' => 'SININE',
- 'DARK GREEN' => 'TUMEROHELINE',
- 'MAGENTA' => 'LILLA',
- 'AMBER' => 'HELEROHELINE'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'p&uuml;hap&auml;ev', 'Sun' => 'P',
- 'Monday' => 'esmasp&auml;ev', 'Mon' => 'E',
- 'Tuesday' => 'teisip&auml;ev', 'Tue' => 'T',
- 'Wednesday' => 'kolmap&auml;ev', 'Wed' => 'K',
- 'Thursday' => 'neljap&auml;ev', 'Thu' => 'N',
- 'Friday' => 'reede', 'Fri' => 'R',
- 'Saturday' => 'laup&auml;ev', 'Sat' => 'L'
-
- );
-
-%month =
- (
- 'January' => 'jaanuar', 'February' => 'veebruar' , 'March' => 'm&auml;rts',
- 'Jan' => 'jaan', 'Feb' => 'veebr', 'Mar' => 'm&auml;rts',
- 'April' => 'aprill', 'May' => 'mai', 'June' => 'juuni',
- 'Apr' => 'aprill', 'May' => 'mai', 'Jun' => 'juuni',
- 'July' => 'juuli', 'August' => 'august', 'September' => 'september',
- 'Jul' => 'juuli', 'Aug' => 'aug', 'Sep' => 'sept',
- 'October' => 'oktoober', 'November' => 'november', 'December' => 'detsember',
- 'Oct' => 'okt', 'Nov' => 'nov', 'Dec' => 'dets'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." kl.".$quux[1];
- };
- return "$wday{$foo[0]}, $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
- };
-
-# eucjp
-
-sub eucjp
-{
- my $string = shift;
- return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- '^iso-8859-1' => 'euc-jp',
- '^Maximal 5 Minute Incoming Traffic' => 'ºÇÂç5ʬ¼õ¿®ÎÌ',
- '^Maximal 5 Minute Outgoing Traffic' => 'ºÇÂç5ʬÁ÷¿®ÎÌ',
- '^the device' => '¥Ç¥Ð¥¤¥¹',
- '^The statistics were last updated (.*)' => '¹¹¿·Æü»þ $1',
- '^Average\)' => 'Ê¿¶Ñ)',
- '^Average$' => 'Ê¿¶Ñ',
- '^Max$' => 'ºÇÂç',
- '^Current' => 'ºÇ¿·',
- '^`Daily\' Graph \((.*) Minute' => 'Æü¥°¥é¥Õ($1ʬ´Ö',
- '^`Weekly\' Graph \(30 Minute' => '½µ¥°¥é¥Õ(30ʬ´Ö',
- '^`Monthly\' Graph \(2 Hour' => '·î¥°¥é¥Õ(2»þ´Ö',
- '^`Yearly\' Graph \(1 Day' => 'ǯ¥°¥é¥Õ(1Æü',
- '^Incoming Traffic in (\S+) per Second' => 'ËèÉäμõ¿®$1¿ô',
- '^Incoming Traffic in (\S+) per Minute' => 'Ëèʬ¤Î¼õ¿®$1¿ô',
- '^Incoming Traffic in (\S+) per Hour' => 'Ëè»þ¤Î¼õ¿®$1¿ô',
- '^Outgoing Traffic in (\S+) per Second' => 'ËèÉäÎÁ÷¿®$1¿ô',
- '^Outgoing Traffic in (\S+) per Minute' => 'Ëèʬ¤ÎÁ÷¿®$1¿ô',
- '^Outgoing Traffic in (\S+) per Hour' => 'Ëè»þ¤ÎÁ÷¿®$1¿ô',
- '^at which time (.*) had been up for (.*)' => '$1¤Î²ÔƯ»þ´Ö $2',
- '^Average max 5 min values for `Daily\' Graph \((.*) Minute interval\):' => 'Æü¥°¥é¥Õ¤Ç¤ÎºÇÂç5ʬÃͤÎÊ¿¶Ñ($1ʬ´Ö³Ö):',
- '^Average max 5 min values for `Weekly\' Graph \(30 Minute interval\):' => '½µ¥°¥é¥Õ¤Ç¤ÎºÇÂç5ʬÃͤÎÊ¿¶Ñ(30ʬ´Ö³Ö):',
- '^Average max 5 min values for `Monthly\' Graph \(2 Hour interval\):' => '·î¥°¥é¥Õ¤Ç¤ÎºÇÂç5ʬÃͤÎÊ¿¶Ñ(2»þ´Ö´Ö³Ö):',
- '^Average max 5 min values for `Yearly\' Graph \(1 Day interval\):' => 'ǯ¥°¥é¥Õ¤Ç¤ÎºÇÂç5ʬÃͤÎÊ¿¶Ñ(1Æü´Ö³Ö):',
- #'^([kMG]?)([bB])/s' => '$1$2/ÉÃ',
- #'^([kMG]?)([bB])/min' => '$1$2/ʬ',
- #'^([kMG]?)([bB])/h' => '$1$2/»þ',
- '^Bits$' => '¥Ó¥Ã¥È',
- '^Bytes$' => '¥Ð¥¤¥È',
- '^In$' => '¼õ¿®',
- '^Out$' => 'Á÷¿®',
- '^Percentage' => 'ÈæÎ¨',
- '^Ported to OpenVMS Alpha by' => 'OpenVMS Alpha¤Ø¤Î°Ü¿¢',
- '^Ported to WindowsNT by' => 'WindowsNT¤Ø¤Î°Ü¿¢',
- #'^and' => 'and',
- '^GREEN' => 'ÎÐ',
- '^BLUE' => 'ÀÄ',
- '^DARK GREEN' => '¿¼ÎÐ',
- '^MAGENTA' => '¥Þ¥¼¥ó¥¿',
- '^AMBER' => 'àèàá'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => '(Æü)',
- 'Monday' => '(·î)',
- 'Tuesday' => '(²Ð)',
- 'Wednesday' => '(¿å)',
- 'Thursday' => '(ÌÚ)',
- 'Friday' => '(¶â)',
- 'Saturday' => '(ÅÚ)',
- );
-
-%month =
- (
- 'January' => '1·î', 'February' => '2·î',
- 'March' => '3·î', 'April' => '4·î',
- 'May' => '5·î', 'June' => '6·î',
- 'July' => '7·î', 'August' => '8·î',
- 'September' => '9·î', 'October' => '10·î',
- 'November' => '11·î', 'December' => '12·î',
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)\s+(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~/at/)
- {
- @quux=split(/\s+at\s+/,$foo[3]);
- }
- else
- {
- @quux=split(/ /,$foo[3],2);
- };
- return "$quux[0]ǯ$month{$foo[2]}$foo[1]Æü$wday{$foo[0]} $quux[1]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# Finnish
-
-sub finnish
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Tulevan liikenteen maksimi 5 minuutin aikana',
- 'Maximal 5 Minute Outgoing Traffic' => 'L&auml;htev&auml;n liikenteen maksimi 5 minuutin aikana',
- 'the device' => 'laite',
- 'The statistics were last updated(.*)' => 'Tiedot p&auml;ivitetty viimeksi $1',
- ' Average\)' => '',
- 'Average' => 'Keskim&auml;&auml;rin',
- 'Max' => 'Maksimi',
- 'Current' => 'T&auml;ll&auml; hetkell&auml;',
- 'version' => 'versio',
- '`Daily\' Graph \((.*) Minute' => 'P&auml;iv&auml;raportti (skaala $1 minuutti(a))',
- '`Weekly\' Graph \(30 Minute' => 'Viikkoraportti (skaala 30 minuuttia)' ,
- '`Monthly\' Graph \(2 Hour' => 'Kuukausiraportti (skaala 2 tuntia)',
- '`Yearly\' Graph \(1 Day' => 'Vuosiraportti (skaala 1 vuorokausi)',
- 'Incoming Traffic in (\S+) per Second' => 'Tuleva liikenne $1 sekunnissa',
- 'Outgoing Traffic in (\S+) per Second' => 'L&auml;htev&auml; liikenne $1 sekunnissa',
- 'Incoming Traffic in (\S+) per Minute' => 'Tuleva liikenne $1 minuutissa',
- 'Outgoing Traffic in (\S+) per Minute' => 'L&auml;htev&auml; liikenne $1 minuutissa',
- 'Incoming Traffic in (\S+) per Hour' => 'Tuleva liikenne $1 tunnissa',
- 'Outgoing Traffic in (\S+) per Hour' => 'L&auml;htev&auml; liikenne $1 tunnissa',
- 'at which time (.*) had been up for(.*)' => 'jolloin $1 on toiminut yht&auml;jaksoisesti $2',
- '(\S+) per minute' => '$1 minuutissa',
- '(\S+) per hour' => '$1 tunnissa',
- '(.+)/s$' => '$1/s',
- # '(.+)/min' => '$1/min',
- #'(.+)/h$' => '$1/h',
- #'([kMG]?)([bB])/s' => '$1$2/s',
- #'([kMG]?)([bB])/min' => '$1$2/min',
- #'([kMG]?)([bB])/h' => '$1$2/h',
- 'Bits' => 'bitti&auml;',
- 'Bytes' => 'tavua',
- 'In' => 'Tuleva',
- 'Out' => 'L&auml;htev&auml;',
- 'Percentage' => 'Prosenttia',
- 'Ported to OpenVMS Alpha by' => 'OpenVMS -j&auml;rjestelm&auml;lle sovittanut',
- 'Ported to WindowsNT by' => 'WindowsNT -j&auml;rjestelm&auml;lle sovittanut',
- 'and' => 'ja',
- '^GREEN' => 'VIHRE&Auml;',
- 'BLUE' => 'SININEN',
- 'DARK GREEN' => 'TUMMANVIHRE&Auml;',
- 'MAGENTA' => 'PINKKI',
- 'AMBER' => 'PUNAINEN',
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Sunnuntai', 'Sun' => 'Su',
- 'Monday' => 'Maanantai', 'Mon' => 'Ma',
- 'Tuesday' => 'Tiistai', 'Tue' => 'Ti',
- 'Wednesday' => 'Keskiviikko', 'Wed' => 'Ke',
- 'Thursday' => 'Torstai', 'Thu' => 'To',
- 'Friday' => 'Perjantai', 'Fri' => 'Pe',
- 'Saturday' => 'Lauantai', 'Sat' => 'La'
- );
-
-%month =
- (
- 'January' => 'Tammi', 'February' => 'Helmi' , 'March' => 'Maalis',
- 'Jan' => 'Tam', 'Feb' => 'Hel', 'Mar' => 'Maa',
- 'April' => 'Huhti', 'May' => 'Touko', 'June' => 'Kes&auml;',
- 'Apr' => 'Huh', 'May' => 'Tou', 'Jun' => 'Kes',
- 'July' => 'Hein&auml;', 'August' => 'Elo', 'September' => 'Syys',
- 'Jul' => 'Hei', 'Aug' => 'Elo', 'Sep' => 'Syy',
- 'October' => 'Loka', 'November' => 'Marras', 'December' => 'Joulu',
- 'Oct' => 'Lok', 'Nov' => 'Mar', 'Dec' => 'Kou'
- );
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if( $wday{$foo[0]} && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." kello ".$quux[1];
- };
- return "$wday{$foo[0]}, $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-
-
-
-# French
-
-sub french
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Trafic maximal en entr&eacute;e sur 5 minutes',
- 'Maximal 5 Minute Outgoing Traffic' => 'Trafic maximal en sortie sur 5 minutes',
- 'the device' => 'le mat&eacute;riel',
- 'The statistics were last updated(.*)' => 'Les statistiques ont &eacute;t&eacute; mises &agrave; jour le $1',
- ' Average\)' => ' Moyenne)',
- 'Average' => 'Moyenne',
- '>Max' => 'Max',
- 'Current' => 'Actuel',
- #'version' => 'version',
- '`Daily\' Graph \((.*) Minute' => 'Graphique quotidien (sur $1 minutes :',
- '`Weekly\' Graph \(30 Minute' => 'Graphique hebdomadaire (sur 30 minutes :' ,
- '`Monthly\' Graph \(2 Hour' => 'Graphique mensuel (sur 2 heures :',
- '`Yearly\' Graph \(1 Day' => 'Graphique annuel (sur 1 jour :',
- 'Incoming Traffic in (\S+) per Second' => 'Trafic d\'entr&eacute;e en $1 par seconde',
- 'Outgoing Traffic in (\S+) per Second' => 'Trafic de sortie en $1 par seconde',
- 'at which time (.*) had been up for(.*)' => '$1 &eacute;tait alors en marche depuis $2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/t',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Entr&eacute;e',
- 'Out' => 'Sortie',
- 'Percentage' => 'Pourcentage',
- 'Ported to OpenVMS Alpha by' => 'Port&eacute; sur OpenVMS Alpha par',
- 'Ported to WindowsNT by' => 'Port&eacute; sur WindowsNT par',
- 'and' => 'et',
- '^GREEN' => 'VERT',
- 'BLUE' => 'BLEU',
- 'DARK GREEN' => 'VERT SOMBRE',
- 'MAGENTA' => 'MAGENTA',
- 'AMBER' => 'AMBRE'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Dimanche', 'Sun' => 'Dim',
- 'Monday' => 'Lundi', 'Mon' => 'Lun',
- 'Tuesday' => 'Mardi', 'Tue' => 'Mar',
- 'Wednesday' => 'Mercredi', 'Wed' => 'Mer',
- 'Thursday' => 'Jeudi', 'Thu' => 'Jeu',
- 'Friday' => 'Vendredi', 'Fri' => 'Ven',
- 'Saturday' => 'Samedi', 'Sat' => 'Sam'
- );
-
-%month =
- (
- 'January' => 'Janvier', 'February' => 'F&eacute;vrier' , 'March' => 'Mars',
- 'Jan' => 'Jan', 'Feb' => 'Fev', 'Mar' => 'Mar',
- 'April' => 'Avril', 'May' => 'Mai', 'June' => 'Juin',
- 'Apr' => 'Avr', 'May' => 'Mai', 'Jun' => 'Jun',
- 'July' => 'Juillet', 'August' => 'Ao&ucirc;t', 'September' => 'Septembre',
- 'Jul' => 'Jul', 'Aug' => 'Aou', 'Sep' => 'Sep',
- 'October' => 'Octobre', 'November' => 'Novembre', 'December' => 'D&eacute;cembre',
- 'Oct' => 'Oct', 'Nov' => 'Nov', 'Dec' => 'Dec'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." &agrave; ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." &agrave; $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-
-
-# Galician
-
-sub galician
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Tr&&aacute;fico entrante m&aacute;ximo en 5 minutos',
- 'Maximal 5 Minute Outgoing Traffic' => 'Tr&&aacute;fico sa&iacute;nte m&aacute;ximo en 5 minutos',
- 'the device' => 'o dispositivo',
- 'The statistics were last updated(.*)' => 'Estas estat&iacute;sticas actualiz&aacute;ronse o $1',
- ' Average\)' => ' de Media)',
- 'Average' => 'Media',
- 'Max' => 'M&aacute;x',
- 'Current' => 'Actual',
- 'version' => 'versi&oacute;n',
- '`Daily\' Graph \((.*) Minute' => 'Gr&aacute;fica diaria ($1 minutos',
- '`Weekly\' Graph \(30 Minute' => 'Gr&aacute;fica semanal (30 minutos' ,
- '`Monthly\' Graph \(2 Hour' => 'Gr&aacute;fica mensual (2 horas',
- '`Yearly\' Graph \(1 Day' => 'Gr&aacute;fica anual (1 d&iacute;a',
- 'Incoming Traffic in (\S+) per Second' => 'Tr&aacute;fico entrante en $1 por segundo',
- 'Outgoing Traffic in (\S+) per Second' => 'Tr&aacute;fico sa&iacute;nte en $1 por segundo',
- 'at which time (.*) had been up for(.*)' => 'nese intre $1 levaba prendida $2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/h',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Entrante',
- 'Out' => 'Sa&iacute;nte',
- 'Percentage' => 'Tanto por ciento',
- 'Ported to OpenVMS Alpha by' => 'Portado a OpenVMS Alpha por',
- 'Ported to WindowsNT by' => 'Portado a Windows NT por',
- 'and' => 'e',
- '^GREEN' => 'VERDE',
- 'BLUE' => 'AZUL',
- 'DARK GREEN' => 'VERDE OSCURO',
- 'MAGENTA' => 'ROSA',
- 'AMBER' => 'AMBAR'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Domingo', 'Sun' => 'Dom',
- 'Monday' => 'Luns', 'Mon' => 'Lun',
- 'Tuesday' => 'Martes', 'Tue' => 'Mar',
- 'Wednesday' => 'M&eacute;rcores', 'Wed' => 'm&eacute;r',
- 'Thursday' => 'Xoves', 'Thu' => 'Xov',
- 'Friday' => 'Venres', 'Fri' => 'Ven',
- 'Saturday' => 'S&aacute;bado', 'Sat' => 'S&aacute;b'
-
- );
-
-%month =
- (
- 'January' => 'Xaneiro', 'February' => 'Febreiro' , 'March' => 'Marzo',
- 'Jan' => 'Xan', 'Feb' => 'Feb', 'Mar' => 'Mar',
- 'April' => 'Abril', 'May' => 'Maio', 'June' => 'Xu&ntilde;o',
- 'Apr' => 'Abr', 'May' => 'Mai', 'Jun' => 'Xu&ntilde;',
- 'July' => 'Xullo', 'August' => 'Agosto', 'September' => 'Setembro',
- 'Jul' => 'Xul', 'Aug' => 'Ago', 'Sep' => 'Set',
- 'October' => 'Outubro', 'November' => 'Novembro', 'December' => 'Decembro',
- 'Oct' => 'Out', 'Nov' => 'Nov', 'Dec' => 'Dec'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." &aacute;s ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] de $month{$foo[2]} de $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
- };
-# Chinese gb Code
-
-sub gb
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'gb',
- 'Maximal 5 Minute Incoming Traffic' => '5·ÖÖÓ×î´óµÄÁ÷Á¿',
- 'Maximal 5 Minute Outgoing Traffic' => '5·ÖÖÓ×î´óµÄÁ÷³öÁ÷Á¿',
- 'the device' => 'µ±Ç°É豸',
- 'The statistics were last updated(.*)' => 'ͳ¼ÆÐÅÏ¢¸üÐÂÓÚ: $1',
- ' Average\)' => 'ƽ¾ù)',
- 'Average' => 'ƽ¾ù',
- 'Max' => '×î´ó',
- 'Current' => 'µ±Ç°',
- 'version' => '°æ±¾',
- '`Daily\' Graph \((.*) Minute' => 'ÈÕ·ÖÎöͼ($1·ÖÖÓ',
- '`Weekly\' Graph \(30 Minute' => 'ÖÜ·ÖÎöͼ(30·ÖÖÓ' ,
- '`Monthly\' Graph \(2 Hour' => 'Ô·ÖÎöͼ(2Сʱ',
- '`Yearly\' Graph \(1 Day' => 'Äê·ÖÎöͼ(1Ìì',
- 'Incoming Traffic in (\S+) per Second' => 'ÿÃëµÄÁ÷ÈëÁ÷Á¿(µ¥Î»$1)',
- 'Outgoing Traffic in (\S+) per Second' => 'ÿÃëµÄÁ÷³öÁ÷Á¿(µ¥Î»$1)',
- 'at which time (.*) had been up for(.*)' => 'Æäʱ $1ÒѾ­¸üÐÂ(UPTIME): $2',
- '([kMG]?)([bB])/s' => '$1$2/s',
- '([kMG]?)([bB])/min' => '$1$2/m',
- '([kMG]?)([bB])/h' => '$1$2/h',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Á÷Èë',
- 'Out' => 'Á÷³ö',
- 'Percentage' => '°Ù·Ö±È',
- 'Ported to OpenVMS Alpha by' => 'OpenVMSµÄ¶Ë¿Ú',
- 'Ported to WindowsNT by' => 'WindowsNTµÄ¶Ë¿Ú',
- 'and' => 'Óë',
- '^GREEN' => 'ÂÌÉ«',
- 'BLUE' => 'À¼É«',
- 'DARK GREEN' => '°µÂÌ',
- 'MAGENTA' => 'ºÖÉ«',
- 'AMBER' => '×ÏÉ«'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'ÖÜÈÕ', 'Sun' => 'ÖÜÈÕ',
- 'Monday' => 'ÖÜÒ»', 'Mon' => 'ÖÜÒ»¤@',
- 'Tuesday' => 'Öܶþ', 'Tue' => 'Öܶþ¤G',
- 'Wednesday' => 'ÖÜÈý', 'Wed' => 'ÖÜÈý¤T',
- 'Thursday' => 'ÖÜËÄ', 'Thu' => 'ÖÜËÄ¥|',
- 'Friday' => 'ÖÜÎå', 'Fri' => 'ÖÜÎå',
- 'Saturday' => 'ÖÜÁù', 'Sat' => 'ÖÜÁù'
-
- );
-
-%month =
- (
- 'January' => '1ÔÂ', 'February' => '2ÔÂ', 'March' => '3ÔÂ',
- 'Jan' => '1ÔÂ', 'Feb' => '2ÔÂ', 'Mar' => '3ÔÂ',
- 'April' => '4ÔÂ', 'May' => '5ÔÂ', 'June' => '6ÔÂ',
- 'Apr' => '4ÔÂ', 'May' => '5ÔÂ', 'Jun' => '6ÔÂ',
- 'July' => '7ÔÂ', 'August' => '8ÔÂ', 'September' => '9ÔÂ',
- 'Jul' => '7ÔÂ', 'Aug' => '8ÔÂ', 'Sep' => '9ÔÂ',
- 'October' => '10ÔÂ', 'November' => '11ÔÂ', 'December' => '12ÔÂ',
- 'Oct' => '10ÔÂ', 'Nov' => '11ÔÂ', 'Dec' => '12ÔÂ'
-
- );
-
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- @quux=split(/at/,$foo[3]);
- if($foo[3]=~(/(.*)at(.*)/))
- {
- $foo[3]=$quux[0];
- $foo[4]=$quux[1];
- };
- return "$foo[3]Äê $month{$foo[2]} $foo[1]ÈÕ, $wday{$foo[0]}, $foo[4]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# Chinese gb2312 Code
-
-sub gb2312
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'gb2312',
- 'Maximal 5 Minute Incoming Traffic' => '5·ÖÖÓ×î´óÁ÷ÈëÁ¿',
- 'Maximal 5 Minute Outgoing Traffic' => '5·ÖÖÓ×î´óÁ÷³öÁ¿',
- 'the device' => '×°ÖÃ',
- 'The statistics were last updated(.*)' => 'ÉÏ´Îͳ¼Æ¸üÐÂʱ¼ä: $1',
- ' Average\)' => ' ƽ¾ù)',
- 'Average' => 'ƽ¾ù',
- 'Max' => '×î´ó',
- 'Current' => 'Ŀǰ',
- 'version' => '°æ±¾',
- '`Daily\' Graph \((.*) Minute' => 'ÿÈÕ Í¼±í ($1 ·ÖÖÓ',
- '`Weekly\' Graph \(30 Minute' => 'ÿÖÜ Í¼±í (30 ·ÖÖÓ' ,
- '`Monthly\' Graph \(2 Hour' => 'ÿÔ ͼ±í (2 Сʱ',
- '`Yearly\' Graph \(1 Day' => 'ÿÄê ͼ±í (1 Ìì',
- 'Incoming Traffic in (\S+) per Second' => 'ÿÃëÁ÷ÈëÁ¿ (µ¥Î» $1)',
- 'Outgoing Traffic in (\S+) per Second' => 'ÿÃëÁ÷³öÁ¿ (µ¥Î» $1)',
- 'at which time (.*) had been up for(.*)' => 'É豸Ãû³Æ $1£¬ÒÑÔË×÷ʱ¼ä(UPTIME): $2',
- '([kMG]?)([bB])/s' => '\$1\$2/Ãë',
- '([kMG]?)([bB])/min' => '\$1\$2/·Ö',
- '([kMG]?)([bB])/h' => '$1$2/ʱ',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Á÷Èë',
- 'Out' => 'Á÷³ö',
- 'Percentage' => '°Ù·Ö±È',
- 'Ported to OpenVMS Alpha by' => 'ÒÆÖ²µ½ OpenVM Alpha ×÷Õß',
- 'Ported to WindowsNT by' => 'ÒÆÖ²µ½ WindowsNT ×÷Õß',
- 'and' => '¼°',
- '^GREEN' => 'ÂÌÉ«',
- 'BLUE' => 'À¶É«',
- 'DARK GREEN' => 'Ä«ÂÌÉ«',
- 'MAGENTA' => '×ÏÉ«',
- 'AMBER' => 'çúçêÉ«'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'ÐÇÆÚÌì', 'Sun' => 'ÈÕ',
- 'Monday' => 'ÐÇÆÚÒ»', 'Mon' => 'Ò»',
- 'Tuesday' => 'ÐÇÆÚ¶þ', 'Tue' => '¶þ',
- 'Wednesday' => 'ÐÇÆÚÈý', 'Wed' => 'Èý',
- 'Thursday' => 'ÐÇÆÚËÄ', 'Thu' => 'ËÄ',
- 'Friday' => 'ÐÇÆÚÎå', 'Fri' => 'Îå',
- 'Saturday' => 'ÐÇÆÚÁù', 'Sat' => 'Áù'
-
- );
-
-%month =
- (
- 'January' => 'Ò»ÔÂ', 'February' => '¶þÔÂ', 'March' => 'ÈýÔÂ',
- 'Jan' => 'Ò»', 'Feb' => '¶þ', 'Mar' => 'Èý',
- 'April' => 'ËÄÔÂ', 'May' => 'ÎåÔÂ', 'June' => 'ÁùÔÂ',
- 'Apr' => 'ËÄ', 'May' => 'Îå', 'Jun' => 'Áù',
- 'July' => 'ÆßÔÂ', 'August' => '°ËÔÂ', 'September' => '¾ÅÔÂ',
- 'Jul' => 'Æß', 'Aug' => '°Ë', 'Sep' => '¾Å',
- 'October' => 'Ê®ÔÂ', 'November' => 'ʮһÔÂ', 'December' => 'Ê®¶þÔÂ',
- 'Oct' => 'Ê®', 'Nov' => 'ʮһ', 'Dec' => 'Ê®¶þ'
-
- );
-
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- @quux=split(/at/,$foo[3]);
- if($foo[3]=~(/(.*)at(.*)/))
- {
- $foo[3]=$quux[0];
- $foo[4]=$quux[1];
- };
- return "$foo[3] $month{$foo[2]} $foo[1] ÈÕ, $wday{$foo[0]}, $foo[4]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# German
-
-sub german
-{
- my $string = shift;
- return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Maximaler hereinkommender Traffic in 5 Minuten',
- 'Maximal 5 Minute Outgoing Traffic' => 'Maximaler hinausgehender Traffic in 5 Minuten',
- 'the device' => 'das Gerät',
- 'The statistics were last updated(.*)' => 'Die Statistiken wurden am $1 zuletzt aktualisiert',
- ' Average\)' => '',
- 'Average' => 'Mittel',
- 'Max' => 'Maximal',
- 'Current' => 'Aktuell',
- 'version' => 'Version',
- '`Daily\' Graph \((.*) Minute' => 'Tages&uuml;bersicht (Skalierung $1 Minute(n)',
- '`Weekly\' Graph \(30 Minute' => 'Wochen&uuml;bersicht (Skalierung 30 Minuten',
- '`Monthly\' Graph \(2 Hour' => 'Monats&uuml;bersicht (Skalierung 2 Stunden',
- '`Yearly\' Graph \(1 Day' => 'Jahres&uuml;bersicht (Skalierung 1 Tag',
- 'Incoming Traffic in (\S+) per Second' => 'Hereinkommender Traffic in $1 pro Sekunde',
- 'Outgoing Traffic in (\S+) per Second' => 'Hinausgehender Traffic in $1 pro Sekunde',
- 'Incoming Traffic in (\S+) per Minute' => 'Hereinkommender Traffic in $1 pro Minute',
- 'Outgoing Traffic in (\S+) per Minute' => 'Hinausgehender Traffic in $1 pro Minute',
- 'Incoming Traffic in (\S+) per Hour' => 'Hereinkommender Traffic in $1 pro Stunde',
- 'Outgoing Traffic in (\S+) per Hour' => 'Hinausgehender Traffic in $1 pro Stunde',
- 'at which time (.*) had been up for(.*)' => 'zu diesem Zeitpunkt lief $1 seit $2',
- '(\S+) per minute' => '$1 pro Minute',
- '(\S+) per hour' => '$1 pro Stunde',
- '(.+)/s$' => '$1/s',
- # '(.+)/min' => '$1/min',
- '(.+)/h$' => '$1/std',
- #'([kMG]?)([bB])/s' => '$1$2/s',
- #'([kMG]?)([bB])/min' => '$1$2/min',
- #'([kMG]?)([bB])/h' => '$1$2/std',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Herein',
- 'Out' => 'Hinaus',
- 'Percentage' => 'Prozent',
- 'Ported to OpenVMS Alpha by' => 'Portierung nach OpenVMS von',
- 'Ported to WindowsNT by' => 'Portierung nach WindowsNT von',
- 'and' => 'und',
- '^GREEN' => 'GR&Uuml;N',
- 'BLUE' => 'BLAU',
- 'DARK GREEN' => 'DUNKELGR&Uuml;N',
- # 'MAGENTA' => 'ROSA',
- # 'AMBER' => 'AMBER',
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Sonntag', 'Sun' => 'So',
- 'Monday' => 'Montag', 'Mon' => 'Mo',
- 'Tuesday' => 'Dienstag', 'Tue' => 'Di',
- 'Wednesday' => 'Mittwoch', 'Wed' => 'Mi',
- 'Thursday' => 'Donnerstag', 'Thu' => 'Do',
- 'Friday' => 'Freitag', 'Fri' => 'Fr',
- 'Saturday' => 'Samstag', 'Sat' => 'Sa'
- );
-
-%month =
- (
- 'January' => 'Januar', 'February' => 'Februar' , 'March' => 'M&auml;rz',
- 'Jan' => 'Jan', 'Feb' => 'Feb', 'Mar' => 'M&auml;r',
- 'April' => 'April', 'May' => 'Mai', 'June' => 'Juni',
- 'Apr' => 'Apr', 'May' => 'Mai', 'Jun' => 'Jun',
- 'July' => 'Juli', 'August' => 'August', 'September' => 'September',
- 'Jul' => 'Jul', 'Aug' => 'Aug', 'Sep' => 'Sep',
- 'October' => 'Oktober', 'November' => 'November', 'December' => 'Dezember',
- 'Oct' => 'Okt', 'Nov' => 'Nov', 'Dec' => 'Dez'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." um ".$quux[1];
- };
- return "$wday{$foo[0]}, den $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-
-
-
-# Greek
-
-sub greek
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'iso-8859-7',
- 'Maximal 5 Minute Incoming Traffic' => 'ÌÝãéóôï Åéóåñ÷üìåíï Öïñôßï óôá 5 ËåðôÜ',
- 'Maximal 5 Minute Outgoing Traffic' => 'ÌÝãéóôï Åîåñ÷üìåíï Öïñôßï óôá 5 ËåðôÜ',
- 'the device' => 'ç óõóêåõÞ',
- 'The statistics were last updated(.*)' => 'Ôá óôáôéóôéêÜ åíçìåñþèçêáí ôåëåõôáßá öïñÜ ôç(í)/ôï $1',
- ' Average\)' => ' ÌÝóïò ¼ñïò)',
- 'Average' => 'ÌÝóïò ¼ñïò',
- 'Max' => 'ÌÝãéóôï',
- 'Current' => 'ÔñÝ÷ïí',
- 'version' => 'Ýêäïóç',
- '`Daily\' Graph \((.*) Minute' => 'ÇìåñÞóéï ÃñÜöçìá (êÜèå $1 ëåðôÜ :',
- '`Weekly\' Graph \(30 Minute' => 'Åâäïìáäéáßï ÃñÜöçìá (êÜèå 30 ëåðôÜ :' ,
- '`Monthly\' Graph \(2 Hour' => 'Ìçíéáßï ÃñÜöçìá (êÜèå 2 þñåò :',
- '`Yearly\' Graph \(1 Day' => 'ÅôÞóéï ÃñÜöçìá (êÜèå 1 ìÝñá :',
- 'Incoming Traffic in (\S+) per Second' => 'Åéóåñ÷üìåíï Öïñôßï óå $1 áíÜ äåõôåñüëåðôï',
- 'Outgoing Traffic in (\S+) per Second' => 'Åîåñ÷üìåíï Öïñôßï óå $1 áíÜ äåõôåñüëåðôï',
- 'at which time (.*) had been up for(.*)' => 'óôïí ïðïßï ÷ñüíï $1 Þôáí åíåñãÞ ãéá $2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/t',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Åéóåñ÷üìåíá',
- 'Out' => 'Åîåñ÷üìåíá',
- 'Percentage' => 'Ðïóïóôü',
- 'Ported to OpenVMS Alpha by' => 'ÌåôáöåñìÝíï óå OpenVMS Alpha áðü',
- 'Ported to WindowsNT by' => 'ÌåôáöåñìÝíï óå WindowsNT áðü',
- 'and' => 'êáé',
- '^GREEN' => 'ÐÑÁÓÉÍÏ',
- 'BLUE' => 'ÌÐËÅ',
- 'DARK GREEN' => 'ÓÊÏÕÑÏ ÐÑÁÓÉÍÏ',
- 'MAGENTA' => 'ÌÙÂ',
- 'AMBER' => 'ÐÏÑÔÏÊÁËÉ'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'ÊõñéáêÞ', 'Sun' => 'Êõñ',
- 'Monday' => 'ÄåõôÝñá', 'Mon' => 'Äåõ',
- 'Tuesday' => 'Ôñßôç', 'Tue' => 'Ôñé',
- 'Wednesday' => 'ÔåôÜñôç', 'Wed' => 'Ôåô',
- 'Thursday' => 'ÐÝìðôç', 'Thu' => 'Ðåì',
- 'Friday' => 'ÐáñáóêåõÞ', 'Fri' => 'Ðáñ',
- 'Saturday' => 'ÓÜââáôï', 'Sat' => 'Óáâ'
- );
-
-%month =
- (
- 'January' => 'Éáíïõñßïõ', 'February' => 'Öåâñïõáñßïõ' , 'March' => 'Ìáñôßïõ',
- 'Jan' => 'Éáí', 'Feb' => 'Öåâ', 'Mar' => 'Ìáñ',
- 'April' => 'Áðñéëßïõ', 'May' => 'ÌáÀïõ', 'June' => 'Éïõíßïõ',
- 'Apr' => 'Áðñ', 'May' => 'Ìáé', 'Jun' => 'Éïõ',
- 'July' => 'Éïõëßïõ', 'August' => 'Áõãïýóôïõ', 'September' => 'Óåðôåìâñßïõ',
- 'Jul' => 'Éïõ', 'Aug' => 'Áõã', 'Sep' => 'Óåð',
- 'October' => 'Ïêôùâñßïõ', 'November' => 'Íïåìâñßïõ', 'December' => 'Äåêåìâñßïõ',
- 'Oct' => 'Ïêô', 'Nov' => 'Íïå', 'Dec' => 'Äåê'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." óôéò ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." &agrave; $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# Hungarian
-
-
-sub hungarian
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-2',
- 'Maximal 5 Minute Incoming Traffic' => 'Maxim&aacute;lis bej&ouml;v&otilde; forgalom 5 perc alatt',
- 'Maximal 5 Minute Outgoing Traffic' => 'Maxim&aacute;lis kimen&otilde; forgalom 5 perc alatt',
- 'the device' => 'az eszk&ouml;z',
- 'The statistics were last updated(.*)' => 'A statisztika utols&oacute; friss&iacute;t&eacute;se:$1',
- ' Average\)' => ' &aacute;tlag)',
- 'Average' => '&Aacute;tlagos',
- 'Max' => 'Maximum',
- 'Current' => 'Pillanatnyi',
- 'version' => 'verzi&oacute;',
- '`Daily\' Graph \((.*) Minute' => '`Napi\' grafikon ($1 perces',
- '`Weekly\' Graph \(30 Minute' => '`Heti\' grafikon (30 perces' ,
- '`Monthly\' Graph \(2 Hour' => '`Havi\' grafikon (2 &oacute;r&aacute;s',
- '`Yearly\' Graph \(1 Day' => '`&Eacute;ves\' grafikon (1 napos',
- 'Incoming Traffic in (\S+) per Second' => 'Bej&ouml;v&otilde; forgalom $1 per m&aacute;sodpercben',
- 'Outgoing Traffic in (\S+) per Second' => 'Kimen&otilde; forgalom $1 per m&aacute;sodpercben',
- 'at which time (.*) had been up for(.*)' => 'amikor a $1 &uuml;zemideje $2 volt.',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/t',
- 'Bits' => 'Bit',
- 'Bytes' => 'Byte',
- 'In' => 'be',
- 'Out' => 'ki',
- 'Percentage' => 'sz&aacute;zale&acute;k',
- 'Ported to OpenVMS Alpha by' => 'OpenVMS-re portolta',
- 'Ported to WindowsNT by' => 'WindowsNT-re portolta',
- 'and' => '&eacute;s',
- '^GREEN' => 'Z&Ouml;LD',
- 'BLUE' => 'K&Eacute;K',
- 'DARK GREEN' => 'S&Ouml;T&Eacute;T Z&Ouml;LD',
- 'MAGENTA' => 'B&Iacute;BOR',
- 'AMBER' => 'S&Aacute;RGA'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'vas&aacute;rnap', 'Sun' => 'vas',
- 'Monday' => 'h&eacute;tf&otilde;', 'Mon' => 'h&eacute;t',
- 'Tuesday' => 'kedd', 'Tue' => 'kedd',
- 'Wednesday' => 'szerda', 'Wed' => 'sze',
- 'Thursday' => 'cs&uuml;t&ouml;rt&ouml;k','Thu' => 'cs&uuml;t',
- 'Friday' => 'p&eacute;ntek', 'Fri' => 'p&eacute;n',
- 'Saturday' => 'szombat', 'Sat' => 'szo'
-
- );
-
-%month =
- (
- 'January' => 'janu&aacute;r', 'February' => 'febru&aacute;r' , 'March' => 'm&aacute;rcius',
- 'Jan' => 'jan', 'Feb' => 'feb', 'Mar' => 'marc',
- 'April' => '&aacute;prilis', 'May' => 'm&aacute;jus', 'June' => 'j&uacute;nius',
- 'Apr' => 'apr', 'May' => 'maj', 'Jun' => 'jun',
- 'July' => 'j&uacute;lius', 'August' => 'augusztus', 'September' => 'szeptember',
- 'Jul' => 'jul', 'Aug' => 'aug', 'Sep' => 'szept',
- 'October' => 'okt&oacute;ber', 'November' => 'november', 'December' => 'december',
- 'Oct' => 'okt', 'Nov' => 'nov', 'Dec' => 'dec'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." kl.".$quux[1];
- };
- return "$quux[0]. $month{$foo[2]} $foo[1]., $wday{$foo[0]} $quux[1]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
- };
-# Icelandic
-
-sub icelandic
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'H&aacute;marks 5 m&iacute;n&uacute;tna umfer&eth; inn',
- 'Maximal 5 Minute Outgoing Traffic' => 'H&aacute;marks 5 m&iacute;n&uacute;tna umfer&eth; &uacute;t',
- 'the device' => 'tæki&eth;',
- 'The statistics were last updated(.*)' => 'G&ouml;gnin voru s&iacute;&eth;ast uppf&aelig;r&eth;$1',
- ' Average\)' => ' Me&eth;altal)',
- 'Average' => 'Me&eth;altal',
- 'Max' => 'H&aacute;mark',
- 'Current' => 'N&uacute;',
- 'version' => '&uacute;tg&aacute;fa',
- '`Daily\' Graph \((.*) Minute' => '`Dagleg\' sta&eth;a ($1 m&iacute;n&uacute;tur',
- '`Weekly\' Graph \(30 Minute' => '`Vikuleg\' sta&eth;a (30 m&iacute;n&uacute;tur',
- '`Monthly\' Graph \(2 Hour' => '`M&aacute;na&eth;arleg\' sta&eth;a (2 klst.',
- '`Yearly\' Graph \(1 Day' => '`&Aarleg\' sta&eth;a (1 dags',
- 'Incoming Traffic in (\S+) per Second' => 'Umfer&eth; inn &iacute; $1 &aacute; sek&uacute;ndu',
- 'Outgoing Traffic in (\S+) per Second' => 'Umfer&eth; &uacute;t &iacute; $1 &aacute; sek&uacute;ndu',
- 'at which time (.*) had been up for(.*)' => '&thorn;egar $1 haf&eth;i veri&eth; uppi &iacute;$2',
- # '([kMG]?)([bB])/s' => '\$1\$2/sek',
- # '([kMG]?)([bB])/min' => '\$1\$2/m&iacute;n',
- '([kMG]?)([bB])/h' => '$1$2/klst',
- # 'Bits' => 'Bitar',
- # 'Bytes' => 'B&aelig;ti'
- 'In' => 'Inn',
- 'Out' => '&Uacute;t',
- 'Percentage' => 'Pr&oacute;sent',
- 'Ported to OpenVMS Alpha by' => 'Sta&eth;f&aelig;rt &aacute; OpenVMS af',
- 'Ported to WindowsNT by' => 'Sta&eth;f&aelig;rt &aacute; WindowsNT af',
- 'and' => 'og',
- '^GREEN' => 'GR&AElig;Nt',
- 'BLUE' => 'BL&Aacute;TT',
- 'DARK GREEN' => 'D&Ouml;KK GR&AElig;NN',
- 'MAGENTA' => 'BL&Aacute;RAU&ETH;UR',
- 'AMBER' => 'GULBR&Uacute;NN'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Sunnudagur', 'Sun' => 'Sun',
- 'Monday' => 'M&aacute;nudagur', 'Mon' => 'M&aacute;n',
- 'Tuesday' => '&THORN;ri&eth;judagur', 'Tue' => '&THORN;ri',
- 'Wednesday' => 'Mi&eth;vikudagur', 'Wed' => 'Mi&eth;',
- 'Thursday' => 'Fimmtudagur', 'Thu' => 'Fim',
- 'Friday' => 'F&ouml;studagur', 'Fri' => 'F&ouml;s',
- 'Saturday' => 'Laugardagur', 'Sat' => 'Lau'
-
- );
-
-%month =
- (
- 'January' => 'Jan&uacute;ar', 'February' => 'Febr&uacute;ar' , 'March' => 'Mars',
- 'Jan' => 'Jan', 'Feb' => 'Feb', 'Mar' => 'Mar',
- 'April' => 'Apr&iacute;l', 'May' => 'Ma&iacute;', 'June' => 'J&uacute;n&iacute;',
- 'Apr' => 'Apr', 'May' => 'Ma&iacute;', 'Jun' => 'J&uacute;n',
- 'July' => 'J&uacute;l&iacute;', 'August' => '&Aacute;g&uacute;st', 'September' => 'September',
- 'Jul' => 'J&uacute;l', 'Aug' => '&Aacute;g&uacute;', 'Sep' => 'Sep',
- 'October' => 'Okt&oacute;ber', 'November' => 'N&oacute;vember', 'December' => 'Desember',
- 'Oct' => 'Okt', 'Nov' => 'N&oacute;v', 'Dec' => 'Des'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." kl.".$quux[1];
- };
- return "$wday{$foo[0]} den $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# Malaysian/Indonesian/Malay
-
-sub indonesia
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Trafik Masuk Maksimum dalam 5 Menit',
- 'Maximal 5 Minute Outgoing Traffic' => 'Trafik Keluar Maksimum dalam 5 Menit',
- 'the device' => 'device',
- 'The statistics were last updated(.*)' => 'Statistik ini terakhir kali diupdate pada $1',
- ' Average\)' => ')',
- 'Average' => 'Rata-rata',
- 'Max' => 'Maksimum',
- 'Current' => 'Sekarang',
- 'version' => 'versi',
- '`Daily\' Graph \((.*) Minute' => 'Grafik Harian (Rata-rata per $1 menit',
- '`Weekly\' Graph \(30 Minute' => 'Grafik Mingguan (Rata-rata per 30 menit',
- '`Monthly\' Graph \(2 Hour' => 'Grafik Bulanan (Rata-rata per 2 jam',
- '`Yearly\' Graph \(1 Day' => 'Grafik Tahunan (Rata-rata per hari',
- 'Incoming Traffic in (\S+) per Second' => 'Trafik Masuk $1 per detik',
- 'Outgoing Traffic in (\S+) per Second' => 'Trafik Keluar $1 per detik',
- 'at which time (.*) had been up for(.*)' => 'Pada saat $1 telah aktif selama $2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/j',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Masuk',
- 'Out' => 'Keluar',
- 'Percentage' => 'Persentase',
- 'Ported to OpenVMS Alpha by' => 'Porting ke OpenVMS Alpha oleh',
- 'Ported to WindowsNT by' => 'Porting ke WindowsNT oleh',
- 'and' => 'dan',
- '^GREEN' => 'HIJAU',
- 'BLUE' => 'BIRU',
- 'DARK GREEN' => 'HIJAU GELAP',
- 'MAGENTA' => 'MAGENTA',
- 'AMBER' => 'AMBAR'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Ahad', 'Sun' => 'Aha',
- 'Monday' => 'Senin', 'Mon' => 'Sen',
- 'Tuesday' => 'Selasa', 'Tue' => 'Sel',
- 'Wednesday' => 'Rabu', 'Wed' => 'Rab',
- 'Thursday' => 'Kamis', 'Thu' => 'Kam',
- 'Friday' => 'Jumat', 'Fri' => 'Jum',
- 'Saturday' => 'Sabtu', 'Sat' => 'Sab'
- );
-
-%month =
- (
- 'January' => 'Januari', 'February' => 'Februari' , 'March' => 'Maret',
- 'Jan' => 'Jan', 'Feb' => 'Feb', 'Mar' => 'Mar',
- 'April' => 'April', 'May' => 'Mei', 'June' => 'Juni',
- 'Apr' => 'Apr', 'May' => 'Mei', 'Jun' => 'Jun',
- 'July' => 'Juli', 'August' => 'Agustus', 'September' => 'September',
- 'Jul' => 'Jul', 'Aug' => 'Ags', 'Sep' => 'Sep',
- 'October' => 'Oktober', 'November' => 'November', 'December' => 'Desember',
- 'Oct' => 'Okt', 'Nov' => 'Nov', 'Dec' => 'Des'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." pada ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# iso2022jp
-
-sub iso2022jp
-{
- my $string = shift;
- return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- '^iso-8859-1' => 'iso-2022-jp',
- '^Maximal 5 Minute Incoming Traffic' => '\e\\$B:GBg\e(B5\e\\$BJ,<u?.NL\e(B',
- '^Maximal 5 Minute Outgoing Traffic' => '\e\\$B:GBg\e(B5\e\\$BJ,Aw?.NL\e(B',
- '^the device' => '\e\\$B%G%P%\\$%9\e(B',
- '^The statistics were last updated (.*)' => '\e\\$B99?7F|;~\e(B $1',
- '^Average\)' => '\e\\$BJ?6Q\e(B)',
- '^Average$' => '\e\\$BJ?6Q\e(B',
- '^Max$' => '\e\\$B:GBg\e(B',
- '^Current' => '\e\\$B:G?7\e(B',
- '^`Daily\' Graph \((.*) Minute' => '\e\\$BF|%0%i%U\e(B($1\e\\$BJ,4V\e(B',
- '^`Weekly\' Graph \(30 Minute' => '\e\\$B=5%0%i%U\e(B(30\e\\$BJ,4V\e(B',
- '^`Monthly\' Graph \(2 Hour' => '\e\\$B7n%0%i%U\e(B(2\e\\$B;~4V\e(B',
- '^`Yearly\' Graph \(1 Day' => '\e\\$BG/%0%i%U\e(B(1\e\\$BF|\e(B',
- '^Incoming Traffic in (\S+) per Second' => '\e\\$BKhIC\\$N<u?.\e(B$1\e\\$B?t\e(B',
- '^Incoming Traffic in (\S+) per Minute' => '\e\\$BKhJ,\\$N<u?.\e(B$1\e\\$B?t\e(B',
- '^Incoming Traffic in (\S+) per Hour' => '\e\\$BKh;~\\$N<u?.\e(B$1\e\\$B?t\e(B',
- '^Outgoing Traffic in (\S+) per Second' => '\e\\$BKhIC\\$NAw?.\e(B$1\e\\$B?t\e(B',
- '^Outgoing Traffic in (\S+) per Minute' => '\e\\$BKhJ,\\$NAw?.\e(B$1\e\\$B?t\e(B',
- '^Outgoing Traffic in (\S+) per Hour' => '\e\\$BKh;~\\$NAw?.\e(B$1\e\\$B?t\e(B',
- '^at which time (.*) had been up for (.*)' => '$1\e\\$B\\$N2TF/;~4V\e(B $2',
- '^Average max 5 min values for `Daily\' Graph \((.*) Minute interval\):' => '\e\\$BF|%0%i%U\\$G\\$N:GBg\e(B5\e\\$BJ,CM\\$NJ?6Q\e(B($1\e\\$BJ,4V3V\e(B):',
- '^Average max 5 min values for `Weekly\' Graph \(30 Minute interval\):' => '\e\\$B=5%0%i%U\\$G\\$N:GBg\e(B5\e\\$BJ,CM\\$NJ?6Q\e(B(30\e\\$BJ,4V3V\e(B):',
- '^Average max 5 min values for `Monthly\' Graph \(2 Hour interval\):' => '\e\\$B7n%0%i%U\\$G\\$N:GBg\e(B5\e\\$BJ,CM\\$NJ?6Q\e(B(2\e\\$B;~4V4V3V\e(B):',
- '^Average max 5 min values for `Yearly\' Graph \(1 Day interval\):' => '\e\\$BG/%0%i%U\\$G\\$N:GBg\e(B5\e\\$BJ,CM\\$NJ?6Q\e(B(1\e\\$BF|4V3V\e(B):',
- #'^([kMG]?)([bB])/s' => '$1$2/\e\\$BIC\e(B',
- #'^([kMG]?)([bB])/min' => '$1$2/\e\\$BJ,\e(B',
- #'^([kMG]?)([bB])/h' => '$1$2/\e\\$B;~\e(B',
- '^Bits$' => '\e\\$B%S%C%H\e(B',
- '^Bytes$' => '\e\\$B%P%\\$%H\e(B',
- '^In$' => '\e\\$B<u?.\e(B',
- '^Out$' => '\e\\$BAw?.\e(B',
- '^Percentage' => '\e\\$BHfN(\e(B',
- '^Ported to OpenVMS Alpha by' => 'OpenVMS Alpha\e\\$B\\$X\\$N0\\\?"\e(B',
- '^Ported to WindowsNT by' => 'WindowsNT\e\\$B\\$X\\$N0\\\?"\e(B',
- #'^and' => 'and',
- '^GREEN' => '\e\\$BNP\e(B',
- '^BLUE' => '\e\\$B\\@D\e(B',
- '^DARK GREEN' => '\e\\$B?<NP\e(B',
- '^MAGENTA' => '\e\\$B%^%<%s%?\e(B',
- '^AMBER' => '\e\\$B`h`a\e(B'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => "(\e\$BF|\e(B)",
- 'Monday' => "(\e\$B7n\e(B)",
- 'Tuesday' => "(\e\$B2P\e(B)",
- 'Wednesday' => "(\e\$B?e\e(B)",
- 'Thursday' => "(\e\$BLZ\e(B)",
- 'Friday' => "(\e\$B6b\e(B)",
- 'Saturday' => "(\e\$BEZ\e(B)",
- );
-
-%month =
- (
- 'January' => "1\e\$B7n\e(B", 'February' => "2\e\$B7n\e(B",
- 'March' => "3\e\$B7n\e(B", 'April' => "4\e\$B7n\e(B",
- 'May' => "5\e\$B7n\e(B", 'June' => "6\e\$B7n\e(B",
- 'July' => "7\e\$B7n\e(B", 'August' => "8\e\$B7n\e(B",
- 'September' => "9\e\$B7n\e(B", 'October' => "10\e\$B7n\e(B",
- 'November' => "11\e\$B7n\e(B", 'December' => "12\e\$B7n\e(B",
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)\s+(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~/at/)
- {
- @quux=split(/\s+at\s+/,$foo[3]);
- }
- else
- {
- @quux=split(/ /,$foo[3],2);
- };
- return "$quux[0]\e\$BG/\e(B$month{$foo[2]}$foo[1]\e\$BF|\e(B$wday{$foo[0]} $quux[1]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# Italian
-
-sub italian
-{
- my $string = shift;
- return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Traffico massimo in entrata su 5 minuti',
- 'Maximal 5 Minute Outgoing Traffic' => 'Traffico massimo in uscita su 5 minuti',
- 'the device' => 'Il dispositivo',
- 'The statistics were last updated(.*)' => 'Le statistiche l\' ultima volta sono state aggiornate $1',
- ' Average\)' => ' Media)',
- 'Average' => 'Media',
- 'Max' => 'Max',
- 'Current' => 'Attuale',
- 'version' => 'versione',
- '`Daily\' Graph \((.*) Minute' => 'Grafico giornaliero (su $1 minuti:',
- '`Weekly\' Graph \(30 Minute' => 'Grafico settimanale (su 30 minuti:' ,
- '`Monthly\' Graph \(2 Hour' => 'Grafico mensile (su 2 ore:',
- '`Yearly\' Graph \(1 Day' => 'Grafico annuale (su 1 giorno:',
- 'Incoming Traffic in (\S+) per Second' => 'Traffico in ingresso in $1 per Secondo',
- 'Outgoing Traffic in (\S+) per Second' => 'Traffico in uscita in $1 per Secondo',
- 'Incoming Traffic in (\S+) per Minute' => 'Traffico in ingresso in $1 per Minuto',
- 'Outgoing Traffic in (\S+) per Minute' => 'Traffico in uscita $1 per Minuto',
- 'Incoming Traffic in (\S+) per Hour' => 'Traffico in ingresso $1 per Ora',
- 'Outgoing Traffic in (\S+) per Hour' => 'Traffico in uscita $1 per Ora',
- 'at which time (.*) had been up for(.*)' => '$1 &eacute attivo da $2',
- '(\S+) per minute' => '$1 per Minuto',
- '(\S+) per hour' => '$1 per Ora',
- '(.+)/s$' => '$1/s',
- # '(.+)/min' => '$1/min',
- '(.+)/h$' => '$1/ora',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- # '([kMG]?)([bB])/h' => '$1$2/t',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Ingresso',
- 'Out' => 'Uscita',
- 'Percentage' => 'Percentuale',
- 'Ported to OpenVMS Alpha by' => 'Ported su OpenVMS Alpha da',
- 'Ported to WindowsNT by' => 'Ported su WindowsNT da',
- 'and' => 'e',
- '^GREEN' => 'VERDE',
- 'BLUE' => 'BLU',
- 'DARK GREEN' => 'VERDE SCURO',
- #'MAGENTA' => 'MAGENTA',
- #'AMBER' => 'AMBRA'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Domenica', 'Sun' => 'Dom',
- 'Monday' => 'Lunedi', 'Mon' => 'Lun',
- 'Tuesday' => 'Martedi', 'Tue' => 'Mar',
- 'Wednesday' => 'Mercoledi', 'Wed' => 'Mer',
- 'Thursday' => 'Giovedi', 'Thu' => 'Gio',
- 'Friday' => 'Venerdi', 'Fri' => 'Ven',
- 'Saturday' => 'Sabato', 'Sat' => 'Sab'
- );
-
-%month =
- (
- 'January' => 'Gennaio', 'February' => 'Febbraio' , 'March' => 'Marzo',
- 'Jan' => 'Gen', 'Feb' => 'Feb', 'Mar' => 'Mar',
- 'April' => 'Aprile', 'May' => 'Maggio', 'June' => 'Giugno',
- 'Apr' => 'Apr', 'May' => 'Mag', 'Jun' => 'Giu',
- 'July' => 'Luglio', 'August' => 'Agosto', 'September' => 'Settembre',
- 'Jul' => 'Lug', 'Aug' => 'Ago', 'Sep' => 'Set',
- 'October' => 'Ottobre', 'November' => 'Novembre', 'December' => 'Dicembre',
- 'Oct' => 'Ott', 'Nov' => 'Nov', 'Dec' => 'Dic'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." alle ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." &agrave; $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-
-
-# Korean
-
-sub korean
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'euc-kr',
- 'Maximal 5 Minute Incoming Traffic' => '5ºÐ°£ ÃÖ´ë ¼ö½Å',
- 'Maximal 5 Minute Outgoing Traffic' => '5ºÐ°£ ÃÖ´ë ¼Û½Å',
- 'the device' => 'ÀåÄ¡',
- 'The statistics were last updated(.*)' => 'ÃÖÁ¾ °»½Å ÀϽÃ: $1',
- ' Average\)' => ' Æò±Õ°ª ±âÁØ)',
- 'Average' => 'Æò±Õ',
- 'Max' => 'ÃÖ´ë',
- 'Current' => 'ÇöÀç',
- 'version' => '¹öÀü',
- '`Daily\' Graph \((.*) Minute' => 'Àϰ£ ±×·¡ÇÁ ($1 ºÐ ´ÜÀ§',
- '`Weekly\' Graph \(30 Minute' => 'ÁÖ°£ ±×·¡ÇÁ (30 ºÐ ´ÜÀ§' ,
- '`Monthly\' Graph \(2 Hour' => '¿ù°£ ±×·¡ÇÁ (2 ½Ã°£ ´ÜÀ§',
- '`Yearly\' Graph \(1 Day' => '¿¬°£ ±×·¡ÇÁ (1 ÀÏ ´ÜÀ§',
- 'Incoming Traffic in (\S+) per Second' => 'ÃÊ´ç ¼ö½ÅµÈ Æ®·¡ÇÈ ($1)',
- 'Outgoing Traffic in (\S+) per Second' => 'ÃÊ´ç ¼Û½ÅµÈ Æ®·¡ÇÈ ($1)',
- 'at which time (.*) had been up for(.*)' => '$1ÀÇ °¡µ¿ ½Ã°£: $2',
- '([kMG]?)([bB])/s' => '$1$2/ÃÊ',
- '([kMG]?)([bB])/min' => '$1$2/ºÐ',
- '([kMG]?)([bB])/h' => '$1$2/½Ã',
- 'Bits' => 'ºñÆ®',
- 'Bytes' => '¹ÙÀÌÆ®',
- 'In' => '¼ö½Å',
- 'Out' => '¼Û½Å',
- 'Percentage' => 'ÆÛ¼¾Æ®',
- 'Ported to OpenVMS Alpha by' => 'OpenVMS Alpha Æ÷ÆÃ',
- 'Ported to WindowsNT by' => 'WindowsNT Æ÷ÆÃ',
- 'and' => '¿Í',
- '^GREEN' => '³ì»ö',
- 'BLUE' => 'û»ö',
- 'DARK GREEN' => 'ÁøÇѳì»ö',
- 'MAGENTA' => 'ºÐÈ«»ö',
- 'AMBER' => 'ÁÖȲ»ö'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'ÀÏ¿äÀÏ', 'Sun' => 'ÀÏ',
- 'Monday' => '¿ù¿äÀÏ', 'Mon' => '¿ù',
- 'Tuesday' => 'È­¿äÀÏ', 'Tue' => 'È­',
- 'Wednesday' => '¼ö¿äÀÏ', 'Wed' => '¼ö',
- 'Thursday' => '¸ñ¿äÀÏ', 'Thu' => '¸ñ',
- 'Friday' => '±Ý¿äÀÏ', 'Fri' => '±Ý',
- 'Saturday' => 'Åä¿äÀÏ', 'Sat' => 'Åä'
-
- );
-
-%month =
- (
- 'January' => '1¿ù', 'February' => '2¿ù' , 'March' => '3¿ù',
- 'Jan' => '1¿ù', 'Feb' => '2¿ù', 'Mar' => '3¿ù',
- 'April' => '4¿ù', 'May' => '5¿ù', 'June' => '6¿ù',
- 'Apr' => '4¿ù', 'May' => '5¿ù', 'Jun' => '6¿ù',
- 'July' => '7¿ù', 'August' => '8¿ù', 'September' => '9¿ù',
- 'Jul' => '7¿ù', 'Aug' => '8¿ù', 'Sep' => '9¿ù',
- 'October' => '10¿ù', 'November' => '11¿ù', 'December' => '12¿ù',
- 'Oct' => '10¿ù', 'Nov' => '11¿ù', 'Dec' => '12¿ù'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
-# $foo[3]=$quux[0]." kl.".$quux[1];
- $foo[3]=$quux[0];
- $foo[4]=$quux[1];
- };
- return $foo[3]."³â $month{$foo[2]} $foo[1]ÀÏ $wday{$foo[0]} $foo[4]";
-# return "$wday{$foo[0]} den $foo[1]. $month{$foo[2]} $foo[3]";
-
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-};
-
-# Lithuanian
-
-sub lithuanian
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'windows-1257',
- 'Maximal 5 Minute Incoming Traffic' => 'Maksimalus 5 minuèiø áeinantis srautas',
- 'Maximal 5 Minute Outgoing Traffic' => 'Maksimalus 5 minuèiø iðeinantis srautas',
- 'the device' => 'árenginys',
- 'The statistics were last updated(.*)' => 'Statistika atnaujinta$1',
- ' Average\)' => ' vidurkis)',
- 'Average' => 'vid',
- 'Max' => 'max',
- 'Current' => 'dabar',
- 'version' => 'versija',
- '`Daily\' Graph \((.*) Minute' => '\'dienos\' grafikas ($1 min.',
- '`Weekly\' Graph \(30 Minute' => '\'savaitës\' grafikas (30 min.' ,
- '`Monthly\' Graph \(2 Hour' => '\'mënesio\' grafikas (2 val.',
- '`Yearly\' Graph \(1 Day' => '\'metø\' grafikas (1 d.',
- 'Incoming Traffic in (\S+) per Second' => 'Áeinantis srautas, $1 per sekundæ',
- 'Outgoing Traffic in (\S+) per Second' => 'Iðeinantis srautas i $1 per sekundæ',
- 'at which time (.*) had been up for(.*)' => '$1 veikia jau $2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- # '([kMG]?)([bB])/h' => '$1$2/h',
- 'Bits' => 'bitai',
- 'Bytes' => 'baitai',
- 'In' => 'á',
- 'Out' => 'ið',
- 'Percentage' => 'procentai',
- 'Ported to OpenVMS Alpha by' => 'Perkëlë á OpenVMS Alpha:',
- 'Ported to WindowsNT by' => 'Perkëlë á WindowsNT:',
- 'and' => 'ir',
- '^GREEN' => 'ÞALIA ',
- 'BLUE' => 'MËLYNA ',
- 'DARK GREEN' => 'TAMSIAI ÞALIA ',
- 'MAGENTA' => 'RAUDONA ',
- 'AMBER' => 'GINTARINË '
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'sekmadiená', 'Sun' => 'Sek',
- 'Monday' => 'pirmadiená', 'Mon' => 'Pir',
- 'Tuesday' => 'antradiená', 'Tue' => 'Ant',
- 'Wednesday' => 'treèiadiená', 'Wed' => 'Tre',
- 'Thursday' => 'ketvirtadiená', 'Thu' => 'Ket',
- 'Friday' => 'penktadiená', 'Fri' => 'Pen',
- 'Saturday' => 'ðeðtadiená', 'Sat' => 'Ðeð'
-
- );
-
-%month =
- (
- 'January' => 'sausio', 'February' => 'vasario' , 'March' => 'kovo',
- 'Jan' => 'Sau', 'Feb' => 'Vas', 'Mar' => 'Kov',
- 'April' => 'balandþio', 'May' => 'geguþës', 'June' => 'birþelio',
- 'Apr' => 'Bal', 'May' => 'Geg', 'Jun' => 'Bir',
- 'July' => 'liepos', 'August' => 'rugpjûèio', 'September' => 'rugsëjo',
- 'Jul' => 'Lie', 'Aug' => 'Rgp', 'Sep' => 'Rgs',
- 'October' => 'spalio', 'November' => 'lapkrièio', 'December' => 'gruodþio',
- 'Oct' => 'Spa', 'Nov' => 'Lap', 'Dec' => 'Gru'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[1].", ".$quux[0];
- };
- return "$foo[3] $month{$foo[2]} $foo[1], $wday{$foo[0]}" ;
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
- };
-# Macedonian
-
-sub macedonian
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=windows-1251',
- 'Maximal 5 Minute Incoming Traffic' => 'Ìàêñèìàëåí 5 ìèíóòåí âëåçåí ñîîáðà�à¼',
- 'Maximal 5 Minute Outgoing Traffic' => 'Ìàêñèìàëåí 5 ìèíóòåí èçëåçåí ñîîáðà�à¼',
- 'the device' => 'óðåä',
- 'The statistics were last updated(.*)' => 'Ïîñëåäíî àæóðèðàœå íà ïîäàòîöèòå$1',
- ' Average\)' => ' ïðîñåê)',
- 'Average' => 'Ïðîñå÷åí',
- 'Max' => 'Ìàêñèìàë',
- 'Current' => 'Ìoìåíò',
- 'version' => 'âåðçè¼à',
- '`Daily\' Graph \((.*) Minute' => '`Äíåâåí\' ãðàô ($1 ìèíóòè',
- '`Weekly\' Graph \(30 Minute' => '`Íåäåëåí\' ãðàô (30 ìèíóòè' ,
- '`Monthly\' Graph \(2 Hour' => '`Ìåñå÷åí\' ãðàô (2 ÷àñà',
- '`Yearly\' Graph \(1 Day' => '`Ãîäèøåí\' ãðàô (1 äåí',
- 'Incoming Traffic in (\S+) per Second' => 'Âëåçåí ñîîáðà�༠- $1 âî ñåêóíäà',
- 'Outgoing Traffic in (\S+) per Second' => 'Èçëåçåí ñîîáðà�༠- $1 âî ñåêóíäà',
- 'at which time (.*) had been up for(.*)' => 'Âðåìå íà íåïðåêèíàòî ðàáîòåœå íà ñèñòåìîò $1 : $2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/h',
- # 'Bits' => 'Áèòîâè',
- # 'Bytes' => 'Áà¼òè'
- 'In' => 'Âëåç',
- 'Out' => 'Èçëåç',
- 'Percentage' => 'Ïðîöåíò',
- 'Ported to OpenVMS Alpha by' => 'Ïîðòèðàíî íà OpenVMS îä',
- 'Ported to WindowsNT by' => 'Ïîðòèðàíî íà WindowsNT îä',
- 'and' => 'è',
- '^GREEN' => 'Çåëåíà',
- 'BLUE' => 'Ñèíà',
- 'DARK GREEN' => 'Òåìíî Çåëåíà',
- 'MAGENTA' => 'Âèîëåòîâà',
- 'AMBER' => 'Ïîðòîêàëîâà'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Íåäåëà', 'Sun' => 'Íåä',
- 'Monday' => 'Ïîíåäåëíèê', 'Mon' => 'Ïîí',
- 'Tuesday' => 'Âòîðíèê', 'Tue' => 'Âòî',
- 'Wednesday' => 'Ñðåäà', 'Wed' => 'Ñðå',
- 'Thursday' => '×åòâðòîê', 'Thu' => '×åò',
- 'Friday' => 'Ïåòîê', 'Fri' => 'Ïåò',
- 'Saturday' => 'Ñàáîòà', 'Sat' => 'Ñàá'
-
- );
-
-%month =
- (
- 'January' => '£àíóàð', 'February' => 'Ôåâðóàð' , 'March' => 'Ìàðò',
- 'Jan' => '£àí', 'Feb' => 'Ôåâ', 'Mar' => 'Ìàð',
- 'April' => 'Àïðèë', 'May' => 'Ìà¼', 'June' => '£óíè',
- 'Apr' => 'Àïð', 'May' => 'Ìà¼', 'Jun' => '£óí',
- 'July' => '£óëè', 'August' => 'Àâãóñò', 'September' => 'Ñåïòåìâðè',
- 'Jul' => '£óë', 'Aug' => 'Àâã', 'Sep' => 'Ñåï',
- 'October' => 'Îêòîìâðè', 'November' => 'Íîåìâðè', 'December' => 'Äåêåìâðè',
- 'Oct' => 'Îêò', 'Nov' => 'Íîå', 'Dec' => 'Äåê'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." kl.".$quux[1];
- };
- return "$wday{$foo[0]} äåí $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
- };# Malaysian/Malay
-
-sub malay
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Maksimum 5 Minit Trafik Masuk',
- 'Maximal 5 Minute Outgoing Traffic' => 'Maksimum 5 Minit Trafik Keluar',
- 'the device' => 'alatan',
- 'The statistics were last updated(.*)' => 'Statistik ini kali terakhir dikemaskini pada $1',
- ' Average\)' => ' secara purata)',
- 'Average' => 'Purata',
- 'Max' => 'Maksimum',
- 'Current' => 'Kini',
- 'version' => 'versi',
- '`Daily\' Graph \((.*) Minute' => 'Graf `Harian\' ($1 minit :',
- '`Weekly\' Graph \(30 Minute' => 'Graf `Mingguan\' (30 minit :' ,
- '`Monthly\' Graph \(2 Hour' => 'Graf `Bulanan\' (2 jam :',
- '`Yearly\' Graph \(1 Day' => 'Graf `Tahunan\' (1 hari :',
- 'Incoming Traffic in (\S+) per Second' => 'Trafik Masuk $1 per saat',
- 'Outgoing Traffic in (\S+) per Second' => 'Traffic Keluar $1 per saat',
- 'at which time (.*) had been up for(.*)' => 'Sehingga waktu $1 ia telah aktif selama $2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/j',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Masuk',
- 'Out' => 'Keluar',
- 'Percentage' => 'Peratus',
- 'Ported to OpenVMS Alpha by' => 'Pengubahsuaian ke OpenVMS Alpha oleh',
- 'Ported to WindowsNT by' => 'Pengubahsuaian ke WindowsNT oleh',
- 'and' => 'dan',
- '^GREEN' => 'HIJAU',
- 'BLUE' => 'BIRU',
- 'DARK GREEN' => 'HIJAU GELAP',
- 'MAGENTA' => 'MAGENTA',
- 'AMBER' => 'AMBAR'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Ahad', 'Sun' => 'Aha',
- 'Monday' => 'Isnin', 'Mon' => 'Isn',
- 'Tuesday' => 'Selasa', 'Tue' => 'Sel',
- 'Wednesday' => 'Rabu', 'Wed' => 'Rab',
- 'Thursday' => 'Khamis', 'Thu' => 'Kha',
- 'Friday' => 'Jumaat', 'Fri' => 'Jum',
- 'Saturday' => 'Sabtu', 'Sat' => 'Sab'
- );
-
-%month =
- (
- 'January' => 'Januari', 'February' => 'Februari' , 'March' => 'Mac',
- 'Jan' => 'Jan', 'Feb' => 'Feb', 'Mar' => 'Mac',
- 'April' => 'April', 'May' => 'Mei', 'June' => 'Jun',
- 'Apr' => 'Apr', 'May' => 'Mei', 'Jun' => 'Jun',
- 'July' => 'Julai', 'August' => 'Ogos', 'September' => 'September',
- 'Jul' => 'Jul', 'Aug' => 'Ogo', 'Sep' => 'Sep',
- 'October' => 'Oktober', 'November' => 'November', 'December' => 'Disember',
- 'Oct' => 'Okt', 'Nov' => 'Nov', 'Dec' => 'Dis'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." pada ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# Norwegian
-
-sub norwegian
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Maksimal inng&aring;ende trafikk i 5 minutter',
- 'Maximal 5 Minute Outgoing Traffic' => 'Maksimal utg&aring;ende trafikk i 5 minutter',
- 'the device' => 'enhetden',
- 'The statistics were last updated(.*)' => 'Statistikken ble sist oppdatert $1',
- ' Average\)' => ' gjennomsnitt)',
- 'Average' => 'Gjennomsnitt',
- 'Max' => 'Max',
- 'Current' => 'N&aring;',
- 'version' => 'versjon',
- '`Daily\' Graph \((.*) Minute' => '`Daglig\' graf ($1 minutts',
- '`Weekly\' Graph \(30 Minute' => '`Ukentlig\' graf (30 minutts' ,
- '`Monthly\' Graph \(2 Hour' => '`M&aring;nedlig\' graf (2 times',
- '`Yearly\' Graph \(1 Day' => '`&Aring;rlig\' graf (1 dags',
- 'Incoming Traffic in (\S+) per Second' => 'Inng&aring;ende trafikk i $1 per sekund',
- 'Outgoing Traffic in (\S+) per Second' => 'Utg&aring;ende trafikk i $1 per sekund',
- 'at which time (.*) had been up for(.*)' => 'hvor $1 hadde v&aelig;rt oppe i $2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/t',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Inn',
- 'Out' => 'Ut',
- 'Percentage' => 'Prosent',
- 'Ported to OpenVMS Alpha by' => 'Port til OpenVMS av',
- 'Ported to WindowsNT by' => 'Port til WindowsNT av',
- 'and' => 'og',
- '^GREEN' => 'GR&Oslash;NN',
- 'BLUE' => 'BL&Aring;',
- 'DARK GREEN' => 'M&Oslash;RKEGR&Oslash;NN',
- 'MAGENTA' => 'MAGENTA',
- 'AMBER' => 'GUL'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'S&oslash;ndag', 'Sun' => 'S&oslash;n',
- 'Monday' => 'Mandag', 'Mon' => 'Man',
- 'Tuesday' => 'Tirsdag', 'Tue' => 'Tir',
- 'Wednesday' => 'Onsdag', 'Wed' => 'Ons',
- 'Thursday' => 'Torsdag', 'Thu' => 'Tor',
- 'Friday' => 'Fredag', 'Fri' => 'Fre',
- 'Saturday' => 'L&oslash;rdag', 'Sat' => 'L&oslash;r'
-
- );
-
-%month =
- (
- 'January' => 'Januar', 'February' => 'Februar' , 'March' => 'Mars',
- 'Jan' => 'Jan', 'Feb' => 'Feb', 'Mar' => 'Mar',
- 'April' => 'April', 'May' => 'Mai', 'June' => 'Juni',
- 'Apr' => 'Apr', 'May' => 'Mai', 'Jun' => 'Jun',
- 'July' => 'Juli', 'August' => 'August', 'September' => 'September',
- 'Jul' => 'Jul', 'Aug' => 'Aug', 'Sep' => 'Sep',
- 'October' => 'Oktober', 'November' => 'November', 'December' => 'Desember',
- 'Oct' => 'Okt', 'Nov' => 'Nov', 'Dec' => 'Des'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." kl.".$quux[1];
- };
- return "$wday{$foo[0]} den $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
- };
-
-sub polish
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
-
- %translations =
- (
- 'iso-8859-1' => 'iso-8859-2',
- 'Maximal 5 Minute Incoming Traffic' => 'Maksymalny ruch przychodz±cy w ci±gu 5 minut',
- 'Maximal 5 Minute Outgoing Traffic' => 'Maksymalny ruch wychodz±cy w ci±gu 5 minut',
- 'the device' => 'urz±dzenie',
- 'The statistics were last updated(.*)' => 'Ostatnie uaktualnienie statystyki $1',
- ' Average\)' => ' ¦rednia)',
- 'Average' => '¦rednio',
- 'Max' => 'Maksymalnie',
- 'Current' => 'Aktualnie',
- 'version' => 'wersja',
- '`Daily\' Graph \((.*) Minute' => '`Dzienny\' Graf w ci±gu ($1 Minut/y - ',
- '`Weekly\' Graph \(30 Minute' => '`Tygodniowy\' Graf w ci±gu (30 minut - ' ,
- '`Monthly\' Graph \(2 Hour' => '`Miesiêczny\' Graf w ci±gu (2 Godzin - ',
- '`Yearly\' Graph \(1 Day' => '`Roczny\' Graf w ci±gu (1 Dnia - ',
- 'Incoming Traffic in (\S+) per Second' => 'Ruch przychodz±cy - $1 na sekundê',
- 'Outgoing Traffic in (\S+) per Second' => 'Ruch wychodz±cy - $1 na sekundê',
- 'at which time (.*) had been up for(.*)' => 'gdy $1 by³ w³±czony przez $2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/g',
- 'Bits' => 'Bity',
- 'Bytes' => 'Bajty',
- 'In' => 'Do',
- 'Out' => 'Z',
- 'Percentage' => 'Procent',
- 'Ported to OpenVMS Alpha by' => 'Port dla OpenVMS Alpha dziêki',
- 'Ported to WindowsNT by' => 'Port dla WindowsNT dziêki',
- 'and' => 'i',
- '^GREEN' => 'ZIELONY',
- 'BLUE' => 'NIEBIESKI',
- 'DARK GREEN' => 'CIEMNO ZIELONY',
- 'MAGENTA' => 'KARMAZYNOWY',
- 'AMBER' => 'BURSZTYNOWY'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Niedziela', 'Sun' => 'Nie',
- 'Monday' => 'Poniedzia³ek', 'Mon' => 'Pon',
- 'Tuesday' => 'Wtorek', 'Tue' => 'Wto',
- 'Wednesday' => '¦roda', 'Wed' => '¦ro',
- 'Thursday' => 'Czwartek', 'Thu' => 'Czw',
- 'Friday' => 'Pi±tek', 'Fri' => 'Pi±',
- 'Saturday' => 'Sobota', 'Sat' => 'Sob'
-
- );
-
-%month =
- (
- 'January' => 'Stycznia', 'February' => 'Lutego', 'March' => 'Marca',
- 'Jan' => 'Sty', 'Feb' => 'Lut', 'Mar' => 'Mar',
- 'April' => 'Kwietnia', 'May' => 'Maja', 'June' => 'Czerwca',
- 'Apr' => 'Kwi', 'May' => 'Maj', 'Jun' => 'Cze',
- 'July' => 'Lipca', 'August' => 'Sierpnia', 'September' => 'Wrze¶nia',
- 'Jul' => 'Lip', 'Aug' => 'Sie', 'Sep' => 'Wrz',
- 'October' => 'Pa¼dziernika', 'November' => 'Listopada', 'December' => 'Grudnia',
- 'Oct' => 'Pa¼', 'Nov' => 'Lis', 'Dec' => 'Gru'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." o godzinie".$quux[1];
- };
- return "$wday{$foo[0]} dzieñ $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# Português
-
-sub portuguese
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Tr&aacute;fego Maximal Recebido em 5 minutos',
- 'Maximal 5 Minute Outgoing Traffic' => 'Tr&aacute;fego Maximal Enviado em 5 minutos',
- 'the device' => 'o dispositivo',
- 'The statistics were last updated(.*)' => 'As Estat&iacute;sticas foram actualizadas pela &uacute;ltima vez na $1',
- ' Average\)</B><BR>' => '',
- 'Average' => 'M&eacute;dia',
- 'Max' => 'Max.',
- 'Current' => 'Actual',
- 'version' => 'Vers&atilde;o',
- '`Daily\' Graph \((.*) Minute' => 'Gr&aacute;fico Di&aacute;rio (em intervalos de $1 Minutos)</B><BR>',
- '`Weekly\' Graph \(30 Minute' => 'Gr&aacute;fico Semanal (em intervalos de 30 Minutos)' ,
- '`Monthly\' Graph \(2 Hour' => 'Gr&aacute;fico Mensal (em intervalos de 2 horas)',
- '`Yearly\' Graph \(1 Day' => 'Gr&aacute;fico Anual (em intervalos de 24 horas)',
- 'Incoming Traffic in (\S+) per Second' => 'Tr&aacute;fego recebido em $1/segundo',
- 'Outgoing Traffic in (\S+) per Second' => 'Tr&aacute;fego enviado em $1/segundo',
- 'Incoming Traffic in (\S+) per Minute' => 'Tr&aacute;fego recebido em $1/minuto',
- 'Outgoing Traffic in (\S+) per Minute' => 'Tr&aacute;fego enviado em $1/minuto',
- 'Incoming Traffic in (\S+) per Hour' => 'Tr&aacute;fego recebido em $1/hora',
- 'Outgoing Traffic in (\S+) per Hour' => 'Tr&aacute;fego recebido em $1/hora',
- 'at which time (.*) had been up for(.*)' => 'quando o $1, tinha um <em>uptime</em> de $2',
- '(\S+) per minute' => '$1/minuto',
- '(\S+) per hour' => '$1/hora',
- '(.+)/s$' => '$1/s',
- # '(.+)/min' => '$1/min',
- '(.+)/h$' => '$1/h',
- #'([kMG]?)([bB])/s' => '$1$2/s',
- #'([kMG]?)([bB])/min' => '$1$2/min',
- #'([kMG]?)([bB])/h' => '$1$2/h',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Rec.',
- 'Out' => 'Env.',
- 'Percentage' => 'Perc.',
- 'Ported to OpenVMS Alpha by' => 'Portado para OpenVMS Alpha por',
- 'Ported to WindowsNT by' => 'Portado para WindowsNT por',
- 'and' => 'e',
- '^GREEN' => 'VERDE',
- 'BLUE' => 'AZUL',
- 'DARK GREEN' => 'VERDE ESCURO',
- # 'MAGENTA' => 'MAGENTA',
- # 'AMBER' => 'AMBAR',
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Domingo', 'Sun' => 'Dom',
- 'Monday' => 'Segunda-Feira', 'Mon' => 'Seg',
- 'Tuesday' => 'Ter&ccedil;a-Feira', 'Tue' => 'Ter',
- 'Wednesday' => 'Quarta-Feira', 'Wed' => 'Qua',
- 'Thursday' => 'Quinta-Feira', 'Thu' => 'Qui',
- 'Friday' => 'Sexta-Feira', 'Fri' => 'Sex',
- 'Saturday' => 'S&aacute;bado', 'Sat' => 'Sab'
- );
-
-%month =
- (
- 'January' => 'Janeiro', 'February' => 'Fevereiro' , 'March' => 'Mar&ccedil;o',
- 'Jan' => 'Jan', 'Feb' => 'Fev', 'Mar' => 'Mar',
- 'April' => 'Abril', 'May' => 'Maio', 'June' => 'Junho',
- 'Apr' => 'Abr', 'May' => 'Mai', 'Jun' => 'Jun',
- 'July' => 'Julho', 'August' => 'Agosto', 'September' => 'Setembro',
- 'Jul' => 'Jul', 'Aug' => 'Ago', 'Sep' => 'Set',
- 'October' => 'Outubro', 'November' => 'Novembro', 'December' => 'Dezembro',
- 'Oct' => 'Out', 'Nov' => 'Nov', 'Dec' => 'Dez'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." pelas ".$quux[1];
- };
- return "$wday{$foo[0]}, $foo[1] de $month{$foo[2]} de $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-
-
-
-# Romanian
-
-sub romanian
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-8859-2
-
- %translations =
- (
- 'iso-8859-1' => 'iso-8859-2',
- 'Maximal 5 Minute Incoming Traffic' => 'Traficul Maxim de intrare pe 5 Minute',
- 'Maximal 5 Minute Outgoing Traffic' => 'Traficul Maxim de iesire pe 5 Minute',
- 'the device' => 'echipamentul',
- 'The statistics were last updated(.*)' => 'Ultima actualizare :$1',
- ' Average\)' => '',
- 'Average' => 'Medie',
- 'Max' => 'Maxim',
- 'Current' => 'Curent',
- 'version' => 'versiunea',
- '`Daily\' Graph \((.*) Minute' => 'Graficul \'Zilnic\' (medie pe $1 minute)',
- '`Weekly\' Graph \(30 Minute' => 'Graficul \'Sãptãmânal\' (medie pe 30 de minute)' ,
- '`Monthly\' Graph \(2 Hour' => 'Graficul \'Lunar\' (medie pe 2 ore)',
- '`Yearly\' Graph \(1 Day' => 'Graficul \'Anual\' (medie pe 1 zi)',
- 'Incoming Traffic in (\S+) per Second' => 'Traficul de intrare [$1/secundã]',
- 'Outgoing Traffic in (\S+) per Second' => 'Traficul de ieºire [$1/secundã]',
- 'at which time <strong>(\S+)</strong> had been up for <strong>(\S+)</strong>' => 'când <strong>$1</strong> funcþiona de <strong>$2</strong>',
- 'at which time <strong>(\S+)</strong> had been up for <strong>(\S+) day, (\S+)</strong>' => 'când <strong>$1</strong> funcþiona de <strong>$2 zi, $3</strong>',
- 'at which time <strong>(\S+)</strong> had been up for <strong>(\S+) days, (\S+)</strong>' => 'când <strong>$1</strong> funcþiona de <strong>$2 zile, $3</strong>',
- #'(.+)/s$' => '$1/s',
- #'(.+)/min' => '$1/min',
- '(.+)/h$' => '$1/ora',
- #'([kMG]?)([bB])/s' => '$1$2/s',
- #'([kMG]?)([bB])/min' => '$1$2/min',
- '([kMG]?)([bB])/h' => '$1$2/ora',
- 'Bits' => 'Biþi',
- 'Bytes' => 'Octeþi',
- 'In' => 'int',
- 'Out' => 'ieº',
- 'Percentage' => 'procent',
- 'Ported to OpenVMS Alpha by' => 'Translatat sub OpenVMS de',
- 'Ported to WindowsNT by' => 'Translatat sub WindowsNT de',
- 'and' => 'ºi',
- '^GREEN' => 'VERDE',
- 'BLUE' => 'ALBASTRU',
- 'DARK GREEN' => 'VERDE ÎNCHIS',
- 'MAGENTA' => 'PURPURIU',
- 'AMBER' => 'GALBEN',
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'duminicã', 'Sun' => 'lu',
- 'Monday' => 'luni', 'Mon' => 'ma',
- 'Tuesday' => 'marþi', 'Tue' => 'mi',
- 'Wednesday' => 'miercuri', 'Wed' => 'jo',
- 'Thursday' => 'joi', 'Thu' => 'vi',
- 'Friday' => 'vineri', 'Fri' => 'sâ',
- 'Saturday' => 'sâmbãtã', 'Sat' => 'du'
- );
-
-%month =
- (
- 'January' => 'ianuarie', 'February' => 'februarie' , 'March' => 'martie',
- 'Jan' => 'ian', 'Feb' => 'feb', 'Mar' => 'mar',
- 'April' => 'aprilie', 'May' => 'mai', 'June' => 'iunie',
- 'Apr' => 'apr', 'May' => 'mai', 'Jun' => 'iun',
- 'July' => 'iulie', 'August' => 'august', 'September' => 'septembrie',
- 'Jul' => 'iul', 'Aug' => 'aug', 'Sep' => 'sep',
- 'October' => 'octombrie', 'November' => 'noiembrie', 'December' => 'decembrie',
- 'Oct' => 'oct', 'Nov' => 'noi', 'Dec' => 'dec'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0].", ora ".$quux[1];
- };
- return "$wday{$foo[0]}, $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-
-
-# Russian
-
-sub russian
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'koi8-r',
- 'Maximal 5 Minute Incoming Traffic' => 'íÁËÓÉÍÁÌØÎÙÊ ×ÈÏÄÑÝÉÊ ÔÒÁÆÉË ÚÁ 5 ÍÉÎÕÔ',
- 'Maximal 5 Minute Outgoing Traffic' => 'íÁËÓÉÍÁÌØÎÙÊ ÉÓÈÏÄÑÝÉÊ ÔÒÁÆÉË ÚÁ 5 ÍÉÎÕÔ',
- 'the device' => 'ÕÓÔÒÏÊÓÔ×Ï',
- 'The statistics were last updated(.*)' => 'ðÏÓÌÅÄÎÅÅ ÏÂÎÏ×ÌÅÎÉÅ ÓÔÁÔÉÓÔÉËÉ: $1',
- ' Average\)' => ')',
- 'Average' => 'óÒÅÄÎÉÊ',
- 'Max' => 'íÁËÓ.',
- 'Current' => 'ôÅËÕÝÉÊ',
- 'version' => '×ÅÒÓÉÑ',
- '`Daily\' Graph \((.*) Minute' => 'óÕÔÏÞÎÙÊ ÇÒÁÆÉË (ÓÒÅÄÎÅÅ ÚÁ $1 ÍÉÎÕÔ',
- '`Weekly\' Graph \(30 Minute' => 'îÅÄÅÌØÎÙÊ ÇÒÁÆÉË (ÓÒÅÄÎÅÅ ÚÁ 30 ÍÉÎÕÔ' ,
- '`Monthly\' Graph \(2 Hour' => 'íÅÓÑÞÎÙÊ ÇÒÁÆÉË (ÓÒÅÄÎÅÅ ÚÁ 2 ÞÁÓÁ',
- '`Yearly\' Graph \(1 Day' => 'çÏÄÏ×ÏÊ ÇÒÁÆÉË (ÓÒÅÄÎÅÅ ÚÁ 1 ÄÅÎØ',
- 'Incoming Traffic in (\S+) per Second' => '÷ÈÏÄÑÝÉÊ ÔÒÁÆÉË × $1 × ÓÅËÕÎÄÕ',
- 'Outgoing Traffic in (\S+) per Second' => 'éÓÈÏÄÑÝÉÊ ÔÒÁÆÉË × $1 × ÓÅËÕÎÄÕ',
- 'at which time (.*) had been up for(.*)' => '× ÜÔÏ ×ÒÅÍÑ $1 ÂÙÌÁ ×ËÌÀÞÅÎÁ $2',
- #'([kMG]?)([bB])/s' => '$1$1/ÓÅË',
- #'([kMG]?)([bB])/min' => '$1$2/ÍÉÎ',
- '([kMG]?)([bB])/h' => '$1$2/ÞÁÓ',
- 'Bits' => 'ÂÉÔÁÈ',
- 'Bytes' => 'ÂÁÊÔÁÈ',
- 'In' => '÷È',
- 'Out' => 'éÓÈ',
- 'Percentage' => 'ðÒÏÃÅÎÔÙ',
- 'Ported to OpenVMS Alpha by' => 'áÄÁÐÔÉÒÏ×ÁÎÏ ÄÌÑ OpenVMS Alpha',
- 'Ported to WindowsNT by' => 'áÄÁÐÔÉÒÏ×ÁÎÏ ÄÌÑ WindowsNT',
- 'and' => 'É',
- '^GREEN' => 'úåìåîùê',
- 'BLUE' => 'óéîéê',
- 'DARK GREEN' => 'ôåíîïúåìåîùê',
- 'MAGENTA' => 'æéïìåôï÷ùê',
- 'AMBER' => 'ñîôáòîùê'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => ' ÷ÏÓËÒÅÓÅÎØÅ', 'Sun' => '÷Ó',
- 'Monday' => ' ðÏÎÅÄÅÌØÎÉË', 'Mon' => 'ðÎ',
- 'Tuesday' => ' ÷ÔÏÒÎÉË', 'Tue' => '÷Ô',
- 'Wednesday' => ' óÒÅÄÁ', 'Wed' => 'óÒ',
- 'Thursday' => ' þÅÔ×ÅÒÇ', 'Thu' => 'þÔ',
- 'Friday' => ' ðÑÔÎÉÃÁ', 'Fri' => 'ðÔ',
- 'Saturday' => ' óÕÂÂÏÔÁ', 'Sat' => 'óÂ'
- );
-
-%month =
- (
- 'January' => 'ñÎ×ÁÒÑ', 'February' => 'æÅ×ÒÁÌÑ' , 'March' => 'íÁÒÔÁ',
- 'Jan' => 'ñÎ×', 'Feb' => 'æÅ×', 'Mar' => 'íÁÒ',
- 'April' => 'áÐÒÅÌÑ', 'May' => 'íÁÑ', 'June' => 'éÀÎÑ',
- 'Apr' => 'áÐÒ', 'May' => 'íÁÑ', 'Jun' => 'éÀÎ',
- 'July' => 'éÀÌÑ', 'August' => 'á×ÇÕÓÔÁ', 'September' => 'óÅÎÔÑÂÒÑ',
- 'Jul' => 'éÀÌ', 'Aug' => 'á×Ç', 'Sep' => 'óÅÎ',
- 'October' => 'ïËÔÑÂÒÑ', 'November' => 'îÏÑÂÒÑ', 'December' => 'äÅËÁÂÒÑ',
- 'Oct' => 'ïËÔ', 'Nov' => 'îÏÑ', 'Dec' => 'äÅË'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]."Ç. × ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# Russian1251 Code
-
-sub russian1251
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'windows-1251',
- 'Maximal 5 Minute Incoming Traffic' => 'Ìàêñèìàëüíûé âõîäÿùèé òðàôèê çà 5 ìèíóò',
- 'Maximal 5 Minute Outgoing Traffic' => 'Ìàêñèìàëüíûé èñõîäÿùèé òðàôèê çà 5 ìèíóò',
- 'the device' => 'óñòðîéñòâî',
- 'The statistics were last updated(.*)' => 'Âðåìÿ ïîñëåäíåãî îáíîâëåíèÿ: $1',
- ' Average\)' => ')',
- 'Average' => 'Â ñðåäíåì',
- 'Max' => 'Ìàêñèìàëüíî',
- 'Current' => 'Ñåé÷àñ',
- 'version' => 'âåðñèÿ',
- '`Daily\' Graph \((.*) Minute' => 'Ñóòî÷íûé ãðàôèê (ñðåäíåå çà $1 ìèíóò',
- '`Weekly\' Graph \(30 Minute' => 'Íåäåëüíûé ãðàôèê (ñðåäíåå çà 30 ìèíóò' ,
- '`Monthly\' Graph \(2 Hour' => 'Ìåñÿ÷íûé ãðàôèê (ñðåäíåå çà 2 ÷àñà',
- '`Yearly\' Graph \(1 Day' => 'Ãîäîâîé ãðàôèê (ñðåäíåå çà 1 äåíü',
- 'Incoming Traffic in (\S+) per Second' => 'Âõîäÿùèé òðàôèê â $1 â ñåêóíäó',
- 'Outgoing Traffic in (\S+) per Second' => 'Èñõîäÿùèé òðàôèê â $1 â ñåêóíäó',
- 'at which time <strong>(\S+)</strong> had been up for <strong>(\S+)</strong>' => 'âðåìÿ ïîñëå èíèöèàëèçàöèè óñòðîéñòâà <strong>$1</strong>: <strong>$2</strong>.',
- 'at which time <strong>(\S+)</strong> had been up for <strong>(\S+) day, (\S+)</strong>' => 'âðåìÿ ïîñëå èíèöèàëèçàöèè óñòðîéñòâà <strong>$1</strong>: <strong>$2 ñóòêè</strong>, <strong>$3</strong>.',
- 'at which time <strong>(\S+)</strong> had been up for <strong>(\S+) days, (\S+)</strong>' => 'âðåìÿ ïîñëå èíèöèàëèçàöèè óñòðîéñòâà <strong>$1</strong>: <strong>$2 ñóòîê</strong>, <strong>$3</strong>.',
- #'([kMG]?)([bB])/s' => '$1$1/ñåê',
- #'([kMG]?)([bB])/min' => '$1$2/ìèí',
- '([kMG]?)([bB])/h' => '$1$2/÷àñ',
- 'Bits' => 'áèòàõ',
- 'Bytes' => 'áàéòàõ',
- 'In' => 'Âõ',
- 'Out' => 'Èñõ',
- 'Percentage' => 'Ïðîöåíòû',
- 'Ported to OpenVMS Alpha by' => 'Àäàïòèðîâàíî äëÿ OpenVMS Alpha',
- 'Ported to WindowsNT by' => 'Àäàïòèðîâàíî äëÿ WindowsNT',
- 'and' => 'è',
- '^GREEN' => 'ÇÅËÅÍÛÉ',
- 'BLUE' => 'ÑÈÍÈÉ',
- 'DARK GREEN' => 'ÒÅÌÍÎÇÅËÅÍÛÉ',
- 'MAGENTA' => 'ÔÈÎËÅÒÎÂÛÉ',
- 'AMBER' => 'ßÍÒÀÐÍÛÉ'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => ' Âîñêðåñåíüå', 'Sun' => 'Âñ',
- 'Monday' => ' Ïîíåäåëüíèê', 'Mon' => 'Ïí',
- 'Tuesday' => ' Âòîðíèê', 'Tue' => 'Âò',
- 'Wednesday' => ' Ñðåäà', 'Wed' => 'Ñð',
- 'Thursday' => ' ×åòâåðã', 'Thu' => '×ò',
- 'Friday' => ' Ïÿòíèöà', 'Fri' => 'Ïò',
- 'Saturday' => ' Ñóááîòà', 'Sat' => 'Ñá'
- );
-
-%month =
- (
- 'January' => 'ßíâàðÿ', 'February' => 'Ôåâðàëÿ' , 'March' => 'Ìàðòà',
- 'Jan' => 'ßíâ', 'Feb' => 'Ôåâ', 'Mar' => 'Ìàð',
- 'April' => 'Àïðåëÿ', 'May' => 'Ìàÿ', 'June' => 'Èþíÿ',
- 'Apr' => 'Àïð', 'May' => 'Ìàÿ', 'Jun' => 'Èþí',
- 'July' => 'Èþëÿ', 'August' => 'Àâãóñòà', 'September' => 'Ñåíòÿáðÿ',
- 'Jul' => 'Èþë', 'Aug' => 'Àâã', 'Sep' => 'Ñåí',
- 'October' => 'Îêòÿáðÿ', 'November' => 'Íîÿáðÿ', 'December' => 'Äåêàáðÿ',
- 'Oct' => 'Îêò', 'Nov' => 'Íîÿ', 'Dec' => 'Äåê'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]."ã. â ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-# Serbian
-
-sub serbian
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'windows-1250',
- 'Maximal 5 Minute Incoming Traffic' => 'Najveæi 5 minutni ulazni saobraæaj',
- 'Maximal 5 Minute Outgoing Traffic' => 'Najveæi 5 minutni izlazni saobraæaj',
- 'the device' => 'uredjaj',
- 'The statistics were last updated(.*)' => 'Poslednje ažuriranje podataka:$1',
- ' Average\)' => ' prosek)',
- 'Average' => 'Proseèni',
- 'Max' => 'Maksimalni',
- 'Current' => 'Trenutni',
- 'version' => 'verzija',
- '`Daily\' Graph \((.*) Minute' => 'Dnevni graf ($1 minutni ',
- '`Weekly\' Graph \(30 Minute' => 'Nedeljni graf (30 minutni ' ,
- '`Monthly\' Graph \(2 Hour' => 'Meseèni graf (2 sata ',
- '`Yearly\' Graph \(1 Day' => 'Godišnji graf (1 dnevni ',
- 'Incoming Traffic in (\S+) per Second' => 'Ulazni saobraæaj - $1 u sekundi.',
- 'Outgoing Traffic in (\S+) per Second' => 'Izlazni saobraæaj - $1 u sekundi.',
- 'Incoming Traffic in (\S+) per Minute' => 'Ulazni saobraæaj - $1 u minutu',
- 'Outgoing Traffic in (\S+) per Minute' => 'Izlazni saobraæaj - $1 u minutu',
- 'Incoming Traffic in (\S+) per Hour' => 'Ulazni saobraæaj - $1 na sat',
- 'Outgoing Traffic in (\S+) per Hour' => 'Izlazni saobraæaj - $1 na sat',
- 'at which time (.*) had been up for(.*)' => 'Vreme neprekidnog rada sistema $1 : $2',
- #'([kMG]?)([bB])/s' => '\$1\$2/s',
- #'([kMG]?)([bB])/min' => '\$1\$2/min',
- #'([kMG]?)([bB])/h' => '$1$2/h',
- 'Bits' => 'Bita',
- 'Bytes' => 'Bajta',
- 'In' => 'Ulaz',
- 'Out' => 'Izlaz',
- 'Percentage' => 'Procenat',
- 'Ported to OpenVMS Alpha by' => 'Na OpenVMS portovao',
- 'Ported to WindowsNT by' => 'Na WindowsNT portovao',
- 'and' => 'i',
- '^GREEN' => 'Zeleno',
- 'BLUE' => 'Plavo',
- 'DARK GREEN' => 'Tamnozeleno',
- 'MAGENTA' => 'Ljubièasto',
- 'AMBER' => 'Narandžasto'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Nedelja', 'Sun' => 'Ned',
- 'Monday' => 'Ponedeljak', 'Mon' => 'Pon',
- 'Tuesday' => 'Utorak', 'Tue' => 'Uto',
- 'Wednesday' => 'Sreda', 'Wed' => 'Sre',
- 'Thursday' => 'Èetvrtak', 'Thu' => 'Èet',
- 'Friday' => 'Petak', 'Fri' => 'Pet',
- 'Saturday' => 'Subota', 'Sat' => 'Sub'
- );
-
-%month =
- (
- 'January' => 'januar', 'February' => 'februar', 'March' => 'mart',
- 'Jan' => 'Jan', 'Feb' => 'Feb', 'Mar' => 'Mar',
- 'April' => 'april', 'May' => 'maj', 'June' => 'jun',
- 'Apr' => 'Apr', 'May' => 'Maj', 'Jun' => 'Jun',
- 'July' => 'jul', 'August' => 'avgust', 'September' => 'septembar',
- 'Jul' => 'Jul', 'Aug' => 'Avg', 'Sep' => 'Sep',
- 'October' => 'oktobar','November' => 'novembar','December' => 'decembar',
- 'Oct' => 'Okt', 'Nov' => 'Nov', 'Dec' => 'Dec'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0].",".$quux[1]." ";
- };
- return "$wday{$foo[0]} $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-}
-#
-# Slovak
-
-sub slovak
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'iso-8859-2',
- 'Maximal 5 Minute Incoming Traffic' => 'Maximálny 5 minútový prichádzajúci tok',
- 'Maximal 5 Minute Outgoing Traffic' => 'Maximálny 5 minútový odchádzajúci tok',
- 'the device' => 'zariadenie',
- 'The statistics were last updated(.*)' => 'Posledná aktualizácia ¹tatistík:$1',
- ' Average\)' => ' priemer)',
- 'Average' => 'Priem.',
- 'Max' => 'Max.',
- 'Current' => 'Akt.',
- 'version' => 'verzia',
- '`Daily\' Graph \((.*) Minute' => 'Denný graf ($1 minútový',
- '`Weekly\' Graph \(30 Minute' => 'Tý¾denný graf (30 minútový' ,
- '`Monthly\' Graph \(2 Hour' => 'Mesaèný graf (2 hodinový',
- '`Yearly\' Graph \(1 Day' => 'Roèný graf (1 denný',
- 'Incoming Traffic in (\S+) per Second' => 'Prichádzajúci tok v $1 za sekundu.',
- 'Outgoing Traffic in (\S+) per Second' => 'Odchádzajúci tok v $1 za sekundu.',
- 'at which time (.*) had been up for(.*)' => 'Èas od posledného re¹tartu $1 : $2',
- #'([kMG]?)([bB])/s' => '\$1\$2/s',
- #'([kMG]?)([bB])/min' => '\$1\$2/min',
- #'([kMG]?)([bB])/h' => '$1$2/h',
- 'Bits' => 'bitoch',
- 'Bytes' => 'bytoch',
- #'&nbsp;In:</FONT>' => '&nbsp;In:</FONT>',
- #'&nbsp;Out:</FONT>' => '&nbsp;Out:</FONT>',
- 'Percentage' => 'Perc.',
- 'Ported to OpenVMS Alpha by' => 'Na OpenVMS portoval',
- 'Ported to WindowsNT by' => 'Na WindowsNT portoval',
- 'and' => 'a',
- '^GREEN' => 'Zelená',
- 'BLUE' => 'Modrá',
- 'DARK GREEN' => 'Tmavozelená',
- 'MAGENTA' => 'Fialová',
- 'AMBER' => '®ltá'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Nedeµa', 'Sun' => 'Ne',
- 'Monday' => 'Pondelok', 'Mon' => 'Po',
- 'Tuesday' => 'Utorok', 'Tue' => 'Ut',
- 'Wednesday' => 'Streda', 'Wed' => 'St',
- 'Thursday' => '©tvrtok', 'Thu' => '©t',
- 'Friday' => 'Piatok', 'Fri' => 'Pi',
- 'Saturday' => 'Sobota', 'Sat' => 'So'
- );
-
-%month =
- (
- 'January' => 'Január', 'February' => 'Február', 'March' => 'Marec',
- 'Jan' => 'Január', 'Feb' => 'Február', 'Mar' => 'Marec',
- 'April' => 'Apríl', 'May' => 'Máj', 'June' => 'Jún',
- 'Apr' => 'Apríl', 'May' => 'Máj', 'Jun' => 'Jún',
- 'July' => 'Júl', 'August' => 'August', 'September' => 'September',
- 'Jul' => 'Júl', 'Aug' => 'August', 'Sep' => 'September',
- 'October' => 'Október','November' => 'November','December' => 'December',
- 'Oct' => 'Október','Nov' => 'November','Dec' => 'December'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0].",".$quux[1]." hod.";
- };
- return "$wday{$foo[0]} $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-}
-#
-# Slovenian
-
-sub slovenian
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'windows-1250',
- 'Maximal 5 Minute Incoming Traffic' => 'Najvecji petminutni vhodni promet',
- 'Maximal 5 Minute Outgoing Traffic' => 'Najvecji petminutni izhodni promet',
- 'the device' => 'naprava',
- 'The statistics were last updated(.*)' => 'Zadnja posodobitev podatkov:$1',
- ' Average\)' => ' povprecje)',
- 'Average' => 'Povprecje',
- 'Max' => 'Maksimalno',
- 'Current' => 'Trenutno',
- 'version' => 'verzija',
- '`Daily\' Graph \((.*) Minute' => 'Dnevni graf ($1 min.',
- '`Weekly\' Graph \(30 Minute' => 'Tedenski graf (30 min.' ,
- '`Monthly\' Graph \(2 Hour' => 'Mesecni graf (2 urno',
- '`Yearly\' Graph \(1 Day' => 'Letni graf (1 dnevno',
- 'Incoming Traffic in (\S+) per Second' => 'Vhodni promet v $1 na sekundo.',
- 'Outgoing Traffic in (\S+) per Second' => 'Izhodni promet v $1 na sekundo.',
- 'at which time (.*) had been up for(.*)' => 'Cas od zadnjega restarta sistema $1 : $2',
- #'([kMG]?)([bB])/s' => '\$1\$2/s',
- #'([kMG]?)([bB])/min' => '\$1\$2/min',
- #'([kMG]?)([bB])/h' => '$1$2/h',
- 'Bits' => 'bitov',
- 'Bytes' => 'bytov',
- 'In' => 'Vhod',
- 'Out' => 'Izhod',
- 'Percentage' => 'Proc.',
- 'Ported to OpenVMS Alpha by' => 'Na OpenVMS portiral',
- 'Ported to WindowsNT by' => 'Na WindowsNT portiral',
- 'and' => 'in',
- '^GREEN' => 'Zeleno',
- 'BLUE' => 'Modro',
- 'DARK GREEN' => 'Temnozeleno',
- 'MAGENTA' => 'Vijolicasto',
- 'AMBER' => 'Oranzno'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Nedelja', 'Sun' => 'Ne',
- 'Monday' => 'Ponedeljek', 'Mon' => 'Po',
- 'Tuesday' => 'Torek', 'Tue' => 'To',
- 'Wednesday' => 'Sreda', 'Wed' => 'Sr',
- 'Thursday' => 'Cetrtek', 'Thu' => 'Ce',
- 'Friday' => 'Petek', 'Fri' => 'Po',
- 'Saturday' => 'Sobota', 'Sat' => 'So'
- );
-
-%month =
- (
- 'January' => 'Januar', 'February' => 'Februar', 'March' => 'Marec',
- 'Jan' => 'Jan', 'Feb' => 'Feb', 'Mar' => 'Mar',
- 'April' => 'April', 'May' => 'Maj', 'June' => 'Jun',
- 'Apr' => 'Apr', 'May' => 'Maj', 'Jun' => 'Jun',
- 'July' => 'Julij', 'August' => 'Avgust', 'September' => 'September',
- 'Jul' => 'Jul', 'Aug' => 'Avg', 'Sep' => 'Sep',
- 'October' => 'Oktober','November' => 'November','December' => 'December',
- 'Oct' => 'Okt','Nov' => 'Nov','Dec' => 'Dec'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0].",".$quux[1]." ";
- };
- return "$wday{$foo[0]} $foo[1]. $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-}
-#
-# Spanish
-
-sub spanish
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
-
- %translations =
- (
- #'iso-8859-1' => 'iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Tr&aacute;fico entrante m&aacute;ximo en 5 minutos',
- 'Maximal 5 Minute Outgoing Traffic' => 'Tr&aacute;fico saliente m&aacute;ximo en 5 minutos',
- 'the device' => 'el dispositivo',
- 'The statistics were last updated(.*)' => 'Estad&iacute;sticas actualizadas el $1',
- ' Average\)' => ' Promedio)',
- 'Average' => 'Promedio',
- 'Max' => 'M&aacute;x',
- 'Current' => 'Actual',
- 'version' => 'version',
- '`Daily\' Graph \((.*) Minute' => 'Gr&aacute;fico diario ($1 minutos :',
- '`Weekly\' Graph \(30 Minute' => 'Gr&aacute;fico semanal (30 minutos :' ,
- '`Monthly\' Graph \(2 Hour' => 'Gr&aacute;fico mensual (2 horas :',
- '`Yearly\' Graph \(1 Day' => 'Gr&aacute;fico anual (1 d&iacute;a :',
- 'Incoming Traffic in (\S+) per Second' => 'Tr&aacute;fico entrante en $1 por segundo',
- 'Outgoing Traffic in (\S+) per Second' => 'Tr&aacute;fico saliente en $1 por segundo',
- 'at which time (.*) had been up for(.*)' => '$1 ha estado funcionando durante $2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- # '([kMG]?)([bB])/h' => '$1$2/t',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes'
- 'In' => 'Entrante:',
- 'Out' => 'Saliente:',
- 'Percentage' => 'Porcentaje:',
- 'Ported to OpenVMS Alpha by' => 'Portado a OpenVMS Alpha por',
- 'Ported to WindowsNT by' => 'Portado a WindowsNT por',
- 'and' => 'y',
- '^GREEN' => 'VERDE',
- 'BLUE' => 'AZUL',
- 'DARK GREEN' => 'VERDE OSCURO',
- 'MAGENTA' => 'MAGENTA',
- 'AMBER' => 'AMBAR'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Domingo', 'Sun' => 'Dom',
- 'Monday' => 'Lunes', 'Mon' => 'Lun',
- 'Tuesday' => 'Martes', 'Tue' => 'Mar',
- 'Wednesday' => 'Mi&eacute;rcoles','Wed' => 'Mi&eacute;',
- 'Thursday' => 'Jueves', 'Thu' => 'Jue',
- 'Friday' => 'Viernes', 'Fri' => 'Vie',
- 'Saturday' => 'S&aacute;bado', 'Sat' => 'Sab'
- );
-
-%month =
- (
- 'January' => 'Enero', 'February' => 'Febrero' , 'March' => 'Marzo',
- 'Jan' => 'Ene', 'Feb' => 'Feb', 'Mar' => 'Mar',
- 'April' => 'Abril', 'May' => 'Mayo', 'June' => 'Junio',
- 'Apr' => 'Abr', 'May' => 'Mai', 'Jun' => 'Jun',
- 'July' => 'Julio', 'August' => 'Agosto', 'September' => 'Setiembre',
- 'Jul' => 'Jul', 'Aug' => 'Ago', 'Sep' => 'Set',
- 'October' => 'Octubre', 'November' => 'Noviembre', 'December' => 'Diciembre',
- 'Oct' => 'Oct', 'Nov' => 'Nov', 'Dec' => 'Dic'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." a las ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] de $month{$foo[2]} de $foo[3]";
- };
- return $string;
-}
-# Swedish
-
-sub swedish
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- #'charset=iso-8859-1' => 'charset=iso-8859-1',
- 'Maximal 5 Minute Incoming Traffic' => 'Maximalt inkommande trafik i 5 minuter',
- 'Maximal 5 Minute Outgoing Traffic' => 'Maximalt utg&aring;ende trafik i 5 minuter',
- 'the device' => 'enheten',
- 'The statistics were last updated(.*)' => 'Statistiken blev senast uppdaterad$1',
- ' Average\)' => ')',
- 'Average' => 'Medel',
- #'Max' => 'Max',
- 'Current' => 'Senaste',
- 'version' => 'version',
- '`Daily\' Graph \((.*) Minute' => 'Daglig graf (samplingsintervall $1 minut(er)',
- '`Weekly\' Graph \(30 Minute' => 'Veckovis graf (medelvärde per 30 minuter' ,
- '`Monthly\' Graph \(2 Hour' => 'M&aring;natlig graf (medelvärde per 2 timmar',
- '`Yearly\' Graph \(1 Day' => '&Aring;rlig graf (medelvärde per dygn',
- 'Incoming Traffic in (\S+) per Second' => 'Inkommande trafik i $1 per sekund',
- 'Outgoing Traffic in (\S+) per Second' => 'Utgående trafik i $1 per sekund',
- 'at which time (.*) had been up for(.*)' => 'då $1 varit ig&aring;ng i$2',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- '([kMG]?)([bB])/h' => '$1$2/t',
- # 'Bits' => 'Bits',
- # 'Bytes' => 'Bytes',
- #'In' => 'In',
- 'Out' => 'Ut',
- 'Percentage' => 'Procent',
- 'Ported to OpenVMS Alpha by' => 'Portad till OpenVMS av',
- 'Ported to WindowsNT by' => 'Portad till WindowsNT av',
- 'and' => 'och',
- '^GREEN' => 'GR&Ouml;N',
- 'BLUE' => 'BL&Aring;',
- 'DARK GREEN' => 'M&Ouml;RKGR&Ouml;N',
- 'MAGENTA' => 'MANGENTA',
- 'AMBER' => 'BRUN',
-
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 's&ouml;ndag', 'Sun' => 's&ouml;n',
- 'Monday' => 'm&aring;ndag', 'Mon' => 'm&aring;n',
- 'Tuesday' => 'tisdag', 'Tue' => 'tis',
- 'Wednesday' => 'onsdag', 'Wed' => 'ons',
- 'Thursday' => 'torsdag', 'Thu' => 'tor',
- 'Friday' => 'fredag', 'Fri' => 'fre',
- 'Saturday' => 'l&ouml;rdag', 'Sat' => 'l&ouml;r'
-
- );
-
-%month =
- (
- 'January' => 'januari', 'February' => 'februari', 'March' => 'mars',
- 'Jan' => 'jan', 'Feb' => 'feb', 'Mar' => 'mar',
- 'April' => 'april', 'May' => 'maj', 'June' => 'juni',
- 'Apr' => 'apr', 'May' => 'maj', 'Jun' => 'jun',
- 'July' => 'juli', 'August' => 'augusti', 'September' => 'september',
- 'Jul' => 'jul', 'Aug' => 'aug', 'Sep' => 'sep',
- 'October' => 'oktober', 'November' => 'november', 'December' => 'december',
- 'Oct' => 'okt', 'Nov' => 'nov', 'Dec' => 'dec'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." kl.".$quux[1];
- };
- return "$wday{$foo[0]} den $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
- };
-# Turkish
-
-sub turkish
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
-
- %translations =
- (
- 'iso-8859-1' => 'iso-8859-9',
- 'Maximal 5 Minute Incoming Traffic' => '5 dakika için en yüksek giriþ trafiði',
- 'Maximal 5 Minute Outgoing Traffic' => '5 dakika için en yüksek çýkýþ trafiði',
- 'the device' => 'aygýt',
- 'The statistics were last updated(.*)' => 'Ýstatistiklerin en son güncellenmesi $1',
- ' Average\)' => ' Ortalama)',
- 'Average' => 'Ortalama',
- 'Max' => 'EnYüksek;x',
- 'Current' => 'ÞuAnki',
- 'version' => 'sürüm',
- '`Daily\' Graph \((.*) Minute' => 'Günlük ($1 dakika :',
- '`Weekly\' Graph \(30 Minute' => 'Haftalýk (30 dakika :' ,
- '`Monthly\' Graph \(2 Hour' => 'Aylýk (2 saat :',
- '`Yearly\' Graph \(1 Day' => 'Yýllýk (1 gün :',
- 'Incoming Traffic in (\S+) per Second' => '$1 deki saniyelik giriþ trafiði',
- 'Outgoing Traffic in (\S+) per Second' => '$1 deki saniyelik çýkýþ trafiði',
- 'at which time (.*) had been up for(.*)' => '$1 Ne zamandan $2 beri ayakta',
- # '([kMG]?)([bB])/s' => '\$1\$2/s',
- # '([kMG]?)([bB])/min' => '\$1\$2/min',
- # '([kMG]?)([bB])/h' => '$1$2/t',
- # 'Bits' => 'Bit',
- # 'Bytes' => 'Byte'
- 'In' => 'Giriþ',
- 'Out' => 'Çýkýþ',
- 'Percentage' => 'Yüzge',
- 'Ported to OpenVMS Alpha by' => 'OpenVMS Alpha ya uyarlayan',
- 'Ported to WindowsNT by' => 'WindowsNT ye uyarlayan',
- 'and' => 've',
- '^GREEN' => 'YEÞÝL',
- 'BLUE' => 'MAVÝ',
- 'DARK GREEN' => 'KOYU YEÞÝL',
- 'MAGENTA' => 'MACENTA',
- 'AMBER' => 'AMBER'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => 'Pazar', 'Pzr' => 'Dom',
- 'Monday' => 'Pazartesi', 'Pzt' => 'Lun',
- 'Tuesday' => 'Salý', 'Sal' => 'Mar',
- 'Wednesday' => 'Çarþamba', 'Çrþ' => 'Mi&eacute;',
- 'Thursday' => 'Perþembe', 'Prþ' => 'Jue',
- 'Friday' => 'Cuma', 'Cum' => 'Vie',
- 'Saturday' => 'Cumartesi', 'Cmr' => 'Sab'
- );
-
-%month =
- (
- 'January' => 'Ocak', 'February' => 'Þubat', 'March' => 'Mart',
- 'Jan' => 'Ock', 'Feb' => 'Þub', 'Mar' => 'Mar',
- 'April' => 'Nisan', 'May' => 'Mayýs', 'June' => 'Haziran',
- 'Apr' => 'Nis', 'May' => 'May', 'Jun' => 'Hzr',
- 'July' => 'Temmuz', 'August' => 'Agustos', 'September' => 'Eylül',
- 'Jul' => 'Tem', 'Aug' => 'Agu', 'Sep' => 'Eyl',
- 'October' => 'Ekim', 'November' => 'Kasým', 'December' => 'Aralýk',
- 'Oct' => 'Ekm', 'Nov' => 'Kas', 'Dec' => 'Ara'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]." a las ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] de $month{$foo[2]} de $foo[3]";
- };
-}
-
-
-# Ukrainian
-
-sub ukrainian
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
-
- # regexp => replacement string NOTE does not use autovars $1,$2...
- # charset=iso-2022-jp
-
- %translations =
- (
- 'iso-8859-1' => 'koi8-u',
- 'Maximal 5 Minute Incoming Traffic' => 'íÁËÓÉÍÁÌØÎÉÊ ×ȦÄÎÉÊ ÔÒÁÆ¦Ë ÚÁ 5 È×ÉÌÉÎ',
- 'Maximal 5 Minute Outgoing Traffic' => 'íÁËÓÉÍÁÌØÎÉÊ ×ÉȦÄÎÉÊ ÔÒÁÆ¦Ë ÚÁ 5 È×ÉÌÉÎ',
- 'the device' => 'ÐÒÉÓÔÒ¦Ê',
- 'The statistics were last updated(.*)' => 'ïÓÔÁÎΤ ÏÎÏ×ÌÅÎÎÑ ÓÔÁÔÉÓÔÉËÉ ÂÕÌÏ ×: $1',
- ' Average\)' => ')',
- 'Average' => 'óÅÒÅÄΦÊ',
- 'Max' => 'íÁËÓ.',
- 'Current' => 'ðÏÔÏÞÎÉÊ',
- 'version' => '×ÅÒÓ¦Ñ',
- '`Daily\' Graph \((.*) Minute' => 'äÏÂÏ×ÉÊ ÔÒÁÆ¦Ë (ÓÅÒÅÄΤ ÚÁ $1 È×ÉÌÉÎ',
- '`Weekly\' Graph \(30 Minute' => 'ôÉÖÎÅ×ÉÊ ÔÒÁÆ¦Ë (ÓÅÒÅÄΤ ÚÁ 30 È×ÉÌÉÎ' ,
- '`Monthly\' Graph \(2 Hour' => 'í¦ÓÑÞÎÉÊ ÔÒÁÆ¦Ë (ÓÅÒÅÄΤ ÚÁ 2 ÇÏÄÉÎÉ',
- '`Yearly\' Graph \(1 Day' => 'ò¦ÞÎÉÊ ÔÒÁÆ¦Ë (ÓÅÒÅÄΤ ÚÁ 1 ÄÅÎØ',
- 'Incoming Traffic in (\S+) per Second' => '÷ȦÄÎÉÊ ÔÒÁÆ¦Ë × $1 ÚÁ ÓÅËÕÎÄÕ',
- 'Outgoing Traffic in (\S+) per Second' => '÷ÉȦÄÎÉÊ ÔÒÁÆ¦Ë × $1 ÚÁ ÓÅËÕÎÄÕ',
- 'at which time (.*) had been up for(.*)' => '$1 ÂÕÌÏ ×ËÌÀÞÅÎÏ Ï $2',
- #'([kMG]?)([bB])/s' => '$1$1/Ó',
- #'([kMG]?)([bB])/min' => '$1$2/È×',
- '([kMG]?)([bB])/h' => '$1$2/ÇÏÄ',
- 'Bits' => '¦ÔÁÈ',
- 'Bytes' => 'ÂÁÊÔÁÈ',
- 'In' => '÷È',
- 'Out' => '÷ÉÈ',
- 'Percentage' => '÷¦ÄÓÏÔËÉ',
- 'Ported to OpenVMS Alpha by' => 'áÄÁÐÔÏ×ÁÎÏ ÄÌÑ OpenVMS Alpha',
- 'Ported to WindowsNT by' => 'áÄÁÐÔÏ×ÁÎÏ ÄÌÑ WindowsNT',
- 'and' => '¦',
- '^GREEN' => 'úåìåîéê',
- 'BLUE' => 'óéî¶ê',
- 'DARK GREEN' => 'ôåíîïúåìåîéê',
- 'MAGENTA' => 'æ¶ïìåôï÷éê',
- 'AMBER' => 'âõòûôéîï÷éê'
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => ' îÅĦÌÀ', 'Sun' => 'îÄ',
- 'Monday' => ' ðÏÎÅĦÌÏË', 'Mon' => 'ðÎ',
- 'Tuesday' => ' ÷¦×ÔÏÒÏË', 'Tue' => '÷×',
- 'Wednesday' => ' óÅÒÅÄÕ', 'Wed' => 'óÒ',
- 'Thursday' => ' þÅÔ×ÅÒ', 'Thu' => 'þÔ',
- 'Friday' => ' ð\'ÑÔÎÉÃÀ', 'Fri' => 'ðÔ',
- 'Saturday' => ' óÕÂÏÔÕ', 'Sat' => 'óÂ'
- );
-
-%month =
- (
- 'January' => 'ó¦ÞÎÑ', 'February' => 'ìÀÔÏÇÏ' , 'March' => 'âÅÒÅÚÎÑ',
- 'Jan' => 'ó¦Þ', 'Feb' => 'ìÀÔ', 'Mar' => 'âÅÒ',
- 'April' => 'ëצÔÎÑ', 'May' => 'ôÒÁ×ÎÑ', 'June' => 'þÅÒ×ÎÑ',
- 'Apr' => 'ëצ', 'May' => 'ôÒÁ', 'Jun' => 'þÅÒ',
- 'July' => 'ìÉÐÎÑ', 'August' => 'óÅÒÐÎÑ', 'September' => '÷ÅÒÅÓÎÑ',
- 'Jul' => 'ìÉÐ', 'Aug' => 'óÅÒ', 'Sep' => '÷ÅÒ',
- 'October' => 'öÏ×ÔÎÑ', 'November' => 'ìÉÓÔÏÐÁÄÁ', 'December' => 'çÒÕÄÎÑ',
- 'Oct' => 'öÏ×', 'Nov' => 'ìÉÓ', 'Dec' => 'çÒÕ'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]."Ò. Ï ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-
-
-# Ukrainian1251 - windowze encoding
-
-sub ukrainian1251
-{
- my $string = shift;
-return "" unless defined $string;
- my(%translations,%month,%wday);
-
- my($i,$j);
- my(@dollar,@quux,@foo);
-
- %translations =
- (
- 'iso-8859-1' => 'windows-1251',
- 'Maximal 5 Minute Incoming Traffic' => 'Ìàêñèìàëüíèé âõ³äíèé òðàô³ê çà 5 õâèëèí',
- 'Maximal 5 Minute Outgoing Traffic' => 'Ìàêñèìàëüíèé âèõ³äíèé òðàô³ê çà 5 õâèëèí',
- 'the device' => 'ïðèñòð³é',
- 'The statistics were last updated(.*)' => 'Îñòàííº îíîâëåííÿ ñòàòèñòèêè: $1',
- ' Average\)' => ')',
- 'Average' => 'Ñåðåäí³é',
- 'Max' => 'Ìàêñèìàëüíèé',
- 'Current' => 'Ïîòî÷íèé',
- 'version' => 'âåðñ³ÿ',
- '`Daily\' Graph \((.*) Minute' => 'Äåííèé òðàô³ê (â ñåðåäíüîìó çà $1 õâèëèí',
- '`Weekly\' Graph \(30 Minute' => 'Òèæíåâèé òðàô³ê (â ñåðåäíüîìó çà 30 õâèëèí' ,
- '`Monthly\' Graph \(2 Hour' => '̳ñÿ÷íèé òðàô³ê (â ñåðåäíüîìó çà äâi ãîäèíè',
- '`Yearly\' Graph \(1 Day' => 'г÷íèé òðàô³ê (â ñåðåäíüîìó çà îäèí äåíü',
- 'Incoming Traffic in (\S+) per Second' => 'Âõ³äíèé òðàô³ê â $1 çà ñåêóíäó',
- 'Outgoing Traffic in (\S+) per Second' => 'Âèõ³äíèé òðàô³ê â $1 çà ñåêóíäó',
- 'at which time (.*) had been up for(.*)' => '$1 â 䳿: $2',
- '([kMG]?)([bB])/s' => '$1$1/ñåê',
- '([kMG]?)([bB])/min' => '$1$2/õâ',
- '([kMG]?)([bB])/h' => '$1$2/ãîä',
- '([bB])/s' => '$1/ñåê',
- '([bB])/min' => '$1/õâ',
- '([bB])/h' => '$1/ãîä',
- 'Bits' => 'á³òàõ',
- 'Bytes' => 'áàéòàõ',
- 'In' => 'âõ³ä',
- 'Out' => 'âèõ³ä',
- 'Percentage' => '³äñîòîê',
- 'Ported to OpenVMS Alpha by' => 'Ïîðòîâàíî íà OpenVMS Alpha',
- 'Ported to WindowsNT by' => 'Ïîðòîâàíî íà WindowsNT',
- 'and' => 'òà',
- 'RED' => '×ÅÐÂÎÍÈÉ',
- '^GREEN' => 'ÇÅËÅÍÈÉ',
- 'BLUE' => 'ÑÈͲÉ',
- 'DARK GREEN' => 'ÒÅÌÍÎÇÅËÅÍÈÉ',
- 'MAGENTA' => 'Ô²ÎËÅÒÎÂÈÉ',
- 'AMBER' => 'ÁÓÐØÒÈÍÎÂÈÉ',
- );
-
-# maybe expansions with replacement of whitespace would be more appropriate
-
-foreach $i (keys %translations)
-{
- my $trans = $translations{$i};
- $trans =~ s/\|/\|/;
- return $string if eval " \$string =~ s|\${i}|${trans}| ";
-};
-
-%wday =
- (
- 'Sunday' => ' Íåä³ëÿ', 'Sun' => 'Íä',
- 'Monday' => ' Ïîíåä³ëîê', 'Mon' => 'Ïí',
- 'Tuesday' => ' ³âòîðîê', 'Tue' => 'Âò',
- 'Wednesday' => ' Ñåðåäà', 'Wed' => 'Ñð',
- 'Thursday' => ' ×åòâåð', 'Thu' => '×ò',
- 'Friday' => ' Ï\'ÿòíèöÿ', 'Fri' => 'Ïò',
- 'Saturday' => ' Ñóáîòà', 'Sat' => 'Ñá'
- );
-
-%month =
- (
- 'January' => 'ѳ÷íÿ', 'February' => 'Ëþòîãî' , 'March' => 'Áåðåçíÿ',
- 'Jan' => 'ѳ÷', 'Feb' => 'Ëþò', 'Mar' => 'Áåð',
- 'April' => 'Êâ³òíÿ', 'May' => 'Òðàâíÿ', 'June' => '×åðâíÿ',
- 'Apr' => 'Êâò', 'May' => 'Òðâ', 'Jun' => '×åð',
- 'July' => 'Ëèïíÿ', 'August' => 'Ñåðïíÿ', 'September' => 'Âåðåñíÿ',
- 'Jul' => 'Ëèï', 'Aug' => 'Ñåð', 'Sep' => 'Âåð',
- 'October' => 'Æîâòíÿ', 'November' => 'Ëèñòîïàäà', 'December' => 'Ãðóäíÿ',
- 'Oct' => 'Æîâ', 'Nov' => 'Ëèñ', 'Dec' => 'Ãðä'
- );
-
- @foo=($string=~/(\S+),\s+(\S+)\s+(\S+)(.*)/);
- if($foo[0] && $wday{$foo[0]} && $foo[2] && $month{$foo[2]} )
- {
- if($foo[3]=~(/(.*)at(.*)/))
- {
- @quux=split(/at/,$foo[3]);
- $foo[3]=$quux[0]."ð. ".$quux[1];
- };
- return "$wday{$foo[0]} $foo[1] $month{$foo[2]} $foo[3]";
- };
-
-#
-# handle two different time/date formats:
-# return "$wday, $mday $month ".($year+1900)." at $hour:$min";
-# return "$wday, $mday $month ".($year+1900)." $hour:$min:$sec GMT";
-#
-
-# handle nontranslated strings which ought to be translated
-# print STDERR "$_\n" or print DEBUG "not translated $_";
-# but then again we might not want/need to translate all strings
-
- return $string;
-
-};
-