The Answer Guy 30: Compression Libraries to Link into a C Program

#### "Linux Gazette...making Linux just a little more fun!"

# The Answer Guy

#### By James T. Dennis, answerguy@ssc.com
Starshine Technical Services, http://www.starshine.org/

### Compression Libraries to Link into a C Program

From Corne van Biljon on the linuxprog mailing list on 30 May 1998

Hello
I would like to zip a file, specified by the user, from within a C program. Currently I use the `system()` command to invoke `gzip`. Is there a compression library or routines out there somewhere, or is there a better way of doing this ?
Thanks

> I can understand your concerns.
> The `system()`, and `popen()` calls are notoriously insecure and can be used to subvert your program to the users' will.
> I would have started with some Yahoo! and Alta Vista searches (actually I used Google --- a new and interesting search engine at Stanford University: http://google.stanford.edu/).
> The obvious phrase would be "`+free +compression +library`" (and reasonable variations).
> I get a bunch of links to the PKware Inc. pages (which are presumably shareware and/or commercial) and then I find a link to the zlib pages (which declare that they should not be confused with the Linux `zlibc` compression libraries).
> The zlib home pages are at:

> > http://www.cdrom.com/pub/infozip/zlib/

> ... and appear to be `gzip` compatible, and co-written by the primary author/maintainer of `gzip`. However the impression I got from this page is that `zlib` is not under a GPL or is under an LGPL --- that your `zlib` linked code will not be encumbered.
> Naturally you'll want to read the licenses yourself.
> This zlib home page also has numerous links to other compresssion software and programming resources.

##### Copyright © 1998, James T. Dennis
Published in Linux Gazette Issue 30 July 1998

| SCOkeys | chroot | dosemu-db | NTauth | cdr | 3270 | comport
lilostop | emulate | ppadrivers | database | vacation | nullmodem | lockups
gzipC | newlook | c500 | solprint | vc1shell | memleak | tvcard