473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
Jun 27 '08 #1
2 2118
miztaken wrote:
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.
Jun 27 '08 #2
Sam
miztaken writes:
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-----

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: surfunbear | last post by:
I've read some posts on Perl versus Python and studied a bit of my Python book. I'm a software engineer, familiar with C++ objected oriented development, but have been using Perl because it is...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
13
by: Otto J. Makela | last post by:
I'm trying to install to php the Perl-1.0.0.tgz package (from http://pecl.php.net/package/perl, enabling one to call perl libraries) to a pre-existing Solaris system. Unfortunately, the attempt...
6
by: surfivor | last post by:
I may be involved in a data migration project involving databases and creating XML feeds. Our site is PHP based, so I imagine the team might suggest PHP, but I had a look at the PHP documentation...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.