Use z_stream and gz_header types (these are the ones that are actually API-intended rather than implementation details)
Clean up error paths; allocate out_path instead of trying hard to use static buffers
Factor out error reporting
Use S_ISDIR directly instead of redoing it