home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / HINFO.pm < prev    next >
Encoding:
Perl POD Document  |  2004-01-04  |  2.1 KB  |  115 lines

  1. package Net::DNS::RR::HINFO;
  2. #
  3. # $Id: HINFO.pm,v 2.101 2004/01/04 04:31:10 ctriv Exp $
  4. #
  5. use strict;
  6. use vars qw(@ISA $VERSION);
  7.  
  8. use Net::DNS::Packet;
  9.  
  10. @ISA     = qw(Net::DNS::RR);
  11. $VERSION = (qw$Revision: 2.101 $)[1];
  12.  
  13. sub new {
  14.     my ($class, $self, $data, $offset) = @_;
  15.  
  16.     if ($self->{"rdlength"} > 0) {
  17.         my ($cpu, $os, $len);
  18.  
  19.         ($len) = unpack("\@$offset C", $$data);
  20.         ++$offset;
  21.         $cpu = substr($$data, $offset, $len);
  22.         $offset += $len;
  23.  
  24.         ($len) = unpack("\@$offset C", $$data);
  25.         ++$offset;
  26.         $os = substr($$data, $offset, $len);
  27.         $offset += $len;
  28.  
  29.         $self->{"cpu"} = $cpu;
  30.         $self->{"os"}  = $os;
  31.     }
  32.  
  33.     return bless $self, $class;
  34. }
  35.  
  36. sub new_from_string {
  37.     my ($class, $self, $string) = @_;
  38.  
  39.     if ($string && $string =~ /^["'](.*?)["']\s+["'](.*?)["']$/) {
  40.         $self->{"cpu"} = $1;
  41.         $self->{"os"}  = $2;
  42.     }
  43.  
  44.     return bless $self, $class;
  45. }
  46.  
  47. sub rdatastr {
  48.     my $self = shift;
  49.  
  50.     return $self->{"cpu"}
  51.            ? qq("$self->{cpu}" "$self->{os}")
  52.            : '';
  53. }
  54.  
  55. sub rr_rdata {
  56.     my $self = shift;
  57.     my $rdata = "";
  58.  
  59.     if (exists $self->{"cpu"}) {
  60.         $rdata .= pack("C", length $self->{"cpu"});
  61.         $rdata .= $self->{"cpu"};
  62.  
  63.         $rdata .= pack("C", length $self->{"os"});
  64.         $rdata .= $self->{"os"};
  65.     }
  66.  
  67.     return $rdata;
  68. }
  69.  
  70. 1;
  71. __END__
  72.  
  73. =head1 NAME
  74.  
  75. Net::DNS::RR::HINFO - DNS HINFO resource record
  76.  
  77. =head1 SYNOPSIS
  78.  
  79. C<use Net::DNS::RR>;
  80.  
  81. =head1 DESCRIPTION
  82.  
  83. Class for DNS Host Information (HINFO) resource records.
  84.  
  85. =head1 METHODS
  86.  
  87. =head2 cpu
  88.  
  89.     print "cpu = ", $rr->cpu, "\n";
  90.  
  91. Returns the CPU type for this RR.
  92.  
  93. =head2 os
  94.  
  95.     print "os = ", $rr->os, "\n";
  96.  
  97. Returns the operating system type for this RR.
  98.  
  99. =head1 COPYRIGHT
  100.  
  101. Copyright (c) 1997-2002 Michael Fuhr. 
  102.  
  103. Portions Copyright (c) 2002-2003 Chris Reinhardt.
  104.  
  105. All rights reserved.  This program is free software; you may redistribute
  106. it and/or modify it under the same terms as Perl itself.
  107.  
  108. =head1 SEE ALSO
  109.  
  110. L<perl(1)>, L<Net::DNS>, L<Net::DNS::Resolver>, L<Net::DNS::Packet>,
  111. L<Net::DNS::Header>, L<Net::DNS::Question>, L<Net::DNS::RR>,
  112. RFC 1035 Section 3.3.2
  113.  
  114. =cut
  115.