forked from old/legacy-imlib2
Add lzma loader
This commit is contained in:
parent
c880edac55
commit
503e8527c3
|
@ -210,6 +210,7 @@ loader_check_bz2() {
|
|||
}
|
||||
|
||||
EC_LOADER_CHECK(BZ2, auto, bzip2, loader_check_bz2)
|
||||
EC_LOADER_CHECK(LZMA, auto, liblzma)
|
||||
EC_LOADER_CHECK(ZLIB, auto, zlib)
|
||||
|
||||
EC_LOADER_CHECK(ID3, auto, id3tag)
|
||||
|
@ -277,6 +278,7 @@ echo " TIFF....................: $tiff_ok"
|
|||
echo " WEBP....................: $webp_ok"
|
||||
echo " Decompressors"
|
||||
echo " BZIP2...................: $bz2_ok"
|
||||
echo " LZMA(XZ)................: $lzma_ok"
|
||||
echo " ZLIB....................: $zlib_ok"
|
||||
echo " Containers"
|
||||
echo " ID3.....................: $id3_ok"
|
||||
|
|
|
@ -50,6 +50,9 @@ static const char *const ext_xpm[] = { "xpm", NULL };
|
|||
#ifdef BUILD_BZ2_LOADER
|
||||
static const char *const ext_bz2[] = { "bz2", NULL };
|
||||
#endif
|
||||
#ifdef BUILD_LZMA_LOADER
|
||||
static const char *const ext_lzma[] = { "xz", "lzma", NULL };
|
||||
#endif
|
||||
#ifdef BUILD_ZLIB_LOADER
|
||||
static const char *const ext_zlib[] = { "gz", NULL };
|
||||
#endif
|
||||
|
@ -86,6 +89,9 @@ static const KnownLoader loaders_known[] = {
|
|||
#ifdef BUILD_BZ2_LOADER
|
||||
{"bz2", ext_bz2},
|
||||
#endif
|
||||
#ifdef BUILD_LZMA_LOADER
|
||||
{"lzma", ext_lzma},
|
||||
#endif
|
||||
#ifdef BUILD_ZLIB_LOADER
|
||||
{"zlib", ext_zlib},
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,9 @@ endif
|
|||
if BUILD_BZ2_LOADER
|
||||
pkg_LTLIBRARIES += bz2.la
|
||||
endif
|
||||
if BUILD_LZMA_LOADER
|
||||
pkg_LTLIBRARIES += lzma.la
|
||||
endif
|
||||
if BUILD_ZLIB_LOADER
|
||||
pkg_LTLIBRARIES += zlib.la
|
||||
endif
|
||||
|
@ -123,6 +126,12 @@ bz2_la_LDFLAGS = -module -avoid-version
|
|||
bz2_la_LIBADD = $(BZ2_LIBS) $(top_builddir)/src/lib/libImlib2.la
|
||||
bz2_la_LIBTOOLFLAGS = --tag=disable-static
|
||||
|
||||
lzma_la_SOURCES = loader_lzma.c decompress_load.c
|
||||
lzma_la_CPPFLAGS = $(LZMA_CFLAGS) $(AM_CPPFLAGS)
|
||||
lzma_la_LDFLAGS = -module -avoid-version
|
||||
lzma_la_LIBADD = $(LZMA_LIBS) $(top_builddir)/src/lib/libImlib2.la
|
||||
lzma_la_LIBTOOLFLAGS = --tag=disable-static
|
||||
|
||||
zlib_la_SOURCES = loader_zlib.c decompress_load.c
|
||||
zlib_la_CPPFLAGS = $(ZLIB_CFLAGS) $(AM_CPPFLAGS)
|
||||
zlib_la_LDFLAGS = -module -avoid-version
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
#include "loader_common.h"
|
||||
|
||||
#include <lzma.h>
|
||||
|
||||
#define OUTBUF_SIZE 16484
|
||||
|
||||
static int
|
||||
uncompress_file(const void *fdata, unsigned int fsize, int dest)
|
||||
{
|
||||
int ok;
|
||||
lzma_stream strm = LZMA_STREAM_INIT;
|
||||
lzma_ret ret;
|
||||
uint8_t outbuf[OUTBUF_SIZE];
|
||||
unsigned int bytes;
|
||||
|
||||
ok = 0;
|
||||
|
||||
ret = lzma_auto_decoder(&strm, UINT64_MAX, 0);
|
||||
if (ret != LZMA_OK)
|
||||
return ok;
|
||||
|
||||
strm.next_in = fdata;
|
||||
strm.avail_in = fsize;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
strm.next_out = outbuf;
|
||||
strm.avail_out = sizeof(outbuf);
|
||||
|
||||
ret = lzma_code(&strm, 0);
|
||||
|
||||
if (ret != LZMA_OK && ret != LZMA_STREAM_END)
|
||||
goto quit;
|
||||
|
||||
bytes = sizeof(outbuf) - strm.avail_out;
|
||||
if (write(dest, outbuf, bytes) != bytes)
|
||||
goto quit;
|
||||
|
||||
if (ret == LZMA_STREAM_END)
|
||||
break;
|
||||
}
|
||||
|
||||
ok = 1;
|
||||
|
||||
quit:
|
||||
lzma_end(&strm);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static const char *const list_formats[] = { "xz", "lzma" };
|
||||
|
||||
int
|
||||
load2(ImlibImage * im, int load_data)
|
||||
{
|
||||
|
||||
return decompress_load(im, load_data, list_formats, ARRAY_SIZE(list_formats),
|
||||
uncompress_file);
|
||||
}
|
||||
|
||||
void
|
||||
formats(ImlibLoader * l)
|
||||
{
|
||||
__imlib_LoaderSetFormats(l, list_formats, ARRAY_SIZE(list_formats));
|
||||
}
|
Binary file not shown.
|
@ -3,6 +3,8 @@
|
|||
#include <Imlib2.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
int debug = 0;
|
||||
|
||||
#define D(...) if (debug) printf(__VA_ARGS__)
|
||||
|
@ -18,7 +20,6 @@ int debug = 0;
|
|||
static const char *const pfxs[] = {
|
||||
"argb",
|
||||
"bmp",
|
||||
"ff.bz2", // bz2
|
||||
"ff",
|
||||
"gif",
|
||||
"ico",
|
||||
|
@ -33,7 +34,15 @@ static const char *const pfxs[] = {
|
|||
"webp",
|
||||
"xbm",
|
||||
"xpm",
|
||||
#ifdef BUILD_BZ2_LOADER
|
||||
"ff.bz2", // bz2
|
||||
#endif
|
||||
#ifdef BUILD_ZLIB_LOADER
|
||||
"ff.gz", // zlib
|
||||
#endif
|
||||
#ifdef BUILD_LZMA_LOADER
|
||||
"ff.xz", // lzma
|
||||
#endif
|
||||
};
|
||||
#define N_PFX (sizeof(pfxs) / sizeof(char*))
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <fcntl.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
int debug = 0;
|
||||
|
||||
#define D(...) if (debug) printf(__VA_ARGS__)
|
||||
|
@ -24,7 +26,15 @@ static tii_t tii[] = {
|
|||
{ "icon-64.argb", 1153555547 },
|
||||
{ "icon-64.bmp", 1153555547 },
|
||||
{ "icon-64.ff", 1153555547 },
|
||||
#ifdef BUILD_BZ2_LOADER
|
||||
{ "icon-64.ff.bz2", 1153555547 },
|
||||
#endif
|
||||
#ifdef BUILD_ZLIB_LOADER
|
||||
{ "icon-64.ff.gz", 1153555547 },
|
||||
#endif
|
||||
#ifdef BUILD_LZMA_LOADER
|
||||
{ "icon-64.ff.xz", 1153555547 },
|
||||
#endif
|
||||
{ "icon-64.gif", 1768448874 },
|
||||
{ "icon-64.ico", 1153555547 },
|
||||
{ "icon-64.ilbm", 1153555547 },
|
||||
|
|
Loading…
Reference in New Issue