--- trunk/Split.pm 2004/12/08 20:35:49 6 +++ trunk/Split.pm 2004/12/17 18:32:34 7 @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.00'; +our $VERSION = '0.01'; use SWISH::API; use Text::Iconv; @@ -149,14 +149,14 @@ my $swishpath = shift || return; my $data = shift || return; - my ($out,$err) = $self->put_slice($swishpath, $self->to_xml($data)); + my $slice = $self->put_slice($swishpath, $self->to_xml($data)); - if ($err) { - carp "$swishpath: $err"; - return 0; - } +# if ($err) { +# carp "$swishpath: $err"; +# return undef; +# } - return 1; + return $slice; } =head2 delete @@ -347,9 +347,7 @@ If you want to see what is allready defined for swish-e in configuration take a look at source code for C. -It uses C utility to comunicate with C. Path is provided -by C. Do Windows users have to change that to C -or something similar? +It uses C as C to comunicate with C. =cut @@ -368,8 +366,7 @@ print $tmp_fh <<"DEFAULT_SWISH_CONF"; # swish-e config file -IndexDir cat -#SwishProgParameters - +IndexDir stdin # input file definition DefaultContents XML* @@ -427,7 +424,7 @@ print STDERR "creating slice $s\n"; # FIXME - my @swish = qw(swish-e -S prog -c); + my @swish = qw(swish-e -u -S prog -c); push @swish, $swish_config; ## Build the harness, open all pipes, and launch the subprocesses @@ -447,9 +444,11 @@ =head2 put_slice -Pass XML data to swish and receive output and errors. +Pass XML data to swish. + + my $slice = $i->put_slice('/swish/path', 'data'); - my ($out,$err) = $i->put_slice('/swish/path', 'data'); +Returns slice in which XML ended up. =cut @@ -473,6 +472,7 @@ $self->{'slice'}->{$s}->{'in'} .= "Path-Name: $path\n". "Content-Length: ".(length($xml)+1)."\n". + "Update-Mode: Index\n". "Document-Type: XML\n\n$xml\n"; # do I/O @@ -480,7 +480,6 @@ $self->slice_output($s); - $self->{'paths'}->{$path} = ADDED; return $s; @@ -490,7 +489,7 @@ Prints to STDERR output and errors from C. - $i->slice_output($s); + my $slice = $i->slice_output($s); Normally, you don't need to call it. @@ -508,15 +507,15 @@ if (length $self->{'slice'}->{$s}->{'out'} > $self->{'slice'}->{$s}->{'out_len'}) { #print STDERR "swish-e OUT: ",$self->{'slice'}->{$s}->{'out'},"\n" if ($self->{'slice'}->{$s}->{'out'}); $self->{'slice'}->{$s}->{'out_len'} = length $self->{'slice'}->{$s}->{'out'}; - return 1; + return $s; } elsif (length $self->{'slice'}->{$s}->{'err'} > $self->{'slice'}->{$s}->{'err_len'}) { print STDERR "swish-e ERR: ",$self->{'slice'}->{$s}->{'err'},"\n" if ($self->{'slice'}->{$s}->{'err'}); $self->{'slice'}->{$s}->{'err_len'} = length $self->{'slice'}->{$s}->{'err'}; # this is fatal - return 0; + return undef; } - return 1; + return $s; } =head2 close_slice @@ -543,7 +542,7 @@ $self->slice_output($s); # clean up - $self->{'slice'}->{$s}->{'h'}->finish or confess "finish on slice $s returned: $?"; + $self->{'slice'}->{$s}->{'h'}->finish or confess "finish on slice $s returned $?: $! -- ",$self->{'slice'}->{$s}->{'err'}; delete($self->{'slice'}->{$s}) && return 1; return 0;