Is a .BIN CD Image file a standard format? - file-format

In this page:
http://en.wikipedia.org/wiki/List_of_file_formats
I found many .BIN files used by many applications. Are all these the same format?
I am going to deal with .BIN files. I want to know the standard format.
Google could not help me to find a site explaining the standard structure for the .BIN format.
Because it changes BIN to Binary in the search results.
I am talking about the CD Image .BIN files.

The BIN extension indicates that it is just binary data and doesn't say anything about the actual format. Like your linked Wikipedia page suggests, the extension has different meanings depending on where it's used.
If you know it is a CD image, the actual structure of the data inside the image is usually some file system (probably ISO 9660 with Rock Ridge or Joliet extensions). On Linux this can be mounted through a loop device and used like a regular CD.
EDIT
The ISO 9660:1988 standard can be downloaded freely online:
http://www.ecma-international.org/publications/standards/Ecma-119.htm
A draft of the current ISO 9660:1999 is available here:
http://www.pismotechnic.com/cfs/iso9660-1999.html
The draft does not represent the official released standard (which you may purchase) but it may be close enough to get you most of the way. Note, these do not include any information about extensions that may be in use. The linked Wikipedia page lists a few of the most common extensions each of which will also have their own published standards.

Related

How to check if a object code is 16/32 bit?

Is there any way by which we can identify that a .obj file and .exe file is 16/32 bit?
Basically I want to create a smart linker, that will automatically identify which linker do the given file names need to be passed to.
Preferred Language: C (it can be different, if needed)
I am looking for some solution that can read the bytes of an .exe/the code of an .obj file and then determine if it's 16/32 bit. Even an algorithm would too do.
Note: I know both object code and a executable are two different entities.
All of this information is encoded in the binary object according to the relevant Application Binary Interface (ABI).
The current Linux ABI is the Executable and Linkable Format (ELF), and you can query a specific binary file using a tool such as readelf or objdump.
The current Windows ABI is the Portable Executable (PE) format. I'm not familiar with the toolset here but a quick google search suggests there are programs that function the same as readelf:
http://www.pe-explorer.com/peexplorer-tour.htm
Here's the Microsoft specification of the PE format:
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format
However, neither of those formats support 16-bit binaries anymore. The older ABI format is called "a.out" for Linux, which can be read and queried with objdump (I'm not sure about readelf). The older Windows/DOS formats are called MZ and NE. Again, I'm not familiar with the tool support for these older Windows formats.
Wikipedia has a pretty comprehensive list of all the popular executable file formats that have been used, with links to more info:
https://en.wikipedia.org/wiki/Comparison_of_executable_file_formats

How .extension readers are made?

For example, there are many pdf readers in the market and they are not from Adobe. So, how do they make the readers(viewers) for these extensions?
I want to make an online application which has an ability to view these formats:
pdf,
word,
powerpoint,
is there special libraries or frameworks to do that?
They will either search for the official file format and implement a viewer for it, or they will try to reverse engineer the file formats and make a viewer for it.
For PDF, the file format has always been publicly shared by Adobe so others could implement viewers (and more); Adobe still makes their version of the specification public here: http://www.adobe.com/devnet/pdf/pdf_reference.html. Meanwhile, the PDF file format became an international standard through the ISO as ISO 32000 so the latest version of the PDF specification can also be gotten through the ISO or your countries standards organisation (if it is member of the ISO community).
For Word and PowerPoint, you would have to find the information from Microsoft. These file formats are proprietary file formats and certainly for the beginning of their life, no public documentation (that I'm aware of) existed. The later formats have been (at least partially) made public by Microsoft) - how complete that support is I'm not aware of.
As to your second point - how would you implement this, there are basically two ways to do this:
1) You can write everything from scratch. That is certainly feasible for PDF; some tens of companies have done so.
2) You could use the (very many) man years of work these companies have put in this by using an existing library that supports the file format. Libraries exist both on the open source, free and commercial level which implement support for all or a partial list of features in these file formats.

decompress multiple files from resource in c

i have a visual c project, where i want to include an archive containing multiple files in a directory structure
i would like to programmatically extract it to somewhere on the disk, using a preferably small library (under small i mean just a few .c and .h files - size doesnt really matter), but i only seem to find libraries that decompress or compress data directly (i looked over lzo-lzop-minilzo, but i dont seem to find anything that says it can decmpress an entire directory tree even tho i used lzop already to compress the archive with the files)
thanks
zlib and accompanying (in the contrib) minizip library support .zip format decompression.
You can pack the .zip file as a resource in your executable. To get the raw data from .exe use the FindResource, SizeofResource, LoadResource, LockResource APIs.
Then see minizip's samples to see how to decompress and read zlib's documentation to overload the I/O callbacks.
Disclaimer: I did this for Linderdaum Engine's virtual file system and there is now support for .zip, .tar, .rar (uncompressed) and .tar.gz formats. The code for VFS is in Src/Linderdaum/Core/VFS and it is under MIT license for non-commercial use. It's C++, but the I/O wrappers for zlib use C-style API and the code is pretty straightforward.

Zip on-the-fly compression library in C for streaming

Is there a library for creating zip files (the zip file format not gzip or any other compression format) on-the-fly (so I can start sending the file while it is compressing) for very large files (4 Gb and above).
The compression ratio does not matter much (mostly media files).
The library has to have a c-interface and work on Debian and OSX.
libarchive supports any format you want, on the fly and even in-memory files.
zlib supports compressing by chunks. you should be able to start sending a small chunk right after compressing it, while the library is still compressing the next chunk. (see this example)
(unfortunately, the file table is stored at the end of the zip file, so the file will be unusable until it is complete on the receiver side)
While this question is old and already answered I will note a new potential solution for those that find this.
I needed something very similar, a portable and very small library that created ZIP archives in a streaming fashion in C. Not finding anything that fit the bill I created one that uses zlib, available here:
https://github.com/CTrabant/fdzipstream
That code only depends on zlib and essentially provides a simple interface to creating ZIP archives. Most importantly (for me) the output can be streamed to a pipe, socket, whatever as the output stream does not need to be seek-able. The code is very small, a single source file and a header file. Works on OSX and Linux and probably elsewhere. Hope it helps someone beyond just me...

C library to read from zip archives

Is there a portable C library to access .zip archives? "gzip" or "zlib" (the closest I could find) only handle compressed data, I need to be able to list the files inside the archive, and access each one individually, and if they're compressed using the 'deflate' method, I can use zlib on it.
Minizip, maybe?
http://www.winimage.com/zLibDll/minizip.html
The zip that comes with Linux and BSD is actually called info-ZIP which is here. Personally I have not tried such a thing but the info-zip front page states "Info-ZIP's primary compression engine has also been spun off into the free zlib compression library", so you might want to check out zlib. The zlib page has a FAQ with a answer to your specific question. I would start by studying how info-zip works. Good luck.
7-zip has a complete SDK, with example sources, and a lot of functionality.
take a look here

Resources