Skip Menu |

This queue is for tickets about the Net-Nessus-XMLRPC CPAN distribution.

Report information
The Basics
Id: 57883
Status: new
Priority: 0/
Queue: Net-Nessus-XMLRPC

People
Owner: Nobody in particular
Requestors: shuff [...] hmdc.harvard.edu
Cc: pdurbin [...] hmdc.harvard.edu
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



CC: pdurbin [...] hmdc.harvard.edu
Subject: feature request: enable callbacks for public functions
Hello, One of my colleagues has been writing a program that uses Net::Nessus::XMLRPC; thanks for writing it! However, he's discovered that many of the public functions return arrayrefs, and he's been complaining to me that he wants hashrefs (I believe he has contacted you separately about this issue; I've Cc'd him on the ticket). I suggest that you enable optional callbacks on each of your public functions, which makes it easy for other programmers to manipulate the returned data any way they please. I've attached a patch which demonstrates one way to do this for two of the functions (policy_list_hash() and report_list_hash()); however, the technique is easily generalized to other functions. I suspect that you could convert your public functions to accept optional callbacks without losing any of your existing functionality; programmers who don't want to use them wouldn't have to change their code, and programmers who do would then have the option to do so. thanks, -Steve -- Steve Huff * shuff@hmdc.harvard.edu
Subject: Net-Nessus-XMLRPC-0.30_callback_examples.patch
diff -Naur Net-Nessus-XMLRPC-0.30-orig/lib/Net/Nessus/XMLRPC.pm Net-Nessus-XMLRPC-0.30/lib/Net/Nessus/XMLRPC.pm --- Net-Nessus-XMLRPC-0.30-orig/lib/Net/Nessus/XMLRPC.pm 2010-05-21 12:16:45.000000000 -0400 +++ Net-Nessus-XMLRPC-0.30/lib/Net/Nessus/XMLRPC.pm 2010-05-26 15:54:43.879928000 -0400 @@ -549,7 +549,7 @@ $value{'comment'} =cut sub policy_list_hash { - my ( $self ) = @_; + my ( $self, $callback ) = @_; my $post=[ "token" => $self->token, @@ -568,7 +568,14 @@ push @list, \%info; } # foreach } # if - return \@list; + + # run the callback if we got one + my $return = \@list; + if ( defined( $callback ) && ref( $callback ) eq 'CODE' ) { + + ( $return ) = $callback->( $return ); + } + return $return; } =head2 policy_list_uids @@ -885,7 +892,7 @@ timestamp =cut sub report_list_hash { - my ( $self ) = @_; + my ( $self, $callback ) = @_; my $post=[ "token" => $self->token @@ -905,7 +912,13 @@ } } - return \@list; + # run the callback if we got one + my $return = \@list; + if ( defined( $callback ) && ref( $callback ) eq 'CODE' ) { + + ( $return ) = $callback->( $return ); + } + return $return; } =head2 report_file_download ($report_id)