Skip to content
Snippets Groups Projects
Commit 785a3f36 authored by Guillem Jover's avatar Guillem Jover
Browse files

libdpkg: Switch dpkg_lzma_strerror() to use struct io_lzma

Instead of passing the dpkg_stream_action enum, pass the io_lzma struct,
so that we can use other members if needed.
parent 75d0fbec
No related branches found
No related tags found
1 merge request!4Update crimson to version from bookworm
......@@ -483,9 +483,22 @@ enum dpkg_stream_status {
DPKG_STREAM_FILTER = DPKG_STREAM_COMPRESS | DPKG_STREAM_DECOMPRESS,
};
struct io_lzma {
const char *desc;
struct compress_params *params;
enum dpkg_stream_status status;
lzma_action action;
void (*init)(struct io_lzma *io, lzma_stream *s);
int (*code)(struct io_lzma *io, lzma_stream *s);
void (*done)(struct io_lzma *io, lzma_stream *s);
};
/* XXX: liblzma does not expose error messages. */
static const char *
dpkg_lzma_strerror(lzma_ret code, enum dpkg_stream_status status)
dpkg_lzma_strerror(struct io_lzma *io, lzma_ret code)
{
const char *const impossible = _("internal error (bug)");
......@@ -493,29 +506,29 @@ dpkg_lzma_strerror(lzma_ret code, enum dpkg_stream_status status)
case LZMA_MEM_ERROR:
return strerror(ENOMEM);
case LZMA_MEMLIMIT_ERROR:
if (status & DPKG_STREAM_RUN)
if (io->status & DPKG_STREAM_RUN)
return _("memory usage limit reached");
return impossible;
case LZMA_OPTIONS_ERROR:
if (status == (DPKG_STREAM_INIT | DPKG_STREAM_COMPRESS))
if (io->status == (DPKG_STREAM_INIT | DPKG_STREAM_COMPRESS))
return _("unsupported compression preset");
if (status == (DPKG_STREAM_RUN | DPKG_STREAM_DECOMPRESS))
if (io->status == (DPKG_STREAM_RUN | DPKG_STREAM_DECOMPRESS))
return _("unsupported options in file header");
return impossible;
case LZMA_DATA_ERROR:
if (status & DPKG_STREAM_RUN)
if (io->status & DPKG_STREAM_RUN)
return _("compressed data is corrupt");
return impossible;
case LZMA_BUF_ERROR:
if (status & DPKG_STREAM_RUN)
if (io->status & DPKG_STREAM_RUN)
return _("unexpected end of input");
return impossible;
case LZMA_FORMAT_ERROR:
if (status == (DPKG_STREAM_RUN | DPKG_STREAM_DECOMPRESS))
if (io->status == (DPKG_STREAM_RUN | DPKG_STREAM_DECOMPRESS))
return _("file format not recognized");
return impossible;
case LZMA_UNSUPPORTED_CHECK:
if (status == (DPKG_STREAM_INIT | DPKG_STREAM_COMPRESS))
if (io->status == (DPKG_STREAM_INIT | DPKG_STREAM_COMPRESS))
return _("unsupported type of integrity check");
return impossible;
default:
......@@ -523,18 +536,6 @@ dpkg_lzma_strerror(lzma_ret code, enum dpkg_stream_status status)
}
}
struct io_lzma {
const char *desc;
struct compress_params *params;
enum dpkg_stream_status status;
lzma_action action;
void (*init)(struct io_lzma *io, lzma_stream *s);
int (*code)(struct io_lzma *io, lzma_stream *s);
void (*done)(struct io_lzma *io, lzma_stream *s);
};
static void
filter_lzma(struct io_lzma *io, int fd_in, int fd_out)
{
......@@ -592,7 +593,7 @@ static void DPKG_ATTR_NORET
filter_lzma_error(struct io_lzma *io, lzma_ret ret)
{
ohshit(_("%s: lzma error: %s"), io->desc,
dpkg_lzma_strerror(ret, io->status));
dpkg_lzma_strerror(io, ret));
}
#ifdef HAVE_LZMA_MT_ENCODER
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment