Structure the sources so that the compression and decompression code form a library usable by any program, and write both gzip and zip on top of this library. This would ideally be a reentrant (thread safe) library, but this would degrade performance. In the meantime, you can look at the sample program zread.c.