Perl to C++

Discussion in 'C++' started by miztaken, May 19, 2008.

  1. miztaken

    miztaken Guest

    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
    miztaken, May 19, 2008
    #1
    1. Advertising

  2. miztaken

    Ian Collins Guest

    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.
    Ian Collins, May 19, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,791
  2. PerlFAQ Server

    FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?

    PerlFAQ Server, Jan 23, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    297
    PerlFAQ Server
    Jan 23, 2011
  3. PerlFAQ Server
    Replies:
    0
    Views:
    677
    PerlFAQ Server
    Feb 3, 2011
  4. PerlFAQ Server

    FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?

    PerlFAQ Server, Feb 27, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    291
    PerlFAQ Server
    Feb 27, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    678
    PerlFAQ Server
    Apr 4, 2011
Loading...

Share This Page