ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/ihost-perl/ihost.pl
(Generate patch)

Comparing projects/cms/source/host/ihost-perl/ihost.pl (file contents):
Revision 1.42 by tdb, Wed Nov 21 10:08:20 2001 UTC vs.
Revision 1.43 by tdb, Tue Dec 18 03:51:11 2001 UTC

# Line 275 | Line 275 | sub send_udp_packet() {
275      $ip = inet_ntoa(scalar(gethostbyname(hostname())) || 'localhost') or $ip = 'localhost';
276      
277      # add some extra data to the array
278 <    push(@data, "packet.attributes.seq_no=$seq_no");
279 <    push(@data, "packet.attributes.machine_name=$fqdn");
280 <    push(@data, "packet.attributes.date=$date");
281 <    push(@data, "packet.attributes.type=data");
282 <    push(@data, "packet.attributes.ip=$ip");
278 >    push(@data, "packet.attributes.seq_no $seq_no");
279 >    push(@data, "packet.attributes.machine_name $fqdn");
280 >    push(@data, "packet.attributes.date $date");
281 >    push(@data, "packet.attributes.type data");
282 >    push(@data, "packet.attributes.ip $ip");
283      
284      # sort the data
285 <    @data = sort(@data);
286 <    
285 >    @data = sort(grep(!/^$/, grep(/^packet\./, @data)));
286 >
287      # turn the array into some nice XML
288      my($xml) = &make_xml("", "");
289 <    
289 >
290      my($sock) = new IO::Socket::INET (
291                                        PeerPort => $udp_port,
292                                        PeerAddr => $filter_addr,
# Line 407 | Line 407 | sub make_xml() {
407      my($curlevel, $curline) = @_;
408      my($xmltemp) = ""; my($curtag) = ""; my($attributes) = "";
409      while(1) {
410 <        $curline = shift(@data) if $curline eq ""; chomp $curline;
410 >        $curline = shift(@data) if $curline eq "";
411 >        return $xmltemp if not defined $curline;
412 >        chomp $curline;
413 >        # dealing with nest (or attributes)
414          if($curline =~ /^$curlevel([^\.\s]+\.)/) {
415              $curtag=$1;
416 +            if($curline =~ /^$curlevel$curtag([^\.\s]+)\s+(.*)$/) {
417 +                $xmltemp .= &make_xml("$curlevel$curtag", $curline);
418 +            }
419 +            elsif($curline =~ /^$curlevel$curtag(attributes)\.([^\.\s]+)\s+(.*)$/) {
420 +                $attributes .= " $2=\"$3\"";
421 +            }
422 +            else {
423 +                $xmltemp .= &make_xml("$curlevel$curtag", $curline);
424 +            }
425 +            my($nextline) = $data[0]; chomp $nextline if defined $nextline;
426 +            if((defined $nextline) && ($nextline =~ /^$curlevel$curtag/)) {
427 +                $curline = "";
428 +            }
429 +            else {
430 +                $curtag =~ s/(.*)\./$1/;
431 +                $xmltemp = "<$curtag$attributes>$xmltemp</$curtag>" unless $curtag eq "";
432 +                return $xmltemp;
433 +            }
434          }
435 <        if($curline =~ /^$curlevel$curtag([^\.\s]+)\s+(.*)$/) {
436 <            $xmltemp .= "<$1$attributes>$2</$1>";
437 <        }
438 <        elsif($curline =~ /^$curlevel$curtag(attributes)\.([^\.=]+)=(.*)$/) {
439 <            $attributes .= " $2=\"$3\"";
440 <        }
441 <        else {
442 <            $xmltemp .= &make_xml("$curlevel$curtag", $curline);
443 <        }
444 <        my($nextline) = $data[0]; chomp $nextline if defined $nextline;
445 <        $curtag =~ s/(.*)\./$1/;                
446 <        if((defined $nextline) && ($nextline =~ /^$curlevel$curtag\./)) {
426 <            $curline = "";
427 <        }
428 <        else {
429 <            $xmltemp = "<$curtag$attributes>$xmltemp</$curtag>" unless $curtag eq "";
430 <            return $xmltemp;
435 >        # dealing with value
436 >        elsif($curline =~ /^$curlevel([^\.\s]+)\s+(.*)$/) {
437 >            $curtag=$1;
438 >            $xmltemp=$2;          
439 >            my($nextline) = $data[0]; chomp $nextline if defined $nextline;
440 >            if(defined $nextline && ($nextline =~ /^$curlevel$curtag\./ || $nextline =~ /^$curlevel$curtag\s+/)) {
441 >                $curline = "";
442 >            }
443 >            else {
444 >                $xmltemp = "<$curtag$attributes>$xmltemp</$curtag>" unless $curtag eq "";
445 >                return $xmltemp;
446 >            }
447          }
448      }
449   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines