[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [PATCH v2 09/13] libdpkg: factor out function to execute compressors



Hi!

On Sat, 2009-10-24 at 17:47:01 -0500, Jonathan Nieder wrote:
> gzip, bzip2, and lzma use the same command-line syntax.  Factor
> out a compress_cmd() function that can be used to invoke any one
> of these commands.

> diff --git a/lib/dpkg/compression.c b/lib/dpkg/compression.c
> index f901867..914ba1d 100644
> --- a/lib/dpkg/compression.c
> +++ b/lib/dpkg/compression.c
> @@ -95,6 +95,17 @@ fd_fd_filter(int fd_in, int fd_out,
>    exit(0); \
>  } while(0)
>  
> +static void
> +compress_cmd(int fd_in, int fd_out, const char *path,
> +             const char *cmd, char compression,
> +             const char *desc)
> +{
> +  char combuf[6];
> +  strncpy(combuf, "-9c", sizeof(combuf));
> +  combuf[1] = compression;
> +  fd_fd_filter(fd_in, fd_out, path, cmd, combuf, desc);
> +}

I didn't apply this one, instead I added ‘struct command’ support to
fd_fd_filter and made the backend functions call that one. Also used
snprintf to create the compression level argument string.

regards,
guillem


Reply to: