Access zip files - c

How can I access to the contents of a zip file?
I'm trying write a program in C and I want use the libraries used by zip.

You may want to check the open source widely used library ZLIB.
The link provides sample code and the home page provides more information about the libraries, source code, installation and usage.

The Info-zip project has code for that.

Minizip, which is included with zlib is what you need. Look in the 'contribs' directory for the code. There is an example for zip/unzip and is easily included in a project.

Related

What's the use of DLL files and why I cannot see the source code of a random app?

The title basically says it all. It might be a dumb question (which probably is) because I am entirely new to programming. I wonder how the desktop apps we use are made of mostly .dll files when you check their program files, but not even a single source code file? Is there any way to open them, or how can I turn my code file into .dll?
Thats exactly what DLL files are. DLL files are libraries which contain code that is called by the 'main' source code, which is compiled into '.exe' files.
You not being able to see such code is intended by its owner, unless the source itself is released alongside the compiled software. A project may integrate .dll files already developed by someone else instead of developing them from scratch.
As to how to turn your code into a .dll, it would depend on the language you are developing in.
More detailed answers at: What exactly are DLL files, and how do they work?
Short answer: The DLL files are "compiled".
Compiled files no longer rely on their source code. Once compiled they can be executed by the operating system directly.
DLL files are not "scripts". In languages like HTML, Javascript and PHP, the files are interpreted at run time by the browser's HTML or Java engine or the PHP engine on a server. Thus you can also read them since they are not yet compiled. But in the case of a DLL file, the original source code files have been compiled (interpreted and converted) and the result is an executable Library which is used by another program to accomplish whatever tasks are in them.
It is possible to "decompile" them with a decompiler, but that will not give you the original source code, any more than a "jpg" will give you the original layered Photoshop file. All you have is the Result.

How convert file. a to .c or other extension? I need read file .a

Good day, I am working with Codeblock IDE under Windows in C language and I got the static library in file ".a" with the development of some functions. I must see somehow the code of the functions in the file because i need.
I was reading a lot on the forum but I could not solve my doubt.
someone could help? Tanks!!
(People said that this should be an answer, so here it is!)
*.a files are compiled libraries on Windows (the file extension is different on different operating systems). You can't see the source code unless you decompile it (which is very hard or impossible).
(From another comment) However, if the library is from an open-source project, then you might be able to find the source code.

Where is the code that corresponds to the c standard headers?

I was looking through my root folders in my new ubuntu desktop, and noticed the standard c header files in my include folder(like stdio.h), so i tried to sudo locate stdio.c to no avail. Where are these files? If they are non existent, how do these headers work, what will happen if i were to edit them? Thank you.
You can't find source files because you only get object files in the form of library. So you can't edit the source. The best you could do is to look at the object file(s) of standard files.
locate libc.a
then extract the object files:
ar x /path/to/libc.a
and then you can use objdump to read the interested object file.
However, if you are looking for source samples, you can look at this post for various online resources.
Where can I browse the sourcecode for libc online

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

Where can I find an example unzipper using zlib?

I'm looking for a bare bones simple example C app for unpacking a zip file using zlib. It must support fairly new version of .zip and must have source right down to the zlib calls.
The zlib-bin source package on my system (linux) has some example programs called "minizip" and "miniunzip" which shows just that.
The zpipe.c example on the zlib.net web site is pretty straight forward. There is also a pretty good description of what it does.

Resources