diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2005-12-30 12:56:33 +0000 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2005-12-30 12:56:33 +0000 |
commit | 286e34bb626108dfc0b227ecd372fb5bed5b47e0 (patch) | |
tree | 520fb10a24998953de8b124f4fecb3e6c5304101 /camlibs/ptp2/ptp-parse.pl | |
parent | 84114cc393ba62d939c09b66a230711682fdc812 (diff) | |
download | libgphoto2-286e34bb626108dfc0b227ecd372fb5bed5b47e0.tar.gz |
restructure to allow multiple input fileformats.
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@8376 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/ptp2/ptp-parse.pl')
-rw-r--r-- | camlibs/ptp2/ptp-parse.pl | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/camlibs/ptp2/ptp-parse.pl b/camlibs/ptp2/ptp-parse.pl index c0f11fe1d..420d4c951 100644 --- a/camlibs/ptp2/ptp-parse.pl +++ b/camlibs/ptp2/ptp-parse.pl @@ -2,16 +2,16 @@ # Copyright Marcus Meissner 2005. # Licensed under GPL v2. NO WARRANTY. # -# This is unfinished ... It does not correctly read the data. +# This is mostly unfinished ... use strict; use XML::Parser; my $xmlfile = shift @ARGV || die "specify xml file on cmdline:$!\n"; my $p1 = new XML::Parser( - Handlers => { Start => \&handle_start, - End => \&handle_end, - Char => \&handle_char} + Handlers => { Start => \&xml_handle_start, + End => \&xml_handle_end, + Char => \&xml_handle_char} ); $p1->parsefile($xmlfile); @@ -25,20 +25,6 @@ my %urbenc = (); my @curdata = (); my $lastcode = 0; -sub handle_start { - my ($expat, $element, $attr, $val) = @_; - if (($element eq "urb") && ($attr eq "sequence")) { - $curseq = $val; - $urbenc{$val} = $urbenc{$val} + 1; - } - push @elemstack, $element; -} - -sub handle_end { - my ($expat, $element) = @_; - pop @elemstack; -} - sub get_uint32 { my($arrref) = @_; @@ -77,9 +63,8 @@ sub get_str { my $lastfunction; -sub handle_char { +sub xml_handle_char { my ($expat, $str) = @_; - my $dummy; my @bytes; if ($elemstack[$#elemstack] eq "function") { @@ -138,6 +123,35 @@ sub handle_char { push @curdata, @bytes; return; } + dump_ptp_line($type,$code,\@bytes,\@curdata); +} + +sub xml_handle_start { + my ($expat, $element, $attr, $val) = @_; + if (($element eq "urb") && ($attr eq "sequence")) { + $curseq = $val; + $urbenc{$val} = $urbenc{$val} + 1; + } + push @elemstack, $element; +} + +sub xml_handle_end { + my ($expat, $element) = @_; + pop @elemstack; +} + + +# Evaluate and print out debug commands +# type == 1 during send ... print parameters sent to camera +# type == 3 after response ... print data returned +# @bytes - bulk container in response (no data) +# @curdata - bulk data if command had seperate datastream +sub +dump_ptp_line() { + my($type,$code,$bytesref,$curdataref) = @_; + my @bytes = @{$bytesref}; + my @curdata = @{$curdataref}; + my $dummy; if ($type == 3) { if ($code == 0x2001) { print "OK(2001) "; } @@ -148,11 +162,6 @@ sub handle_char { } - # evaluate commands - # type == 1 during send ... print parameters sent to camera - # type == 3 after response ... print data returned - # @bytes - bulk container in response (no data) - # @curdata - bulk data if command had seperate datastream if ($code == 0x1001) { if ($type == 1) { |