Connecting Tech Pros Worldwide Help | Site Map

Perl to C++

 
LinkBack Thread Tools Search this Thread
  #1  
Old June 27th, 2008, 04:43 PM
miztaken
Guest
 
Posts: n/a
Default Perl to C++

Hi there,
can somebody convert the following perl code to C++

sub OleUnpackPackages {
my($this, $explodeinto, $parentname, @NativeFilenames) = @_;

my($infh, $byte, $number, $buffer, $outname);
my($finished);

OLEFILE: foreach my $inname (@NativeFilenames) {
$byte = "";
$buffer = "";
close $infh if $infh;
$infh = new FileHandle;
sysopen $infh, "$explodeinto/$inname", O_RDONLY; sysseek $infh,
6, SEEK_SET; # Skip 1st 6 bytes
$outname = "";
$finished = 0;
until ($byte eq "\0" || $finished) { # Read a C-string into
$outname
sysread($infh, $byte, 1) or $finished = 1;
$outname .= $byte;
}
# Then there is a null-terminated ASCII string which is the filename
of the object.
#print STDERR "Output filename is $outname\n";
$finished = 0;
$byte = 1;
until ($byte eq "\0" || $finished) { # Throw away a C-string
sysread($infh, $byte, 1) or $finished = 1;
}
# Throw away the next null-terminated ASCII string
sysseek $infh, 4, Fcntl::SEEK_CUR or next OLEFILE; # Skip next 4
bytes
# Throw away next 4 byte int
sysread $infh, $number, 4 or next OLEFILE;
$number = unpack 'V', $number;
# The next 4 bytes are an int giving the length of the next bit of the
header
#print STDERR "Skipping $number bytes of header filename\n";
sysseek $infh, $number, Fcntl::SEEK_CUR; # Skip the next bit of
header (C-string)
# Skip over the next bit of the header whose length we just read
sysread $infh, $number, 4 or next OLEFILE;
$number = unpack 'V', $number;
#print STDERR "Reading $number bytes of file data\n";
# Then you have a 4-byte int which is the length of the real embedded
original file
sysread $infh, $buffer, $number
if $number < -s "$explodeinto/$inname"; # Sanity check
# Read in all the data of the original embedded file
my $outfh = new FileHandle;
my $outsafe = $this->MakeNameSafe($outname, $explodeinto);
sysopen $outfh, "$explodeinto/$outsafe", (O_CREAT | O_WRONLY)
or next OLEFILE;
syswrite $outfh, $buffer, $number or next OLEFILE;
close $outfh;
# Set up MailScanner data structures
$this->{file2parent}{$outname} = $parentname;
$this->{file2parent}{$outsafe} = $parentname;
$this->{file2safefile}{$outname} = $outsafe;
$this->{safefile2file}{$outsafe} = $outname;

}
close $infh if $infh;

}

You help will be highly appreciated.

Thank You
miztaken

  #2  
Old June 27th, 2008, 04:43 PM
Ian Collins
Guest
 
Posts: n/a
Default Re: Perl to C++

miztaken wrote:
Quote:
Hi there,
can somebody convert the following perl code to C++
>
I'm sure they can, for an appropriate fee. This isn't the place to ask.

--
Ian Collins.
  #3  
Old June 27th, 2008, 04:43 PM
Sam
Guest
 
Posts: n/a
Default Re: Perl to C++

miztaken writes:
Quote:
Hi there,
can somebody convert the following perl code to C++

sub OleUnpackPackages {
my($this, $explodeinto, $parentname, @NativeFilenames) = @_;
>
[ … ]
Yup, I can definitely convert this perl code to C++. And I'm sure many
others can, too.



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBIMWD4x9p3GYHlUOIRApotAJ4/dzPj/8ma2DFQ17R74l3bAzda5gCeKo5m
26fFuNtNL6bxAJw6PVCVSgY=
=bUEs
-----END PGP SIGNATURE-----

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.