--- google/bin/acs.pl 2007/06/18 07:59:20 28 +++ google/trunk/bin/acs.pl 2007/11/23 21:14:54 221 @@ -6,31 +6,57 @@ use strict; -use HTTP::Server::Simple; - -my $port = 3333; - -my $server = CWMP::Server->new( $port ); -$server->run(); - -package CWMP::Server; - +use lib './lib'; +use CWMP::Server; +use CWMP::Session; +use CWMP::Vendor; +use Getopt::Long; use Data::Dump qw/dump/; +use File::Find; -use base qw(HTTP::Server::Simple::CGI); +use Devel::LeakTrace::Fast; -sub handle_request { - my ($self, $cgi) = @_; - - #... do something, print output to default - # selected filehandle... - - warn $cgi->param('POSTDATA'); - - print "Content-Type: text/xml\r\n\r\n"; - -}; +my $port = 3333; +my $debug = 0; +my $store_path = './'; +my $store_plugin = 'YAML'; +my $create_dump = 1; + +GetOptions( + 'debug+' => \$debug, + 'port=i' => \$port, + 'store-path=s' => \$store_path, + 'store-plugin=s' => \$store_plugin, + 'create_dump!' => \$create_dump, +); + +if ( $create_dump ) { + warn "## cleaning dump directory\n" if $debug; + find({ + wanted => sub { + my $path = $File::Find::name; + return if -d $path; + unlink($path) || die "can't remove $path: $!"; + warn "## removed $path\n" if $debug; + }, + no_chdir => 1, + }, 'dump/' ); +} + +my $server = CWMP::Server->new({ + port => $port, + session => { + store => { + module => $store_plugin, + path => $store_path, + debug => $debug, + }, + create_dump => $create_dump, + }, + debug => $debug, +}); -1; +CWMP::Vendor->add_triggers; +$server->run();