Topic: Reading VAX binary files
Author: "Andrew F. Vesper" <avesper@wn.net>
Date: 2000/01/25 Raw View
Tim Sharrock wrote:
> I have just had a look at the code and it looks horrible, including
> comments like
> /* Subtract 2 from the exponent unless the exponent value is zero */
> /* THIS WORKS BUT DONT KNOW WHY */
> (this was written in C originally).
This is part of the F-float to IEEE S-float conversion.
--
Andy V (OpenGL Alpha Geek)
"In order to make progress, one must leave the door to the unknown ajar."
Richard P. Feynman, quoted by Jagdish Mehra in _The Beat of a Different Drum_.
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Francis Glassborow <francis@robinton.demon.co.uk>
Date: 2000/01/22 Raw View
In article <3887149C.D5E4E2A6@spf.fairchildsemi.com>, Swamy
Ananthanarayan <sananthanara@spf.fairchildsemi.com> writes
>Greetings,
>
>I have a Pascal program that produces a binary file as output. The
>operating system is VAX. I know the record structure of the binary file
>but after numerous attempts I am unable to read the file using C++. My
>goal is to create a C++ program that can read this file. I am using
>structs to recreate the record. Are there differences in memory
>allocation between C++ structs and Pascal Records. Also are there
>differences in how a file is stored in terms of the two operating
>systems (VAX and Windows NT). I have a pascal program on the VAX machine
>that can read this file, so therefore I know what the file looks like,
>but I would like to be able to read it using a C++ program on a windows
>NT machine. I have used the Pascal code from the VAX machine as my
>guide. Also when transferring over the binary file, I used ftp with
>binary mode set. Thank you for the help.
My initial reaction is that you must be kidding. Binary files are about
as unportable as they come. To start with there is the whole issue of
little versus big endian.
Even if C++ had produced the original there is no reason to suppose that
you could read it back on a different platform. The sizes of the
fundamental types, the encoding of floating point types and the
alignment requirements are all important. Actually the last of these
means that you may not even be able to read a binary file back on the
same platform that it was produced on if you have recompiled your code
with different compiler settings.
Put simply, I think you are on a hiding to nothing if the contents of
that file are anything other than a byte oriented graphics file or
similar.
Francis Glassborow Journal Editor, Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Frank Canavan" <fcanavan@netc.net.au>
Date: 2000/01/22 Raw View
<snip>
>Put simply, I think you are on a hiding to nothing if the contents of
>that file are anything other than a byte oriented graphics file or
>similar.
>
Instead of trying to read the data straight into a struct or class object,
he could read the file one byte at a time and reconstruct the data as he
requires.
He knows what data is in the file. He can use a hex editor to tell him how
it is stored on disc.
Regards
Frank Canavan
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Tim Sharrock <tjsharrock@iee.org>
Date: 2000/01/23 Raw View
On Sat, 22 Jan 2000 01:51:31 CST, Francis Glassborow
<francis@robinton.demon.co.uk> wrote:
>In article <3887149C.D5E4E2A6@spf.fairchildsemi.com>, Swamy
>Ananthanarayan <sananthanara@spf.fairchildsemi.com> writes
>>Greetings,
>>
>>I have a Pascal program that produces a binary file as output. The
>>operating system is VAX. I know the record structure of the binary file
>>but after numerous attempts I am unable to read the file using C++. My
>>goal is to create a C++ program that can read this file. I am using
>>structs to recreate the record. Are there differences in memory
>>allocation between C++ structs and Pascal Records. Also are there
>>differences in how a file is stored in terms of the two operating
>>systems (VAX and Windows NT). I have a pascal program on the VAX machine
>>that can read this file, so therefore I know what the file looks like,
>>but I would like to be able to read it using a C++ program on a windows
>>NT machine. I have used the Pascal code from the VAX machine as my
>>guide. Also when transferring over the binary file, I used ftp with
>>binary mode set. Thank you for the help.
>
>My initial reaction is that you must be kidding. Binary files are about
>as unportable as they come. To start with there is the whole issue of
>little versus big endian.
>
>Even if C++ had produced the original there is no reason to suppose that
>you could read it back on a different platform. The sizes of the
>fundamental types, the encoding of floating point types and the
>alignment requirements are all important. Actually the last of these
>means that you may not even be able to read a binary file back on the
>same platform that it was produced on if you have recompiled your code
>with different compiler settings.
>
>Put simply, I think you are on a hiding to nothing if the contents of
>that file are anything other than a byte oriented graphics file or
>similar.
it can we done, but it is hard work, and you do need to know all the
details of things like the floating point formats. One of the file
formats I maintain a translator for at work was originally, I believe,
a similar VAX binary format. We read the file in as unsigned shorts
(I would generally recommend unsigned char, but this format is
documented in 16-bit chunks) and then have functions to manipulate
the contents, swapping byte-orders, interpreting the bit patterns of
the floating point numbers and so on.
We can then have a constructor for a class that takes the data
source, reads the raw data, mangles it bit by bit, and sets the members
of the class as appropriate.
It does work...
I have just had a look at the code and it looks horrible, including
comments like
/* Subtract 2 from the exponent unless the exponent value is zero */
/* THIS WORKS BUT DONT KNOW WHY */
(this was written in C originally).
I cannot post the code we have (due to Copyright etc), but it would
probably not be much help anyway, being tied to this particular format.
It would almost certainly be easier, if you can, to write a VAX pascal
program to read the file, and write it out in human-readable form,
ftp it as text, and then read it in to your C++ program
Tim
--
Tim Sharrock (tjsharrock@iee.org)
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Francis Glassborow <francis@robinton.demon.co.uk>
Date: 2000/01/23 Raw View
In article <8m0h8s4itks018d7bj105n0p2nserbnvc9@4ax.com>, Tim Sharrock
<tjsharrock@iee.org> writes
>I cannot post the code we have (due to Copyright etc), but it would
>probably not be much help anyway, being tied to this particular format.
>
>It would almost certainly be easier, if you can, to write a VAX pascal
>program to read the file, and write it out in human-readable form,
>ftp it as text, and then read it in to your C++ program
I did not mean that it was impossible. However just change the settings
of your C++ compiler and you have to start again.
Francis Glassborow Journal Editor, Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Swamy Ananthanarayan <sananthanara@spf.fairchildsemi.com>
Date: 2000/01/21 Raw View
Greetings,
I have a Pascal program that produces a binary file as output. The
operating system is VAX. I know the record structure of the binary file
but after numerous attempts I am unable to read the file using C++. My
goal is to create a C++ program that can read this file. I am using
structs to recreate the record. Are there differences in memory
allocation between C++ structs and Pascal Records. Also are there
differences in how a file is stored in terms of the two operating
systems (VAX and Windows NT). I have a pascal program on the VAX machine
that can read this file, so therefore I know what the file looks like,
but I would like to be able to read it using a C++ program on a windows
NT machine. I have used the Pascal code from the VAX machine as my
guide. Also when transferring over the binary file, I used ftp with
binary mode set. Thank you for the help.
Swamy
PS If possible please reply to me as well as to the group.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]