1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#!/usr/bin/env entity
<object title="sdf">
<perl>
print "hello\n";
</perl>
<perl>
<![CDATA[
use IO::Handle;
sub get_part
{
print "in got_part\n";
my $node = shift;
my $INFILE = IO::Handle->new_from_fd( $node->attrib("fd"), "r" );
do
{
read $INFILE, $buffer, 2;
print $buffer;
}
while(length($buffer) == 2);
print "\n----\n";
if(!$buffer && $ERRNO != EAGAIN) #eof
{
$node->attrib("fd" => "-1");
}
$data .= $buffer;
}
sub do_write
{
#print "in do_write\n";
my $node = shift;
#local $offset;
my $OUTFILE = IO::Handle->new_from_fd($node->attrib("fd"), "w");
print OUTFILE $data;
}
sub openfiles
{
print "opening files\n";
open(INFILE, "</etc/passwd") or die "unable to open passwd";
#open(OUTFILE, " |");
enode("raw-io.src")->attrib("fd" => fileno(INFILE) );
#enode("raw-io.dest")->attrib("fd" => 1);
}
]]>
</perl>
<window ondelete="entity:exit">
<label text="Source"/><entry name="src"/>
<label text="Dest"/><entry name="dest"/>
<button label="copy" onclick="openfiles"/>
</window>
<raw-io
name="src"
onread="get_part"
onerror="got_messed"
/>
<raw-io
name="dest"
onerror="got_messed"
/>
</object>
|