I see that you already use the
bool
type, so extend that to the return type of functions that only have two possible outcomes, success (true
) and failure (false
). Returning integer error codes is error prone for the programmer since there isn't a single agreement or convention on which values should be returned. A boolean is much more obvious of its meaning.Go easy on the magic numbers. You have a lot of repeated literal constants out there that could be consolidated into a few named constants.
#define
andenum
are the traditional C ways of doing that, but I'd instead recommend preferringstatic const
s whenever possible to gain some type safetypreferringstatic const
s whenever possible to gain some type safety.You correctly use
stderr
in your decompression routines to print errors, but inmain()
all error reporting is done withprintf
, which outputs tostdout
. Error output should always be sent tostderr
, so that users can easily filter the program output. Replace those error prints withstderr
. You might also consider adding the output ofstrerror()
to the messages involving system errors (likefopen()
and friends).